infinite loading in shop module.
Improvements in infinite loading in all modules. Error handling for live tv when use comes back to home in case of error. Text changes. and removal of continue as guest text.
This commit is contained in:
@@ -8,7 +8,7 @@ import android.graphics.drawable.InsetDrawable
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.Html
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
@@ -173,9 +173,12 @@ class AudioBooksActivity : WokaBaseActivity() {
|
||||
|
||||
val percentageScrolled = (scrolledHeight.toFloat()/totalHeight.toFloat()) * 100
|
||||
|
||||
if (percentageScrolled >= 60) {
|
||||
if (percentageScrolled == 100f) {
|
||||
if (!isLoading && !viewModel.lastPage && isNetworkConnected()){
|
||||
isLoading = true
|
||||
binding.loadMoreProgress.post {
|
||||
binding.nestedScrollView.fullScroll(View.FOCUS_DOWN)
|
||||
}
|
||||
viewModel.loadAudioSongs()
|
||||
}
|
||||
}
|
||||
@@ -301,6 +304,9 @@ class AudioBooksActivity : WokaBaseActivity() {
|
||||
} else {
|
||||
// loading more data
|
||||
binding.loadMoreProgress.show()
|
||||
binding.loadMoreProgress.post {
|
||||
binding.nestedScrollView.fullScroll(View.FOCUS_DOWN)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -192,7 +192,11 @@ class Home1Fragment : Fragment() {
|
||||
viewModel.player?.play()
|
||||
}
|
||||
|
||||
binding.playerView.show()
|
||||
if (viewModel.errorRetryCount == 0){
|
||||
viewModel.reloadPlayer()
|
||||
}
|
||||
|
||||
binding.playerView.show()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
||||
@@ -119,6 +119,10 @@ class Home2Fragment : Fragment() {
|
||||
viewModel.player?.play()
|
||||
}
|
||||
|
||||
if (viewModel.errorRetryCount == 0){
|
||||
viewModel.reloadPlayer()
|
||||
}
|
||||
|
||||
binding.playerView.show()
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.google.android.gms.ads.AdSize
|
||||
import com.google.android.gms.ads.AdView
|
||||
import com.jwplayer.pub.api.media.playlists.PlaylistItem
|
||||
import com.woka.R
|
||||
import com.woka.WokaApp
|
||||
import com.woka.WokaApp.Companion.userPrefs
|
||||
import com.woka.advertisements.AdsRepository
|
||||
import com.woka.advertisements.models.ForPage
|
||||
@@ -940,16 +941,27 @@ class MyListFragment : Fragment() {
|
||||
watchCard.setOnClickListener {
|
||||
activity?.let { activity ->
|
||||
gameData.game_url?.let {
|
||||
startActivity(Intent(activity, GamePlayerActivity::class.java).apply {
|
||||
putExtra(
|
||||
GamePlayerActivity.EXTRA_GAME_PLAYER_DATA,
|
||||
GamePlayerData(
|
||||
gameData.id,
|
||||
it,
|
||||
gameData.screen_orientation == "Landscape"
|
||||
)
|
||||
)
|
||||
})
|
||||
lifecycleScope.launch {
|
||||
AdsRepository.getADs()?.let { ads ->
|
||||
val fmAds = ads.filter { it.slug == ForPage.GAME_INTERSTITIAL.value }
|
||||
|
||||
if (fmAds.isNotEmpty()){
|
||||
fmAds.first().google_ad?.let {_ ->
|
||||
WokaApp.interstitialAds?.showNewAd(activity){
|
||||
startActivity(Intent(activity, GamePlayerActivity::class.java).apply {
|
||||
putExtra(GamePlayerActivity.EXTRA_GAME_PLAYER_DATA, GamePlayerData(gameData.id, it, gameData.screen_orientation == "Landscape"))
|
||||
})
|
||||
}
|
||||
|
||||
return@launch
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
startActivity(Intent(activity, GamePlayerActivity::class.java).apply {
|
||||
putExtra(GamePlayerActivity.EXTRA_GAME_PLAYER_DATA, GamePlayerData(gameData.id, it, gameData.screen_orientation == "Landscape"))
|
||||
})
|
||||
}
|
||||
|
||||
clickHelper.upsertClickEvent(ContentType.GAME, gameData.id)
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.Html
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
@@ -174,10 +175,13 @@ class KaraokeActivity : WokaBaseActivity() {
|
||||
|
||||
val percentageScrolled = (scrolledHeight.toFloat()/totalHeight.toFloat()) * 100
|
||||
|
||||
if (percentageScrolled >= 60) {
|
||||
if (percentageScrolled == 100f) {
|
||||
if (!isLoading && !viewModel.lastPage && isNetworkConnected()){
|
||||
Log.d("infinite_scroll", "LOAD MORE")
|
||||
isLoading = true
|
||||
binding.loadMoreProgress.post {
|
||||
binding.nestedScrollView.fullScroll(View.FOCUS_DOWN)
|
||||
}
|
||||
viewModel.loadKaraokeSongs()
|
||||
}
|
||||
}
|
||||
@@ -528,6 +532,9 @@ class KaraokeActivity : WokaBaseActivity() {
|
||||
} else {
|
||||
// loading more data
|
||||
binding.loadMoreProgress.show()
|
||||
binding.loadMoreProgress.post {
|
||||
binding.nestedScrollView.fullScroll(View.FOCUS_DOWN)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,6 @@ class LanguageFragment : Fragment() {
|
||||
is ApiResult.Loading -> {}
|
||||
is ApiResult.Success -> {
|
||||
progressView.hide()
|
||||
toast(response.message)
|
||||
requireActivity().changeLocale(locale)
|
||||
|
||||
response.data?.let {
|
||||
|
||||
@@ -160,7 +160,6 @@ class SignInFragment : Fragment() {
|
||||
is ApiResult.Success -> {
|
||||
progressView.hide()
|
||||
it.data?.let {data ->
|
||||
toast(it.message)
|
||||
|
||||
userPrefs?.userType = UserType.GUEST
|
||||
userPrefs?.guestUserName = data.fullname
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.woka.shop.adapters.ShopProductAdapter
|
||||
import com.woka.shop.viewmodels.ShopViewModel
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.isNetworkConnected
|
||||
import com.woka.utils.setVisibility
|
||||
import com.woka.utils.show
|
||||
|
||||
class ShopFragment3 : Fragment(), TabLayout.OnTabSelectedListener {
|
||||
@@ -36,7 +35,7 @@ class ShopFragment3 : Fragment(), TabLayout.OnTabSelectedListener {
|
||||
private val categoryId: String by lazy { args.categoryId }
|
||||
private val categoryName: String by lazy { args.categoryName }
|
||||
|
||||
private var loadMoreProducts = false
|
||||
private var isLoadMoreProducts = false
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
@@ -45,7 +44,7 @@ class ShopFragment3 : Fragment(), TabLayout.OnTabSelectedListener {
|
||||
binding = FragmentShop3Binding.inflate(inflater, container, false)
|
||||
viewModel = ViewModelProvider(requireActivity())[ShopViewModel::class.java]
|
||||
productAdapter = ShopProductAdapter()
|
||||
loadMoreProducts = false
|
||||
isLoadMoreProducts = false
|
||||
return binding.root
|
||||
}
|
||||
|
||||
@@ -88,21 +87,21 @@ class ShopFragment3 : Fragment(), TabLayout.OnTabSelectedListener {
|
||||
val totalItemCount = layoutManager.itemCount
|
||||
val firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition()
|
||||
|
||||
val subCategoryId = categoryTabs.getTabAt(categoryTabs.selectedTabPosition)?.tag
|
||||
val subCategoryId = categoryTabs.getTabAt(categoryTabs.selectedTabPosition)?.tag?.toString()
|
||||
|
||||
if ((viewModel.productPagingData["${superCategoryId}_${categoryId}_$subCategoryId"]?.nextPageToLoad?:0) > 0
|
||||
&& !loadMoreProducts
|
||||
&& !isLoadMoreProducts
|
||||
&& viewModel.productPagingData["${superCategoryId}_${categoryId}_$subCategoryId"]?.lastPage == false
|
||||
&& context?.isNetworkConnected() == true) {
|
||||
if (visibleItemCount + firstVisibleItemPosition >= totalItemCount
|
||||
&& firstVisibleItemPosition >= 0
|
||||
) {
|
||||
Log.d("infinite_scroll", "LOAD MORE ${!loadMoreProducts}")
|
||||
loadMoreProducts = true
|
||||
Log.d("infinite_scroll", "LOAD MORE ${!isLoadMoreProducts}")
|
||||
isLoadMoreProducts = true
|
||||
viewModel.loadMoreProducts(
|
||||
superCategoryId,
|
||||
categoryId,
|
||||
"$subCategoryId"
|
||||
subCategoryId
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -133,7 +132,6 @@ class ShopFragment3 : Fragment(), TabLayout.OnTabSelectedListener {
|
||||
if (selectedTabPos >= 0) {
|
||||
viewModel.subcategoryDataMap["${superCategoryId}_$categoryId"]?.let { subCategories ->
|
||||
if (selectedTabPos < subCategories.size) {
|
||||
loadMoreProducts = false
|
||||
viewModel.loadProducts(superCategoryId, categoryId, subCategories[selectedTabPos].id?.toString())
|
||||
|
||||
ClicksHelper.upsertClickEvent(ContentType.SHOP_PRODUCT, subCategories[selectedTabPos].id)
|
||||
@@ -180,21 +178,23 @@ class ShopFragment3 : Fragment(), TabLayout.OnTabSelectedListener {
|
||||
viewModel.productListingLiveData.observe(viewLifecycleOwner){
|
||||
when (it) {
|
||||
is ApiResult.Error -> {
|
||||
if (!loadMoreProducts){
|
||||
if (!isLoadMoreProducts){
|
||||
rvProducts.hide()
|
||||
}
|
||||
loadMoreProducts = false
|
||||
isLoadMoreProducts = false
|
||||
}
|
||||
|
||||
is ApiResult.Loading -> {
|
||||
binding.rvProducts.setVisibility(loadMoreProducts)
|
||||
if (isLoadMoreProducts){
|
||||
rvProducts.show()
|
||||
}
|
||||
}
|
||||
|
||||
is ApiResult.Success -> {
|
||||
it.data?.let { productList ->
|
||||
binding.rvProducts.show()
|
||||
|
||||
if (loadMoreProducts) {
|
||||
if (isLoadMoreProducts) {
|
||||
// loaded more data
|
||||
productAdapter.notifyItemRangeInserted(
|
||||
productAdapter.currentList.size,
|
||||
@@ -214,7 +214,7 @@ class ShopFragment3 : Fragment(), TabLayout.OnTabSelectedListener {
|
||||
}
|
||||
}
|
||||
|
||||
loadMoreProducts = false
|
||||
isLoadMoreProducts = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,13 +176,16 @@ class WebShowFragment : Fragment(), TabLayout.OnTabSelectedListener {
|
||||
|
||||
val percentageScrolled = (scrolledHeight.toFloat()/totalHeight.toFloat()) * 100
|
||||
|
||||
if (percentageScrolled >= 80) {
|
||||
if (percentageScrolled == 100f) {
|
||||
if (viewModel.episodesNextPageToLoad > 0
|
||||
&& !isLoadingMoreEpisodes
|
||||
&& !viewModel.episodesLastPage
|
||||
&& context?.isNetworkConnected() == true){
|
||||
Log.d("infinite_scroll", "LOAD MORE")
|
||||
isLoadingMoreEpisodes = true
|
||||
binding.loadMoreProgress.post {
|
||||
binding.nestedScrollView.fullScroll(View.FOCUS_DOWN)
|
||||
}
|
||||
viewModel.loadEpisodes("${showData.id}", selectedSeasonId)
|
||||
}
|
||||
}
|
||||
@@ -426,6 +429,9 @@ class WebShowFragment : Fragment(), TabLayout.OnTabSelectedListener {
|
||||
}else {
|
||||
// loading more data
|
||||
binding.loadMoreProgress.show()
|
||||
binding.loadMoreProgress.post {
|
||||
binding.nestedScrollView.fullScroll(View.FOCUS_DOWN)
|
||||
}
|
||||
binding.rvEpisodes.show()
|
||||
binding.seasonMediaType.show()
|
||||
}
|
||||
@@ -437,7 +443,6 @@ class WebShowFragment : Fragment(), TabLayout.OnTabSelectedListener {
|
||||
binding.rvEpisodes.show()
|
||||
binding.seasonMediaType.show()
|
||||
binding.epShimmer.hide()
|
||||
binding.loadMoreProgress.hide()
|
||||
|
||||
if (!isLoadingMoreEpisodes){
|
||||
// loading new data
|
||||
@@ -449,6 +454,8 @@ class WebShowFragment : Fragment(), TabLayout.OnTabSelectedListener {
|
||||
episodeAdapter.currentList.size,
|
||||
episodeList.size
|
||||
)
|
||||
|
||||
binding.loadMoreProgress.hide()
|
||||
} catch (e: Exception) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.Html
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.core.view.ViewCompat
|
||||
@@ -149,10 +150,13 @@ class GamesActivity : WokaBaseActivity() {
|
||||
|
||||
val percentageScrolled = (scrolledHeight.toFloat()/totalHeight.toFloat()) * 100
|
||||
|
||||
if (percentageScrolled >= 80) {
|
||||
if (percentageScrolled == 100f) {
|
||||
if (!isLoading && !viewModel.lastPage && isNetworkConnected()){
|
||||
Log.d("infinite_scroll", "LOAD MORE")
|
||||
isLoading = true
|
||||
binding.loadMoreProgress.post {
|
||||
binding.nestedScrollView.fullScroll(View.FOCUS_DOWN)
|
||||
}
|
||||
viewModel.loadGames()
|
||||
}
|
||||
}
|
||||
@@ -464,6 +468,9 @@ class GamesActivity : WokaBaseActivity() {
|
||||
} else {
|
||||
// loading more data
|
||||
binding.loadMoreProgress.show()
|
||||
binding.loadMoreProgress.post {
|
||||
binding.nestedScrollView.fullScroll(View.FOCUS_DOWN)
|
||||
}
|
||||
}
|
||||
}
|
||||
is ApiResult.Success -> {
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="45dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginVertical="10dp"
|
||||
app:tabBackground="@drawable/sub_category_tab_bg"
|
||||
app:tabGravity="start"
|
||||
app:tabIndicatorHeight="0dp"
|
||||
|
||||
@@ -199,7 +199,7 @@
|
||||
<string name="dummy_button">Dummy Button</string>
|
||||
<string name="dummy_content">DUMMY\nCONTENT</string>
|
||||
<string name="warning">Warning</string>
|
||||
<string name="back_warning_text">Clicking \"OK\" will exit you from the game.\nAre you sure you want to proceed?</string>
|
||||
<string name="back_warning_text">Are you sure you want to exit the game?</string>
|
||||
<string name="cancel_caps">CANCEL</string>
|
||||
<string name="ok_caps">OK</string>
|
||||
<string name="sing_along_and_dance">SING ALONG and DANCE</string>
|
||||
|
||||
Reference in New Issue
Block a user