new place holder to all the images when there's an error in loading the image.
Removal of testing code for ads repository. Error handling for custom ad image loading. Unique user engagement when clicked on 8 modules on Home1Fragment and Home2Fragment
This commit is contained in:
@@ -12,12 +12,6 @@ object AdsRepository {
|
||||
@Volatile
|
||||
private var adsData: List<AdResult>? = null
|
||||
|
||||
// testing purpose remove this function
|
||||
suspend fun loadNewAds(){
|
||||
adsData = null
|
||||
getADs()
|
||||
}
|
||||
|
||||
suspend fun getADs(): List<AdResult>?{
|
||||
if (adsData != null){
|
||||
return adsData
|
||||
|
||||
@@ -193,11 +193,6 @@ class Home1Fragment : Fragment() {
|
||||
}
|
||||
|
||||
binding.playerView.show()
|
||||
|
||||
// remove this : for testing purpose
|
||||
lifecycleScope.launch {
|
||||
AdsRepository.loadNewAds()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
@@ -275,6 +270,8 @@ class Home1Fragment : Fragment() {
|
||||
progressView.hide()
|
||||
binding.liveTv.setOnClickListener {
|
||||
activity?.let {activity ->
|
||||
viewModel.sendAnalyticsIfUniqueUser()
|
||||
|
||||
startActivity(Intent(activity, LiveStreamPlayerActivity::class.java).apply {
|
||||
putExtra(
|
||||
LiveStreamPlayerActivity.EXTRA_LIVE_STREAM_ID,
|
||||
@@ -292,6 +289,8 @@ class Home1Fragment : Fragment() {
|
||||
it.data?.live_fm_data?.let {fmData ->
|
||||
binding.fmButton.setOnClickListener {
|
||||
activity?.let {activity ->
|
||||
viewModel.sendAnalyticsIfUniqueUser()
|
||||
|
||||
startActivity(Intent(activity, FMActivity::class.java).apply {
|
||||
putExtra(FMActivity.EXTRA_FM_URL, fmData.live_fm_url)
|
||||
putExtra(FMActivity.EXTRA_FM_ID, fmData.id)
|
||||
@@ -322,6 +321,8 @@ class Home1Fragment : Fragment() {
|
||||
|
||||
webSeries.setOnClickListener {
|
||||
activity?.let {
|
||||
viewModel.sendAnalyticsIfUniqueUser()
|
||||
|
||||
startActivity(Intent(it, WebSeriesActivity::class.java))
|
||||
|
||||
clickHelper.upsertClickEvent(ContentType.OTHERS)
|
||||
@@ -330,6 +331,8 @@ class Home1Fragment : Fragment() {
|
||||
|
||||
audioBooks.setOnClickListener {
|
||||
activity?.let {
|
||||
viewModel.sendAnalyticsIfUniqueUser()
|
||||
|
||||
startActivity(Intent(it, AudioBooksActivity::class.java))
|
||||
|
||||
clickHelper.upsertClickEvent(ContentType.OTHERS)
|
||||
@@ -338,6 +341,8 @@ class Home1Fragment : Fragment() {
|
||||
|
||||
play.setOnClickListener {
|
||||
activity?.let {
|
||||
viewModel.sendAnalyticsIfUniqueUser()
|
||||
|
||||
startActivity(Intent(it, GamesActivity::class.java))
|
||||
|
||||
clickHelper.upsertClickEvent(ContentType.OTHERS)
|
||||
@@ -346,6 +351,8 @@ class Home1Fragment : Fragment() {
|
||||
|
||||
karaoke.setOnClickListener {
|
||||
activity?.let {
|
||||
viewModel.sendAnalyticsIfUniqueUser()
|
||||
|
||||
startActivity(Intent(it, KaraokeActivity::class.java))
|
||||
|
||||
clickHelper.upsertClickEvent(ContentType.OTHERS)
|
||||
@@ -354,6 +361,8 @@ class Home1Fragment : Fragment() {
|
||||
|
||||
shop.setOnClickListener {
|
||||
activity?.let {
|
||||
viewModel.sendAnalyticsIfUniqueUser()
|
||||
|
||||
startActivity(Intent(it, ShopActivity::class.java))
|
||||
|
||||
clickHelper.upsertClickEvent(ContentType.OTHERS)
|
||||
|
||||
@@ -144,6 +144,8 @@ class Home2Fragment : Fragment() {
|
||||
|
||||
webSeries.setOnClickListener {
|
||||
activity?.let {
|
||||
viewModel.sendAnalyticsIfUniqueUser()
|
||||
|
||||
startActivity(Intent(it, WebSeriesActivity::class.java))
|
||||
|
||||
clickHelper.upsertClickEvent(ContentType.OTHERS)
|
||||
@@ -152,6 +154,8 @@ class Home2Fragment : Fragment() {
|
||||
|
||||
audioBooks.setOnClickListener {
|
||||
activity?.let {
|
||||
viewModel.sendAnalyticsIfUniqueUser()
|
||||
|
||||
startActivity(Intent(it, AudioBooksActivity::class.java))
|
||||
|
||||
clickHelper.upsertClickEvent(ContentType.OTHERS)
|
||||
@@ -160,6 +164,8 @@ class Home2Fragment : Fragment() {
|
||||
|
||||
playGames.setOnClickListener {
|
||||
activity?.let {
|
||||
viewModel.sendAnalyticsIfUniqueUser()
|
||||
|
||||
startActivity(Intent(it, GamesActivity::class.java))
|
||||
|
||||
clickHelper.upsertClickEvent(ContentType.OTHERS)
|
||||
@@ -168,6 +174,8 @@ class Home2Fragment : Fragment() {
|
||||
|
||||
karaoke.setOnClickListener {
|
||||
activity?.let {
|
||||
viewModel.sendAnalyticsIfUniqueUser()
|
||||
|
||||
startActivity(Intent(it, KaraokeActivity::class.java))
|
||||
|
||||
clickHelper.upsertClickEvent(ContentType.OTHERS)
|
||||
@@ -176,6 +184,8 @@ class Home2Fragment : Fragment() {
|
||||
|
||||
shop.setOnClickListener {
|
||||
activity?.let {
|
||||
viewModel.sendAnalyticsIfUniqueUser()
|
||||
|
||||
startActivity(Intent(it, ShopActivity::class.java))
|
||||
|
||||
clickHelper.upsertClickEvent(ContentType.OTHERS)
|
||||
@@ -266,6 +276,8 @@ class Home2Fragment : Fragment() {
|
||||
progressView.hide()
|
||||
binding.liveTv.setOnClickListener {
|
||||
activity?.let { activity ->
|
||||
viewModel.sendAnalyticsIfUniqueUser()
|
||||
|
||||
startActivity(
|
||||
Intent(
|
||||
activity,
|
||||
@@ -289,6 +301,8 @@ class Home2Fragment : Fragment() {
|
||||
it.data?.live_fm_data?.let { fmData ->
|
||||
binding.wokaFm.setOnClickListener {
|
||||
activity?.let { activity ->
|
||||
viewModel.sendAnalyticsIfUniqueUser()
|
||||
|
||||
startActivity(Intent(activity, FMActivity::class.java).apply {
|
||||
putExtra(FMActivity.EXTRA_FM_URL, fmData.live_fm_url)
|
||||
putExtra(FMActivity.EXTRA_FM_ID, fmData.id)
|
||||
|
||||
@@ -339,7 +339,9 @@ class MyListFragment : Fragment() {
|
||||
AdClicksHelper.addImpression(adv.id)
|
||||
|
||||
binding.imgCustomAd.show()
|
||||
binding.imgCustomAd.loadImage(adv.banner_image)
|
||||
binding.imgCustomAd.loadImage(adv.banner_image, failureListener = {
|
||||
binding.imgCustomAd.hide()
|
||||
})
|
||||
binding.imgCustomAd.setOnClickListener {
|
||||
adv.ad_link?.let {url ->
|
||||
AdClicksHelper.addClick(adv.id)
|
||||
|
||||
@@ -151,7 +151,9 @@ class NotificationsActivity : WokaBaseActivity() {
|
||||
AdClicksHelper.addImpression(adv.id)
|
||||
|
||||
binding.imgCustomAd.show()
|
||||
binding.imgCustomAd.loadImage(adv.banner_image)
|
||||
binding.imgCustomAd.loadImage(adv.banner_image, failureListener = {
|
||||
binding.imgCustomAd.hide()
|
||||
})
|
||||
binding.imgCustomAd.setOnClickListener {
|
||||
adv.ad_link?.let {url ->
|
||||
AdClicksHelper.addClick(adv.id)
|
||||
|
||||
@@ -11,10 +11,15 @@ import androidx.media3.common.PlaybackException
|
||||
import androidx.media3.common.Player
|
||||
import androidx.media3.common.Player.Listener
|
||||
import androidx.media3.exoplayer.ExoPlayer
|
||||
import com.google.firebase.analytics.ktx.analytics
|
||||
import com.google.firebase.ktx.Firebase
|
||||
import com.woka.WokaApp.Companion.userPrefs
|
||||
import com.woka.database.helpers.RemoteSync
|
||||
import com.woka.home.views.BottomNavigation.Companion.HOME
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.userPreference.UserType
|
||||
import com.woka.userdata.UserRepository
|
||||
import com.woka.utils.ANALYTICS_UNIQUE_USER
|
||||
import com.woka.utils.TAG
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@@ -122,6 +127,31 @@ class HomeViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
fun sendAnalyticsIfUniqueUser(){
|
||||
viewModelScope.launch {
|
||||
if (userPrefs?.userType == UserType.GUEST && userPrefs?.isGuestUserUnique == true){
|
||||
when (UserRepository.sendUniqueUser()){
|
||||
is ApiResult.Error -> {}
|
||||
is ApiResult.Loading -> {}
|
||||
is ApiResult.Success -> {
|
||||
Firebase.analytics.logEvent(ANALYTICS_UNIQUE_USER, null)
|
||||
userPrefs?.isGuestUserUnique = false
|
||||
}
|
||||
}
|
||||
}else if (userPrefs?.userType != UserType.GUEST && userPrefs?.userData?.is_unique_user == true){
|
||||
// sending unique user firebase analytics
|
||||
when (UserRepository.sendUniqueUser()){
|
||||
is ApiResult.Error -> {}
|
||||
is ApiResult.Loading -> {}
|
||||
is ApiResult.Success -> {
|
||||
Firebase.analytics.logEvent(ANALYTICS_UNIQUE_USER, null)
|
||||
userPrefs?.userData?.is_unique_user = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
player?.release()
|
||||
|
||||
@@ -222,7 +222,9 @@ class FMActivity : WokaBaseActivity() {
|
||||
AdClicksHelper.addImpression(adv.id)
|
||||
|
||||
binding.imgCustomAd.show()
|
||||
binding.imgCustomAd.loadImage(adv.banner_image)
|
||||
binding.imgCustomAd.loadImage(adv.banner_image, failureListener = {
|
||||
binding.imgCustomAd.hide()
|
||||
})
|
||||
binding.imgCustomAd.setOnClickListener {
|
||||
adv.ad_link?.let {url ->
|
||||
AdClicksHelper.addClick(adv.id)
|
||||
|
||||
@@ -199,7 +199,9 @@ class BlogsActivity : WokaBaseActivity() {
|
||||
AdClicksHelper.addImpression(adv.id)
|
||||
|
||||
binding.imgCustomAd.show()
|
||||
binding.imgCustomAd.loadImage(adv.banner_image)
|
||||
binding.imgCustomAd.loadImage(adv.banner_image, failureListener = {
|
||||
binding.imgCustomAd.hide()
|
||||
})
|
||||
binding.imgCustomAd.setOnClickListener {
|
||||
adv.ad_link?.let {url ->
|
||||
AdClicksHelper.addClick(adv.id)
|
||||
|
||||
@@ -108,6 +108,7 @@ class LanguageFragment : Fragment() {
|
||||
private fun completeGuestLogin(data: Guest) {
|
||||
userPrefs?.userType = UserType.GUEST
|
||||
userPrefs?.guestUserName = data.fullname
|
||||
userPrefs?.isGuestUserUnique = data.is_unique_user?:false
|
||||
|
||||
if (data.new_guest == true){
|
||||
Firebase.analytics.logEvent(ANALYTICS_GUEST_LOGIN, null)
|
||||
|
||||
@@ -80,6 +80,7 @@ class OnboardFragment : Fragment() {
|
||||
|
||||
userPrefs?.userType = UserType.GUEST
|
||||
userPrefs?.guestUserName = data.fullname
|
||||
userPrefs?.isGuestUserUnique = data.is_unique_user?:false
|
||||
|
||||
if (data.new_guest == true){
|
||||
Firebase.analytics.logEvent(ANALYTICS_GUEST_LOGIN, null)
|
||||
|
||||
@@ -164,6 +164,7 @@ class SignInFragment : Fragment() {
|
||||
|
||||
userPrefs?.userType = UserType.GUEST
|
||||
userPrefs?.guestUserName = data.fullname
|
||||
userPrefs?.isGuestUserUnique = data.is_unique_user?:false
|
||||
|
||||
if (data.new_guest == true){
|
||||
Firebase.analytics.logEvent(ANALYTICS_GUEST_LOGIN, null)
|
||||
|
||||
@@ -3,5 +3,6 @@ package com.woka.onboard.models
|
||||
data class Guest(
|
||||
val fullname: String?,
|
||||
val username: String?,
|
||||
val new_guest: Boolean?
|
||||
val new_guest: Boolean?,
|
||||
val is_unique_user: Boolean?
|
||||
)
|
||||
@@ -8,17 +8,14 @@ import android.content.SharedPreferences
|
||||
import android.provider.Settings.Secure
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.woka.R
|
||||
import com.woka.home.models.Theme
|
||||
import com.woka.home.mylist.MyListRepository
|
||||
import com.woka.home.notifications.NotificationRepository
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.onboard.views.OnboardActivity
|
||||
import com.woka.shop.ShopRepository
|
||||
import com.woka.userdata.UserRepository
|
||||
import com.woka.userdata.userDataModels.UserData
|
||||
import com.woka.userdata.userDataModels.UserDataResponse
|
||||
import com.woka.utils.DecisionDialog
|
||||
import com.woka.utils.SessionExpiredActivity
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -33,6 +30,7 @@ class UserPreference(val context: Context) {
|
||||
private const val ACCESS_TOKEN = "access_token"
|
||||
private const val USER_TYPE = "user_type"
|
||||
private const val GUEST_USER_NAME = "guest_user_name"
|
||||
private const val IS_GUEST_USER_UNIQUE = "is_guest_user_unique"
|
||||
private const val SKIPPED_VERSION = "skipped_version"
|
||||
}
|
||||
|
||||
@@ -84,6 +82,10 @@ class UserPreference(val context: Context) {
|
||||
get() = userPrefs.getString(GUEST_USER_NAME, null)
|
||||
set(value) = userPrefs.edit().putString(GUEST_USER_NAME, value).apply()
|
||||
|
||||
var isGuestUserUnique: Boolean
|
||||
get() = userPrefs.getBoolean(IS_GUEST_USER_UNIQUE, false)
|
||||
set(value) = userPrefs.edit().putBoolean(IS_GUEST_USER_UNIQUE, value).apply()
|
||||
|
||||
var skippedVersion: Int
|
||||
get() = userPrefs.getInt(SKIPPED_VERSION, 0)
|
||||
set(value) = userPrefs.edit().putInt(SKIPPED_VERSION, value).apply()
|
||||
|
||||
@@ -33,4 +33,7 @@ interface UserApiService {
|
||||
|
||||
@POST("user_video_view")
|
||||
suspend fun userVideoView(@Body videoViewRequestData: VideoViewRequestData): Response<ApiResponse<Any>>
|
||||
|
||||
@POST("unique_click_store")
|
||||
suspend fun sendUniqueUser(@Body formBody: FormBody): Response<ApiResponse<Any>>
|
||||
}
|
||||
@@ -73,4 +73,16 @@ object UserRepository {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun sendUniqueUser(): ApiResult<Any>{
|
||||
return handleApiCall {
|
||||
userApiService.sendUniqueUser(
|
||||
FormBody.Builder()
|
||||
.add("post_type", "1")
|
||||
.add("is_clicked", "1")
|
||||
.add("device_type", "1") // 1 for android
|
||||
.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,5 +17,6 @@ data class UserData(
|
||||
val last_login: String?,
|
||||
val remember_token: String?,
|
||||
val user_type: Int?,
|
||||
val username: String?
|
||||
val username: String?,
|
||||
var is_unique_user: Boolean?
|
||||
)
|
||||
@@ -21,7 +21,7 @@ class AdiImageView: FrameLayout {
|
||||
// attributes
|
||||
private var cornerRadius: Int = 0
|
||||
private var loadingColor: Int = android.R.color.darker_gray
|
||||
private var errorSrc: Drawable? = AppCompatResources.getDrawable(context, R.drawable.img_error_src)
|
||||
private var errorSrc: Drawable? = AppCompatResources.getDrawable(context, R.drawable.img_woka_place_holder)
|
||||
private var progressTintMode: Int = context.getColor(android.R.color.white)
|
||||
|
||||
// views
|
||||
@@ -48,7 +48,9 @@ class AdiImageView: FrameLayout {
|
||||
val attributes = context.obtainStyledAttributes(attrs, R.styleable.AdiImageView)
|
||||
|
||||
cornerRadius = attributes.getDimensionPixelSize(R.styleable.AdiImageView_imageCornerRadius, 0)
|
||||
errorSrc = attributes.getDrawable(R.styleable.AdiImageView_errorSrc)
|
||||
attributes.getDrawable(R.styleable.AdiImageView_errorSrc)?.let {
|
||||
errorSrc = it
|
||||
}
|
||||
progressTintMode = attributes.getColor(R.styleable.AdiImageView_android_progressTintMode, progressTintMode)
|
||||
|
||||
attributes.recycle()
|
||||
@@ -81,7 +83,6 @@ class AdiImageView: FrameLayout {
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
progressView?.hide()
|
||||
imageView?.setImageDrawable(errorSrc)
|
||||
failureListener?.invoke()
|
||||
return false
|
||||
}
|
||||
@@ -99,6 +100,7 @@ class AdiImageView: FrameLayout {
|
||||
}
|
||||
})
|
||||
.placeholder(loadingColor)
|
||||
.error(errorSrc)
|
||||
.into(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,4 +30,5 @@ const val ONESIGNAL_APP_ID = "f9674e6f-75fb-49e8-8379-4f2ed2a880b8"
|
||||
// analytics constants
|
||||
const val ANALYTICS_GUEST_LOGIN = "guest_login_android"
|
||||
const val ANALYTICS_USER_SIGN_UP = "user_signup_android"
|
||||
const val ANALYTICS_NEW_USER = "new_user_android"
|
||||
const val ANALYTICS_NEW_USER = "new_user_android"
|
||||
const val ANALYTICS_UNIQUE_USER = "engaged_users"
|
||||
BIN
app/src/main/res/drawable-hdpi/img_woka_place_holder.png
Normal file
BIN
app/src/main/res/drawable-hdpi/img_woka_place_holder.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
BIN
app/src/main/res/drawable-ldpi/img_woka_place_holder.png
Normal file
BIN
app/src/main/res/drawable-ldpi/img_woka_place_holder.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
BIN
app/src/main/res/drawable-mdpi/img_woka_place_holder.png
Normal file
BIN
app/src/main/res/drawable-mdpi/img_woka_place_holder.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
BIN
app/src/main/res/drawable-xhdpi/img_woka_place_holder.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/img_woka_place_holder.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 147 KiB |
BIN
app/src/main/res/drawable-xxhdpi/img_woka_place_holder.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/img_woka_place_holder.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 227 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/img_woka_place_holder.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/img_woka_place_holder.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 351 KiB |
@@ -27,10 +27,13 @@ android.enableJetifier=true
|
||||
# BASE URLS
|
||||
|
||||
# staging
|
||||
#WOKA_BASE_URL="https://wokaland.com/secret-panel-10102023/hidden-admin-portal-20092023/api/"
|
||||
WOKA_BASE_URL="https://wokaland.com/secret-panel-10102023/hidden-admin-portal-20092023/api/"
|
||||
|
||||
# testing
|
||||
WOKA_BASE_URL="https://wokanative.betadelivery.com/api/"
|
||||
#WOKA_BASE_URL="https://wokanative.betadelivery.com/api/"
|
||||
|
||||
# production
|
||||
#WOKA_BASE_URL="https://wokaland.com/api/"
|
||||
|
||||
WOKA_USER_NAME="admin"
|
||||
WOKA_PASSWORD="Woka@1234"
|
||||
Reference in New Issue
Block a user