Merge remote-tracking branch 'origin/release' into dev
# Conflicts: # app/src/main/java/com/gh/gamecenter/catalog/CatalogFragment.kt # app/src/main/java/com/gh/gamecenter/catalog/SubCatalogFragment.kt
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.database.sqlite.SQLiteFullException
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.HomePluggableFilterEntity
|
||||
import com.gh.gamecenter.room.AppDatabase
|
||||
@ -48,7 +47,7 @@ object HomePluggableHelper {
|
||||
}
|
||||
mHomePluggableFilterDao.addData(filterList)
|
||||
}
|
||||
} catch (e: SQLiteFullException) {
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
toastInInternalRelease("数据库/磁盘已满,插件筛选失败")
|
||||
}
|
||||
|
||||
@ -621,6 +621,13 @@ public class PackageUtils {
|
||||
if (!pm.isScreenOn()) return false;
|
||||
}
|
||||
|
||||
// 上面的判断逻辑可能还是不够用,还是有少部分
|
||||
// Not allowed to start service Intent: app is in background 错误
|
||||
// 这里补充个自有的规则
|
||||
if (!HaloApp.getInstance().isRunningForeground) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String packageName = context.getApplicationContext().getPackageName();
|
||||
for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) {
|
||||
// The name of the process that this object is associated with.
|
||||
|
||||
@ -490,10 +490,15 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
* @param packageName 包名
|
||||
* @return null表示下载列表中不存在该任务,否则返回下载任务
|
||||
*/
|
||||
@Nullable
|
||||
public DownloadEntity getDownloadEntityByPackageName(String packageName) {
|
||||
if (mDownloadDao == null) return null;
|
||||
|
||||
for (DownloadEntity downloadEntity : mDownloadDao.getAll()) {
|
||||
List<DownloadEntity> downloadList = mDownloadDao.getAll();
|
||||
|
||||
if (downloadList == null) return null;
|
||||
|
||||
for (DownloadEntity downloadEntity : downloadList) {
|
||||
if (packageName.equals(downloadEntity.getPackageName())) {
|
||||
return downloadEntity;
|
||||
}
|
||||
@ -762,7 +767,16 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
serviceIntent.putExtra(DownloadService.KEY_SERVICE_ACTION, DownloadService.START_FOREGROUND);
|
||||
mContext.startForegroundService(serviceIntent);
|
||||
} else {
|
||||
mContext.startService(serviceIntent);
|
||||
/*
|
||||
* sentry上报oppo手机无法启动服务,原因:OPPO手机自动熄屏一段时间后,会启用系统自带的电量优化管理,禁止一切自启动的APP(用户设置的自启动白名单除外),所以在服务启动的地方进行try/catch防止崩溃,
|
||||
* https://sentry.ghzs.com/organizations/lightgame/issues/10707/?project=22&query=is%3Aunresolved+assigned%3Ame&statsPeriod=14d,
|
||||
* https://stackoverflow.com/questions/38764497/security-exception-unable-to-start-service-user-0-is-restricted
|
||||
*/
|
||||
ExtensionsKt.tryWithDefaultCatch(() -> {
|
||||
mContext.startService(serviceIntent);
|
||||
return null;
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -329,10 +329,9 @@ public class SuggestionActivity extends ToolBarActivity implements OnRequestCall
|
||||
String[] filePathColumn = {MediaStore.Images.Media.DATA};
|
||||
|
||||
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
|
||||
if (cursor == null) {
|
||||
if (cursor == null || !cursor.moveToFirst()) {
|
||||
return;
|
||||
}
|
||||
cursor.moveToFirst();
|
||||
|
||||
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
|
||||
String picturePath = cursor.getString(columnIndex);
|
||||
|
||||
@ -14,11 +14,11 @@ import com.gh.gamecenter.normal.NormalFragment
|
||||
|
||||
class CatalogFragment : NormalFragment() {
|
||||
|
||||
private lateinit var mBinding: FragmentCatalogBinding
|
||||
private lateinit var mViewModel: CatalogViewModel
|
||||
private lateinit var mEntity: CatalogEntity
|
||||
private lateinit var mSpecialCatalogFragment: SpecialCatalogFragment
|
||||
private lateinit var mSubCatalogFragment: SubCatalogFragment
|
||||
private var mBinding: FragmentCatalogBinding? = null
|
||||
private var mViewModel: CatalogViewModel? = null
|
||||
private var mEntity: CatalogEntity? = null
|
||||
private var mSpecialCatalogFragment: SpecialCatalogFragment? = null
|
||||
private var mSubCatalogFragment: SubCatalogFragment? = null
|
||||
|
||||
private var mCatalogId: String = ""
|
||||
private var mCatalogTitle: String = ""
|
||||
@ -33,15 +33,15 @@ class CatalogFragment : NormalFragment() {
|
||||
mCatalogTitle = arguments?.getString(EntranceUtils.KEY_CATALOG_TITLE) ?: ""
|
||||
mViewModel = viewModelProviderFromParent(CatalogViewModel.Factory(mCatalogId, mCatalogTitle))
|
||||
|
||||
mViewModel.validEntranceName = if (mEntrance.contains("首页")) "首页" else "板块"
|
||||
mViewModel.logAppearance()
|
||||
mViewModel?.validEntranceName = if (mEntrance.contains("首页")) "首页" else "板块"
|
||||
mViewModel?.logAppearance()
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setNavigationTitle(mCatalogTitle)
|
||||
mViewModel.catalogs.observe(viewLifecycleOwner, Observer {
|
||||
mBinding.run {
|
||||
mViewModel?.catalogs?.observe(viewLifecycleOwner, Observer {
|
||||
mBinding?.run {
|
||||
reuseLoading.root.visibility = View.GONE
|
||||
if (it != null) {
|
||||
reuseNoConnection.root.visibility = View.GONE
|
||||
@ -49,9 +49,9 @@ class CatalogFragment : NormalFragment() {
|
||||
containerCatalog.visibility = View.VISIBLE
|
||||
reuseNoneData.root.visibility = View.GONE
|
||||
mEntity = it
|
||||
if (mEntity.hasSpecial) {
|
||||
if (mEntity!!.hasSpecial) {
|
||||
val specialEntity = CatalogEntity.SubCatalogEntity(name = "精选")
|
||||
(mEntity.subCatalog as ArrayList).add(0, specialEntity)
|
||||
(mEntity!!.subCatalog as ArrayList).add(0, specialEntity)
|
||||
}
|
||||
initView()
|
||||
} else {
|
||||
@ -64,7 +64,7 @@ class CatalogFragment : NormalFragment() {
|
||||
reuseNoConnection.root.visibility = View.VISIBLE
|
||||
reuseNoConnection.root.setOnClickListener {
|
||||
reuseLoading.root.visibility = View.VISIBLE
|
||||
mViewModel.getCatalogs()
|
||||
mViewModel?.getCatalogs()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -72,45 +72,43 @@ class CatalogFragment : NormalFragment() {
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
mEntity.run {
|
||||
if (subCatalog.isNotEmpty()) {
|
||||
mViewModel.selectedCatalogName = subCatalog[0].name
|
||||
mBinding.rvCatalog.layoutManager = FixLinearLayoutManager(requireContext())
|
||||
mBinding.rvCatalog.adapter = CatalogAdapter(requireContext(), this@CatalogFragment, mViewModel, subCatalog)
|
||||
mEntity?.takeIf { it.subCatalog.isNotEmpty() && mViewModel != null }?.run {
|
||||
mViewModel?.selectedCatalogName = subCatalog[0].name
|
||||
mBinding?.rvCatalog?.layoutManager = FixLinearLayoutManager(requireContext())
|
||||
mBinding?.rvCatalog?.adapter = CatalogAdapter(requireContext(), this@CatalogFragment, mViewModel!!, subCatalog)
|
||||
|
||||
if (hasSpecial) {
|
||||
mSpecialCatalogFragment = childFragmentManager.findFragmentByTag(SpecialCatalogFragment::class.java.simpleName) as? SpecialCatalogFragment ?: SpecialCatalogFragment()
|
||||
mSpecialCatalogFragment.arguments = bundleOf(EntranceUtils.KEY_CATALOG_ID to mEntity.id, EntranceUtils.KEY_CATALOG_TITLE to mCatalogTitle)
|
||||
childFragmentManager.beginTransaction().replace(R.id.container_sub_catalog, mSpecialCatalogFragment, SpecialCatalogFragment::class.java.simpleName).commitAllowingStateLoss()
|
||||
} else {
|
||||
mSubCatalogFragment = childFragmentManager.findFragmentByTag(SubCatalogFragment::class.java.simpleName) as? SubCatalogFragment ?: SubCatalogFragment()
|
||||
mSubCatalogFragment.arguments = bundleOf(EntranceUtils.KEY_CATALOG_ID to mEntity.id, EntranceUtils.KEY_PRIMARY_CATALOG_ID to subCatalog[0].id, EntranceUtils.KEY_CATALOG_TITLE to mCatalogTitle)
|
||||
childFragmentManager.beginTransaction().replace(R.id.container_sub_catalog, mSubCatalogFragment, SubCatalogFragment::class.java.simpleName).commitAllowingStateLoss()
|
||||
}
|
||||
if (hasSpecial) {
|
||||
mSpecialCatalogFragment = childFragmentManager.findFragmentByTag(SpecialCatalogFragment::class.java.simpleName) as? SpecialCatalogFragment ?: SpecialCatalogFragment()
|
||||
mSpecialCatalogFragment?.arguments = bundleOf(EntranceUtils.KEY_CATALOG_ID to id, EntranceUtils.KEY_CATALOG_TITLE to mCatalogTitle)
|
||||
childFragmentManager.beginTransaction().replace(R.id.container_sub_catalog, mSpecialCatalogFragment!!, SpecialCatalogFragment::class.java.simpleName).commitAllowingStateLoss()
|
||||
} else {
|
||||
mSubCatalogFragment = childFragmentManager.findFragmentByTag(SubCatalogFragment::class.java.simpleName) as? SubCatalogFragment ?: SubCatalogFragment()
|
||||
mSubCatalogFragment?.arguments = bundleOf(EntranceUtils.KEY_CATALOG_ID to id, EntranceUtils.KEY_PRIMARY_CATALOG_ID to subCatalog[0].id, EntranceUtils.KEY_CATALOG_TITLE to mCatalogTitle)
|
||||
childFragmentManager.beginTransaction().replace(R.id.container_sub_catalog, mSubCatalogFragment!!, SubCatalogFragment::class.java.simpleName).commitAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun changeCatalog(position: Int) {
|
||||
mEntity.run {
|
||||
mEntity?.run {
|
||||
if (hasSpecial) {
|
||||
if (mViewModel.selectedCatalogPosition == 0) {
|
||||
if (mViewModel?.selectedCatalogPosition == 0) {
|
||||
mSubCatalogFragment = childFragmentManager.findFragmentByTag(SubCatalogFragment::class.java.simpleName) as? SubCatalogFragment ?: SubCatalogFragment()
|
||||
mSubCatalogFragment.arguments = bundleOf(EntranceUtils.KEY_CATALOG_ID to mEntity.id, EntranceUtils.KEY_PRIMARY_CATALOG_ID to subCatalog[position].id)
|
||||
childFragmentManager.beginTransaction().replace(R.id.container_sub_catalog, mSubCatalogFragment, SubCatalogFragment::class.java.simpleName).commitAllowingStateLoss()
|
||||
mSubCatalogFragment?.arguments = bundleOf(EntranceUtils.KEY_CATALOG_ID to id, EntranceUtils.KEY_PRIMARY_CATALOG_ID to subCatalog[position].id)
|
||||
childFragmentManager.beginTransaction().replace(R.id.container_sub_catalog, mSubCatalogFragment!!, SubCatalogFragment::class.java.simpleName).commitAllowingStateLoss()
|
||||
} else {
|
||||
if (position == 0) {
|
||||
mSpecialCatalogFragment = childFragmentManager.findFragmentByTag(SpecialCatalogFragment::class.java.simpleName) as? SpecialCatalogFragment ?: SpecialCatalogFragment()
|
||||
mSpecialCatalogFragment.arguments = bundleOf(EntranceUtils.KEY_CATALOG_ID to mEntity.id)
|
||||
childFragmentManager.beginTransaction().replace(R.id.container_sub_catalog, mSpecialCatalogFragment, SpecialCatalogFragment::class.java.simpleName).commitAllowingStateLoss()
|
||||
mSpecialCatalogFragment?.arguments = bundleOf(EntranceUtils.KEY_CATALOG_ID to id)
|
||||
childFragmentManager.beginTransaction().replace(R.id.container_sub_catalog, mSpecialCatalogFragment!!, SpecialCatalogFragment::class.java.simpleName).commitAllowingStateLoss()
|
||||
} else {
|
||||
mSubCatalogFragment.changeSubCatalog(subCatalog[position].id)
|
||||
mSubCatalogFragment?.changeSubCatalog(subCatalog[position].id)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mSubCatalogFragment.changeSubCatalog(subCatalog[position].id)
|
||||
mSubCatalogFragment?.changeSubCatalog(subCatalog[position].id)
|
||||
}
|
||||
mViewModel.selectedCatalogPosition = position
|
||||
mViewModel?.selectedCatalogPosition = position
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -137,7 +137,11 @@ class NewCatalogListAdapter(context: Context,
|
||||
|
||||
fun notifyItemByDownload(download: DownloadEntity) {
|
||||
for (key in positionAndPackageMap.keys) {
|
||||
if (key.contains(download.packageName) && key.contains(download.gameId)) {
|
||||
// sentry上报download.packageName可能为空
|
||||
if (download.packageName != null
|
||||
&& download.gameId != null
|
||||
&& key.contains(download.packageName)
|
||||
&& key.contains(download.gameId)) {
|
||||
val position = positionAndPackageMap[key]
|
||||
if (position != null && mEntityList != null && position < mEntityList.size) {
|
||||
mEntityList[position].getEntryMap()[download.platform] = download
|
||||
|
||||
@ -68,7 +68,7 @@ class NewCatalogListFragment : ListFragment<GameEntity, NewCatalogListViewModel>
|
||||
mViewModel.categoryTitle = arguments?.getString(EntranceUtils.KEY_CATALOG_TITLE) ?: ""
|
||||
mEntrance = arguments?.getString(EntranceUtils.KEY_ENTRANCE) ?: Constants.ENTRANCE_UNKNOWN
|
||||
mPrimeCatalog = arguments?.getParcelable(EntranceUtils.KEY_DATA)
|
||||
mSubCatalogList = mPrimeCatalog?.subCatalog as ArrayList<CatalogEntity.SubCatalogEntity>
|
||||
mSubCatalogList = mPrimeCatalog?.subCatalog as? ArrayList<CatalogEntity.SubCatalogEntity> ?: arrayListOf()
|
||||
|
||||
mInitCatalogName = arguments?.getString(EntranceUtils.KEY_CATALOG_INIT_TITLE) ?: ""
|
||||
mPrimaryCatalogName = arguments?.getString(EntranceUtils.KEY_PRIMARY_CATALOG_NAME) ?: ""
|
||||
|
||||
@ -13,10 +13,10 @@ import com.gh.gamecenter.normal.NormalFragment
|
||||
|
||||
class SubCatalogFragment : NormalFragment() {
|
||||
|
||||
private lateinit var mBinding: FragmentSubCatalogBinding
|
||||
private lateinit var mViewModel: SubCatalogViewModel
|
||||
private lateinit var mCatalogViewModel: CatalogViewModel
|
||||
private lateinit var mEntity: CatalogEntity
|
||||
private var mBinding: FragmentSubCatalogBinding? = null
|
||||
private var mViewModel: SubCatalogViewModel? = null
|
||||
private var mCatalogViewModel: CatalogViewModel? = null
|
||||
private var mEntity: CatalogEntity? = null
|
||||
private var mCatalogId: String = ""
|
||||
private var mCatalogTitle: String = ""
|
||||
private var mPrimaryCatalogId: String = ""
|
||||
@ -33,14 +33,14 @@ class SubCatalogFragment : NormalFragment() {
|
||||
mPrimaryCatalogId = arguments?.getString(EntranceUtils.KEY_PRIMARY_CATALOG_ID) ?: ""
|
||||
mViewModel = viewModelProvider(SubCatalogViewModel.Factory(mCatalogId))
|
||||
mCatalogViewModel = viewModelProviderFromParent(CatalogViewModel.Factory(mCatalogId, mCatalogTitle))
|
||||
mViewModel.getSubCatalogs(mPrimaryCatalogId)
|
||||
mViewModel?.getSubCatalogs(mPrimaryCatalogId)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
mViewModel.catalogs.observe(viewLifecycleOwner, Observer {
|
||||
mBinding.run {
|
||||
mViewModel?.catalogs?.observe(viewLifecycleOwner, Observer {
|
||||
mBinding?.run {
|
||||
reuseLoading.root.visibility = View.GONE
|
||||
if (it != null) {
|
||||
reuseNoConnection.root.visibility = View.GONE
|
||||
@ -59,7 +59,7 @@ class SubCatalogFragment : NormalFragment() {
|
||||
reuseNoConnection.root.visibility = View.VISIBLE
|
||||
reuseNoConnection.root.setOnClickListener {
|
||||
reuseLoading.root.visibility = View.VISIBLE
|
||||
mViewModel.getSubCatalogs(mPrimaryCatalogId)
|
||||
mViewModel?.getSubCatalogs(mPrimaryCatalogId)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -67,20 +67,20 @@ class SubCatalogFragment : NormalFragment() {
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
mEntity.run {
|
||||
mBinding.rvSubCatalog.layoutManager = GridLayoutManager(requireContext(), 3)
|
||||
mBinding.rvSubCatalog.adapter = SubCatalogAdapter(requireContext(), mCatalogViewModel, mEntity, subCatalog)
|
||||
mEntity?.takeIf { mCatalogViewModel != null }?.run {
|
||||
mBinding?.rvSubCatalog?.layoutManager = GridLayoutManager(requireContext(), 3)
|
||||
mBinding?.rvSubCatalog?.adapter = SubCatalogAdapter(requireContext(), mCatalogViewModel!!, this, subCatalog)
|
||||
}
|
||||
}
|
||||
|
||||
fun changeSubCatalog(primaryCatalogId: String) {
|
||||
mBinding.run {
|
||||
mBinding?.run {
|
||||
mPrimaryCatalogId = primaryCatalogId
|
||||
rvSubCatalog.visibility = View.GONE
|
||||
reuseNoneData.root.visibility = View.GONE
|
||||
reuseNoConnection.root.visibility = View.GONE
|
||||
reuseLoading.root.visibility = View.VISIBLE
|
||||
mViewModel.getSubCatalogs(mPrimaryCatalogId)
|
||||
mViewModel?.getSubCatalogs(mPrimaryCatalogId)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -147,6 +147,8 @@ object PackageRepository {
|
||||
e.printStackTrace()
|
||||
}
|
||||
LoghubUtils.log(wrapperObject, "halo-api-device-installed", true)
|
||||
|
||||
SPUtils.setLong(LAST_UPLOAD_APPLIST_TIME, System.currentTimeMillis() / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -123,8 +123,8 @@ public class UserInfoEditFragment extends NormalFragment {
|
||||
|
||||
initMenu(R.menu.menu_button);
|
||||
mSaveMenuItem = getItemMenu(R.id.menu_button);
|
||||
// sentry上报mSaveMenuItem.getActionView()可能为空
|
||||
if (mSaveMenuItem.getActionView() != null) {
|
||||
// sentry上报mSaveMenuItem、mSaveMenuItem.getActionView()可能为空
|
||||
if (mSaveMenuItem != null && mSaveMenuItem.getActionView() != null) {
|
||||
TextView menuView = mSaveMenuItem.getActionView().findViewById(R.id.tv_menu_button);
|
||||
menuView.setText(R.string.menu_text_save);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user