Compare commits
28 Commits
video_only
...
v4.4.0-221
| Author | SHA1 | Date | |
|---|---|---|---|
| 0397092414 | |||
| ddc515b490 | |||
| a7b138b2b2 | |||
| 951768e070 | |||
| 88e28b2388 | |||
| 538bc6f97c | |||
| 0a49f27ed2 | |||
| 5dc7badc97 | |||
| d185d39985 | |||
| 2141440ec4 | |||
| 452a94f4a2 | |||
| 310be97fe4 | |||
| 65d4b43c9c | |||
| 41f510d333 | |||
| cc39bfd06c | |||
| 15d0ad6f49 | |||
| a2e2379073 | |||
| d2431ed8ff | |||
| 80818dee55 | |||
| f2d0916a16 | |||
| 2fa84e0ce1 | |||
| c9f5cfd4aa | |||
| d6c1f692be | |||
| 12e6fb8330 | |||
| ad857d4500 | |||
| 43d8d24c1c | |||
| a34ee5a753 | |||
| ca39f723e1 |
@ -125,15 +125,11 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions "nonsense"
|
||||
flavorDimensions ("env")
|
||||
|
||||
/**
|
||||
* 多渠道打包,渠道请参考"channel.txt"文件,所有渠道值均通过java code设置
|
||||
*/
|
||||
productFlavors {
|
||||
// publish release host
|
||||
publish {
|
||||
dimension "nonsense"
|
||||
dimension "env"
|
||||
buildConfigField "String", "API_HOST", "\"${API_HOST}\""
|
||||
|
||||
buildConfigField "String", "SENSITIVE_API_HOST", "\"${SENSITIVE_API_HOST}\""
|
||||
@ -142,9 +138,8 @@ android {
|
||||
buildConfigField "String", "UMENG_MESSAGE_SECRET", "\"${UMENG_MESSAGE_SECRET}\""
|
||||
buildConfigField "String", "BUGLY_APPID", "\"${BUGLY_APPID}\""
|
||||
}
|
||||
// internal test dev host
|
||||
internal {
|
||||
dimension "nonsense"
|
||||
dimension "env"
|
||||
versionNameSuffix "-debug"
|
||||
|
||||
buildConfigField "String", "API_HOST", "\"${DEV_API_HOST}\""
|
||||
|
||||
@ -581,12 +581,12 @@
|
||||
android:name=".personalhome.excellentcomments.ExcellentCommentsActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<!-- 使用小米/华为推送弹窗功能提高推送成功率-->
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.PushProxyActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@android:style/Theme.Translucent" />
|
||||
<!-- <!– 使用小米/华为推送弹窗功能提高推送成功率–>-->
|
||||
<!-- <activity-->
|
||||
<!-- android:name="com.gh.gamecenter.PushProxyActivity"-->
|
||||
<!-- android:exported="true"-->
|
||||
<!-- android:launchMode="singleTask"-->
|
||||
<!-- android:theme="@android:style/Theme.Translucent" />-->
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.SkipActivity"
|
||||
|
||||
@ -81,8 +81,13 @@ public class WaitingDialogFragment extends BaseDialogFragment {
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
dismissAllowingStateLoss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismissAllowingStateLoss() {
|
||||
mBackListener = null;
|
||||
super.dismiss();
|
||||
super.dismissAllowingStateLoss();
|
||||
}
|
||||
|
||||
public static class WaitingDialogData {
|
||||
|
||||
@ -48,7 +48,7 @@ class GameOffServiceDialogFragment
|
||||
siteTv.setOnClickListener {
|
||||
// MtaHelper.onEvent("游戏下载状态按钮", getKey(), site.text)
|
||||
DirectUtils.directToWebView(requireContext(), site.url, "(关闭下载弹窗)")
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
container.addView(siteTv)
|
||||
|
||||
@ -102,11 +102,11 @@ class PrivacyDialogFragment : BaseDialogFragment() {
|
||||
|
||||
containerView?.findViewById<View>(R.id.refuseTv)?.setOnClickListener {
|
||||
mCallBack?.invoke(false)
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
containerView?.findViewById<View>(R.id.agreeTv)?.setOnClickListener {
|
||||
mCallBack?.invoke(true)
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ object MetaUtil {
|
||||
|
||||
private var m: Meta? = null
|
||||
private var imei: String? = null
|
||||
private var base64EncodedImei: String? = null
|
||||
private var androidId: String? = null
|
||||
|
||||
fun refreshMeta() {
|
||||
@ -104,6 +105,20 @@ object MetaUtil {
|
||||
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getBase64EncodedIMEI(): String {
|
||||
if (TextUtils.isEmpty(base64EncodedImei) && imei != null) {
|
||||
try {
|
||||
base64EncodedImei = android.util.Base64.encodeToString(getIMEI().trim().toByteArray(), android.util.Base64.NO_WRAP)
|
||||
} catch (e: java.lang.Exception) {
|
||||
e.printStackTrace()
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
return base64EncodedImei ?: ""
|
||||
}
|
||||
|
||||
fun getModel(): String? {
|
||||
return Build.MODEL
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import com.gh.common.runOnIoThread
|
||||
import com.gh.common.util.clearHtmlFormatCompletely
|
||||
import com.gh.common.util.removeInsertedContent
|
||||
import com.gh.common.util.removeVideoContent
|
||||
import com.gh.common.util.tryCatchInRelease
|
||||
import com.gh.gamecenter.entity.*
|
||||
import com.gh.gamecenter.qa.entity.AnswerDetailEntity
|
||||
import com.gh.gamecenter.qa.entity.AnswerEntity
|
||||
@ -14,27 +15,28 @@ object HistoryHelper {
|
||||
|
||||
fun insertAnswerEntity(answerDetailEntity: AnswerDetailEntity) {
|
||||
val answerEntity = convertAnswerDetailToAnswer(answerDetailEntity)
|
||||
runOnIoThread { HistoryDatabase.instance.answerDao().addAnswer(answerEntity) }
|
||||
// 偶尔有设备会出现磁盘满了写不进数据库的问题 database or disk is full 异常,毕竟只是插入个本地历史,这里直接捕抓
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.answerDao().addAnswer(answerEntity) } }
|
||||
}
|
||||
|
||||
fun insertArticleEntity(articleDetailEntity: ArticleDetailEntity) {
|
||||
val articleEntity = convertArticleDetailToArticle(articleDetailEntity)
|
||||
runOnIoThread { HistoryDatabase.instance.articleDao().addArticle(articleEntity) }
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.articleDao().addArticle(articleEntity) } }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun insertGameEntity(gameEntity: GameEntity) {
|
||||
val historyGameEntity = convertGameEntityToHistoryGameEntity(gameEntity)
|
||||
runOnIoThread { HistoryDatabase.instance.gameDao().addGame(historyGameEntity) }
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.gameDao().addGame(historyGameEntity) } }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun insertGameEntity(updateEntity: GameUpdateEntity) {
|
||||
val historyGameEntity = convertGameUpdateEntityToHistoryGameEntity(updateEntity)
|
||||
runOnIoThread { HistoryDatabase.instance.gameDao().addGame(historyGameEntity) }
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.gameDao().addGame(historyGameEntity) } }
|
||||
}
|
||||
|
||||
private fun convertGameUpdateEntityToHistoryGameEntity(updateEntity: GameUpdateEntity): HistoryGameEntity{
|
||||
private fun convertGameUpdateEntityToHistoryGameEntity(updateEntity: GameUpdateEntity): HistoryGameEntity {
|
||||
val historyGame = HistoryGameEntity()
|
||||
|
||||
historyGame.orderTag = System.currentTimeMillis()
|
||||
|
||||
@ -4,6 +4,7 @@ import android.content.Context
|
||||
import android.database.ContentObserver
|
||||
import android.media.AudioManager
|
||||
import android.os.Handler
|
||||
import com.gh.common.util.tryCatchInRelease
|
||||
|
||||
class VolumeObserver(var context: Context, handler: Handler, var callback: MuteCallback? = null)
|
||||
: ContentObserver(handler) {
|
||||
@ -11,7 +12,8 @@ class VolumeObserver(var context: Context, handler: Handler, var callback: MuteC
|
||||
|
||||
init {
|
||||
val audio = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
previousVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC)
|
||||
// 部分设备的 audioManager getStreamVolume 内部会触发空指针 :(
|
||||
tryCatchInRelease { previousVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC) }
|
||||
}
|
||||
|
||||
override fun onChange(selfChange: Boolean) {
|
||||
|
||||
@ -3,11 +3,13 @@ package com.gh.common.util;
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.common.constant.Constants;
|
||||
import com.gh.common.exposure.meta.MetaUtil;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gid.GidCallback;
|
||||
import com.gh.gid.GidHelper;
|
||||
import com.halo.assistant.HaloApp;
|
||||
@ -189,36 +191,36 @@ public class DataUtils {
|
||||
|
||||
// 游戏下载
|
||||
public static void onGameDownloadEvent(Context context, String gameName, String platform, String entrance, String status, String method) {
|
||||
// Map<String, Object> kv = new HashMap<>();
|
||||
//
|
||||
// platform = PlatformUtils.getInstance(HaloApp.getInstance().getApplication()).getPlatformName(platform);
|
||||
//
|
||||
// kv.put("版本", platform);
|
||||
// kv.put("用户机型", Build.MODEL);
|
||||
// kv.put("设备IMEI", Util_System_Phone_State.getDeviceId(HaloApp.getInstance().getApplication()));
|
||||
// kv.put("网络状态", DeviceUtils.getNetwork(HaloApp.getInstance().getApplication()));
|
||||
// kv.put("光环助手版本", BuildConfig.VERSION_NAME);
|
||||
// kv.put("位置", entrance);
|
||||
// kv.put("类型", method);
|
||||
// kv.put("厂商", Build.MANUFACTURER);
|
||||
// kv.put("Android版本", Build.VERSION.RELEASE);
|
||||
// onEvent(context, "游戏下载", gameName, kv);
|
||||
//
|
||||
// Map<String, Object> kv2 = new HashMap<>();
|
||||
// kv2.put("状态", status);
|
||||
// kv2.put("位置", entrance);
|
||||
//
|
||||
// if (status.equals("开始")) {
|
||||
// kv2.put("版本", entrance + "-开始");
|
||||
// kv2.put("游戏分平台", gameName + "-" + platform + "-开始");
|
||||
// kv2.put("光环助手版本", BuildConfig.VERSION_NAME + "-开始");
|
||||
// } else {
|
||||
// kv2.put("版本", platform);
|
||||
// kv2.put("游戏分平台", gameName + "-" + platform);
|
||||
// kv2.put("光环助手版本", BuildConfig.VERSION_NAME);
|
||||
// }
|
||||
//
|
||||
// onEvent(context, "游戏下载位置", gameName, kv2);
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
|
||||
platform = PlatformUtils.getInstance(HaloApp.getInstance().getApplication()).getPlatformName(platform);
|
||||
|
||||
kv.put("版本", platform);
|
||||
kv.put("用户机型", Build.MODEL);
|
||||
kv.put("设备IMEI", MetaUtil.getIMEI());
|
||||
kv.put("网络状态", DeviceUtils.getNetwork(HaloApp.getInstance().getApplication()));
|
||||
kv.put("光环助手版本", BuildConfig.VERSION_NAME);
|
||||
kv.put("位置", entrance);
|
||||
kv.put("类型", method);
|
||||
kv.put("厂商", Build.MANUFACTURER);
|
||||
kv.put("Android版本", Build.VERSION.RELEASE);
|
||||
onEvent(context, "游戏下载", gameName, kv);
|
||||
|
||||
Map<String, Object> kv2 = new HashMap<>();
|
||||
kv2.put("状态", status);
|
||||
kv2.put("位置", entrance);
|
||||
|
||||
if (status.equals("开始")) {
|
||||
kv2.put("版本", entrance + "-开始");
|
||||
kv2.put("游戏分平台", gameName + "-" + platform + "-开始");
|
||||
kv2.put("光环助手版本", BuildConfig.VERSION_NAME + "-开始");
|
||||
} else {
|
||||
kv2.put("版本", platform);
|
||||
kv2.put("游戏分平台", gameName + "-" + platform);
|
||||
kv2.put("光环助手版本", BuildConfig.VERSION_NAME);
|
||||
}
|
||||
|
||||
onEvent(context, "游戏下载位置", gameName, kv2);
|
||||
}
|
||||
|
||||
// 游戏更新
|
||||
|
||||
@ -575,7 +575,7 @@ object DirectUtils {
|
||||
@JvmStatic
|
||||
fun directToExternalBrowser(context: Context, url: String) {
|
||||
if (url.isEmpty()) return
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(Uri.decode(url)))
|
||||
if (context !is AppCompatActivity) {
|
||||
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
|
||||
@ -157,15 +157,15 @@ object DownloadObserver {
|
||||
}
|
||||
|
||||
// 下载过程分析统计
|
||||
val pm = mApplication.packageManager
|
||||
val packageInfo = pm.getPackageArchiveInfo(downloadEntity.path, PackageManager.GET_ACTIVITIES)
|
||||
if (packageInfo == null) {
|
||||
// val pm = mApplication.packageManager
|
||||
// val packageInfo = pm.getPackageArchiveInfo(downloadEntity.path, 0)
|
||||
// if (packageInfo == null) {
|
||||
// MtaHelper.onEventWithBasicDeviceInfo("解析包错误分析",
|
||||
// "游戏名字", downloadEntity.name + ":" + PlatformUtils.getInstance(mApplication).getPlatformName(downloadEntity.platform))
|
||||
//
|
||||
// MtaHelper.onEventWithBasicDeviceInfo("解析包错误_新",
|
||||
// "游戏", downloadEntity.name + ":" + PlatformUtils.getInstance(mApplication).getPlatformName(downloadEntity.platform))
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
if (downloadEntity.status == DownloadStatus.done) {
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.app.Application
|
||||
import android.text.TextUtils
|
||||
import com.halo.assistant.HaloApp
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* 广点通辅助类 [https://gitlab.ghzhushou.com/pm/halo-app-issues/issues/403]
|
||||
@ -19,18 +22,22 @@ object GdtHelper {
|
||||
const val PLATFORM = "PLATFORM"
|
||||
|
||||
fun init(application: Application, channel: String) {
|
||||
// if (channel == "GH_728") {
|
||||
// GDTAction.init(application, "1111012969", "9d3d9da5b0948a317c03d08f14d445dc")
|
||||
// } else if (channel == "GH_729") {
|
||||
// GDTAction.init(application, "1111013063", "f53dabf458a356b101d99fc4069eb7f1")
|
||||
// } else {
|
||||
// GDTAction.init(application, "1110680399", "f5ddaafbf520d7d7385499232a408d0a")
|
||||
// if (shouldUseGdtHelper()) {
|
||||
// if (channel == "GH_728") {
|
||||
// GDTAction.init(application, "1111012969", "9d3d9da5b0948a317c03d08f14d445dc")
|
||||
// } else if (channel == "GH_729") {
|
||||
// GDTAction.init(application, "1111013063", "f53dabf458a356b101d99fc4069eb7f1")
|
||||
// } else {
|
||||
// GDTAction.init(application, "1110680399", "f5ddaafbf520d7d7385499232a408d0a")
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
fun logAction(type: String) {
|
||||
// GDTAction.logAction(type)
|
||||
// Utils.log("GDT", type)
|
||||
// if (shouldUseGdtHelper()) {
|
||||
// GDTAction.logAction(type)
|
||||
// Utils.log("GDT", type)
|
||||
// }
|
||||
}
|
||||
|
||||
fun logAction(type: String, vararg kv: String?) {
|
||||
@ -52,4 +59,12 @@ object GdtHelper {
|
||||
// }
|
||||
}
|
||||
|
||||
// TODO 确认开启的渠道条件
|
||||
private fun shouldUseGdtHelper(): Boolean {
|
||||
return true
|
||||
|
||||
val channel = HaloApp.getInstance().channel
|
||||
return !(TextUtils.isEmpty(channel) || channel.contains("GDT".toLowerCase(Locale.CHINA)))
|
||||
}
|
||||
|
||||
}
|
||||
@ -15,7 +15,7 @@ object HomePluggableHelper {
|
||||
if (apkList.isNotEmpty()) {
|
||||
val apk = apkList.first()
|
||||
val tag = if (isNever) "never" else apk.version ?: ""
|
||||
mHomePluggableFilterDao.addData(HomePluggableFilterEntity(pkgName = apk.packageName, tag = tag, active = isNever))
|
||||
tryCatchInRelease { mHomePluggableFilterDao.addData(HomePluggableFilterEntity(pkgName = apk.packageName, tag = tag, active = isNever)) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ object HomePluggableHelper {
|
||||
for (entity in filterList) {
|
||||
entity.active = true
|
||||
}
|
||||
mHomePluggableFilterDao.addData(filterList)
|
||||
tryCatchInRelease { mHomePluggableFilterDao.addData(filterList) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,7 @@ public class InstallUtils {
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == INSTALL_WHAT && packageManager != null) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
List<PackageInfo> packageInfos = packageManager.getInstalledPackages(0);
|
||||
List<PackageInfo> packageInfos = PackageUtils.getInstalledPackages(context, 0);
|
||||
for (PackageInfo packageInfo : packageInfos) {
|
||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
list.add(packageInfo.packageName);
|
||||
|
||||
@ -458,7 +458,7 @@ public class LibaoUtils {
|
||||
adapter.notifyDataSetChanged();
|
||||
final String finalLibaoCode = libaoCode;
|
||||
NotificationHelper.showNotificationHintDialog(NotificationUgc.GIFT, isShow -> {
|
||||
if (!isShow){
|
||||
if (!isShow) {
|
||||
DialogUtils.showWarningDialog(context, "领取成功", Html.fromHtml(context.getString(R.string.linged_dialog, finalLibaoCode))
|
||||
, "关闭", " 复制礼包码"
|
||||
, () -> {
|
||||
@ -547,8 +547,7 @@ public class LibaoUtils {
|
||||
}
|
||||
|
||||
public static boolean isAppInstalled(Context context, String packageName) {
|
||||
final android.content.pm.PackageManager packageManager = context.getPackageManager();
|
||||
List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);
|
||||
List<PackageInfo> pinfo = PackageUtils.getInstalledPackages(context, 0);
|
||||
if (pinfo != null) {
|
||||
for (int i = 0; i < pinfo.size(); i++) {
|
||||
String pn = pinfo.get(i).packageName;
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.os.Build
|
||||
import android.text.TextUtils
|
||||
import com.gh.common.exposure.meta.MetaUtil
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import java.util.*
|
||||
|
||||
object MtaHelper {
|
||||
|
||||
@JvmStatic
|
||||
@ -9,7 +17,7 @@ object MtaHelper {
|
||||
// if (kv.size == 1) {
|
||||
// prop.setProperty(kv[0], kv[0])
|
||||
// StatService.trackCustomKVEvent(HaloApp.getInstance().application, eventId, prop)
|
||||
// Utils.log("MTA","$eventId + [${kv.joinToString(" , ")}]")
|
||||
// Utils.log("MTA", "$eventId + [${kv.joinToString(" , ")}]")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
@ -23,7 +31,7 @@ object MtaHelper {
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Utils.log("MTA","$eventId + [${kv.joinToString(" , ")}]")
|
||||
// Utils.log("MTA", "$eventId + [${kv.joinToString(" , ")}]")
|
||||
// StatService.trackCustomKVEvent(HaloApp.getInstance().application, eventId, prop)
|
||||
}
|
||||
|
||||
@ -45,7 +53,7 @@ object MtaHelper {
|
||||
// }
|
||||
//
|
||||
// if (prop.size == 0) return
|
||||
// Utils.log("MTA","$eventId + [${kv.joinToString(" , ")}] + last $time seconds")
|
||||
// Utils.log("MTA", "$eventId + [${kv.joinToString(" , ")}] + last $time seconds")
|
||||
// StatService.trackCustomKVTimeIntervalEvent(HaloApp.getInstance().application, time, eventId, prop)
|
||||
}
|
||||
|
||||
@ -75,7 +83,7 @@ object MtaHelper {
|
||||
// prop.setProperty("GID", HaloApp.getInstance().gid)
|
||||
// }
|
||||
//
|
||||
// Utils.log("MTA","$eventId + [${kv.joinToString(" , ")}]")
|
||||
// Utils.log("MTA", "$eventId + [${kv.joinToString(" , ")}]")
|
||||
// StatService.trackCustomKVEvent(HaloApp.getInstance().application, eventId, prop)
|
||||
}
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ object PackageHelper {
|
||||
private fun getAllPackageName(context: Context): HashSet<String> {
|
||||
val set = HashSet<String>()
|
||||
return try {
|
||||
val packageInfos = context.applicationContext.packageManager.getInstalledPackages(0)
|
||||
val packageInfos = PackageUtils.getInstalledPackages(context, 0)
|
||||
for (packageInfo in packageInfos) {
|
||||
if (packageInfo.applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM == 0) {
|
||||
if (context.packageName != packageInfo.packageName) {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
@ -113,6 +114,9 @@ object PackageInstaller {
|
||||
val uninstallIntent = Intent()
|
||||
uninstallIntent.action = Intent.ACTION_DELETE
|
||||
uninstallIntent.addCategory(Intent.CATEGORY_DEFAULT)
|
||||
if (context !is Activity) {
|
||||
uninstallIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
val packageName = PackageUtils.getPackageNameByPath(context, path)
|
||||
uninstallIntent.data = Uri.parse("package:$packageName")
|
||||
InstallUtils.getInstance(context).addUninstall(packageName)
|
||||
|
||||
@ -30,8 +30,11 @@ import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.X509Certificate;
|
||||
@ -286,7 +289,7 @@ public class PackageUtils {
|
||||
*/
|
||||
public static String getPackageNameByPath(Context context, String path) {
|
||||
PackageManager packageManager = context.getApplicationContext().getPackageManager();
|
||||
PackageInfo info = packageManager.getPackageArchiveInfo(path, PackageManager.GET_ACTIVITIES);
|
||||
PackageInfo info = packageManager.getPackageArchiveInfo(path, 0);
|
||||
if (info != null) {
|
||||
ApplicationInfo appInfo = info.applicationInfo;
|
||||
return appInfo.packageName;
|
||||
@ -365,7 +368,7 @@ public class PackageUtils {
|
||||
*/
|
||||
public static ArrayList<String> getAllPackageName(Context context) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
List<PackageInfo> packageInfos = context.getApplicationContext().getPackageManager().getInstalledPackages(0);
|
||||
List<PackageInfo> packageInfos = getInstalledPackages(context, 0);
|
||||
for (PackageInfo packageInfo : packageInfos) {
|
||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
if (!context.getPackageName().equals(packageInfo.packageName)) {
|
||||
@ -380,7 +383,7 @@ public class PackageUtils {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
try {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
List<PackageInfo> packageInfos = pm.getInstalledPackages(0);
|
||||
List<PackageInfo> packageInfos = getInstalledPackages(context, 0);
|
||||
for (PackageInfo packageInfo : packageInfos) {
|
||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
@ -552,4 +555,42 @@ public class PackageUtils {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 在5.1系统手机使用PackageManager获取已安装应用容易发生Package manager has died异常
|
||||
* https://stackoverflow.com/questions/13235793/transactiontoolargeeception-when-trying-to-get-a-list-of-applications-installed/30062632#30062632
|
||||
*/
|
||||
public static List<PackageInfo> getInstalledPackages(Context context, int flags) {
|
||||
final PackageManager pm = context.getPackageManager();
|
||||
try {
|
||||
return pm.getInstalledPackages(flags);
|
||||
} catch (Exception ignored) {
|
||||
//we don't care why it didn't succeed. We'll do it using an alternative way instead
|
||||
}
|
||||
// use fallback:
|
||||
Process process;
|
||||
List<PackageInfo> result = new ArrayList<>();
|
||||
BufferedReader bufferedReader = null;
|
||||
try {
|
||||
process = Runtime.getRuntime().exec("pm list packages");
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
final String packageName = line.substring(line.indexOf(':') + 1);
|
||||
final PackageInfo packageInfo = pm.getPackageInfo(packageName, flags);
|
||||
result.add(packageInfo);
|
||||
}
|
||||
process.waitFor();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (bufferedReader != null)
|
||||
try {
|
||||
bufferedReader.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -158,8 +158,7 @@ public class ShareUtils {
|
||||
|
||||
//检查是否安装手机QQ
|
||||
public static boolean isQQClientAvailable(Context context) {
|
||||
final PackageManager packageManager = context.getPackageManager();
|
||||
List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);
|
||||
List<PackageInfo> pinfo = PackageUtils.getInstalledPackages(context, 0);
|
||||
if (pinfo != null) {
|
||||
for (int i = 0; i < pinfo.size(); i++) {
|
||||
String pn = pinfo.get(i).packageName;
|
||||
@ -619,7 +618,7 @@ public class ShareUtils {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (mShareEntrance != ShareEntrance.shareGh ) {
|
||||
if (mShareEntrance != ShareEntrance.shareGh) {
|
||||
safelyDismiss();
|
||||
}
|
||||
}
|
||||
@ -746,7 +745,7 @@ public class ShareUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void safelyDismiss() {
|
||||
if (popupWindow.get() != null) {
|
||||
popupWindow.get().dismiss();
|
||||
|
||||
@ -32,7 +32,7 @@ class ReserveDialog : BaseDialogFragment() {
|
||||
binding.more.setOnClickListener {
|
||||
val intent = MyGameActivity.getIntentWithConfig(requireContext(), 2)
|
||||
startActivity(intent)
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding.recyclerView.layoutManager = if (mReserveList.size > 4) {
|
||||
GridLayoutManager(context, 4)
|
||||
@ -54,7 +54,7 @@ class ReserveDialog : BaseDialogFragment() {
|
||||
holder.binding.game = entity
|
||||
holder.itemView.setOnClickListener {
|
||||
GameDetailActivity.startGameDetailActivity(mContext, entity.id, "(预约弹窗)")
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ class WelcomeDialog : BaseDialogFragment() {
|
||||
|
||||
mDismissByClickImage = true
|
||||
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
binding.ivOpeningCover.loadingCallback = object : WrapContentDraweeView.LoadingCallback {
|
||||
@ -102,15 +102,24 @@ class WelcomeDialog : BaseDialogFragment() {
|
||||
}
|
||||
|
||||
binding.ivCloseBackup.setOnClickListener {
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding.ivClose.setOnClickListener {
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding.welcome = mWelcomeEntity
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun dismissAllowingStateLoss() {
|
||||
try {
|
||||
mDismissByClickImage = false
|
||||
super.dismissAllowingStateLoss()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun dismiss() {
|
||||
try {
|
||||
mDismissByClickImage = false
|
||||
|
||||
@ -142,7 +142,14 @@ object XapkInstaller : IXapkUnzipListener {
|
||||
mXapkUnzipThreadMap.remove(downloadEntity.path)
|
||||
|
||||
AppExecutor.uiExecutor.execute {
|
||||
val pkgPath = checkNotNull(downloadEntity.meta[XAPK_PACKAGE_PATH_TAG])
|
||||
val pkgPath = downloadEntity.meta[XAPK_PACKAGE_PATH_TAG]
|
||||
|
||||
if (pkgPath == null) {
|
||||
Utils.toast(mContext, "下载出错,请重新下载!")
|
||||
|
||||
return@execute
|
||||
}
|
||||
|
||||
PackageInstaller.install(mContext, pkgPath)
|
||||
|
||||
downloadEntity.meta[XAPK_UNZIP_PERCENT] = "100.0"
|
||||
|
||||
@ -50,7 +50,7 @@ object DownloadDataHelper {
|
||||
"暂停下载-连上WiFi自动下载"
|
||||
} else if (status == DownloadStatus.done) {
|
||||
val pm = HaloApp.getInstance().application.applicationContext.packageManager
|
||||
val packageInfo = pm.getPackageArchiveInfo(downloadEntity.path, PackageManager.GET_ACTIVITIES)
|
||||
val packageInfo = pm.getPackageArchiveInfo(downloadEntity.path, 0)
|
||||
if (packageInfo == null) {
|
||||
"解析包错误"
|
||||
} else {
|
||||
|
||||
@ -943,7 +943,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
map.put(HttpDnsManager.GID, HaloApp.getInstance().getGid());
|
||||
map.put(HttpDnsManager.OAID, HaloApp.getInstance().getOAID());
|
||||
map.put(HttpDnsManager.USER_ID, UserManager.getInstance().getUserId());
|
||||
map.put(HttpDnsManager.IMEI, MetaUtil.INSTANCE.getIMEI());
|
||||
map.put(HttpDnsManager.IMEI, MetaUtil.getBase64EncodedIMEI());
|
||||
|
||||
HttpDnsManager.metaMap = map;
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ class DownloadDialog : BaseDialogFragment(), View.OnTouchListener {
|
||||
}
|
||||
})
|
||||
mViewModel.dismissLiveData.observe(this, Observer {
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
})
|
||||
|
||||
mElapsedHelper = TimeElapsedHelper()
|
||||
@ -173,7 +173,7 @@ class DownloadDialog : BaseDialogFragment(), View.OnTouchListener {
|
||||
postBrowseMta()
|
||||
mViewModel.collectionLiveData.postValue(null)
|
||||
} else {
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
mGestureDetector = GestureDetector(requireContext(), SingleTapConfirm())
|
||||
@ -332,7 +332,7 @@ class DownloadDialog : BaseDialogFragment(), View.OnTouchListener {
|
||||
MotionEvent.ACTION_UP,
|
||||
MotionEvent.ACTION_OUTSIDE -> {
|
||||
if (mBinding.root.y >= mBinding.root.height / 2) {
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
} else {
|
||||
resetDialogPosition(300)
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ class DownloadLinkDialog : BaseDialogFragment() {
|
||||
mLinkEntity.content, "text/html", "utf-8", null)
|
||||
|
||||
binding.confirm.setOnClickListener {
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
return binding.root
|
||||
}
|
||||
|
||||
@ -15,6 +15,12 @@ import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.g00fy2.versioncompare.Version;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.AppExecutor;
|
||||
@ -56,11 +62,6 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
@ -17,6 +17,7 @@ import androidx.core.content.ContextCompat;
|
||||
import com.gh.common.util.BitmapUtils;
|
||||
import com.gh.common.util.MtaHelper;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.KcSelectGameViewHolder;
|
||||
import com.gh.gamecenter.entity.InstallGameEntity;
|
||||
@ -106,7 +107,7 @@ public class CleanApkAdapter extends BaseRecyclerAdapter<KcSelectGameViewHolder>
|
||||
for (String apk_path : mApkPath) {
|
||||
InstallGameEntity apkEntity = new InstallGameEntity();
|
||||
PackageManager pm = mContext.getApplicationContext().getPackageManager();
|
||||
PackageInfo packageInfo = pm.getPackageArchiveInfo(apk_path, PackageManager.GET_ACTIVITIES);
|
||||
PackageInfo packageInfo = pm.getPackageArchiveInfo(apk_path, 0);
|
||||
if (packageInfo == null) continue;
|
||||
|
||||
ApplicationInfo appInfo = packageInfo.applicationInfo;
|
||||
@ -132,7 +133,7 @@ public class CleanApkAdapter extends BaseRecyclerAdapter<KcSelectGameViewHolder>
|
||||
/**安装处理类型*/
|
||||
/** 得到包名 */
|
||||
String packageName = packageInfo.packageName;
|
||||
int type = doType(pm, packageName);
|
||||
int type = doType(packageName);
|
||||
apkEntity.setInstallStatus(type);
|
||||
|
||||
mApkList.add(apkEntity);
|
||||
@ -176,8 +177,8 @@ public class CleanApkAdapter extends BaseRecyclerAdapter<KcSelectGameViewHolder>
|
||||
}
|
||||
}
|
||||
|
||||
private int doType(PackageManager pm, String packageName) {
|
||||
List<PackageInfo> pakageinfos = pm.getInstalledPackages(0);
|
||||
private int doType(String packageName) {
|
||||
List<PackageInfo> pakageinfos = PackageUtils.getInstalledPackages(mContext, 0);
|
||||
for (PackageInfo pi : pakageinfos) {
|
||||
if ((pi.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
String pi_packageName = pi.packageName;
|
||||
|
||||
@ -17,7 +17,7 @@ public class DataCollectionDao {
|
||||
try {
|
||||
helper = DatabaseHelper.getHelper(context);
|
||||
dao = helper.getDao(DataCollectionInfo.class);
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLException | IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -28,7 +28,7 @@ public class DataCollectionDao {
|
||||
public List<DataCollectionInfo> findByType(String type) {
|
||||
try {
|
||||
return dao.queryForEq("type", type);
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLException | IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
@ -40,7 +40,8 @@ public class DataCollectionDao {
|
||||
public void add(DataCollectionInfo entity) {
|
||||
try {
|
||||
dao.create(entity);
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLException | IllegalStateException e) {
|
||||
// java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase:
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -51,7 +52,8 @@ public class DataCollectionDao {
|
||||
public void delete(String id) {
|
||||
try {
|
||||
dao.deleteById(id);
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLException | IllegalStateException e) {
|
||||
// java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase:
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -62,7 +64,7 @@ public class DataCollectionDao {
|
||||
public void delete(List<String> ids) {
|
||||
try {
|
||||
dao.deleteIds(ids);
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLException | IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -73,7 +75,7 @@ public class DataCollectionDao {
|
||||
public DataCollectionInfo find(String id) {
|
||||
try {
|
||||
return dao.queryForId(id);
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLException | IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
@ -85,7 +87,7 @@ public class DataCollectionDao {
|
||||
public List<DataCollectionInfo> getAll() {
|
||||
try {
|
||||
return dao.queryForAll();
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLException | IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
@ -97,7 +99,7 @@ public class DataCollectionDao {
|
||||
public List<DataCollectionInfo> getClickData() {
|
||||
try {
|
||||
return dao.queryForEq("type", "click-item");
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLException | IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
@ -109,7 +111,7 @@ public class DataCollectionDao {
|
||||
public void update(DataCollectionInfo entity) {
|
||||
try {
|
||||
dao.update(entity);
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLException | IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.gamecenter.db;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteException;
|
||||
|
||||
import com.gh.gamecenter.db.info.PackageInfo;
|
||||
import com.j256.ormlite.dao.Dao;
|
||||
@ -18,7 +19,7 @@ public class FilterDao {
|
||||
try {
|
||||
helper = DatabaseHelper.getHelper(context);
|
||||
dao = helper.getDao(PackageInfo.class);
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLiteException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -31,7 +32,7 @@ public class FilterDao {
|
||||
if (list != null && list.size() != 0) {
|
||||
return list.get(0).getTime();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLiteException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
@ -43,7 +44,7 @@ public class FilterDao {
|
||||
if (filterEntity != null) {
|
||||
return true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLiteException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
@ -55,7 +56,7 @@ public class FilterDao {
|
||||
public void add(PackageInfo entity) {
|
||||
try {
|
||||
dao.create(entity);
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLiteException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -67,7 +68,7 @@ public class FilterDao {
|
||||
public void addAll(List<PackageInfo> list) {
|
||||
try {
|
||||
dao.create(list);
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLiteException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -75,7 +76,7 @@ public class FilterDao {
|
||||
public void deleteAll(List<PackageInfo> list) {
|
||||
try {
|
||||
dao.delete(list);
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLiteException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -86,7 +87,7 @@ public class FilterDao {
|
||||
public void delete(String packageName) {
|
||||
try {
|
||||
dao.deleteById(packageName);
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLiteException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -97,7 +98,7 @@ public class FilterDao {
|
||||
public List<PackageInfo> getAll() {
|
||||
try {
|
||||
return dao.queryForAll();
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLiteException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
@ -109,7 +110,7 @@ public class FilterDao {
|
||||
public long getCount() {
|
||||
try {
|
||||
return dao.countOf();
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLiteException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
|
||||
@ -61,12 +61,12 @@ class GameResourcePolicyDialogFragment : BaseDialogFragment() {
|
||||
mVebView?.loadUrl(requireContext().getString(R.string.upload_game_policy_url))
|
||||
containerView?.findViewById<View>(R.id.refuseTv)?.setOnClickListener {
|
||||
MtaHelper.onEvent("游戏上传", "开发者弹窗", "不同意")
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
requireActivity().finish()
|
||||
}
|
||||
containerView?.findViewById<View>(R.id.agreeTv)?.setOnClickListener {
|
||||
MtaHelper.onEvent("游戏上传", "开发者弹窗", "同意")
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ object PackagesManager {
|
||||
*/
|
||||
val updateListSize: Int get() = updateAndPluginList.size
|
||||
|
||||
fun initInstallPkgList(list: ArrayList<String>) {
|
||||
fun initInstallPkgList(list: List<String>) {
|
||||
installedPkgList.clear()
|
||||
installedPkgList.addAll(list)
|
||||
}
|
||||
|
||||
@ -33,6 +33,8 @@ import okhttp3.ResponseBody
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import retrofit2.HttpException
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
/**
|
||||
* 该类存储的是已安装的所有游戏(助手后台已收录的)和所有更新(包括插件化)数据
|
||||
@ -54,7 +56,7 @@ object PackageRepository {
|
||||
|
||||
private const val LAST_UPLOAD_APPLIST_TIME = "last_upload_applist_time"
|
||||
|
||||
private val mInstalledPkgList = ArrayList<String>()
|
||||
private val mInstalledPkgList = Collections.synchronizedList(ArrayList<String>())
|
||||
|
||||
val gameUpdateLiveData = MutableLiveData<List<GameUpdateEntity>>()
|
||||
val gameInstalledLiveData = MutableLiveData<List<GameInstall>>()
|
||||
|
||||
@ -2,10 +2,10 @@ package com.gh.gamecenter.personal;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.database.sqlite.SQLiteException;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewStub;
|
||||
@ -13,6 +13,14 @@ import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.base.fragment.BaseLazyFragment;
|
||||
import com.gh.common.databind.BindingAdapters;
|
||||
@ -84,13 +92,6 @@ import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
@ -622,7 +623,11 @@ public class PersonalFragment extends BaseLazyFragment {
|
||||
|
||||
signEntity.setId(UserManager.getInstance().getUserId());
|
||||
if (mDatabase.signDao().updateSignEntity(signEntity) <= 0) {
|
||||
mDatabase.signDao().addSignEntity(signEntity);
|
||||
try {
|
||||
mDatabase.signDao().addSignEntity(signEntity);
|
||||
} catch (SQLiteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -121,12 +121,19 @@ class ArticleDetailCommentFragment : BaseArticleDetailCommentFragment<CommentIte
|
||||
false,
|
||||
listener = object : OnCommentOptionClickListener {
|
||||
override fun onCommentOptionClick(entity: CommentEntity, option: String) {
|
||||
DialogUtils.showNewAlertDialog(requireContext(), "提示", "删除评论后,评论下所有的回复都将被删除", "取消", "删除", null, {
|
||||
mViewModel.hideCommunityArticleComment(entity.id ?: "") {
|
||||
EventBus.getDefault().post(EBDeleteCommentDetail(entity.id))
|
||||
requireActivity().finish()
|
||||
when (option) {
|
||||
"删除评论" -> {
|
||||
DialogUtils.showNewAlertDialog(requireContext(), "提示", "删除评论后,评论下所有的回复都将被删除", "取消", "删除", null, {
|
||||
mViewModel.hideCommunityArticleComment(entity.id ?: "") {
|
||||
EventBus.getDefault().post(EBDeleteCommentDetail(entity.id))
|
||||
requireActivity().finish()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
else -> {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
@ -80,7 +80,7 @@ class ArticleTagsSelectFragment : BaseFragment<String>() {
|
||||
|
||||
mCancelBtn.setOnClickListener {
|
||||
val fragment = parentFragment
|
||||
(fragment as? BaseDialogWrapperFragment)?.dismiss()
|
||||
(fragment as? BaseDialogWrapperFragment)?.dismissAllowingStateLoss()
|
||||
}
|
||||
mPostBtn.setOnClickListener {
|
||||
mViewModel?.postArticle()
|
||||
|
||||
@ -101,7 +101,7 @@ open class NewCommentFragment : ListFragment<CommentEntity, NewCommentViewModel>
|
||||
mArticleId = getString(ARTICLE_ID, "")
|
||||
mVideoId = getString(VIDEO_ID, "")
|
||||
mCommentCount = getInt(COMMENT_COUNT, 0)
|
||||
mCommentType = getSerializable(COMMENT_TYPE) as CommentType
|
||||
mCommentType = getSerializable(COMMENT_TYPE) as? CommentType ?: CommentType.ANSWER
|
||||
mCommunityId = getString(COMMUNITY_ID, "")
|
||||
mShowInputOnly = getBoolean(SHOW_INPUT_ONLY, false)
|
||||
mCommentEntity = getParcelable(COMMENT_ENTITY)
|
||||
|
||||
@ -11,6 +11,7 @@ import com.gh.common.syncpage.SyncFieldConstants
|
||||
import com.gh.common.syncpage.SyncPageRepository
|
||||
import com.gh.common.util.CommentDraftContainer
|
||||
import com.gh.common.util.createRequestBody
|
||||
import com.gh.common.util.tryCatchInRelease
|
||||
import com.gh.gamecenter.baselist.ListViewModel
|
||||
import com.gh.gamecenter.entity.CommentDraft
|
||||
import com.gh.gamecenter.entity.CommentEntity
|
||||
@ -170,7 +171,7 @@ open class NewCommentViewModel(application: Application,
|
||||
if (draftContent.isNotEmpty()) {
|
||||
val draft = CommentDraft(id = id, draft = draftContent)
|
||||
if (it.updateDraft(draft) <= 0) {
|
||||
it.addDraft(draft)
|
||||
tryCatchInRelease { it.addDraft(draft) }
|
||||
}
|
||||
} else {
|
||||
it.deleteDraftById(id)
|
||||
|
||||
@ -92,7 +92,7 @@ class TagsSelectFragment : BaseFragment<String>() {
|
||||
}
|
||||
mModeratorPatchTagsCallback?.onPatchTagsSuccess()
|
||||
val fragment = parentFragment
|
||||
(fragment as? BaseDialogWrapperFragment)?.dismiss()
|
||||
(fragment as? BaseDialogWrapperFragment)?.dismissAllowingStateLoss()
|
||||
AppExecutor.uiExecutor.executeWithDelay(Runnable {
|
||||
NotificationHelper.showNotificationHintDialog(NotificationUgc.QUESTION)
|
||||
}, 1000)
|
||||
@ -107,7 +107,7 @@ class TagsSelectFragment : BaseFragment<String>() {
|
||||
"确定", null, DialogUtils.ConfirmListener {
|
||||
mModeratorPatchTagsCallback?.onPermissionError()
|
||||
val fragment = parentFragment
|
||||
(fragment as? BaseDialogWrapperFragment)?.dismiss()
|
||||
(fragment as? BaseDialogWrapperFragment)?.dismissAllowingStateLoss()
|
||||
}, null)
|
||||
return@Observer
|
||||
}
|
||||
@ -198,7 +198,7 @@ class TagsSelectFragment : BaseFragment<String>() {
|
||||
|
||||
mCancelBtn.setOnClickListener {
|
||||
val fragment = parentFragment
|
||||
(fragment as? BaseDialogWrapperFragment)?.dismiss()
|
||||
(fragment as? BaseDialogWrapperFragment)?.dismissAllowingStateLoss()
|
||||
|
||||
if (mViewModel?.postLiveData?.value != null) {
|
||||
mViewModel?.postLiveData?.postValue(null)
|
||||
|
||||
@ -1,14 +1,16 @@
|
||||
package com.gh.gamecenter.qa.recommends;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteException;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MediatorLiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.common.util.UrlFilterUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
@ -379,7 +381,11 @@ public class AskQuestionsRecommendsViewModel extends BaseListViewModel<Recommend
|
||||
answerEntity.setOrderTag(orderTag);
|
||||
}
|
||||
if (mAnswerDao.updateAnswerEntity(entityList) <= 0) {
|
||||
mAnswerDao.addAnswerEntity(entityList);
|
||||
try {
|
||||
mAnswerDao.addAnswerEntity(entityList);
|
||||
} catch (SQLiteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
mPreference.edit().putBoolean(getCheckIsHasCommunityDataKey(), true).apply();
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.gh.common.util.BitmapUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.UrlFilterUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.entity.GameInstall;
|
||||
@ -101,7 +102,7 @@ public class SelectGameDialogAdapter extends BaseRecyclerAdapter<VotingSelectGam
|
||||
Observable
|
||||
.create(emitter -> {
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
List<PackageInfo> installedPackages = pm.getInstalledPackages(0);
|
||||
List<PackageInfo> installedPackages = PackageUtils.getInstalledPackages(mContext, 0);
|
||||
|
||||
|
||||
for (PackageInfo installedPackage : installedPackages) {
|
||||
|
||||
@ -96,7 +96,7 @@ class OkHttpCacheInterceptor implements Interceptor {
|
||||
// }
|
||||
|
||||
request = request.newBuilder()
|
||||
.addHeader("IMEI", MetaUtil.getIMEI())
|
||||
.addHeader("JNFJ", MetaUtil.getBase64EncodedIMEI())
|
||||
.addHeader("CHANNEL", HaloApp.getInstance().getChannel())
|
||||
.addHeader("VERSION", PackageUtils.getVersionName())
|
||||
.addHeader("OAID", HaloApp.getInstance().getOAID())
|
||||
|
||||
@ -11,6 +11,7 @@ import android.widget.ProgressBar;
|
||||
import com.gh.base.OnRequestCallBackListener;
|
||||
import com.gh.base.fragment.BaseFragment;
|
||||
import com.gh.common.util.BitmapUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.SuggestionActivity;
|
||||
import com.gh.gamecenter.entity.InstallGameEntity;
|
||||
@ -60,7 +61,7 @@ public class SuggestSelectGameAdapter extends BaseRecyclerAdapter<SelectGameView
|
||||
Observable
|
||||
.create(emitter -> {
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
List<PackageInfo> installedPackages = pm.getInstalledPackages(0);
|
||||
List<PackageInfo> installedPackages = PackageUtils.getInstalledPackages(mContext, 0);
|
||||
|
||||
for (PackageInfo installedPackage : installedPackages) {
|
||||
if ((installedPackage.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
|
||||
@ -107,6 +107,7 @@ class VideoDetailContainerFragment : BaseLazyFragment(), OnBackPressedListener {
|
||||
|
||||
override fun onFragmentFirstVisible() {
|
||||
super.onFragmentFirstVisible()
|
||||
mViewModel.setRecyclerView(recyclerview)
|
||||
initListener()
|
||||
if (!mIsHomeVideo) {
|
||||
toolbar.setNavigationIcon(R.drawable.ic_toolbar_back_white)
|
||||
@ -187,6 +188,11 @@ class VideoDetailContainerFragment : BaseLazyFragment(), OnBackPressedListener {
|
||||
mViewModel.followVideoInfo.observeNonNull(this) {
|
||||
updateAllFollowDatas(it.user.id ?: "", it.me.isFollower)
|
||||
}
|
||||
mViewModel.refreshFinish.observeNonNull(this){
|
||||
if (it){
|
||||
refresh.isRefreshing = false
|
||||
}
|
||||
}
|
||||
|
||||
mViewModel.getVideoDetailList(mInitialVideoId, mLocation, isLoadNext = true)
|
||||
}
|
||||
|
||||
@ -4,11 +4,14 @@ import android.annotation.SuppressLint
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.exposure.meta.MetaUtil
|
||||
import com.gh.common.history.HistoryDatabase
|
||||
import com.gh.common.runOnIoThread
|
||||
import com.gh.common.util.UrlFilterUtils
|
||||
import com.gh.common.util.createRequestBodyAny
|
||||
import com.gh.common.util.tryCatchInRelease
|
||||
import com.gh.common.util.tryWithDefaultCatch
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.MyVideoEntity
|
||||
@ -23,6 +26,7 @@ import com.lightgame.utils.Utils
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.ResponseBody
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.*
|
||||
import kotlin.random.Random
|
||||
|
||||
@ -36,6 +40,7 @@ class VideoDetailContainerViewModel(application: Application) : AndroidViewModel
|
||||
var path = ""
|
||||
var entranceDetail = "" // 视频流入口链接, WEB($页面Url$)
|
||||
|
||||
var refreshFinish = MutableLiveData<Boolean>()
|
||||
var noDataError = MutableLiveData<Boolean>()
|
||||
var networkError = MutableLiveData<Boolean>()
|
||||
var videoList = MutableLiveData<ArrayList<VideoEntity>>()
|
||||
@ -51,15 +56,20 @@ class VideoDetailContainerViewModel(application: Application) : AndroidViewModel
|
||||
var paginationType = "page"//活动分页方式 page(默认) filter
|
||||
var fieldId = ""//专区视频板块id
|
||||
var sectionName = ""//专区视频专题名
|
||||
var positionAndPackageMap = HashMap<String, Int>() // key: packageName + position, value: position
|
||||
var isPauseVideo = true
|
||||
private var page = 1
|
||||
private var cacheVideoIds: MutableList<String>? = null
|
||||
private var cacheId = ""
|
||||
var positionAndPackageMap = HashMap<String, Int>() // key: packageName + position, value: position
|
||||
var isPauseVideo = true
|
||||
private var mRecyclerViewRef: WeakReference<RecyclerView>? = null
|
||||
|
||||
// 是否为第一次加载(即没有进行加载更多)
|
||||
private var mIsFirstLoad = true
|
||||
|
||||
fun setRecyclerView(recyclerView: RecyclerView) {
|
||||
mRecyclerViewRef = WeakReference(recyclerView)
|
||||
}
|
||||
|
||||
fun collect() {
|
||||
collectVideo(currentDisplayingVideo)
|
||||
}
|
||||
@ -218,10 +228,20 @@ class VideoDetailContainerViewModel(application: Application) : AndroidViewModel
|
||||
}
|
||||
if (mIsFirstLoad || !(data.size == 1 && data[0].id == videoId)) {
|
||||
//下拉刷新清除列表数据
|
||||
if (!isLoadNext) {
|
||||
// if (!isLoadNext) {
|
||||
// videoList.value?.clear()
|
||||
// }
|
||||
// mergeVideoList(data, isLoadNext)
|
||||
if (isLoadNext) {
|
||||
mergeVideoList(data, isLoadNext)
|
||||
} else if (!isLoadNext && mRecyclerViewRef?.get()?.computeVerticalScrollOffset() == 0) {
|
||||
//下拉刷新并且列表没有滚动清除列表数据,数据发生变化
|
||||
videoList.value?.clear()
|
||||
mergeVideoList(data, isLoadNext)
|
||||
} else {
|
||||
//下拉刷新并且列表滚动中关闭下拉刷新动画,数据不变
|
||||
refreshFinish.postValue(true)
|
||||
}
|
||||
mergeVideoList(data, isLoadNext)
|
||||
}
|
||||
|
||||
mIsFirstLoad = false
|
||||
@ -419,10 +439,8 @@ class VideoDetailContainerViewModel(application: Application) : AndroidViewModel
|
||||
commentCount = videoEntity.commentCount
|
||||
videoStreamRecord = if (location == Location.VIDEO_CHOICENESS.value || location == Location.VIDEO_HOT.value) 1 else 0
|
||||
}
|
||||
runOnIoThread {
|
||||
HistoryDatabase.instance.videoHistoryDao().addVideo(videoHistory)
|
||||
}
|
||||
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.videoHistoryDao().addVideo(videoHistory) } }
|
||||
}
|
||||
|
||||
fun shareVideoStatistics(videoEntity: VideoEntity?) {
|
||||
|
||||
@ -3,15 +3,14 @@ package com.gh.gamecenter.video.upload
|
||||
import android.annotation.SuppressLint
|
||||
import com.alibaba.sdk.android.oss.common.OSSLog
|
||||
import com.gh.common.util.MD5Utils
|
||||
import com.gh.common.util.tryCatchInRelease
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
|
||||
import com.gh.gamecenter.entity.OssEntity
|
||||
import com.gh.gamecenter.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.room.AppDatabase
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
@ -36,7 +35,7 @@ object UploadManager : OnUploadListener {
|
||||
val entity = mUploadDao.getUploadByFilePath(uploadFilePath)
|
||||
if (entity != null) {
|
||||
entity.success = true
|
||||
mUploadDao.addUpload(entity)
|
||||
tryCatchInRelease { mUploadDao.addUpload(entity) }
|
||||
}
|
||||
mUploadListenerMap[uploadFilePath]?.onUploadSuccess(uploadFilePath, url)
|
||||
mUploadListenerMap.remove(uploadFilePath)
|
||||
@ -76,7 +75,7 @@ object UploadManager : OnUploadListener {
|
||||
data.domain = uploadEntity.domain
|
||||
data.key = uploadEntity.key
|
||||
} else {
|
||||
mUploadDao.addUpload(UploadEntity(uploadFilePath, fileMD5, data.domain, data.key, false))
|
||||
tryCatchInRelease { mUploadDao.addUpload(UploadEntity(uploadFilePath, fileMD5, data.domain, data.key, false)) }
|
||||
}
|
||||
|
||||
val uploadThread = UploadThread(data, this@UploadManager)
|
||||
|
||||
@ -23,6 +23,7 @@ import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DeviceUtils;
|
||||
import com.gh.common.util.DownloadNotificationHelper;
|
||||
import com.gh.common.util.DownloadObserver;
|
||||
import com.gh.common.util.GdtHelper;
|
||||
import com.gh.common.util.HomeBottomBarHelper;
|
||||
import com.gh.common.util.PackageHelper;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
@ -211,7 +212,7 @@ public class HaloApp extends Application {
|
||||
private void initThirdPartySdk() {
|
||||
initPushSdk();
|
||||
DataUtils.init(this, mChannel);
|
||||
// GdtHelper.INSTANCE.init(this, mChannel);
|
||||
GdtHelper.INSTANCE.init(this, mChannel);
|
||||
// AntiBotHelper.getManager();
|
||||
}
|
||||
|
||||
|
||||
@ -97,8 +97,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_toEndOf="@+id/back_tiny"
|
||||
android:layout_toRightOf="@+id/back_tiny"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<ImageView
|
||||
|
||||
@ -51,7 +51,6 @@
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintLeft_toRightOf="@id/user_icon"
|
||||
app:layout_constraintRight_toLeftOf="@+id/sdv_user_badge"
|
||||
app:layout_constraintTop_toTopOf="@id/user_icon"
|
||||
tools:text="我的昵称很长很长有十二字" />
|
||||
|
||||
|
||||
@ -7,8 +7,8 @@ ext {
|
||||
targetSdkVersion = 26
|
||||
|
||||
// application info
|
||||
versionCode = 218
|
||||
versionName = "4.3.8"
|
||||
versionCode = 221
|
||||
versionName = "4.4.0"
|
||||
applicationId = "com.gh.gamecenter"
|
||||
|
||||
// AndroidX
|
||||
|
||||
Submodule libraries/LGLibrary updated: 6f98431cbd...329431eb8e
BIN
libraries/MTA/libs/mid-core-sdk-4.3.0.jar
Normal file
BIN
libraries/MTA/libs/mid-core-sdk-4.3.0.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
libraries/MTA/libs/mta-android-sdk-3.7.1.jar
Normal file
BIN
libraries/MTA/libs/mta-android-sdk-3.7.1.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user