Cart listing removing caching.
loading continue data properly after user video view api is hit.
This commit is contained in:
@@ -17,6 +17,7 @@ import android.os.Environment
|
|||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
|
import androidx.activity.addCallback
|
||||||
import androidx.activity.enableEdgeToEdge
|
import androidx.activity.enableEdgeToEdge
|
||||||
import androidx.activity.result.ActivityResultLauncher
|
import androidx.activity.result.ActivityResultLauncher
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
@@ -157,6 +158,32 @@ class KaraokePlayerActivity : WokaBaseActivity() {
|
|||||||
|
|
||||||
loadAudioFromUrl()
|
loadAudioFromUrl()
|
||||||
|
|
||||||
|
onBackPressedDispatcher.addCallback {
|
||||||
|
if (playbackStartTime > 0) {
|
||||||
|
val elapsed = System.currentTimeMillis() - playbackStartTime
|
||||||
|
totalPlaybackDuration += elapsed
|
||||||
|
playbackStartTime = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
val playingDurationInSecs = Math.round(totalPlaybackDuration/1000.0)
|
||||||
|
|
||||||
|
karaokePlayerData?.id?.let {
|
||||||
|
if (it > 0 && playingDurationInSecs > 0) {
|
||||||
|
UserRepository.userVideoView(
|
||||||
|
VideoViewRequestData(
|
||||||
|
it,
|
||||||
|
ContentType.KARAOKE_VIDEO.id,
|
||||||
|
playingDurationInSecs
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
totalPlaybackDuration = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
@@ -164,6 +191,8 @@ class KaraokePlayerActivity : WokaBaseActivity() {
|
|||||||
|
|
||||||
if (recordingState == RecordingState.RECORDING){
|
if (recordingState == RecordingState.RECORDING){
|
||||||
startStopRecording()
|
startStopRecording()
|
||||||
|
}else if (player?.isPlaying == true) {
|
||||||
|
player?.pause()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playbackStartTime > 0) {
|
if (playbackStartTime > 0) {
|
||||||
|
|||||||
@@ -530,7 +530,9 @@ class KaraokeActivity : WokaBaseActivity() {
|
|||||||
binding.continueSingTxt.show()
|
binding.continueSingTxt.show()
|
||||||
binding.rvContinueSing.show()
|
binding.rvContinueSing.show()
|
||||||
|
|
||||||
continueKaraokeAdapter.submitList(continueList)
|
continueKaraokeAdapter.submitList(continueList){
|
||||||
|
binding.rvContinueSing.scrollToPosition(0)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
binding.continueSingTxt.hide()
|
binding.continueSingTxt.hide()
|
||||||
binding.rvContinueSing.hide()
|
binding.rvContinueSing.hide()
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import android.net.NetworkRequest
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.activity.addCallback
|
||||||
import androidx.activity.enableEdgeToEdge
|
import androidx.activity.enableEdgeToEdge
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
@@ -92,6 +93,12 @@ class PlayerActivity : AppCompatActivity(), FullscreenHandler {
|
|||||||
|
|
||||||
clickEvents()
|
clickEvents()
|
||||||
|
|
||||||
|
onBackPressedDispatcher.addCallback {
|
||||||
|
uploadVideoView()
|
||||||
|
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
@@ -104,6 +111,10 @@ class PlayerActivity : AppCompatActivity(), FullscreenHandler {
|
|||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
super.onStop()
|
super.onStop()
|
||||||
|
uploadVideoView()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun uploadVideoView(){
|
||||||
videoPlayList?.videoViewRequestDataList?.let {playlistData ->
|
videoPlayList?.videoViewRequestDataList?.let {playlistData ->
|
||||||
if (playingIndex >= 0 && playingIndex < playlistData.size){
|
if (playingIndex >= 0 && playingIndex < playlistData.size){
|
||||||
with(playlistData[playingIndex]){
|
with(playlistData[playingIndex]){
|
||||||
@@ -129,7 +140,6 @@ class PlayerActivity : AppCompatActivity(), FullscreenHandler {
|
|||||||
)
|
)
|
||||||
|
|
||||||
totalPlaybackDuration = 0
|
totalPlaybackDuration = 0
|
||||||
Log.d(TAG, "onStop: API DONE $playingDurationInSecs")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,9 +95,10 @@ object ShopRepository {
|
|||||||
get() = _cartCountLiveData
|
get() = _cartCountLiveData
|
||||||
|
|
||||||
suspend fun cartListing(): ApiResult<CartResponse> {
|
suspend fun cartListing(): ApiResult<CartResponse> {
|
||||||
if (cartResponse != null) {
|
// caching cart list
|
||||||
return ApiResult.Success(cartResponse)
|
// if (cartResponse != null) {
|
||||||
}
|
// return ApiResult.Success(cartResponse)
|
||||||
|
// }
|
||||||
|
|
||||||
val response = handleApiCall {
|
val response = handleApiCall {
|
||||||
apiService.cartListing()
|
apiService.cartListing()
|
||||||
@@ -137,9 +138,11 @@ object ShopRepository {
|
|||||||
cartResponse?.let { cartData ->
|
cartResponse?.let { cartData ->
|
||||||
cartData.result?.let { cartItems ->
|
cartData.result?.let { cartItems ->
|
||||||
cartItems.add(CartItem(shopProduct))
|
cartItems.add(CartItem(shopProduct))
|
||||||
shopProduct.product_final_price?.let {
|
|
||||||
cartData.total_amount = (cartData.total_amount?:0.0) + it
|
// caching data
|
||||||
}
|
// shopProduct.product_final_price?.let {
|
||||||
|
// cartData.total_amount = (cartData.total_amount?:0.0) + it
|
||||||
|
// }
|
||||||
|
|
||||||
cartItems.let {
|
cartItems.let {
|
||||||
_cartCountLiveData.postValue(it.size)
|
_cartCountLiveData.postValue(it.size)
|
||||||
@@ -172,6 +175,8 @@ object ShopRepository {
|
|||||||
// removing from cache
|
// removing from cache
|
||||||
cartResponse?.let { cartData ->
|
cartResponse?.let { cartData ->
|
||||||
cartData.result?.let { cartItems ->
|
cartData.result?.let { cartItems ->
|
||||||
|
|
||||||
|
// caching data
|
||||||
cartItems.find { it?.id == id }?.let {item ->
|
cartItems.find { it?.id == id }?.let {item ->
|
||||||
val remainingAmount = (cartData.total_amount?:0.0) - (item.product_final_price?:0.0)
|
val remainingAmount = (cartData.total_amount?:0.0) - (item.product_final_price?:0.0)
|
||||||
cartData.total_amount = maxOf(0.0, remainingAmount)
|
cartData.total_amount = maxOf(0.0, remainingAmount)
|
||||||
|
|||||||
@@ -49,12 +49,10 @@
|
|||||||
android:layout_height="@dimen/_200sdp"
|
android:layout_height="@dimen/_200sdp"
|
||||||
android:contentDescription="@string/about_woka"
|
android:contentDescription="@string/about_woka"
|
||||||
android:src="@drawable/img_about"
|
android:src="@drawable/img_about"
|
||||||
|
|
||||||
android:translationZ="1dp"
|
|
||||||
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintBottom_toTopOf="@id/g1"
|
app:layout_constraintBottom_toTopOf="@id/g1"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/back_btn"
|
||||||
|
app:layout_constraintVertical_bias="0"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.Guideline
|
<androidx.constraintlayout.widget.Guideline
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="100dp"
|
android:layout_width="@dimen/_80sdp"
|
||||||
android:layout_height="100dp"
|
android:layout_height="@dimen/_80sdp"
|
||||||
android:id="@+id/card"
|
android:id="@+id/card"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
|
||||||
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/avatar"
|
android:id="@+id/avatar"
|
||||||
android:layout_width="60dp"
|
android:layout_width="@dimen/_50sdp"
|
||||||
android:layout_height="60dp"
|
android:layout_height="@dimen/_50sdp"
|
||||||
android:contentDescription="@string/image"
|
android:contentDescription="@string/image"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -115,14 +115,12 @@
|
|||||||
<androidx.cardview.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/player_card"
|
android:id="@+id/player_card"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="@dimen/_160sdp"
|
||||||
|
|
||||||
android:layout_marginTop="15dp"
|
android:layout_marginTop="15dp"
|
||||||
|
|
||||||
app:cardBackgroundColor="@color/black"
|
app:layout_constraintTop_toBottomOf="@id/profile_image"
|
||||||
|
app:cardBackgroundColor="@color/black">
|
||||||
app:layout_constraintBottom_toTopOf="@id/g1"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/profile_image">
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/player_view_bg"
|
android:id="@+id/player_view_bg"
|
||||||
@@ -142,13 +140,6 @@
|
|||||||
|
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.Guideline
|
|
||||||
android:id="@+id/g1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
app:layout_constraintGuide_percent="0.4"/>
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.Guideline
|
<androidx.constraintlayout.widget.Guideline
|
||||||
android:id="@+id/g2"
|
android:id="@+id/g2"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -159,8 +150,8 @@
|
|||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/g1"
|
app:layout_constraintTop_toBottomOf="@id/player_card"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
|
|||||||
Reference in New Issue
Block a user