Commit b5cc1dbc authored by wanglei's avatar wanglei

...

parent d6a1ce42
package com.base.scanqr.bean
import com.base.scanqr.utils.AppPreferences
class FunctionUIBean(
val key: String = "",
val icon: Int = 0,
val desc: String = ""
val desc: String = "",
var showGuide: Boolean = AppPreferences.getInstance().getBoolean("${key}_guide", true)
) {
var isPlaying: Boolean = false
companion object {
const val KEY_WIFI = "key_wifi"
......
......@@ -105,7 +105,7 @@ class ContractActivity : BaseActivity<ActivityContractBinding>(ActivityContractB
return@setOnClickListener
}
if (AdConfigBean.adsConfigBean.functionUseShowAd) {
AdsMgr.showInsert(this, false, object : AdsShowCallBack() {
AdsMgr.showInsert(this, true, object : AdsShowCallBack() {
override fun close(where: Int) {
jumpCodeActivity()
}
......
......@@ -73,7 +73,7 @@ class EmailActivity : BaseActivity<ActivityEmailBinding>(ActivityEmailBinding::i
email.message = binding.editMessage.text.toString()
val activity = this
if (AdConfigBean.adsConfigBean.functionUseShowAd) {
AdsMgr.showInsert(activity, false, object : AdsShowCallBack() {
AdsMgr.showInsert(activity, true, object : AdsShowCallBack() {
override fun close(where: Int) {
jumpCodeActivity()
}
......
......@@ -201,7 +201,7 @@ class EventActivity : BaseActivity<ActivityEventBinding>(ActivityEventBinding::i
}
if (AdConfigBean.adsConfigBean.functionUseShowAd) {
AdsMgr.showInsert(this, false, object : AdsShowCallBack() {
AdsMgr.showInsert(this, true, object : AdsShowCallBack() {
override fun close(where: Int) {
jumpCodeActivity()
}
......
package com.base.scanqr.ui.main
import android.annotation.SuppressLint
import android.content.Intent
import androidx.core.view.updatePadding
import androidx.recyclerview.widget.GridLayoutManager
......@@ -31,6 +32,7 @@ import com.base.scanqr.ui.wifi.WifiActivity
import com.base.scanqr.utils.AppPreferences
import com.base.scanqr.utils.BarUtils
import com.base.scanqr.utils.ClickTimesUtils.isContinuousTimesClick
import com.base.scanqr.utils.LogEx
import com.google.gson.Gson
import com.gyf.immersionbar.ktx.immersionBar
......@@ -38,14 +40,7 @@ class CreateFragment : BaseFragment<FragmentCreateBinding>(FragmentCreateBinding
private var adapter: FunctionAdapter? = null
override fun initView() {
super.initView()
binding.tvTitle.updatePadding(top = BarUtils.getStatusBarHeight())
binding.ivVip.updatePadding(top = BarUtils.getStatusBarHeight())
adapter = FunctionAdapter()
binding.rv.layoutManager = GridLayoutManager(requireContext(), 3)
binding.rv.adapter = adapter
adapter?.submitList(
private val functions by lazy(LazyThreadSafetyMode.NONE) {
listOf(
FunctionUIBean(KEY_WIFI, R.mipmap.h_wifi, resources.getString(R.string.wifi)),
FunctionUIBean(KEY_TEXT, R.mipmap.h_text, resources.getString(R.string.text)),
......@@ -57,7 +52,16 @@ class CreateFragment : BaseFragment<FragmentCreateBinding>(FragmentCreateBinding
FunctionUIBean(KEY_TELEPHONE, R.mipmap.h_telephone, resources.getString(R.string.telephone)),
FunctionUIBean(KEY_MESSAGE, R.mipmap.h_message, resources.getString(R.string.message)),
)
)
}
override fun initView() {
super.initView()
binding.tvTitle.updatePadding(top = BarUtils.getStatusBarHeight())
binding.ivVip.updatePadding(top = BarUtils.getStatusBarHeight())
adapter = FunctionAdapter()
binding.rv.layoutManager = GridLayoutManager(requireContext(), 3)
binding.rv.adapter = adapter
adapter?.submitList(functions)
adapter?.itemClick = { key ->
val activity = requireActivity() as MainActivity?
activity?.let {
......@@ -83,7 +87,13 @@ class CreateFragment : BaseFragment<FragmentCreateBinding>(FragmentCreateBinding
}
}
@SuppressLint("NotifyDataSetChanged")
private fun itemKeyClick(key: String) {
val bean = functions.find { it.key == key }
if (bean?.isPlaying == true) {
bean.showGuide = false
AppPreferences.getInstance().put("${key}_guide", false)
}
when (key) {
KEY_WIFI -> {
startActivity(Intent(requireContext(), WifiActivity::class.java))
......@@ -119,6 +129,12 @@ class CreateFragment : BaseFragment<FragmentCreateBinding>(FragmentCreateBinding
}
}
@SuppressLint("NotifyDataSetChanged")
override fun onResumeOneShoot() {
super.onResumeOneShoot()
adapter?.changeGuide()
}
override fun onResume() {
super.onResume()
immersionBar {
......
package com.base.scanqr.ui.main
import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.annotation.SuppressLint
import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.view.animation.AccelerateDecelerateInterpolator
import com.base.scanqr.R
import com.base.scanqr.bean.FunctionUIBean
import com.base.scanqr.databinding.ItemFunctionBinding
import com.base.scanqr.ui.adapter.CommonViewHolder
import com.base.scanqr.utils.AppPreferences
import com.base.scanqr.utils.LogEx
import com.base.scanqr.utils.XmlEx.inflate
import com.chad.library.adapter4.BaseQuickAdapter
class FunctionAdapter : BaseQuickAdapter<FunctionUIBean, CommonViewHolder>() {
private val TAG = "FunctionAdapter"
var itemClick: ((key: String) -> Unit)? = null
var isGuide: Boolean = false
override fun onBindViewHolder(holder: CommonViewHolder, position: Int, item: FunctionUIBean?) {
item ?: return
val binding = ItemFunctionBinding.bind(holder.itemView)
binding.iv.setImageResource(item.icon)
binding.tvDesc.text = item.desc
kotlin.runCatching {
if (binding.fl.tag is AnimatorSet) {
(binding.fl.tag as AnimatorSet).cancel()
LogEx.logDebug(TAG, "AnimatorSet cancel")
}
}
LogEx.logDebug(TAG, "isGuide=$isGuide showGuide=${item.showGuide} isPlaying=${item.isPlaying}")
if (!isGuide) {
if (item.showGuide) {
isGuide = true
item.isPlaying = true
showHeartAnimation(binding.fl)
}
}
binding.root.setOnClickListener {
itemClick?.invoke(item.key)
}
......@@ -26,4 +51,36 @@ class FunctionAdapter : BaseQuickAdapter<FunctionUIBean, CommonViewHolder>() {
override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): CommonViewHolder {
return CommonViewHolder(R.layout.item_function.inflate(parent))
}
private fun showHeartAnimation(view: View): AnimatorSet {
val scaleXAnimator = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.75f, 1f)
val scaleYAnimator = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0.75f, 1f)
scaleXAnimator.duration = 800 // 动画持续时间,可根据需要调整
scaleYAnimator.duration = 800
scaleXAnimator.interpolator = AccelerateDecelerateInterpolator()
scaleYAnimator.interpolator = AccelerateDecelerateInterpolator()
scaleXAnimator.repeatCount = ObjectAnimator.INFINITE // 设置动画无限循环
scaleYAnimator.repeatCount = ObjectAnimator.INFINITE
val animatorSet = AnimatorSet()
animatorSet.playTogether(scaleXAnimator, scaleYAnimator) // 同时播放两个动画
animatorSet.start()
view.tag = animatorSet
return animatorSet
}
@SuppressLint("NotifyDataSetChanged")
fun changeGuide() {
isGuide = false
items.forEach { it.showGuide = AppPreferences.getInstance().getBoolean("${it.key}_guide", true) }
notifyDataSetChanged()
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import android.graphics.Color
import android.view.LayoutInflater
import android.widget.TextView
import androidx.activity.addCallback
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
import com.base.scanqr.R
......@@ -19,6 +20,7 @@ import com.base.scanqr.bean.config.AdConfigBean
import com.base.scanqr.databinding.ActivityMainBinding
import com.base.scanqr.databinding.ItemHomeTabBinding
import com.base.scanqr.qr.CameraUtils
import com.base.scanqr.ui.vm.QrViewModel
import com.base.scanqr.ui.widget.AppExitDialog.showAppExitDialog
import com.base.scanqr.ui.widget.NotificationDialog.showNotificationTurnOn
import com.base.scanqr.utils.LogEx
......@@ -35,6 +37,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(ActivityMainBinding::infl
private var navController: NavController? = null
var cameraUtils: CameraUtils? = null
private val homeTabs by lazy {
arrayOf(
HomeTabUIBean(R.drawable.bg_selector_create, getString(R.string.create)),
......@@ -170,8 +173,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>(ActivityMainBinding::infl
1 -> {
tabAt = 1
navController?.navigate(R.id.scanFragment)
if (!isScanTabFirst && tabCanShowAd() && AdConfigBean.adsConfigBean.scanTabShowAd) {
isScanTabFirst = false
val flag = !isScanTabFirst && tabCanShowAd() && AdConfigBean.adsConfigBean.scanTabShowAd
LogEx.logDebug(TAG, "flag=$flag")
if (flag) {
AdsMgr.showInsert(this, false, object : AdsShowCallBack() {
override fun show() {
mainFgTabLastShow = System.currentTimeMillis()
......@@ -187,6 +191,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(ActivityMainBinding::infl
}
})
}
isScanTabFirst = false
}
2 -> {
......
......@@ -105,7 +105,7 @@ class MessageActivity : BaseActivity<ActivityMessageBinding>(ActivityMessageBind
return@setOnClickListener
}
if (AdConfigBean.adsConfigBean.functionUseShowAd) {
AdsMgr.showInsert(this, false, object : AdsShowCallBack() {
AdsMgr.showInsert(this, true, object : AdsShowCallBack() {
override fun close(where: Int) {
jumpCodeActivity()
}
......
......@@ -85,7 +85,7 @@ class TelephoneActivity : BaseActivity<ActivityTelephoneBinding>(ActivityTelepho
return@setOnClickListener
}
if (AdConfigBean.adsConfigBean.functionUseShowAd) {
AdsMgr.showInsert(this, false, object : AdsShowCallBack() {
AdsMgr.showInsert(this, true, object : AdsShowCallBack() {
override fun close(where: Int) {
jumpCodeActivity()
}
......
......@@ -60,7 +60,7 @@ class TextActivity : BaseActivity<ActivityTextBinding>(ActivityTextBinding::infl
}
if (AdConfigBean.adsConfigBean.functionUseShowAd) {
AdsMgr.showInsert(this, false, object : AdsShowCallBack() {
AdsMgr.showInsert(this, true, object : AdsShowCallBack() {
override fun close(where: Int) {
jumpCodeActivity()
}
......
......@@ -71,7 +71,7 @@ class WebsiteActivity : BaseActivity<ActivityWebsiteBinding>(ActivityWebsiteBind
binding.flQueren.setOnClickListener {
if (websiteUIBean.http.startsWith("http://") || websiteUIBean.http.startsWith("https://")) {
if (AdConfigBean.adsConfigBean.functionUseShowAd) {
AdsMgr.showInsert(this,false,object :AdsShowCallBack(){
AdsMgr.showInsert(this,true,object :AdsShowCallBack(){
override fun close(where: Int) {
jumpCodeActivity()
}
......
......@@ -152,8 +152,8 @@ class WifiActivity : BaseActivity<ActivityWifiBinding>(ActivityWifiBinding::infl
return@setOnClickListener
}
if (AdConfigBean.adsConfigBean.functionUseShowAd){
AdsMgr.showInsert(this,false,object :AdsShowCallBack(){
if (AdConfigBean.adsConfigBean.functionUseShowAd) {
AdsMgr.showInsert(this, true, object : AdsShowCallBack() {
override fun close(where: Int) {
jumpCodeActivity()
}
......@@ -166,7 +166,7 @@ class WifiActivity : BaseActivity<ActivityWifiBinding>(ActivityWifiBinding::infl
jumpCodeActivity()
}
})
}else{
} else {
jumpCodeActivity()
}
}
......
package com.base.scanqr.ui.wifi
import android.os.Environment
import androidx.activity.addCallback
import androidx.core.view.updatePadding
import androidx.lifecycle.ViewModelProvider
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white"/>
<corners android:radius="20dp"/>
</shape>
\ No newline at end of file
......@@ -4,7 +4,11 @@
<solid android:color="@color/white" />
<stroke
android:width="0.5dp"
android:color="#E4E4E4" />
android:color="@android:color/transparent" />
<corners android:radius="20dp" />
<gradient
android:angle="0"
android:centerColor="#FFFAA6"
android:endColor="#8069FF"
android:startColor="#FFB98C" />
</shape>
\ No newline at end of file
......@@ -8,12 +8,24 @@
android:layout_marginVertical="8dp"
android:background="@drawable/bg_stroke_e4e4e4_20">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:background="@drawable/bg_ffffff_20">
<FrameLayout
android:id="@+id/fl"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="UselessParent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:padding="2dp"
tools:ignore="UseCompoundDrawables,UselessParent">
<ImageView
......@@ -37,4 +49,10 @@
</LinearLayout>
</FrameLayout>
</FrameLayout>
</FrameLayout>
\ No newline at end of file
This image diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment