Skip to content

Commit

Permalink
rough outline for downloading anime
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelonion committed Dec 28, 2023
1 parent 42c3b42 commit c964975
Show file tree
Hide file tree
Showing 11 changed files with 643 additions and 26 deletions.
8 changes: 6 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,9 @@
android:exported="true" />
<service
android:name=".download.video.MyDownloadService"
android:exported="false">
<intent-filter>
android:exported="false"
android:foregroundServiceType="dataSync">
<intent-filter>
<action android:name="androidx.media3.exoplayer.downloadService.action.RESTART" />

<category android:name="android.intent.category.DEFAULT" />
Expand All @@ -297,6 +298,9 @@
android:name=".download.novel.NovelDownloaderService"
android:exported="false"
android:foregroundServiceType="dataSync" />
<service android:name=".download.anime.AnimeDownloaderService"
android:exported="false"
android:foregroundServiceType="dataSync" />
<service
android:name=".connections.discord.DiscordService"
android:exported="false"
Expand Down
22 changes: 21 additions & 1 deletion app/src/main/java/ani/dantotsu/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.provider.Settings
import android.util.Log
import android.view.View
import android.view.ViewGroup
import android.view.animation.AnticipateInterpolator
import android.widget.TextView
import androidx.activity.addCallback
import androidx.activity.viewModels
import androidx.annotation.OptIn
import androidx.appcompat.app.AppCompatActivity
import androidx.core.animation.doOnEnd
import androidx.core.content.ContextCompat
Expand All @@ -26,11 +28,13 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.media3.common.util.UnstableApi
import androidx.viewpager2.adapter.FragmentStateAdapter
import ani.dantotsu.connections.anilist.Anilist
import ani.dantotsu.connections.anilist.AnilistHomeViewModel
import ani.dantotsu.databinding.ActivityMainBinding
import ani.dantotsu.databinding.SplashScreenBinding
import ani.dantotsu.download.video.Helper
import ani.dantotsu.home.AnimeFragment
import ani.dantotsu.home.HomeFragment
import ani.dantotsu.home.LoginFragment
Expand All @@ -45,6 +49,7 @@ import ani.dantotsu.themes.ThemeManager
import io.noties.markwon.Markwon
import io.noties.markwon.SoftBreakAddsNewLinePlugin
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
Expand All @@ -60,7 +65,7 @@ class MainActivity : AppCompatActivity() {
private var uiSettings = UserInterfaceSettings()


override fun onCreate(savedInstanceState: Bundle?) {
@OptIn(UnstableApi::class) override fun onCreate(savedInstanceState: Bundle?) {
ThemeManager(this).applyTheme()
LangSet.setLocale(this)
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -242,6 +247,21 @@ class MainActivity : AppCompatActivity() {
}
}

GlobalScope.launch(Dispatchers.IO) {
val index = Helper.downloadManager(this@MainActivity).downloadIndex
if (index != null) {
val downloadCursor = index.getDownloads()
if (downloadCursor != null) {
while (downloadCursor.moveToNext()) {
val download = downloadCursor.download
Log.e("Downloader", download.request.uri.toString())
Log.e("Downloader", download.request.id.toString())
Log.e("Downloader", download.request.mimeType.toString())
}
}
}
}

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ package ani.dantotsu.aniyomi.anime.custom

import android.app.Application
import android.content.Context
import androidx.annotation.OptIn
import androidx.core.content.ContextCompat
import androidx.media3.common.util.UnstableApi
import androidx.media3.database.StandaloneDatabaseProvider
import androidx.media3.datasource.cache.SimpleCache
import ani.dantotsu.download.DownloadsManager
import ani.dantotsu.media.manga.MangaCache
import ani.dantotsu.parsers.novel.NovelExtensionManager
Expand All @@ -27,7 +31,7 @@ import uy.kohesive.injekt.api.addSingletonFactory
import uy.kohesive.injekt.api.get

class AppModule(val app: Application) : InjektModule {
override fun InjektRegistrar.registerInjectables() {
@OptIn(UnstableApi::class) override fun InjektRegistrar.registerInjectables() {
addSingleton(app)

addSingletonFactory { DownloadsManager(app) }
Expand All @@ -51,6 +55,8 @@ class AppModule(val app: Application) : InjektModule {
}
}

addSingletonFactory { StandaloneDatabaseProvider(app) }

addSingletonFactory { MangaCache() }

ContextCompat.getMainExecutor(app).execute {
Expand Down
Loading

0 comments on commit c964975

Please sign in to comment.