V1.0.5(6) 增加重试按钮
This commit is contained in:
parent
d14c57fb95
commit
e7d7a4e7eb
@ -6,6 +6,7 @@ import android.content.SharedPreferences
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.DataSource
|
||||
@ -80,7 +81,6 @@ class DownloadActivity :
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun initTitle() {
|
||||
binding.bgName.text = "Keyboard background"
|
||||
}
|
||||
@ -100,6 +100,7 @@ class DownloadActivity :
|
||||
}
|
||||
|
||||
private fun initStyleList() {
|
||||
retryBtnStatus(false)
|
||||
val listOf = mutableListOf<String>()
|
||||
backgroundEntity.skinNumber.let {
|
||||
for (i in 0 until 5) {
|
||||
@ -114,7 +115,7 @@ class DownloadActivity :
|
||||
val keyAdapter = KeyAdapter(this, defaultStyle, listOf) {
|
||||
selectedStyle = it + 1
|
||||
if (appliedSkinNumber == backgroundEntity.skinNumber.toString()) {
|
||||
updateBtn(appliedSkinStyle == selectedStyle)
|
||||
updateBtn(if (appliedSkinStyle == selectedStyle) 0 else 1)
|
||||
}
|
||||
}
|
||||
binding.listRecycler.run {
|
||||
@ -126,35 +127,49 @@ class DownloadActivity :
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun initButton() {
|
||||
binding.downloadBack.setOnClickListener(this)
|
||||
binding.btnDownload.setOnClickListener(this)
|
||||
binding.imLike.setOnClickListener(this)
|
||||
binding.btnRetry.setOnClickListener(this)
|
||||
}
|
||||
|
||||
/**
|
||||
* isApplied 是否已经apply
|
||||
* 0 已经apply 2 下载失败置灰
|
||||
*/
|
||||
private fun updateBtn(isApplied: Boolean) {
|
||||
binding.btnDownload.isSelected = isApplied
|
||||
binding.btnDownload.isEnabled = !isApplied
|
||||
if (isApplied) {
|
||||
private fun updateBtn(type: Int) {
|
||||
|
||||
when (type) {
|
||||
0 -> {
|
||||
binding.btnDownload.isSelected = true
|
||||
binding.btnDownload.isEnabled = false
|
||||
binding.btnDownload.text = getString(R.string.applied)
|
||||
} else {
|
||||
}
|
||||
|
||||
1 -> {
|
||||
binding.btnDownload.isSelected = false
|
||||
binding.btnDownload.isEnabled = true
|
||||
binding.btnDownload.text = getString(R.string.apply)
|
||||
}
|
||||
|
||||
2 -> {
|
||||
binding.btnDownload.isSelected = true
|
||||
binding.btnDownload.isEnabled = false
|
||||
binding.btnDownload.text = getString(R.string.apply)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun initImg() {
|
||||
appliedSkinNumber = sp.getString(AppConstant.KEY_CUR_Skin_Number, "") ?: run { "-1" }
|
||||
appliedSkinStyle = sp.getInt(AppConstant.KEY_CUR_STYLE, -1)
|
||||
if (appliedSkinNumber == backgroundEntity.skinNumber.toString()) {
|
||||
updateBtn(appliedSkinStyle == selectedStyle)
|
||||
}else{
|
||||
updateBtn(false)
|
||||
}
|
||||
// if (appliedSkinNumber == backgroundEntity.skinNumber.toString()) {
|
||||
// updateBtn(if (appliedSkinStyle == selectedStyle) 0 else 1)
|
||||
// } else {
|
||||
// updateBtn(1)
|
||||
// }
|
||||
binding.imLike.isSelected = backgroundEntity.like
|
||||
try {
|
||||
Glide
|
||||
@ -181,13 +196,26 @@ class DownloadActivity :
|
||||
|
||||
}
|
||||
|
||||
binding.btnRetry->{
|
||||
binding.downloadProgress.visibility = View.VISIBLE
|
||||
initDownload()
|
||||
}
|
||||
|
||||
binding.imLike -> {
|
||||
AdManager.showTopOn(this@DownloadActivity){
|
||||
AdManager.showTopOn(this@DownloadActivity) {
|
||||
binding.imLike.isSelected = !binding.imLike.isSelected
|
||||
if(binding.imLike.isSelected){
|
||||
Toast.makeText(this@DownloadActivity,getString(R.string.add_success),Toast.LENGTH_SHORT).show()
|
||||
}else{
|
||||
Toast.makeText(this@DownloadActivity,getString(R.string.cancel_success),Toast.LENGTH_SHORT).show()
|
||||
if (binding.imLike.isSelected) {
|
||||
Toast.makeText(
|
||||
this@DownloadActivity,
|
||||
getString(R.string.add_success),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
} else {
|
||||
Toast.makeText(
|
||||
this@DownloadActivity,
|
||||
getString(R.string.cancel_success),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,7 +263,10 @@ class DownloadActivity :
|
||||
putInt(AppConstant.KEY_CUR_STYLE, selectedStyle)
|
||||
putString(AppConstant.KEY_CUR_Bg, backgroundEntity.coverPath)
|
||||
apply()
|
||||
Log.d(App.TAG, "------putConfig ----skin_Number = ${ backgroundEntity.skinNumber} style=${selectedStyle} ")
|
||||
Log.d(
|
||||
App.TAG,
|
||||
"------putConfig ----skin_Number = ${backgroundEntity.skinNumber} style=${selectedStyle} "
|
||||
)
|
||||
}
|
||||
|
||||
binding.downloadProgress.visibility = View.GONE
|
||||
@ -318,11 +349,21 @@ class DownloadActivity :
|
||||
unzipPath = str
|
||||
binding.downloadProgress.visibility = View.GONE
|
||||
if (isSuccess) {
|
||||
|
||||
initStyleList()
|
||||
} else {
|
||||
Toast.makeText(this, getString(R.string.reenter), Toast.LENGTH_LONG).show()
|
||||
retryBtnStatus(true)
|
||||
Toast.makeText(this, getString(R.string.reenter), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
private fun retryBtnStatus(showRetry:Boolean){
|
||||
binding.btnRetry.isVisible = showRetry
|
||||
if(showRetry){
|
||||
updateBtn(2)
|
||||
}else{
|
||||
updateBtn(1)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -13,7 +13,7 @@ class LoadingActivity : BaseActivity() {
|
||||
|
||||
private var countDownTimer: CountDownTimer?= null
|
||||
|
||||
private val time = 12000L
|
||||
private val time = 13000L
|
||||
override fun onUI() {
|
||||
countDownTimer = AdManager.showWelcomeAd(this@LoadingActivity, time, { millisUntilFinished ->
|
||||
val percentage: Float = 100 - millisUntilFinished.toFloat() / time * 100
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
@ -44,12 +43,12 @@
|
||||
android:textSize="18sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/im_like"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="40dp"
|
||||
android:paddingStart="5dp"
|
||||
android:paddingEnd="15dp"
|
||||
android:paddingTop="5dp"
|
||||
android:id="@+id/im_like"
|
||||
android:paddingEnd="15dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:src="@drawable/selector_like" />
|
||||
</LinearLayout>
|
||||
@ -100,7 +99,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginStart="70dp"
|
||||
android:layout_marginTop="50dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginEnd="70dp"
|
||||
android:background="@drawable/selector_step"
|
||||
android:gravity="center"
|
||||
@ -108,6 +107,24 @@
|
||||
android:textColor="@color/step_text_color"
|
||||
android:textSize="19sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/btn_retry"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginStart="70dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginEnd="70dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:background="@drawable/selector_step"
|
||||
android:gravity="center"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:text="@string/retry"
|
||||
android:visibility="gone"
|
||||
android:textColor="@color/step_text_color"
|
||||
android:textSize="19sp" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
<string name="unEnable">If the keyboard is not enabled, please set it in the settings</string>
|
||||
<string name="succ_apply">Application successful</string>
|
||||
<string name="fail_apply">Application failed, please try again</string>
|
||||
<string name="reenter">Download failed, please re-enter this page</string>
|
||||
<string name="reenter">Please check your network connection and try again</string>
|
||||
<string name="slect_key">Please select the following button background</string>
|
||||
<string name="display">Display</string>
|
||||
<string name="display_et">Enter text to see the effect</string>
|
||||
@ -27,6 +27,7 @@
|
||||
<string name="app_privacy">Privacy Policy</string>
|
||||
<string name="add_success">Added to favorites successfully</string>
|
||||
<string name="cancel_success">Successfully canceled the collection</string>
|
||||
<string name="retry">Retry</string>
|
||||
|
||||
<string name="delete_res">skin_%s_delete_emoji.png</string>
|
||||
<string name="caps_res">skin_%s_caps_enabled.png</string>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user