任务页面UI
|
|
@ -11,6 +11,7 @@ import com.ama.core.architecture.appBase.AppViewsFragment
|
||||||
import com.ama.core.architecture.appBase.OnFragmentBackgroundListener
|
import com.ama.core.architecture.appBase.OnFragmentBackgroundListener
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.ama.core.architecture.util.setStatusBarDarkFont
|
import com.ama.core.architecture.util.setStatusBarDarkFont
|
||||||
|
import com.gamedog.vididin.R
|
||||||
import com.gamedog.vididin.main.WatchVideoDialog
|
import com.gamedog.vididin.main.WatchVideoDialog
|
||||||
import com.gamedog.vididin.main.fragments.task.DailySignDialog
|
import com.gamedog.vididin.main.fragments.task.DailySignDialog
|
||||||
import com.gamedog.vididin.main.fragments.task.TaskBean
|
import com.gamedog.vididin.main.fragments.task.TaskBean
|
||||||
|
|
@ -76,32 +77,48 @@ class TasksFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnTab
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
beginnerTaskWithdraw.initUI(R.mipmap.icon_cash_s, R.string.beginner_withdraw_title, R.string.beginner_withdraw_desc,R.string.resgatar)
|
||||||
|
beginnerTaskWithdraw.setRewardIcon(R.mipmap.icon_cash_s)
|
||||||
|
beginnerTaskWithdraw.setRewardTextStyle(21, R.color.green_39)
|
||||||
beginnerTaskWithdraw.setActionFun {
|
beginnerTaskWithdraw.setActionFun {
|
||||||
gotoWithDraw()
|
gotoWithDraw()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beginnerTaskDiscord.initUI(R.mipmap.icon_dicord, R.string.beginner_discord_title, R.string.beginner_discord_desc,R.string.resgatar)
|
||||||
beginnerTaskDiscord.setActionFun {
|
beginnerTaskDiscord.setActionFun {
|
||||||
gotoDiscord()
|
gotoDiscord()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beginnerTaskEnableNotify.initUI(R.mipmap.icon_notify, R.string.beginner_notify_title, R.string.beginner_notify_desc,R.string.Resgatado)
|
||||||
beginnerTaskEnableNotify.setActionFun {
|
beginnerTaskEnableNotify.setActionFun {
|
||||||
gotoNotification()
|
gotoNotification()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dailyTaskWatch1.initUI(R.mipmap.icon_video_task, R.string.daily_video_task_title, 1, R.string.resgatar)
|
||||||
dailyTaskWatch1.setActionFun {
|
dailyTaskWatch1.setActionFun {
|
||||||
gotoWithVideo()
|
gotoWithVideo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dailyTaskWatch5.initUI(R.mipmap.icon_video_task, R.string.daily_video_task_title, 5, R.string.resgatar)
|
||||||
dailyTaskWatch5.setActionFun {
|
dailyTaskWatch5.setActionFun {
|
||||||
gotoWithVideo()
|
gotoWithVideo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dailyTaskWatch10.initUI(R.mipmap.icon_video_task, R.string.daily_video_task_title, 10, R.string.resgatar)
|
||||||
dailyTaskWatch10.setActionFun {
|
dailyTaskWatch10.setActionFun {
|
||||||
gotoWithVideo()
|
gotoWithVideo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dailyTaskWatch20.initUI(R.mipmap.icon_video_task, R.string.daily_video_task_title, 20, R.string.resgatar)
|
||||||
dailyTaskWatch20.setActionFun {
|
dailyTaskWatch20.setActionFun {
|
||||||
gotoWithVideo()
|
gotoWithVideo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dailyTaskWatch30.initUI(R.mipmap.icon_video_task, R.string.daily_video_task_title, 30, R.string.resgatar)
|
||||||
dailyTaskWatch30.setActionFun {
|
dailyTaskWatch30.setActionFun {
|
||||||
gotoWithVideo()
|
gotoWithVideo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
|
|
|
||||||
|
|
@ -31,21 +31,31 @@ class BeginnerTaskItemView @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun initUI(titleIconRes: Int, titleRes: Int, actionRes: Int) {
|
fun initUI(titleIconRes: Int, titleRes: Int, desRes: Int, actionRes: Int) {
|
||||||
mBinding.ivItemIcon.setImageResource(titleIconRes)
|
mBinding.ivItemIcon.setImageResource(titleIconRes)
|
||||||
mBinding.tvItemTitle.setText(titleRes)
|
mBinding.tvItemTitle.setText(titleRes)
|
||||||
mBinding.tvAction.setText(actionRes)
|
mBinding.tvAction.setText(actionRes)
|
||||||
|
mBinding.tvItemDescrible.setText(desRes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun setRewardInfo(rewardIconRes: Int, rewardNum: Int) {
|
fun setRewardNum(rewardNum: String) {
|
||||||
mBinding.tvRewardNum.text = "" + rewardNum
|
mBinding.tvRewardNum.text = rewardNum
|
||||||
mBinding.ivRewardIcon.setImageResource(rewardIconRes)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setRewardIcon(iconRes: Int) {
|
||||||
|
mBinding.ivRewardIcon.setImageResource(iconRes)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fun setActionFun(action: ()->Unit) {
|
fun setActionFun(action: ()->Unit) {
|
||||||
mAction = action
|
mAction = action
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setRewardTextStyle(textSize: Int, color: Int) {
|
||||||
|
mBinding.tvRewardNum.textSize = textSize.toFloat()
|
||||||
|
mBinding.tvRewardNum.setTextColor(color)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -4,6 +4,7 @@ import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import com.ama.core.architecture.util.ResUtil
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.gamedog.vididin.databinding.DailyTaskItemViewBinding
|
import com.gamedog.vididin.databinding.DailyTaskItemViewBinding
|
||||||
|
|
||||||
|
|
@ -32,9 +33,9 @@ class DailyTaskItemView @JvmOverloads constructor(
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun initUI(titleIconRes: Int, titleRes: Int, actionRes: Int) {
|
fun initUI(titleIconRes: Int, titleRes: Int, videosNum: Int, actionRes: Int) {
|
||||||
mBinding.ivItemIcon.setImageResource(titleIconRes)
|
mBinding.ivItemIcon.setImageResource(titleIconRes)
|
||||||
mBinding.tvItemTitle.setText(titleRes)
|
mBinding.tvItemTitle.text = String.format(ResUtil.getString(titleRes), videosNum)
|
||||||
mBinding.tvAction.setText(actionRes)
|
mBinding.tvAction.setText(actionRes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,17 +67,17 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:src="@mipmap/temp"/>
|
android:src="@mipmap/task_gold"/>
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:id="@+id/tv_reward_num"
|
android:id="@+id/tv_reward_num"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="9dp"
|
android:layout_marginHorizontal="9dp"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textColor="@color/red_0b"
|
android:textColor="@color/red_0b"
|
||||||
android:text="+10443"
|
android:text="+1"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="6dp"
|
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textColor="@color/gray6"
|
android:textColor="@color/gray6"
|
||||||
|
|
@ -63,7 +62,6 @@
|
||||||
android:id="@+id/tv_item_progress"
|
android:id="@+id/tv_item_progress"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="6dp"
|
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textColor="@color/gray6"
|
android:textColor="@color/gray6"
|
||||||
|
|
@ -90,7 +88,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:src="@mipmap/temp"/>
|
android:src="@mipmap/task_gold"/>
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:id="@+id/tv_reward_num"
|
android:id="@+id/tv_reward_num"
|
||||||
|
|
@ -100,7 +98,7 @@
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textColor="@color/red_0b"
|
android:textColor="@color/red_0b"
|
||||||
android:text="+10443"
|
android:text="+1"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
||||||
|
|
@ -391,7 +391,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:layout_marginHorizontal="14dp"
|
android:layout_marginHorizontal="14dp"
|
||||||
android:layout_marginTop="15dp"
|
android:layout_marginTop="5dp"
|
||||||
android:background="@drawable/vididinapp_feature_message_bg_task_fazer"
|
android:background="@drawable/vididinapp_feature_message_bg_task_fazer"
|
||||||
android:text="Fazer Login Agora"
|
android:text="Fazer Login Agora"
|
||||||
android:paddingVertical="9dp"
|
android:paddingVertical="9dp"
|
||||||
|
|
|
||||||
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 9.3 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
|
@ -23,5 +23,14 @@
|
||||||
<string name="papabens">Parabéns!</string>
|
<string name="papabens">Parabéns!</string>
|
||||||
<string name="papabens_hint">Você recebeu um presente de boas-vindas</string>
|
<string name="papabens_hint">Você recebeu um presente de boas-vindas</string>
|
||||||
<string name="cash01">R$ 0.1</string>
|
<string name="cash01">R$ 0.1</string>
|
||||||
|
<string name="beginner_withdraw_title">Saque para Novatos</string>
|
||||||
|
<string name="daily_video_task_title">Assistir a %d vídeo</string>
|
||||||
|
<string name="beginner_notify_title">Notificações push</string>
|
||||||
|
<string name="beginner_notify_desc">Ative as notificações e ganhe 200 moedas!</string>
|
||||||
|
<string name="beginner_discord_title">Comunidade Discord</string>
|
||||||
|
<string name="beginner_discord_desc">Junte-se à nossa comunidade e ganhe 150 moedas!</string>
|
||||||
|
<string name="beginner_withdraw_desc">Um benefício exclusivo. Saque R$0,1 AGORA!</string>
|
||||||
|
<string name="Resgatado">Resgatado</string>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -1,11 +1,147 @@
|
||||||
package com.ama.core.architecture.util
|
package com.ama.core.architecture.util
|
||||||
|
|
||||||
class ResUtil private constructor() {
|
import android.graphics.Color
|
||||||
companion object {
|
import android.util.TypedValue
|
||||||
|
import androidx.annotation.AttrRes
|
||||||
|
import androidx.annotation.ColorRes
|
||||||
|
import androidx.annotation.DimenRes
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import com.ama.core.architecture.BaseApp
|
||||||
|
|
||||||
|
object ResUtil {
|
||||||
|
|
||||||
|
private val appContext = BaseApp.appContext()
|
||||||
|
|
||||||
|
|
||||||
|
// ==================== Dimen相关 ====================
|
||||||
|
/**
|
||||||
|
* 获取dp值对应的像素值
|
||||||
|
*/
|
||||||
|
fun dp(dpValue: Float): Float {
|
||||||
|
return dpValue * appContext.resources.displayMetrics.density
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun dp(dpValue: Int): Float {
|
||||||
|
return dp(dpValue.toFloat())
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取dp值对应的像素值(取整)
|
||||||
|
*/
|
||||||
|
fun dpToPx(dpValue: Float): Int {
|
||||||
|
return (dp(dpValue) + 0.5f).toInt()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun dpToPx(dpValue: Int): Int {
|
||||||
|
return dpToPx(dpValue.toFloat())
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取sp值对应的像素值
|
||||||
|
*/
|
||||||
|
fun sp(spValue: Float): Float {
|
||||||
|
return spValue * appContext.resources.displayMetrics.scaledDensity
|
||||||
|
}
|
||||||
|
|
||||||
|
fun sp(spValue: Int): Float {
|
||||||
|
return sp(spValue.toFloat())
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从dimen资源获取像素值
|
||||||
|
*/
|
||||||
|
fun getPixelSize(@DimenRes dimenRes: Int): Int {
|
||||||
|
return appContext.resources.getDimensionPixelSize(dimenRes)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getDimension(@DimenRes dimenRes: Int): Float {
|
||||||
|
return appContext.resources.getDimension(dimenRes)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ==================== 颜色相关 ====================
|
||||||
|
fun getString(@StringRes strRes: Int): String {
|
||||||
|
return ContextCompat.getString(appContext, strRes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 颜色相关 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从颜色资源获取颜色值
|
||||||
|
*/
|
||||||
|
fun getColor(@ColorRes colorRes: Int): Int {
|
||||||
|
return ContextCompat.getColor(appContext, colorRes)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从颜色资源获取颜色值(带透明度)
|
||||||
|
*/
|
||||||
|
fun getColor(@ColorRes colorRes: Int, alpha: Float): Int {
|
||||||
|
val color = getColor(colorRes)
|
||||||
|
return applyAlphaToColor(color, alpha)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析颜色字符串
|
||||||
|
*/
|
||||||
|
fun parseColor(colorString: String): Int {
|
||||||
|
return try {
|
||||||
|
Color.parseColor(colorString)
|
||||||
|
} catch (e: IllegalArgumentException) {
|
||||||
|
Color.BLACK // 默认颜色
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 给颜色应用透明度
|
||||||
|
*/
|
||||||
|
fun applyAlphaToColor(color: Int, alpha: Float): Int {
|
||||||
|
val alphaValue = (alpha.coerceIn(0f, 1f) * 255).toInt()
|
||||||
|
return color and 0x00FFFFFF or (alphaValue shl 24)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取主题颜色属性
|
||||||
|
*/
|
||||||
|
fun getColorAttr(@AttrRes attrRes: Int): Int {
|
||||||
|
val typedValue = TypedValue()
|
||||||
|
appContext.theme.resolveAttribute(attrRes, typedValue, true)
|
||||||
|
return typedValue.data
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//==================== 扩展函数 ====================
|
||||||
|
/**
|
||||||
|
* Float的扩展函数:转换为dp像素值
|
||||||
|
*/
|
||||||
|
val Float.dp: Float
|
||||||
|
get() = ResUtil.dp(this)
|
||||||
|
|
||||||
|
val Float.dpToPx: Int
|
||||||
|
get() = ResUtil.dpToPx(this)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Int的扩展函数:转换为dp像素值
|
||||||
|
*/
|
||||||
|
val Int.dp: Float
|
||||||
|
get() = ResUtil.dp(this)
|
||||||
|
|
||||||
|
val Int.dpToPx: Int
|
||||||
|
get() = ResUtil.dpToPx(this)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Float的扩展函数:转换为sp像素值
|
||||||
|
*/
|
||||||
|
val Float.sp: Float
|
||||||
|
get() = ResUtil.sp(this)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字符串的扩展函数:解析颜色
|
||||||
|
*/
|
||||||
|
val String.colorInt: Int
|
||||||
|
get() = ResUtil.parseColor(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||