Merge branch 'dev-4.6.0' of git.ghzs.com:halo/assistant-android into dev-4.6.0
This commit is contained in:
@ -118,7 +118,9 @@ class CertificationDialog(context: Context, private val authDialogEntity: AuthDi
|
||||
|
||||
//跳转登录页面
|
||||
private fun gotoLoginPage() {
|
||||
CheckLoginUtils.checkLogin(AppManager.getInstance().currentActivity() as AppCompatActivity,
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
CheckLoginUtils.checkLogin(currentActivity as AppCompatActivity,
|
||||
null, true, "实名认证弹窗") {
|
||||
if (UserManager.getInstance().isAuth) {
|
||||
listener.onConfirm()
|
||||
@ -129,7 +131,9 @@ class CertificationDialog(context: Context, private val authDialogEntity: AuthDi
|
||||
|
||||
//跳转实名认证页面
|
||||
private fun gotoAuthPage() {
|
||||
AvoidOnResultManager.getInstance(AppManager.getInstance().currentActivity() as AppCompatActivity)
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
AvoidOnResultManager.getInstance(currentActivity as AppCompatActivity)
|
||||
.startForResult(UserInfoEditActivity.getIntent(context, UserViewModel.TYPE_ID_CARD), object : Callback {
|
||||
override fun onActivityResult(resultCode: Int, data: Intent?) {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
|
||||
@ -20,7 +20,12 @@ class VolumeObserver(var context: Context, handler: Handler, var callback: MuteC
|
||||
super.onChange(selfChange)
|
||||
|
||||
val audio = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
val currentVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC)
|
||||
var currentVolume = 0
|
||||
|
||||
tryCatchInRelease {
|
||||
// 部分设备(Meizu 7.1.2 M6 Note)的 audioManager getStreamVolume 内部会触发空指针 :(
|
||||
currentVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC)
|
||||
}
|
||||
|
||||
val delta = previousVolume - currentVolume
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ object SimulatorGameManager {
|
||||
|
||||
@JvmStatic
|
||||
fun deleteLocalGames(names: List<String>) {
|
||||
val downloadEntityList = DownloadDao.getInstance(HaloApp.getInstance().application).all
|
||||
val downloadEntityList = DownloadManager.getInstance(HaloApp.getInstance().application).allDownloadEntity
|
||||
names.forEach { name ->
|
||||
val downloadEntity = downloadEntityList.find { it.name == name }
|
||||
if (downloadEntity != null) {
|
||||
@ -48,7 +48,7 @@ object SimulatorGameManager {
|
||||
|
||||
@JvmStatic
|
||||
fun deleteLocalGame(name: String) {
|
||||
val downloadEntityList = DownloadDao.getInstance(HaloApp.getInstance().application).all
|
||||
val downloadEntityList = DownloadManager.getInstance(HaloApp.getInstance().application).allDownloadEntity
|
||||
val downloadEntity = downloadEntityList.find { it.name == name }
|
||||
if (downloadEntity != null) {
|
||||
val file = File(downloadEntity.path)
|
||||
|
||||
@ -42,6 +42,15 @@ public class DataUtils {
|
||||
}
|
||||
|
||||
SentryAndroid.init(context, options -> {
|
||||
// Sentry 疯狂报 ANR (很大一部分还是莫名奇妙的 ANR)严重影响到其它闪退日志的收集
|
||||
// 这里将它局限到只有官网渠道的包才统计 ANR
|
||||
if ("GH_206".equals(channel)) {
|
||||
options.setAnrEnabled(true);
|
||||
options.setAnrTimeoutIntervalMillis(6000);
|
||||
} else {
|
||||
options.setAnrEnabled(false);
|
||||
}
|
||||
|
||||
options.setDebug(BuildConfig.DEBUG);
|
||||
options.setEnableSessionTracking(true);
|
||||
options.setEnvironment(BuildConfig.FLAVOR);
|
||||
@ -57,10 +66,6 @@ public class DataUtils {
|
||||
});
|
||||
|
||||
Sentry.configureScope(scope -> {
|
||||
User user = new User();
|
||||
user.setId(HaloApp.getInstance().getGid());
|
||||
scope.setUser(user);
|
||||
|
||||
if (BuildConfig.BUILD_TIME != 0L) {
|
||||
scope.setTag("alias", "内测版" + BuildConfig.VERSION_NAME);
|
||||
} else {
|
||||
|
||||
@ -76,9 +76,10 @@ object DownloadObserver {
|
||||
// MtaHelper.onEventWithBasicDeviceInfo("下载失败弹窗",
|
||||
// "游戏", downloadEntity.name,
|
||||
// "平台", downloadEntity.platform)
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
DialogUtils.showAlertDialog(AppManager.getInstance().currentActivity(), "下载失败", "下载链接已失效,建议提交反馈", "立即反馈", "取消", {
|
||||
SuggestionActivity.startSuggestionActivity(AppManager.getInstance().currentActivity(),
|
||||
DialogUtils.showAlertDialog(currentActivity, "下载失败", "下载链接已失效,建议提交反馈", "立即反馈", "取消", {
|
||||
SuggestionActivity.startSuggestionActivity(currentActivity,
|
||||
SuggestType.gameQuestion, "notfound",
|
||||
StringUtils.buildString(downloadEntity.name, ",问题反馈:下载链接失效"),
|
||||
SimpleGameEntity(gameId, downloadEntity.name, ""))
|
||||
@ -141,7 +142,9 @@ object DownloadObserver {
|
||||
if (gameEntity?.simulator != null) {
|
||||
val isInstalled = PackageUtils.isInstalledFromAllPackage(HaloApp.getInstance().application, gameEntity.simulator!!.apk!!.packageName)
|
||||
if (!isInstalled) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(AppManager.getInstance().currentActivity(), gameEntity.simulator,
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(currentActivity, gameEntity.simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.id, gameEntity.name
|
||||
?: "", null)
|
||||
}
|
||||
|
||||
@ -78,6 +78,9 @@ public class GameUtils {
|
||||
int pluginCount = 0; // 可插件化数量
|
||||
int updateCount = 0; // 可更新数量
|
||||
int installCount = 0; // 已安装数量
|
||||
|
||||
boolean isRelatedEmulatorInstalled = false; // 若该游戏是模拟器游戏时其对应的模拟器是否已经安装
|
||||
|
||||
DownloadEntity downloadEntity;
|
||||
Object gh_id;
|
||||
apkFor:
|
||||
@ -123,20 +126,26 @@ public class GameUtils {
|
||||
boolean isInstalled = PackageUtils.isInstalledFromAllPackage(context, gameEntity.getSimulator().getApk().getPackageName());
|
||||
if (isInstalled) {
|
||||
installCount++;
|
||||
isRelatedEmulatorInstalled = true;
|
||||
} else {
|
||||
doneCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (installCount != 0) {
|
||||
|
||||
if (isRelatedEmulatorInstalled && doneCount != 0) {
|
||||
return context.getString(R.string.launch);
|
||||
}
|
||||
|
||||
if (doneCount != 0) {
|
||||
return context.getString(R.string.install);
|
||||
} else if (pluginCount != 0 && !SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
return context.getString(R.string.pluggable);
|
||||
} else if (updateCount != 0 && !SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
return context.getString(R.string.update);
|
||||
} else if (doneCount != 0) {
|
||||
return context.getString(R.string.install);
|
||||
} else if (installCount != 0) {
|
||||
return context.getString(R.string.launch);
|
||||
} else if (gameEntity.getVersionNumber().contains("无版号") && Config.isGameDomeSwitchOpen() && !SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
return context.getString(R.string.attempt);
|
||||
} else {
|
||||
|
||||
@ -41,7 +41,10 @@ object PackageInstaller {
|
||||
fun install(context: Context, downloadEntity: DownloadEntity, showUnzipToast: Boolean) {
|
||||
val pkgPath = downloadEntity.path
|
||||
val isXapk = XapkInstaller.XAPK_EXTENSION_NAME == pkgPath.getExtension()
|
||||
InstallPermissionDialogFragment.show(AppManager.getInstance().currentActivity() as AppCompatActivity, downloadEntity) {
|
||||
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
InstallPermissionDialogFragment.show(currentActivity as AppCompatActivity, downloadEntity) {
|
||||
// 取消状态栏下载完成的通知,若存在
|
||||
downloadEntity.meta[Constants.MARK_ALREADY_TRIGGERED_INSTALLATION] = "YES"
|
||||
DownloadNotificationHelper.addOrUpdateDownloadNotification(downloadEntity)
|
||||
|
||||
@ -183,11 +183,13 @@ public class PackageUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO 找一个更好的办法来比较签名并且不触发 ANR
|
||||
public static boolean compareSignatureBetweenInstalledAppWithApk(Context context, String packageName, String apkFilePath) {
|
||||
try {
|
||||
// 据 Sentry 统计,刚上架一个周末的包里对这个方法有 700+ 次调用,然后其中一部分会造成 ANR
|
||||
Signature sig = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES).signatures[0];
|
||||
|
||||
// Fuck HUAWEI, 华为系统调用 getPackageArchiveInfo 获取魔羯 apk 的签名时会耗时超过5秒造成 ANR,没有找到解决方法
|
||||
// 调用 getPackageArchiveInfo 获取较大的 apk 的签名时会耗时超过5秒造成 ANR,没有找到解决方法
|
||||
// 如果可以的话尽量避免调用 getPackageArchiveInfo 方法
|
||||
Signature releaseSig = context.getPackageManager().getPackageArchiveInfo(apkFilePath, PackageManager.GET_SIGNATURES).signatures[0];
|
||||
return sig.hashCode() == releaseSig.hashCode();
|
||||
|
||||
@ -420,7 +420,7 @@ public class DWebView extends WebView {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
super.loadUrl("javascript:" + script);
|
||||
} catch (Exception ignored){
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
@ -1029,4 +1029,19 @@ public class DWebView extends WebView {
|
||||
mainHandler.post(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOverScrollMode(int mode) {
|
||||
try {
|
||||
super.setOverScrollMode(mode);
|
||||
} catch (Throwable e) {
|
||||
String trace = Log.getStackTraceString(e);
|
||||
if (trace.contains("android.content.pm.PackageManager$NameNotFoundException")
|
||||
|| trace.contains("java.lang.RuntimeException: Cannot load WebView")
|
||||
|| trace.contains("android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed")) {
|
||||
e.printStackTrace();
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -543,7 +543,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
}
|
||||
|
||||
public List<DownloadEntity> getAllSimulatorDownloadEntity() {
|
||||
List<DownloadEntity> downloadEntityList = mDownloadDao.getAll();
|
||||
List<DownloadEntity> downloadEntityList = getAllDownloadEntity();
|
||||
ArrayList<DownloadEntity> filteredDownloadEntityList = new ArrayList<>();
|
||||
for (DownloadEntity downloadEntity : downloadEntityList) {
|
||||
if (ExtensionsKt.isSimulatorGame(downloadEntity) && downloadEntity.getStatus() == DownloadStatus.done) {
|
||||
@ -560,7 +560,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
if (CommonDebug.IS_DEBUG) {
|
||||
CommonDebug.logMethodName(this);
|
||||
}
|
||||
List<DownloadEntity> all = mDownloadDao.getAll();
|
||||
List<DownloadEntity> all = getAllDownloadEntity();
|
||||
return filterSilentDownloadTask(all);
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ import android.preference.PreferenceManager
|
||||
import android.text.TextUtils
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.loghub.LoghubUtils
|
||||
import com.gh.common.runOnIoThread
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.entity.GameDigestEntity
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
@ -106,7 +107,8 @@ object PackageObserver {
|
||||
}
|
||||
})
|
||||
}
|
||||
postNewlyInstalledApp(gameId, packageName)
|
||||
|
||||
runOnIoThread { postNewlyInstalledApp(gameId, packageName) }
|
||||
}
|
||||
|
||||
if ("卸载" == busFour.type) {
|
||||
|
||||
@ -300,7 +300,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
finish();
|
||||
}
|
||||
|
||||
private void uploadTeaAndGdtData(){
|
||||
private void uploadTeaAndGdtData() {
|
||||
// 在可能获取了相关权限后才初始化SDK/发送激活数据
|
||||
// TeaHelper.init(getApplication(), HaloApp.getInstance().getChannel());
|
||||
try {
|
||||
@ -422,25 +422,25 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
// 检查下载文件夹下是否有旧版本的光环助手的包,有则删除
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
private void deleteOutdatedUpdatePackage() {
|
||||
File folder = new File(FileUtils.getDownloadDir(this) + File.separator);
|
||||
if (folder.isDirectory()) {
|
||||
for (File file : folder.listFiles()) {
|
||||
if (!file.isDirectory() && file.getName().startsWith("光环助手V")) {
|
||||
String name = file.getName();
|
||||
int index = name.indexOf("_");
|
||||
if (index != -1) {
|
||||
try {
|
||||
try {
|
||||
File folder = new File(FileUtils.getDownloadDir(this) + File.separator);
|
||||
if (folder.isDirectory()) {
|
||||
for (File file : folder.listFiles()) {
|
||||
if (!file.isDirectory() && file.getName().startsWith("光环助手V")) {
|
||||
String name = file.getName();
|
||||
int index = name.indexOf("_");
|
||||
if (index != -1) {
|
||||
String versionString = name.substring(name.indexOf("V") + 1, index);
|
||||
Version currentVersion = new Version(PackageUtils.getVersionName());
|
||||
if (currentVersion.isHigherThan(versionString) || currentVersion.isEqual(versionString)) {
|
||||
file.delete();
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@ public abstract class ListAdapter<DataType> extends BaseRecyclerAdapter {
|
||||
public static final int FOOTER_ITEM_COUNT = 1;
|
||||
public static final int TOP_ITEM_COUNT = 1;
|
||||
|
||||
// TODO mEntityList 适配多线程读写
|
||||
protected List<DataType> mEntityList = new ArrayList<>();
|
||||
|
||||
protected boolean mIsOver;
|
||||
|
||||
@ -14,6 +14,7 @@ import com.gh.common.exposure.ExposureEvent
|
||||
import com.gh.common.exposure.ExposureSource
|
||||
import com.gh.common.exposure.IExposable
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.common.util.dip2px
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder
|
||||
import com.gh.gamecenter.baselist.ListAdapter
|
||||
@ -100,6 +101,11 @@ class SpecialCatalogAdapter(context: Context, private val mCatalogViewModel: Cat
|
||||
is CatalogImageItemHolder -> {
|
||||
val imageEntity = mEntityList[position].bigImage!!
|
||||
holder.binding.run {
|
||||
image.layoutParams = image.layoutParams.apply {
|
||||
val imageWidth = mContext.resources.displayMetrics.widthPixels - (80F + 16F + 16F).dip2px()
|
||||
height = imageWidth * 9 / 16
|
||||
}
|
||||
|
||||
entity = imageEntity.image
|
||||
|
||||
var exposureEvent: ExposureEvent? = null
|
||||
|
||||
@ -79,6 +79,9 @@ public class GameDownloadFragment extends BaseFragment implements View.OnClickLi
|
||||
@Nullable Integer location = adapter.getLocation(downloadEntity.getUrl());
|
||||
String xapkStatus = downloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_STATUS);
|
||||
if (location != null && XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
|
||||
|
||||
if (location > adapter.getDoneList().size()) return;
|
||||
|
||||
adapter.getDoneList().set(location, downloadEntity);
|
||||
adapter.notifyItemChanged(location + 1);
|
||||
return;
|
||||
|
||||
@ -58,7 +58,10 @@ class CommodityAdapter(context: Context): ListAdapter<CommodityEntity>(context)
|
||||
executePendingBindings()
|
||||
|
||||
commodity.tag?.run {
|
||||
if (id.isNotBlank()) tagContainer.addView(getTagView(this))
|
||||
if (id.isNotBlank()) {
|
||||
tagContainer.removeAllViews()
|
||||
tagContainer.addView(getTagView(this))
|
||||
}
|
||||
}
|
||||
|
||||
originEnergy.paint.flags = Paint.STRIKE_THRU_TEXT_FLAG
|
||||
|
||||
@ -100,13 +100,17 @@ class CommodityFragment : ListFragment<CommodityEntity, CommodityViewModel>() {
|
||||
}
|
||||
|
||||
fun refreshPage(size: SubjectSettingEntity.Size) {
|
||||
mListViewModel.sortSize = size
|
||||
onRefresh()
|
||||
if (size != mListViewModel.sortSize) {
|
||||
mListViewModel.sortSize = size
|
||||
onRefresh()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mListRefresh?.isNestedScrollingEnabled = false
|
||||
if (mEntrance == "光能中心") {
|
||||
mListRefresh?.isNestedScrollingEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLoadDone() {
|
||||
@ -114,6 +118,17 @@ class CommodityFragment : ListFragment<CommodityEntity, CommodityViewModel>() {
|
||||
mListRefresh?.isEnabled = false
|
||||
}
|
||||
|
||||
override fun onLoadEmpty() {
|
||||
super.onLoadEmpty()
|
||||
// RecyclerView 被隐藏的话会导致不能 AppBar 不能滑动
|
||||
mListRv.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
override fun onLoadError() {
|
||||
super.onLoadError()
|
||||
mListRv.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
fun setNestedScrollingEnabled(enable: Boolean) {
|
||||
mListRv.isNestedScrollingEnabled = enable
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package com.gh.gamecenter.energy
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.CheckedTextView
|
||||
@ -88,7 +90,12 @@ class EnergyCenterFragment : BaseLazyFragment() {
|
||||
}
|
||||
|
||||
mBinding.run {
|
||||
val screenHeight = resources.displayMetrics.heightPixels
|
||||
val screenHeight = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
resources.displayMetrics.heightPixels
|
||||
else
|
||||
DisplayMetrics()
|
||||
.apply { requireActivity().windowManager.defaultDisplay.getRealMetrics(this) }
|
||||
.heightPixels
|
||||
val behavior = BottomSheetBehavior.from(bottomSheet)
|
||||
val toolbarHeight = screenHeight - DisplayUtils.getStatusBarHeight(resources) - 48F.dip2px()
|
||||
behavior.peekHeight = screenHeight - 312F.dip2px()
|
||||
@ -105,8 +112,7 @@ class EnergyCenterFragment : BaseLazyFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSlide(bottomSheet: View, slideOffset: Float) {
|
||||
}
|
||||
override fun onSlide(bottomSheet: View, slideOffset: Float) {}
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -182,13 +188,13 @@ class EnergyCenterFragment : BaseLazyFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.backIv, R.id.EnergyRecord, R.id.lotteryCenter, R.id.signSwitch, R.id.signBubble,
|
||||
@OnClick(R.id.backIv, R.id.energyRecord, R.id.lotteryCenter, R.id.signSwitch, R.id.signBubble,
|
||||
R.id.oneDay, R.id.twoDay, R.id.threeDay, R.id.fourDay, R.id.fiveDay, R.id.sixDay, R.id.sevenDay)
|
||||
fun onViewClicked(v: View) {
|
||||
when (v.id) {
|
||||
R.id.backIv -> requireActivity().finish()
|
||||
|
||||
R.id.EnergyRecord -> {
|
||||
R.id.energyRecord -> {
|
||||
ifLogin("光能中心-光能记录") {
|
||||
DirectUtils.directToEnergyRecord(requireContext())
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ import com.gh.gamecenter.databinding.FragmentEnergyHouseBinding
|
||||
import com.gh.gamecenter.entity.CommodityCategoryEntity
|
||||
import com.gh.gamecenter.entity.SubjectSettingEntity
|
||||
import com.gh.gamecenter.entity.TaskEntity
|
||||
import com.gh.gamecenter.entity.UserInfoEntity
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.gh.gamecenter.personalhome.UserHomeViewModel
|
||||
import com.gh.gamecenter.user.UserViewModel
|
||||
@ -34,12 +35,14 @@ class EnergyHouseFragment: BaseLazyFragment() {
|
||||
private lateinit var mUserHomeViewModel: UserHomeViewModel
|
||||
private lateinit var mEnergyHouseViewModel: EnergyHouseViewModel
|
||||
private lateinit var mCommodityCategories: List<CommodityCategoryEntity>
|
||||
private var mUserInfo: UserInfoEntity? = null
|
||||
private val mTitleList = ArrayList<String>()
|
||||
private val mFragments = ArrayList<Fragment>()
|
||||
private val mTasks = ArrayList<TaskEntity>()
|
||||
private var mTasks = ArrayList<TaskEntity>()
|
||||
private val mRollUserNames = ArrayList<String>()
|
||||
private val mRollCommodityNames = ArrayList<String>()
|
||||
private var currentSizeIndex = 0
|
||||
private var mCurrentSizeIndex = 0
|
||||
private var mCurrentSize = SubjectSettingEntity.Size()
|
||||
|
||||
override fun getLayoutId() = 0
|
||||
|
||||
@ -70,9 +73,9 @@ class EnergyHouseFragment: BaseLazyFragment() {
|
||||
mUserViewModel.loginObsUserinfo.observeNonNull(viewLifecycleOwner) {
|
||||
if (it.data != null) {
|
||||
mBinding.run {
|
||||
val userInfo = it.data
|
||||
userIcon.display(userInfo.iconBorder?.url, userInfo.icon ?: "")
|
||||
userName.text = userInfo.name
|
||||
mUserInfo = it.data
|
||||
userIcon.display(mUserInfo?.iconBorder?.url, mUserInfo?.icon ?: "")
|
||||
userName.text = mUserInfo?.name
|
||||
}
|
||||
mUserHomeViewModel.userId = UserManager.getInstance().userId
|
||||
mUserHomeViewModel.getUserEnergy()
|
||||
@ -101,12 +104,20 @@ class EnergyHouseFragment: BaseLazyFragment() {
|
||||
|
||||
mEnergyHouseViewModel.noviceTasks.observeNonNull(viewLifecycleOwner) {
|
||||
mTasks.clear()
|
||||
mTasks.addAll(it)
|
||||
mEnergyHouseViewModel.getDailyTasks()
|
||||
if (it.size > 4) {
|
||||
mTasks.addAll(it.subList(0, 5))
|
||||
initTaskView()
|
||||
} else {
|
||||
mTasks.addAll(it)
|
||||
mEnergyHouseViewModel.getDailyTasks()
|
||||
}
|
||||
}
|
||||
|
||||
mEnergyHouseViewModel.dailyTasks.observeNonNull(viewLifecycleOwner) {
|
||||
mTasks.addAll(it)
|
||||
if (mTasks.size > 4) {
|
||||
mTasks = ArrayList(mTasks.subList(0, 5))
|
||||
}
|
||||
initTaskView()
|
||||
}
|
||||
|
||||
@ -203,6 +214,10 @@ class EnergyHouseFragment: BaseLazyFragment() {
|
||||
updateTabStyle(tab, true)
|
||||
}
|
||||
})
|
||||
|
||||
viewpager.doOnPageSelected {
|
||||
(mFragments[it] as CommodityFragment).refreshPage(mCurrentSize)
|
||||
}
|
||||
}
|
||||
|
||||
initSize()
|
||||
@ -244,10 +259,11 @@ class EnergyHouseFragment: BaseLazyFragment() {
|
||||
val tv = item.findViewById<TextView>(R.id.size_tv)
|
||||
tv.text = size.text
|
||||
item.setOnClickListener {
|
||||
if (currentSizeIndex != index) {
|
||||
if (mCurrentSizeIndex != index) {
|
||||
changeSizeBg(index)
|
||||
(mFragments[mBinding.viewpager.currentItem] as CommodityFragment).refreshPage(size)
|
||||
currentSizeIndex = index
|
||||
mCurrentSizeIndex = index
|
||||
mCurrentSize = size
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -269,12 +285,18 @@ class EnergyHouseFragment: BaseLazyFragment() {
|
||||
}
|
||||
|
||||
|
||||
@OnClick(R.id.backIv, R.id.EnergyRecord, R.id.energyOrder)
|
||||
@OnClick(R.id.backIv, R.id.userEnergy, R.id.energyRecord, R.id.energyOrder)
|
||||
fun onViewClicked(v: View) {
|
||||
when (v.id) {
|
||||
R.id.backIv -> requireActivity().finish()
|
||||
|
||||
R.id.EnergyRecord -> {
|
||||
R.id.userEnergy -> {
|
||||
mUserInfo?.run {
|
||||
DialogUtils.showEnergyDialog(requireContext(), name, mBinding.userEnergy.text.toString())
|
||||
}
|
||||
}
|
||||
|
||||
R.id.energyRecord -> {
|
||||
ifLogin("光能屋-光能记录") {
|
||||
DirectUtils.directToEnergyRecord(requireContext(), 1)
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ class GameDetailFragment : NormalFragment() {
|
||||
if (mGameEntity != null && mGameEntity!!.getApk().size == 1) {
|
||||
val url = mGameEntity!!.getApk()[0].url
|
||||
if (downloadEntity.url == url) {
|
||||
if ("pause" != DownloadManager.getInstance(context).getStatus(downloadEntity.url).status) {
|
||||
if ("pause" != DownloadManager.getInstance(context).getStatus(downloadEntity.url)?.status) {
|
||||
mDownloadEntity = downloadEntity
|
||||
DetailDownloadUtils.detailInvalidate(detailViewHolder)
|
||||
}
|
||||
@ -291,8 +291,8 @@ class GameDetailFragment : NormalFragment() {
|
||||
|
||||
mMaxWidth = resources.displayMetrics.widthPixels - DisplayUtils.dip2px(40f)
|
||||
|
||||
val args = arguments
|
||||
mAutoDownload = args!!.getBoolean(EntranceUtils.KEY_AUTO_DOWNLOAD)
|
||||
val args = arguments ?: Bundle()
|
||||
mAutoDownload = args.getBoolean(EntranceUtils.KEY_AUTO_DOWNLOAD)
|
||||
mTraceEvent = args.getParcelable(EntranceUtils.KEY_TRACE_EVENT)
|
||||
mSkipGameComment = args.getBoolean(EntranceUtils.KEY_SKIP_GAME_COMMENT)
|
||||
mDestinationTab = args.getInt(EntranceUtils.KEY_TARGET, -1)
|
||||
|
||||
@ -86,8 +86,8 @@ class FuLiFragment : BaseFragment<Any>(), IScrollable {
|
||||
mAdapter?.itemList = it.data
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
} else {
|
||||
containerRl.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.white))
|
||||
noDataImg.visibility = View.VISIBLE
|
||||
containerRl?.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.white))
|
||||
noDataImg?.visibility = View.VISIBLE
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@ -84,7 +84,7 @@ class TopVideoView @JvmOverloads constructor(context: Context, attrs: AttributeS
|
||||
clearFullscreenLayout()
|
||||
}
|
||||
|
||||
errorBtn.setOnClickListener {
|
||||
errorBtn?.setOnClickListener {
|
||||
debounceActionWithInterval(errorBtn.id, 1000) {
|
||||
if (!com.shuyu.gsyvideoplayer.utils.NetworkUtils.isAvailable(mContext)) {
|
||||
Utils.toast(context, "网络异常,请检查手机网络状态")
|
||||
|
||||
@ -61,7 +61,7 @@ object PackageRepository {
|
||||
val gameUpdateLiveData = MutableLiveData<List<GameUpdateEntity>>()
|
||||
val gameInstalledLiveData = MutableLiveData<List<GameInstall>>()
|
||||
|
||||
val gameInstalled = ArrayList<GameInstall>()
|
||||
val gameInstalled = Collections.synchronizedList(ArrayList<GameInstall>())
|
||||
val gameUpdate = ArrayList<GameUpdateEntity>()
|
||||
|
||||
init {
|
||||
@ -190,7 +190,7 @@ object PackageRepository {
|
||||
*
|
||||
* @param list 已安装的游戏包名集合
|
||||
*/
|
||||
private fun loadInstalledGameDigestAndNotifyData(list: ArrayList<String>) {
|
||||
private fun loadInstalledGameDigestAndNotifyData(list: ArrayList<String>, onWorkerThreadOnly: Boolean = false) {
|
||||
var isNotifyUpdate = false
|
||||
val latch = ObservableUtil.latch(list.size, {
|
||||
if (isNotifyUpdate || gameUpdateLiveData.value == null) notifyGameUpdateData()
|
||||
@ -199,33 +199,39 @@ object PackageRepository {
|
||||
|
||||
for (pkgName in list) {
|
||||
val filterQuery = UrlFilterUtils.getFilterQuery("package", pkgName)
|
||||
mSensitiveApi.loadGameDataByPackageName(filterQuery)
|
||||
|
||||
var observable = mSensitiveApi.loadGameDataByPackageName(filterQuery)
|
||||
.map(RegionSettingHelper.filterGame)
|
||||
.map(ApkActiveUtils.filterMapperList)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<List<GameEntity>>() {
|
||||
override fun onResponse(response: List<GameEntity>?) {
|
||||
if (response != null) {
|
||||
val gh_id = PackageUtils.getMetaData(HaloApp.getInstance().application, pkgName, "gh_id")
|
||||
for (game in response) {
|
||||
if (gh_id == null || gh_id == game.id) {
|
||||
gameInstalled.add(GameInstall.transformGameInstall(game, pkgName))
|
||||
val isCanPluggable = checkGamePlugin(game, pkgName)
|
||||
val isCanUpdate = checkGameUpdate(game)
|
||||
if (!isNotifyUpdate && isCanUpdate || isCanPluggable) {
|
||||
isNotifyUpdate = true
|
||||
}
|
||||
}
|
||||
|
||||
if (!onWorkerThreadOnly) {
|
||||
// 这里面的代码(根据包名获取签名?)或许是造成安装完成后的 ANR 和 startForegroundService did not then call startForeground 的原因
|
||||
// 为了避免影响其它地方,这里只处理安装完成后的调用
|
||||
observable = observable.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
observable.subscribe(object : Response<List<GameEntity>>() {
|
||||
override fun onResponse(response: List<GameEntity>?) {
|
||||
if (response != null) {
|
||||
val gh_id = PackageUtils.getMetaData(HaloApp.getInstance().application, pkgName, "gh_id")
|
||||
for (game in response) {
|
||||
if (gh_id == null || gh_id == game.id) {
|
||||
gameInstalled.add(GameInstall.transformGameInstall(game, pkgName))
|
||||
val isCanPluggable = checkGamePlugin(game, pkgName)
|
||||
val isCanUpdate = checkGameUpdate(game)
|
||||
if (!isNotifyUpdate && isCanUpdate || isCanPluggable) {
|
||||
isNotifyUpdate = true
|
||||
}
|
||||
}
|
||||
latch.countDown()
|
||||
}
|
||||
}
|
||||
latch.countDown()
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
latch.countDown()
|
||||
}
|
||||
})
|
||||
override fun onFailure(e: HttpException?) {
|
||||
latch.countDown()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,7 +309,7 @@ object PackageRepository {
|
||||
|
||||
val list = ArrayList<String>()
|
||||
list.add(pkgName)
|
||||
loadInstalledGameDigestAndNotifyData(list)
|
||||
loadInstalledGameDigestAndNotifyData(list, true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -48,14 +48,14 @@ class AvatarBorderFragment : BaseFragment_TabLayout() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mUserViewModel = viewModelProvider(UserViewModel.Factory(HaloApp.getInstance().application))
|
||||
mUserViewModel.loginObsUserinfo.observe(this, Observer {
|
||||
mUserViewModel.loginObsUserinfo.observeNonNull(this) {
|
||||
if (it.data.background?.url.isNullOrEmpty()) {
|
||||
ImageUtils.display(mBinding.forumBackground, R.drawable.bg_avatar_border)
|
||||
} else {
|
||||
ImageUtils.display(mBinding.forumBackground, it.data.background?.url)
|
||||
}
|
||||
mBinding.userAvatar.display(it.data.iconBorder?.url, it.data.icon ?: "")
|
||||
})
|
||||
}
|
||||
mUserViewModel.editObsUserinfo.observe(this, Observer {
|
||||
mBinding.userAvatar.displayAvatar(it.data.icon ?: "")
|
||||
})
|
||||
|
||||
@ -4,6 +4,7 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.gh.common.AppExecutor;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.ExtensionsKt;
|
||||
import com.gh.common.util.InstallUtils;
|
||||
@ -38,7 +39,14 @@ public class InstallAndUninstallReceiver extends BroadcastReceiver {
|
||||
String versionName = PackageUtils.getVersionByPackage(packageName);
|
||||
EBPackage installEb = new EBPackage("安装", packageName, versionName);
|
||||
EventBus.getDefault().post(installEb);
|
||||
PackageObserver.onPackageChanged(installEb);
|
||||
if (PackageUtils.isAppOnForeground(context)) {
|
||||
PackageObserver.onPackageChanged(installEb);
|
||||
} else {
|
||||
// 处于后台运行的时候尝试延迟 1 秒再触发 onPackageChanged (猜测是引起 ANR 的原因)
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> {
|
||||
PackageObserver.onPackageChanged(installEb);
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
// 接收卸载广播
|
||||
|
||||
@ -120,7 +120,7 @@ class BindPhoneFragment : NormalFragment() {
|
||||
|
||||
// 如果当前登录方式是手机号登录,也要更新loginType
|
||||
UserManager.getInstance().loginTokenEntity?.apply {
|
||||
if (loginType.length == 11) loginType = phoneNum
|
||||
if (loginType?.length == 11) loginType = phoneNum
|
||||
}
|
||||
|
||||
requireActivity().finish()
|
||||
@ -186,7 +186,7 @@ class BindPhoneFragment : NormalFragment() {
|
||||
}
|
||||
|
||||
@OnClick(R.id.bind_phone_skip, R.id.bind_phone_captcha, R.id.bind_phone_btn)
|
||||
override fun onClick(v : View) {
|
||||
override fun onClick(v: View) {
|
||||
// 防止快速点击
|
||||
if (ClickUtils.isFastDoubleClick()) return
|
||||
|
||||
|
||||
@ -122,7 +122,7 @@ class SimulatorGameFragment : NormalFragment() {
|
||||
MtaHelper.onEvent("我的光环_新", "模拟器游戏", "点击${mTypeAliasList[it]}")
|
||||
|
||||
if (mCurrentPage != it) {
|
||||
(mFragmentsList[mCurrentPage] as SimulatorGameListFragment).resetPage()
|
||||
(mFragmentsList.safelyGetInRelease(mCurrentPage) as? SimulatorGameListFragment)?.resetPage()
|
||||
mCurrentPage = it
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,6 +218,7 @@ class VideoDetailContainerFragment : BaseLazyFragment(), OnBackPressedListener {
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
val (itemHeight, distance) = getDistance()
|
||||
if (itemHeight <= 0) return
|
||||
val offsetY = distance % itemHeight
|
||||
val alpha = 1 - offsetY.toFloat() / itemHeight
|
||||
val homeVideoFragment = this@VideoDetailContainerFragment.parentFragment as? HomeVideoFragment
|
||||
@ -242,7 +243,7 @@ class VideoDetailContainerFragment : BaseLazyFragment(), OnBackPressedListener {
|
||||
}
|
||||
|
||||
override fun onPageRelease(isNext: Boolean, position: Int) {
|
||||
val video = mViewModel.videoList.value?.get(position)
|
||||
val video = mViewModel.videoList.value?.safelyGetInRelease(position)
|
||||
|
||||
video?.let {
|
||||
ExoCacheManager.cancel(video.url)
|
||||
|
||||
@ -453,8 +453,10 @@ class VideoDetailContainerViewModel(application: Application) : AndroidViewModel
|
||||
}
|
||||
|
||||
fun shareVideoStatistics(videoEntity: VideoEntity?) {
|
||||
if (videoEntity == null) return
|
||||
|
||||
RetrofitManager.getInstance(getApplication())
|
||||
.api.shareVideoStatistics(videoEntity!!.id)
|
||||
.api.shareVideoStatistics(videoEntity.id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<JsonObject>() {
|
||||
override fun onSuccess(data: JsonObject) {
|
||||
|
||||
@ -28,8 +28,10 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
@ -42,7 +42,7 @@
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/list_rv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout >
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/EnergyRecord"
|
||||
android:id="@+id/energyRecord"
|
||||
android:layout_below="@+id/toolbar"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
@ -82,7 +82,7 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/lotteryCenter"
|
||||
android:layout_below="@+id/EnergyRecord"
|
||||
android:layout_below="@+id/energyRecord"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentRight="true"
|
||||
@ -152,10 +152,9 @@
|
||||
android:id="@+id/oneDayIv"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:src="@drawable/ic_energy_center_signed" />
|
||||
android:src="@drawable/ic_energy_center_sign_normal" />
|
||||
|
||||
<TextView
|
||||
android:visibility="gone"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:gravity="center"
|
||||
@ -184,6 +183,7 @@
|
||||
android:orientation="horizontal">
|
||||
|
||||
<View
|
||||
android:visibility="gone"
|
||||
android:id="@+id/oneStraightLine"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
@ -208,10 +208,9 @@
|
||||
android:id="@+id/twoDayIv"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:src="@drawable/ic_energy_center_signed" />
|
||||
android:src="@drawable/ic_energy_center_sign_normal" />
|
||||
|
||||
<TextView
|
||||
android:visibility="gone"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:gravity="center"
|
||||
@ -247,6 +246,7 @@
|
||||
android:background="@color/bg_91F0FD" />
|
||||
|
||||
<View
|
||||
android:visibility="gone"
|
||||
android:id="@+id/twoDottedLine"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
@ -521,7 +521,7 @@
|
||||
android:background="@color/transparent"
|
||||
android:orientation="vertical"
|
||||
app:behavior_hideable="false"
|
||||
app:behavior_peekHeight="300dp"
|
||||
app:behavior_peekHeight="0dp"
|
||||
app:layout_behavior="@string/bottom_sheet_behavior">
|
||||
|
||||
<View
|
||||
|
||||
@ -145,7 +145,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/EnergyRecord"
|
||||
android:id="@+id/energyRecord"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginTop="5dp"
|
||||
@ -162,7 +162,7 @@
|
||||
android:layout_marginRight="16dp"
|
||||
android:src="@drawable/ic_energy_order_center"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/EnergyRecord" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/energyRecord" />
|
||||
|
||||
<RelativeLayout
|
||||
android:visibility="gone"
|
||||
|
||||
Reference in New Issue
Block a user