领取成功显示 自定义toast

This commit is contained in:
renhaoting 2026-01-12 11:30:12 +08:00
parent ceb91122b0
commit e7ab378394
6 changed files with 14 additions and 12 deletions

View File

@ -226,7 +226,8 @@ class BenefitActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
setOnClickListener { setOnClickListener {
if (taskStateHelper.executeClaimCash()) { if (taskStateHelper.executeClaimCash()) {
AndroidUtil.showToast(String.format(ResUtil.getString(R.string.has_claim_box_cash_hint), couldClaimCashNum)) //AndroidUtil.showToast(String.format(ResUtil.getString(R.string.has_claim_box_cash_hint), couldClaimCashNum))
AndroidUtil.showCustomToast(String.format(ResUtil.getString(R.string.has_claim_box_cash_hint), couldClaimCashNum))
} }
} }
} }

View File

@ -107,7 +107,7 @@
<string name="box_subtask_hint_3_1">Assistir a 30 anúncios</string> <string name="box_subtask_hint_3_1">Assistir a 30 anúncios</string>
<string name="box_subtask_hint_3_2">Assistir a 50 vídeos</string> <string name="box_subtask_hint_3_2">Assistir a 50 vídeos</string>
<string name="box_subtask_hint_3_3">Participar de 10 compras gratuitas</string> <string name="box_subtask_hint_3_3">Participar de 10 compras gratuitas</string>
<string name="has_claim_box_cash_hint">%d foram retirados com sucesso.</string> <string name="has_claim_box_cash_hint">Parabéns! Você ganhou\n%d</string>
<string name="cur_version">Current Version:</string> <string name="cur_version">Current Version:</string>

View File

@ -2,10 +2,8 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> android:shape="rectangle">
<solid android:color="#66EEEEEE" /> <solid android:color="#f22c2c2c" />
<corners android:radius="15dp" /> <corners android:radius="15dp" />
<stroke <stroke android:width="0dp" android:color="#00000000" />
android:width="0dp"
android:color="#00000000" />
</shape> </shape>

View File

@ -82,7 +82,7 @@ class AndroidUtil private constructor() {
} }
} }
fun showCustomToast(textStr: String, iconRes: Int) { fun showCustomToast(textStr: String, iconRes: Int = 0) {
val layout: View = LayoutInflater.from(BaseApp.appContext()).inflate(R.layout.layout_toast_center, null) val layout: View = LayoutInflater.from(BaseApp.appContext()).inflate(R.layout.layout_toast_center, null)
layout.findViewById<AppCompatImageView>(R.id.iv_top).setImageResource(iconRes) layout.findViewById<AppCompatImageView>(R.id.iv_top).setImageResource(iconRes)
layout.findViewById<AppCompatTextView>(R.id.tv_bottom).text = textStr layout.findViewById<AppCompatTextView>(R.id.tv_bottom).text = textStr

View File

@ -2,8 +2,9 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="150dp" android:layout_width="240dp"
android:layout_height="150dp" android:layout_height="wrap_content"
android:minHeight="120dp"
android:background="@drawable/bg_custom_toast" android:background="@drawable/bg_custom_toast"
tools:ignore="ResourceName"> tools:ignore="ResourceName">
@ -18,15 +19,17 @@
android:id="@+id/iv_top" android:id="@+id/iv_top"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:src="@mipmap/home_gold" /> android:src="@mipmap/icon_cash3" />
<TextView <TextView
android:id="@+id/tv_bottom" android:id="@+id/tv_bottom"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:gravity="center"
android:text="hint" android:text="hint"
android:textSize="15sp" android:textColor="@color/white"
android:textSize="14sp"
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB