Pass app as a parcel to AppDetailsFragment

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2023-07-06 10:56:51 +05:30
parent edba1100b3
commit f7c8c8d6cb
3 changed files with 17 additions and 33 deletions

View File

@@ -41,7 +41,7 @@ open class BaseFragment : Fragment {
fun openDetailsFragment(app: App) { fun openDetailsFragment(app: App) {
findNavController().navigate( findNavController().navigate(
MobileNavigationDirections.actionGlobalAppDetailsFragment(app.packageName) MobileNavigationDirections.actionGlobalAppDetailsFragment(app.packageName, app)
) )
} }

View File

@@ -254,10 +254,17 @@ class AppDetailsFragment : BaseFragment(R.layout.fragment_details) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
_binding = FragmentDetailsBinding.bind(view) _binding = FragmentDetailsBinding.bind(view)
// TODO: Parcel app class to better handle onNewIntent fun if (args.app != null) {
isExternal = true app = args.app!!
app = App(args.packageName) isInstalled = PackageUtil.isInstalled(requireContext(), app.packageName)
fetchCompleteApp()
inflatePartialApp()
fetchCompleteApp()
} else {
isExternal = true
app = App(args.packageName)
fetchCompleteApp()
}
// Toolbar // Toolbar
binding.layoutDetailsToolbar.toolbar.apply { binding.layoutDetailsToolbar.toolbar.apply {
@@ -312,34 +319,6 @@ class AppDetailsFragment : BaseFragment(R.layout.fragment_details) {
super.onResume() super.onResume()
} }
private fun onNewIntent(intent: Intent) {
if (intent.scheme != null && (intent.scheme == "market" || intent.scheme == "http" || intent.scheme == "https")) {
val packageName = intent.data!!.getQueryParameter("id")
val packageVersion = intent.data!!.getQueryParameter("v")
if (packageName.isNullOrEmpty()) {
activity?.finishAfterTransition()
} else {
isExternal = true
app = App(packageName)
if (!packageVersion.isNullOrEmpty()) {
app.versionCode = packageVersion.toInt()
}
fetchCompleteApp()
}
} else {
val rawApp: String? = intent.getStringExtra(Constants.STRING_EXTRA)
if (rawApp != null) {
app = gson.fromJson(rawApp, App::class.java)
isInstalled = PackageUtil.isInstalled(requireContext(), app.packageName)
inflatePartialApp()
fetchCompleteApp()
} else {
activity?.finishAfterTransition()
}
}
}
private fun attachActions() { private fun attachActions() {
flip(0) flip(0)
checkAndSetupInstall() checkAndSetupInstall()

View File

@@ -120,6 +120,11 @@
<action <action
android:id="@+id/action_appDetailsFragment_to_detailsExodusFragment" android:id="@+id/action_appDetailsFragment_to_detailsExodusFragment"
app:destination="@id/detailsExodusFragment" /> app:destination="@id/detailsExodusFragment" />
<argument
android:name="app"
app:argType="com.aurora.gplayapi.data.models.App"
app:nullable="true"
android:defaultValue="@null" />
</fragment> </fragment>
<fragment <fragment
android:id="@+id/categoryBrowseFragment" android:id="@+id/categoryBrowseFragment"