完成"首页插件化提示区域优化"的红点优化 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/898

This commit is contained in:
chenjuntao
2020-06-18 17:32:17 +08:00
parent 7fb502e87e
commit c2eb0b267c
4 changed files with 36 additions and 7 deletions

View File

@ -33,6 +33,9 @@ object HomePluggableHelper {
return true
}
@JvmStatic
fun getPermanentInactivePluggablePackage() = mHomePluggableFilterDao.getDataByTag("never")
@JvmStatic
fun activationFilterData() {
val filterList = mHomePluggableFilterDao.getDataByActive(false)

View File

@ -17,6 +17,7 @@ import com.gh.common.util.DataCollectionUtils;
import com.gh.common.util.DeviceUtils;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.GdtHelper;
import com.gh.common.util.HomePluggableHelper;
import com.gh.common.util.MD5Utils;
import com.gh.common.util.MtaHelper;
import com.gh.common.util.NetworkUtils;
@ -25,6 +26,7 @@ import com.gh.common.util.SPUtils;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.GameUpdateEntity;
import com.gh.gamecenter.entity.HomePluggableFilterEntity;
import com.gh.gamecenter.entity.PluginLocation;
import com.gh.gamecenter.eventbus.EBDownloadStatus;
import com.gh.gamecenter.manager.PackagesManager;
@ -138,7 +140,6 @@ public class DownloadManager implements DownloadStatusListener {
mUpdateMarks = SPUtils.getStringSet(UPDATE_IS_READ_MARK);
//TODO unregister this
DownloadStatusManager.getInstance().registerTaskStatusListener(this);
// 只有下载模块需要这坨东西,因此移动到这里初始化
@ -152,7 +153,6 @@ public class DownloadManager implements DownloadStatusListener {
statusMap = new ArrayMap<>();
downloadingMap = new ArrayMap<>();
// TODO 这里的 handler 类的 case 可能会被多次调用,原因未知
mHandler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message msg) {
@ -722,12 +722,26 @@ public class DownloadManager implements DownloadStatusListener {
}
if (showRedPoint) return "";
if (updateList != null) {
// 首页永久忽略的插件化列表
List<HomePluggableFilterEntity> permanentInactiveUpdateList = HomePluggableHelper.getPermanentInactivePluggablePackage();
for (GameUpdateEntity updateEntity : updateList) {
if (updateEntity.isShowPlugin(PluginLocation.only_index)
&& !mUpdateMarks.contains(updateEntity.getId() + updateEntity.getPackageName())) {
return "";
if (updateEntity.isShowPlugin(PluginLocation.only_index) && !mUpdateMarks.contains(updateEntity.getId() + updateEntity.getPackageName())) {
// 判断该更新的的包名是否被永久忽略
if (permanentInactiveUpdateList != null) {
boolean isPluggablePermanentInactive = false;
for (HomePluggableFilterEntity filterEntity : permanentInactiveUpdateList) {
if (filterEntity.getPkgName().equals(updateEntity.getPackageName())) {
isPluggablePermanentInactive = true;
}
}
if (!isPluggablePermanentInactive) {
return "";
}
} else {
return "";
}
}
}
}

View File

@ -9,12 +9,14 @@ import android.widget.LinearLayout
import android.widget.TextView
import androidx.fragment.app.Fragment
import com.gh.base.fragment.BaseFragment_TabLayout
import com.gh.common.util.HomePluggableHelper
import com.gh.common.util.MtaHelper
import com.gh.common.util.dip2px
import com.gh.common.util.visibleIf
import com.gh.download.DownloadManager
import com.gh.gamecenter.DownloadManagerActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.entity.HomePluggableFilterEntity
import com.gh.gamecenter.entity.PluginLocation
import com.gh.gamecenter.eventbus.EBDownloadChanged
import com.gh.gamecenter.eventbus.EBMiPush
@ -42,10 +44,13 @@ class DownloadFragment : BaseFragment_TabLayout() {
private lateinit var mUpdateNumber: TextView
private lateinit var mDownloadManager: DownloadManager
private var mPermanentInactivePluggableApkList: List<HomePluggableFilterEntity>? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mDownloadManager = DownloadManager.getInstance(HaloApp.getInstance().application)
mPermanentInactivePluggableApkList = HomePluggableHelper.getPermanentInactivePluggablePackage()
}
override fun initFragmentList(fragments: MutableList<Fragment>) {
@ -190,7 +195,11 @@ class DownloadFragment : BaseFragment_TabLayout() {
return
}
val updateCount = mDownloadManager.getUnreadUpdateCount(PackagesManager.getUpdateList().filter { it.isShowPlugin(PluginLocation.only_index) })
val updateCount = mDownloadManager.getUnreadUpdateCount(PackagesManager.getUpdateList()
.filter { gameUpdateEntity ->
gameUpdateEntity.isShowPlugin(PluginLocation.only_index)
&& mPermanentInactivePluggableApkList?.filter { it.pkgName == gameUpdateEntity.packageName }?.size == 0
})
mUpdateNumber.visibleIf(updateCount != 0)
}

View File

@ -15,6 +15,9 @@ interface HomePluggableFilterDao {
@Query("select * from HomePluggableFilterEntity where active = :active")
fun getDataByActive(active: Boolean): List<HomePluggableFilterEntity>?
@Query("select * from HomePluggableFilterEntity where tag = :tag")
fun getDataByTag(tag: String): List<HomePluggableFilterEntity>?
@Query("select * from HomePluggableFilterEntity where pkgName = :pkgName")
fun getDataByPkgName(pkgName: String?): HomePluggableFilterEntity?