Compare commits
126 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e512634c6 | |||
| 7045354808 | |||
| dbcc97a250 | |||
| 050081b7b1 | |||
| 993d1e7635 | |||
| a86a3c1f71 | |||
| b0a192ad9a | |||
| ea7b478c6b | |||
| b673383f59 | |||
| 06ae366b74 | |||
| 6b9cf7094e | |||
| 5ae22bd2bc | |||
| e951551531 | |||
| 272e5fb6cc | |||
| 7dc17d09c1 | |||
| cfacbe739d | |||
| 0a72226ba5 | |||
| 5f22a14643 | |||
| 5562e38c2f | |||
| f9027f7a61 | |||
| 6d0e437ad4 | |||
| 3abc53d3b3 | |||
| d0e4c2c3ab | |||
| 5be50c1638 | |||
| 7c525aec79 | |||
| 63d5edf892 | |||
| c9f2cf178a | |||
| fc98de3bc0 | |||
| dd8360f5e8 | |||
| bc9b815b47 | |||
| 2a93995221 | |||
| 0e93f6521c | |||
| b3a6d0ce94 | |||
| de60d05190 | |||
| 2a2ce9a490 | |||
| 639644e3c3 | |||
| 2378e6e94e | |||
| 87d9feae70 | |||
| 4a93d129bb | |||
| 39e5e2e9f9 | |||
| 8a5f777c65 | |||
| 22c693e042 | |||
| 36d04f5841 | |||
| 409123337d | |||
| b180a210cb | |||
| 32dfdc4d08 | |||
| 4d46888995 | |||
| 69db836231 | |||
| f82b9ad308 | |||
| 3ac91b1216 | |||
| 8d4b3e0851 | |||
| 67d8f46217 | |||
| f357136936 | |||
| 9d622d2be9 | |||
| 800525227d | |||
| c9dec9a31e | |||
| 2ae4fda6e8 | |||
| 609702715f | |||
| ec7e138208 | |||
| bfd64a8bce | |||
| 5571b6481f | |||
| 6d6574988c | |||
| af8d075bf2 | |||
| b7db66e90b | |||
| 13ac4658d9 | |||
| 8ad3420822 | |||
| f842ced67e | |||
| e0081e56df | |||
| 3202764f22 | |||
| f477876359 | |||
| 86ffcb92f8 | |||
| a2088e5cd9 | |||
| 6e1247f393 | |||
| c33faa4918 | |||
| d0aeb1c411 | |||
| 485924527e | |||
| ca1bfda326 | |||
| c7c786d662 | |||
| acf9fe308c | |||
| 3b32231709 | |||
| 9dae198af2 | |||
| 29bfd5bb93 | |||
| 8da51d7f5a | |||
| 91964a0ffc | |||
| 479ef20859 | |||
| f458b7dcb8 | |||
| 2d25ff7836 | |||
| 57dd5d0584 | |||
| 757efec05e | |||
| 4979045be2 | |||
| f59af60f70 | |||
| 60bc2a02f4 | |||
| 996be3906e | |||
| 14a054bdbc | |||
| 07a9fd6273 | |||
| a067f7bc43 | |||
| a5eefbb6f4 | |||
| 8d9f83c432 | |||
| ae0df36a89 | |||
| 72539671a1 | |||
| 94277a4aeb | |||
| e276d148cf | |||
| a7152034e8 | |||
| 4a5e9da34a | |||
| 1422365cc5 | |||
| 7f55ff6340 | |||
| 4722626fb7 | |||
| 39d87ad98d | |||
| 85333b9eed | |||
| c99ae6db3e | |||
| c5be98adc2 | |||
| 5321aa2e9f | |||
| 345707ef42 | |||
| 6a9d05d916 | |||
| faf2a89706 | |||
| ada51f90f1 | |||
| 53962116d5 | |||
| 3ea52745b3 | |||
| a8f2289b27 | |||
| 6dd56b5d16 | |||
| eb739cf6cb | |||
| 4853cd9047 | |||
| 4e0f14aeed | |||
| 5e37dac0f6 | |||
| 22bfa9051a | |||
| 0a1dca3aa3 |
@ -30,4 +30,9 @@
|
||||
- 删除TINKER_VERISON_NAME
|
||||
- tinker打包方式变更(以小版本作为Base包,防止与数据后台小版本更新发生冲突)
|
||||
* 社区增加版主功能(版主可以对存在的相关内容进行修改/隐藏操作,内容包括问题/回答/回答评论)
|
||||
* 社区互动引导优化(问答推荐增加`推荐关注`,回答详情增加一些交互动效)
|
||||
* 社区互动引导优化(问答推荐增加`推荐关注`,回答详情增加一些交互动效)
|
||||
|
||||
### Ver 3.6.1
|
||||
* 可以后台控制关闭资讯功能
|
||||
* 版块、分类、专题详情、游戏详情、礼包详情增加预览骨架
|
||||
* 下载按钮状态可以通过接口屏蔽相应的包
|
||||
@ -1,7 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="user-scalable=no">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<link rel="stylesheet" type="text/css" href="normalize.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
|
||||
@ -75,7 +75,7 @@ public class AppUncaughtHandler implements UncaughtExceptionHandler {
|
||||
// 保存log到本地
|
||||
public static void saveLocalLog(Context context, Throwable ex) {
|
||||
String errorMsg = Log.getStackTraceString(ex);
|
||||
Config.setExceptionMsg(context, errorMsg);
|
||||
Config.setExceptionMsg(errorMsg);
|
||||
|
||||
// 保存到本地
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.getDefault());
|
||||
|
||||
@ -101,6 +101,12 @@ public abstract class BaseToolBarActivity extends BaseAppCompatActivity implemen
|
||||
return mToolbar.getMenu().findItem(res);
|
||||
}
|
||||
|
||||
public void clearMenu() {
|
||||
if (mToolbar != null) {
|
||||
mToolbar.getMenu().clear();
|
||||
}
|
||||
}
|
||||
|
||||
public Menu getMenu() {
|
||||
return mToolbar.getMenu();
|
||||
}
|
||||
|
||||
@ -15,9 +15,8 @@ import android.view.View
|
||||
import com.gh.common.notifier.Notifier
|
||||
import com.gh.common.util.DataUtils
|
||||
import com.gh.common.util.EntranceUtils
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.common.util.StringUtils
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.common.util.toObject
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.PushEntity
|
||||
import com.gh.gamecenter.entity.PushMessageEntity
|
||||
@ -32,7 +31,6 @@ import com.gh.gamecenter.receiver.UmengMessageReceiver.Companion.TYPE_REMOVE
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.google.gson.Gson
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.umeng.message.UmengMessageService
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
@ -48,22 +46,16 @@ class GHUmengNotificationService : UmengMessageService() {
|
||||
|
||||
companion object {
|
||||
const val ACTION_UMENG = "com.gh.gamecenter.UMENG"
|
||||
|
||||
const val MESSAGE_FROM_SYSTEM = "message_from_system"
|
||||
|
||||
const val HALO_MESSAGE_DIALOG = "HALO_MESSAGE_DIALOG"
|
||||
|
||||
const val HALO_MESSAGE_CENTER = "HALO_MESSAGE_CENTER"
|
||||
|
||||
const val ANSWER = "answer"
|
||||
|
||||
const val FOLLOW_QUESTION = "follow_question"
|
||||
|
||||
const val NOTIFICATION_ID = 2015
|
||||
|
||||
const val DISPLAY_TYPE_NOTIFICATION = "notification"
|
||||
|
||||
const val DISPLAY_TYPE_CUSTOM = "custom"
|
||||
const val MESSAGE_ID = "message_id"
|
||||
const val PUSH_ID = "push_id"
|
||||
}
|
||||
|
||||
val notificationTags = arrayOf("GH_UMENG_TAG_1", "GH_UMENG_TAG_2", "GH_UMENG_TAG_3")
|
||||
@ -74,7 +66,7 @@ class GHUmengNotificationService : UmengMessageService() {
|
||||
val isMessageFromSystem = intent.getBooleanExtra(MESSAGE_FROM_SYSTEM, false)
|
||||
|
||||
try {
|
||||
val pushData = gson.fromJson(message, PushEntity::class.java)
|
||||
val pushData = message.toObject<PushEntity>()
|
||||
pushData?.let { handlePushData(context, it, message, isMessageFromSystem) }
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
@ -87,10 +79,10 @@ class GHUmengNotificationService : UmengMessageService() {
|
||||
if (pushData.displayType == DISPLAY_TYPE_NOTIFICATION) {
|
||||
// 其它类型的透传信息
|
||||
// 显示到通知栏
|
||||
val msg = gson.fromJson(message, PushNotificationEntity::class.java)
|
||||
val msg = message.toObject<PushNotificationEntity>()
|
||||
val data = msg?.extra?.data
|
||||
|
||||
// 系统推送,直接处理跳转
|
||||
// 系统推送(非自定义信息),直接处理跳转
|
||||
if (isMessageFromSystem) {
|
||||
val intent = Intent()
|
||||
intent.setClass(context, UmengMessageReceiver::class.java)
|
||||
@ -101,43 +93,49 @@ class GHUmengNotificationService : UmengMessageService() {
|
||||
return
|
||||
}
|
||||
|
||||
// 判断是否过滤该消息
|
||||
if (validatePush(data?.condition)) {
|
||||
val clickIntent = Intent()
|
||||
val removeIntent = Intent()
|
||||
|
||||
clickIntent.setClass(context, UmengMessageReceiver::class.java)
|
||||
clickIntent.putExtra(EntranceUtils.KEY_DATA, data?.link)
|
||||
clickIntent.putExtra(EntranceUtils.KEY_MESSAGE, message)
|
||||
clickIntent.putExtra(EntranceUtils.KEY_TYPE, TYPE_CLICK)
|
||||
|
||||
removeIntent.setClass(context, UmengMessageReceiver::class.java)
|
||||
removeIntent.putExtra(EntranceUtils.KEY_TYPE, TYPE_REMOVE)
|
||||
removeIntent.putExtra(EntranceUtils.KEY_MESSAGE, message)
|
||||
|
||||
val clickPendingIntent = PendingIntent.getBroadcast(context, System.currentTimeMillis().toInt(),
|
||||
clickIntent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
|
||||
val deletePendingIntent = PendingIntent.getBroadcast(context, System.currentTimeMillis().toInt() + 1,
|
||||
removeIntent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val channel = NotificationChannel("Halo_Push", "Halo_Push", NotificationManager.IMPORTANCE_DEFAULT)
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
|
||||
val notification = NotificationCompat.Builder(context, "Halo_Push")
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
.setTicker(pushData.body?.ticker)
|
||||
.setContentTitle(pushData.body?.title)
|
||||
.setContentText(pushData.body?.text)
|
||||
.setContentIntent(clickPendingIntent)
|
||||
.setDeleteIntent(deletePendingIntent)
|
||||
.build()
|
||||
notification.flags = notification.flags or Notification.FLAG_AUTO_CANCEL
|
||||
|
||||
notificationManager.notify(getNotificationTag(context), NOTIFICATION_ID, notification)
|
||||
// 用户未登录的情况下不生成消息中心通知,避免用户掉登录了还收到跳转至消息中心的通知
|
||||
if (data != null
|
||||
&& data.link?.target == "system"
|
||||
&& !UserManager.getInstance().isLoggedIn) {
|
||||
return
|
||||
}
|
||||
|
||||
val clickIntent = Intent()
|
||||
val removeIntent = Intent()
|
||||
|
||||
clickIntent.setClass(context, UmengMessageReceiver::class.java)
|
||||
clickIntent.putExtra(EntranceUtils.KEY_DATA, data?.link)
|
||||
clickIntent.putExtra(EntranceUtils.KEY_MESSAGE, message)
|
||||
clickIntent.putExtra(MESSAGE_ID, msg?.msgId)
|
||||
clickIntent.putExtra(PUSH_ID, data?.pushId)
|
||||
clickIntent.putExtra(EntranceUtils.KEY_TYPE, TYPE_CLICK)
|
||||
|
||||
removeIntent.setClass(context, UmengMessageReceiver::class.java)
|
||||
removeIntent.putExtra(EntranceUtils.KEY_TYPE, TYPE_REMOVE)
|
||||
removeIntent.putExtra(EntranceUtils.KEY_MESSAGE, message)
|
||||
|
||||
val clickPendingIntent = PendingIntent.getBroadcast(context, System.currentTimeMillis().toInt(),
|
||||
clickIntent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
|
||||
val deletePendingIntent = PendingIntent.getBroadcast(context, System.currentTimeMillis().toInt() + 1,
|
||||
removeIntent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val channel = NotificationChannel("Halo_Push", "Halo_Push", NotificationManager.IMPORTANCE_DEFAULT)
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
|
||||
val notification = NotificationCompat.Builder(context, "Halo_Push")
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
.setTicker(pushData.body?.ticker)
|
||||
.setContentTitle(pushData.body?.title)
|
||||
.setContentText(pushData.body?.text)
|
||||
.setContentIntent(clickPendingIntent)
|
||||
.setDeleteIntent(deletePendingIntent)
|
||||
.build()
|
||||
notification.flags = notification.flags or Notification.FLAG_AUTO_CANCEL
|
||||
|
||||
notificationManager.notify(getNotificationTag(context), NOTIFICATION_ID, notification)
|
||||
} else {
|
||||
if (HALO_MESSAGE_DIALOG == pushData.body?.custom) {
|
||||
// 回答了问题或者关注了问题的消息
|
||||
@ -201,37 +199,6 @@ class GHUmengNotificationService : UmengMessageService() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun validatePush(condition: PushNotificationEntity.Data.Condition?): Boolean {
|
||||
if (condition == null) return true
|
||||
|
||||
// 校验渠道是否匹配
|
||||
condition.ghzs?.channel?.let {
|
||||
if (it.isNotEmpty() && it != HaloApp.getInstance().channel) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 校验光环版本版本是否匹配
|
||||
condition.ghzs?.version?.let {
|
||||
if (it.isNotEmpty() && !BuildConfig.VERSION_NAME.contains(it)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 校验已安装的应用里是否存在条件的包名
|
||||
if (condition.packageName.isNotEmpty()) {
|
||||
val installedPackageList = PackageUtils.getAllPackageName(HaloApp.getInstance().application)
|
||||
for (packageName in installedPackageList) {
|
||||
if (condition.packageName == packageName) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 规则:最多三条消息,以旧换新
|
||||
*
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.common
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.preference.PreferenceManager
|
||||
import com.gh.base.GHUmengNotificationService
|
||||
import com.gh.common.constant.Config
|
||||
@ -77,6 +78,7 @@ object PushManager {
|
||||
})
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@JvmStatic
|
||||
fun getAndSetAlias() {
|
||||
if (deviceToken.isNullOrEmpty()) {
|
||||
|
||||
@ -13,6 +13,8 @@ import java.util.concurrent.Executors
|
||||
*/
|
||||
class TimeElapsedHelper(val fragment: Fragment?, val activity: Activity?) {
|
||||
|
||||
constructor() : this(null, null)
|
||||
|
||||
constructor(fragment: Fragment) : this(fragment, null)
|
||||
|
||||
constructor(activity: Activity) : this(null, activity)
|
||||
@ -79,7 +81,7 @@ class TimeElapsedHelper(val fragment: Fragment?, val activity: Activity?) {
|
||||
}, false)
|
||||
}
|
||||
|
||||
private fun resumeCounting() {
|
||||
fun resumeCounting() {
|
||||
isWorking = true
|
||||
TimeElapsedThreadHolder.threadService.execute {
|
||||
while (isWorking) {
|
||||
@ -100,7 +102,7 @@ class TimeElapsedHelper(val fragment: Fragment?, val activity: Activity?) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun pauseCounting() {
|
||||
fun pauseCounting() {
|
||||
isWorking = false
|
||||
}
|
||||
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
package com.gh.common.constant;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.common.util.GsonUtils;
|
||||
import com.gh.common.util.PackageHelper;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.entity.NewsEntity;
|
||||
import com.gh.gamecenter.entity.SettingsEntity;
|
||||
@ -50,9 +51,14 @@ public class Config {
|
||||
|
||||
private static SettingsEntity mSettingsEntity;
|
||||
|
||||
public static final String FIX_DOWNLOAD_KEY = "isFixDownload";
|
||||
public static final String FIX_PLUGIN_KEY = "isFixPlugin";
|
||||
public static final String FIX_ARTICLE_KEY = "isFixArticle";
|
||||
public static final String FIX_COMMUNITY_KEY = "isFixCommunity";
|
||||
|
||||
|
||||
public static boolean isShow() {
|
||||
if (PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication())
|
||||
.getBoolean("isFixDownload", false)) return true;
|
||||
if (getPreferences().getBoolean(FIX_DOWNLOAD_KEY, false)) return true;
|
||||
|
||||
if (!isExistDownloadFilter()) return false;
|
||||
|
||||
@ -63,23 +69,20 @@ public class Config {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getExceptionMsg(Context context) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return sp.getString("errMsg", null);
|
||||
public static String getExceptionMsg() {
|
||||
return getPreferences().getString("errMsg", null);
|
||||
}
|
||||
|
||||
public static void setExceptionMsg(Context context, String errMsg) {
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit().putString("errMsg", errMsg).apply();
|
||||
public static void setExceptionMsg(String errMsg) {
|
||||
getPreferences().edit().putString("errMsg", errMsg).apply();
|
||||
}
|
||||
|
||||
public static boolean isShowDownload(String gameId) {
|
||||
|
||||
if (PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication())
|
||||
.getBoolean("isFixDownload", false)) return true;
|
||||
if (getPreferences().getBoolean(FIX_DOWNLOAD_KEY, false)) return true;
|
||||
|
||||
if (TextUtils.isEmpty(gameId) || !isExistDownloadFilter())
|
||||
return false;
|
||||
@ -113,8 +116,15 @@ public class Config {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if ("all".equals(entity.getGame())) {
|
||||
}
|
||||
|
||||
SharedPreferences preferences = getPreferences();
|
||||
boolean isFixPlugin = preferences.getBoolean(FIX_PLUGIN_KEY, false);
|
||||
if (isFixPlugin) return true;
|
||||
|
||||
if ("all".equals(entity.getGame())) {
|
||||
if (entity.getPluginfy() && filterTime(entity.getTime())) {
|
||||
preferences.edit().putBoolean(FIX_PLUGIN_KEY, true).apply();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -151,19 +161,20 @@ public class Config {
|
||||
}
|
||||
|
||||
public static void setSettings(SettingsEntity settingsEntity) {
|
||||
SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication()).edit();
|
||||
edit.putString(SETTINGS_KEY, GsonUtils.getInstance().toJson(settingsEntity)).apply();
|
||||
|
||||
getPreferences().edit().putString(SETTINGS_KEY, GsonUtils.toJson(settingsEntity)).apply();
|
||||
mSettingsEntity = settingsEntity;
|
||||
|
||||
// 加载完设置后刷新下
|
||||
PackageHelper.initList();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static SettingsEntity getSettings() {
|
||||
if (mSettingsEntity == null) {
|
||||
try {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication());
|
||||
String json = sp.getString(SETTINGS_KEY, null);
|
||||
String json = getPreferences().getString(SETTINGS_KEY, null);
|
||||
if (!TextUtils.isEmpty(json)) {
|
||||
mSettingsEntity = GsonUtils.getInstance().fromJsonBean(json, SettingsEntity.class);
|
||||
mSettingsEntity = GsonUtils.fromJson(json, SettingsEntity.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -193,4 +204,27 @@ public class Config {
|
||||
}
|
||||
}
|
||||
|
||||
public static SharedPreferences getPreferences() {
|
||||
return PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication());
|
||||
}
|
||||
|
||||
public static boolean isExistHideFunction() {
|
||||
SharedPreferences preferences = getPreferences();
|
||||
if (!preferences.getBoolean(FIX_DOWNLOAD_KEY, false)) return true;
|
||||
if (!preferences.getBoolean(FIX_PLUGIN_KEY, false)) return true;
|
||||
if (!preferences.getBoolean(FIX_COMMUNITY_KEY, false)) return true;
|
||||
if (!preferences.getBoolean(FIX_ARTICLE_KEY, false)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void fixHideFunction() {
|
||||
SharedPreferences preferences = PreferenceManager.
|
||||
getDefaultSharedPreferences(HaloApp.getInstance().getApplication());
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean(Config.FIX_DOWNLOAD_KEY, true);
|
||||
editor.putBoolean(Config.FIX_ARTICLE_KEY, true);
|
||||
editor.putBoolean(Config.FIX_COMMUNITY_KEY, true);
|
||||
editor.putBoolean(Config.FIX_PLUGIN_KEY, true);
|
||||
editor.apply();
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,27 +11,27 @@ class ExposureConverters {
|
||||
|
||||
@TypeConverter
|
||||
fun convertPayload2String(any: ExposureEntity): String {
|
||||
return GsonUtils.getInstance().mGson.toJson(any)
|
||||
return GsonUtils.toJson(any)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertString2Payload(string: String): ExposureEntity {
|
||||
return GsonUtils.getInstance().mGson.fromJson(string, ExposureEntity::class.java)
|
||||
return GsonUtils.fromJson(string, ExposureEntity::class.java)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertSource2String(sourceList: List<ExposureSource>): String {
|
||||
return GsonUtils.getInstance().mGson.toJson(sourceList)
|
||||
return GsonUtils.toJson(sourceList)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertString2Source(sourceList: String): List<ExposureSource> {
|
||||
return ArrayList(Arrays.asList(GsonUtils.getInstance().mGson.fromJson(sourceList, Array<ExposureSource>::class.java))) as List<ExposureSource>
|
||||
return ArrayList(Arrays.asList(GsonUtils.fromJson(sourceList, Array<ExposureSource>::class.java))) as List<ExposureSource>
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertETrace2String(sourceList: List<ExposureEvent>?): String {
|
||||
return GsonUtils.getInstance().mGson.toJson(sourceList)
|
||||
return GsonUtils.toJson(sourceList)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
@ -51,12 +51,12 @@ class ExposureConverters {
|
||||
|
||||
@TypeConverter
|
||||
fun convertMeta2String(any: Meta): String {
|
||||
return GsonUtils.getInstance().mGson.toJson(any)
|
||||
return GsonUtils.toJson(any)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertString2Meta(string: String): Meta {
|
||||
return GsonUtils.getInstance().mGson.fromJson(string, Meta::class.java)
|
||||
return GsonUtils.fromJson(string, Meta::class.java)
|
||||
}
|
||||
|
||||
}
|
||||
@ -15,7 +15,7 @@ import java.util.*
|
||||
@Parcelize
|
||||
@Entity(tableName = "exposureEvent")
|
||||
data class ExposureEvent(
|
||||
val payload: ExposureEntity,
|
||||
var payload: ExposureEntity,
|
||||
val source: List<ExposureSource>,
|
||||
var eTrace: List<ExposureEvent>? = arrayListOf(),
|
||||
val event: ExposureType,
|
||||
@ -26,7 +26,7 @@ data class ExposureEvent(
|
||||
companion object {
|
||||
fun createEvent(gameEntity: GameEntity?, source: List<ExposureSource>, eTrace: List<ExposureEvent>?, event: ExposureType): ExposureEvent {
|
||||
return ExposureEvent(
|
||||
ExposureEntity(gameId = gameEntity?.id,
|
||||
payload = ExposureEntity(gameId = gameEntity?.id,
|
||||
gameName = gameEntity?.name,
|
||||
sequence = gameEntity?.sequence,
|
||||
platform = gameEntity?.platform,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import com.gh.common.util.fromObject
|
||||
import com.gh.common.util.toObject
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import java.util.*
|
||||
|
||||
@ -30,7 +30,7 @@ object ExposureUtils {
|
||||
val gameEntity = entity.clone()
|
||||
gameEntity.platform = platform
|
||||
gameEntity.downloadCompleteType = downloadType.toString()
|
||||
val traceEvent = trace?.fromObject<ExposureEvent>()
|
||||
val traceEvent = trace?.toObject<ExposureEvent>()
|
||||
val exposureEvent = ExposureEvent.createEvent(gameEntity = gameEntity,
|
||||
source = traceEvent?.source ?: ArrayList(),
|
||||
eTrace = ExposureTraceUtils.appendTrace(traceEvent),
|
||||
|
||||
@ -5,16 +5,19 @@ import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import com.gh.base.CurrentActivityHolder
|
||||
import com.gh.common.util.SPUtils
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.MessageActivity
|
||||
import com.gh.gamecenter.SuggestSelectActivity
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.m7.imkfsdk.KfStartHelper
|
||||
import com.m7.imkfsdk.utils.Utils
|
||||
import com.moor.imkf.ChatListener
|
||||
import com.moor.imkf.IMChat
|
||||
import com.moor.imkf.IMChatManager
|
||||
import com.moor.imkf.IMMessage
|
||||
import com.moor.imkf.utils.MoorUtils
|
||||
|
||||
object ImManager {
|
||||
|
||||
@ -25,10 +28,17 @@ object ImManager {
|
||||
var shouldShowFloatingWindow = false
|
||||
var shouldShowFloatingWindowDot = false
|
||||
|
||||
// 记录当前用户 ID 避免重复初始化
|
||||
var currentUserId = ""
|
||||
|
||||
@JvmStatic
|
||||
fun attachIm() {
|
||||
try {
|
||||
if (UserManager.getInstance().userInfoEntity != null) {
|
||||
if (UserManager.getInstance().userInfoEntity != null &&
|
||||
currentUserId != UserManager.getInstance().userId) {
|
||||
currentUserId = UserManager.getInstance().userId
|
||||
MoorUtils.init(HaloApp.getInstance().application)
|
||||
Utils.init(HaloApp.getInstance().application)
|
||||
IMChatManager.getInstance().init(
|
||||
HaloApp.getInstance().application,
|
||||
ImReceiver.UNIQUE_BROADCAST_ACTION,
|
||||
@ -67,7 +77,8 @@ object ImManager {
|
||||
chatHelper.initSdkChat(
|
||||
ImReceiver.UNIQUE_BROADCAST_ACTION,
|
||||
IM_KEY,
|
||||
UserManager.getInstance().userInfoEntity.name + "(" + UserManager.getInstance().userId + ")",
|
||||
UserManager.getInstance().userInfoEntity.name + "(" + UserManager.getInstance().userId + ")"
|
||||
+ "[" + BuildConfig.VERSION_NAME + "]",
|
||||
UserManager.getInstance().userId)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
|
||||
@ -12,8 +12,8 @@ import android.support.v4.app.NotificationCompat
|
||||
import com.gh.base.CurrentActivityHolder
|
||||
import com.gh.gamecenter.R
|
||||
import com.m7.imkfsdk.chat.ChatActivity
|
||||
import com.m7.imkfsdk.utils.Utils
|
||||
import com.moor.imkf.IMChatManager
|
||||
import com.moor.imkf.utils.Utils
|
||||
|
||||
class ImReceiver : BroadcastReceiver() {
|
||||
|
||||
|
||||
@ -28,6 +28,8 @@ object RemenkapaiRepository {
|
||||
* 选择随机数量的热门卡牌
|
||||
*/
|
||||
private fun pickRandomSizeEntity(size: Int): List<GameEntity> {
|
||||
if (size > remenkapaiList.size) return remenkapaiList
|
||||
|
||||
val randomGameList = arrayListOf<GameEntity>()
|
||||
val randomArray = RandomUtils.getRandomArray(size, remenkapaiList.size)
|
||||
for (i in randomArray) {
|
||||
|
||||
@ -15,14 +15,16 @@ import com.lightgame.utils.Utils;
|
||||
public class CheckLoginUtils {
|
||||
|
||||
public static void checkLogin(final Context context, String entrance, OnLoginListener listener) {
|
||||
if (TextUtils.isEmpty(UserManager.getInstance().getToken())) {
|
||||
if (!isLogin()) {
|
||||
if (listener != null) Utils.toast(context, "需要登录");
|
||||
LogUtils.login("dialog", null, entrance);
|
||||
LogUtils.login("activity", null, entrance);
|
||||
Intent intent = LoginActivity.getIntent(context, entrance);
|
||||
context.startActivity(intent);
|
||||
} else {
|
||||
listener.onLogin();
|
||||
if (listener != null) {
|
||||
listener.onLogin();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import com.gh.gamecenter.eventbus.EBConcernChanged
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
@ -20,9 +21,14 @@ import retrofit2.HttpException
|
||||
*/
|
||||
object ConcernUtils {
|
||||
|
||||
fun postConcernGameId(context: Context, gameId: String, listener: onConcernListener?) {
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
.postConcern(UserManager.getInstance().userId, gameId)
|
||||
fun postConcernGameId(context: Context, gameId: String, listener: onConcernListener?, autoConcern: Boolean = false) {
|
||||
val mode = if (autoConcern) "auto" else "manual"
|
||||
|
||||
val userId = UserManager.getInstance().userId
|
||||
if (TextUtils.isEmpty(userId)) return
|
||||
|
||||
RetrofitManager.getInstance(context).api
|
||||
.postConcern(UserManager.getInstance().userId, gameId, mode)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
@ -40,7 +46,7 @@ object ConcernUtils {
|
||||
}
|
||||
|
||||
fun deleteConcernData(context: Context, gameId: String, listener: onConcernListener?) {
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
RetrofitManager.getInstance(context).api
|
||||
.deleteConcern(UserManager.getInstance().userId, gameId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -61,7 +67,7 @@ object ConcernUtils {
|
||||
fun updateConcernData(context: Context, data: JSONArray) {
|
||||
val body = RequestBody.create(MediaType.parse("application/json"),
|
||||
data.toString())
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
RetrofitManager.getInstance(context).api
|
||||
.putConcern(UserManager.getInstance().userId, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
@ -73,7 +79,7 @@ object ConcernUtils {
|
||||
}
|
||||
|
||||
fun deleteConcernQuestions(context: Context, questionsId: String, listener: onConcernListener?) {
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
RetrofitManager.getInstance(context).api
|
||||
.deleteConcernQuestions(UserManager.getInstance().userId, questionsId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -92,7 +98,7 @@ object ConcernUtils {
|
||||
}
|
||||
|
||||
fun postConcernQuestions(context: Context, questionsId: String, listener: onConcernListener?) {
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
RetrofitManager.getInstance(context).api
|
||||
.postConcernQuestions(UserManager.getInstance().userId, questionsId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
@ -128,6 +128,20 @@ public class DeviceUtils {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static String getUserAgent() {
|
||||
String userAgent = "";
|
||||
userAgent = System.getProperty("http.agent");
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0, length = userAgent.length(); i < length; i++) {
|
||||
char c = userAgent.charAt(i);
|
||||
if (c <= '\u001f' || c >= '\u007f') {
|
||||
sb.append(String.format("\\u%04x", (int) c));
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String getIPAddress(Context context) {
|
||||
NetworkInfo info = ((ConnectivityManager) context
|
||||
|
||||
@ -69,7 +69,7 @@ public class DownloadItemUtils {
|
||||
// adapter.notifyItemChanged(index);
|
||||
// }
|
||||
} else {
|
||||
if (!queue.contains(platform)) {
|
||||
if (!queue.contains(platform) && !TextUtils.isEmpty(platform)) {
|
||||
queue.offer(platform);
|
||||
if (AppDebugConfig.IS_DEBUG) {
|
||||
AppDebugConfig.logMethodWithParams(DownloadItemUtils.class, queue.size(), gameEntity.getBrief(), downloadEntity.getPlatform(), index);
|
||||
@ -159,6 +159,7 @@ public class DownloadItemUtils {
|
||||
// 更新插件的条目,有多个apk包
|
||||
private static void updatePluginItem(Context context, GameViewHolder holder, GameEntity gameEntity,
|
||||
boolean isShowPlatform, PluginLocation pluginLocation) {
|
||||
GameUtils.setDownloadBtnStatus(context, gameEntity, holder.gameDownloadBtn, pluginLocation);
|
||||
|
||||
ArrayMap<String, DownloadEntity> entryMap = gameEntity.getEntryMap();
|
||||
if (entryMap != null && !entryMap.isEmpty()) {
|
||||
@ -177,8 +178,6 @@ public class DownloadItemUtils {
|
||||
}
|
||||
}
|
||||
|
||||
GameUtils.setDownloadBtnStatus(context, gameEntity, holder.gameDownloadBtn, pluginLocation);
|
||||
|
||||
holder.gameDes.setVisibility(View.VISIBLE);
|
||||
holder.gameProgressbar.setVisibility(View.GONE);
|
||||
holder.gameInfo.setVisibility(View.GONE);
|
||||
|
||||
@ -111,6 +111,7 @@ public class EntranceUtils {
|
||||
public static final String KEY_RATING_STAR_COUNT = "ratingStarCount";
|
||||
public static final String KEY_QUESTION_MODERATOR_PATCH = "questionModeratorPatch";
|
||||
public static final String KEY_SKIP_GAME_COMMENT = "skipGameComment";
|
||||
public static final String KEY_OPEN_PLATFORM_WINDOW = "openPlatformWindow";
|
||||
|
||||
public static void jumpActivity(Context context, Bundle bundle) {
|
||||
|
||||
|
||||
@ -28,8 +28,8 @@ object ErrorHelper {
|
||||
/**
|
||||
* [important] 用来标识有同样错误码可以触发两种处理时,为 true 时选择重要的
|
||||
*/
|
||||
fun handleError(context: Context, errorString: String?, important: Boolean? = false) {
|
||||
val errorEntity = errorString?.fromObject<ErrorEntity>()
|
||||
fun handleError(context: Context, errorString: String?, important: Boolean = false) {
|
||||
val errorEntity = errorString?.toObject<ErrorEntity>()
|
||||
|
||||
if (errorEntity == null) {
|
||||
Utils.toast(context, R.string.post_failure_hint)
|
||||
|
||||
@ -5,6 +5,8 @@ import android.content.Context
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.app.FragmentActivity
|
||||
import android.support.v4.view.ViewPager
|
||||
import android.view.View
|
||||
import com.google.gson.reflect.TypeToken
|
||||
|
||||
/**
|
||||
* 创建以 activity 为观察者上下文的 viewModel
|
||||
@ -72,9 +74,9 @@ fun Context.ifLogin(entrance: String, action: (() -> Unit)? = null) {
|
||||
/**
|
||||
* Gson related extensions.
|
||||
*/
|
||||
inline fun <reified T : Any> String.fromObject(): T? {
|
||||
inline fun <reified T : Any> String.toObject(): T? {
|
||||
return try {
|
||||
GsonUtils.getInstance().mGson.fromJson(this, T::class.java)
|
||||
GsonUtils.gson.fromJson(this, object : TypeToken<T>() {}.type)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
null
|
||||
@ -82,7 +84,7 @@ inline fun <reified T : Any> String.fromObject(): T? {
|
||||
}
|
||||
|
||||
inline fun <reified T : Any> T.toJson(): String {
|
||||
return GsonUtils.getInstance().mGson.toJson(this)
|
||||
return GsonUtils.toJson(this)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,4 +94,8 @@ fun fastDoubleClickAction(id: Int, interval: Long = 300, action: (() -> Unit)? =
|
||||
if (ClickUtils.isFastDoubleClick(id, interval)) {
|
||||
action?.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
fun View.fastDoubleClickAction(interval: Long, action: (() -> Unit)? = null) {
|
||||
fastDoubleClickAction(id, interval, action)
|
||||
}
|
||||
113
app/src/main/java/com/gh/common/util/GameRepositoryHelper.kt
Normal file
113
app/src/main/java/com/gh/common/util/GameRepositoryHelper.kt
Normal file
@ -0,0 +1,113 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.SubjectEntity
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
/**
|
||||
* 首页补充游戏库辅助类
|
||||
*/
|
||||
object GameRepositoryHelper {
|
||||
|
||||
private const val KEY_GAME_REPOSITORY = "game_repository"
|
||||
|
||||
// TODO 会有多线程操作问题(在此列表获取补充游戏数据时进行下拉刷新修改此列表)
|
||||
var gameCollectionList: List<SubjectEntity> = arrayListOf()
|
||||
|
||||
init {
|
||||
loadSavedRepository()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取游戏补充库
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getGameRepository(context: Context) {
|
||||
|
||||
// Test only
|
||||
// RetrofitManager.getInstance(context)
|
||||
// .api
|
||||
// .remenkapai
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .subscribe(object : Response<List<GameEntity>>() {
|
||||
// override fun onResponse(response: List<GameEntity>?) {
|
||||
// val subjectEntityList = arrayListOf<SubjectEntity>()
|
||||
// val subjectEntity = SubjectEntity(id = "5ac46cca2924bc2870438d28")
|
||||
// subjectEntity.data = ArrayList(response)
|
||||
// subjectEntityList.add(subjectEntity)
|
||||
// updateGameRepository(subjectEntityList)
|
||||
// }
|
||||
// })
|
||||
|
||||
|
||||
RetrofitManager.getInstance(context)
|
||||
.api
|
||||
.reserveColumns
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<List<SubjectEntity>>() {
|
||||
override fun onResponse(response: List<SubjectEntity>?) {
|
||||
super.onResponse(response)
|
||||
|
||||
updateGameRepository(response)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新内存中的游戏库(即从 SP 中再读一次)
|
||||
*/
|
||||
@JvmStatic
|
||||
fun refreshGameRepository() = loadSavedRepository()
|
||||
|
||||
private fun loadSavedRepository() {
|
||||
gameCollectionList = SPUtils.getString(KEY_GAME_REPOSITORY).toObject() ?: arrayListOf()
|
||||
}
|
||||
|
||||
fun updateGameRepository(subjects: List<SubjectEntity>?) {
|
||||
|
||||
if (subjects == null) return
|
||||
|
||||
SPUtils.setString(KEY_GAME_REPOSITORY, subjects.toJson())
|
||||
|
||||
gameCollectionList = subjects
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 从补充游戏库相应的专题中取出一个与其它游戏都不相同的游戏,为空时即为游戏用完或不存在该相应专题
|
||||
* @param collectionId 补充游戏库相应专题 ID
|
||||
* @param gameIdList 该专题里已经包含的游戏 ID 列表
|
||||
*/
|
||||
fun getOneUniqueGame(collectionId: String?, gameIdList: List<String>): GameEntity? {
|
||||
collectionId?.let {
|
||||
val collection = gameCollectionList.find { it.id == collectionId }
|
||||
// Test only
|
||||
// val collection = gameCollectionList.find { it.id == "5ac46cca2924bc2870438d28" }
|
||||
|
||||
collection?.let {
|
||||
val game = collection.data?.find { game -> findUniqueGame(game, gameIdList) }
|
||||
game?.let {
|
||||
collection.data?.remove(game)
|
||||
return game
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private fun findUniqueGame(game: GameEntity, gameIdList: List<String>): Boolean {
|
||||
for (apk in game.getApk()) {
|
||||
// 检查本地是否已安装该游戏,已过滤那部分框架服务的包名
|
||||
if (PackageHelper.validLocalPackageNameSet.contains(apk.packageName)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return !gameIdList.contains(game.id) && !TextUtils.isEmpty(game.id)
|
||||
}
|
||||
|
||||
}
|
||||
@ -6,13 +6,14 @@ import android.support.v4.content.ContextCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameCollectionEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity;
|
||||
import com.gh.gamecenter.entity.PluginLocation;
|
||||
import com.gh.gamecenter.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.download.DownloadStatus;
|
||||
@ -71,15 +72,18 @@ public class GameUtils {
|
||||
int installCount = 0; // 已安装数量
|
||||
DownloadEntity downloadEntity;
|
||||
Object gh_id;
|
||||
apkFor:
|
||||
for (ApkEntity apkEntity : gameEntity.getApk()) {
|
||||
|
||||
// 去除下载合集判断
|
||||
boolean isCollection = false;
|
||||
for (GameCollectionEntity collectionEntity : gameEntity.getCollection()) {
|
||||
if (collectionEntity.getPackage().contains(apkEntity.getPackageName()))
|
||||
isCollection = true;
|
||||
// filter by packageName
|
||||
SettingsEntity settings = Config.getSettings();
|
||||
if (settings != null && gameEntity.getApk().size() > 1) {
|
||||
for (String pkgName : settings.getGameDownloadBlackList()) {
|
||||
if (pkgName.equals(apkEntity.getPackageName())) {
|
||||
continue apkFor;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isCollection) continue;
|
||||
|
||||
downloadEntity = DownloadManager.getInstance(context).getDownloadEntityByUrl(apkEntity.getUrl());
|
||||
if (downloadEntity != null) {
|
||||
|
||||
@ -21,7 +21,7 @@ object GdtHelper {
|
||||
const val PLATFORM = "PLATFORM"
|
||||
|
||||
fun init(application: Application) {
|
||||
GDTAction.init(application, "1107958753", "dff25cc0dcb4a3b9f881a5fd7eec7e8a")
|
||||
GDTAction.init(application, "1108222478", "0b2bb2b971c8221be45a8454f05a0b1f")
|
||||
}
|
||||
|
||||
fun logAction(type: String) {
|
||||
|
||||
@ -56,7 +56,7 @@ public class GetLoginDataUtils {
|
||||
+ "follow_app_official_microblog," + "invitation_write"; // weiboCode
|
||||
|
||||
private GetLoginDataUtils(Context context) {
|
||||
mContext = context.getApplicationContext();
|
||||
mContext = context;
|
||||
mTencent = Tencent.createInstance(Config.TENCENT_APPID, mContext); //初始化QQ分享
|
||||
|
||||
mIWXAPI = WXAPIFactory.createWXAPI(mContext, Config.WECHAT_APPID, true); //初始化微信分享
|
||||
@ -68,7 +68,7 @@ public class GetLoginDataUtils {
|
||||
|
||||
public static GetLoginDataUtils getInstance(Context context) {
|
||||
if (instance == null) {
|
||||
instance = new GetLoginDataUtils(context);
|
||||
instance = new GetLoginDataUtils(context.getApplicationContext());
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
@ -172,7 +172,7 @@ public class GetLoginDataUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public void WCLofinCallBack(JSONObject content) {
|
||||
public void WCLoginCallBack(JSONObject content) {
|
||||
if (mLoginListener != null) {
|
||||
mLoginListener.OnLoginData(content, LoginTag.wechat);
|
||||
}
|
||||
|
||||
@ -1,36 +1,27 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
|
||||
|
||||
/**
|
||||
* Created by khy on 11/10/17.
|
||||
*/
|
||||
class GsonUtils private constructor() {
|
||||
val mGson: Gson = Gson()
|
||||
object GsonUtils {
|
||||
val gson: Gson = Gson()
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun getInstance(): GsonUtils {
|
||||
return Inner.anotherSingle
|
||||
}
|
||||
|
||||
private object Inner {
|
||||
val anotherSingle = GsonUtils()
|
||||
}
|
||||
@JvmStatic
|
||||
fun <T> fromJson(json: String, t: Class<T>): T {
|
||||
return gson.fromJson(json, t)
|
||||
}
|
||||
|
||||
fun <T> fromJsonBean(json: String, t: Class<T>): T {
|
||||
return mGson.fromJson(json, t)
|
||||
}
|
||||
// @JvmStatic
|
||||
// fun <T> fromJsonList(json: String): List<T> {
|
||||
// val type = object : TypeToken<List<T>>() {}.type
|
||||
// return gson.fromJson(json, type)
|
||||
// }
|
||||
|
||||
fun <T> fromJsonList(json: String, t: Class<T>): T {
|
||||
val type = object : TypeToken<List<T>>() {}.type
|
||||
return mGson.fromJson(json, type)
|
||||
}
|
||||
|
||||
fun toJson(any: Any): String {
|
||||
return mGson.toJson(any)
|
||||
@JvmStatic
|
||||
fun toJson(any: Any?): String {
|
||||
return gson.toJson(any)
|
||||
}
|
||||
}
|
||||
@ -231,12 +231,23 @@ object ImageUtils {
|
||||
*/
|
||||
@JvmStatic
|
||||
fun display(view: SimpleDraweeView?, url: String?) {
|
||||
val width = view?.layoutParams?.width
|
||||
if (width != null && width > 0) {
|
||||
view.setImageURI(getTransformLimitUrl(url, width, view.context))
|
||||
} else {
|
||||
view?.post {
|
||||
view.setImageURI(getTransformLimitUrl(url, view.width, view.context))
|
||||
url?.let {
|
||||
// 图片是以 gif 结尾的就
|
||||
if (it.endsWith(".gif")) {
|
||||
val controller = Fresco.newDraweeControllerBuilder()
|
||||
.setUri(url)
|
||||
.setAutoPlayAnimations(true)
|
||||
.build()
|
||||
view?.controller = controller
|
||||
} else {
|
||||
val width = view?.layoutParams?.width
|
||||
if (width != null && width > 0) {
|
||||
view.setImageURI(getTransformLimitUrl(url, width, view.context))
|
||||
} else {
|
||||
view?.post {
|
||||
view.setImageURI(getTransformLimitUrl(url, view.width, view.context))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,9 @@ import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.entity.CommunityEntity;
|
||||
import com.gh.gamecenter.entity.SpecialColumn;
|
||||
import com.gh.gamecenter.manager.UserManager;
|
||||
import com.gh.gamecenter.qa.entity.Questions;
|
||||
import com.gh.loghub.LogHubUtils;
|
||||
@ -22,8 +24,12 @@ import org.json.JSONObject;
|
||||
*/
|
||||
public class LogUtils {
|
||||
|
||||
public static void uploadCommunityArticle(String tracers, String articleId, String articleTitle,
|
||||
int readTime, CommunityEntity community) {
|
||||
public static void uploadCommunityArticle(String tracers,
|
||||
String articleId,
|
||||
String articleTitle,
|
||||
int readTime,
|
||||
CommunityEntity community,
|
||||
SpecialColumn specialColumn) {
|
||||
JSONObject object = new JSONObject();
|
||||
try {
|
||||
object.put("subject", "community_article");
|
||||
@ -33,6 +39,17 @@ public class LogUtils {
|
||||
object.put("article_name", articleTitle);
|
||||
object.put("tracers", tracers);
|
||||
object.put("read", readTime);
|
||||
JSONObject columnObject = new JSONObject();
|
||||
if (specialColumn != null) {
|
||||
columnObject.put("type", specialColumn.getType());
|
||||
columnObject.put("name", specialColumn.getName());
|
||||
columnObject.put("tab", specialColumn.getTab());
|
||||
} else {
|
||||
columnObject.put("type", "");
|
||||
columnObject.put("name", "");
|
||||
columnObject.put("tab", "");
|
||||
}
|
||||
object.put("special_column", columnObject);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -55,17 +72,34 @@ public class LogUtils {
|
||||
upload(object);
|
||||
}
|
||||
|
||||
public static void uploadAnswerReadTime(String tracers, int readTime, String answerId, Questions questions) {
|
||||
public static void uploadAnswerReadTime(String tracers,
|
||||
int readTime,
|
||||
String answerId,
|
||||
Questions questions,
|
||||
String communityId,
|
||||
String CommunityName,
|
||||
SpecialColumn specialColumn) {
|
||||
JSONObject object = new JSONObject();
|
||||
try {
|
||||
object.put("subject", "answer");
|
||||
object.put("community_id", UserManager.getInstance().getCommunity().getId());
|
||||
object.put("community_name", UserManager.getInstance().getCommunity().getName());
|
||||
object.put("community_id", communityId);
|
||||
object.put("community_name", CommunityName);
|
||||
object.put("question_id", questions.getId());
|
||||
object.put("question_name", questions.getTitle());
|
||||
object.put("tracers", tracers);
|
||||
object.put("answer_id", answerId);
|
||||
object.put("read", readTime);
|
||||
JSONObject columnObject = new JSONObject();
|
||||
if (specialColumn != null) {
|
||||
columnObject.put("type", specialColumn.getType());
|
||||
columnObject.put("name", specialColumn.getName());
|
||||
columnObject.put("tab", specialColumn.getTab());
|
||||
} else {
|
||||
columnObject.put("type", "");
|
||||
columnObject.put("name", "");
|
||||
columnObject.put("tab", "");
|
||||
}
|
||||
object.put("special_column", columnObject);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -73,16 +107,32 @@ public class LogUtils {
|
||||
upload(object);
|
||||
}
|
||||
|
||||
public static void uploadQuestionReadTime(String tracers, int readTime, Questions questions) {
|
||||
public static void uploadQuestionReadTime(String tracers,
|
||||
int readTime,
|
||||
Questions questions,
|
||||
String communityId,
|
||||
String communityName,
|
||||
SpecialColumn specialColumn) {
|
||||
JSONObject object = new JSONObject();
|
||||
try {
|
||||
object.put("subject", "question");
|
||||
object.put("community_id", UserManager.getInstance().getCommunity().getId());
|
||||
object.put("community_name", UserManager.getInstance().getCommunity().getName());
|
||||
object.put("community_id", communityId);
|
||||
object.put("community_name", communityName);
|
||||
object.put("question_id", questions.getId());
|
||||
object.put("question_name", questions.getTitle());
|
||||
object.put("tracers", tracers);
|
||||
object.put("read", readTime);
|
||||
JSONObject columnObject = new JSONObject();
|
||||
if (specialColumn != null) {
|
||||
columnObject.put("type", specialColumn.getType());
|
||||
columnObject.put("name", specialColumn.getName());
|
||||
columnObject.put("tab", specialColumn.getTab());
|
||||
} else {
|
||||
columnObject.put("type", "");
|
||||
columnObject.put("name", "");
|
||||
columnObject.put("tab", "");
|
||||
}
|
||||
object.put("special_column", columnObject);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -137,6 +187,10 @@ public class LogUtils {
|
||||
}
|
||||
|
||||
private static void upload(JSONObject object) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Utils.log("LogUtils->" + object.toString());
|
||||
}
|
||||
|
||||
Context context = HaloApp.getInstance().getApplication();
|
||||
try {
|
||||
object.put("version", PackageUtils.getVersionName());
|
||||
|
||||
@ -255,6 +255,11 @@ public class MessageShareUtils {
|
||||
private void wechatSahre() {
|
||||
Utils.toast(mContext, "分享跳转中...");
|
||||
|
||||
if (!PackageHelper.INSTANCE.getLocalPackageNameSet().contains("com.tencent.mm")) {
|
||||
Utils.toast(mContext, "没安装微信,分享失败");
|
||||
return;
|
||||
}
|
||||
|
||||
//官方分享
|
||||
// WXImageObject imgObj = new WXImageObject();
|
||||
// imgObj.setImagePath(mContext.getExternalCacheDir().getPath() + "/ShareImg/" + picName);
|
||||
@ -286,6 +291,11 @@ public class MessageShareUtils {
|
||||
private void wechatMomentsSahre() {
|
||||
Utils.toast(mContext, "分享跳转中...");
|
||||
|
||||
if (!PackageHelper.INSTANCE.getLocalPackageNameSet().contains("com.tencent.mm")) {
|
||||
Utils.toast(mContext, "没安装微信,分享失败");
|
||||
return;
|
||||
}
|
||||
|
||||
WXImageObject imgObj = new WXImageObject();
|
||||
imgObj.setImagePath(mContext.getExternalCacheDir().getPath() + "/ShareImg/" + picName);
|
||||
WXMediaMessage msg = new WXMediaMessage();
|
||||
|
||||
@ -2,15 +2,25 @@ package com.gh.common.util
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.ApplicationInfo
|
||||
import com.gh.common.AppExecutor
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.gamecenter.entity.SettingsEntity
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
object PackageHelper {
|
||||
|
||||
// 黑名单包名,用于区分像 Xposed Installer 那些工具的包名
|
||||
var excludePackageNameList = arrayListOf<String>()
|
||||
// 评论黑名单包名列表,避免用户安装了 Xposed Installer 这样的工具,也能在包含该安装包的游戏详情页评论
|
||||
var commentPackageNameBlackList = arrayListOf<String>()
|
||||
|
||||
// 关闭下载的包列表
|
||||
var downloadPackageNameBlackList = arrayListOf<String>()
|
||||
|
||||
// 本地已安装的包去掉关闭下载的包后的列表
|
||||
var validLocalPackageNameSet = hashSetOf<String>()
|
||||
|
||||
// 游戏包名匹配列表
|
||||
var relatedPackageList = arrayListOf<SettingsEntity.GameWithPackages>()
|
||||
|
||||
// 本地已安装包的列表
|
||||
var localPackageNameSet = hashSetOf<String>()
|
||||
get() {
|
||||
return if (field.isEmpty()) {
|
||||
@ -23,16 +33,28 @@ object PackageHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun refreshLocalPackageList() {
|
||||
AppExecutor.ioExecutor.execute {
|
||||
localPackageNameSet = getAllPackageName(HaloApp.getInstance().application)
|
||||
}
|
||||
localPackageNameSet = getAllPackageName(HaloApp.getInstance().application)
|
||||
updateValidPackageNameList()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun initExcludePackageName() {
|
||||
fun initList() {
|
||||
Config.getSettings()?.gameCommentBlackList?.let {
|
||||
excludePackageNameList = ArrayList(it)
|
||||
commentPackageNameBlackList = ArrayList(it)
|
||||
}
|
||||
Config.getSettings()?.gameDownloadBlackList?.let {
|
||||
downloadPackageNameBlackList = ArrayList(it)
|
||||
}
|
||||
Config.getSettings()?.gamePackageMatch?.let {
|
||||
relatedPackageList = ArrayList(it)
|
||||
}
|
||||
|
||||
Config.getSettings()?.gameDownloadBlackList
|
||||
updateValidPackageNameList()
|
||||
}
|
||||
|
||||
private fun updateValidPackageNameList() {
|
||||
validLocalPackageNameSet = localPackageNameSet.filterNot { p -> downloadPackageNameBlackList.contains(p) }.toHashSet()
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -236,7 +236,10 @@ public class PlatformUtils {
|
||||
if (TextUtils.isEmpty(platformName)) {
|
||||
getPlatform();
|
||||
}
|
||||
return platformName;
|
||||
if (!TextUtils.isEmpty(platformName)) {
|
||||
return platformName;
|
||||
}
|
||||
return platform;
|
||||
}
|
||||
|
||||
public void getPlatform() {
|
||||
|
||||
@ -251,6 +251,12 @@ public class ShareUtils {
|
||||
//微信好友分享
|
||||
private void wechatShare() {
|
||||
Utils.toast(mContext, R.string.share_skip);
|
||||
|
||||
if (!PackageHelper.INSTANCE.getLocalPackageNameSet().contains("com.tencent.mm")) {
|
||||
Utils.toast(mContext, "没安装微信,分享失败");
|
||||
return;
|
||||
}
|
||||
|
||||
WXWebpageObject webpage = new WXWebpageObject();
|
||||
WXMediaMessage msg = new WXMediaMessage(webpage);
|
||||
webpage.webpageUrl = shareUrl;
|
||||
@ -387,6 +393,12 @@ public class ShareUtils {
|
||||
//微信朋友圈分享
|
||||
private void wechatMomentsShare() {
|
||||
Utils.toast(mContext, R.string.share_skip);
|
||||
|
||||
if (!PackageHelper.INSTANCE.getLocalPackageNameSet().contains("com.tencent.mm")) {
|
||||
Utils.toast(mContext, "没安装微信,分享失败");
|
||||
return;
|
||||
}
|
||||
|
||||
WXWebpageObject webpage = new WXWebpageObject();
|
||||
WXMediaMessage msg = new WXMediaMessage(webpage);
|
||||
|
||||
|
||||
@ -1,84 +0,0 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
/**
|
||||
* 用于解决因为沉浸式状态栏(自定义)时键盘不遮挡输入框
|
||||
*/
|
||||
public class SoftInputHidWidgetUtils {
|
||||
private View mChildOfContent;
|
||||
private int usableHeightPrevious;
|
||||
private FrameLayout.LayoutParams frameLayoutParams;
|
||||
private int contentHeight;
|
||||
private boolean isfirst = true;
|
||||
private int statusBarHeight;
|
||||
|
||||
public static void assistActivity(Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
new SoftInputHidWidgetUtils(activity);
|
||||
}
|
||||
}
|
||||
|
||||
private SoftInputHidWidgetUtils(Activity activity) {
|
||||
statusBarHeight = getStatusBarHeight(activity);
|
||||
FrameLayout content = (FrameLayout)activity.findViewById(android.R.id.content);
|
||||
mChildOfContent = content.getChildAt(0);
|
||||
|
||||
//界面出现变动都会调用这个监听事件
|
||||
mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
public void onGlobalLayout() {
|
||||
if (isfirst) {
|
||||
contentHeight = mChildOfContent.getHeight();//兼容华为等机型
|
||||
isfirst = false;
|
||||
}
|
||||
possiblyResizeChildOfContent();
|
||||
}
|
||||
});
|
||||
|
||||
frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
|
||||
}
|
||||
|
||||
//重新调整跟布局的高度
|
||||
private void possiblyResizeChildOfContent() {
|
||||
|
||||
int usableHeightNow = computeUsableHeight();
|
||||
//当前可见高度和上一次可见高度不一致 布局变动
|
||||
if (usableHeightNow != usableHeightPrevious) {
|
||||
int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
|
||||
int heightDifference = usableHeightSansKeyboard - usableHeightNow;
|
||||
if (heightDifference > (usableHeightSansKeyboard / 4)) {
|
||||
// keyboard probably just became visible
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
|
||||
frameLayoutParams.height = usableHeightSansKeyboard - heightDifference + statusBarHeight;
|
||||
} else {
|
||||
frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
|
||||
}
|
||||
} else {
|
||||
frameLayoutParams.height = contentHeight;
|
||||
}
|
||||
mChildOfContent.requestLayout();
|
||||
usableHeightPrevious = usableHeightNow;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取改变之后界面的可用高度(可以为开发者显示内容的高度)
|
||||
* @return
|
||||
*/
|
||||
private int computeUsableHeight() {
|
||||
Rect r = new Rect();
|
||||
mChildOfContent.getWindowVisibleDisplayFrame(r);//获取到的rect就是界面除去标题栏、除去软键盘挡住部分,所剩下的域
|
||||
return (r.bottom - r.top);
|
||||
}
|
||||
|
||||
public static int getStatusBarHeight(Activity activity) {
|
||||
//获取状态栏的高度
|
||||
int resourceId = activity.getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||
return activity.getResources().getDimensionPixelSize(resourceId);
|
||||
}
|
||||
}
|
||||
@ -55,6 +55,11 @@ object SPUtils {
|
||||
return sp.getBoolean(key, false)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getBoolean(key: String, defaultValue: Boolean): Boolean {
|
||||
return sp.getBoolean(key, defaultValue)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setString(sp: SharedPreferences, key: String, value: String? = null) {
|
||||
try {
|
||||
|
||||
39
app/src/main/java/com/gh/common/util/TextHelper.kt
Normal file
39
app/src/main/java/com/gh/common/util/TextHelper.kt
Normal file
@ -0,0 +1,39 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.widget.EditText
|
||||
import com.gh.gamecenter.R
|
||||
|
||||
object TextHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun limitTheLengthOfEditText(editText: EditText, length: Int, exceedCallback: ExceedTextLengthLimitCallback? = null) {
|
||||
editText.addTextChangedListener(object :TextWatcher {
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
|
||||
}
|
||||
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
val tvCount = editText.text.toString().length
|
||||
if (tvCount > length) {
|
||||
val str = editText.text.toString().substring(0, length)
|
||||
editText.setText(str)
|
||||
editText.setSelection(str.length)
|
||||
if (!ClickUtils.isFastDoubleClick(R.id.userinfo_nickname_et, 2000)) {
|
||||
exceedCallback?.onExceed()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
interface ExceedTextLengthLimitCallback {
|
||||
fun onExceed()
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.gh.common.util
|
||||
|
||||
/**
|
||||
* 第三方安装包(即安装包里没有 gh-id)的辅助类
|
||||
*/
|
||||
object ThirdPartyPackageHelper {
|
||||
|
||||
private const val PREFIX = "third_party_package"
|
||||
|
||||
@JvmStatic
|
||||
fun saveGameId(packageName: String, gameId: String) {
|
||||
SPUtils.setString(PREFIX + packageName, gameId)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getGameId(packageName: String): String {
|
||||
return SPUtils.getString(PREFIX + packageName, "")!!
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,33 +1,44 @@
|
||||
package com.gh.common.view;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.databinding.DataBindingUtil;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v4.view.ViewPager.OnPageChangeListener;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.exposure.ExposureEvent;
|
||||
import com.gh.common.util.ClickUtils;
|
||||
import com.gh.common.util.DirectUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.common.util.SPUtils;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.OnCollectionCallBackListener;
|
||||
import com.gh.gamecenter.adapter.PlatformPagerAdapter;
|
||||
import com.gh.gamecenter.databinding.ImprintContentItemBinding;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.ApkLink;
|
||||
import com.gh.gamecenter.entity.GameCollectionEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.LinkEntity;
|
||||
import com.gh.gamecenter.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus;
|
||||
import com.gh.gamecenter.eventbus.EBPackage;
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
@ -56,21 +67,35 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* @des 弹出游戏版本下载按钮,点击并添加到下载任务中
|
||||
*/
|
||||
public class DownloadDialog implements OnCollectionCallBackListener {
|
||||
|
||||
private static DownloadDialog instance;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private boolean isShow;
|
||||
private PopupWindow popupWindow;
|
||||
private List<ApkEntity> gameApk;
|
||||
private GameEntity gameEntity;
|
||||
|
||||
private ViewPager viewPager;
|
||||
private PlatformPagerAdapter adapter;
|
||||
private ViewPager collectionViewPager;
|
||||
private LinearLayout dialog_ll_collection_hint;
|
||||
private LinearLayout dialog_ll_hint;
|
||||
private LinearLayout dialog_ll_collection;
|
||||
private ViewPager collectionViewPager;
|
||||
private View mDialogMorePlatformHint;
|
||||
|
||||
private List<ApkEntity> gameApk;
|
||||
private GameEntity gameEntity;
|
||||
|
||||
private PlatformPagerAdapter adapter;
|
||||
private PlatformPagerAdapter collectionAdapter;
|
||||
|
||||
private ExposureEvent traceEvent;
|
||||
|
||||
private static final String DOWNLOAD_PLATFORM_HINT = "download_platform_hint";
|
||||
|
||||
private String entrance;
|
||||
private String location;
|
||||
private String mAutoDownloadPlatform;
|
||||
|
||||
private final int row = 3;
|
||||
private final int column = 3;
|
||||
private boolean isLoadPlatform;
|
||||
|
||||
private DataWatcher dataWatcher = new DataWatcher() {
|
||||
@Override
|
||||
public void onDataChanged(DownloadEntity downloadEntity) {
|
||||
@ -85,25 +110,13 @@ public class DownloadDialog implements OnCollectionCallBackListener {
|
||||
}
|
||||
}
|
||||
};
|
||||
private LinearLayout dialog_ll_collection_hint;
|
||||
private String entrance;
|
||||
private String location;
|
||||
private ExposureEvent traceEvent;
|
||||
private String mAutoDownloadPlatform;
|
||||
private final int row = 3;
|
||||
private final int column = 3;
|
||||
private boolean isLoadPlatform;
|
||||
|
||||
private DownloadDialog() {
|
||||
isShow = false;
|
||||
private DownloadDialog(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public static DownloadDialog getInstance(Context context) {
|
||||
if (instance == null) {
|
||||
instance = new DownloadDialog();
|
||||
}
|
||||
instance.mContext = context; // 每次创建context重新赋值, Dialog持有context问题
|
||||
return instance;
|
||||
return new DownloadDialog(context);
|
||||
}
|
||||
|
||||
// 自动下载并翻到相应页面
|
||||
@ -119,13 +132,9 @@ public class DownloadDialog implements OnCollectionCallBackListener {
|
||||
|
||||
public void showPopupWindow(View view, GameEntity gameEntity, String entrance, String location,
|
||||
@Nullable ExposureEvent traceEvent) {
|
||||
if (isShow && (popupWindow == null || !popupWindow.isShowing())) {
|
||||
isShow = false;
|
||||
}
|
||||
if (isShow) {
|
||||
if (ClickUtils.isFastDoubleClick()) {
|
||||
return;
|
||||
}
|
||||
isShow = true;
|
||||
|
||||
this.gameEntity = gameEntity;
|
||||
this.entrance = entrance;
|
||||
@ -146,14 +155,39 @@ public class DownloadDialog implements OnCollectionCallBackListener {
|
||||
// 一个自定义的布局,作为显示的内容
|
||||
View contentView = View.inflate(mContext, R.layout.game_download_dialog, null);
|
||||
|
||||
TextView title = (TextView) contentView.findViewById(R.id.dialog_title);
|
||||
TextView title = contentView.findViewById(R.id.dialog_title);
|
||||
title.setText(gameEntity.getName());
|
||||
|
||||
viewPager = (ViewPager) contentView.findViewById(R.id.dialog_viewPager);
|
||||
dialog_ll_hint = (LinearLayout) contentView.findViewById(R.id.dialog_ll_hint);
|
||||
dialog_ll_collection = (LinearLayout) contentView.findViewById(R.id.dialog_ll_collection);
|
||||
dialog_ll_collection_hint = (LinearLayout) contentView.findViewById(R.id.dialog_ll_collection_hint);
|
||||
collectionViewPager = (ViewPager) contentView.findViewById(R.id.dialog_collection_viewPager);
|
||||
viewPager = contentView.findViewById(R.id.dialog_viewPager);
|
||||
dialog_ll_hint = contentView.findViewById(R.id.dialog_ll_hint);
|
||||
dialog_ll_collection = contentView.findViewById(R.id.dialog_ll_collection);
|
||||
dialog_ll_collection_hint = contentView.findViewById(R.id.dialog_ll_collection_hint);
|
||||
collectionViewPager = contentView.findViewById(R.id.dialog_collection_viewPager);
|
||||
mDialogMorePlatformHint = contentView.findViewById(R.id.dialog_more_platform_hit);
|
||||
TextView dialogAd = contentView.findViewById(R.id.dialog_ad);
|
||||
TextView dialogAdMirror = contentView.findViewById(R.id.dialog_ad_mirror);
|
||||
mDialogMorePlatformHint.setOnClickListener(v -> {
|
||||
mDialogMorePlatformHint.setVisibility(View.GONE);
|
||||
SPUtils.setBoolean(DOWNLOAD_PLATFORM_HINT, false);
|
||||
});
|
||||
|
||||
LinkEntity downloadAd = gameEntity.getDownloadAd();
|
||||
if (downloadAd != null) {
|
||||
dialogAd.setVisibility(View.VISIBLE);
|
||||
dialogAd.setText(downloadAd.getTitle());
|
||||
dialogAdMirror.setVisibility(View.INVISIBLE);
|
||||
dialogAdMirror.setText(downloadAd.getTitle());
|
||||
dialogAd.setOnClickListener(v -> {
|
||||
if ("imprint".equals(downloadAd.getType())) {
|
||||
showImprintDialog(downloadAd.getTitle());
|
||||
} else {
|
||||
DirectUtils.directToLinkPage(
|
||||
mContext,
|
||||
downloadAd,
|
||||
entrance, "下载多平台弹窗");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
isLoadPlatform = false;
|
||||
|
||||
@ -164,32 +198,20 @@ public class DownloadDialog implements OnCollectionCallBackListener {
|
||||
popupWindow = new PopupWindow(contentView, LayoutParams.MATCH_PARENT,
|
||||
LayoutParams.MATCH_PARENT, true);
|
||||
|
||||
contentView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
});
|
||||
contentView.setOnClickListener(v -> popupWindow.dismiss());
|
||||
contentView.setFocusable(true);
|
||||
contentView.setFocusableInTouchMode(true);
|
||||
contentView.setOnKeyListener(new View.OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0
|
||||
&& popupWindow != null && popupWindow.isShowing()) {
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
return false;
|
||||
contentView.setOnKeyListener((v, keyCode, event) -> {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0
|
||||
&& popupWindow != null && popupWindow.isShowing()) {
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss() {
|
||||
isShow = false;
|
||||
EventBus.getDefault().unregister(DownloadDialog.this);
|
||||
DownloadManager.getInstance(mContext).removeObserver(dataWatcher);
|
||||
}
|
||||
popupWindow.setOnDismissListener(() -> {
|
||||
EventBus.getDefault().unregister(DownloadDialog.this);
|
||||
DownloadManager.getInstance(mContext).removeObserver(dataWatcher);
|
||||
});
|
||||
|
||||
popupWindow.setTouchable(true);
|
||||
@ -208,6 +230,51 @@ public class DownloadDialog implements OnCollectionCallBackListener {
|
||||
DownloadManager.getInstance(mContext).addObserver(dataWatcher);
|
||||
}
|
||||
|
||||
private void showImprintDialog(String titleName) {
|
||||
Dialog dialog = new Dialog(mContext, R.style.full_dialog);
|
||||
View inflate = LayoutInflater.from(mContext).inflate(R.layout.imprint_dialog, null);
|
||||
dialog.setContentView(inflate);
|
||||
dialog.show();
|
||||
|
||||
Window window = dialog.getWindow();
|
||||
WindowManager.LayoutParams params;
|
||||
if (window != null) {
|
||||
params = window.getAttributes();
|
||||
params.width = (int) (mContext.getResources().getDisplayMetrics().widthPixels * 0.9);
|
||||
window.setAttributes(params);
|
||||
window.setBackgroundDrawableResource(R.drawable.full_dialog_background);
|
||||
}
|
||||
|
||||
inflate.findViewById(R.id.imprint_close).setOnClickListener(v -> dialog.dismiss());
|
||||
LinearLayout content = inflate.findViewById(R.id.imprint_content);
|
||||
((TextView) inflate.findViewById(R.id.imprint_title)).setText(titleName);
|
||||
View head = LayoutInflater.from(mContext).inflate(R.layout.imprint_content_item, null);
|
||||
content.addView(head, LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(30));
|
||||
LimitHeightLinearLayout imprintContainer = inflate.findViewById(R.id.imprint_container);
|
||||
imprintContainer.setLimitHeight((int) (mContext.getResources().getDisplayMetrics().heightPixels * 0.8));
|
||||
|
||||
ArrayList<ApkEntity> list = gameEntity.getApk();
|
||||
SettingsEntity settings = Config.getSettings();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ApkEntity apk = gameEntity.getApk().get(i);
|
||||
if (settings != null && settings.getGameDownloadBlackList().contains(apk.getPackageName())) {
|
||||
continue;
|
||||
}
|
||||
View item = LayoutInflater.from(mContext).inflate(R.layout.imprint_content_item, null);
|
||||
ImprintContentItemBinding bind = DataBindingUtil.bind(item);
|
||||
bind.setApk(apk);
|
||||
bind.setPlatformName(PlatformUtils.getInstance(mContext).getPlatformName(apk.getPlatform()));
|
||||
content.addView(item, LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(40));
|
||||
}
|
||||
|
||||
|
||||
// close line
|
||||
View view = new View(mContext);
|
||||
view.setBackgroundColor(mContext.getResources().getColor(R.color.text_5d5d5d));
|
||||
view.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(1)));
|
||||
content.addView(view);
|
||||
}
|
||||
|
||||
private void sortApk() {
|
||||
for (ApkEntity apkEntity : gameApk) {
|
||||
GameCollectionEntity apkCollection = apkEntity.getApkCollection();
|
||||
@ -388,6 +455,13 @@ public class DownloadDialog implements OnCollectionCallBackListener {
|
||||
int size = (int) Math.ceil(apkList.size() / (double) (row * column));
|
||||
addHintPoint(dialog_ll_hint, size);
|
||||
|
||||
if (size >= 2) {
|
||||
boolean isShowPlatformHint = SPUtils.getBoolean(DOWNLOAD_PLATFORM_HINT, true);
|
||||
if (isShowPlatformHint) {
|
||||
mDialogMorePlatformHint.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
int count = apkList.size();
|
||||
int vpHeight;
|
||||
if (count <= 3) {
|
||||
|
||||
@ -8,9 +8,11 @@ import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ProgressBar;
|
||||
@ -37,6 +39,8 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
|
||||
private PorterDuffXfermode mDuffXFerMode = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN);
|
||||
private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
// 仅用于测量文字是否超出范围,不用于画文字
|
||||
private TextPaint mFakeTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
|
||||
private DownloadType mDownloadType;
|
||||
|
||||
@ -46,6 +50,8 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
private int mDefaultColor;
|
||||
private int mTextSize;
|
||||
|
||||
private Rect mTextBound = new Rect();
|
||||
|
||||
public DownloadProgressBar(Context context) {
|
||||
super(context);
|
||||
}
|
||||
@ -79,6 +85,9 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
|
||||
mPaint.setColor(mDefaultColor == 0 ? ContextCompat.getColor(getContext(), R.color.theme) : mDefaultColor); // 初始化颜色
|
||||
mPaint.setTextSize(mTextSize);
|
||||
mFakeTextPaint.setTextSize(mTextSize);
|
||||
mFakeTextPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||
mFakeTextPaint.setTextAlign(Paint.Align.CENTER);
|
||||
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||
mPaint.setXfermode(null);
|
||||
create();
|
||||
@ -87,7 +96,11 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
int baseline = (getHeight() - fontMetrics.bottom - fontMetrics.top) / 2;
|
||||
|
||||
mPaint.setTextAlign(Paint.Align.CENTER);
|
||||
srcCanvas.drawText(mText, getWidth() / 2, baseline, mPaint);
|
||||
|
||||
canvas.getClipBounds(mTextBound); //The dimensions of your canvas
|
||||
int width = mTextBound.width() - 20; //10 to keep some space on the right for the "..."
|
||||
String txt = TextUtils.ellipsize(mText, mFakeTextPaint, width, TextUtils.TruncateAt.END).toString();
|
||||
srcCanvas.drawText(txt, getWidth() / 2, baseline, mPaint);
|
||||
mPaint.setXfermode(mDuffXFerMode);
|
||||
if (getProgress() != 0 && getProgress() != MAX_LENGTH) {
|
||||
mPaint.setColor(DOWNLOAD_IMAGE_STYLE == mDownloadStyle ? Color.BLACK : Color.WHITE); // 反向颜色
|
||||
|
||||
@ -10,8 +10,13 @@ object DrawableView {
|
||||
|
||||
@JvmStatic
|
||||
fun getServerDrawable(colorCode: String): Drawable {
|
||||
return getServerDrawable(Color.parseColor(colorCode))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getServerDrawable(colorCode: Int): Drawable {
|
||||
val drawable = GradientDrawable()
|
||||
drawable.setColor(Color.parseColor(colorCode))
|
||||
drawable.setColor(colorCode)
|
||||
drawable.cornerRadius = DisplayUtils.dip2px(2F).toFloat()
|
||||
return drawable
|
||||
}
|
||||
|
||||
@ -0,0 +1,59 @@
|
||||
package com.gh.common.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
|
||||
/**
|
||||
* Created by khy on 2/04/18.
|
||||
*/
|
||||
|
||||
public class LimitHeightLinearLayout extends LinearLayout {
|
||||
|
||||
private int mLimitHeight;
|
||||
|
||||
public LimitHeightLinearLayout(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public LimitHeightLinearLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
if (attrs != null) {
|
||||
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.LimitHeightScrollView);
|
||||
mLimitHeight = ta.getDimensionPixelSize(R.styleable.LimitHeightScrollView_maxHeight, DisplayUtils.dip2px(getContext(), 240));
|
||||
ta.recycle();
|
||||
} else {
|
||||
mLimitHeight = DisplayUtils.dip2px(getContext(), 240);
|
||||
}
|
||||
}
|
||||
|
||||
public LimitHeightLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
|
||||
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
|
||||
|
||||
if (heightMode == MeasureSpec.EXACTLY
|
||||
|| heightMode == MeasureSpec.AT_MOST
|
||||
|| heightMode == MeasureSpec.UNSPECIFIED) {
|
||||
heightSize = heightSize <= mLimitHeight ? heightSize
|
||||
: mLimitHeight;
|
||||
}
|
||||
int maxHeightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize,
|
||||
heightMode);
|
||||
super.onMeasure(widthMeasureSpec, maxHeightMeasureSpec);
|
||||
}
|
||||
|
||||
public void setLimitHeight(int limitHeight) {
|
||||
mLimitHeight = limitHeight;
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
@ -1,62 +0,0 @@
|
||||
//package com.gh.common.view;
|
||||
//
|
||||
//import android.content.Context;
|
||||
//import android.support.v7.widget.LinearLayoutManager;
|
||||
//import android.support.v7.widget.RecyclerView;
|
||||
//import android.view.View;
|
||||
//import android.view.ViewGroup;
|
||||
//
|
||||
///**
|
||||
// * Created by khy on 2017/3/30.
|
||||
// */
|
||||
//public class MeasureLinearLayoutManager extends LinearLayoutManager {
|
||||
// int height;
|
||||
// private int[] mMeasuredDimension = new int[1];
|
||||
//
|
||||
// public MeasureLinearLayoutManager(Context context) {
|
||||
// super(context);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state,
|
||||
// int widthSpec, int heightSpec) {
|
||||
// super.onMeasure(recycler, state, widthSpec, heightSpec);
|
||||
// height = 0;
|
||||
//
|
||||
// try {
|
||||
// for (int i = 0; i < getItemCount(); i++) {
|
||||
// measureScrapChild(recycler, i,
|
||||
// View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED),
|
||||
// View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED),
|
||||
// mMeasuredDimension);
|
||||
// height = height + mMeasuredDimension[0];
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private void measureScrapChild(RecyclerView.Recycler recycler, int position, int widthSpec,
|
||||
// int heightSpec, int[] measuredDimension) throws Exception {
|
||||
// View view = recycler.getViewForPosition(position);
|
||||
// if (view.getVisibility() == View.GONE) {
|
||||
// measuredDimension[0] = 0;
|
||||
// return;
|
||||
// }
|
||||
// super.measureChildWithMargins(view, 0, 0);
|
||||
// RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams();
|
||||
// int childHeightSpec = ViewGroup.getChildMeasureSpec(
|
||||
// heightSpec,
|
||||
// getPaddingTop() + getPaddingBottom() + getDecoratedTop(view) + getDecoratedBottom(view),
|
||||
// p.height);
|
||||
//
|
||||
// view.measure(0, childHeightSpec);
|
||||
// measuredDimension[0] = getDecoratedMeasuredHeight(view) + p.bottomMargin + p.topMargin;
|
||||
// recycler.recycleView(view);
|
||||
// }
|
||||
//
|
||||
// public int getRvHeight() {
|
||||
// return height;
|
||||
// }
|
||||
//}
|
||||
@ -0,0 +1,136 @@
|
||||
package com.gh.common.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import com.gh.gamecenter.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MessageSpannableTextView extends android.support.v7.widget.AppCompatTextView {
|
||||
|
||||
private OnSpannableClickListener mSpannableClickListener;
|
||||
|
||||
private final String mStartMarkKey = "{{";
|
||||
private final String mEndMarkKey = "}}";
|
||||
|
||||
private List<MarkData> mMarkList;
|
||||
|
||||
public MessageSpannableTextView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public MessageSpannableTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mMarkList = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(CharSequence text, BufferType type) {
|
||||
if (TextUtils.isEmpty(text) ||
|
||||
!text.toString().contains(mStartMarkKey) && !text.toString().contains(mEndMarkKey)) {
|
||||
super.setText(text, type);
|
||||
return;
|
||||
}
|
||||
|
||||
mMarkList.clear();
|
||||
String sText = text.toString();
|
||||
String[] split = sText.split("\\}\\}");
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
String s = split[i];
|
||||
int p = s.lastIndexOf(mStartMarkKey);
|
||||
if (p != -1) {
|
||||
MarkData markData = new MarkData();
|
||||
String substring = s.substring(p);
|
||||
String content = s.replace(substring, "");
|
||||
builder.append(content);
|
||||
markData.setStart(builder.length() + 1);
|
||||
|
||||
String key = substring.replace(mStartMarkKey, " ") + " ";
|
||||
builder.append(key);
|
||||
markData.setEnd(builder.length() - 1);
|
||||
markData.setKey(key);
|
||||
|
||||
mMarkList.add(markData);
|
||||
System.out.println(substring);
|
||||
System.out.println(s);
|
||||
} else {
|
||||
builder.append(s);
|
||||
if (i != split.length - 1 || sText.substring(sText.length() - 2, sText.length()).equals("}}")) {
|
||||
builder.append("}}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SpannableStringBuilder msp = new SpannableStringBuilder(builder);
|
||||
for (MarkData markData : mMarkList) {
|
||||
msp.setSpan(new ClickableSpan() {
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setColor(getContext().getResources().getColor(R.color.tag_orange));
|
||||
ds.setUnderlineText(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View widget) {
|
||||
if (mSpannableClickListener != null) {
|
||||
mSpannableClickListener.onClick(markData.getKey().trim());
|
||||
}
|
||||
}
|
||||
}, markData.getStart(), markData.getEnd(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
||||
}
|
||||
|
||||
setMovementMethod(CustomLinkMovementMethod.getInstance());
|
||||
super.setText(msp, type);
|
||||
}
|
||||
|
||||
public void setOnSpannableClickListener(OnSpannableClickListener spannableClickListener) {
|
||||
this.mSpannableClickListener = spannableClickListener;
|
||||
}
|
||||
|
||||
|
||||
public interface OnSpannableClickListener {
|
||||
void onClick(String spannableText);
|
||||
}
|
||||
|
||||
class MarkData {
|
||||
private int start;
|
||||
private int end;
|
||||
private String key;
|
||||
|
||||
public int getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public void setStart(int start) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public int getEnd() {
|
||||
return end;
|
||||
}
|
||||
|
||||
public void setEnd(int end) {
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,18 +3,13 @@ package com.gh.common.view
|
||||
import android.content.Context
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||
import android.media.AudioManager
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import cn.jzvd.JZDataSource
|
||||
import cn.jzvd.JZUtils
|
||||
import cn.jzvd.Jzvd
|
||||
import cn.jzvd.JzvdStd
|
||||
import cn.jzvd.*
|
||||
import com.gh.common.observer.MuteCallback
|
||||
import com.gh.common.observer.VolumeObserver
|
||||
import com.gh.common.util.DialogUtils
|
||||
@ -60,12 +55,12 @@ class PlayerView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
if (v.id == R.id.start || v.id == R.id.thumb) {
|
||||
if (Jzvd.CURRENT_STATE_PLAYING != currentState) {
|
||||
if ((currentScreen == SCREEN_WINDOW_NORMAL || currentScreen == SCREEN_WINDOW_LIST)) {
|
||||
MtaHelper.onEvent("游戏详情", "视频_点击播放", gameName)
|
||||
MtaHelper.onEvent("游戏详情_新", "视频_点击播放", gameName)
|
||||
} else {
|
||||
MtaHelper.onEvent("游戏详情", "视频全屏_点击播放", gameName)
|
||||
MtaHelper.onEvent("游戏详情_新", "视频全屏_点击播放", gameName)
|
||||
}
|
||||
} else {
|
||||
MtaHelper.onEvent("游戏详情", "视频_点击暂停", gameName)
|
||||
MtaHelper.onEvent("游戏详情_新", "视频_点击暂停", gameName)
|
||||
}
|
||||
|
||||
if (showAlertDialogForTheFistTime
|
||||
@ -86,7 +81,7 @@ class PlayerView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
Jzvd.FULLSCREEN_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
JZUtils.setRequestedOrientation(context, Jzvd.FULLSCREEN_ORIENTATION)
|
||||
}
|
||||
MtaHelper.onEvent("游戏详情", "视频全屏_点击旋转", gameName)
|
||||
MtaHelper.onEvent("游戏详情_新", "视频全屏_点击旋转", gameName)
|
||||
}
|
||||
R.id.mute -> {
|
||||
toggleMute()
|
||||
@ -101,6 +96,10 @@ class PlayerView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
|
||||
private fun toggleMute() {
|
||||
HaloApp.getInstance().isMute = !HaloApp.getInstance().isMute
|
||||
updateMuteStatus()
|
||||
}
|
||||
|
||||
private fun updateMuteStatus() {
|
||||
if (HaloApp.getInstance().isMute) {
|
||||
mute()
|
||||
} else {
|
||||
@ -124,26 +123,22 @@ class PlayerView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
|
||||
private fun mute() {
|
||||
muteIv.setImageResource(R.drawable.ic_volume_off)
|
||||
// 安卓 6.0 以上 toggle 静音接口,以下将声音置为 0% 或 60%
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_MUTE, 0)
|
||||
} else {
|
||||
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0)
|
||||
try {
|
||||
JZMediaManager.instance()?.jzMediaInterface?.setVolume(0f, 0f)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
MtaHelper.onEvent("游戏详情", "视频_点击静音", gameName)
|
||||
MtaHelper.onEvent("游戏详情_新", "视频_点击静音", gameName)
|
||||
}
|
||||
|
||||
private fun unmute() {
|
||||
muteIv.setImageResource(R.drawable.ic_volume_on)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_UNMUTE, 0)
|
||||
} else {
|
||||
mAudioManager.setStreamVolume(
|
||||
AudioManager.STREAM_MUSIC,
|
||||
60 * mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC),
|
||||
0)
|
||||
try {
|
||||
JZMediaManager.instance()?.jzMediaInterface?.setVolume(1.0f, 1.0f)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
MtaHelper.onEvent("游戏详情", "视频_解除静音", gameName)
|
||||
MtaHelper.onEvent("游戏详情_新", "视频_解除静音", gameName)
|
||||
}
|
||||
|
||||
override fun onStatePlaying() {
|
||||
@ -154,6 +149,11 @@ class PlayerView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStatePrepared() {
|
||||
super.onStatePrepared()
|
||||
updateMuteStatus()
|
||||
}
|
||||
|
||||
override fun onClickUiToggle() {
|
||||
// 仅在全屏状态下才会 toggle 播放信息
|
||||
if (currentScreen == Jzvd.SCREEN_WINDOW_FULLSCREEN) {
|
||||
@ -204,11 +204,7 @@ class PlayerView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
rotateIv.visibility = View.GONE
|
||||
|
||||
// 将右下角的按钮变成静音与否
|
||||
if (HaloApp.getInstance().isMute) {
|
||||
mute()
|
||||
} else {
|
||||
unmute()
|
||||
}
|
||||
updateMuteStatus()
|
||||
} else {
|
||||
progressBar.visibility = View.VISIBLE
|
||||
totalTimeTextView.visibility = View.VISIBLE
|
||||
@ -257,7 +253,7 @@ class PlayerView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
if (currentScreen == SCREEN_WINDOW_NORMAL || currentScreen == SCREEN_WINDOW_LIST) {
|
||||
progressBar.visibility = View.INVISIBLE
|
||||
totalTimeTextView.visibility = View.INVISIBLE
|
||||
MtaHelper.onEvent("游戏详情", "视频全屏_点击后退", gameName)
|
||||
MtaHelper.onEvent("游戏详情_新", "视频全屏_点击后退", gameName)
|
||||
} else {
|
||||
progressBar.visibility = View.VISIBLE
|
||||
totalTimeTextView.visibility = View.VISIBLE
|
||||
@ -267,7 +263,7 @@ class PlayerView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
override fun startWindowFullscreen() {
|
||||
super.startWindowFullscreen()
|
||||
unmute()
|
||||
MtaHelper.onEvent("游戏详情", "视频_点击进入全屏", gameName)
|
||||
MtaHelper.onEvent("游戏详情_新", "视频_点击进入全屏", gameName)
|
||||
}
|
||||
|
||||
override fun startDismissControlViewTimer() {
|
||||
|
||||
@ -398,7 +398,11 @@ public class RichEditor extends WebView {
|
||||
|
||||
private void load(String trigger) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
evaluateJavascript(trigger, null);
|
||||
try {
|
||||
evaluateJavascript(trigger, null);
|
||||
} catch (IllegalStateException ignore) {
|
||||
loadUrl(trigger);
|
||||
}
|
||||
} else {
|
||||
loadUrl(trigger);
|
||||
}
|
||||
|
||||
@ -53,6 +53,18 @@ public class GameDetailActivity extends NormalActivity {
|
||||
public static void startGameDetailActivity(Context context, GameEntity gameEntity, String entrance, ExposureEvent traceEvent) {
|
||||
DataUtils.onMtaEvent(context, "详情页面", "游戏详情", gameEntity != null ? gameEntity.getName() : "");
|
||||
|
||||
if (gameEntity != null
|
||||
&& traceEvent != null
|
||||
&& gameEntity.getId() != null
|
||||
&& !gameEntity.getId().equals(traceEvent.getPayload().getGameId())) {
|
||||
// 当游戏 ID 跟曝光 traceEvent 的游戏ID 不一样的时候更新 traceEvent 的游戏ID
|
||||
ExposureEvent forNewPayload = ExposureEvent.Companion.createEvent(gameEntity,
|
||||
traceEvent.getSource(),
|
||||
ExposureTraceUtils.INSTANCE.appendTrace(traceEvent),
|
||||
ExposureType.EXPOSURE);
|
||||
traceEvent.setPayload(forNewPayload.getPayload());
|
||||
}
|
||||
|
||||
ExposureEvent clickEvent = ExposureEvent.Companion.createEvent(gameEntity, traceEvent.getSource(), ExposureTraceUtils.INSTANCE.appendTrace(traceEvent), ExposureType.CLICK);
|
||||
ExposureManager.INSTANCE.log(clickEvent);
|
||||
Bundle bundle = new Bundle();
|
||||
@ -67,6 +79,16 @@ public class GameDetailActivity extends NormalActivity {
|
||||
*/
|
||||
public static void startGameDetailActivity(Context context, String gameId, String entrance, ExposureEvent traceEvent) {
|
||||
|
||||
if (traceEvent != null
|
||||
&& !gameId.equals(traceEvent.getPayload().getGameId())) {
|
||||
// 当游戏 ID 跟曝光 traceEvent 的游戏ID 不一样的时候更新 traceEvent 的游戏ID
|
||||
ExposureEvent forNewPayload = ExposureEvent.Companion.createEvent(new GameEntity(gameId),
|
||||
traceEvent.getSource(),
|
||||
ExposureTraceUtils.INSTANCE.appendTrace(traceEvent),
|
||||
ExposureType.EXPOSURE);
|
||||
traceEvent.setPayload(forNewPayload.getPayload());
|
||||
}
|
||||
|
||||
ExposureEvent clickEvent = ExposureEvent.Companion.createEvent(new GameEntity(gameId), traceEvent.getSource(), ExposureTraceUtils.INSTANCE.appendTrace(traceEvent), ExposureType.CLICK);
|
||||
ExposureManager.INSTANCE.log(clickEvent);
|
||||
|
||||
@ -88,6 +110,17 @@ public class GameDetailActivity extends NormalActivity {
|
||||
context.startActivity(getTargetIntent(context, GameDetailActivity.class, GameDetailFragment.class, bundle));
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果存在多个游戏平台则打开
|
||||
*/
|
||||
public static void startGameDetailActivityByVote(Context context, String gameId, String entrance) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(EntranceUtils.KEY_GAMEID, gameId);
|
||||
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
|
||||
bundle.putBoolean(EntranceUtils.KEY_OPEN_PLATFORM_WINDOW, true);
|
||||
context.startActivity(getTargetIntent(context, GameDetailActivity.class, GameDetailFragment.class, bundle));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (Jzvd.backPress()) {
|
||||
|
||||
@ -70,10 +70,12 @@ public class InstallActivity extends BaseActivity implements InstallFragmentAdap
|
||||
if (locationList != null && locationList.size() != 0) {
|
||||
GameEntity gameEntity;
|
||||
for (int location : locationList) {
|
||||
gameEntity = mAdapter.getGameList().get(location);
|
||||
if (gameEntity != null) {
|
||||
DownloadItemUtils.processDate(InstallActivity.this, gameEntity,
|
||||
downloadEntity, mAdapter, location);
|
||||
if (location < mAdapter.getGameList().size()) {
|
||||
gameEntity = mAdapter.getGameList().get(location);
|
||||
if (gameEntity != null) {
|
||||
DownloadItemUtils.processDate(InstallActivity.this, gameEntity,
|
||||
downloadEntity, mAdapter, location);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,6 +13,8 @@ import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.ethanhua.skeleton.Skeleton;
|
||||
import com.ethanhua.skeleton.ViewSkeletonScreen;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.base.OnRequestCallBackListener;
|
||||
import com.gh.common.util.ApkActiveUtils;
|
||||
@ -75,6 +77,10 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
|
||||
LinearLayout mNoneData;
|
||||
@BindView(R.id.detail_progressbar)
|
||||
DownloadProgressBar mDownloadPb;
|
||||
@BindView(R.id.list_skeleton)
|
||||
View mListSkeleton;
|
||||
|
||||
private ViewSkeletonScreen mSkeleton;
|
||||
|
||||
private LibaoDetailAdapter mAdapter;
|
||||
|
||||
@ -174,6 +180,7 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
|
||||
|
||||
mIsScroll = true;
|
||||
|
||||
mSkeleton = Skeleton.bind(mListSkeleton).shimmer(false).load(R.layout.activity_libaodetail_skeleton).show();
|
||||
mAdapter = new LibaoDetailAdapter(this, this, this, mLibaoEntity, mDownloadPb, mEntrance);
|
||||
mLibaoDetailRv.setLayoutManager(new LinearLayoutManager(this) {
|
||||
@Override
|
||||
@ -184,13 +191,11 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
|
||||
mLibaoDetailRv.addItemDecoration(new VerticalItemDecoration(this, 8, true));
|
||||
mLibaoDetailRv.setAdapter(mAdapter);
|
||||
|
||||
mNoConnection.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mNoConnection.setVisibility(View.GONE);
|
||||
mLlLoading.setVisibility(View.VISIBLE);
|
||||
mBaseHandler.postDelayed(() -> getGameDigest(), 1000);
|
||||
}
|
||||
mNoConnection.setOnClickListener(v -> {
|
||||
mSkeleton.show();
|
||||
mNoConnection.setVisibility(View.GONE);
|
||||
mLlLoading.setVisibility(View.VISIBLE);
|
||||
mBaseHandler.postDelayed(() -> getGameDigest(), 1000);
|
||||
});
|
||||
|
||||
if (mLibaoEntity == null) {
|
||||
@ -411,6 +416,8 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
|
||||
|
||||
checkLibaoStatus();
|
||||
}
|
||||
|
||||
mSkeleton.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -428,6 +435,8 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
|
||||
mLlLoading.setVisibility(View.GONE);
|
||||
mLibaoDetailRv.setPadding(0, 0, 0, 0);
|
||||
mNoConnection.setVisibility(View.VISIBLE);
|
||||
|
||||
mSkeleton.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -442,6 +451,8 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
|
||||
} else {
|
||||
mNoneDataTv.setText("天了噜~页面不见了");
|
||||
}
|
||||
|
||||
mSkeleton.hide();
|
||||
}
|
||||
|
||||
// 领取/淘号失败,根据返回的时间重新倒数
|
||||
|
||||
@ -48,6 +48,7 @@ import com.gh.common.util.MtaHelper;
|
||||
import com.gh.common.util.NetworkUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.common.util.ThirdPartyPackageHelper;
|
||||
import com.gh.common.util.UrlFilterUtils;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.download.DownloadNotification;
|
||||
@ -261,6 +262,7 @@ public class MainActivity extends BaseActivity {
|
||||
if (isNewFirstLaunch) {
|
||||
LogUtils.uploadDevice(DeviceTokenUtils.getLaunchType());
|
||||
getPluginUpdate();
|
||||
sendActivationInfo();
|
||||
mSp.edit().putBoolean("isNewFirstLaunchV" + PackageUtils.getVersionName(), false).apply();
|
||||
|
||||
checkDevice(); // 根据设备信息判断用户是否是新用户
|
||||
@ -277,9 +279,9 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
mPackageViewModel = ViewModelProviders.of(this, new PackageViewModel.Factory()).get(PackageViewModel.class);
|
||||
|
||||
final String message = Config.getExceptionMsg(this);
|
||||
final String message = Config.getExceptionMsg();
|
||||
if (!TextUtils.isEmpty(message)) {
|
||||
Config.setExceptionMsg(this, null);
|
||||
Config.setExceptionMsg(null);
|
||||
AppUncaughtHandler.reportException(this, new Throwable(message));
|
||||
DialogUtils.showWarningDialog(this, "发生闪退", "光环助手刚刚发生了闪退,马上反馈以帮助我们更好地修复问题?(只需简单描述你刚才的操作)"
|
||||
, "暂不", "马上反馈",
|
||||
@ -332,6 +334,13 @@ public class MainActivity extends BaseActivity {
|
||||
return intent;
|
||||
}
|
||||
|
||||
private void sendActivationInfo() {
|
||||
RetrofitManager.getInstance(this)
|
||||
.getApi().postBaiduActivationInfo()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(new Response<>());
|
||||
}
|
||||
|
||||
private void doSkip() {
|
||||
handler.postDelayed(() -> {
|
||||
isSkipped = true;
|
||||
@ -420,7 +429,11 @@ public class MainActivity extends BaseActivity {
|
||||
"网络状态", DeviceUtils.getNetwork(HaloApp.getInstance().getApplication()));
|
||||
}
|
||||
|
||||
ExposureUtils.logADownloadCompleteExposureEvent(new GameEntity(downloadEntity.getGameId()), downloadEntity.getPlatform(), downloadEntity.getExposureTrace(), type);
|
||||
ExposureUtils.logADownloadCompleteExposureEvent(
|
||||
new GameEntity(downloadEntity.getGameId(), downloadEntity.getName()),
|
||||
downloadEntity.getPlatform(),
|
||||
downloadEntity.getExposureTrace(),
|
||||
type);
|
||||
|
||||
DataCollectionUtils.uploadDownload(this, downloadEntity, "完成");
|
||||
}
|
||||
@ -537,11 +550,11 @@ public class MainActivity extends BaseActivity {
|
||||
// 意见反馈
|
||||
SharedPreferences.Editor edit = mSp.edit();
|
||||
edit.putString(SuggestionActivity.SUGGESTION_HINT_TYPE,
|
||||
GsonUtils.Companion.getInstance().toJson(response.getSuggestion()));
|
||||
GsonUtils.toJson(response.getSuggestion()));
|
||||
edit.apply();
|
||||
|
||||
if (!mSp.getBoolean("isFixDownload", false) && Config.isShow()) {
|
||||
mSp.edit().putBoolean("isFixDownload", true).apply();
|
||||
if (!mSp.getBoolean(Config.FIX_DOWNLOAD_KEY, false) && Config.isShow()) {
|
||||
mSp.edit().putBoolean(Config.FIX_DOWNLOAD_KEY, true).apply();
|
||||
}
|
||||
|
||||
EventBus.getDefault().post(new EBReuse("Refresh"));
|
||||
@ -769,6 +782,12 @@ public class MainActivity extends BaseActivity {
|
||||
"操作", "安装完成",
|
||||
"网络状态", DeviceUtils.getNetwork(HaloApp.getInstance().getApplication()));
|
||||
}
|
||||
|
||||
// 没有光环 ID 的都记录一下游戏 ID,供'我的游戏'区分同包名不同插件用
|
||||
Object gh_id = PackageUtils.getMetaData(this, mDownloadEntity.getPackageName(), "gh_id");
|
||||
if (gh_id == null) {
|
||||
ThirdPartyPackageHelper.saveGameId(mDownloadEntity.getPackageName(), mDownloadEntity.getGameId());
|
||||
}
|
||||
DownloadManager.getInstance(getApplicationContext()).cancel(
|
||||
mDownloadEntity.getUrl(), false); // 默认不删除安装包 mSp.getBoolean("autodelete", true)
|
||||
}
|
||||
@ -786,7 +805,7 @@ public class MainActivity extends BaseActivity {
|
||||
for (GameDigestEntity gameDigestEntity : response) {
|
||||
if (!TextUtils.isEmpty(gameDigestEntity.getId())) { // 关注游戏
|
||||
if (finalDownloadEntity != null && gameDigestEntity.getId().equals(finalDownloadEntity.getGameId())) {
|
||||
ConcernUtils.INSTANCE.postConcernGameId(MainActivity.this, gameDigestEntity.getId(), null);
|
||||
ConcernUtils.INSTANCE.postConcernGameId(MainActivity.this, gameDigestEntity.getId(), null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.View
|
||||
import com.gh.base.BaseActivity
|
||||
import com.gh.common.util.DataUtils
|
||||
import com.gh.common.util.EntranceUtils
|
||||
import com.gh.common.util.StringUtils
|
||||
@ -144,7 +145,7 @@ class PersonalHomeActivity : ListActivity<PersonalHistoryEntity, PersonalHomeVie
|
||||
val intent = Intent(context, PersonalHomeActivity::class.java)
|
||||
intent.putExtra(EntranceUtils.KEY_USER_ID, userId)
|
||||
intent.putExtra(EntranceUtils.KEY_PATH, path)
|
||||
intent.putExtra(EntranceUtils.KEY_ENTRANCE, "$entrance+($path)")
|
||||
intent.putExtra(EntranceUtils.KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,12 +19,14 @@ import com.gh.base.BaseActivity;
|
||||
import com.gh.common.util.DataCollectionUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.GdtHelper;
|
||||
import com.gh.common.util.TextHelper;
|
||||
import com.gh.gamecenter.db.SearchHistoryDao;
|
||||
import com.gh.gamecenter.eventbus.EBSearch;
|
||||
import com.gh.gamecenter.search.SearchGameDetailFragment;
|
||||
import com.gh.gamecenter.search.SearchGameListFragment;
|
||||
import com.gh.gamecenter.search.SearchHistoryFragment;
|
||||
import com.lightgame.utils.Util_System_Keyboard;
|
||||
import com.lightgame.utils.Utils;
|
||||
import com.qq.gdt.action.ActionType;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@ -177,6 +179,9 @@ public class SearchActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
});
|
||||
TextHelper.limitTheLengthOfEditText(searchInput, 50, () -> {
|
||||
Utils.toast(searchInput.getContext(), "最多输入50个字");
|
||||
});
|
||||
|
||||
findViewById(R.id.btnGoBack).setOnClickListener(v -> finish());
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ public class SkipActivity extends BaseActivity {
|
||||
case HOST_SUGGESTION:
|
||||
String platform = uri.getQueryParameter(KEY_PLATFORM);
|
||||
String platformName = PlatformUtils.getInstance(this).getPlatformName(platform);
|
||||
String content = String.format("【%s-%s-V%s】",
|
||||
String content = String.format("%s-%s-V%s,",
|
||||
uri.getQueryParameter(KEY_GAME_NAME),
|
||||
TextUtils.isEmpty(platformName) ? platform : platformName,
|
||||
uri.getQueryParameter(KEY_VERSION));
|
||||
|
||||
@ -25,6 +25,7 @@ import com.gh.common.exposure.meta.MetaUtil;
|
||||
import com.gh.common.util.DeviceTokenUtils;
|
||||
import com.gh.common.util.DeviceUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.GameRepositoryHelper;
|
||||
import com.gh.common.util.GdtHelper;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
@ -210,6 +211,8 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
if (hasFocus && isFirst) {
|
||||
isFirst = false;
|
||||
|
||||
GameRepositoryHelper.getGameRepository(this);
|
||||
|
||||
HaloApp.getInstance().getMainExecutor().execute(() -> {
|
||||
// 第一次启动,把package.txt文件内容加载进数据库
|
||||
FilterManager filterManager = new FilterManager(getApplicationContext());
|
||||
|
||||
@ -128,6 +128,12 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
TextView mEmailName;
|
||||
@BindView(R.id.tv_ad)
|
||||
TextView mAdTv;
|
||||
@BindView(R.id.suggest_platform_container)
|
||||
View mPlatformContainer;
|
||||
@BindView(R.id.suggest_platform_et)
|
||||
TextView mPlatformEt;
|
||||
@BindView(R.id.suggest_platform_title)
|
||||
TextView mPlatformTitle;
|
||||
|
||||
public static final int MEDIA_STORE_REQUEST = 1;
|
||||
public static final String SUGGESTION_HINT_TYPE = "SUGGESTION_HINT_TYPE";
|
||||
@ -146,6 +152,7 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
private String mGameInfo;
|
||||
private String mHideHint;
|
||||
private String mSuggestContent;
|
||||
private String mSuggestHintType;
|
||||
|
||||
private boolean mAgreePostPic;
|
||||
|
||||
@ -226,7 +233,7 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
mSuggestType = SuggestType.normal;
|
||||
}
|
||||
mSuggestContent = extras.getString(EntranceUtils.KEY_CONTENT);
|
||||
String suggestHintType = extras.getString(EntranceUtils.KEY_SUGGEST_HINT_TYPE);
|
||||
mSuggestHintType = extras.getString(EntranceUtils.KEY_SUGGEST_HINT_TYPE);
|
||||
mHideHint = extras.getString(EntranceUtils.KEY_HIDE_SUGGEST_HINT, "");
|
||||
mFunctionTypeName = getResources().getStringArray(R.array.suggest_function_type);
|
||||
|
||||
@ -258,19 +265,26 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
mSuggestPicRv.setAdapter(mAdapter);
|
||||
|
||||
if (!TextUtils.isEmpty(mSuggestContent)) {
|
||||
mSuggestContentEt.setText(mSuggestContent);
|
||||
if (mSuggestType == SuggestType.gameQuestion && "game".equals(mSuggestHintType)) {
|
||||
mSuggestContentEt.setText("问题反馈:");
|
||||
mSuggestSelectGame.setVisibility(View.GONE);
|
||||
mSuggestGameName.setVisibility(View.VISIBLE);
|
||||
mSuggestGameName.setText(mSuggestContent);
|
||||
} else {
|
||||
mSuggestContentEt.setText(mSuggestContent);
|
||||
}
|
||||
mSuggestContentEt.setSelection(mSuggestContentEt.getText().length());
|
||||
}
|
||||
|
||||
initSuggest(mSuggestType);
|
||||
|
||||
String suggestionType = sp.getString(SUGGESTION_HINT_TYPE, null);
|
||||
if (!TextUtils.isEmpty(suggestHintType) && !TextUtils.isEmpty(suggestionType)) {
|
||||
if (!TextUtils.isEmpty(mSuggestHintType) && !TextUtils.isEmpty(suggestionType)) {
|
||||
Gson gson = new Gson();
|
||||
SuggestionTypeEntity typeEntity = gson.fromJson(suggestionType, SuggestionTypeEntity.class);
|
||||
if (typeEntity != null) {
|
||||
switch (suggestHintType) {
|
||||
case "plugin":
|
||||
switch (mSuggestHintType) {
|
||||
case EntranceUtils.KEY_PLUGIN:
|
||||
List<String> plugin = typeEntity.getPlugin();
|
||||
if (plugin != null && plugin.size() > 0) {
|
||||
showHintDialog(plugin);
|
||||
@ -335,14 +349,23 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
mSuggestTypeContainer.setVisibility(View.GONE);
|
||||
mSuggestGameLl.setVisibility(View.GONE);
|
||||
} else if (type == SuggestType.gameQuestion) {
|
||||
mSuggestContentEt.setHint("请写上游戏名字,以及具体遇到的问题... \n ↓↓你还可以上传截图");
|
||||
mSuggestTypeContainer.setVisibility(View.GONE);
|
||||
mSuggestGameLl.setVisibility(View.GONE);
|
||||
if (!EntranceUtils.KEY_PLUGIN.equals(mSuggestHintType)) {
|
||||
mSuggestContentEt.setHint("请描述具体遇到的问题... \n ↓↓你还可以上传截图");
|
||||
mSuggestGameLl.setVisibility(View.VISIBLE);
|
||||
mPlatformContainer.setVisibility(View.VISIBLE);
|
||||
mGameNameTitle.setText(Html.fromHtml(getString(R.string.suggestion_game_name)));
|
||||
mPlatformTitle.setText(Html.fromHtml(getString(R.string.suggestion_platform_name)));
|
||||
} else {
|
||||
mSuggestContentEt.setHint("请写上游戏名字,以及具体遇到的问题... \n ↓↓你还可以上传截图");
|
||||
mSuggestGameLl.setVisibility(View.GONE);
|
||||
mPlatformContainer.setVisibility(View.GONE);
|
||||
}
|
||||
} else if (type == SuggestType.gameCollect) {
|
||||
mSuggestGameLl.setVisibility(View.VISIBLE);
|
||||
mGameNameTitle.setText(Html.fromHtml(getString(R.string.suggestion_game_name)));
|
||||
mSuggestTypeContainer.setVisibility(View.GONE);
|
||||
mSuggestContentEt.setHint("你想收录哪个游戏或游戏版本... \n ↓↓你还可以上传截图");
|
||||
mSuggestContentEt.setHint("请在上方选择或填写游戏名↑↑ \n 在此处可输入补充信息(例如游戏的平台版本等)");
|
||||
mEmailName.setText(Html.fromHtml(getString(R.string.suggestion_contact)));
|
||||
} else if (type == SuggestType.functionSuggest) {
|
||||
mSuggestContentEt.setHint("请详细描述你的建议... \n ↓↓你还可以上传截图");
|
||||
@ -456,6 +479,12 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
}
|
||||
}
|
||||
|
||||
if (mPlatformContainer.getVisibility() == View.VISIBLE &&
|
||||
TextUtils.isEmpty(mPlatformEt.getText().toString())) {
|
||||
toast("请填写版本");
|
||||
return;
|
||||
}
|
||||
|
||||
String entrance = "我的光环-反馈-[提交]";
|
||||
if (!TextUtils.isEmpty(mSuggestContent)) {
|
||||
switch (mSuggestContent) {
|
||||
@ -470,25 +499,14 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
break;
|
||||
}
|
||||
}
|
||||
CheckLoginUtils.checkLogin(this, entrance, () -> {
|
||||
if (TextUtils.isEmpty(email)) {
|
||||
if (mSuggestType == SuggestType.functionSuggest || mSuggestType == SuggestType.gameCollect) {
|
||||
toast("请填写联系方式");
|
||||
} else {
|
||||
showConfirmDialog(email);
|
||||
}
|
||||
} else {
|
||||
postDialog = WaitingDialogFragment.newInstance(getString(R.string.dialog_feedback_doing));
|
||||
postDialog.show(getSupportFragmentManager(), null);
|
||||
|
||||
List<String> fileList = mAdapter.getFileList();
|
||||
if (fileList != null && fileList.size() > 0) {
|
||||
postPic(email);
|
||||
} else {
|
||||
initPostData(email, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
// 闪退反馈不需要反馈(由闪退提示框跳转)
|
||||
if (mSuggestType == SuggestType.crash && !mHideHint.isEmpty()) {
|
||||
postSuggestion(email);
|
||||
} else {
|
||||
CheckLoginUtils.checkLogin(this, entrance, () -> {
|
||||
postSuggestion(email);
|
||||
});
|
||||
}
|
||||
break;
|
||||
case R.id.suggest_game_container:
|
||||
showSelectDialog();
|
||||
@ -528,6 +546,26 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
}
|
||||
}
|
||||
|
||||
private void postSuggestion(String email) {
|
||||
if (TextUtils.isEmpty(email)) {
|
||||
if (mSuggestType == SuggestType.functionSuggest || mSuggestType == SuggestType.gameCollect) {
|
||||
toast("请填写联系方式");
|
||||
} else {
|
||||
showConfirmDialog(email);
|
||||
}
|
||||
} else {
|
||||
postDialog = WaitingDialogFragment.newInstance(getString(R.string.dialog_feedback_doing));
|
||||
postDialog.show(getSupportFragmentManager(), null);
|
||||
|
||||
List<String> fileList = mAdapter.getFileList();
|
||||
if (fileList != null && fileList.size() > 0) {
|
||||
postPic(email);
|
||||
} else {
|
||||
initPostData(email, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 弹出确认对话框
|
||||
private void showConfirmDialog(final String email) {
|
||||
|
||||
@ -598,8 +636,9 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
|
||||
params.put("suggestion_type", mSuggestType.getType());
|
||||
String message;
|
||||
String content = mSuggestContentEt.getText().toString().trim();
|
||||
if (mSuggestType == SuggestType.gameCollect) {
|
||||
message = mGameInfo + "," + mSuggestContentEt.getText().toString().trim();
|
||||
message = mGameInfo + "," + content;
|
||||
} else if (mSuggestType == SuggestType.functionSuggest) {
|
||||
String typeName;
|
||||
if (mFunctionType == 3) {
|
||||
@ -607,9 +646,15 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
} else {
|
||||
typeName = mFunctionTypeName[mFunctionType];
|
||||
}
|
||||
message = mGameInfo + "," + typeName + "," + mSuggestContentEt.getText().toString().trim();
|
||||
message = mGameInfo + "," + typeName + "," + content;
|
||||
} else if (mSuggestType == SuggestType.gameQuestion) {
|
||||
if (EntranceUtils.KEY_PLUGIN.equals(mSuggestHintType)) {
|
||||
message = "【插件问题】" + content;
|
||||
} else {
|
||||
message = mSuggestGameName.getText() + "-" + mPlatformEt.getText() + "," + content;
|
||||
}
|
||||
} else {
|
||||
message = mSuggestContentEt.getText().toString().trim();
|
||||
message = content;
|
||||
if (mSuggestType == SuggestType.crash) {
|
||||
params.put("log", readFromFile());
|
||||
}
|
||||
@ -632,9 +677,11 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
|
||||
sendSuggestion(body);
|
||||
|
||||
// 创建一条信息至七陌客服
|
||||
String feedbackType = "意见反馈-" + mSuggestType.getType();
|
||||
ImManager.sendFeedbackMessage(feedbackType + ": " + message);
|
||||
if (CheckLoginUtils.isLogin()) {
|
||||
// 创建一条信息至七陌客服
|
||||
String feedbackType = "意见反馈-" + mSuggestType.getType();
|
||||
ImManager.sendFeedbackMessage(feedbackType + ": " + message);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendSuggestion(final RequestBody body) {
|
||||
|
||||
@ -17,7 +17,7 @@ public class UserInfoEditActivity extends NormalActivity {
|
||||
@NonNull
|
||||
public static Intent getIntent(Context context, String editType) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(UserViewModel.KEY_EDITTYPE, editType);
|
||||
args.putString(UserViewModel.KEY_EDIT_TYPE, editType);
|
||||
return getTargetIntent(context, UserInfoEditActivity.class, UserInfoEditFragment.class, args);
|
||||
}
|
||||
|
||||
|
||||
@ -338,7 +338,10 @@ public class ViewImageActivity extends BaseActivity implements OnPageChangeListe
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(container1);
|
||||
dialog.show();
|
||||
|
||||
if (!isFinishing()) {
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
reportTv.setOnClickListener(v -> {
|
||||
findImageBM();
|
||||
|
||||
@ -161,8 +161,10 @@ public class CommentDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
String content;
|
||||
if (parent.getActive()) {
|
||||
content = parent.getComment();
|
||||
holder.quoteContentTv.setTextColor(mContext.getResources().getColor(R.color.text_5d5d5d));
|
||||
} else {
|
||||
content = mContext.getString(R.string.comment_hide_hint);
|
||||
holder.quoteContentTv.setTextColor(mContext.getResources().getColor(R.color.text_d5d5d5));
|
||||
}
|
||||
holder.quoteContentTv.setText(content);
|
||||
} else {
|
||||
|
||||
@ -16,6 +16,7 @@ import com.gh.common.util.DataCollectionUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.NewsUtils;
|
||||
import com.gh.common.util.StringUtils;
|
||||
import com.gh.common.util.TextHelper;
|
||||
import com.gh.common.util.UrlFilterUtils;
|
||||
import com.gh.gamecenter.NewsDetailActivity;
|
||||
import com.gh.gamecenter.NewsSearchActivity;
|
||||
@ -249,6 +250,10 @@ public class GameNewsAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
TextHelper.limitTheLengthOfEditText(searchViewHolder.searchEt, 50, () -> {
|
||||
Utils.toast(searchViewHolder.searchEt.getContext(), "最多输入50个字");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.support.v7.widget.RecyclerView.ViewHolder;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
@ -23,6 +24,7 @@ import com.gh.common.util.GameViewUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.common.util.ThirdPartyPackageHelper;
|
||||
import com.gh.common.view.SwipeLayout;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.GameDetailActivity;
|
||||
@ -101,6 +103,11 @@ public class InstallFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
Object gh_id = PackageUtils.getMetaData(mContext, gameInstall.getPackageName(), "gh_id");
|
||||
if (gh_id != null && !gh_id.equals(gameInstall.getId())) {
|
||||
gameInstall.setId(gh_id.toString());
|
||||
} else {
|
||||
String gameId = ThirdPartyPackageHelper.getGameId(gameInstall.getPackageName());
|
||||
if (!TextUtils.isEmpty(gameId)) {
|
||||
gameInstall.setId(gameId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,7 +305,7 @@ public class InstallFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
private void initGameNormal(final GameNormalSwipeViewHolder holder, final GameEntity gameEntity, final int i) {
|
||||
|
||||
gameEntity.setCollection(new ArrayList<>()); // 清空集合,防止下载按钮会因为存在集合而清空合集包的状态判断
|
||||
holder.initServerType(gameEntity, mContext);
|
||||
holder.initServerType(gameEntity);
|
||||
|
||||
holder.swipeText.setPadding(0, 0, DisplayUtils.dip2px(mContext, 15), 0);
|
||||
String name;
|
||||
|
||||
@ -368,8 +368,10 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
String content;
|
||||
if (parent.getActive()) {
|
||||
content = parent.getComment();
|
||||
holder.quoteContentTv.setTextColor(mContext.getResources().getColor(R.color.text_5d5d5d));
|
||||
} else {
|
||||
content = mContext.getString(R.string.comment_hide_hint);
|
||||
holder.quoteContentTv.setTextColor(mContext.getResources().getColor(R.color.text_d5d5d5));
|
||||
}
|
||||
holder.quoteContentTv.setText(content);
|
||||
} else {
|
||||
@ -411,7 +413,7 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
holder.commentUserNameTv.setOnClickListener(v -> PersonalHomeActivity.startTargetActivity(mContext, finalCommentEntity.getUser().getId(), mEntrance, "文章-评论详情"));
|
||||
holder.commentUserIconDv.setOnClickListener(v -> PersonalHomeActivity.startTargetActivity(mContext, finalCommentEntity.getUser().getId(), mEntrance, "文章-评论详情"));
|
||||
|
||||
if (commentEntity.getPriority() != 0 && !isHotComment) {
|
||||
if (commentEntity.getPriority() != 0) {
|
||||
holder.commentBadge.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.commentBadge.setVisibility(View.GONE);
|
||||
|
||||
@ -17,6 +17,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.exposure.ExposureEvent;
|
||||
import com.gh.common.exposure.ExposureUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
@ -25,6 +26,7 @@ import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DirectUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.PackageHelper;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.download.DownloadManager;
|
||||
@ -39,6 +41,7 @@ import com.gh.gamecenter.entity.CollectionCloseEntity;
|
||||
import com.gh.gamecenter.entity.GameCollectionEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.PluginLocation;
|
||||
import com.gh.gamecenter.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter;
|
||||
@ -120,65 +123,59 @@ public class PlatformAdapter extends BaseRecyclerAdapter<PlatformViewHolder> {
|
||||
viewHolder.mDownloadItemTvStatus.setVisibility(View.GONE);
|
||||
ImageUtils.display(viewHolder.mDownloadItemIvPic, R.drawable.platform_vote);
|
||||
viewHolder.itemView.setBackgroundDrawable(new ColorDrawable(0));
|
||||
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = VoteActivity.getIntent(mContext, mGameEntity.getName(), mGameEntity.getId());
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
viewHolder.itemView.setOnClickListener(v -> {
|
||||
Intent intent = VoteActivity.getIntent(mContext, mGameEntity.getName(), mGameEntity.getId());
|
||||
mContext.startActivity(intent);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (apkEntity.getApkCollection() == null) {
|
||||
// 非合集
|
||||
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ApkLink apkLink = apkEntity.getApkLink();
|
||||
if (apkLink != null) {
|
||||
String entrance = mEntrance + "(" + apkLink.getName() + ")";
|
||||
DirectUtils.directToLinkPage(mContext, apkLink.getLinkEntity(), entrance, "下载多平台弹窗");
|
||||
} else if (viewHolder.mDownloadItemTvStatus.getVisibility() == View.GONE) {
|
||||
//下载游戏
|
||||
DialogUtils.checkDownload(mContext, apkEntity.getSize(),
|
||||
isSubscribe -> download(apkEntity, viewHolder.mDownloadItemTvStatus, "下载", isSubscribe));
|
||||
} else {
|
||||
String status = viewHolder.mDownloadItemTvStatus.getText().toString();
|
||||
switch (status) {
|
||||
case "下载中":
|
||||
case "等待中":
|
||||
case "插件化下载中":
|
||||
case "更新下载中":
|
||||
case "插件化等待中":
|
||||
case "更新等待中":
|
||||
// 打开下载管理界面
|
||||
mContext.startActivity(DownloadManagerActivity.getDownloadMangerIntent(mContext, apkEntity.getUrl()
|
||||
, mEntrance + "(" + mLocation.split(":")[0] + ")"));
|
||||
break;
|
||||
case "已安装":
|
||||
case "启动":
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
kv.put("版本", apkEntity.getPlatform());
|
||||
DataUtils.onEvent(mContext, "游戏启动", mGameEntity.getName(), kv);
|
||||
viewHolder.itemView.setOnClickListener(v -> {
|
||||
ApkLink apkLink = apkEntity.getApkLink();
|
||||
if (apkLink != null) {
|
||||
String entrance = mEntrance + "(" + apkLink.getName() + ")";
|
||||
DirectUtils.directToLinkPage(mContext, apkLink.getLinkEntity(), entrance, "下载多平台弹窗");
|
||||
} else if (viewHolder.mDownloadItemTvStatus.getVisibility() == View.GONE) {
|
||||
//下载游戏
|
||||
DialogUtils.checkDownload(mContext, apkEntity.getSize(),
|
||||
isSubscribe -> download(apkEntity, viewHolder.mDownloadItemTvStatus, "下载", isSubscribe));
|
||||
} else {
|
||||
String status = viewHolder.mDownloadItemTvStatus.getText().toString();
|
||||
switch (status) {
|
||||
case "下载中":
|
||||
case "等待中":
|
||||
case "插件化下载中":
|
||||
case "更新下载中":
|
||||
case "插件化等待中":
|
||||
case "更新等待中":
|
||||
// 打开下载管理界面
|
||||
mContext.startActivity(DownloadManagerActivity.getDownloadMangerIntent(mContext, apkEntity.getUrl()
|
||||
, mEntrance + "(" + mLocation.split(":")[0] + ")"));
|
||||
break;
|
||||
case "已安装":
|
||||
case "启动":
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
kv.put("版本", apkEntity.getPlatform());
|
||||
DataUtils.onEvent(mContext, "游戏启动", mGameEntity.getName(), kv);
|
||||
|
||||
PackageUtils.launchApplicationByPackageName(mContext, apkEntity.getPackageName());
|
||||
break;
|
||||
case "安装":
|
||||
case "安装更新":
|
||||
install(apkEntity, viewHolder.getAdapterPosition());
|
||||
break;
|
||||
case "插件化":
|
||||
DialogUtils.checkDownload(mContext, apkEntity.getSize(),
|
||||
isSubscribe -> download(apkEntity, viewHolder.mDownloadItemTvStatus, "插件化", isSubscribe));
|
||||
break;
|
||||
case "安装插件":
|
||||
showPluginDialog(apkEntity, PlatformAdapter.this, viewHolder.getAdapterPosition());
|
||||
break;
|
||||
case "更新":
|
||||
DialogUtils.checkDownload(mContext, apkEntity.getSize(), isSubscribe -> update(apkEntity, isSubscribe));
|
||||
break;
|
||||
}
|
||||
PackageUtils.launchApplicationByPackageName(mContext, apkEntity.getPackageName());
|
||||
break;
|
||||
case "安装":
|
||||
case "安装更新":
|
||||
install(apkEntity, viewHolder.getAdapterPosition());
|
||||
break;
|
||||
case "插件化":
|
||||
DialogUtils.checkDownload(mContext, apkEntity.getSize(),
|
||||
isSubscribe -> download(apkEntity, viewHolder.mDownloadItemTvStatus, "插件化", isSubscribe));
|
||||
break;
|
||||
case "安装插件":
|
||||
showPluginDialog(apkEntity, PlatformAdapter.this, viewHolder.getAdapterPosition());
|
||||
break;
|
||||
case "更新":
|
||||
DialogUtils.checkDownload(mContext, apkEntity.getSize(), isSubscribe -> update(apkEntity, isSubscribe));
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -194,7 +191,7 @@ public class PlatformAdapter extends BaseRecyclerAdapter<PlatformViewHolder> {
|
||||
viewHolder.itemView.setBackgroundDrawable(new ColorDrawable(0));
|
||||
} else {
|
||||
Object gh_id = PackageUtils.getMetaData(mContext, apkEntity.getPackageName(), "gh_id");
|
||||
if (PackagesManager.INSTANCE.isInstalled(apkEntity.getPackageName())
|
||||
if (PackageHelper.INSTANCE.getLocalPackageNameSet().contains(apkEntity.getPackageName())
|
||||
&& (gh_id == null || gh_id.equals(mGameEntity.getId()))) {
|
||||
// 已安装
|
||||
viewHolder.mDownloadItemIvPic.setVisibility(View.GONE);
|
||||
@ -233,7 +230,16 @@ public class PlatformAdapter extends BaseRecyclerAdapter<PlatformViewHolder> {
|
||||
} else if (PackagesManager.INSTANCE.isCanUpdate(mGameEntity.getId(), apkEntity.getPackageName())) {
|
||||
viewHolder.mDownloadItemTvStatus.setText(R.string.update);
|
||||
} else {
|
||||
if (mOnCollectionCallBackListener == null) {
|
||||
boolean isFilter = false;
|
||||
SettingsEntity settings = Config.getSettings();
|
||||
if (settings != null) {
|
||||
for (String pkgName : settings.getGameDownloadBlackList()) {
|
||||
if (pkgName.equals(apkEntity.getPackageName())) {
|
||||
isFilter = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isFilter) {
|
||||
viewHolder.mDownloadItemTvStatus.setText("已安装");
|
||||
} else {
|
||||
viewHolder.mDownloadItemTvStatus.setText(R.string.launch);
|
||||
@ -342,32 +348,29 @@ public class PlatformAdapter extends BaseRecyclerAdapter<PlatformViewHolder> {
|
||||
viewHolder.mDownloadItemOpenCollection.setVisibility(View.VISIBLE);
|
||||
viewHolder.mDownloadItemColseCollection.setVisibility(View.GONE);
|
||||
}
|
||||
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (viewHolder.mDownloadItemOpenCollection.getVisibility() == View.VISIBLE) {
|
||||
if (mOnCollectionCallBackListener != null) {
|
||||
mOnCollectionCallBackListener.showCollection(apkEntity.getApkCollection());
|
||||
}
|
||||
mCloseEntity.setPosition(viewHolder.getAdapterPosition());
|
||||
mCloseEntity.setAdapterPosition(mAdapterPosition);
|
||||
for (int[] ints : mCloseEntity.getList()) {
|
||||
mAdapterMap.get(ints[0]).notifyItemChanged(ints[1]);
|
||||
}
|
||||
mCloseEntity.getList().clear();
|
||||
int[] arrCollectionPosition = {mAdapterPosition, viewHolder.getAdapterPosition()};
|
||||
mCloseEntity.getList().add(arrCollectionPosition);
|
||||
viewHolder.mDownloadItemOpenCollection.setVisibility(View.GONE);
|
||||
viewHolder.mDownloadItemColseCollection.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (mOnCollectionCallBackListener != null) {
|
||||
mOnCollectionCallBackListener.hideCollection();
|
||||
}
|
||||
mCloseEntity.setPosition(-1);
|
||||
mCloseEntity.setAdapterPosition(-1);
|
||||
viewHolder.mDownloadItemOpenCollection.setVisibility(View.VISIBLE);
|
||||
viewHolder.mDownloadItemColseCollection.setVisibility(View.GONE);
|
||||
viewHolder.itemView.setOnClickListener(v -> {
|
||||
if (viewHolder.mDownloadItemOpenCollection.getVisibility() == View.VISIBLE) {
|
||||
if (mOnCollectionCallBackListener != null) {
|
||||
mOnCollectionCallBackListener.showCollection(apkEntity.getApkCollection());
|
||||
}
|
||||
mCloseEntity.setPosition(viewHolder.getAdapterPosition());
|
||||
mCloseEntity.setAdapterPosition(mAdapterPosition);
|
||||
for (int[] ints : mCloseEntity.getList()) {
|
||||
mAdapterMap.get(ints[0]).notifyItemChanged(ints[1]);
|
||||
}
|
||||
mCloseEntity.getList().clear();
|
||||
int[] arrCollectionPosition = {mAdapterPosition, viewHolder.getAdapterPosition()};
|
||||
mCloseEntity.getList().add(arrCollectionPosition);
|
||||
viewHolder.mDownloadItemOpenCollection.setVisibility(View.GONE);
|
||||
viewHolder.mDownloadItemColseCollection.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (mOnCollectionCallBackListener != null) {
|
||||
mOnCollectionCallBackListener.hideCollection();
|
||||
}
|
||||
mCloseEntity.setPosition(-1);
|
||||
mCloseEntity.setAdapterPosition(-1);
|
||||
viewHolder.mDownloadItemOpenCollection.setVisibility(View.VISIBLE);
|
||||
viewHolder.mDownloadItemColseCollection.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -11,11 +11,16 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.gh.base.OnRequestCallBackListener;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.gamecenter.GameDetailActivity;
|
||||
import com.gh.gamecenter.NewsDetailActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.VoteViewHolder;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.entity.LinkEntity;
|
||||
import com.gh.gamecenter.entity.MeEntity;
|
||||
import com.gh.gamecenter.entity.VersionVoteEntity;
|
||||
|
||||
@ -62,19 +67,32 @@ public class VoteAdapter extends ListAdapter<VersionVoteEntity> {
|
||||
if (holder instanceof VoteViewHolder) {
|
||||
final VoteViewHolder viewHolder = (VoteViewHolder) holder;
|
||||
VersionVoteEntity versionVoteEntity = mEntityList.get(position);
|
||||
MeEntity userData = versionVoteEntity.getMe();
|
||||
if (userData != null && userData.isVersionRequested()) {
|
||||
viewHolder.voteBtn.setBackgroundResource(R.drawable.border_suggest_bg);
|
||||
viewHolder.voteBtn.setTextColor(ContextCompat.getColor(mContext, R.color.content));
|
||||
viewHolder.voteBtn.setText(R.string.voted);
|
||||
viewHolder.voteBtn.setEnabled(false);
|
||||
if (versionVoteEntity.getOpen()) {
|
||||
MeEntity userData = versionVoteEntity.getMe();
|
||||
if (userData != null && userData.isVersionRequested()) {
|
||||
viewHolder.voteBtn.setBackgroundResource(R.drawable.border_suggest_bg);
|
||||
viewHolder.voteBtn.setTextColor(ContextCompat.getColor(mContext, R.color.content));
|
||||
viewHolder.voteBtn.setText(R.string.voted);
|
||||
viewHolder.voteBtn.setEnabled(false);
|
||||
} else {
|
||||
viewHolder.voteBtn.setBackgroundResource(R.drawable.button_normal_style);
|
||||
viewHolder.voteBtn.setTextColor(Color.WHITE);
|
||||
viewHolder.voteBtn.setText(R.string.vote);
|
||||
viewHolder.voteBtn.setEnabled(true);
|
||||
}
|
||||
} else {
|
||||
LinkEntity link = versionVoteEntity.getLink();
|
||||
if (EntranceUtils.HOST_GAME.equals(link.getType())) {
|
||||
viewHolder.voteBtn.setText(R.string.download);
|
||||
} else {
|
||||
viewHolder.voteBtn.setText(R.string.libao_check);
|
||||
}
|
||||
viewHolder.voteBtn.setBackgroundResource(R.drawable.button_normal_style);
|
||||
viewHolder.voteBtn.setTextColor(Color.WHITE);
|
||||
viewHolder.voteBtn.setText(R.string.vote);
|
||||
viewHolder.voteBtn.setEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
View progressbar = viewHolder.progressbar;
|
||||
ViewGroup.LayoutParams layoutParams = progressbar.getLayoutParams();
|
||||
if (position > 0) {
|
||||
@ -99,7 +117,25 @@ public class VoteAdapter extends ListAdapter<VersionVoteEntity> {
|
||||
viewHolder.count.setText(mContext.getString(R.string.vote_count, versionVoteEntity.getNum()));
|
||||
progressbar.setLayoutParams(layoutParams);
|
||||
|
||||
viewHolder.voteBtn.setOnClickListener(v -> mCallBackListener.loadDone(versionVoteEntity.getId()));
|
||||
viewHolder.voteBtn.setOnClickListener(v -> {
|
||||
if (versionVoteEntity.getOpen()) {
|
||||
mCallBackListener.loadDone(versionVoteEntity.getId());
|
||||
} else {
|
||||
LinkEntity link = versionVoteEntity.getLink();
|
||||
String entrance = "(游戏求版本)";
|
||||
switch (link.getType() == null ? "" : link.getType()) {
|
||||
case EntranceUtils.HOST_GAME:
|
||||
GameDetailActivity.startGameDetailActivityByVote(mContext, link.getLink(), entrance);
|
||||
break;
|
||||
case EntranceUtils.HOST_ARTICLE:
|
||||
mContext.startActivity(NewsDetailActivity.getIntentById(mContext, link.getLink(), entrance));
|
||||
break;
|
||||
default:
|
||||
DialogUtils.showLowVersionDialog(mContext);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (holder instanceof FooterViewHolder) {
|
||||
initFooterViewHolder((FooterViewHolder) holder);
|
||||
}
|
||||
|
||||
@ -86,35 +86,35 @@ public class DetailViewHolder {
|
||||
// 这个 switch 纯粹是为了 MTA 统计用的
|
||||
switch (mViewHolder.mDownloadPb.getDownloadType()) {
|
||||
case DOWNLOADING_PLUGIN:
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情", "插件化中", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情_新", "插件化中", mGameEntity.getName());
|
||||
break;
|
||||
case DOWNLOADING_NORMAL:
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情", "下载中", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情_新", "下载中", mGameEntity.getName());
|
||||
break;
|
||||
case NONE:
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情", "关闭下载", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情_新", "关闭下载", mGameEntity.getName());
|
||||
break;
|
||||
case NORMAL:
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情", "下载", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情_新", "下载", mGameEntity.getName());
|
||||
break;
|
||||
case PLUGIN:
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情", "插件化", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情_新", "插件化", mGameEntity.getName());
|
||||
break;
|
||||
case INSTALL_PLUGIN:
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情", "安装插件化", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情_新", "安装插件化", mGameEntity.getName());
|
||||
break;
|
||||
case INSTALL_NORMAL:
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情", "安装", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情_新", "安装", mGameEntity.getName());
|
||||
break;
|
||||
}
|
||||
// 由于部分状态不包含在 downloadType 里,所以还是需要手动获取下载按钮文字判断点击时的状态
|
||||
String downloadText = mViewHolder.mDownloadPb.getText();
|
||||
if (downloadText.contains("打开")) {
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情", "打开", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情_新", "打开", mGameEntity.getName());
|
||||
} else if (downloadText.contains("启动")) {
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情", "启动", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情_新", "启动", mGameEntity.getName());
|
||||
} else if (downloadText.contains("更新")) {
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情", "更新", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情_新", "更新", mGameEntity.getName());
|
||||
}
|
||||
|
||||
String autoDownloadPlatform = v.getTag() instanceof String ? (String) v.getTag() : "";
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.gh.gamecenter.adapter.viewholder;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
@ -9,7 +8,6 @@ import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.base.BaseRecyclerViewHolder;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.view.DrawableView;
|
||||
import com.gh.gamecenter.databinding.GameItemBinding;
|
||||
import com.gh.gamecenter.entity.ColorEntity;
|
||||
@ -46,8 +44,7 @@ public class GameViewHolder extends BaseRecyclerViewHolder {
|
||||
gameDownloadSpeed = binding.downloadSpeed;
|
||||
}
|
||||
|
||||
public void initServerType(GameEntity gameEntity, Context context) {
|
||||
int paddRight = 0;
|
||||
public void initServerType(GameEntity gameEntity) {
|
||||
ColorEntity serverLabel = gameEntity.getServerLabel();
|
||||
if (gameEntity.getTest() != null) {
|
||||
gameServerType.setVisibility(View.GONE);
|
||||
@ -55,15 +52,12 @@ public class GameViewHolder extends BaseRecyclerViewHolder {
|
||||
gameServerType.setVisibility(View.VISIBLE);
|
||||
gameServerType.setText(serverLabel.getValue());
|
||||
gameServerType.setBackground(DrawableView.getServerDrawable(serverLabel.getColor()));
|
||||
int i;
|
||||
if (serverLabel.getValue().length() <= 2) i = 30;
|
||||
else if (serverLabel.getValue().length() <= 4) i = 50;
|
||||
else i = 60;
|
||||
paddRight = DisplayUtils.dip2px(context, i);
|
||||
} else {
|
||||
gameServerType.setVisibility(View.GONE);
|
||||
}
|
||||
gameName.setPadding(0, 0, paddRight, 0);
|
||||
|
||||
// 由于RecyclerView的复用机制 需要每次测量gameName的宽
|
||||
gameName.requestLayout();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -67,7 +67,8 @@ public abstract class ListViewModel<LD /*ListData*/, ID /*ItemData*/> extends Ba
|
||||
@Override
|
||||
public void onResponse(List<LD> response) {
|
||||
List<LD> previousData = mListLiveData.getValue();
|
||||
if (previousData == null || mCurLoadParams.getLoadOffset() == LoadParams.DEFAULT_OFFSET) {
|
||||
if (previousData == null || mCurLoadParams.getLoadOffset() == LoadParams.DEFAULT_OFFSET ||
|
||||
curStatus == LoadStatus.INIT) {
|
||||
previousData = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
@ -5,16 +5,28 @@ import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.View
|
||||
import com.ethanhua.skeleton.Skeleton
|
||||
import com.ethanhua.skeleton.ViewSkeletonScreen
|
||||
import com.gh.common.util.EntranceUtils
|
||||
import com.gh.common.view.VerticalItemDecoration
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.baselist.ListAdapter
|
||||
import com.gh.gamecenter.baselist.ListFragment
|
||||
import com.gh.gamecenter.entity.CategoryEntity
|
||||
import kotterknife.bindView
|
||||
|
||||
class CategoryDirectoryFragment : ListFragment<CategoryEntity, CategoryDirectoryListViewModel>() {
|
||||
|
||||
private val mListSkeleton by bindView<View>(R.id.list_skeleton)
|
||||
|
||||
private lateinit var mViewModel: CategoryDirectoryListViewModel
|
||||
private lateinit var mAdapter: CategoryDirectoryAdapter
|
||||
private lateinit var mSkeleton: ViewSkeletonScreen
|
||||
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.fragment_list_base_skeleton
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
mViewModel = ViewModelProviders.of(this).get(CategoryDirectoryListViewModel::class.java)
|
||||
@ -28,6 +40,27 @@ class CategoryDirectoryFragment : ListFragment<CategoryEntity, CategoryDirectory
|
||||
setNavigationTitle(arguments?.getString(EntranceUtils.KEY_CATEGORY_TITLE))
|
||||
mListRv.setBackgroundColor(Color.WHITE)
|
||||
mListRefresh?.isEnabled = false
|
||||
mSkeleton = Skeleton.bind(mListSkeleton).shimmer(false).load(R.layout.fragment_category_skeleton).show()
|
||||
}
|
||||
|
||||
override fun onLoadDone() {
|
||||
super.onLoadDone()
|
||||
mSkeleton.hide()
|
||||
}
|
||||
|
||||
override fun onLoadEmpty() {
|
||||
super.onLoadEmpty()
|
||||
mSkeleton.hide()
|
||||
}
|
||||
|
||||
override fun onLoadError() {
|
||||
super.onLoadError()
|
||||
mSkeleton.hide()
|
||||
}
|
||||
|
||||
override fun onRefresh() {
|
||||
mSkeleton.show()
|
||||
super.onRefresh()
|
||||
}
|
||||
|
||||
override fun provideListAdapter(): ListAdapter<*> {
|
||||
|
||||
@ -29,10 +29,12 @@ import com.gh.gamecenter.NewsDetailActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.GameImageViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.GameNormalViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.GameTestViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.GameViewHolder;
|
||||
import com.gh.gamecenter.databinding.GameItemBinding;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.game.GameItemViewHolder;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.gh.gamecenter.subject.SubjectActivity;
|
||||
@ -200,12 +202,8 @@ public class CategoryListAdapter extends BaseRecyclerAdapter<RecyclerView.ViewHo
|
||||
case ItemViewType.LOADING:
|
||||
view = mLayoutInflater.inflate(R.layout.refresh_footerview, viewGroup, false);
|
||||
return new FooterViewHolder(view);
|
||||
case ItemViewType.GAME_TEST:
|
||||
view = mLayoutInflater.inflate(R.layout.game_test_item, viewGroup, false);
|
||||
return new GameTestViewHolder(view);
|
||||
case ItemViewType.GAME_NORMAL:
|
||||
view = mLayoutInflater.inflate(R.layout.game_normal_item, viewGroup, false);
|
||||
return new GameNormalViewHolder(view);
|
||||
return new GameItemViewHolder(GameItemBinding.bind(mLayoutInflater.inflate(R.layout.game_item, viewGroup, false)));
|
||||
case ItemViewType.GAME_IMAGE:
|
||||
view = mLayoutInflater.inflate(R.layout.game_image_item, viewGroup, false);
|
||||
return new GameImageViewHolder(view);
|
||||
@ -216,10 +214,8 @@ public class CategoryListAdapter extends BaseRecyclerAdapter<RecyclerView.ViewHo
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
|
||||
if (viewHolder instanceof GameNormalViewHolder) {
|
||||
initGameNormalViewHolder((GameNormalViewHolder) viewHolder, position);
|
||||
} else if (viewHolder instanceof GameTestViewHolder) {
|
||||
initGameTestViewHolder((GameTestViewHolder) viewHolder, position);
|
||||
if (viewHolder instanceof GameItemViewHolder) {
|
||||
initGameNormalViewHolder(((GameItemViewHolder) viewHolder), position);
|
||||
} else if (viewHolder instanceof FooterViewHolder) {
|
||||
initFooterViewHolder((FooterViewHolder) viewHolder);
|
||||
} else if (viewHolder instanceof GameImageViewHolder) {
|
||||
@ -263,8 +259,6 @@ public class CategoryListAdapter extends BaseRecyclerAdapter<RecyclerView.ViewHo
|
||||
}
|
||||
if (position == 0 && mSubjectList.size() > 0 && !TextUtils.isEmpty(mSubjectList.get(0).getImage())) {
|
||||
return ItemViewType.GAME_IMAGE;
|
||||
} else if (mSubjectList.get(position).getTest() != null) {
|
||||
return ItemViewType.GAME_TEST;
|
||||
} else {
|
||||
return ItemViewType.GAME_NORMAL;
|
||||
}
|
||||
@ -278,33 +272,25 @@ public class CategoryListAdapter extends BaseRecyclerAdapter<RecyclerView.ViewHo
|
||||
return mSubjectList.size() + 1;
|
||||
}
|
||||
|
||||
private void initGameNormalViewHolder(final GameNormalViewHolder holder, final int position) {
|
||||
private void initGameNormalViewHolder(final GameItemViewHolder holder, final int position) {
|
||||
GameEntity gameEntity = mSubjectList.get(position);
|
||||
|
||||
holder.getBinding().setGame(gameEntity);
|
||||
holder.getBinding().setSubjectTag("type");
|
||||
holder.initServerType(gameEntity);
|
||||
holder.getBinding().executePendingBindings();
|
||||
|
||||
if (mIsOrder) {
|
||||
int index = 1;
|
||||
if (!TextUtils.isEmpty(mSubjectList.get(0).getImage())) {
|
||||
index = 0;
|
||||
}
|
||||
holder.gameOrder.setVisibility(View.VISIBLE);
|
||||
holder.gameOrder.setText(String.valueOf(position + index));
|
||||
holder.getBinding().gameOrder.setVisibility(View.VISIBLE);
|
||||
holder.getBinding().gameOrder.setText(String.valueOf(position + index));
|
||||
} else {
|
||||
holder.gameOrder.setVisibility(View.GONE);
|
||||
holder.getBinding().gameOrder.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
final GameEntity gameEntity = mSubjectList.get(position);
|
||||
|
||||
// holder.gameThumb.setImageURI(gameEntity.getIcon());
|
||||
ImageUtils.display(holder.gameThumb, gameEntity.getIcon());
|
||||
holder.gameName.setText(gameEntity.getName());
|
||||
if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) {
|
||||
holder.gameDes.setText(gameEntity.getBrief());
|
||||
} else {
|
||||
holder.gameDes.setText(String.format("%s %s", gameEntity.getApk().get(0).getSize(), gameEntity.getBrief()));
|
||||
}
|
||||
|
||||
holder.initServerType(gameEntity, mContext);
|
||||
GameViewUtils.setLabelList(mContext, holder.gameLabelList, gameEntity.getTag(), "type", gameEntity.getTagStyle());
|
||||
|
||||
ArrayList<ExposureSource> exposureSources = new ArrayList<>();
|
||||
exposureSources.add(new ExposureSource(mTitle, mName));
|
||||
exposureSources.add(new ExposureSource("二级分类", mType + "+" + ("download:-1".equals(mOrder) ? "最热" : "最新")));
|
||||
@ -319,12 +305,12 @@ public class CategoryListAdapter extends BaseRecyclerAdapter<RecyclerView.ViewHo
|
||||
StringUtils.buildString(mEntrance, "+(", mName, ":列表[", mType, "=", ("download:-1".equals(mOrder) ? "最热" : "最新"), "=", String.valueOf(position + 1), "])"), event);
|
||||
});
|
||||
|
||||
DownloadItemUtils.setOnClickListener(mContext, holder.gameDownloadBtn,
|
||||
DownloadItemUtils.setOnClickListener(mContext, holder.getBinding().downloadBtn,
|
||||
gameEntity, position, this,
|
||||
StringUtils.buildString(mEntrance, "+(", mName, ":列表[", mType, "=", ("download:-1".equals(mOrder) ? "最热" : "最新"), "=", String.valueOf(position + 1), "])"),
|
||||
StringUtils.buildString(mName, ":", gameEntity.getName()), event);
|
||||
|
||||
DownloadItemUtils.updateItem(mContext, gameEntity, holder, true);
|
||||
DownloadItemUtils.updateItem(mContext, gameEntity, new GameViewHolder(holder.getBinding()), true);
|
||||
}
|
||||
|
||||
private void initGameTestViewHolder(final GameTestViewHolder holder, final int position) {
|
||||
|
||||
@ -25,9 +25,10 @@ public class AskSearchHistoryDao {
|
||||
}
|
||||
}
|
||||
|
||||
public void add(String item) {
|
||||
public void add(String key, String communityId) {
|
||||
try {
|
||||
dao.createOrUpdate(new AskSearchHistoryInfo(item));
|
||||
List<String> all = getAll(communityId);
|
||||
if (!all.contains(key)) dao.createOrUpdate(new AskSearchHistoryInfo(key, communityId));
|
||||
} catch (SQLException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
@ -57,14 +58,17 @@ public class AskSearchHistoryDao {
|
||||
return;
|
||||
}
|
||||
|
||||
public List<String> getAll() {
|
||||
public List<String> getAll(String communityId) {
|
||||
List<String> history = new ArrayList<String>();
|
||||
|
||||
try {
|
||||
List<AskSearchHistoryInfo> his = dao.queryBuilder().orderBy("time", false).query();
|
||||
List<AskSearchHistoryInfo> his = dao.queryBuilder().
|
||||
orderBy("time", false).
|
||||
where().eq("communityId", communityId).
|
||||
query();
|
||||
Iterator<AskSearchHistoryInfo> hisIterator = his.iterator();
|
||||
while (hisIterator.hasNext()) {
|
||||
history.add(hisIterator.next().getItem());
|
||||
history.add(hisIterator.next().getKey());
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ import java.sql.SQLException;
|
||||
public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||
|
||||
private static final String DATABASE_NAME = "gh_assist.db";
|
||||
private static final int DATABASE_VERSION = 12;
|
||||
private static final int DATABASE_VERSION = 13;
|
||||
|
||||
private static DatabaseHelper instance;
|
||||
private ArrayMap<String, Dao> daos = new ArrayMap<>();
|
||||
|
||||
@ -16,27 +16,46 @@ public class AskSearchHistoryInfo implements Serializable {
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@DatabaseField(id = true, columnName = "item")
|
||||
private String item;
|
||||
@DatabaseField(id = true, columnName = "id")
|
||||
private String id;
|
||||
|
||||
@DatabaseField(useGetSet = true, columnName = "time")
|
||||
@DatabaseField(columnName = "key")
|
||||
private String key;
|
||||
|
||||
@DatabaseField(columnName = "time")
|
||||
private String time;
|
||||
|
||||
@DatabaseField(columnName = "communityId")
|
||||
private String communityId;
|
||||
|
||||
public AskSearchHistoryInfo() {
|
||||
|
||||
}
|
||||
|
||||
public AskSearchHistoryInfo(String item) {
|
||||
this.item = item;
|
||||
public AskSearchHistoryInfo(String key, String communityId) {
|
||||
this.key = key;
|
||||
this.communityId = communityId;
|
||||
Date date = new Date();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",
|
||||
Locale.getDefault());
|
||||
this.time = format.format(date);
|
||||
this.id = String.valueOf(date.getTime());
|
||||
}
|
||||
|
||||
public AskSearchHistoryInfo(String item, String time) {
|
||||
this.item = item;
|
||||
this.time = time;
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
@ -47,13 +66,20 @@ public class AskSearchHistoryInfo implements Serializable {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getItem() {
|
||||
return item;
|
||||
public String getCommunityId() {
|
||||
return communityId;
|
||||
}
|
||||
|
||||
public void setCommunityId(String communityId) {
|
||||
this.communityId = communityId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SearchHistoryEntity [item=" + item + ", time=" + time + "]";
|
||||
return "AskSearchHistoryInfo{" +
|
||||
"key='" + key + '\'' +
|
||||
", time='" + time + '\'' +
|
||||
", communityId='" + communityId + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ import butterknife.OnClick
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.gh.base.fragment.BaseFragment
|
||||
import com.gh.common.AppExecutor
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.*
|
||||
import com.gh.gamecenter.databinding.PieceDiscoverItemBinding
|
||||
@ -31,6 +32,12 @@ class DiscoverFragment : BaseFragment<Any>() {
|
||||
lateinit var mDiscoverGameUnreadIcon: SimpleDraweeView
|
||||
@BindView(R.id.discover_container)
|
||||
lateinit var mDiscoverContainer: LinearLayout
|
||||
@BindView(R.id.discover_game_trends)
|
||||
lateinit var mDiscoverGameTrends: View
|
||||
@BindView(R.id.discover_info)
|
||||
lateinit var mDiscoverInfo: View
|
||||
@BindView(R.id.discover_libao_line)
|
||||
lateinit var mDiscoverLibaoLine: View
|
||||
|
||||
private val mGameTrendsDao by lazy { GameTrendsDao(context) }
|
||||
|
||||
@ -76,6 +83,8 @@ class DiscoverFragment : BaseFragment<Any>() {
|
||||
mDiscoverContainer.addView(discoverAdView)
|
||||
}
|
||||
}
|
||||
|
||||
checkArticleStatus()
|
||||
}
|
||||
|
||||
@OnClick(R.id.discover_game_trends,
|
||||
@ -155,6 +164,19 @@ class DiscoverFragment : BaseFragment<Any>() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkArticleStatus() {
|
||||
val showArticleEntrance = Config.getSettings()?.showArticleEntrance()
|
||||
if (showArticleEntrance == false) {
|
||||
mDiscoverGameTrends.visibility = View.GONE
|
||||
mDiscoverInfo.visibility = View.GONE
|
||||
mDiscoverLibaoLine.visibility = View.GONE
|
||||
} else {
|
||||
mDiscoverGameTrends.visibility = View.VISIBLE
|
||||
mDiscoverInfo.visibility = View.VISIBLE
|
||||
mDiscoverLibaoLine.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
// 登录事件
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(reuse: EBReuse) {
|
||||
@ -162,6 +184,8 @@ class DiscoverFragment : BaseFragment<Any>() {
|
||||
showDot()
|
||||
} else if (reuse.type == LOGOUT_TAG) {
|
||||
mDiscoverGameUnread.visibility = View.GONE
|
||||
} else if (reuse.type == "Refresh") {
|
||||
checkArticleStatus()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -146,10 +146,21 @@ class DownloadFragment : BaseFragment_TabLayout() {
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(skip: EBSkip) {
|
||||
if (DownloadManagerActivity.TAG == skip.type) {
|
||||
if (skip.currentItem == DownloadManagerActivity.INDEX_UPDATE) {
|
||||
if (view != null) {
|
||||
view!!.postDelayed({ mViewPager.currentItem = DownloadManagerActivity.INDEX_DOWNLOAD }, 300)
|
||||
}
|
||||
if (view != null) {
|
||||
view!!.postDelayed({
|
||||
mViewPager.currentItem = skip.currentItem
|
||||
if (isAdded && skip.currentItem == DownloadManagerActivity.INDEX_DOWNLOAD) {
|
||||
val fragments = childFragmentManager.fragments
|
||||
if (fragments != null) {
|
||||
for (fragment in fragments) {
|
||||
if (fragment.isAdded
|
||||
&& fragment is GameDownloadFragment) {
|
||||
fragment.onResume() // auto refresh list
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 300)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ public class GameDownloadFragment extends BaseFragment implements View.OnClickLi
|
||||
}
|
||||
}
|
||||
|
||||
adapter.getUrlMap().put(PackageUtils.getPackageNameByPath(getActivity(),
|
||||
adapter.getUrlMap().put(PackageUtils.getPackageNameByPath(HaloApp.getInstance().getApplication(),
|
||||
downloadEntity.getPath()), downloadEntity.getUrl());
|
||||
} else if (DownloadStatus.cancel.equals(downloadEntity.getStatus())) { // 有可能由于网络劫持造成的
|
||||
adapter.initMap();
|
||||
|
||||
@ -252,7 +252,7 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
DialogUtils.checkResumeDownload(mContext, isSubscribe -> {
|
||||
if (isSubscribe) {
|
||||
DownloadManager.getInstance(mContext).subscribe(downloadEntity);
|
||||
statusMap.put(url, "subscribe");
|
||||
statusMap.put(url, DownloadStatus.subscribe.getStatus());
|
||||
notifyItemChanged(doneList.isEmpty() ? 0 : 1 + doneList.size());
|
||||
} else {
|
||||
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
|
||||
@ -269,7 +269,7 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
viewHolder.dmStartorpause.setBackgroundResource(R.drawable.game_item_btn_downloading_bg);
|
||||
viewHolder.dmStartorpause.setText("暂停");
|
||||
viewHolder.dmStartorpause.setTextColor(ContextCompat.getColor(mContext, R.color.theme));
|
||||
statusMap.put(url, "downloading");
|
||||
statusMap.put(url, DownloadStatus.downloading.getStatus());
|
||||
notifyItemChanged(doneList.isEmpty() ? 0 : 1 + doneList.size());
|
||||
|
||||
Message msg = Message.obtain();
|
||||
@ -307,7 +307,7 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
viewHolder.dmDownloads.setTextColor(0xFF9A9A9A);
|
||||
viewHolder.dmDownloads.setText("已暂停");
|
||||
viewHolder.dmDelete.setVisibility(View.VISIBLE);
|
||||
statusMap.put(url, "pause");
|
||||
statusMap.put(url, DownloadStatus.pause.getStatus());
|
||||
notifyItemChanged(doneList.isEmpty() ? 0 : 1 + doneList.size());
|
||||
Message msg = Message.obtain();
|
||||
msg.what = DownloadConfig.PAUSE_DOWNLOAD_TASK;
|
||||
@ -407,7 +407,7 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
msg.obj = downloadEntity.getUrl();
|
||||
DownloadManager.getInstance(mContext).sendMessageDelayed(msg, 1000);
|
||||
// DownloadManager.getInstance(mContext).add(downloadEntity);
|
||||
statusMap.put(downloadEntity.getUrl(), "downloading");
|
||||
statusMap.put(downloadEntity.getUrl(), DownloadStatus.downloading.getStatus());
|
||||
}
|
||||
|
||||
// DownloadManager.getInstance(mContext).startAll();
|
||||
|
||||
@ -232,13 +232,16 @@ class GameUpdateFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
int done = 0;
|
||||
for (int i = 0; i < updateList.size(); i++) {
|
||||
String str = updateList.get(i).getSize();
|
||||
str = str.substring(0, str.lastIndexOf("M"));
|
||||
size += Float.valueOf(str);
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(mContext).getDownloadEntityByUrl(updateList.get(i).getUrl());
|
||||
if (downloadEntity != null) {
|
||||
count++;
|
||||
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
|
||||
done++;
|
||||
int lastM = str.lastIndexOf("M");
|
||||
if (lastM != -1) {
|
||||
str = str.substring(0, lastM);
|
||||
size += Float.valueOf(str);
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(mContext).getDownloadEntityByUrl(updateList.get(i).getUrl());
|
||||
if (downloadEntity != null) {
|
||||
count++;
|
||||
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
|
||||
done++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -355,7 +358,7 @@ class GameUpdateFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
updateEntity.getPackageName());
|
||||
} else if (mContext.getString(R.string.updating).equals(str) || "插件化中".equals(str)) {
|
||||
notifyItemChanged(0);
|
||||
EventBus.getDefault().post(new EBSkip(DownloadManagerActivity.TAG, DownloadManagerActivity.INDEX_UPDATE));
|
||||
EventBus.getDefault().post(new EBSkip(DownloadManagerActivity.TAG, DownloadManagerActivity.INDEX_DOWNLOAD));
|
||||
}
|
||||
|
||||
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "下载管理", "游戏更新", str);
|
||||
@ -401,7 +404,14 @@ class GameUpdateFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
|
||||
if (mPackageName != null && mPackageName.equals(updateEntity.getPackageName())) {
|
||||
// 插件跳转游戏更新页面造成闪退,可能是页面未绘制完成点击造成的闪退
|
||||
AppExecutor.getUiExecutor().execute(() -> viewHolder.guUpdate.performClick());
|
||||
AppExecutor.getUiExecutor().execute(() -> {
|
||||
DownloadEntity entity = DownloadManager.getInstance(mContext).getDownloadEntityByUrl(updateEntity.getUrl());
|
||||
if (entity != null && DownloadStatus.pause == entity.getStatus()) {
|
||||
addUpdateDownload(viewHolder.getPosition() - 1, false);
|
||||
} else {
|
||||
viewHolder.guUpdate.performClick();
|
||||
}
|
||||
});
|
||||
mPackageName = null;
|
||||
}
|
||||
}
|
||||
@ -448,6 +458,7 @@ class GameUpdateFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
DataUtils.onEvent(mContext, "游戏更新", updateEntity.getName(), kv);
|
||||
|
||||
DownloadEntity downloadEntity = new DownloadEntity();
|
||||
downloadEntity.setGameId(updateEntity.getId());
|
||||
downloadEntity.setUrl(updateEntity.getUrl());
|
||||
downloadEntity.setName(updateEntity.getName());
|
||||
downloadEntity.setPath(FileUtils.getDownloadPath(mContext,
|
||||
@ -464,7 +475,7 @@ class GameUpdateFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
null,
|
||||
ExposureUtils.DownloadType.UPDATE);
|
||||
|
||||
downloadEntity.setExposureTrace(GsonUtils.Companion.getInstance().toJson(event));
|
||||
downloadEntity.setExposureTrace(GsonUtils.toJson(event));
|
||||
|
||||
String platform = PlatformUtils.getInstance(mContext)
|
||||
.getPlatformName(updateEntity.getPlatform());
|
||||
@ -495,7 +506,7 @@ class GameUpdateFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
GdtHelper.PLATFORM, downloadEntity.getPlatform());
|
||||
|
||||
notifyItemChanged(0);
|
||||
EventBus.getDefault().post(new EBSkip(DownloadManagerActivity.TAG, DownloadManagerActivity.INDEX_UPDATE));
|
||||
EventBus.getDefault().post(new EBSkip(DownloadManagerActivity.TAG, DownloadManagerActivity.INDEX_DOWNLOAD));
|
||||
}
|
||||
|
||||
public ArrayMap<String, ArrayList<Integer>> getLocationMap() {
|
||||
|
||||
@ -21,7 +21,8 @@ data class ApkEntity(@SerializedName("package")
|
||||
var isActive: Boolean = true,
|
||||
var force: Boolean = false,
|
||||
var apkLink: ApkLink? = null,
|
||||
var plugin: String? = ""/*控制是否显示插件化 默认:open,取值有:open/only_index/only_game/close*/) : Parcelable {
|
||||
var plugin: String? = "",/*控制是否显示插件化 默认:open,取值有:open/only_index/only_game/close*/
|
||||
var time: Long? = null) : Parcelable {
|
||||
fun getPlatform(): String? {
|
||||
if (TextUtils.isEmpty(platform)) {
|
||||
return "官方版"
|
||||
|
||||
@ -69,7 +69,9 @@ data class GameEntity(
|
||||
// 用于开服表标记是否为置顶项目
|
||||
@SerializedName("is_fixed_top")
|
||||
var fixedTop: Boolean? = false,
|
||||
var fixedTopHint: Boolean? = false) : Parcelable {
|
||||
var fixedTopHint: Boolean? = false,
|
||||
@SerializedName("download_notice")
|
||||
val downloadAd: LinkEntity? = null) : Parcelable {
|
||||
|
||||
@IgnoredOnParcel
|
||||
private var entryMap: ArrayMap<String, DownloadEntity>? = ArrayMap()
|
||||
|
||||
@ -33,6 +33,8 @@ class MessageEntity {
|
||||
|
||||
var game: Game = Game()
|
||||
|
||||
var fold: Fold? = null
|
||||
|
||||
|
||||
class Article() : Parcelable {
|
||||
@SerializedName("_id")
|
||||
@ -172,5 +174,11 @@ class MessageEntity {
|
||||
var name: String? = null
|
||||
}
|
||||
|
||||
class Fold {
|
||||
@SerializedName("resource_id")
|
||||
var resourceId: String = ""
|
||||
|
||||
var number: Int = 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
package com.gh.gamecenter.entity
|
||||
|
||||
data class MessageFold(val time: Long = 0,
|
||||
var user: UserEntity = UserEntity())
|
||||
@ -22,7 +22,7 @@ class MessageKeFuEntity {
|
||||
|
||||
var suggestion: String? = null
|
||||
|
||||
var link: MessageLinkEntity? = null
|
||||
var links : List<MessageLinkEntity>? = null
|
||||
|
||||
@SerializedName("service")
|
||||
var serviceEntity: ServiceEntity? = null
|
||||
|
||||
@ -30,8 +30,11 @@ data class PushNotificationEntity(
|
||||
|
||||
data class Extra(var data: Data? = null)
|
||||
|
||||
data class Data(var condition: Condition? = null,
|
||||
var link: Link? = null) {
|
||||
data class Data(
|
||||
@SerializedName("push_id")
|
||||
var pushId: String? = "",
|
||||
var condition: Condition? = null,
|
||||
var link: Link? = null) {
|
||||
|
||||
@Parcelize
|
||||
data class Link(var type: String? = "", var target: String? = "") : Parcelable
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
package com.gh.gamecenter.entity
|
||||
|
||||
import android.preference.PreferenceManager
|
||||
import com.gh.common.constant.Config
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
data class SettingsEntity(
|
||||
var download: List<Download>? = listOf(),
|
||||
@ -10,11 +13,54 @@ data class SettingsEntity(
|
||||
var image: Image? = null,
|
||||
var support: Support? = null,
|
||||
@SerializedName("community_entrance")
|
||||
var communityEntrance: String? = "",
|
||||
private var communityEntrance: String? = "",
|
||||
@SerializedName("game_comment_blacklist")
|
||||
var gameCommentBlackList: List<String>? = listOf(),
|
||||
@SerializedName("game_download_blacklist")
|
||||
var gameDownloadBlackList: List<String> = listOf(),
|
||||
@SerializedName("game_package_match")
|
||||
var gamePackageMatch: List<GameWithPackages>? = listOf(),
|
||||
@SerializedName("ad")
|
||||
var adList: List<AD>? = listOf()) {
|
||||
var adList: List<AD>? = listOf(),
|
||||
@SerializedName("article_entrance")
|
||||
private var articleEntrance: String = "") {
|
||||
|
||||
fun setCommunityEntrance(communityEntrance: String) {
|
||||
this.communityEntrance = communityEntrance
|
||||
}
|
||||
|
||||
fun showCommunityEntrance(): Boolean {
|
||||
val preferences =
|
||||
PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().application)
|
||||
val isFixCommunity =
|
||||
preferences.getBoolean(Config.FIX_COMMUNITY_KEY, false)
|
||||
if (isFixCommunity) return true
|
||||
|
||||
if ("on" == communityEntrance) {
|
||||
preferences.edit().putBoolean(Config.FIX_COMMUNITY_KEY, true).apply()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun setArticleEntrance(articleEntrance: String) {
|
||||
this.articleEntrance = articleEntrance
|
||||
}
|
||||
|
||||
fun showArticleEntrance(): Boolean {
|
||||
val preferences =
|
||||
PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().application)
|
||||
val isFixArticle =
|
||||
preferences.getBoolean(Config.FIX_ARTICLE_KEY, false)
|
||||
if (isFixArticle) return true
|
||||
|
||||
if ("on" == articleEntrance) {
|
||||
preferences.edit().putBoolean(Config.FIX_ARTICLE_KEY, true).apply()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
data class Support(
|
||||
@SerializedName("qq-group")
|
||||
@ -76,4 +122,10 @@ data class SettingsEntity(
|
||||
}
|
||||
}
|
||||
|
||||
data class GameWithPackages(
|
||||
@SerializedName("game_id")
|
||||
var gameId: String? = "",
|
||||
var packages: List<String>? = listOf()
|
||||
)
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.gh.gamecenter.entity
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class SpecialColumn(
|
||||
var type: String? = "",
|
||||
var name: String? = "",
|
||||
var tab: String? = ""
|
||||
) : Parcelable
|
||||
@ -19,4 +19,6 @@ data class SubjectEntity(@SerializedName("_id")
|
||||
var sort: Int = 0,
|
||||
var data: MutableList<GameEntity>? = null,
|
||||
var type: String? = null,
|
||||
var des: String? = null) : Parcelable
|
||||
var des: String? = null,
|
||||
@SerializedName("relation_column_id")
|
||||
var relatedColumnId: String ?= null) : Parcelable
|
||||
@ -19,4 +19,8 @@ class VersionVoteEntity {
|
||||
var me: MeEntity? = null
|
||||
|
||||
var reply: String? = null
|
||||
|
||||
var open : Boolean = true
|
||||
|
||||
var link: LinkEntity = LinkEntity()
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ public class MainWrapperFragment extends BaseFragment_ViewPager_Checkable {
|
||||
}
|
||||
} else if ("Refresh".equals(reuse.getType())) {
|
||||
SettingsEntity settings = Config.getSettings();
|
||||
if (settings != null && "off".equals(settings.getCommunityEntrance())) {
|
||||
if (settings != null && !settings.showCommunityEntrance()) {
|
||||
mTabCommunity.setVisibility(View.GONE);
|
||||
} else {
|
||||
mTabCommunity.setVisibility(View.VISIBLE);
|
||||
|
||||
@ -21,6 +21,7 @@ import com.gh.common.util.DataCollectionUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.MtaHelper;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.ConcernActivity;
|
||||
import com.gh.gamecenter.DownloadManagerActivity;
|
||||
@ -30,8 +31,8 @@ import com.gh.gamecenter.entity.GameUpdateEntity;
|
||||
import com.gh.gamecenter.entity.PluginLocation;
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus;
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.packagehelper.PackageViewModel;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.gh.gamecenter.packagehelper.PackageViewModel;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
@ -220,13 +221,13 @@ public class SearchToolbarFragment extends BaseFragment implements View.OnClickL
|
||||
|
||||
switch (id) {
|
||||
case R.id.actionbar_rl_download:
|
||||
DataUtils.onEvent(getActivity(), "主页", "下载图标");
|
||||
MtaHelper.onEvent("首页_点击", "顶栏", "下载管理");
|
||||
DataCollectionUtils.uploadClick(getActivity(), "下载图标", "主页");
|
||||
|
||||
startActivity(DownloadManagerActivity.getDownloadMangerIntent(getContext(), null, "(工具栏)"));
|
||||
break;
|
||||
case R.id.actionbar_iv_search:
|
||||
DataUtils.onEvent(getActivity(), "主页", "搜索图标");
|
||||
MtaHelper.onEvent("首页_点击", "顶栏", "搜索");
|
||||
DataCollectionUtils.uploadClick(getActivity(), "搜索图标", "主页");
|
||||
|
||||
intent = SearchActivity.getIntent(getContext(), true, mSearchHintTv.getHint().toString(), "(工具栏)");
|
||||
@ -235,6 +236,7 @@ public class SearchToolbarFragment extends BaseFragment implements View.OnClickL
|
||||
case R.id.actionbar_search_input:
|
||||
case R.id.actionbar_search_rl:
|
||||
DataUtils.onEvent(getActivity(), "主页", "搜索框");
|
||||
MtaHelper.onEvent("首页_点击", "顶栏", "搜索");
|
||||
DataCollectionUtils.uploadClick(getActivity(), "搜索框", "主页");
|
||||
|
||||
intent = SearchActivity.getIntent(getContext(), false, mSearchHintTv.getHint().toString(), "(工具栏)");
|
||||
@ -242,6 +244,7 @@ public class SearchToolbarFragment extends BaseFragment implements View.OnClickL
|
||||
break;
|
||||
case R.id.actionbar_notification:
|
||||
DataUtils.onEvent(getActivity(), "主页", "关注图标");
|
||||
MtaHelper.onEvent("首页_点击", "顶栏", "我的关注");
|
||||
DataCollectionUtils.uploadClick(getActivity(), "关注图标", "主页");
|
||||
|
||||
intent = ConcernActivity.getIntent(getContext(), "(工具栏)");
|
||||
|
||||
@ -155,7 +155,6 @@ class GameFragment : NormalFragment() {
|
||||
mSkeleton = Skeleton.bind(mBinding?.gameSkeletonContainer).shimmer(false).load(R.layout.fragment_game_skeleton).show()
|
||||
}
|
||||
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
DownloadManager.getInstance(context).removeObserver(dataWatcher)
|
||||
|
||||
@ -42,7 +42,8 @@ import com.lightgame.download.DownloadEntity
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class GameFragmentAdapter(context: Context, model: GameViewModel, var blockName: String) : BaseRecyclerAdapter<RecyclerView.ViewHolder>(context), IExposable {
|
||||
class GameFragmentAdapter(context: Context, model: GameViewModel, var blockName: String)
|
||||
: BaseRecyclerAdapter<RecyclerView.ViewHolder>(context), IExposable {
|
||||
|
||||
private val mPluginPosition = 1
|
||||
|
||||
@ -54,6 +55,9 @@ class GameFragmentAdapter(context: Context, model: GameViewModel, var blockName:
|
||||
|
||||
private var mIsOpenPluginList: Boolean = false
|
||||
|
||||
// 有点蠢,不过想要获取引用的话好像只能把这个 viewHolder 记起来了,要是到时要显示两个插件区域这里就要改了.
|
||||
private var mPluginViewHolder: GamePluginViewHolder? = null
|
||||
|
||||
var isAutoScroll: Boolean = true
|
||||
|
||||
init {
|
||||
@ -110,319 +114,344 @@ class GameFragmentAdapter(context: Context, model: GameViewModel, var blockName:
|
||||
GameHeadViewHolder(GameHeadItemBinding.bind(mLayoutInflater.inflate(R.layout.game_head_item, parent, false)))
|
||||
}
|
||||
ItemViewType.GAME_PLUGIN -> {
|
||||
GamePluginViewHolder(mLayoutInflater.inflate(R.layout.game_plugin_item, parent, false))
|
||||
mPluginViewHolder = GamePluginViewHolder(mLayoutInflater.inflate(R.layout.game_plugin_item, parent, false))
|
||||
mPluginViewHolder as GamePluginViewHolder
|
||||
}
|
||||
else -> GameItemViewHolder(GameItemBinding.bind(mLayoutInflater.inflate(R.layout.game_item, parent, false)))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
when (holder) {
|
||||
is GameHeadViewHolder -> bindHeadView(holder, position)
|
||||
is GamePluginViewHolder -> bindPluginView(holder, position)
|
||||
is GameItemViewHolder -> bindGameItemView(holder, position)
|
||||
is GameViewPagerViewHolder -> bindGameViewPagerView(holder, position)
|
||||
is FooterViewHolder -> bindFooterView(holder)
|
||||
is GameImageViewHolder -> bindGameImageView(holder, position)
|
||||
is GameHorizontalListViewHolder -> bindGameHorizontalListView(holder, position)
|
||||
}
|
||||
}
|
||||
|
||||
if (holder is GameHeadViewHolder) {
|
||||
val column = mItemDataList[position].columnHead
|
||||
holder.binding.subject = column
|
||||
holder.binding.headPb.visibility = View.GONE
|
||||
val text = if ("change" == column?.home) "换一批" else "全部"
|
||||
holder.binding.headMore.text = text
|
||||
private fun bindGameHorizontalListView(holder: GameHorizontalListViewHolder, position: Int) {
|
||||
val subjectEntity = mItemDataList[position].horizontalColumn
|
||||
val exposureEventList = arrayListOf<ExposureEvent>()
|
||||
|
||||
if (text == "全部" && column != null && column.data != null && column.data!!.size >= column.more!!) {
|
||||
holder.binding.headMore.visibility = View.GONE
|
||||
} else {
|
||||
holder.binding.headMore.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
holder.binding.headMore.setOnClickListener {
|
||||
if ("all" == column?.home) {
|
||||
DataUtils.onMtaEvent(mContext, "游戏专题", "全部", column.name)
|
||||
SubjectActivity.startSubjectActivity(mContext, column.id, column.name, column.isOrder, "(游戏-专题:" + column.name + "-全部)")
|
||||
} else {
|
||||
DataUtils.onMtaEvent(mContext, "游戏专题", "换一批", column?.name)
|
||||
holder.binding.headPb.visibility = View.VISIBLE
|
||||
mViewModel.changeSubjectGame(column?.id!!)
|
||||
}
|
||||
}
|
||||
} else if (holder is GamePluginViewHolder) {
|
||||
val pluginList = mItemDataList[position].pluginList
|
||||
var adapter = holder.mPluginRv.adapter
|
||||
|
||||
if (adapter == null) {
|
||||
adapter = GamePluginAdapter(mContext, pluginList)
|
||||
adapter.openList(mIsOpenPluginList)
|
||||
(holder.mPluginRv.itemAnimator as DefaultItemAnimator).supportsChangeAnimations = false
|
||||
holder.mPluginRv.layoutManager = LinearLayoutManager(mContext)
|
||||
holder.mPluginRv.adapter = adapter
|
||||
} else {
|
||||
(adapter as GamePluginAdapter).openList(mIsOpenPluginList)
|
||||
adapter.checkResetData(pluginList)
|
||||
}
|
||||
|
||||
holder.mHeadTitle.text = String.format(Locale.getDefault(), "你有%d个游戏可以升级插件版", pluginList?.size)
|
||||
holder.mPluginHead.setOnClickListener {
|
||||
if (mIsOpenPluginList) {
|
||||
mIsOpenPluginList = false
|
||||
holder.mHeadOpen.setImageResource(R.drawable.gamedetail_open_icon)
|
||||
} else {
|
||||
mIsOpenPluginList = true
|
||||
holder.mHeadOpen.setImageResource(R.drawable.gamedetail_colse_icon)
|
||||
}
|
||||
notifyItemChanged(holder.adapterPosition)
|
||||
}
|
||||
} else if (holder is GameItemViewHolder) {
|
||||
val itemData = mItemDataList[position]
|
||||
val gameEntity = itemData.game
|
||||
val subjectData = gameEntity?.subjectData
|
||||
|
||||
if (mItemDataList[position - 1].game == null) {
|
||||
holder.itemView.setPadding(DisplayUtils.dip2px(8F), DisplayUtils.dip2px(10.5F),
|
||||
DisplayUtils.dip2px(20F), DisplayUtils.dip2px(6F))
|
||||
} else {
|
||||
holder.itemView.setPadding(DisplayUtils.dip2px(8F), DisplayUtils.dip2px(6F),
|
||||
DisplayUtils.dip2px(20F), DisplayUtils.dip2px(6F))
|
||||
}
|
||||
holder.binding.game = gameEntity
|
||||
holder.binding.subjectTag = subjectData?.tag
|
||||
holder.initServerType(gameEntity!!)
|
||||
holder.binding.executePendingBindings()
|
||||
|
||||
if (subjectData?.isOrder!!) {
|
||||
holder.binding.gameOrder.visibility = View.VISIBLE
|
||||
holder.binding.gameOrder.text = (subjectData.position).toString()
|
||||
} else {
|
||||
holder.binding.gameOrder.visibility = View.GONE
|
||||
}
|
||||
val binding = holder.binding
|
||||
var subjectAdapter = binding.horizontalRv.adapter
|
||||
if (subjectAdapter == null) {
|
||||
subjectAdapter = GameHorizontalAdapter(mContext, subjectEntity!!)
|
||||
(binding.horizontalRv.itemAnimator as DefaultItemAnimator).supportsChangeAnimations = false
|
||||
binding.horizontalRv.layoutManager = GridLayoutManager(mContext, 4)
|
||||
binding.horizontalRv.adapter = subjectAdapter
|
||||
} else {
|
||||
(subjectAdapter as GameHorizontalAdapter).checkResetData(subjectEntity!!)
|
||||
subjectAdapter.notifyItemRangeChanged(0, subjectAdapter.itemCount)
|
||||
}
|
||||
|
||||
subjectEntity.data?.let {
|
||||
val keyName = if (TextUtils.isEmpty(blockName)) "首页" else "板块"
|
||||
val keyValue = if (TextUtils.isEmpty(blockName)) "" else blockName
|
||||
itemData.exposureEvent = ExposureEvent.createEvent(gameEntity = gameEntity,
|
||||
source = listOf(ExposureSource(keyName, keyValue), ExposureSource("专题", subjectData.name!!)),
|
||||
eTrace = null,
|
||||
event = ExposureType.EXPOSURE)
|
||||
|
||||
DownloadItemUtils.setOnClickListener(mContext, holder.binding.downloadBtn, gameEntity, position,
|
||||
this@GameFragmentAdapter,
|
||||
StringUtils.buildString("(游戏-专题:", subjectData.name, "-列表[", (position + 1).toString(), "])"),
|
||||
StringUtils.buildString("游戏-专题-", subjectData.name, ":", gameEntity.name), itemData.exposureEvent)
|
||||
DownloadItemUtils.updateItem(mContext, gameEntity, GameViewHolder(holder.binding), !gameEntity.isPluggable)
|
||||
holder.itemView.setOnClickListener {
|
||||
DataCollectionUtils.uploadClick(mContext, subjectData.name + "-列表", "游戏-专题", gameEntity.name)
|
||||
val positionOffset = subjectAdapter.getIndex()
|
||||
|
||||
if (gameEntity.isPluggable) {
|
||||
GameDetailActivity.startGameDetailActivity(mContext, gameEntity.id,
|
||||
StringUtils.buildString("(游戏-专题:插件化-列表[", (subjectData.position).toString(), "])"), itemData.exposureEvent)
|
||||
} else {
|
||||
GameDetailActivity.startGameDetailActivity(mContext, gameEntity,
|
||||
StringUtils.buildString("(游戏-专题:", subjectData.name, "-列表[", (subjectData.position).toString(), "])"), itemData.exposureEvent)
|
||||
}
|
||||
for (i in positionOffset until subjectAdapter.itemCount + positionOffset) {
|
||||
it[i].sequence = i
|
||||
val event = ExposureEvent.createEvent(gameEntity = it[i],
|
||||
source = listOf(ExposureSource(keyName, keyValue), ExposureSource("专题", subjectEntity.name!!)),
|
||||
eTrace = null,
|
||||
event = ExposureType.EXPOSURE)
|
||||
exposureEventList.add(event)
|
||||
}
|
||||
} else if (holder is GameViewPagerViewHolder) {
|
||||
val subjectDigestList = mItemDataList[position].subjectRecommend
|
||||
val binding = holder.binding
|
||||
mItemDataList[position].exposureEventList = exposureEventList
|
||||
subjectAdapter.exposureEventList = exposureEventList
|
||||
}
|
||||
}
|
||||
|
||||
binding.list = subjectDigestList
|
||||
binding.clickListener = OnViewClickListener { v, data ->
|
||||
if (data is Int) {
|
||||
DataUtils.onMtaEvent(mContext, "推荐入口", if (TextUtils.isEmpty(blockName)) "首页" else blockName, (data + 1).toString())
|
||||
if (data < subjectDigestList?.size!!) {
|
||||
val entity = subjectDigestList[data]
|
||||
when {
|
||||
entity.type == "block" -> mContext.startActivity(BlockActivity.getIntent(mContext, entity))
|
||||
entity.type == "category" -> mContext.startActivity(CategoryDirectoryActivity.getIntent(mContext, entity.link!!, entity.text!!))
|
||||
entity.type == "column" -> {
|
||||
SubjectActivity.startSubjectActivity(mContext, entity.link, entity.text, entity.order
|
||||
, StringUtils.buildString("(游戏-专题:", entity.name, "[1-", (data + 1).toString(), "]", ")"))
|
||||
DataCollectionUtils.uploadPosition(mContext, "游戏", (data + 1).toString(), entity.name)
|
||||
}
|
||||
entity.type == "game" -> GameDetailActivity.startGameDetailActivity(mContext, entity.link, "(推荐入口)")
|
||||
entity.type == EntranceUtils.HOST_COMMUNITY -> DirectUtils.directToCommunity(mContext, CommunityEntity(entity.link!!, entity.text!!))
|
||||
else -> DialogUtils.showLowVersionDialog(mContext)
|
||||
}
|
||||
private fun bindGameImageView(holder: GameImageViewHolder, position: Int) {
|
||||
val entity = mItemDataList[position].image
|
||||
|
||||
val keyName = if (TextUtils.isEmpty(blockName)) "首页" else "板块"
|
||||
val keyValue = if (TextUtils.isEmpty(blockName)) "" else blockName
|
||||
|
||||
entity?.let {
|
||||
if (it.type == "game") {
|
||||
mItemDataList[position].exposureEvent = ExposureEvent.createEvent(gameEntity = entity,
|
||||
source = listOf(ExposureSource(keyName, keyValue), ExposureSource("专题", entity.subjectData?.name + "-大图")),
|
||||
eTrace = null,
|
||||
event = ExposureType.EXPOSURE)
|
||||
}
|
||||
}
|
||||
|
||||
holder.binding.game = entity
|
||||
holder.binding.traceEvent = mItemDataList[position].exposureEvent
|
||||
|
||||
val name = entity?.subjectData?.name
|
||||
val link = entity?.link
|
||||
val width = mContext.resources.displayMetrics.widthPixels - DisplayUtils.dip2px(mContext, 16F)
|
||||
ImageUtils.display(holder.binding.gameImageIcon, entity?.image, width, object : BaseControllerListener<ImageInfo>() {
|
||||
override fun onFinalImageSet(id: String?, imageInfo: ImageInfo?, animatable: Animatable?) {
|
||||
if (imageInfo == null) return
|
||||
val imageParams = holder.binding.gameImageIcon.layoutParams
|
||||
val scale = imageInfo.height.toFloat() / imageInfo.width.toFloat()
|
||||
imageParams?.height = (width * scale).toInt()
|
||||
holder.binding.gameImageIcon.layoutParams = imageParams
|
||||
holder.binding.gameContainer.layoutParams.height = (width * scale).toInt()
|
||||
}
|
||||
})
|
||||
holder.binding.gameImageIcon.setOnClickListener {
|
||||
DataCollectionUtils.uploadClick(mContext, "$name-大图", "游戏-专题")
|
||||
DataUtils.onMtaEvent(mContext, "游戏专题", "大图", name + ":" + entity?.name)
|
||||
val linkEntity = LinkEntity()
|
||||
linkEntity.link = link
|
||||
linkEntity.type = entity?.type
|
||||
linkEntity.text = name
|
||||
DirectUtils.directToLinkPage(mContext, linkEntity, "(游戏-专题:$name-大图)", "首页游戏")
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindFooterView(holder: FooterViewHolder) {
|
||||
holder.initFooterViewHolder(mLoadStatus == LoadStatus.LIST_LOADING
|
||||
, mLoadStatus == LoadStatus.LIST_FAILED
|
||||
, mLoadStatus == LoadStatus.LIST_OVER) {
|
||||
if (mLoadStatus == LoadStatus.LIST_OVER) {
|
||||
MtaHelper.onEvent("首页_点击", "底部", "点击回到顶部")
|
||||
mViewModel.commandScrollTop.postValue(null)
|
||||
} else {
|
||||
mViewModel.getSubjectList(false)
|
||||
notifyItemChanged(itemCount - 1)
|
||||
}
|
||||
} else if (v.id == R.id.home_subject_failure) {
|
||||
mViewModel.getSubjectDigest(false)
|
||||
} else if (v.id == R.id.viewpager_tv_failure) {
|
||||
mViewModel.getSlideData(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindGameViewPagerView(holder: GameViewPagerViewHolder, position: Int) {
|
||||
val subjectDigestList = mItemDataList[position].subjectRecommend
|
||||
val binding = holder.binding
|
||||
|
||||
binding.list = subjectDigestList
|
||||
binding.clickListener = OnViewClickListener { v, data ->
|
||||
if (data is Int) {
|
||||
DataUtils.onMtaEvent(mContext, "推荐入口", if (TextUtils.isEmpty(blockName)) "首页" else blockName, (data + 1).toString())
|
||||
if (data < subjectDigestList?.size!!) {
|
||||
val entity = subjectDigestList[data]
|
||||
when {
|
||||
entity.type == "block" -> mContext.startActivity(BlockActivity.getIntent(mContext, entity))
|
||||
entity.type == "category" -> mContext.startActivity(CategoryDirectoryActivity.getIntent(mContext, entity.link!!, entity.text!!))
|
||||
entity.type == "column" -> {
|
||||
SubjectActivity.startSubjectActivity(mContext, entity.link, entity.text, entity.order
|
||||
, StringUtils.buildString("(游戏-专题:", entity.name, "[1-", (data + 1).toString(), "]", ")"))
|
||||
DataCollectionUtils.uploadPosition(mContext, "游戏", (data + 1).toString(), entity.name)
|
||||
}
|
||||
entity.type == "game" -> GameDetailActivity.startGameDetailActivity(mContext, entity.link, "(推荐入口)")
|
||||
entity.type == EntranceUtils.HOST_COMMUNITY -> DirectUtils.directToCommunity(mContext, CommunityEntity(entity.link!!, entity.text!!))
|
||||
else -> DialogUtils.showLowVersionDialog(mContext)
|
||||
}
|
||||
}
|
||||
} else if (v.id == R.id.home_subject_failure) {
|
||||
mViewModel.getSubjectDigest(false)
|
||||
} else if (v.id == R.id.viewpager_tv_failure) {
|
||||
mViewModel.getSlideData(false)
|
||||
}
|
||||
}
|
||||
|
||||
if (mViewModel.blockData != null) {
|
||||
if (subjectDigestList != null && subjectDigestList.size >= 5) {
|
||||
ImageUtils.display(binding.entranceIcon5, subjectDigestList[4].icon)
|
||||
binding.entranceName5.text = if (Config.isShowPlugin()) subjectDigestList[4].name else subjectDigestList[4].nameNormal
|
||||
}
|
||||
} else {
|
||||
ImageUtils.display(binding.entranceIcon5, R.drawable.home_entrance_kaifu)
|
||||
binding.entranceName5.text = "开服表"
|
||||
}
|
||||
|
||||
binding.entranceContainer5.setOnClickListener {
|
||||
DataUtils.onMtaEvent(mContext, "推荐入口", if (TextUtils.isEmpty(blockName)) "首页" else blockName, "5")
|
||||
if (mViewModel.blockData != null) {
|
||||
if (subjectDigestList != null && subjectDigestList.size >= 5) {
|
||||
ImageUtils.display(binding.entranceIcon5, subjectDigestList[4].icon)
|
||||
binding.entranceName5.text = if (Config.isShowPlugin()) subjectDigestList[4].name else subjectDigestList[4].nameNormal
|
||||
val entity = subjectDigestList[4]
|
||||
when {
|
||||
entity.type == "block" -> mContext.startActivity(BlockActivity.getIntent(mContext, entity))
|
||||
entity.type == "category" -> mContext.startActivity(CategoryDirectoryActivity.getIntent(mContext, entity.link!!, entity.text!!))
|
||||
entity.type == "column" -> {
|
||||
SubjectActivity.startSubjectActivity(mContext, entity.link, entity.text, entity.order
|
||||
, StringUtils.buildString("(游戏-专题:", entity.name, "[1-", (5).toString(), "]", ")"))
|
||||
DataCollectionUtils.uploadPosition(mContext, "游戏", (5).toString(), entity.name)
|
||||
}
|
||||
entity.type == "game" -> GameDetailActivity.startGameDetailActivity(mContext, entity.link, "(推荐入口)")
|
||||
entity.type == EntranceUtils.HOST_COMMUNITY -> DirectUtils.directToCommunity(mContext, CommunityEntity(entity.link!!, entity.text!!))
|
||||
else -> DialogUtils.showLowVersionDialog(mContext)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ImageUtils.display(binding.entranceIcon5, R.drawable.home_entrance_kaifu)
|
||||
binding.entranceName5.text = "开服表"
|
||||
val intent = KaiFuActivity.getIntent(mContext, "(游戏-专题:开服表[1-4])")
|
||||
mContext.startActivity(intent)
|
||||
DataCollectionUtils.uploadPosition(mContext, "游戏", "4", "开服表")
|
||||
}
|
||||
}
|
||||
|
||||
binding.entranceContainer5.setOnClickListener {
|
||||
DataUtils.onMtaEvent(mContext, "推荐入口", if (TextUtils.isEmpty(blockName)) "首页" else blockName, "5")
|
||||
if (mViewModel.blockData != null) {
|
||||
if (subjectDigestList != null && subjectDigestList.size >= 5) {
|
||||
val entity = subjectDigestList[4]
|
||||
when {
|
||||
entity.type == "block" -> mContext.startActivity(BlockActivity.getIntent(mContext, entity))
|
||||
entity.type == "category" -> mContext.startActivity(CategoryDirectoryActivity.getIntent(mContext, entity.link!!, entity.text!!))
|
||||
entity.type == "column" -> {
|
||||
SubjectActivity.startSubjectActivity(mContext, entity.link, entity.text, entity.order
|
||||
, StringUtils.buildString("(游戏-专题:", entity.name, "[1-", (5).toString(), "]", ")"))
|
||||
DataCollectionUtils.uploadPosition(mContext, "游戏", (5).toString(), entity.name)
|
||||
}
|
||||
entity.type == "game" -> GameDetailActivity.startGameDetailActivity(mContext, entity.link, "(推荐入口)")
|
||||
entity.type == EntranceUtils.HOST_COMMUNITY -> DirectUtils.directToCommunity(mContext, CommunityEntity(entity.link!!, entity.text!!))
|
||||
else -> DialogUtils.showLowVersionDialog(mContext)
|
||||
}
|
||||
}
|
||||
val slideList = mItemDataList[position].slideList
|
||||
val pagerAdapter = binding.viewPager.adapter
|
||||
if (slideList != null && slideList.isNotEmpty() &&
|
||||
(pagerAdapter == null ||
|
||||
pagerAdapter is ImagePagerAdapter &&
|
||||
pagerAdapter.dataSize == slideList.size)) {
|
||||
binding.viewpagerLlHint.removeAllViews()
|
||||
val margin = DisplayUtils.dip2px(mContext, 6f)
|
||||
var i = 0
|
||||
val size = slideList.size
|
||||
while (i < size) {
|
||||
val imageView = ImageView(mContext)
|
||||
val lparams = LinearLayout.LayoutParams(margin, margin)
|
||||
if (i == 0) {
|
||||
imageView.setImageResource(R.drawable.oval_hint_up)
|
||||
} else {
|
||||
val intent = KaiFuActivity.getIntent(mContext, "(游戏-专题:开服表[1-4])")
|
||||
mContext.startActivity(intent)
|
||||
DataCollectionUtils.uploadPosition(mContext, "游戏", "4", "开服表")
|
||||
imageView.setImageResource(R.drawable.oval_hint_dn)
|
||||
}
|
||||
if (i != 0) {
|
||||
lparams.leftMargin = margin
|
||||
}
|
||||
imageView.layoutParams = lparams
|
||||
binding.viewpagerLlHint.addView(imageView)
|
||||
i++
|
||||
}
|
||||
|
||||
val slideList = mItemDataList[position].slideList
|
||||
val pagerAdapter = binding.viewPager.adapter
|
||||
if (slideList != null && slideList.isNotEmpty() &&
|
||||
(pagerAdapter == null ||
|
||||
pagerAdapter is ImagePagerAdapter &&
|
||||
pagerAdapter.dataSize == slideList.size)) {
|
||||
binding.viewpagerLlHint.removeAllViews()
|
||||
val margin = DisplayUtils.dip2px(mContext, 6f)
|
||||
var i = 0
|
||||
val size = slideList.size
|
||||
while (i < size) {
|
||||
val imageView = ImageView(mContext)
|
||||
val lparams = LinearLayout.LayoutParams(margin, margin)
|
||||
if (i == 0) {
|
||||
imageView.setImageResource(R.drawable.oval_hint_up)
|
||||
binding.viewPager.adapter = ImagePagerAdapter(mContext, slideList, true, if (TextUtils.isEmpty(blockName)) "首页" else blockName)
|
||||
binding.viewPager.interval = 3000
|
||||
binding.viewPager.startAutoScroll()
|
||||
binding.viewPager.doOnPageSelected {
|
||||
var j = 0
|
||||
val childCount = binding.viewpagerLlHint.childCount
|
||||
while (j < childCount) {
|
||||
if (j == it % childCount) {
|
||||
(binding.viewpagerLlHint.getChildAt(j) as ImageView)
|
||||
.setImageResource(R.drawable.oval_hint_up)
|
||||
} else {
|
||||
imageView.setImageResource(R.drawable.oval_hint_dn)
|
||||
(binding.viewpagerLlHint.getChildAt(j) as ImageView)
|
||||
.setImageResource(R.drawable.oval_hint_dn)
|
||||
}
|
||||
if (i != 0) {
|
||||
lparams.leftMargin = margin
|
||||
}
|
||||
imageView.layoutParams = lparams
|
||||
binding.viewpagerLlHint.addView(imageView)
|
||||
i++
|
||||
j++
|
||||
}
|
||||
|
||||
binding.viewPager.adapter = ImagePagerAdapter(mContext, slideList, true, if (TextUtils.isEmpty(blockName)) "首页" else blockName)
|
||||
binding.viewPager.interval = 3000
|
||||
binding.viewPager.startAutoScroll()
|
||||
binding.viewPager.doOnPageSelected {
|
||||
var j = 0
|
||||
val childCount = binding.viewpagerLlHint.childCount
|
||||
while (j < childCount) {
|
||||
if (j == it % childCount) {
|
||||
(binding.viewpagerLlHint.getChildAt(j) as ImageView)
|
||||
.setImageResource(R.drawable.oval_hint_up)
|
||||
} else {
|
||||
(binding.viewpagerLlHint.getChildAt(j) as ImageView)
|
||||
.setImageResource(R.drawable.oval_hint_dn)
|
||||
}
|
||||
j++
|
||||
}
|
||||
}
|
||||
} else if (slideList != null && slideList.isNotEmpty() && pagerAdapter != null) {
|
||||
(pagerAdapter as ImagePagerAdapter).checkResetData(slideList)
|
||||
} else if (slideList == null || slideList.isEmpty()) {
|
||||
binding.viewPager.adapter = null
|
||||
}
|
||||
} else if (slideList != null && slideList.isNotEmpty() && pagerAdapter != null) {
|
||||
(pagerAdapter as ImagePagerAdapter).checkResetData(slideList)
|
||||
} else if (slideList == null || slideList.isEmpty()) {
|
||||
binding.viewPager.adapter = null
|
||||
}
|
||||
|
||||
if (mViewModel.blockData != null) {
|
||||
binding.viewpagerContainer.visibility = if (slideList!!.isEmpty()) View.GONE else View.VISIBLE
|
||||
binding.entranceContainer.visibility = if (subjectDigestList!!.isEmpty()) View.GONE else View.VISIBLE
|
||||
}
|
||||
if (mViewModel.blockData != null) {
|
||||
binding.viewpagerContainer.visibility = if (slideList!!.isEmpty()) View.GONE else View.VISIBLE
|
||||
binding.entranceContainer.visibility = if (subjectDigestList!!.isEmpty()) View.GONE else View.VISIBLE
|
||||
}
|
||||
|
||||
if (isAutoScroll) {
|
||||
binding.viewPager.startAutoScroll()
|
||||
if (isAutoScroll) {
|
||||
binding.viewPager.startAutoScroll()
|
||||
} else {
|
||||
binding.viewPager.stopAutoScroll()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun bindGameItemView(holder: GameItemViewHolder, position: Int) {
|
||||
val itemData = mItemDataList[position]
|
||||
val gameEntity = itemData.game
|
||||
val subjectData = gameEntity?.subjectData
|
||||
|
||||
if (mItemDataList[position - 1].game == null) {
|
||||
holder.itemView.setPadding(DisplayUtils.dip2px(8F), DisplayUtils.dip2px(10.5F),
|
||||
DisplayUtils.dip2px(20F), DisplayUtils.dip2px(6F))
|
||||
} else {
|
||||
holder.itemView.setPadding(DisplayUtils.dip2px(8F), DisplayUtils.dip2px(6F),
|
||||
DisplayUtils.dip2px(20F), DisplayUtils.dip2px(6F))
|
||||
}
|
||||
holder.binding.game = gameEntity
|
||||
holder.binding.subjectTag = subjectData?.tag
|
||||
holder.initServerType(gameEntity!!)
|
||||
holder.binding.executePendingBindings()
|
||||
|
||||
if (subjectData?.isOrder!!) {
|
||||
holder.binding.gameOrder.visibility = View.VISIBLE
|
||||
holder.binding.gameOrder.text = (subjectData.position).toString()
|
||||
} else {
|
||||
holder.binding.gameOrder.visibility = View.GONE
|
||||
}
|
||||
|
||||
val keyName = if (TextUtils.isEmpty(blockName)) "首页" else "板块"
|
||||
val keyValue = if (TextUtils.isEmpty(blockName)) "" else blockName
|
||||
itemData.exposureEvent = ExposureEvent.createEvent(gameEntity = gameEntity,
|
||||
source = listOf(ExposureSource(keyName, keyValue), ExposureSource("专题", subjectData.name!!)),
|
||||
eTrace = null,
|
||||
event = ExposureType.EXPOSURE)
|
||||
|
||||
DownloadItemUtils.setOnClickListener(mContext, holder.binding.downloadBtn, gameEntity, position,
|
||||
this@GameFragmentAdapter,
|
||||
StringUtils.buildString("(游戏-专题:", subjectData.name, "-列表[", (position + 1).toString(), "])"),
|
||||
StringUtils.buildString("游戏-专题-", subjectData.name, ":", gameEntity.name), itemData.exposureEvent)
|
||||
DownloadItemUtils.updateItem(mContext, gameEntity, GameViewHolder(holder.binding), !gameEntity.isPluggable)
|
||||
holder.itemView.setOnClickListener {
|
||||
DataCollectionUtils.uploadClick(mContext, subjectData.name + "-列表", "游戏-专题", gameEntity.name)
|
||||
|
||||
if (gameEntity.isPluggable) {
|
||||
GameDetailActivity.startGameDetailActivity(mContext, gameEntity.id,
|
||||
StringUtils.buildString("(游戏-专题:插件化-列表[", (subjectData.position).toString(), "])"), itemData.exposureEvent)
|
||||
} else {
|
||||
binding.viewPager.stopAutoScroll()
|
||||
GameDetailActivity.startGameDetailActivity(mContext, gameEntity,
|
||||
StringUtils.buildString("(游戏-专题:", subjectData.name, "-列表[", (subjectData.position).toString(), "])"), itemData.exposureEvent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (holder is FooterViewHolder) {
|
||||
holder.initFooterViewHolder(mLoadStatus == LoadStatus.LIST_LOADING
|
||||
, mLoadStatus == LoadStatus.LIST_FAILED
|
||||
, mLoadStatus == LoadStatus.LIST_OVER, View.OnClickListener {
|
||||
if (mLoadStatus == LoadStatus.LIST_OVER) {
|
||||
mViewModel.commandScrollTop.postValue(null)
|
||||
} else {
|
||||
mViewModel.getSubjectList(false)
|
||||
notifyItemChanged(itemCount - 1)
|
||||
}
|
||||
})
|
||||
} else if (holder is GameImageViewHolder) {
|
||||
val entity = mItemDataList[position].image
|
||||
private fun bindHeadView(holder: GameHeadViewHolder, position: Int) {
|
||||
val column = mItemDataList[position].columnHead
|
||||
holder.binding.subject = column
|
||||
holder.binding.headPb.visibility = View.GONE
|
||||
val text = if ("change" == column?.home) "换一批" else "全部"
|
||||
holder.binding.headMore.text = text
|
||||
|
||||
val keyName = if (TextUtils.isEmpty(blockName)) "首页" else "板块"
|
||||
val keyValue = if (TextUtils.isEmpty(blockName)) "" else blockName
|
||||
if (text == "全部" && column != null && column.data != null && column.data!!.size >= column.more!!) {
|
||||
holder.binding.headMore.visibility = View.GONE
|
||||
} else {
|
||||
holder.binding.headMore.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
entity?.let {
|
||||
if (it.type == "game") {
|
||||
mItemDataList[position].exposureEvent = ExposureEvent.createEvent(gameEntity = entity,
|
||||
source = listOf(ExposureSource(keyName, keyValue), ExposureSource("专题", entity.subjectData?.name + "-大图")),
|
||||
eTrace = null,
|
||||
event = ExposureType.EXPOSURE)
|
||||
}
|
||||
}
|
||||
|
||||
holder.binding.game = entity
|
||||
holder.binding.traceEvent = mItemDataList[position].exposureEvent
|
||||
|
||||
val name = entity?.subjectData?.name
|
||||
val link = entity?.link
|
||||
val width = mContext.resources.displayMetrics.widthPixels - DisplayUtils.dip2px(mContext, 16F)
|
||||
ImageUtils.display(holder.binding.gameImageIcon, entity?.image, width, object : BaseControllerListener<ImageInfo>() {
|
||||
override fun onFinalImageSet(id: String?, imageInfo: ImageInfo?, animatable: Animatable?) {
|
||||
if (imageInfo == null) return
|
||||
val imageParams = holder.binding.gameImageIcon.layoutParams
|
||||
val scale = imageInfo.height.toFloat() / imageInfo.width.toFloat()
|
||||
imageParams?.height = (width * scale).toInt()
|
||||
holder.binding.gameImageIcon.layoutParams = imageParams
|
||||
holder.binding.gameContainer.layoutParams.height = (width * scale).toInt()
|
||||
}
|
||||
})
|
||||
holder.binding.gameImageIcon.setOnClickListener {
|
||||
DataCollectionUtils.uploadClick(mContext, "$name-大图", "游戏-专题")
|
||||
DataUtils.onMtaEvent(mContext, "游戏专题", "大图", name + ":" + entity?.name)
|
||||
val linkEntity = LinkEntity()
|
||||
linkEntity.link = link
|
||||
linkEntity.type = entity?.type
|
||||
linkEntity.text = name
|
||||
DirectUtils.directToLinkPage(mContext, linkEntity, "(游戏-专题:$name-大图)", "首页游戏")
|
||||
}
|
||||
} else if (holder is GameHorizontalListViewHolder) {
|
||||
val subjectEntity = mItemDataList[position].horizontalColumn
|
||||
val exposureEventList = arrayListOf<ExposureEvent>()
|
||||
|
||||
val binding = holder.binding
|
||||
var subjectAdapter = binding.horizontalRv.adapter
|
||||
if (subjectAdapter == null) {
|
||||
subjectAdapter = GameHorizontalAdapter(mContext, subjectEntity!!)
|
||||
(binding.horizontalRv.itemAnimator as DefaultItemAnimator).supportsChangeAnimations = false
|
||||
binding.horizontalRv.layoutManager = GridLayoutManager(mContext, 4)
|
||||
binding.horizontalRv.adapter = subjectAdapter
|
||||
holder.binding.headMore.setOnClickListener {
|
||||
if ("all" == column?.home) {
|
||||
DataUtils.onMtaEvent(mContext, "游戏专题", "全部", column.name)
|
||||
SubjectActivity.startSubjectActivity(mContext, column.id, column.name, column.isOrder, "(游戏-专题:" + column.name + "-全部)")
|
||||
} else {
|
||||
(subjectAdapter as GameHorizontalAdapter).checkResetData(subjectEntity!!)
|
||||
subjectAdapter.notifyItemRangeChanged(0, subjectAdapter.itemCount)
|
||||
DataUtils.onMtaEvent(mContext, "游戏专题", "换一批", column?.name)
|
||||
holder.binding.headPb.visibility = View.VISIBLE
|
||||
mViewModel.changeSubjectGame(column?.id!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
subjectEntity.data?.let {
|
||||
val keyName = if (TextUtils.isEmpty(blockName)) "首页" else "板块"
|
||||
val keyValue = if (TextUtils.isEmpty(blockName)) "" else blockName
|
||||
private fun bindPluginView(holder: GamePluginViewHolder, position: Int) {
|
||||
val pluginList = mItemDataList[position].pluginList
|
||||
var adapter = holder.mPluginRv.adapter
|
||||
|
||||
val positionOffset = subjectAdapter.getIndex()
|
||||
if (adapter == null) {
|
||||
adapter = GamePluginAdapter(mContext, pluginList)
|
||||
adapter.openList(mIsOpenPluginList)
|
||||
(holder.mPluginRv.itemAnimator as DefaultItemAnimator).supportsChangeAnimations = false
|
||||
holder.mPluginRv.layoutManager = LinearLayoutManager(mContext)
|
||||
holder.mPluginRv.adapter = adapter
|
||||
} else {
|
||||
(adapter as GamePluginAdapter).openList(mIsOpenPluginList)
|
||||
adapter.checkResetData(pluginList)
|
||||
}
|
||||
|
||||
for (i in positionOffset until subjectAdapter.itemCount + positionOffset) {
|
||||
it[i].sequence = i
|
||||
val event = ExposureEvent.createEvent(gameEntity = it[i],
|
||||
source = listOf(ExposureSource(keyName, keyValue), ExposureSource("专题", subjectEntity.name!!)),
|
||||
eTrace = null,
|
||||
event = ExposureType.EXPOSURE)
|
||||
exposureEventList.add(event)
|
||||
}
|
||||
mItemDataList[position].exposureEventList = exposureEventList
|
||||
subjectAdapter.exposureEventList = exposureEventList
|
||||
holder.mHeadTitle.text = String.format(Locale.getDefault(), "你有%d个游戏可以升级插件版", pluginList?.size)
|
||||
holder.mPluginHead.setOnClickListener {
|
||||
if (mIsOpenPluginList) {
|
||||
mIsOpenPluginList = false
|
||||
holder.mHeadOpen.setImageResource(R.drawable.gamedetail_open_icon)
|
||||
MtaHelper.onEvent("首页_点击", "插件化区域", "收起")
|
||||
} else {
|
||||
mIsOpenPluginList = true
|
||||
holder.mHeadOpen.setImageResource(R.drawable.gamedetail_colse_icon)
|
||||
MtaHelper.onEvent("首页_点击", "插件化区域", "展开")
|
||||
}
|
||||
notifyItemChanged(holder.adapterPosition)
|
||||
}
|
||||
}
|
||||
|
||||
@ -437,7 +466,15 @@ class GameFragmentAdapter(context: Context, model: GameViewModel, var blockName:
|
||||
val entryMap = gameAndPosition.entity.getEntryMap()
|
||||
entryMap[download.platform] = download
|
||||
}
|
||||
notifyItemChanged(gameAndPosition.position)
|
||||
|
||||
if (getItemViewType(gameAndPosition.position) == ItemViewType.GAME_PLUGIN) {
|
||||
val adapter = mPluginViewHolder?.mPluginRv?.adapter
|
||||
if (adapter is GamePluginAdapter) {
|
||||
adapter.notifyItemByDownload(download)
|
||||
}
|
||||
} else {
|
||||
notifyItemChanged(gameAndPosition.position)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
package com.gh.gamecenter.game
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Application
|
||||
import android.arch.lifecycle.*
|
||||
import android.preference.PreferenceManager
|
||||
import android.support.v4.util.ArrayMap
|
||||
import android.text.TextUtils
|
||||
import com.gh.common.TimeElapsedHelper
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.util.ApkActiveUtils
|
||||
import com.gh.common.util.GameUtils
|
||||
import com.gh.common.util.RandomUtils
|
||||
import com.gh.common.util.*
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.baselist.LoadStatus
|
||||
import com.gh.gamecenter.entity.*
|
||||
@ -27,52 +27,59 @@ import java.util.HashMap
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.collections.set
|
||||
|
||||
class GameViewModel(application: Application, var blockData: SubjectRecommendEntity?)
|
||||
: AndroidViewModel(application) {
|
||||
|
||||
class GameViewModel(application: Application, blockData: SubjectRecommendEntity?) : AndroidViewModel(application) {
|
||||
private var mSlideList = ArrayList<LinkEntity>() // 轮播图
|
||||
private var mPluginList: List<GameEntity>? = null // 插件化
|
||||
private var mSubjectList: MutableList<SubjectEntity> = ArrayList() // 专题
|
||||
private var mSubjectDigestList = ArrayList<SubjectRecommendEntity>() // 专题入口
|
||||
private var mSmartSubject: SubjectEntity? = null // 插件化
|
||||
|
||||
var mApi = RetrofitManager.getInstance(getApplication()).api
|
||||
private val mItemDataListCache: MutableList<GameItemData> = ArrayList()
|
||||
private val mSubjectChangedMap: ArrayMap<String, List<GameEntity>> = ArrayMap() // 存储换一换的数据
|
||||
|
||||
var blockData = blockData
|
||||
private var mSubjectPage = 1 // 专题分页
|
||||
private var mIsLoading = false
|
||||
|
||||
var slideList = ArrayList<LinkEntity>() // 轮播图
|
||||
var pluginList: List<GameEntity>? = null // 插件化
|
||||
var subjectList: MutableList<SubjectEntity> = ArrayList() // 专题
|
||||
var subjectDigestList = ArrayList<SubjectRecommendEntity>() // 专题入口
|
||||
var smartSubject: SubjectEntity? = null // 插件化
|
||||
private var mApi = RetrofitManager.getInstance(getApplication()).api
|
||||
|
||||
private var mElapsedHelper: TimeElapsedHelper? = null
|
||||
|
||||
private var mShouldLogReplacingGame = true
|
||||
|
||||
var itemDataList: MediatorLiveData<List<GameItemData>> = MediatorLiveData()
|
||||
val loadStatus = MutableLiveData<LoadStatus>()
|
||||
val openingDialog = MutableLiveData<WelcomeDialogEntity>()
|
||||
|
||||
val mSubjectChangedMap: ArrayMap<String, List<GameEntity>> = ArrayMap() //存储换一换的数据
|
||||
var positionAndPackageMap = HashMap<String, Int>() // key: packageName + position, value: position
|
||||
private val itemDataListCache: MutableList<GameItemData> = ArrayList()
|
||||
|
||||
val commandScrollTop = MutableLiveData<Any>()
|
||||
|
||||
private var mSubjectPage = 1 // 专分页
|
||||
|
||||
private var mIsLoading = false
|
||||
|
||||
var positionAndPackageMap = HashMap<String, Int>() // key: packageName + position, value: position
|
||||
|
||||
init {
|
||||
if (blockData == null) {
|
||||
itemDataList.addSource(PackageRepository.gameUpdateLiveData) {
|
||||
initPlugin(it)
|
||||
|
||||
// 第一次加载开始计时,供加载成功查看加载用时
|
||||
mElapsedHelper = TimeElapsedHelper()
|
||||
mElapsedHelper?.resumeCounting()
|
||||
}
|
||||
}
|
||||
initData()
|
||||
}
|
||||
|
||||
fun initData() {
|
||||
slideList.clear()
|
||||
subjectList.clear()
|
||||
subjectDigestList.clear()
|
||||
itemDataListCache.clear()
|
||||
mSlideList.clear()
|
||||
mSubjectList.clear()
|
||||
mSubjectDigestList.clear()
|
||||
mItemDataListCache.clear()
|
||||
|
||||
loadStatus.postValue(LoadStatus.INIT_LOADING)
|
||||
getSlideData(true)
|
||||
getSmartColumn()
|
||||
|
||||
// 触发列表刷新行为时亦刷新内存中的备用游戏库列表
|
||||
GameRepositoryHelper.refreshGameRepository()
|
||||
}
|
||||
|
||||
private fun initPlugin(updateList: List<GameUpdateEntity>?) {
|
||||
@ -87,14 +94,14 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
|
||||
for (game in list) {
|
||||
game.setEntryMap(DownloadManager.getInstance(getApplication()).getEntryMap(game.name))
|
||||
}
|
||||
pluginList = list
|
||||
mPluginList = list
|
||||
transformationItemData()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取启动弹窗
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
fun requestOpeningData() {
|
||||
val lastId = PreferenceManager.getDefaultSharedPreferences(getApplication()).getString(Constants.SP_LAST_OPENING_ID, "")
|
||||
val lastTime = PreferenceManager.getDefaultSharedPreferences(getApplication()).getLong(Constants.SP_LAST_OPENING_TIME, 0)
|
||||
@ -122,7 +129,7 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<List<LinkEntity>>() {
|
||||
override fun onResponse(response: List<LinkEntity>?) {
|
||||
if (response != null) slideList.addAll(response)
|
||||
if (response != null) mSlideList.addAll(response)
|
||||
if (initData) getSubjectDigest(initData)
|
||||
}
|
||||
|
||||
@ -138,12 +145,18 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
|
||||
if (initData) getSubjectList(initData)
|
||||
return
|
||||
}
|
||||
val observable = if (blockData == null) mApi.subjectDigest else mApi.getBlockRecommends(blockData?.link)
|
||||
|
||||
val observable = if (blockData == null) {
|
||||
mApi.subjectDigest
|
||||
} else {
|
||||
mApi.getBlockRecommends(blockData?.link)
|
||||
}
|
||||
|
||||
observable.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<List<SubjectRecommendEntity>>() {
|
||||
override fun onResponse(response: List<SubjectRecommendEntity>?) {
|
||||
if (response != null) subjectDigestList.addAll(response)
|
||||
if (response != null) mSubjectDigestList.addAll(response)
|
||||
transformationItemData()
|
||||
if (initData) {
|
||||
getSubjectList(initData)
|
||||
@ -169,7 +182,13 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
|
||||
} else {
|
||||
loadStatus.postValue(LoadStatus.LIST_LOADING)
|
||||
}
|
||||
val observable = if (blockData == null) mApi.getColumn(mSubjectPage) else mApi.getBlockColumns(blockData?.link, mSubjectPage)
|
||||
|
||||
val observable = if (blockData == null) {
|
||||
mApi.getColumn(mSubjectPage)
|
||||
} else {
|
||||
mApi.getBlockColumns(blockData?.link, mSubjectPage)
|
||||
}
|
||||
|
||||
observable.subscribeOn(Schedulers.io())
|
||||
.map {
|
||||
for (subjectEntity in it) {
|
||||
@ -188,7 +207,7 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
|
||||
if (response != null) {
|
||||
when {
|
||||
initData -> {
|
||||
subjectList = response as MutableList<SubjectEntity>
|
||||
mSubjectList = response as MutableList<SubjectEntity>
|
||||
loadStatus.postValue(LoadStatus.INIT_LOADED)
|
||||
transformationItemData()
|
||||
}
|
||||
@ -196,7 +215,7 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
|
||||
loadStatus.postValue(LoadStatus.LIST_OVER)
|
||||
}
|
||||
else -> {
|
||||
subjectList.addAll(response)
|
||||
mSubjectList.addAll(response)
|
||||
loadStatus.postValue(LoadStatus.LIST_LOADED)
|
||||
transformationItemData()
|
||||
}
|
||||
@ -204,19 +223,39 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
|
||||
}
|
||||
mSubjectPage++
|
||||
mIsLoading = false
|
||||
|
||||
logSuccess()
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
if (initData && slideList.isEmpty() && subjectDigestList.isEmpty()) {
|
||||
if (initData && mSlideList.isEmpty() && mSubjectDigestList.isEmpty()) {
|
||||
loadStatus.postValue(LoadStatus.INIT_FAILED)
|
||||
} else {
|
||||
loadStatus.postValue(LoadStatus.LIST_FAILED)
|
||||
}
|
||||
mIsLoading = false
|
||||
|
||||
logFailure()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun logFailure() {
|
||||
mElapsedHelper?.let {
|
||||
it.pauseCounting()
|
||||
mElapsedHelper = null
|
||||
MtaHelper.onEvent("首页_加载", "启动光环", "加载失败")
|
||||
}
|
||||
}
|
||||
|
||||
private fun logSuccess() {
|
||||
mElapsedHelper?.let {
|
||||
it.pauseCounting()
|
||||
MtaHelper.onEventWithTime("首页_加载", it.elapsedTime, "启动光环", "加载成功")
|
||||
mElapsedHelper = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun getSmartColumn() {
|
||||
if (blockData != null) return
|
||||
mApi.smartColumn
|
||||
@ -224,11 +263,7 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<SubjectEntity>() {
|
||||
override fun onResponse(response: SubjectEntity?) {
|
||||
smartSubject = response
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
|
||||
mSmartSubject = response
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -269,7 +304,7 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
|
||||
private fun initRandomGame(subjectId: String, sourceList: List<GameEntity>?) {
|
||||
|
||||
var rawList: MutableList<GameEntity>? = null
|
||||
for (entity in subjectList) {
|
||||
for (entity in mSubjectList) {
|
||||
if (entity.id == subjectId) rawList = entity.data
|
||||
}
|
||||
if (rawList == null) return
|
||||
@ -302,46 +337,50 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
|
||||
}
|
||||
|
||||
private fun transformationItemData() {
|
||||
itemDataListCache.clear()
|
||||
mItemDataListCache.clear()
|
||||
positionAndPackageMap.clear()
|
||||
|
||||
// 插入智能推荐专题
|
||||
if (smartSubject != null && subjectList.size > smartSubject!!.sort) {
|
||||
subjectList.add(smartSubject!!.sort, smartSubject!!)
|
||||
smartSubject = null // 防止重复插入
|
||||
if (mSmartSubject != null && mSubjectList.size > mSmartSubject!!.sort) {
|
||||
mSubjectList.add(mSmartSubject!!.sort, mSmartSubject!!)
|
||||
mSmartSubject = null // 防止重复插入
|
||||
}
|
||||
|
||||
// 轮播图+专题入口
|
||||
if (blockData == null || blockData?.display?.recommend!! || blockData?.display?.slide!!) {
|
||||
val itemDataTop = GameItemData()
|
||||
itemDataTop.slideList = slideList
|
||||
itemDataTop.subjectRecommend = subjectDigestList
|
||||
itemDataListCache.add(itemDataTop)
|
||||
itemDataTop.slideList = mSlideList
|
||||
itemDataTop.subjectRecommend = mSubjectDigestList
|
||||
mItemDataListCache.add(itemDataTop)
|
||||
}
|
||||
|
||||
// 插件化
|
||||
if (pluginList != null && pluginList!!.isNotEmpty()) {
|
||||
if (mPluginList != null && mPluginList!!.isNotEmpty()) {
|
||||
val itemDataPlugin = GameItemData()
|
||||
itemDataPlugin.pluginList = pluginList
|
||||
itemDataListCache.add(itemDataPlugin)
|
||||
itemDataPlugin.pluginList = mPluginList
|
||||
mItemDataListCache.add(itemDataPlugin)
|
||||
|
||||
for (entity in pluginList!!) {
|
||||
for (entity in mPluginList!!) {
|
||||
addGamePositionAndPackage(entity)
|
||||
}
|
||||
}
|
||||
|
||||
// 专题 "type": "image/game_vertical/game_horizontal"
|
||||
for (subjectEntity in subjectList) {
|
||||
for (subjectEntity in mSubjectList) {
|
||||
val data = subjectEntity.data
|
||||
if (data == null || data.isEmpty()) continue
|
||||
|
||||
subjectEntity.relatedColumnId?.let {
|
||||
replaceInstalledApp(data, it)
|
||||
}
|
||||
|
||||
if (!data[0].image.isNullOrEmpty()) {
|
||||
val itemDataImage = GameItemData()
|
||||
val gameEntity = data[0]
|
||||
if (gameEntity.id.isNullOrEmpty()) gameEntity.id = gameEntity.link
|
||||
itemDataImage.image = gameEntity
|
||||
itemDataImage.image?.subjectData = GameSubjectData(name = subjectEntity.name, isOrder = false)
|
||||
itemDataListCache.add(itemDataImage)
|
||||
mItemDataListCache.add(itemDataImage)
|
||||
if (gameEntity.type == "game") addGamePositionAndPackage(gameEntity)
|
||||
|
||||
if (subjectEntity.type == "image") continue
|
||||
@ -349,12 +388,12 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
|
||||
|
||||
val itemDataHead = GameItemData()
|
||||
itemDataHead.columnHead = subjectEntity
|
||||
itemDataListCache.add(itemDataHead)
|
||||
mItemDataListCache.add(itemDataHead)
|
||||
|
||||
if (subjectEntity.type == "game_horizontal") {
|
||||
val itemDataSubject = GameItemData()
|
||||
itemDataSubject.horizontalColumn = subjectEntity
|
||||
itemDataListCache.add(itemDataSubject)
|
||||
mItemDataListCache.add(itemDataSubject)
|
||||
for (game in subjectEntity.data!!) {
|
||||
addGamePositionAndPackage(game)
|
||||
}
|
||||
@ -370,12 +409,69 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
|
||||
val itemDataGame = GameItemData()
|
||||
game.sequence = i
|
||||
itemDataGame.game = game
|
||||
itemDataListCache.add(itemDataGame)
|
||||
mItemDataListCache.add(itemDataGame)
|
||||
addGamePositionAndPackage(game)
|
||||
}
|
||||
}
|
||||
|
||||
itemDataList.postValue(itemDataListCache)
|
||||
itemDataList.postValue(mItemDataListCache)
|
||||
}
|
||||
|
||||
private fun replaceInstalledApp(gameList: MutableList<GameEntity>, relatedCollectionId: String) {
|
||||
val gameIdList = arrayListOf<String>() // 专题包含的游戏 ID 列表
|
||||
val positionOfTheGameToReplaceList = arrayListOf<Int>()
|
||||
|
||||
// 标记需要替换的已安装游戏
|
||||
for ((index, game) in gameList.withIndex()) {
|
||||
gameIdList.add(game.id ?: "")
|
||||
|
||||
// 是大图形式的游戏时不标记替换
|
||||
if ((index == 0 && !gameList[0].image.isNullOrEmpty())) {
|
||||
continue
|
||||
}
|
||||
|
||||
var isThisPositionAdded = false
|
||||
// 检查是否已安装该游戏里同包名的 APK
|
||||
for (apk in game.getApk()) {
|
||||
if (PackageHelper.validLocalPackageNameSet.contains(apk.packageName)) {
|
||||
// 将该位置的游戏标记为需要替换
|
||||
positionOfTheGameToReplaceList.add(index)
|
||||
isThisPositionAdded = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// 若此游戏所包含的 apk 没有已安装,那么再检查是否已安装有预设相关包名
|
||||
if (!isThisPositionAdded) {
|
||||
var relatedPackageList = arrayListOf<String>()
|
||||
for (entity in PackageHelper.relatedPackageList) {
|
||||
if (entity.gameId == game.id) {
|
||||
relatedPackageList = ArrayList(entity.packages)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
for (packageName in relatedPackageList) {
|
||||
if (PackageHelper.validLocalPackageNameSet.contains(packageName)) {
|
||||
positionOfTheGameToReplaceList.add(index)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (positionOfTheGameToReplaceList.isNotEmpty()) {
|
||||
if (blockData == null && mShouldLogReplacingGame) {
|
||||
mShouldLogReplacingGame = false
|
||||
MtaHelper.onEvent("首页_加载", "启动光环", "替换游戏")
|
||||
}
|
||||
for (position in positionOfTheGameToReplaceList) {
|
||||
val replacingGame = GameRepositoryHelper.getOneUniqueGame(relatedCollectionId, gameIdList)
|
||||
replacingGame?.let {
|
||||
gameList[position] = replacingGame
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun addGamePositionAndPackage(game: GameEntity) {
|
||||
@ -383,15 +479,12 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
|
||||
for (apkEntity in game.getApk()) {
|
||||
packages += apkEntity.packageName
|
||||
}
|
||||
positionAndPackageMap[packages + (itemDataListCache.size - 1)] = itemDataListCache.size - 1
|
||||
positionAndPackageMap[packages + (mItemDataListCache.size - 1)] = mItemDataListCache.size - 1
|
||||
game.gameLocation = GameEntity.GameLocation.INDEX
|
||||
game.setEntryMap(DownloadManager.getInstance(getApplication()).getEntryMap(game.name))
|
||||
|
||||
}
|
||||
|
||||
|
||||
class Factory(val mApplication: Application, val blockData: SubjectRecommendEntity?) : ViewModelProvider.NewInstanceFactory() {
|
||||
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
|
||||
return GameViewModel(mApplication, blockData) as T
|
||||
|
||||
@ -43,7 +43,6 @@ class GameHorizontalAdapter(context: Context, subject: SubjectEntity) : BaseRecy
|
||||
holder.itemView?.setOnClickListener {
|
||||
GameDetailActivity.startGameDetailActivity(mContext, gameEntity,
|
||||
StringUtils.buildString("(游戏-专题:", mSubjectEntity.name, "-列表[", (position + 1).toString(), "])"), exposureEventList!![position])
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,8 @@ import android.widget.CheckedTextView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.ethanhua.skeleton.Skeleton;
|
||||
import com.ethanhua.skeleton.ViewSkeletonScreen;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.exposure.ExposureEvent;
|
||||
@ -72,7 +74,7 @@ import retrofit2.HttpException;
|
||||
|
||||
/**
|
||||
* Created by CsHeng on 19/12/2017.
|
||||
* \游戏详情适配器
|
||||
* 游戏详情适配器
|
||||
*/
|
||||
public class GameDetailFragment extends NormalFragment {
|
||||
|
||||
@ -125,6 +127,10 @@ public class GameDetailFragment extends NormalFragment {
|
||||
View mNoneDataView;
|
||||
@BindView(R.id.reuse_tv_none_data)
|
||||
TextView mNoneDataTv;
|
||||
@BindView(R.id.list_skeleton)
|
||||
View mListSkeleton;
|
||||
|
||||
private ViewSkeletonScreen mSkeleton;
|
||||
|
||||
private GameDetailViewModel mViewModel;
|
||||
|
||||
@ -145,6 +151,8 @@ public class GameDetailFragment extends NormalFragment {
|
||||
private boolean mAutoDownload;
|
||||
private boolean mSwitchToFirstTabInStartup;
|
||||
private boolean mSkipGameComment;
|
||||
private boolean mIsPageChanged;
|
||||
private boolean mIsOpenPlatformWindow;
|
||||
private int mCurVpPosition;
|
||||
private int mMaxWidth;
|
||||
|
||||
@ -206,6 +214,9 @@ public class GameDetailFragment extends NormalFragment {
|
||||
mAutoDownload = args.getBoolean(EntranceUtils.KEY_AUTO_DOWNLOAD);
|
||||
mTraceEvent = args.getParcelable(EntranceUtils.KEY_TRACE_EVENT);
|
||||
mSkipGameComment = args.getBoolean(EntranceUtils.KEY_SKIP_GAME_COMMENT);
|
||||
mIsOpenPlatformWindow = args.getBoolean(EntranceUtils.KEY_OPEN_PLATFORM_WINDOW);
|
||||
|
||||
mSkeleton = Skeleton.bind(mListSkeleton).shimmer(false).load(R.layout.fragment_gamedetail_skeleton).show();
|
||||
|
||||
GameDetailViewModel.Factory factory = new GameDetailViewModel.Factory(HaloApp.getInstance().getApplication(),
|
||||
args.getString(EntranceUtils.KEY_GAMEID),
|
||||
@ -231,7 +242,7 @@ public class GameDetailFragment extends NormalFragment {
|
||||
|
||||
pauseVideo();
|
||||
if (mFirstTimeSelected) {
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情", "默认_动态", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情_新", "默认_动态", mGameEntity.getName());
|
||||
}
|
||||
} else if (position == INDEX_DESCRIPTION) {
|
||||
mKaifuHint.setVisibility(View.GONE);
|
||||
@ -240,7 +251,7 @@ public class GameDetailFragment extends NormalFragment {
|
||||
mTabBarRatingTv.setChecked(false);
|
||||
|
||||
if (mFirstTimeSelected) {
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情", "默认_介绍", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情_新", "默认_介绍", mGameEntity.getName());
|
||||
}
|
||||
} else {
|
||||
mKaifuHint.setVisibility(View.GONE);
|
||||
@ -250,10 +261,11 @@ public class GameDetailFragment extends NormalFragment {
|
||||
|
||||
pauseVideo();
|
||||
if (mFirstTimeSelected) {
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情", "默认_评分", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情_新", "默认_评分", mGameEntity.getName());
|
||||
}
|
||||
}
|
||||
mFirstTimeSelected = false;
|
||||
mIsPageChanged = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -330,19 +342,21 @@ public class GameDetailFragment extends NormalFragment {
|
||||
|
||||
if (!mGameDetailEntity.getMe().isGameConcerned()) {
|
||||
if (PackagesManager.findInstallById(mGameEntity.getId()) == null) {
|
||||
mTabBarXinXiTv.performClick();
|
||||
tabPerformClick(mTabBarXinXiTv);
|
||||
}
|
||||
}
|
||||
|
||||
if (mAutoDownload) {
|
||||
if (mAutoDownload || (mIsOpenPlatformWindow && mGameEntity.getApk().size() > 1)) {
|
||||
viewHolder.mDownloadPb.performClick();
|
||||
mAutoDownload = false;
|
||||
}
|
||||
|
||||
if (mSwitchToFirstTabInStartup) mViewPager.setCurrentItem(0);
|
||||
|
||||
mSkeleton.hide();
|
||||
} else if (detailResource.status == Status.ERROR) {
|
||||
loadErrorControl(detailResource.exception);
|
||||
mSkeleton.hide();
|
||||
}
|
||||
});
|
||||
|
||||
@ -353,7 +367,7 @@ public class GameDetailFragment extends NormalFragment {
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
kv.put("状态", R.string.concern);
|
||||
DataUtils.onEvent(getContext(), "游戏关注", mGameEntity.getName(), kv);
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情", "关注", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情_新", "关注", mGameEntity.getName());
|
||||
DataCollectionUtils.uploadConcern(getContext(), mGameEntity.getName(), mGameEntity.getId(), "关注");
|
||||
GdtHelper.INSTANCE.logAction(ActionType.ADD_TO_WISHLIST,
|
||||
GdtHelper.CONTENT_TYPE, "GAME",
|
||||
@ -372,7 +386,7 @@ public class GameDetailFragment extends NormalFragment {
|
||||
|
||||
DataCollectionUtils.uploadConcern(getContext(),
|
||||
mGameEntity.getName(), mGameEntity.getId(), "取消关注");
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情", "取消关注", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情_新", "取消关注", mGameEntity.getName());
|
||||
|
||||
mConcernMenuItem.setIcon(R.drawable.game_detail_concern_unselect);
|
||||
} else {
|
||||
@ -440,7 +454,7 @@ public class GameDetailFragment extends NormalFragment {
|
||||
mGameEntity.getName(), shareType);
|
||||
}
|
||||
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情", "分享按钮", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情_新", "分享按钮", mGameEntity.getName());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -470,7 +484,7 @@ public class GameDetailFragment extends NormalFragment {
|
||||
mTabBarRatingTv.setVisibility(View.VISIBLE);
|
||||
tabParams.width = mMaxWidth;
|
||||
if (mSkipGameComment) {
|
||||
mTabBarRatingTv.performClick();
|
||||
tabPerformClick(mTabBarRatingTv);
|
||||
mSkipGameComment = false;
|
||||
}
|
||||
} else {
|
||||
@ -552,16 +566,16 @@ public class GameDetailFragment extends NormalFragment {
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMainThread(EBReuse reuse) {
|
||||
if (SKIP_DESC.equals(reuse.getType())) {
|
||||
mViewPager.setCurrentItem(1);
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情", "默认_介绍", mGameEntity.getName());
|
||||
tabPerformClick(mTabBarXinXiTv);
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情_新", "默认_介绍", mGameEntity.getName());
|
||||
} else if (OPEN_APPBAR.equals(reuse.getType()) && !mIsTouchScreen) {
|
||||
mAppBarLayout.setExpanded(true, true);
|
||||
} else if (SKIP_FULI.equals(reuse.getType())) {
|
||||
mViewPager.setCurrentItem(0);
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情", "默认_动态", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情_新", "默认_动态", mGameEntity.getName());
|
||||
} else if (SKIP_RATING.equals(reuse.getType())) {
|
||||
mViewPager.setCurrentItem(2);
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情", "默认_评分", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情_新", "默认_评分", mGameEntity.getName());
|
||||
} else if ("hideKaifuHint".equals(reuse.getType())) {
|
||||
mIsShowKaifuHint = false;
|
||||
mKaifuHint.setVisibility(View.GONE);
|
||||
@ -613,20 +627,20 @@ public class GameDetailFragment extends NormalFragment {
|
||||
switch (v.getId()) {
|
||||
case R.id.gamedetail_tabbar_fuli_tv:
|
||||
mViewPager.setCurrentItem(INDEX_DYNAMIC);
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情", "点击_动态", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情_新", "点击_动态", mGameEntity.getName());
|
||||
break;
|
||||
case R.id.gamedetail_tabbar_xinxi_tv:
|
||||
mViewPager.setCurrentItem(INDEX_DESCRIPTION);
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情", "点击_介绍", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情_新", "点击_介绍", mGameEntity.getName());
|
||||
break;
|
||||
case R.id.gamedetail_tabbar_rating:
|
||||
mViewPager.setCurrentItem(INDEX_RATING);
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情", "点击_评分", mGameEntity.getName());
|
||||
DataUtils.onMtaEvent(getContext(), "游戏详情_新", "点击_评分", mGameEntity.getName());
|
||||
break;
|
||||
case R.id.reuse_no_connection:
|
||||
mLoading.setVisibility(View.VISIBLE);
|
||||
mNoConnection.setVisibility(View.GONE);
|
||||
|
||||
mSkeleton.show();
|
||||
mViewModel.loadData();
|
||||
break;
|
||||
case R.id.gamedetail_kaifu_hint:
|
||||
@ -635,4 +649,8 @@ public class GameDetailFragment extends NormalFragment {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void tabPerformClick(View view) {
|
||||
if (!mIsPageChanged) view.performClick();
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ class DescAdapter(context: Context,
|
||||
|
||||
holder.itemView.setOnClickListener { v ->
|
||||
EventBus.getDefault().post(EBReuse(GameDetailFragment.SKIP_FULI))
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情", "查看游戏动态", gameName)
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情_新", "查看游戏动态", gameName)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -193,7 +193,7 @@ class DescAdapter(context: Context,
|
||||
viewHolder.binding.recyclerview.layoutManager = LinearLayoutManager(mContext)
|
||||
viewHolder.binding.tvAll.setOnClickListener {
|
||||
EventBus.getDefault().post(EBReuse(GameDetailFragment.SKIP_RATING))
|
||||
MtaHelper.onEvent("游戏详情", "玩家评论_点击全部", gameName)
|
||||
MtaHelper.onEvent("游戏详情_新", "玩家评论_点击全部", gameName)
|
||||
}
|
||||
commentsAdapter.comments = comments!!
|
||||
commentsAdapter.notifyDataSetChanged()
|
||||
@ -202,7 +202,7 @@ class DescAdapter(context: Context,
|
||||
private fun bindImageViewHolder(viewHolder: GameDetailRecommendImageViewHolder, recommendedImage: LinkEntity?) {
|
||||
viewHolder.binding.link = recommendedImage
|
||||
viewHolder.binding.image.setOnClickListener {
|
||||
MtaHelper.onEvent("游戏详情", "图片推荐", gameName + "->${recommendedImage?.title}")
|
||||
MtaHelper.onEvent("游戏详情_新", "图片推荐", gameName + "->${recommendedImage?.title}")
|
||||
if (!TextUtils.isEmpty(recommendedImage?.communityId)) {
|
||||
recommendedImage?.community = CommunityEntity(recommendedImage?.communityId!!, "")
|
||||
}
|
||||
@ -242,11 +242,11 @@ class DescAdapter(context: Context,
|
||||
if (viewHolder.binding.updateTv.maxLines == 5) {
|
||||
viewHolder.binding.updateTv.maxLines = 100
|
||||
viewHolder.binding.expandIv.setImageResource(R.drawable.ic_arrow_up)
|
||||
MtaHelper.onEvent("游戏详情", "展开更新内容", gameName)
|
||||
MtaHelper.onEvent("游戏详情_新", "展开更新内容", gameName)
|
||||
} else {
|
||||
viewHolder.binding.updateTv.maxLines = 5
|
||||
viewHolder.binding.expandIv.setImageResource(R.drawable.ic_arrow_down)
|
||||
MtaHelper.onEvent("游戏详情", "收起更新内容", gameName)
|
||||
MtaHelper.onEvent("游戏详情_新", "收起更新内容", gameName)
|
||||
}
|
||||
notifyItemChanged(viewHolder.adapterPosition)
|
||||
}
|
||||
@ -312,9 +312,9 @@ class DescAdapter(context: Context,
|
||||
viewHolder.gamedetailPluginOpen.setOnClickListener { _ ->
|
||||
mIsPluginExpanded = !mIsPluginExpanded
|
||||
if (mIsPluginExpanded) {
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情", "展开插件介绍", gameName)
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情_新", "展开插件介绍", gameName)
|
||||
} else {
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情", "收起插件介绍", gameName)
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情_新", "收起插件介绍", gameName)
|
||||
}
|
||||
notifyItemChanged(viewHolder.adapterPosition)
|
||||
}
|
||||
@ -367,11 +367,11 @@ class DescAdapter(context: Context,
|
||||
if (mIsIntroExpanded) {
|
||||
viewHolder.introContent.maxLines = 100
|
||||
viewHolder.expandIv.setImageResource(R.drawable.ic_arrow_up)
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情", "展开游戏介绍", gameName)
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情_新", "展开游戏介绍", gameName)
|
||||
} else {
|
||||
viewHolder.introContent.maxLines = 3
|
||||
viewHolder.expandIv.setImageResource(R.drawable.ic_arrow_down)
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情", "收起游戏介绍", gameName)
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情_新", "收起游戏介绍", gameName)
|
||||
}
|
||||
notifyItemChanged(viewHolder.adapterPosition)
|
||||
}
|
||||
@ -394,7 +394,7 @@ class DescAdapter(context: Context,
|
||||
binding.root.setOnClickListener { _ ->
|
||||
DataCollectionUtils.uploadClick(mContext, "大家都在玩", "游戏详情", gameEntity.name)
|
||||
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情", "大家都在玩", gameName + "->" + gameEntity.name)
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情_新", "大家都在玩", gameName + "->" + gameEntity.name)
|
||||
|
||||
GameDetailActivity.startGameDetailActivity(mContext, gameEntity,
|
||||
StringUtils.buildString(mEntrance, "+(", "游戏详情", "[", gameName, "]:大家都在玩[", (position + 1).toString(), "])"))
|
||||
|
||||
@ -64,7 +64,7 @@ class DescCommentsAdapter(context: Context,
|
||||
mContext.ifLogin("游戏详情-介绍-点赞评论") {
|
||||
if (!vote.isChecked) {
|
||||
mViewModel.voteComment(comment.id, callback = {
|
||||
MtaHelper.onEvent("游戏详情", "玩家评论_点赞", mViewModel.game?.name)
|
||||
MtaHelper.onEvent("游戏详情_新", "玩家评论_点赞", mViewModel.game?.name)
|
||||
vote.text = (comment.vote + 1).toString()
|
||||
vote.isChecked = true
|
||||
})
|
||||
@ -74,7 +74,7 @@ class DescCommentsAdapter(context: Context,
|
||||
}
|
||||
}
|
||||
commentItem.setOnClickListener {
|
||||
MtaHelper.onEvent("游戏详情", "玩家评论_点击评论", mViewModel.game?.name)
|
||||
MtaHelper.onEvent("游戏详情_新", "玩家评论_点击评论", mViewModel.game?.name)
|
||||
CommentUtils.showGameCommentOptions(mContext, comment, mViewModel.gameId, "游戏详情-介绍-举报评论")
|
||||
}
|
||||
userIcon.setOnClickListener {
|
||||
@ -84,7 +84,7 @@ class DescCommentsAdapter(context: Context,
|
||||
PersonalHomeActivity.startTargetActivity(mContext, comment.user.id, mEntrance, "(游戏详情:介绍)")
|
||||
}
|
||||
content.setExpandCallback {
|
||||
MtaHelper.onEvent("游戏详情", "玩家评论_点击全文", mViewModel.game?.name)
|
||||
MtaHelper.onEvent("游戏详情_新", "玩家评论_点击全文", mViewModel.game?.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,7 +131,9 @@ class DescViewModel(application: Application,
|
||||
}
|
||||
|
||||
override fun onNext(game: GameEntity) {
|
||||
result.add(game)
|
||||
if (game.getApk().size > 0) {
|
||||
result.add(game)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.gh.gamecenter.gamedetail.desc
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.databinding.DataBindingUtil
|
||||
import android.os.Build
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.text.TextUtils
|
||||
@ -58,7 +59,7 @@ class GameGalleryAdapter(var context: Context,
|
||||
ImageUtils.display(holder.screenshotIv, mGallery[position])
|
||||
holder.itemView.setOnClickListener { _ ->
|
||||
DataCollectionUtils.uploadClick(context, "游戏介绍", "游戏详情")
|
||||
DataUtils.onMtaEvent(context, "游戏详情", "点击游戏截图", mGameName)
|
||||
DataUtils.onMtaEvent(context, "游戏详情_新", "点击游戏截图", mGameName)
|
||||
|
||||
val intent = ViewImageActivity.getViewImageIntent(context,
|
||||
mGallery,
|
||||
@ -84,7 +85,9 @@ class GameGalleryAdapter(var context: Context,
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return if (position == 0 && !TextUtils.isEmpty(mVideo)) {
|
||||
return if (position == 0
|
||||
&& !TextUtils.isEmpty(mVideo)
|
||||
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
VIDEO
|
||||
} else {
|
||||
IMAGE
|
||||
|
||||
@ -2,6 +2,7 @@ package com.gh.gamecenter.gamedetail.fuli
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.preference.PreferenceManager
|
||||
import android.support.v7.widget.GridLayoutManager
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.support.v7.widget.RecyclerView
|
||||
@ -38,6 +39,8 @@ class FuLiAdapter(context: Context,
|
||||
var itemList: List<FuLiItemData>? = null
|
||||
private var isOpenLiBaoList: Boolean = false
|
||||
private var isOpenToolList: Boolean = false
|
||||
private var mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
private val mAnswerHintKey = "game_detail_answer_hint"
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
if (itemList == null || itemList!!.isEmpty()) {
|
||||
@ -131,18 +134,26 @@ class FuLiAdapter(context: Context,
|
||||
holder.hint.setText(R.string.game_suggestion_hint)
|
||||
holder.initItemPadding()
|
||||
holder.itemView.setOnClickListener {
|
||||
SuggestionActivity.startSuggestionActivity(mContext, SuggestType.gameQuestion, "game", mFuLiViewModel?.game?.name + ",问题反馈:")
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情", "此游戏有问题_点击反馈", mFuLiViewModel?.game?.name)
|
||||
SuggestionActivity.startSuggestionActivity(mContext, SuggestType.gameQuestion, "game", mFuLiViewModel?.game?.name)
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情_新", "此游戏有问题_点击反馈", mFuLiViewModel?.game?.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initAnswerViewHolder(holder: GameDetailAnswerViewHolder, position: Int) {
|
||||
holder.binding.run {
|
||||
val isShowAnswerHint = mSharedPreferences.getBoolean(mAnswerHintKey, true)
|
||||
if (isShowAnswerHint) {
|
||||
answerItemHint.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
answerItemList.layoutManager = LinearLayoutManager(mContext)
|
||||
answerItemList.adapter = GameDetailAnswerAdapter(mContext, mFuLiViewModel?.game?.name, itemList?.get(position)?.answer!!, mEntrance)
|
||||
answerItemMore.setOnClickListener {
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情", "进入问答", mFuLiViewModel?.game?.name)
|
||||
answerItemHint.visibility = View.GONE
|
||||
mSharedPreferences.edit().putBoolean(mAnswerHintKey, false).apply()
|
||||
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情_新", "进入问答", mFuLiViewModel?.game?.name)
|
||||
DirectUtils.directToCommunity(mContext, mFuLiViewModel?.gameCommunity)
|
||||
}
|
||||
}
|
||||
@ -161,7 +172,7 @@ class FuLiAdapter(context: Context,
|
||||
NewsDetailActivity.startNewsDetailActivity(mContext, notice[index],
|
||||
StringUtils.buildString(mEntrance, "游戏详情[", mFuLiViewModel?.game?.name, "]:公告"))
|
||||
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情", "公告", mFuLiViewModel?.game?.name + "->" + mvNotice.notices[index])
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情_新", "公告", mFuLiViewModel?.game?.name + "->" + mvNotice.notices[index])
|
||||
}
|
||||
} else {
|
||||
mvNotice.visibility = View.GONE
|
||||
@ -196,7 +207,7 @@ class FuLiAdapter(context: Context,
|
||||
viewHolder.newsMore.setOnClickListener {
|
||||
DataCollectionUtils.uploadClick(mContext, "资讯攻略-全部", "游戏详情", mFuLiViewModel?.game?.name)
|
||||
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情", "资讯攻略_全部", mFuLiViewModel?.game?.name)
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情_新", "资讯攻略_全部", mFuLiViewModel?.game?.name)
|
||||
val intent = GameNewsActivity.getIntent(mContext, mFuLiViewModel?.game?.name, mFuLiViewModel?.game?.id,
|
||||
mEntrance + "+(游戏详情[" + mFuLiViewModel?.game?.name + "]:资讯攻略-全部)")
|
||||
mContext.startActivity(intent)
|
||||
@ -241,7 +252,7 @@ class FuLiAdapter(context: Context,
|
||||
|
||||
DataCollectionUtils.uploadClick(mContext, "资讯攻略", "游戏详情", newsEntity.title)
|
||||
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情", "资讯攻略", mFuLiViewModel?.game?.name + "->" + newsEntity.title)
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情_新", "资讯攻略", mFuLiViewModel?.game?.name + "->" + newsEntity.title)
|
||||
|
||||
// 统计阅读量
|
||||
NewsUtils.statNewsViews(mContext, newsEntity.id)
|
||||
|
||||
@ -155,7 +155,7 @@ class FuLiFragment : BaseFragment<Any>() {
|
||||
EventBus.getDefault().post(EBReuse("showKaifuHint"))
|
||||
} else if (GameDetailFragment.SCROLL_TO_KAIFU == reuse.type && layoutManager != null) {
|
||||
DataUtils.onMtaEvent(context, "游戏详情开服表按钮", mFuLiViewModel?.game?.name)
|
||||
DataUtils.onMtaEvent(context, "游戏详情", "开服表", mFuLiViewModel?.game?.name)
|
||||
DataUtils.onMtaEvent(context, "游戏详情_新", "开服表", mFuLiViewModel?.game?.name)
|
||||
val position = getServerPosition()
|
||||
if (position > 0) layoutManager?.smoothScrollToPosition(mRecyclerView, null, position)
|
||||
}
|
||||
@ -180,7 +180,7 @@ class FuLiFragment : BaseFragment<Any>() {
|
||||
R.id.gamedetail_libao_item -> {
|
||||
val liBao = data as LibaoEntity
|
||||
val intent = LibaoDetailActivity.getIntent(context, liBao, "$mEntrance[$position]")
|
||||
DataUtils.onMtaEvent(context, "游戏详情", "游戏礼包", mFuLiViewModel?.game?.name + "->" + liBao.name)
|
||||
DataUtils.onMtaEvent(context, "游戏详情_新", "游戏礼包", mFuLiViewModel?.game?.name + "->" + liBao.name)
|
||||
startActivityForResult(intent, GAME_DETAIL_LIBAO_REQUEST)
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,12 +176,13 @@ class FuLiViewModel(application: Application,
|
||||
val itemList = ArrayList<FuLiItemData>()
|
||||
var isExistServer = false
|
||||
var index = 0
|
||||
if (gameDetail.notice != null && gameDetail.notice!!.isNotEmpty()) {
|
||||
val showArticleEntrance = Config.getSettings()?.showArticleEntrance()
|
||||
if (showArticleEntrance == true && gameDetail.notice != null && gameDetail.notice!!.isNotEmpty()) {
|
||||
val fuLiData = FuLiItemData()
|
||||
fuLiData.notice = gameDetail.notice
|
||||
itemList.add(fuLiData)
|
||||
}
|
||||
if (mArticleList != null) {
|
||||
if (showArticleEntrance == true && mArticleList != null) {
|
||||
val fuLiData = FuLiItemData()
|
||||
fuLiData.article = mArticleList
|
||||
itemList.add(fuLiData)
|
||||
|
||||
@ -42,7 +42,7 @@ class GameDetailAnswerAdapter(context: Context,
|
||||
if ("community_article" == entity.type) {
|
||||
ArticleDetailActivity.getIntent(mContext, CommunityEntity(entity.id!!, ""), entity.id!!, mEntrance, path)
|
||||
} else {
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情", "点击问题", gameName + "->" + entity.questions.title)
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情_新", "点击问题", gameName + "->" + entity.questions.title)
|
||||
mContext.startActivity(QuestionsDetailActivity.getIntent(mContext, entity.questions.id, mEntrance, path))
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ class GameDetailAnswerAdapter(context: Context,
|
||||
if ("community_article" == entity.type) {
|
||||
mContext.startActivity(ArticleDetailActivity.getIntent(mContext, CommunityEntity(entity.communityId!!, ""), entity.id!!, mEntrance, path))
|
||||
} else {
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情", "点击答案", gameName + "->" + StringUtils.shrinkStringWithDot(entity.brief, 10))
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情_新", "点击答案", gameName + "->" + StringUtils.shrinkStringWithDot(entity.brief, 10))
|
||||
mContext.startActivity(AnswerDetailActivity.getIntent(mContext, entity.id, mEntrance, path))
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,13 +11,11 @@ import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.RecyclerView.ViewHolder;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.OnViewClickListener;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.StringUtils;
|
||||
@ -44,7 +42,6 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
@ -411,7 +408,7 @@ public class GameDetailKaiFuAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
mGameEntity.getName(),
|
||||
calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-" + entity.getDay());
|
||||
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情", "开服详情", mGameEntity.getName() + "->" + viewHolder.calendarKaifu.getText().toString());
|
||||
DataUtils.onMtaEvent(mContext, "游戏详情_新", "开服详情", mGameEntity.getName() + "->" + viewHolder.calendarKaifu.getText().toString());
|
||||
initKaifuDetail(entity);
|
||||
});
|
||||
} else {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user