Fix loading repositories from browser

This commit is contained in:
Blatzar 2022-08-15 17:03:06 +02:00
parent 5a351e1fe3
commit 7eb0c83dc5
3 changed files with 44 additions and 17 deletions

View file

@ -40,7 +40,9 @@
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
android:value="com.lagradost.cloudstream3.utils.CastOptionsProvider" />
<profileable android:shell="true" tools:targetApi="q" />
<profileable
android:shell="true"
tools:targetApi="q" />
<activity
android:name=".ui.player.DownloadedPlayerActivity"
@ -64,11 +66,16 @@
<data android:mimeType="*/*" />
</intent-filter>
</activity>
<!--
android:launchMode="singleTask"
is a bit experimental, it makes loading repositories from browser still stay on the same page
no idea about side effects
-->
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
android:exported="true"
android:launchMode="singleTask"
android:resizeableActivity="true"
android:supportsPictureInPicture="true">
<intent-filter android:exported="true">

View file

@ -16,6 +16,7 @@ import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
import com.lagradost.cloudstream3.AcraApplication.Companion.openBrowser
import com.lagradost.cloudstream3.CommonActivity.showToast
import com.lagradost.cloudstream3.MainActivity.Companion.afterRepositoryLoadedEvent
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.mvvm.Some
import com.lagradost.cloudstream3.mvvm.observe
@ -51,6 +52,21 @@ class ExtensionsFragment : Fragment() {
private val extensionViewModel: ExtensionsViewModel by activityViewModels()
override fun onResume() {
super.onResume()
afterRepositoryLoadedEvent += ::reloadRepositories
}
override fun onStop() {
super.onStop()
afterRepositoryLoadedEvent -= ::reloadRepositories
}
private fun reloadRepositories(success: Boolean = true) {
extensionViewModel.loadStats()
extensionViewModel.loadRepositories()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
//context?.fixPaddingStatusbar(extensions_root)
@ -160,6 +176,7 @@ class ExtensionsFragment : Fragment() {
dialog.repo_url_input?.setText(fixedUrl)
}
}
dialog.list_repositories?.setOnClickListener {
openBrowser(PUBLIC_REPOSITORIES_LIST)
}
@ -189,7 +206,6 @@ class ExtensionsFragment : Fragment() {
}
}
extensionViewModel.loadStats()
extensionViewModel.loadRepositories()
reloadRepositories()
}
}

View file

@ -15,6 +15,7 @@ import com.lagradost.cloudstream3.plugins.RepositoryManager.PREBUILT_REPOSITORIE
import com.lagradost.cloudstream3.ui.settings.extensions.PUBLIC_REPOSITORIES_LIST
import com.lagradost.cloudstream3.ui.settings.extensions.PluginsViewModel
import com.lagradost.cloudstream3.ui.settings.extensions.RepoAdapter
import com.lagradost.cloudstream3.utils.Coroutines.main
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
import kotlinx.android.synthetic.main.fragment_extensions.*
import kotlinx.android.synthetic.main.fragment_setup_media.*
@ -52,18 +53,20 @@ class SetupFragmentExtensions : Fragment() {
}
private fun setRepositories(success: Boolean = true) {
val repositories = RepositoryManager.getRepositories() + PREBUILT_REPOSITORIES
val hasRepos = repositories.isNotEmpty()
repo_recycler_view?.isVisible = hasRepos
blank_repo_screen?.isVisible = !hasRepos
main {
val repositories = RepositoryManager.getRepositories() + PREBUILT_REPOSITORIES
val hasRepos = repositories.isNotEmpty()
repo_recycler_view?.isVisible = hasRepos
blank_repo_screen?.isVisible = !hasRepos
if (hasRepos) {
repo_recycler_view?.adapter = RepoAdapter(true, {}, {
PluginsViewModel.downloadAll(activity, it.url, null)
}).apply { updateList(repositories) }
} else {
list_repositories?.setOnClickListener {
openBrowser(PUBLIC_REPOSITORIES_LIST)
if (hasRepos) {
repo_recycler_view?.adapter = RepoAdapter(true, {}, {
PluginsViewModel.downloadAll(activity, it.url, null)
}).apply { updateList(repositories) }
} else {
list_repositories?.setOnClickListener {
openBrowser(PUBLIC_REPOSITORIES_LIST)
}
}
}
}
@ -84,14 +87,15 @@ class SetupFragmentExtensions : Fragment() {
next_btt?.setOnClickListener {
// Continue setup
println("ISSETUP $isSetup")
if (isSetup)
findNavController().navigate(R.id.action_navigation_setup_extensions_to_navigation_setup_provider_languages)
else
findNavController().popBackStack()
findNavController().navigate(R.id.navigation_home)
}
prev_btt?.setOnClickListener {
findNavController().popBackStack()
findNavController().navigate(R.id.navigation_setup_language)
}
}
}