DO NOT MERGE: Migrate ExpandedStreamBrowseActivity to fragment
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -114,7 +114,6 @@
|
||||
<activity android:name=".view.ui.account.GoogleActivity" />
|
||||
<activity android:name=".view.ui.details.DetailsExodusActivity" />
|
||||
<activity android:name=".view.ui.details.DevAppsActivity" />
|
||||
<activity android:name=".view.ui.commons.ExpandedStreamBrowseActivity" />
|
||||
|
||||
<service android:name=".data.service.NotificationService" />
|
||||
<service android:name=".data.installer.InstallerService" />
|
||||
|
||||
@@ -74,7 +74,7 @@ abstract class BaseActivity : AppCompatActivity(), NetworkProvider.NetworkListen
|
||||
|
||||
fun openStreamBrowseActivity(browseUrl: String, title: String = "") {
|
||||
val intent = if (browseUrl.lowercase().contains("expanded")) {
|
||||
Intent(this, ExpandedStreamBrowseActivity::class.java)
|
||||
Intent(this, ExpandedStreamBrowseFragment::class.java)
|
||||
} else if (browseUrl.lowercase().contains("developer")) {
|
||||
Intent(this, DevProfileActivity::class.java)
|
||||
} else {
|
||||
|
||||
@@ -59,16 +59,23 @@ open class BaseFragment : Fragment {
|
||||
}
|
||||
|
||||
fun openStreamBrowseActivity(browseUrl: String, title: String = "") {
|
||||
val intent = if (browseUrl.lowercase().contains("expanded"))
|
||||
Intent(requireContext(), ExpandedStreamBrowseActivity::class.java)
|
||||
else if (browseUrl.lowercase().contains("developer"))
|
||||
Intent(requireContext(), DevProfileActivity::class.java)
|
||||
else
|
||||
Intent(requireContext(), StreamBrowseActivity::class.java)
|
||||
if (browseUrl.lowercase().contains("expanded")) {
|
||||
findNavController().navigate(
|
||||
MobileNavigationDirections.actionGlobalExpandedStreamBrowseFragment(
|
||||
title,
|
||||
browseUrl
|
||||
)
|
||||
)
|
||||
} else {
|
||||
val intent = if (browseUrl.lowercase().contains("developer"))
|
||||
Intent(requireContext(), DevProfileActivity::class.java)
|
||||
else
|
||||
Intent(requireContext(), StreamBrowseActivity::class.java)
|
||||
|
||||
intent.putExtra(Constants.BROWSE_EXTRA, browseUrl)
|
||||
intent.putExtra(Constants.STRING_EXTRA, title)
|
||||
startActivity(intent, requireContext().getEmptyActivityBundle())
|
||||
intent.putExtra(Constants.BROWSE_EXTRA, browseUrl)
|
||||
intent.putExtra(Constants.STRING_EXTRA, title)
|
||||
startActivity(intent, requireContext().getEmptyActivityBundle())
|
||||
}
|
||||
}
|
||||
|
||||
fun openEditorStreamBrowseActivity(browseUrl: String, title: String = "") {
|
||||
|
||||
@@ -20,10 +20,14 @@
|
||||
package com.aurora.store.view.ui.commons
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import com.airbnb.epoxy.EpoxyModel
|
||||
import com.aurora.Constants
|
||||
import com.aurora.gplayapi.data.models.StreamCluster
|
||||
import com.aurora.store.MainActivity
|
||||
import com.aurora.store.R
|
||||
import com.aurora.store.databinding.ActivityGenericRecyclerBinding
|
||||
import com.aurora.store.view.custom.recycler.EndlessRecyclerOnScrollListener
|
||||
import com.aurora.store.view.epoxy.groups.CarouselHorizontalModel_
|
||||
@@ -35,69 +39,53 @@ import com.aurora.store.view.epoxy.views.shimmer.AppListViewShimmerModel_
|
||||
import com.aurora.store.viewmodel.browse.ExpandedStreamBrowseViewModel
|
||||
|
||||
|
||||
class ExpandedStreamBrowseActivity : BaseActivity() {
|
||||
class ExpandedStreamBrowseFragment : BaseFragment(R.layout.activity_generic_recycler) {
|
||||
|
||||
private var _binding: ActivityGenericRecyclerBinding? = null
|
||||
private val binding: ActivityGenericRecyclerBinding
|
||||
get() = _binding!!
|
||||
|
||||
private val args: ExpandedStreamBrowseFragmentArgs by navArgs()
|
||||
|
||||
lateinit var B: ActivityGenericRecyclerBinding
|
||||
lateinit var VM: ExpandedStreamBrowseViewModel
|
||||
|
||||
lateinit var endlessRecyclerOnScrollListener: EndlessRecyclerOnScrollListener
|
||||
|
||||
lateinit var title: String
|
||||
lateinit var cluster: StreamCluster
|
||||
|
||||
override fun onConnected() {
|
||||
hideNetworkConnectivitySheet()
|
||||
}
|
||||
|
||||
override fun onDisconnected() {
|
||||
showNetworkConnectivitySheet()
|
||||
}
|
||||
|
||||
override fun onReconnected() {
|
||||
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
B = ActivityGenericRecyclerBinding.inflate(layoutInflater)
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
_binding = ActivityGenericRecyclerBinding.bind(view)
|
||||
VM = ViewModelProvider(this)[ExpandedStreamBrowseViewModel::class.java]
|
||||
|
||||
setContentView(B.root)
|
||||
|
||||
attachToolbar()
|
||||
|
||||
VM.liveData.observe(this) {
|
||||
if (!::cluster.isInitialized)
|
||||
attachRecycler()
|
||||
// Toolbar
|
||||
binding.layoutToolbarAction.apply {
|
||||
txtTitle.text = args.title
|
||||
imgActionPrimary.setOnClickListener {
|
||||
findNavController().navigateUp()
|
||||
}
|
||||
}
|
||||
|
||||
VM.liveData.observe(viewLifecycleOwner) {
|
||||
if (!::cluster.isInitialized) attachRecycler()
|
||||
cluster = it
|
||||
|
||||
updateController(cluster)
|
||||
updateTitle(cluster)
|
||||
}
|
||||
|
||||
intent.apply {
|
||||
getStringExtra(Constants.BROWSE_EXTRA)?.let {
|
||||
VM.getInitialCluster(it)
|
||||
}
|
||||
getStringExtra(Constants.STRING_EXTRA)?.let {
|
||||
B.layoutToolbarAction.txtTitle.text = it
|
||||
}
|
||||
}
|
||||
|
||||
VM.getInitialCluster(args.expandedStreamUrl)
|
||||
updateController(null)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}
|
||||
|
||||
private fun updateTitle(streamCluster: StreamCluster) {
|
||||
if (streamCluster.clusterTitle.isNotEmpty())
|
||||
B.layoutToolbarAction.txtTitle.text = streamCluster.clusterTitle
|
||||
}
|
||||
|
||||
private fun attachToolbar() {
|
||||
B.layoutToolbarAction.imgActionPrimary.setOnClickListener {
|
||||
finishAfterTransition()
|
||||
}
|
||||
binding.layoutToolbarAction.txtTitle.text = streamCluster.clusterTitle
|
||||
}
|
||||
|
||||
private fun attachRecycler() {
|
||||
@@ -106,11 +94,11 @@ class ExpandedStreamBrowseActivity : BaseActivity() {
|
||||
VM.next()
|
||||
}
|
||||
}
|
||||
B.recycler.addOnScrollListener(endlessRecyclerOnScrollListener)
|
||||
binding.recycler.addOnScrollListener(endlessRecyclerOnScrollListener)
|
||||
}
|
||||
|
||||
private fun updateController(streamCluster: StreamCluster?) {
|
||||
B.recycler.withModels {
|
||||
binding.recycler.withModels {
|
||||
setFilterDuplicates(true)
|
||||
if (streamCluster == null) {
|
||||
for (i in 1..6) {
|
||||
@@ -131,7 +119,10 @@ class ExpandedStreamBrowseActivity : BaseActivity() {
|
||||
.artwork(artwork)
|
||||
.callback(object : MiniScreenshotView.ScreenshotCallback {
|
||||
override fun onClick(position: Int) {
|
||||
openScreenshotActivity(it, position)
|
||||
(activity as MainActivity).openScreenshotActivity(
|
||||
it,
|
||||
position
|
||||
)
|
||||
}
|
||||
})
|
||||
)
|
||||
@@ -130,6 +130,16 @@
|
||||
android:name="browseUrl"
|
||||
app:argType="string" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/expandedStreamBrowseFragment"
|
||||
android:name="com.aurora.store.view.ui.commons.ExpandedStreamBrowseFragment"
|
||||
tools:layout="@layout/activity_generic_recycler" >
|
||||
<argument android:name="title"
|
||||
app:argType="string" />
|
||||
<argument
|
||||
android:name="expandedStreamUrl"
|
||||
app:argType="string" />
|
||||
</fragment>
|
||||
<action
|
||||
android:id="@+id/action_global_appDetailsFragment"
|
||||
app:destination="@id/appDetailsFragment" />
|
||||
@@ -139,4 +149,7 @@
|
||||
<action
|
||||
android:id="@+id/action_global_editorStreamBrowseFragment"
|
||||
app:destination="@id/editorStreamBrowseFragment" />
|
||||
<action
|
||||
android:id="@+id/action_global_expandedStreamBrowseFragment"
|
||||
app:destination="@id/expandedStreamBrowseFragment" />
|
||||
</navigation>
|
||||
|
||||
Reference in New Issue
Block a user