From 6ed9e8458fb1117208530ee486c15c9731eae97a Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Sun, 13 Jun 2021 20:51:22 -0400 Subject: [PATCH] initialize downloadutils on launch --- .../awais/instagrabber/activities/MainActivity.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/main/java/awais/instagrabber/activities/MainActivity.kt b/app/src/main/java/awais/instagrabber/activities/MainActivity.kt index 90be552a..adb1e728 100644 --- a/app/src/main/java/awais/instagrabber/activities/MainActivity.kt +++ b/app/src/main/java/awais/instagrabber/activities/MainActivity.kt @@ -8,6 +8,7 @@ import android.content.ComponentName import android.content.Intent import android.content.ServiceConnection import android.os.* +import android.provider.DocumentsContract.EXTRA_INITIAL_URI import android.text.Editable import android.util.Log import android.view.Menu @@ -53,6 +54,7 @@ import awais.instagrabber.services.ActivityCheckerService import awais.instagrabber.services.DMSyncAlarmReceiver import awais.instagrabber.utils.* import awais.instagrabber.utils.AppExecutors.tasksThread +import awais.instagrabber.utils.DownloadUtils.ReselectDocumentTreeException import awais.instagrabber.utils.TextUtils.isEmpty import awais.instagrabber.utils.TextUtils.shortcodeToId import awais.instagrabber.utils.emoji.EmojiParser @@ -73,6 +75,7 @@ import kotlinx.coroutines.withContext import java.util.* import java.util.stream.Collectors + class MainActivity : BaseLanguageActivity(), FragmentManager.OnBackStackChangedListener { private lateinit var binding: ActivityMainBinding @@ -107,6 +110,16 @@ class MainActivity : BaseLanguageActivity(), FragmentManager.OnBackStackChangedL private val graphQLRepository: GraphQLRepository by lazy { GraphQLRepository.getInstance() } override fun onCreate(savedInstanceState: Bundle?) { + try { + DownloadUtils.init(this) + } catch (e: ReselectDocumentTreeException) { + super.onCreate(savedInstanceState) + val intent = Intent(this, DirectorySelectActivity::class.java) + intent.putExtra(EXTRA_INITIAL_URI, e.initialUri) + startActivity(intent) + finish() + return + } super.onCreate(savedInstanceState) instance = this binding = ActivityMainBinding.inflate(layoutInflater)