Compare commits
157 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8ba45deac9 | |||
| 0c9f741847 | |||
| 696f862633 | |||
| f85e3c2602 | |||
| d2e3635034 | |||
| 72aa1474d3 | |||
| 6d134edb0a | |||
| 7834e9d55a | |||
| 36ba95e2fd | |||
| 00deba962e | |||
| 4713594c7e | |||
| 688a169e4e | |||
| 3ace50b526 | |||
| a9dbb4850f | |||
| 910cda8dbc | |||
| 7d29c0d883 | |||
| 3f274cb4ea | |||
| 56d378b6dc | |||
| 03eebf2c07 | |||
| cf41572db7 | |||
| a2361254da | |||
| 233f786ee0 | |||
| 8590614272 | |||
| e179de3d0d | |||
| defe3bb3ff | |||
| 24ad3e0265 | |||
| e54646afcc | |||
| 4c62032c66 | |||
| 627affe0f7 | |||
| b5e21bef1e | |||
| 95999791bd | |||
| 07cba611cf | |||
| 29c2dfc1e5 | |||
| 6b904b9213 | |||
| 7e15307b46 | |||
| 626913c6ff | |||
| 00b98e4da9 | |||
| 67f565bee0 | |||
| 9eedf46294 | |||
| 810783da9c | |||
| 39dfe334ed | |||
| 1a985f2a7e | |||
| 35af46e3eb | |||
| 3eefadd83b | |||
| 0fbbd79bbd | |||
| 84eee14363 | |||
| 8f7ce5d148 | |||
| 5ed2fa4a0c | |||
| e5a06f7a3f | |||
| f0ef1c7a76 | |||
| 76ea9a4ba4 | |||
| 33454005c3 | |||
| 37b6e6bce0 | |||
| aaa9aab066 | |||
| e8669cc0cf | |||
| ddb226823f | |||
| 76eca47979 | |||
| bcac6944a0 | |||
| d9aa1c428d | |||
| 85c779ecd2 | |||
| 87a67470fd | |||
| be4142ad96 | |||
| 5a26f7735d | |||
| 11ec77ad99 | |||
| 2da4182ee1 | |||
| d17ad6a497 | |||
| 1abc0ecc79 | |||
| 51ee8c841b | |||
| 0636d2276b | |||
| bffee14882 | |||
| 93f2ed3a09 | |||
| c7b0ed26ae | |||
| e75ade83cb | |||
| 3e4f5d6361 | |||
| 999bc9f720 | |||
| cca068821b | |||
| 6d05a00488 | |||
| ba3450f2b3 | |||
| 57c084d512 | |||
| c956f35e07 | |||
| c44353fa13 | |||
| 8ebdc924f3 | |||
| 3923dd377d | |||
| 82eea64035 | |||
| 10229e59f6 | |||
| 8c2583eab3 | |||
| f9ef4851fb | |||
| d07b99fd98 | |||
| b23ce2adc3 | |||
| c4f2899e07 | |||
| ebb20f5c38 | |||
| 08aaae1b02 | |||
| 4aaef11f9c | |||
| 2d0d253149 | |||
| 875c0b8c16 | |||
| 3e285a4466 | |||
| 76e91265d5 | |||
| 47482ba793 | |||
| 685c38dcf7 | |||
| 240d97cdd5 | |||
| cd891d4378 | |||
| b9c05483d0 | |||
| 190c534dba | |||
| 5cc13d8161 | |||
| 81ac870c62 | |||
| 9eab5c3d4c | |||
| f4a4ae7eb3 | |||
| 4b2715e97d | |||
| 983e546a64 | |||
| d7161578b0 | |||
| d8683068c1 | |||
| efcea45819 | |||
| 28f89aa0ad | |||
| 309d42fdc1 | |||
| f8f45182ce | |||
| 5f08dee0e0 | |||
| deea0f3f83 | |||
| 2090c5950f | |||
| 02dcbdba02 | |||
| ee44b1986f | |||
| 16bc7b1e75 | |||
| 65bc06b195 | |||
| 06734d6274 | |||
| e1dcd72a79 | |||
| 3429a27354 | |||
| 7af99a5ed5 | |||
| d7833cd07f | |||
| a9b885c97f | |||
| 5eb815dba7 | |||
| 9797841280 | |||
| a2382be034 | |||
| 081ce01664 | |||
| eddb8a933c | |||
| 7a019cc465 | |||
| 08e8846af8 | |||
| 67d6cc6f05 | |||
| 1946478ce4 | |||
| 5689cdbafe | |||
| 44adfdede8 | |||
| 2992e3ca64 | |||
| ffbbd44beb | |||
| 3990515dc5 | |||
| 2bd218fd95 | |||
| 1a02239dd2 | |||
| a5a5e38d5c | |||
| 9ebf2be016 | |||
| 3e488d28cd | |||
| ce311d9b17 | |||
| 843a263b3f | |||
| 447b7b35ef | |||
| 68cfdc57c8 | |||
| 81e0f1d9cc | |||
| 5436775b31 | |||
| b8f5c2ddbd | |||
| da433bfb5b | |||
| 50209aa6ed | |||
| 568ff5cb1e |
@ -63,4 +63,8 @@
|
||||
- 将实现细节从 View(Fragment、Activity) 剥离并以 MVVM 结构改造
|
||||
- 将 ListViewModel 所对应的 ListRepository 合并到 ListViewModel 中
|
||||
- 依照光环助手界面功能以大模块 - 小模块的方式去修改包结构,包内文件建议以包名摘要作为前缀
|
||||
- 使用 RxJava 的 Debounce 和 Map 操作优化搜索触发机制 参考资料:[1](https://proandroiddev.com/building-an-autocompleting-edittext-using-rxjava-f69c5c3f5a40),[2](https://medium.com/@kurtisnusbaum/rxandroid-basics-part-2-6e877af352)
|
||||
- 使用 RxJava 的 Debounce 和 Map 操作优化搜索触发机制 参考资料:[1](https://proandroiddev.com/building-an-autocompleting-edittext-using-rxjava-f69c5c3f5a40),[2](https://medium.com/@kurtisnusbaum/rxandroid-basics-part-2-6e877af352)
|
||||
|
||||
- 把 ListViewModel 的数据结构类型转换方式换为抽象方法,让继承的类实现,避免出现无响应的问题
|
||||
|
||||
- 上传图片改为用Retrofit上传
|
||||
@ -1,6 +1,8 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
apply plugin: 'org.jetbrains.kotlin.android.extensions'
|
||||
apply plugin: 'kotlin-android' // kotlin
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
// apkChannelPackage
|
||||
apply plugin: 'channel'
|
||||
@ -9,6 +11,10 @@ apply from: 'tinker-support.gradle'
|
||||
|
||||
android {
|
||||
|
||||
androidExtensions {
|
||||
experimental = true
|
||||
}
|
||||
|
||||
dataBinding {
|
||||
enabled = true
|
||||
}
|
||||
@ -119,12 +125,9 @@ android {
|
||||
buildConfigField "String", "LIBAO_HOST", "\"${LIBAO_HOST}\""
|
||||
buildConfigField "String", "MESSAGE_HOST", "\"${MESSAGE_HOST}\""
|
||||
buildConfigField "String", "DATA_HOST", "\"${DATA_HOST}\""
|
||||
buildConfigField "String", "USERSEA_HOST", "\"${USERSEA_HOST}\""
|
||||
|
||||
buildConfigField "String", "BUGLY_APPID", "\"${BUGLY_APPID}\""
|
||||
|
||||
buildConfigField "String", "USERSEA_APP_ID", "\"${USERSEA_APP_ID}\""
|
||||
buildConfigField "String", "USERSEA_APP_SECRET", "\"${USERSEA_APP_SECRET}\""
|
||||
}
|
||||
// internal test dev host
|
||||
internal {
|
||||
@ -135,19 +138,11 @@ android {
|
||||
buildConfigField "String", "LIBAO_HOST", "\"${DEV_LIBAO_HOST}\""
|
||||
buildConfigField "String", "MESSAGE_HOST", "\"${DEV_MESSAGE_HOST}\""
|
||||
buildConfigField "String", "DATA_HOST", "\"${DEV_DATA_HOST}\""
|
||||
buildConfigField "String", "USERSEA_HOST", "\"${DEV_USERSEA_HOST}\""
|
||||
|
||||
buildConfigField "String", "BUGLY_APPID", "\"${DEBUG_BUGLY_APPID}\""
|
||||
|
||||
buildConfigField "String", "USERSEA_APP_ID", "\"${DEV_USERSEA_APP_ID}\""
|
||||
buildConfigField "String", "USERSEA_APP_SECRET", "\"${DEV_USERSEA_APP_SECRET}\""
|
||||
}
|
||||
}
|
||||
|
||||
dataBinding {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
// productFlavors.all { flavor ->
|
||||
// flavor.manifestPlaceholders = [CHANNEL_VALUE: name]//命令 gradlew assembleRelease
|
||||
// }
|
||||
@ -208,6 +203,8 @@ dependencies {
|
||||
|
||||
implementation "com.jakewharton:butterknife:${butterKnife}"
|
||||
annotationProcessor "com.jakewharton:butterknife-compiler:${butterKnife}"
|
||||
kapt "com.jakewharton:butterknife-compiler:${butterKnife}"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
|
||||
|
||||
implementation "org.greenrobot:eventbus:${eventbus}"
|
||||
annotationProcessor "org.greenrobot:eventbus-annotation-processor:${eventbusApt}"
|
||||
@ -237,13 +234,21 @@ dependencies {
|
||||
implementation "pub.devrel:easypermissions:${easypermissions}"
|
||||
// mvvm
|
||||
implementation "android.arch.lifecycle:runtime:${archLifecycleVersion}"
|
||||
annotationProcessor "android.arch.lifecycle:compiler:${archLifecycleVersion}"
|
||||
kapt "android.arch.lifecycle:compiler:${archLifecycleVersion}"
|
||||
implementation "android.arch.lifecycle:extensions:${archLifecycleVersion}"
|
||||
implementation "android.arch.persistence.room:runtime:${archRoomVersion}"
|
||||
annotationProcessor "android.arch.persistence.room:compiler:${archRoomVersion}"
|
||||
kapt "android.arch.persistence.room:compiler:${archRoomVersion}"
|
||||
|
||||
implementation 'com.google.android:flexbox:0.2.2'
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
kapt 'com.android.databinding:compiler:3.0.1'
|
||||
|
||||
implementation 'com.contrarywind:Android-PickerView:4.1.3'
|
||||
|
||||
implementation "com.scwang.smartrefresh:SmartRefreshLayout:${smartRefreshLayout}"
|
||||
implementation "net.cachapa.expandablelayout:expandablelayout:${expandableLayout}"
|
||||
|
||||
implementation project(':libraries:LGLibrary')
|
||||
implementation project(':libraries:MTA')
|
||||
implementation project(':libraries:QQShare')
|
||||
@ -252,7 +257,6 @@ dependencies {
|
||||
implementation project(':libraries:WechatShare')
|
||||
implementation project(':libraries:iosched')
|
||||
implementation project(':libraries:LogHub')
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
|
||||
}
|
||||
File propFile = file('sign.properties')
|
||||
|
||||
@ -140,7 +140,7 @@
|
||||
-keep class com.gh.common.view.** {*;}
|
||||
-keep class com.gh.gamecenter.db.info.** {*;}
|
||||
-keep class com.gh.gamecenter.entity.** {*;}
|
||||
-keep class com.gh.gamecenter.ask.entity.** {*;}
|
||||
-keep class com.gh.gamecenter.qa.entity.** {*;}
|
||||
-keep class com.gh.gamecenter.retrofit.** {*;}
|
||||
-keep class com.gh.gamecenter.eventbus.** {*;}
|
||||
-keep class * extends rx.Subscriber
|
||||
@ -190,4 +190,11 @@
|
||||
# 重命名文件为SourceFile,再配合mapping符号表,可以拿到真实的类名
|
||||
-renamesourcefileattribute SourceFile
|
||||
# 保留源文件行号
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
-ignorewarnings
|
||||
|
||||
-keep @android.support.annotation.Keep class *
|
||||
-keepclassmembers class ** {
|
||||
@android.support.annotation.Keep *;
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android = "http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools = "http://schemas.android.com/tools"
|
||||
package = "com.gh.gamecenter" >
|
||||
|
||||
<!-- 允许应用程序访问网络连接 -->
|
||||
@ -60,7 +61,9 @@
|
||||
android:allowBackup = "true"
|
||||
android:icon = "@drawable/logo"
|
||||
android:label = "@string/app_name"
|
||||
android:theme = "@style/AppCompatTheme.APP" >
|
||||
android:resizeableActivity = "true"
|
||||
android:theme = "@style/AppCompatTheme.APP"
|
||||
tools:targetApi = "n" >
|
||||
|
||||
<!--android:launchMode = "singleTask"-->
|
||||
<activity
|
||||
@ -197,6 +200,15 @@
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.InstallActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = ".category.CategoryDirectoryActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = ".category.CategoryListActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.LoginActivity"
|
||||
android:screenOrientation = "portrait"
|
||||
@ -227,27 +239,23 @@
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.AskSearchActivity"
|
||||
android:name = "com.gh.gamecenter.qa.search.AskSearchActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.AnswerDetailActivity"
|
||||
android:name = "com.gh.gamecenter.qa.answer.detail.AnswerDetailActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.QuestionsDetailActivity"
|
||||
android:name = "com.gh.gamecenter.qa.questions.detail.QuestionsDetailActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.AnswerFoldActivity"
|
||||
android:name = ".qa.answer.fold.AnswerFoldActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.AnswerEditActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.QuestionEditActivity"
|
||||
android:name = "com.gh.gamecenter.qa.answer.edit.AnswerEditActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
@ -263,11 +271,11 @@
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.CommunitiesSelectActivity"
|
||||
android:name = "com.gh.gamecenter.qa.select.CommunitiesSelectActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.CommunitySubjectActivity"
|
||||
android:name = "com.gh.gamecenter.qa.subject.CommunitySubjectActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
@ -279,17 +287,41 @@
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.QuestionsInviteActivity"
|
||||
android:name = ".qa.questions.invite.QuestionsInviteActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.MyAskActivity"
|
||||
android:name = "com.gh.gamecenter.qa.myqa.MyAskActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.AskTabOrderActivity"
|
||||
android:name = "com.gh.gamecenter.qa.column.order.AskTabOrderActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.ask.QuestionEditActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.kaifu.add.AddKaiFuActivity"
|
||||
android:screenOrientation = "portrait"
|
||||
android:windowSoftInputMode = "stateHidden"/>
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.kaifu.patch.PatchKaifuActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.BlockActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.column.detail.AskColumnDetailActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.NetworkDiagnosisActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<!-- 使用小米/华为推送弹窗功能提高推送成功率-->
|
||||
<activity
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 3.8 KiB |
@ -54,7 +54,8 @@ public abstract class BaseActivity extends BaseToolBarActivity implements EasyPe
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
mActivityWeakReference.get().handleMessage(msg);
|
||||
BaseActivity activity = mActivityWeakReference.get();
|
||||
if (activity != null) activity.handleMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,23 +1,18 @@
|
||||
package com.gh.base;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.normal.ToolbarController;
|
||||
import com.lightgame.BaseAppCompatActivity;
|
||||
import com.lightgame.OnTitleClickListener;
|
||||
import com.lightgame.view.TextDrawable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -25,10 +20,9 @@ import java.util.List;
|
||||
* Created by csheng on 15-10-12.
|
||||
*/
|
||||
|
||||
public abstract class BaseToolBarActivity extends BaseAppCompatActivity {
|
||||
public abstract class BaseToolBarActivity extends BaseAppCompatActivity implements ToolbarController, Toolbar.OnMenuItemClickListener {
|
||||
|
||||
private Toolbar mToolbar;
|
||||
private Drawable mToolbarBackground;
|
||||
private TextView mTitleTv;
|
||||
|
||||
@Override
|
||||
@ -37,71 +31,72 @@ public abstract class BaseToolBarActivity extends BaseAppCompatActivity {
|
||||
initToolbar();
|
||||
}
|
||||
|
||||
public void setNavigationTitle(@StringRes int title, @ColorRes int color) {
|
||||
setNavigationTitle(getString(title), ContextCompat.getColor(this, color));
|
||||
}
|
||||
|
||||
public void setNavigationTitle(String title, @ColorInt int color) {
|
||||
private void initToolbar() {
|
||||
mToolbar = findViewById(R.id.normal_toolbar);
|
||||
mTitleTv = findViewById(R.id.normal_title);
|
||||
if (mToolbar != null) {
|
||||
final TextDrawable textDrawable = new TextDrawable(getResources());
|
||||
textDrawable.setTextColor(color);
|
||||
textDrawable.setText(title);
|
||||
if (mToolbarBackground == null) {
|
||||
mToolbarBackground = mToolbar.getBackground();
|
||||
}
|
||||
LayerDrawable drawable = new LayerDrawable(new Drawable[]{mToolbarBackground, textDrawable});
|
||||
mToolbar.setBackgroundDrawable(drawable);
|
||||
// setSupportActionBar(mToolbar); // 替换actionBar后 toolBar无法控制
|
||||
mToolbar.setNavigationIcon(provideNavigationIcon());
|
||||
mToolbar.setNavigationOnClickListener(view -> onBackPressed());
|
||||
mTitleTv.setOnClickListener(view -> {
|
||||
final List<Fragment> fragmentList = getSupportFragmentManager().getFragments();
|
||||
for (Fragment fragment : fragmentList) {
|
||||
if (fragment instanceof OnTitleClickListener) {
|
||||
((OnTitleClickListener) fragment).onTitleClick();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@DrawableRes
|
||||
public int provideNavigationIcon() {
|
||||
return R.drawable.ic_bar_back; // default navigation icon
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNavigationTitle(String title) {
|
||||
// if (mTitleTv != null) {
|
||||
// mTitleTv.setText(title);
|
||||
// }
|
||||
|
||||
if (mToolbar != null && !TextUtils.isEmpty(title)) {
|
||||
final TextDrawable textDrawable = new TextDrawable(getResources());
|
||||
textDrawable.setText(title);
|
||||
if (mToolbarBackground == null) {
|
||||
mToolbarBackground = mToolbar.getBackground();
|
||||
}
|
||||
LayerDrawable drawable = new LayerDrawable(new Drawable[]{mToolbarBackground, textDrawable});
|
||||
mToolbar.setBackgroundDrawable(drawable);
|
||||
}
|
||||
if (mTitleTv != null) mTitleTv.setText(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNavigationTitle(@StringRes int res) {
|
||||
setNavigationTitle(getString(res));
|
||||
}
|
||||
|
||||
private void initToolbar() {
|
||||
mToolbar = findViewById(R.id.toolbar_navigation);
|
||||
if (mToolbar != null) {
|
||||
setSupportActionBar(mToolbar);
|
||||
final View back = mToolbar.findViewById(R.id.actionbar_rl_back);
|
||||
if (back != null) {
|
||||
back.setOnClickListener(v -> onBackPressed());
|
||||
}
|
||||
mTitleTv = findViewById(R.id.actionbar_tv_title);
|
||||
mTitleTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
final List<Fragment> fragmentList = getSupportFragmentManager().getFragments();
|
||||
for (Fragment fragment : fragmentList) {
|
||||
if (fragment instanceof OnTitleClickListener) {
|
||||
((OnTitleClickListener) fragment).onTitleClick();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setToolbarMenu(int res) {
|
||||
if (mToolbar == null) return;
|
||||
mToolbar.inflateMenu(res);
|
||||
mToolbar.setOnMenuItemClickListener(this);
|
||||
|
||||
Menu menu = mToolbar.getMenu();
|
||||
for (int i = 0; i < menu.size(); i++) {
|
||||
MenuItem menuItem = menu.getItem(i);
|
||||
// menu设置actionLayout后,无法捕捉点击事件,以icon为tag,如果icon is null 手动设置menuItem点击事件
|
||||
if (menuItem != null && menuItem.getIcon() == null) {
|
||||
if (menuItem.getActionView() != null) {
|
||||
menuItem.getActionView().setOnClickListener((v) -> this.onMenuItemClick(menuItem));
|
||||
}
|
||||
});
|
||||
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||
getSupportActionBar().setDisplayShowHomeEnabled(false);
|
||||
getSupportActionBar().setHomeButtonEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuItem getMenuItem(int res) {
|
||||
if (mToolbar == null) return null; //后续页面做好判断
|
||||
return mToolbar.getMenu().findItem(res);
|
||||
}
|
||||
|
||||
public Menu getMenu() {
|
||||
return mToolbar.getMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
|
||||
7
app/src/main/java/com/gh/base/OnViewClickListener.java
Normal file
7
app/src/main/java/com/gh/base/OnViewClickListener.java
Normal file
@ -0,0 +1,7 @@
|
||||
package com.gh.base;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
public interface OnViewClickListener {
|
||||
void onClick(View v, Object data);
|
||||
}
|
||||
@ -6,7 +6,9 @@ import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import com.gh.common.util.ClickUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.lightgame.utils.RuntimeUtils;
|
||||
import com.lightgame.utils.Utils;
|
||||
@ -24,6 +26,12 @@ public class BaseDialogFragment extends DialogFragment {
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
final Dialog dialog = new Dialog(getActivity(), R.style.DialogWindowTransparent);
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
dialog.setOnKeyListener((dialog1, keyCode, event) -> {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && ClickUtils.isFastDoubleClick()) { //会多次响应??
|
||||
return onBack();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
dialog.setCancelable(false);
|
||||
return dialog;
|
||||
}
|
||||
@ -46,6 +54,9 @@ public class BaseDialogFragment extends DialogFragment {
|
||||
RuntimeUtils.getInstance().toastLong(getContext(), msg);
|
||||
}
|
||||
|
||||
public boolean onBack() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -25,6 +25,14 @@ public class BaseDialogWrapperFragment extends BaseDialogFragment {
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public static BaseDialogWrapperFragment getInstance(Fragment fragmentToWrap, boolean isCancelable) {
|
||||
BaseDialogWrapperFragment fragment = new BaseDialogWrapperFragment();
|
||||
fragment.mFragmentToWrap = fragmentToWrap;
|
||||
fragment.setCancelable(isCancelable);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
@ -34,7 +42,9 @@ public class BaseDialogWrapperFragment extends BaseDialogFragment {
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getChildFragmentManager().beginTransaction().replace(R.id.fragment_placeholder, mFragmentToWrap).commitNowAllowingStateLoss();
|
||||
if (mFragmentToWrap != null) {
|
||||
getChildFragmentManager().beginTransaction().replace(R.id.fragment_placeholder, mFragmentToWrap).commitNowAllowingStateLoss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -60,7 +60,8 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
mFragmentWeakReference.get().handleMessage(msg);
|
||||
BaseFragment fragment = mFragmentWeakReference.get();
|
||||
if (fragment != null) fragment.handleMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
package com.gh.base.fragment;
|
||||
|
||||
public interface OnDialogBackListener {
|
||||
void onBack();
|
||||
}
|
||||
@ -19,6 +19,8 @@ public class WaitingDialogFragment extends BaseDialogFragment {
|
||||
|
||||
public static final String KEY_MSG = "msg";
|
||||
|
||||
private OnDialogBackListener mBackListener;
|
||||
|
||||
public static WaitingDialogFragment newInstance(String message) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(KEY_MSG, message);
|
||||
@ -54,4 +56,45 @@ public class WaitingDialogFragment extends BaseDialogFragment {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void show(FragmentManager manager, String tag, OnDialogBackListener backListener) {
|
||||
show(manager, tag);
|
||||
this.mBackListener = backListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBack() {
|
||||
if (mBackListener != null) {
|
||||
mBackListener.onBack();
|
||||
return true;
|
||||
}
|
||||
return super.onBack();
|
||||
}
|
||||
|
||||
public static class WaitingDialogData {
|
||||
private String msg;
|
||||
|
||||
private boolean isShow;
|
||||
|
||||
public WaitingDialogData(String msg, boolean isShow) {
|
||||
this.msg = msg;
|
||||
this.isShow = isShow;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public boolean isShow() {
|
||||
return isShow;
|
||||
}
|
||||
|
||||
public void setShow(boolean show) {
|
||||
isShow = show;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@ import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.common.util.GsonUtils;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.entity.NewsEntity;
|
||||
import com.gh.gamecenter.entity.SettingsEntity;
|
||||
@ -23,7 +22,6 @@ public class Config {
|
||||
public static final String DATA_HOST = BuildConfig.DATA_HOST;
|
||||
public static final String LIBAO_HOST = BuildConfig.LIBAO_HOST;
|
||||
public static final String MESSAGE_HOST = BuildConfig.MESSAGE_HOST;
|
||||
public static final String USERSEA_HOST = BuildConfig.USERSEA_HOST;
|
||||
|
||||
/**
|
||||
* 需要配置的请使用{@link PreferenceManager#getDefaultSharedPreferences(Context)}
|
||||
@ -42,8 +40,6 @@ public class Config {
|
||||
public static final String TALKINGDATA_APPID = BuildConfig.TD_APPID;// TalkingData
|
||||
public static final String UMENG_APPKEY = BuildConfig.UMENG_APPKEY;
|
||||
public static final String UMENG_MESSAGE_SECRET = BuildConfig.UMENG_MESSAGE_SECRET;
|
||||
public static final String USERSEA_APP_ID = BuildConfig.USERSEA_APP_ID; // 登录验证
|
||||
public static final String USERSEA_APP_SECRET = BuildConfig.USERSEA_APP_SECRET; // 登录验证
|
||||
public static final String BUGLY_APPID = BuildConfig.BUGLY_APPID;
|
||||
public static final String PATCH_VERSION_NAME = BuildConfig.PATCH_VERSION_NAME; // 补丁包版本 对应关于->版本号
|
||||
// http://www.ghzs666.com/article/${articleId}.html
|
||||
@ -53,8 +49,8 @@ public class Config {
|
||||
private static SettingsEntity mSettingsEntity;
|
||||
|
||||
public static boolean isShow() {
|
||||
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
// return sp.getBoolean("isShow", true);
|
||||
if (PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication())
|
||||
.getBoolean("isFixDownload", false)) return true;
|
||||
|
||||
if (!isExistDownloadFilter()) return false;
|
||||
|
||||
@ -79,6 +75,7 @@ public class Config {
|
||||
}
|
||||
|
||||
public static boolean isShowDownload(String gameId) {
|
||||
|
||||
if (TextUtils.isEmpty(gameId) || !isExistDownloadFilter())
|
||||
return false;
|
||||
|
||||
@ -90,7 +87,8 @@ public class Config {
|
||||
return false;
|
||||
}
|
||||
} else if ("all".equals(entity.getGame())) {
|
||||
if ("normal".equals(entity.getPolicy()) && filterTime(entity.getTime())) {
|
||||
if ("normal".equals(entity.getPolicy()) && filterTime(entity.getTime())
|
||||
|| PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication()).getBoolean("isFixDownload", false)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -149,10 +147,6 @@ public class Config {
|
||||
}
|
||||
|
||||
public static void setSettings(SettingsEntity settingsEntity) {
|
||||
if (settingsEntity != null && settingsEntity.getSuggestion() != null) {
|
||||
String s = GsonUtils.Companion.getInstance().toJson(settingsEntity);
|
||||
|
||||
}
|
||||
mSettingsEntity = settingsEntity;
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,9 @@ public class Constants {
|
||||
|
||||
public static final String LOGIN_TOKEN_ID = "userToken_id"; // 用户ID 与服务器无关
|
||||
|
||||
public static final String USER_TOKEN_KEY = "userTokenKey";
|
||||
public static final String USER_INFO_KEY = "userInfoKey";
|
||||
|
||||
//手机号码匹配规则
|
||||
public static final String REGEX_MOBILE = "^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$";
|
||||
public static final String REGEX_ACCOUNT = "^[a-zA-Z_]\\w{5,17}$";
|
||||
|
||||
@ -8,6 +8,7 @@ public class ItemViewType {
|
||||
public static final int COLUMN_HEADER = 0; // 专题头部布局
|
||||
public static final int GAME_SLIDE = 1; // 滚动图布局
|
||||
public static final int GAME_NORMAL = 2; // 正常游戏布局
|
||||
public static final int GAME_SUBJECT = 19;
|
||||
public static final int GAME_TEST = 3; // 测试游戏布局
|
||||
public static final int GAME_IMAGE = 4; // 游戏大图布局
|
||||
public static final int NEWS_HEADER = 5; // 新闻头部布局
|
||||
@ -22,7 +23,9 @@ public class ItemViewType {
|
||||
public static final int LIBAO_NORMAL = 15; // 礼包正常布局
|
||||
public static final int LIBAO_SKIP_CONCERN = 16; // 跳转关注管理页面布局
|
||||
public static final int KC_HINT = 17;
|
||||
public static final int GAME_PULGIN = 18; // 游戏插件模块
|
||||
public static final int GAME_PLUGIN = 18; // 游戏插件模块
|
||||
public static final int ASK_REFRESH = 19; // 问答精选 刷新
|
||||
public static final int ITEM_EMPTY = 20;
|
||||
|
||||
/**
|
||||
* 普通列表
|
||||
|
||||
@ -1,16 +1,54 @@
|
||||
package com.gh.common.databind;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.databinding.BindingAdapter;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.base.OnViewClickListener;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.exposure.ExposureEvent;
|
||||
import com.gh.common.exposure.ExposureUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.GameUtils;
|
||||
import com.gh.common.util.GameViewUtils;
|
||||
import com.gh.common.util.KaiFuUtils;
|
||||
import com.gh.common.util.NetworkUtils;
|
||||
import com.gh.common.util.NewsUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.StringUtils;
|
||||
import com.gh.common.view.DownloadDialog;
|
||||
import com.gh.common.view.DownloadProgressBar;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.DownloadManagerActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
import com.gh.gamecenter.databinding.KaifuAddItemBinding;
|
||||
import com.gh.gamecenter.databinding.KaifuDetailItemRowBinding;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.KaiFuCalendarEntity;
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.manager.PackageManager;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.download.FileUtils;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Created by khy on 12/02/18.
|
||||
@ -23,9 +61,109 @@ public class BindingAdapters {
|
||||
view.setImageURI(imageUrl);
|
||||
}
|
||||
|
||||
@BindingAdapter({"addDetailKaiFuView", "addDetailKaiFuViewListener", "isReadyPatch"})
|
||||
public static void addDetailKaiFuView(LinearLayout view, List<KaiFuCalendarEntity> list
|
||||
, OnViewClickListener listener, Boolean isReadyPatch) {
|
||||
if (list == null) return;
|
||||
view.removeAllViews();
|
||||
for (int i = 0; i < list.size() + 1; i++) { // 1 is Title
|
||||
View inflate = LayoutInflater.from(view.getContext()).inflate(R.layout.kaifu_detail_item_row, null);
|
||||
KaifuDetailItemRowBinding binding = KaifuDetailItemRowBinding.bind(inflate);
|
||||
binding.setIsCloseBottom(i == list.size());
|
||||
binding.setIsReadyPatch(isReadyPatch);
|
||||
if (i == 0) {
|
||||
binding.setIsTitle(true);
|
||||
} else {
|
||||
KaiFuCalendarEntity serverEntity = list.get(i - 1);
|
||||
binding.setEntity(serverEntity);
|
||||
binding.getRoot().setOnClickListener(v -> {
|
||||
listener.onClick(v, isReadyPatch != null && isReadyPatch ? serverEntity : null);
|
||||
});
|
||||
|
||||
// 滑动冲突处理
|
||||
binding.getRoot().setOnTouchListener((v, event) -> {
|
||||
if (list.size() > 5) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
EventBus.getDefault().post(new EBReuse("CalenderDown"));
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||
EventBus.getDefault().post(new EBReuse("CalenderCancel"));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
view.addView(inflate);
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter({"addKaiFuView", "clickListener"})
|
||||
public static void addKaiFuView(LinearLayout view, List<KaiFuCalendarEntity> list, OnViewClickListener listener) {
|
||||
if (list == null) return;
|
||||
view.removeAllViews();
|
||||
view.addView(LayoutInflater.from(view.getContext()).inflate(R.layout.kaifu_add_item_title, null));
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
View inflate = LayoutInflater.from(view.getContext()).inflate(R.layout.kaifu_add_item, null);
|
||||
KaifuAddItemBinding binding = KaifuAddItemBinding.bind(inflate);
|
||||
binding.setClickListener(listener);
|
||||
binding.setEntity(list.get(i));
|
||||
binding.setPosition(i);
|
||||
binding.setIsCloseBottom(list.size() - 1 == i);
|
||||
view.addView(inflate);
|
||||
|
||||
binding.kaifuAddName.setOnFocusChangeListener((v, hasFocus) -> {
|
||||
if (hasFocus) {
|
||||
binding.kaifuAddName.setHint("");
|
||||
} else {
|
||||
binding.kaifuAddName.setHint("点击填写");
|
||||
}
|
||||
});
|
||||
binding.kaifuAddRemark.setOnFocusChangeListener((v, hasFocus) -> {
|
||||
if (hasFocus) {
|
||||
binding.kaifuAddRemark.setHint("");
|
||||
} else {
|
||||
binding.kaifuAddRemark.setHint("点击填写");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter({"addKaiFuTime", "addKaiFuPosition"})
|
||||
public static void addKaiFuTime(EditText view, Long time, Integer position) {
|
||||
if (time == 0) {
|
||||
view.setHint("点击选择");
|
||||
view.setText("");
|
||||
} else {
|
||||
String pattern;
|
||||
if (position == 0) {
|
||||
pattern = "yyy-MM-dd HH:mm +";
|
||||
} else {
|
||||
pattern = "yyy-MM-dd HH:mm";
|
||||
}
|
||||
SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.CHINA);
|
||||
view.setText(format.format(time * 1000));
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter({"kaiFuTextColor", "kaiFuTextPosition"})
|
||||
public static void kaiFuTextColor(EditText view, Integer dataMark, Integer position) {
|
||||
if (dataMark == 1 && view.getId() == R.id.kaifu_add_time
|
||||
|| dataMark == 2 && view.getId() == R.id.kaifu_add_name
|
||||
|| dataMark == 3 && view.getId() == R.id.kaifu_add_remark
|
||||
|| dataMark == 4 && (view.getId() == R.id.kaifu_add_time || view.getId() == R.id.kaifu_add_name)) {
|
||||
view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.red));
|
||||
view.setHintTextColor(ContextCompat.getColor(view.getContext(), R.color.red));
|
||||
} else if (position == 0) {
|
||||
view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.hint));
|
||||
view.setHintTextColor(ContextCompat.getColor(view.getContext(), R.color.hint));
|
||||
} else {
|
||||
view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.title));
|
||||
view.setHintTextColor(ContextCompat.getColor(view.getContext(), R.color.hint));
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("visibleGone")
|
||||
public static void showHide(View view, Boolean show) {
|
||||
if (show) {
|
||||
if (show != null && show) {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
view.setVisibility(View.GONE);
|
||||
@ -146,4 +284,190 @@ public class BindingAdapters {
|
||||
view.setText("异常");
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter({"downloadButton", "traceEvent"})
|
||||
public static void setDownloadButton(DownloadProgressBar progressBar, GameEntity gameEntity, ExposureEvent traceEvent) {
|
||||
// 判断是否显示按钮
|
||||
if (gameEntity != null
|
||||
&& Config.isShowDownload(gameEntity.getId())
|
||||
&& !"光环助手".equals(gameEntity.getName())) {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
// 显示下载按钮状态
|
||||
if (gameEntity.getApk().isEmpty()) {
|
||||
progressBar.setText("暂无下载");
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.NONE);
|
||||
} else {
|
||||
String status = GameUtils.getDownloadBtnText(progressBar.getContext(), gameEntity);
|
||||
switch (status) {
|
||||
case "插件化":
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.PLUGIN);
|
||||
break;
|
||||
case "打开":
|
||||
if (gameEntity.getApk().size() == 1) {
|
||||
status = "启动";
|
||||
}
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.LAUNCH_OR_OPEN);
|
||||
break;
|
||||
default:
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.NORMAL);
|
||||
break;
|
||||
}
|
||||
progressBar.setText(status);
|
||||
}
|
||||
|
||||
// 显示下载过程状态
|
||||
if (gameEntity.getApk().size() == 1) {
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(progressBar.getContext()).getDownloadEntityByUrl(gameEntity.getApk().get(0).getUrl());
|
||||
if (downloadEntity != null) {
|
||||
progressBar.setProgress((int) (downloadEntity.getPercent() * 10));
|
||||
switch (downloadEntity.getStatus()) {
|
||||
case downloading:
|
||||
case pause:
|
||||
case timeout:
|
||||
case neterror:
|
||||
case waiting:
|
||||
progressBar.setText(R.string.downloading);
|
||||
if (downloadEntity.isPluggable() && PackageManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.DOWNLOADING_PLUGIN);
|
||||
} else {
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.DOWNLOADING_NORMAL);
|
||||
}
|
||||
break;
|
||||
case done:
|
||||
progressBar.setText(R.string.install);
|
||||
if (downloadEntity.isPluggable()
|
||||
&& PackageManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_PLUGIN);
|
||||
} else {
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_NORMAL);
|
||||
}
|
||||
break;
|
||||
case cancel:
|
||||
case hijack:
|
||||
case notfound:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 点击事件
|
||||
progressBar.setOnClickListener(v -> {
|
||||
switch (progressBar.getDownloadType()) {
|
||||
case DOWNLOADING_PLUGIN:
|
||||
case DOWNLOADING_NORMAL:
|
||||
Intent intent = DownloadManagerActivity.getDownloadMangerIntent(v.getContext(),
|
||||
gameEntity.getApk().get(0).getUrl(), "(我的光环:我的游戏)");
|
||||
v.getContext().startActivity(intent);
|
||||
break;
|
||||
case NONE:
|
||||
Utils.toast(v.getContext(), "该游戏已关闭下载");
|
||||
break;
|
||||
case NORMAL:
|
||||
case PLUGIN:
|
||||
if (gameEntity.getApk().size() == 1) {
|
||||
if (NetworkUtils.isWifiConnected(v.getContext())) {
|
||||
download(progressBar, gameEntity, traceEvent);
|
||||
} else {
|
||||
DialogUtils.showDownloadDialog(v.getContext(), () -> {
|
||||
download(progressBar, gameEntity, traceEvent);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
DownloadDialog.getInstance(v.getContext()).showPopupWindow(v, gameEntity,
|
||||
"(我的光环:我的游戏)", "我的光环-我的游戏:" + gameEntity.getName(), traceEvent);
|
||||
}
|
||||
break;
|
||||
case LAUNCH_OR_OPEN:
|
||||
if (gameEntity.getApk().size() == 1) {
|
||||
DataUtils.onGameLaunchEvent(v.getContext(), gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), "我的光环-我的游戏");
|
||||
PackageUtils.launchApplicationByPackageName(v.getContext(), gameEntity.getApk().get(0).getPackageName());
|
||||
} else {
|
||||
DownloadDialog.getInstance(v.getContext()).showPopupWindow(v, gameEntity,
|
||||
"(我的光环:我的游戏)", "我的光环-我的游戏:" + gameEntity.getName(), traceEvent);
|
||||
}
|
||||
break;
|
||||
case INSTALL_PLUGIN:
|
||||
case INSTALL_NORMAL:
|
||||
if (gameEntity.getApk().size() == 1) {
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(progressBar.getContext()).getDownloadEntityByUrl(gameEntity.getApk().get(0).getUrl());
|
||||
if (downloadEntity != null) {
|
||||
PackageUtils.launchSetup(v.getContext(), downloadEntity.getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 开始下载
|
||||
private static void download(DownloadProgressBar progressBar, GameEntity
|
||||
gameEntity, ExposureEvent traceEvent) {
|
||||
String str = progressBar.getText();
|
||||
String method;
|
||||
if (str.contains("更新")) {
|
||||
method = "更新";
|
||||
} else if (str.contains("插件化")) {
|
||||
method = "插件化";
|
||||
} else {
|
||||
method = progressBar.getContext().getString(R.string.download);
|
||||
}
|
||||
ApkEntity apkEntity = gameEntity.getApk().get(0);
|
||||
String msg = FileUtils.isCanDownload(progressBar.getContext(), apkEntity.getSize());
|
||||
if (TextUtils.isEmpty(msg)) {
|
||||
DataUtils.onGameDownloadEvent(progressBar.getContext(), gameEntity.getName(), apkEntity.getPlatform(), "(我的光环:我的游戏)", "下载开始");
|
||||
|
||||
ExposureEvent downloadExposureEvent = ExposureUtils.INSTANCE.logADownloadExposureEvent(gameEntity, apkEntity.getPlatform(), traceEvent, ExposureUtils.DownloadType.DOWNLOAD);
|
||||
|
||||
DownloadManager.createDownload(progressBar.getContext(),
|
||||
apkEntity,
|
||||
gameEntity,
|
||||
method,
|
||||
StringUtils.buildString("(我的光环:我的游戏)"), "我的光环-我的游戏:" + gameEntity.getName(),
|
||||
downloadExposureEvent);
|
||||
|
||||
progressBar.setProgress(0);
|
||||
progressBar.setDownloadType("插件化".equals(method) ?
|
||||
DownloadProgressBar.DownloadType.DOWNLOADING_PLUGIN : DownloadProgressBar.DownloadType.DOWNLOADING_NORMAL);
|
||||
} else {
|
||||
Utils.toast(progressBar.getContext(), msg);
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter({"gameLabelList", "subjectTag"})
|
||||
public static void setGameLabelList(LinearLayout layout, GameEntity gameEntity, String subjectTag) {
|
||||
if (gameEntity == null) return;
|
||||
if (gameEntity.getTest() != null) {
|
||||
layout.removeAllViews();
|
||||
View testView = LayoutInflater.from(layout.getContext()).inflate(R.layout.game_test_label, null);
|
||||
TextView testType = testView.findViewById(R.id.test_type);
|
||||
TextView testTime = testView.findViewById(R.id.test_time);
|
||||
String type = gameEntity.getTest().getType();
|
||||
KaiFuUtils.setKaiFuType(testType, type);
|
||||
|
||||
if (gameEntity.getTest().getStart() == 0) {
|
||||
testTime.setVisibility(View.GONE);
|
||||
} else {
|
||||
testTime.setText(GameViewUtils.getGameTestDate(gameEntity.getTest().getStart()));
|
||||
}
|
||||
layout.addView(testView);
|
||||
} else {
|
||||
GameViewUtils.setLabelList(layout.getContext(), layout, gameEntity.getTag(), subjectTag, gameEntity.getTagStyle());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@BindingAdapter("isRefreshing")
|
||||
public static void isRefreshing(SwipeRefreshLayout layout, LoadStatus status) {
|
||||
if (status == LoadStatus.INIT_LOADING) {
|
||||
layout.setRefreshing(true);
|
||||
} else {
|
||||
layout.setRefreshing(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,61 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import android.arch.persistence.room.TypeConverter
|
||||
import com.gh.common.exposure.meta.Meta
|
||||
import com.google.gson.Gson
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class ExposureConverters {
|
||||
|
||||
@TypeConverter
|
||||
fun convertPayload2String(any: ExposureEntity): String {
|
||||
return Gson().toJson(any)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertString2Payload(string: String): ExposureEntity {
|
||||
return Gson().fromJson(string, ExposureEntity::class.java)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertSource2String(sourceList: List<ExposureSource>): String {
|
||||
return Gson().toJson(sourceList)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertString2Source(sourceList: String): List<ExposureSource> {
|
||||
return ArrayList(Arrays.asList(Gson().fromJson(sourceList, Array<ExposureSource>::class.java))) as List<ExposureSource>
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertETrace2String(sourceList: List<ExposureEvent>?): String {
|
||||
return Gson().toJson(sourceList)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertStringToETrace(sourceList: String): List<ExposureEvent> {
|
||||
return ArrayList(Arrays.asList(Gson().fromJson(sourceList, Array<ExposureEvent>::class.java))) as List<ExposureEvent>
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertExposeType2String(exposureType: ExposureType): String {
|
||||
return exposureType.toString()
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertStringToExposeType(exposureType: String): ExposureType {
|
||||
return ExposureType.valueOf(exposureType)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertMeta2String(any: Meta): String {
|
||||
return Gson().toJson(any)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertString2Meta(string: String): Meta {
|
||||
return Gson().fromJson(string, Meta::class.java)
|
||||
}
|
||||
|
||||
}
|
||||
23
app/src/main/java/com/gh/common/exposure/ExposureDatabase.kt
Normal file
23
app/src/main/java/com/gh/common/exposure/ExposureDatabase.kt
Normal file
@ -0,0 +1,23 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import android.arch.persistence.room.Database
|
||||
import android.arch.persistence.room.Room
|
||||
import android.arch.persistence.room.RoomDatabase
|
||||
import android.arch.persistence.room.TypeConverters
|
||||
import android.content.Context
|
||||
|
||||
@TypeConverters(ExposureConverters::class)
|
||||
@Database(entities = [ExposureEvent::class], version = 1, exportSchema = false)
|
||||
abstract class ExposureDatabase : RoomDatabase() {
|
||||
companion object {
|
||||
private const val DATABASE = "exposure_database"
|
||||
|
||||
fun buildDatabase(context: Context): ExposureDatabase {
|
||||
return Room.databaseBuilder(context, ExposureDatabase::class.java, DATABASE)
|
||||
.fallbackToDestructiveMigration()
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun logHubEventDao(): ExposureEventDao
|
||||
}
|
||||
18
app/src/main/java/com/gh/common/exposure/ExposureEntity.kt
Normal file
18
app/src/main/java/com/gh/common/exposure/ExposureEntity.kt
Normal file
@ -0,0 +1,18 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import android.os.Parcelable
|
||||
import android.support.annotation.Keep
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Keep
|
||||
@Parcelize
|
||||
data class ExposureEntity(
|
||||
@SerializedName("game_id")
|
||||
val gameId: String? = "",
|
||||
val gameName: String? = "",
|
||||
val sequence: Int? = 0,
|
||||
val platform: String? = "",
|
||||
val downloadType: String? = "",
|
||||
val downloadCompleteType: String? = ""
|
||||
) : Parcelable
|
||||
40
app/src/main/java/com/gh/common/exposure/ExposureEvent.kt
Normal file
40
app/src/main/java/com/gh/common/exposure/ExposureEvent.kt
Normal file
@ -0,0 +1,40 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import android.arch.persistence.room.Entity
|
||||
import android.arch.persistence.room.PrimaryKey
|
||||
import android.os.Parcelable
|
||||
import android.support.annotation.Keep
|
||||
import com.gh.common.exposure.meta.Meta
|
||||
import com.gh.common.exposure.meta.MetaUtil
|
||||
import com.gh.common.exposure.time.TimeUtil
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
import java.util.*
|
||||
|
||||
@Keep
|
||||
@Parcelize
|
||||
@Entity(tableName = "exposureEvent")
|
||||
data class ExposureEvent(
|
||||
val payload: ExposureEntity,
|
||||
val source: List<ExposureSource>,
|
||||
var eTrace: List<ExposureEvent>? = arrayListOf(),
|
||||
val event: ExposureType,
|
||||
val meta: Meta = MetaUtil.getMeta(),
|
||||
val time: Int = TimeUtil.currentTime(),
|
||||
@PrimaryKey
|
||||
val id: String = UUID.randomUUID().toString()) : Parcelable {
|
||||
companion object {
|
||||
fun createEvent(gameEntity: GameEntity?, source: List<ExposureSource>, eTrace: List<ExposureEvent>?, event: ExposureType): ExposureEvent {
|
||||
return ExposureEvent(
|
||||
ExposureEntity(gameId = gameEntity?.id,
|
||||
gameName = gameEntity?.name,
|
||||
sequence = gameEntity?.sequence,
|
||||
platform = gameEntity?.platform,
|
||||
downloadType = gameEntity?.downloadType,
|
||||
downloadCompleteType = gameEntity?.downloadCompleteType),
|
||||
source = source,
|
||||
eTrace = eTrace,
|
||||
event = event)
|
||||
}
|
||||
}
|
||||
}
|
||||
19
app/src/main/java/com/gh/common/exposure/ExposureEventDao.kt
Normal file
19
app/src/main/java/com/gh/common/exposure/ExposureEventDao.kt
Normal file
@ -0,0 +1,19 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import android.arch.persistence.room.*
|
||||
|
||||
@Dao
|
||||
interface ExposureEventDao {
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insertMany(eventList: List<ExposureEvent>)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insert(event: ExposureEvent)
|
||||
|
||||
@Query("SELECT * FROM exposureEvent")
|
||||
fun getAll(): List<ExposureEvent>
|
||||
|
||||
@Delete
|
||||
fun deleteMany(eventList: List<ExposureEvent>)
|
||||
}
|
||||
70
app/src/main/java/com/gh/common/exposure/ExposureListener.kt
Normal file
70
app/src/main/java/com/gh/common/exposure/ExposureListener.kt
Normal file
@ -0,0 +1,70 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import rx.functions.Action1
|
||||
|
||||
/**
|
||||
* Exposure Event Listener for RecyclerView
|
||||
*
|
||||
* TODO 1. Pull down refresh change in first page without scroll down action
|
||||
* TODO 2. Item change not triggered by user scroll action (vm data change etc.)
|
||||
*/
|
||||
class ExposureListener(var fragment: Fragment, var exposable: IExposable) : RecyclerView.OnScrollListener() {
|
||||
|
||||
var throttleBus: ExposureThrottleBus? = null
|
||||
var layoutManager: LinearLayoutManager? = null
|
||||
var visibleState: ExposureThrottleBus.VisibleState? = null
|
||||
|
||||
init {
|
||||
fragment.fragmentManager?.registerFragmentLifecycleCallbacks(
|
||||
object : FragmentManager.FragmentLifecycleCallbacks() {
|
||||
override fun onFragmentResumed(fm: FragmentManager?, f: Fragment?) {
|
||||
throttleBus = ExposureThrottleBus(Action1 { commitExposure(it) }, Action1(Throwable::printStackTrace))
|
||||
}
|
||||
|
||||
override fun onFragmentPaused(fm: FragmentManager?, f: Fragment?) {
|
||||
visibleState?.let { commitExposure(it) }
|
||||
throttleBus?.unsubscribe()
|
||||
}
|
||||
}, false)
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor items in display when scrolling, record those newly displayed as well as
|
||||
* those newly disappeared. And finally trigger commitExposure().
|
||||
*/
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
|
||||
if (layoutManager == null) layoutManager = recyclerView.layoutManager as LinearLayoutManager
|
||||
|
||||
layoutManager?.run {
|
||||
visibleState = ExposureThrottleBus.VisibleState(findFirstCompletelyVisibleItemPosition(), findLastCompletelyVisibleItemPosition())
|
||||
throttleBus?.postVisibleState(visibleState!!)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check disappearMap items together with according data in displayMap,
|
||||
* log any items displayed long enough to be called a EXPOSURE
|
||||
*/
|
||||
private fun commitExposure(visibleState: ExposureThrottleBus.VisibleState) {
|
||||
|
||||
val eventList = arrayListOf<ExposureEvent>()
|
||||
|
||||
for (pos in visibleState.firstCompletelyVisible..visibleState.lastCompletelyVisible) {
|
||||
try {
|
||||
exposable.getEventByPosition(pos)?.let { eventList.add(it) }
|
||||
exposable.getEventListByPosition(pos)?.let { eventList.addAll(it) }
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
ExposureManager.log(eventList)
|
||||
}
|
||||
|
||||
}
|
||||
199
app/src/main/java/com/gh/common/exposure/ExposureManager.kt
Normal file
199
app/src/main/java/com/gh/common/exposure/ExposureManager.kt
Normal file
@ -0,0 +1,199 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import android.app.Application
|
||||
import com.aliyun.sls.android.sdk.LogException
|
||||
import com.aliyun.sls.android.sdk.model.LogGroup
|
||||
import com.gh.common.exposure.aliyun.LGLOG
|
||||
import com.gh.common.exposure.aliyun.LGLOGClient
|
||||
import com.gh.common.exposure.meta.MetaUtil
|
||||
import com.gh.common.exposure.time.TimeUtil
|
||||
import com.google.gson.Gson
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.concurrent.fixedRateTimer
|
||||
|
||||
/**
|
||||
* ExposureManager tool to commit logs to aliyun loghub
|
||||
* TODO handle logs that failed to be committed multiple times
|
||||
*/
|
||||
object ExposureManager {
|
||||
|
||||
private var TAG: String = ExposureManager::class.java.simpleName
|
||||
|
||||
private const val ACCESS_KEY_ID = "LTAIV3i0sNc4TPK1"
|
||||
private const val ACCESS_KEY_SECRET = "8dKtTPeE5WYA6ZCeuIBcIVp7eB0ir4"
|
||||
private const val ENDPOINT = "cn-qingdao.log.aliyuncs.com"
|
||||
private const val PROJECT = "ghzs"
|
||||
private const val LOG_STORE = "exposure"
|
||||
private const val STORE_SIZE = 100
|
||||
private const val STORE_FORCE_UPLOAD_PERIOD = 300 * 1000L
|
||||
|
||||
private lateinit var client: LGLOGClient
|
||||
private lateinit var db: ExposureEventDao
|
||||
private val storeList = arrayListOf<ExposureEvent>()
|
||||
private val storeOpThread = Executors.newSingleThreadExecutor()
|
||||
private val gson = Gson()
|
||||
|
||||
private val exposureCache = FixedSizeLinkedHashSet<String>(20)
|
||||
|
||||
/**
|
||||
* Must be called early to init object then real use (for example in Application)
|
||||
*/
|
||||
fun init(application: Application) {
|
||||
|
||||
client = LGLOGClient(ENDPOINT, ACCESS_KEY_ID, ACCESS_KEY_SECRET, PROJECT)
|
||||
db = ExposureDatabase.buildDatabase(application).logHubEventDao()
|
||||
|
||||
storeOpThread.execute({
|
||||
val eventList = db.getAll()
|
||||
storeList.addAll(eventList)
|
||||
})
|
||||
|
||||
fixedRateTimer(name = "ExposureManager-Store-Checker", initialDelay = 500, period = STORE_FORCE_UPLOAD_PERIOD) {
|
||||
checkAndUploadFromStore(true)
|
||||
}
|
||||
|
||||
MetaUtil.init(application)
|
||||
TimeUtil.init()
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an Event
|
||||
*/
|
||||
fun log(event: ExposureEvent, uploadImmediately: Boolean = false) {
|
||||
when (uploadImmediately) {
|
||||
false -> store(event)
|
||||
true -> upload(event)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log Many Events
|
||||
*/
|
||||
fun log(eventList: List<ExposureEvent>, uploadImmediately: Boolean = false) {
|
||||
when (uploadImmediately) {
|
||||
false -> store(eventList)
|
||||
true -> upload(eventList)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an Event to storeList, upload when storeList size exceeds STORE_SIZE
|
||||
*/
|
||||
private fun store(event: ExposureEvent) {
|
||||
storeOpThread.execute({
|
||||
if (!exposureCache.contains(event.id)) {
|
||||
storeList.add(event)
|
||||
db.insert(event)
|
||||
exposureCache.add(event.id)
|
||||
}
|
||||
})
|
||||
checkAndUploadFromStore()
|
||||
}
|
||||
|
||||
/**
|
||||
* Store Many Events to storeList, upload when storeList size exceeds STORE_SIZE
|
||||
*/
|
||||
private fun store(eventList: List<ExposureEvent>) {
|
||||
storeOpThread.execute({
|
||||
for (event in eventList) {
|
||||
if (!exposureCache.contains(event.id)) {
|
||||
storeList.add(event)
|
||||
db.insert(event)
|
||||
exposureCache.add(event.id)
|
||||
}
|
||||
}
|
||||
})
|
||||
checkAndUploadFromStore()
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload an Event
|
||||
*/
|
||||
private fun upload(event: ExposureEvent) {
|
||||
storeOpThread.execute({
|
||||
client.PostLog(buildLogGroup(event), LOG_STORE)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload Many Events
|
||||
*/
|
||||
private fun upload(eventList: List<ExposureEvent>) {
|
||||
storeOpThread.execute({
|
||||
client.PostLog(buildLogGroup(eventList), LOG_STORE)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload Events From Store, and removed them
|
||||
*/
|
||||
private fun checkAndUploadFromStore(isForceUpload: Boolean = false) {
|
||||
if (storeList.size < STORE_SIZE && !isForceUpload || storeList.size == 0) return
|
||||
storeOpThread.execute({
|
||||
if (storeList.size < STORE_SIZE && !isForceUpload || storeList.size == 0) return@execute
|
||||
val uploaded = storeList.toList()
|
||||
try {
|
||||
client.PostLog(buildLogGroup(uploaded), LOG_STORE)
|
||||
} catch (exception: LogException) {
|
||||
// Return to insure no logs lost because of online commit failure
|
||||
return@execute
|
||||
}
|
||||
storeList.removeAll(uploaded)
|
||||
db.deleteMany(uploaded)
|
||||
})
|
||||
}
|
||||
|
||||
private fun buildLog(event: ExposureEvent): LGLOG {
|
||||
val log = LGLOG()
|
||||
|
||||
log.PutContent("id", event.id)
|
||||
log.PutContent("payload", gson.toJson(event.payload))
|
||||
log.PutContent("event", event.event.toString())
|
||||
log.PutContent("source", eliminateMultipleBrackets(gson.toJson(event.source)))
|
||||
log.PutContent("meta", gson.toJson(event.meta))
|
||||
log.PutContent("e-traces", if (event.eTrace != null) eliminateMultipleBrackets(gson.toJson(event.eTrace)) else "")
|
||||
log.PutTime(event.time)
|
||||
|
||||
return log
|
||||
}
|
||||
|
||||
private fun eliminateMultipleBrackets(jsonWithMultipleBracket: String): String {
|
||||
return jsonWithMultipleBracket.replace("[[", "[").replace("]]", "]")
|
||||
}
|
||||
|
||||
private fun buildLogGroup(event: ExposureEvent): LogGroup {
|
||||
|
||||
val logGroup = LogGroup("sls android", "no ip")
|
||||
|
||||
logGroup.PutLog(buildLog(event))
|
||||
|
||||
return logGroup
|
||||
}
|
||||
|
||||
private fun buildLogGroup(eventList: List<ExposureEvent>): LogGroup {
|
||||
|
||||
val logGroup = LogGroup("sls android", "no ip")
|
||||
|
||||
eventList.forEach { event ->
|
||||
logGroup.PutLog(buildLog(event))
|
||||
}
|
||||
|
||||
return logGroup
|
||||
}
|
||||
|
||||
internal class FixedSizeLinkedHashSet<T>(var maxSize: Int) : LinkedHashSet<T>() {
|
||||
override fun add(element: T): Boolean {
|
||||
if (size == maxSize) {
|
||||
pop()
|
||||
}
|
||||
return super.add(element);
|
||||
}
|
||||
|
||||
private fun pop() {
|
||||
if (size > 0) {
|
||||
remove(iterator().next())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import android.os.Parcelable
|
||||
import android.support.annotation.Keep
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Keep
|
||||
@Parcelize
|
||||
data class ExposureSource(var k: String, var v: String): Parcelable
|
||||
@ -0,0 +1,60 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import rx.Subscription
|
||||
import rx.functions.Action1
|
||||
import rx.schedulers.Schedulers
|
||||
import rx.subjects.PublishSubject
|
||||
import rx.subjects.Subject
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class ExposureThrottleBus(var onSuccess: Action1<VisibleState>, var onError: Action1<Throwable>) {
|
||||
|
||||
companion object {
|
||||
private const val THRESHOLD_TIME = 300L
|
||||
}
|
||||
|
||||
private val mPublishSubject: Subject<VisibleState, VisibleState>
|
||||
private val mSubscription: Subscription
|
||||
|
||||
init {
|
||||
mPublishSubject = PublishSubject.create()
|
||||
|
||||
/**
|
||||
* Since onScroll() callback will be triggered multiple times for every swipe, we use
|
||||
* distinctUntilChanged() to prevent committing the same visibleState event and
|
||||
* throttleWithTimeout() to pass a visibleState event with a delay and drop current event if another event arrives before the timeout.
|
||||
*/
|
||||
mSubscription = mPublishSubject
|
||||
.distinctUntilChanged()
|
||||
.throttleWithTimeout(THRESHOLD_TIME, TimeUnit.MILLISECONDS)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(onSuccess, onError)
|
||||
}
|
||||
|
||||
fun unsubscribe() {
|
||||
mSubscription.unsubscribe()
|
||||
}
|
||||
|
||||
fun postVisibleState(visibleState: VisibleState) {
|
||||
mPublishSubject.onNext(visibleState)
|
||||
}
|
||||
|
||||
class VisibleState(val firstCompletelyVisible: Int, val lastCompletelyVisible: Int) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other == null || javaClass != other.javaClass) return false
|
||||
|
||||
val that = other as VisibleState
|
||||
|
||||
if (firstCompletelyVisible != that.firstCompletelyVisible) return false
|
||||
|
||||
return lastCompletelyVisible == that.lastCompletelyVisible
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = firstCompletelyVisible
|
||||
result = 31 * result + lastCompletelyVisible
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
object ExposureTraceUtils {
|
||||
|
||||
fun appendTrace(event: ExposureEvent?): List<ExposureEvent> {
|
||||
val traceList = arrayListOf<ExposureEvent>()
|
||||
|
||||
event?.let {
|
||||
if (event.eTrace == null) {
|
||||
traceList.add(event)
|
||||
} else {
|
||||
traceList.addAll(event.eTrace!!)
|
||||
traceList.add(flattenTrace(event))
|
||||
}
|
||||
}
|
||||
|
||||
return traceList
|
||||
}
|
||||
|
||||
private fun flattenTrace(event: ExposureEvent): ExposureEvent {
|
||||
event.eTrace = arrayListOf()
|
||||
return event
|
||||
}
|
||||
|
||||
}
|
||||
11
app/src/main/java/com/gh/common/exposure/ExposureType.kt
Normal file
11
app/src/main/java/com/gh/common/exposure/ExposureType.kt
Normal file
@ -0,0 +1,11 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
enum class ExposureType {
|
||||
EXPOSURE,
|
||||
|
||||
CLICK,
|
||||
|
||||
DOWNLOAD,
|
||||
|
||||
DOWNLOAD_COMPLETE
|
||||
}
|
||||
42
app/src/main/java/com/gh/common/exposure/ExposureUtils.kt
Normal file
42
app/src/main/java/com/gh/common/exposure/ExposureUtils.kt
Normal file
@ -0,0 +1,42 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.google.gson.Gson
|
||||
import java.util.*
|
||||
|
||||
object ExposureUtils {
|
||||
|
||||
fun logADownloadExposureEvent(entity: GameEntity, platform: String?, traceEvent: ExposureEvent?, downloadType: DownloadType): ExposureEvent {
|
||||
val gameEntity = entity.clone()
|
||||
gameEntity.platform = platform
|
||||
gameEntity.downloadType = downloadType.toString()
|
||||
val exposureEvent = ExposureEvent.createEvent(gameEntity = gameEntity,
|
||||
source = traceEvent?.source ?: ArrayList(),
|
||||
eTrace = ExposureTraceUtils.appendTrace(traceEvent),
|
||||
event = ExposureType.DOWNLOAD)
|
||||
ExposureManager.log(exposureEvent, false)
|
||||
return exposureEvent
|
||||
}
|
||||
|
||||
fun logADownloadCompleteExposureEvent(entity: GameEntity, platform: String?, trace: String?, downloadType: DownloadType) {
|
||||
val gameEntity = entity.clone()
|
||||
gameEntity.platform = platform
|
||||
gameEntity.downloadCompleteType = downloadType.toString()
|
||||
val traceEvent = Gson().fromJson(trace, ExposureEvent::class.java)
|
||||
val exposureEvent = ExposureEvent.createEvent(gameEntity = gameEntity,
|
||||
source = traceEvent?.source ?: ArrayList(),
|
||||
eTrace = ExposureTraceUtils.appendTrace(traceEvent),
|
||||
event = ExposureType.DOWNLOAD_COMPLETE)
|
||||
ExposureManager.log(exposureEvent, false)
|
||||
}
|
||||
|
||||
enum class DownloadType {
|
||||
DOWNLOAD,
|
||||
|
||||
UPDATE,
|
||||
|
||||
PLUGIN_UPDATE,
|
||||
|
||||
PLUGIN_DOWNLOAD
|
||||
}
|
||||
}
|
||||
7
app/src/main/java/com/gh/common/exposure/IExposable.kt
Normal file
7
app/src/main/java/com/gh/common/exposure/IExposable.kt
Normal file
@ -0,0 +1,7 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
interface IExposable {
|
||||
fun getEventByPosition(pos: Int): ExposureEvent?
|
||||
|
||||
fun getEventListByPosition(pos: Int): List<ExposureEvent>?
|
||||
}
|
||||
42
app/src/main/java/com/gh/common/exposure/aliyun/LGLOG.java
Normal file
42
app/src/main/java/com/gh/common/exposure/aliyun/LGLOG.java
Normal file
@ -0,0 +1,42 @@
|
||||
package com.gh.common.exposure.aliyun;
|
||||
|
||||
import com.aliyun.sls.android.sdk.model.Log;
|
||||
import com.gh.common.exposure.time.TimeUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Extend to change __time__ field in mContent to use the correct time from TimeUtil
|
||||
*/
|
||||
public class LGLOG extends Log {
|
||||
|
||||
private Map<String, Object> mContent = new HashMap<String, Object>();
|
||||
|
||||
public LGLOG() {
|
||||
mContent.put("__time__", TimeUtil.INSTANCE.currentTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PutTime(int time) {
|
||||
mContent.put("__time__", time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PutContent(String key, String value) {
|
||||
if (key == null || key.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (value == null) {
|
||||
mContent.put(key, "");
|
||||
} else {
|
||||
mContent.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> GetContent() {
|
||||
return mContent;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package com.gh.common.exposure.aliyun;
|
||||
|
||||
import com.aliyun.sls.android.sdk.LOGClient;
|
||||
import com.aliyun.sls.android.sdk.LogException;
|
||||
import com.gh.common.exposure.time.TimeUtil;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* Extend to override GetHttpHeadersFrom, so we can change "Date" header attribute using
|
||||
* correct time from TimeUtil.
|
||||
* And accordingly, the value of "Authorization" attribute should also be re-calculate
|
||||
* since the sign became different as before.
|
||||
*/
|
||||
public class LGLOGClient extends LOGClient {
|
||||
|
||||
private String mAccessKeyID;
|
||||
private String mAccessKeySecret;
|
||||
private String mAccessToken;
|
||||
|
||||
public LGLOGClient(String endPoint, String accessKeyID, String accessKeySecret, String projectName) {
|
||||
super(endPoint, accessKeyID, accessKeySecret, projectName);
|
||||
this.mAccessKeyID = accessKeyID;
|
||||
this.mAccessKeySecret = accessKeySecret;
|
||||
this.mAccessToken = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> GetHttpHeadersFrom(String logStoreName, byte[] body, byte[] bodyZipped) throws LogException {
|
||||
|
||||
Map<String, String> headers = super.GetHttpHeadersFrom(logStoreName, body, bodyZipped);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT")); // 设置时区为GMT
|
||||
String str = sdf.format(new Date(TimeUtil.INSTANCE.currentTimeMillis()));
|
||||
headers.put("Date", str);
|
||||
|
||||
StringBuilder signStringBuf = new StringBuilder("POST" + "\n").
|
||||
append(headers.get("Content-MD5") + "\n").
|
||||
append(headers.get("Content-Type") + "\n").
|
||||
append(headers.get("Date") + "\n");
|
||||
String token = mAccessToken;
|
||||
if (token != null && token != "") {
|
||||
headers.put("x-acs-security-token", token);
|
||||
signStringBuf.append("x-acs-security-token:" + headers.get("x-acs-security-token") + "\n");
|
||||
}
|
||||
signStringBuf.append("x-log-apiversion:0.6.0\n").
|
||||
append("x-log-bodyrawsize:" + headers.get("x-log-bodyrawsize") + "\n").
|
||||
append("x-log-compresstype:deflate\n").
|
||||
append("x-log-signaturemethod:hmac-sha1\n").
|
||||
append("/logstores/" + logStoreName + "/shards/lb");
|
||||
String signString = signStringBuf.toString();
|
||||
try {
|
||||
String sign = hmac_sha1(signString, mAccessKeySecret);
|
||||
headers.put("Authorization", "LOG " + mAccessKeyID + ":" + sign);
|
||||
} catch (Exception e) {
|
||||
throw new LogException("LogClientError", "fail to get encode signature", e, "");
|
||||
}
|
||||
|
||||
return headers;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
23
app/src/main/java/com/gh/common/exposure/meta/Meta.kt
Normal file
23
app/src/main/java/com/gh/common/exposure/meta/Meta.kt
Normal file
@ -0,0 +1,23 @@
|
||||
package com.gh.common.exposure.meta
|
||||
|
||||
import android.os.Parcelable
|
||||
import android.support.annotation.Keep
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Keep
|
||||
@Parcelize
|
||||
data class Meta(
|
||||
val mac: String? = "",
|
||||
val imei: String? = "",
|
||||
val model: String? = "",
|
||||
val manufacturer: String? = "",
|
||||
val android_id: String? = "",
|
||||
val android_sdk: Int? = -1,
|
||||
val android_version: String? = "",
|
||||
val network: String? = "",
|
||||
val ip: String? = "",
|
||||
val os: String? = "",
|
||||
val channel: String? = "",
|
||||
val appVersion: String? = "",
|
||||
val userId: String? = ""
|
||||
) : Parcelable
|
||||
165
app/src/main/java/com/gh/common/exposure/meta/MetaUtil.kt
Normal file
165
app/src/main/java/com/gh/common/exposure/meta/MetaUtil.kt
Normal file
@ -0,0 +1,165 @@
|
||||
package com.gh.common.exposure.meta
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.wifi.WifiManager
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import android.telephony.TelephonyManager
|
||||
import android.text.TextUtils
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.leon.channel.helper.ChannelReaderUtil
|
||||
import java.io.File
|
||||
|
||||
object MetaUtil {
|
||||
|
||||
private lateinit var application: Application
|
||||
private var channel = ""
|
||||
|
||||
private var m: Meta? = null
|
||||
|
||||
fun init(application: Application) {
|
||||
MetaUtil.application = application
|
||||
}
|
||||
|
||||
fun refreshMeta() {
|
||||
m = Meta(getMac(), getIMEI(), getModel(), getManufacturer(), getAndroidId(), getAndroidSDK(),
|
||||
getAndroidVersion(), getNetwork(), getIP(), getOS(), getChannel(), BuildConfig.VERSION_NAME, UserManager.getInstance().userId)
|
||||
}
|
||||
|
||||
fun getMeta(): Meta {
|
||||
if (m == null) {
|
||||
refreshMeta()
|
||||
}
|
||||
return m!!
|
||||
}
|
||||
|
||||
private fun getChannel(): String? {
|
||||
if (TextUtils.isEmpty(channel)) {
|
||||
channel = if (ChannelReaderUtil.getChannel(application) != null) ChannelReaderUtil.getChannel(application) else ""
|
||||
}
|
||||
return channel
|
||||
}
|
||||
|
||||
/**
|
||||
* Get MAC address
|
||||
* TODO check > 6.0 results
|
||||
*/
|
||||
fun getMac(): String? {
|
||||
|
||||
var mac: String
|
||||
|
||||
//Plan A
|
||||
try {
|
||||
mac = File("/sys/class/net/wlan0/address").inputStream().bufferedReader().use { it.readText() }
|
||||
if (!TextUtils.isEmpty(mac)) return mac.trim()
|
||||
} catch (e: Exception) {
|
||||
// e.printStackTrace()
|
||||
}
|
||||
|
||||
// Plan B
|
||||
try {
|
||||
mac = File("/sys/class/net/eth0/address").inputStream().bufferedReader().use { it.readText() }
|
||||
if (!TextUtils.isEmpty(mac)) return mac.trim()
|
||||
} catch (e: Exception) {
|
||||
// e.printStackTrace()
|
||||
}
|
||||
|
||||
// Plan C
|
||||
val wifiManager = application.getSystemService(Context.WIFI_SERVICE) as WifiManager
|
||||
mac = wifiManager.connectionInfo.macAddress
|
||||
return mac.trim()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get IMEI
|
||||
*/
|
||||
fun getIMEI(): String? {
|
||||
|
||||
if (application.checkCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED)
|
||||
return ""
|
||||
|
||||
val telephonyManager = application.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
return "!" + telephonyManager.imei
|
||||
}
|
||||
|
||||
return telephonyManager.getDeviceId()
|
||||
|
||||
}
|
||||
|
||||
fun getModel(): String? {
|
||||
return Build.MODEL
|
||||
}
|
||||
|
||||
fun getManufacturer(): String? {
|
||||
return Build.MANUFACTURER
|
||||
}
|
||||
|
||||
fun getAndroidId(): String? {
|
||||
var android_id: String = ""
|
||||
try {
|
||||
android_id = Settings.Secure.getString(application.contentResolver, Settings.Secure.ANDROID_ID)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return android_id
|
||||
}
|
||||
|
||||
fun getAndroidSDK(): Int? {
|
||||
return Build.VERSION.SDK_INT
|
||||
}
|
||||
|
||||
fun getAndroidVersion(): String? {
|
||||
return Build.VERSION.RELEASE
|
||||
}
|
||||
|
||||
fun getNetwork(): String? {
|
||||
|
||||
if (application.checkCallingOrSelfPermission(Manifest.permission.ACCESS_NETWORK_STATE) != PackageManager.PERMISSION_GRANTED)
|
||||
return "unknown"
|
||||
|
||||
val activeNetwork = (application.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager).activeNetworkInfo
|
||||
?: return "unknown"
|
||||
|
||||
return when (activeNetwork.type) {
|
||||
ConnectivityManager.TYPE_WIFI -> "Wifi"
|
||||
ConnectivityManager.TYPE_WIMAX -> "WifiMax"
|
||||
ConnectivityManager.TYPE_MOBILE -> {
|
||||
val telephonyManager = application.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
|
||||
if (telephonyManager.simState != TelephonyManager.SIM_STATE_READY) return "unknown"
|
||||
when (telephonyManager.networkType) {
|
||||
// Unknown
|
||||
TelephonyManager.NETWORK_TYPE_UNKNOWN -> "Cellular - Unknown"
|
||||
// Cellular Data–2G
|
||||
TelephonyManager.NETWORK_TYPE_EDGE, TelephonyManager.NETWORK_TYPE_GPRS, TelephonyManager.NETWORK_TYPE_CDMA,
|
||||
TelephonyManager.NETWORK_TYPE_IDEN, TelephonyManager.NETWORK_TYPE_1xRTT -> "Cellular - 2G"
|
||||
// Cellular Data–3G
|
||||
TelephonyManager.NETWORK_TYPE_UMTS, TelephonyManager.NETWORK_TYPE_HSDPA, TelephonyManager.NETWORK_TYPE_HSPA,
|
||||
TelephonyManager.NETWORK_TYPE_HSPAP, TelephonyManager.NETWORK_TYPE_HSUPA, TelephonyManager.NETWORK_TYPE_EVDO_0,
|
||||
TelephonyManager.NETWORK_TYPE_EVDO_A, TelephonyManager.NETWORK_TYPE_EVDO_B -> "Cellular - 3G"
|
||||
// Cellular Data–4G
|
||||
TelephonyManager.NETWORK_TYPE_LTE -> "Cellular - 4G"
|
||||
else -> "Cellular - Unknown Generation"
|
||||
}
|
||||
|
||||
}
|
||||
else -> "unknown"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun getIP(): String {
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
fun getOS(): String {
|
||||
return "android"
|
||||
}
|
||||
}
|
||||
27
app/src/main/java/com/gh/common/exposure/time/Corrector.kt
Normal file
27
app/src/main/java/com/gh/common/exposure/time/Corrector.kt
Normal file
@ -0,0 +1,27 @@
|
||||
package com.gh.common.exposure.time
|
||||
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import rx.schedulers.Schedulers
|
||||
import kotlin.concurrent.fixedRateTimer
|
||||
|
||||
class Corrector {
|
||||
|
||||
companion object {
|
||||
const val TIME_CORRECTOR_ADJUST_PERIOD: Long = 600000
|
||||
}
|
||||
|
||||
var delta: Long = 0
|
||||
|
||||
init {
|
||||
fixedRateTimer("TimeUtil-Corrector-Checker", initialDelay = 0, period = TIME_CORRECTOR_ADJUST_PERIOD) {
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application).api.time
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe({
|
||||
val serverTime = java.lang.Long.parseLong(it.string())
|
||||
delta = serverTime * 1000 - System.currentTimeMillis()
|
||||
}, Throwable::printStackTrace)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
22
app/src/main/java/com/gh/common/exposure/time/TimeUtil.kt
Normal file
22
app/src/main/java/com/gh/common/exposure/time/TimeUtil.kt
Normal file
@ -0,0 +1,22 @@
|
||||
package com.gh.common.exposure.time
|
||||
|
||||
object TimeUtil {
|
||||
|
||||
private lateinit var corrector: Corrector
|
||||
|
||||
fun currentTimeMillis(): Long {
|
||||
return corrector.delta + System.currentTimeMillis()
|
||||
}
|
||||
|
||||
fun currentTime(): Int {
|
||||
return ( ( corrector.delta + System.currentTimeMillis() ) / 1000 ).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Must be called early then real use (for example in Application)
|
||||
*/
|
||||
fun init() {
|
||||
corrector = Corrector()
|
||||
}
|
||||
|
||||
}
|
||||
@ -22,7 +22,7 @@ public class ApkActiveUtils {
|
||||
ApkEntity apkEntity = apkList.get(i);
|
||||
String packageName = apkEntity.getPackageName();
|
||||
String id = gameEntity.getId();
|
||||
if (!apkEntity.isActive() && !PackageManager.isCanPluggable(id, packageName)) {
|
||||
if (!apkEntity.isActive() && !PackageManager.INSTANCE.isCanPluggable(id, packageName)) {
|
||||
apkList.remove(i);
|
||||
i--;
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@ import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.ask.entity.Questions;
|
||||
import com.gh.gamecenter.manager.UserManager;
|
||||
import com.gh.gamecenter.qa.entity.Questions;
|
||||
import com.gh.loghub.LogHubUtils;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.utils.Util_System_Phone_State;
|
||||
@ -25,8 +25,8 @@ public class AskLogUtils {
|
||||
if (context == null) return;
|
||||
JSONObject object = new JSONObject();
|
||||
try {
|
||||
object.put("community_id", UserManager.getInstance().getCommunityId(context));
|
||||
object.put("community_name", UserManager.getInstance().getCommunityName(context));
|
||||
object.put("community_id", UserManager.getInstance().getCommunity().getId());
|
||||
object.put("community_name", UserManager.getInstance().getCommunity().getName());
|
||||
object.put("question_id", questions.getId());
|
||||
object.put("question_name", questions.getTitle());
|
||||
object.put("subject", "question");
|
||||
@ -42,8 +42,8 @@ public class AskLogUtils {
|
||||
if (context == null) return;
|
||||
JSONObject object = new JSONObject();
|
||||
try {
|
||||
object.put("community_id", UserManager.getInstance().getCommunityId(context));
|
||||
object.put("community_name", UserManager.getInstance().getCommunityName(context));
|
||||
object.put("community_id", UserManager.getInstance().getCommunity().getId());
|
||||
object.put("community_name", UserManager.getInstance().getCommunity().getName());
|
||||
object.put("question_id", questions.getId());
|
||||
object.put("question_name", questions.getTitle());
|
||||
object.put("subject", "answer");
|
||||
@ -61,8 +61,8 @@ public class AskLogUtils {
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
try {
|
||||
object.put("community_id", UserManager.getInstance().getCommunityId(context));
|
||||
object.put("community_name", UserManager.getInstance().getCommunityName(context));
|
||||
object.put("community_id", UserManager.getInstance().getCommunity().getId());
|
||||
object.put("community_name", UserManager.getInstance().getCommunity().getName());
|
||||
object.put("keyword", searchKey);
|
||||
object.put("subject", "search");
|
||||
} catch (JSONException e) {
|
||||
@ -78,7 +78,7 @@ public class AskLogUtils {
|
||||
JSONObject object = new JSONObject();
|
||||
try {
|
||||
object.put("subject", "community_refresh");
|
||||
object.put("community_id", UserManager.getInstance().getCommunityId(context));
|
||||
object.put("community_id", UserManager.getInstance().getCommunity().getId());
|
||||
object.put("refresh_type", "recommend");
|
||||
object.put("data_count", dataCount);
|
||||
object.put("user_id", UserManager.getInstance().getUserId());
|
||||
|
||||
@ -85,20 +85,6 @@ object CollectionUtils {
|
||||
})
|
||||
}
|
||||
|
||||
fun patchCollection(context: Context, id: String, type: CollectionType) {
|
||||
// val postCollection = when (type) {
|
||||
// CollectionType.article -> RetrofitManager.getInstance(context).getApi().patchCollectionArticle(id)
|
||||
// CollectionType.toolkit -> RetrofitManager.getInstance(context).getApi().patchCollectionTools(id)
|
||||
// else -> {
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
// postCollection
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(object : Response<ResponseBody>() {})
|
||||
}
|
||||
|
||||
|
||||
interface OnCollectionListener {
|
||||
fun onSuccess()
|
||||
|
||||
@ -18,7 +18,7 @@ import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.OnCommentCallBackListener;
|
||||
import com.gh.gamecenter.adapter.viewholder.CommentViewHolder;
|
||||
import com.gh.gamecenter.entity.CommentEntity;
|
||||
import com.gh.gamecenter.entity.UserDataEntity;
|
||||
import com.gh.gamecenter.entity.MeEntity;
|
||||
import com.gh.gamecenter.entity.UserInfoEntity;
|
||||
import com.gh.gamecenter.manager.UserManager;
|
||||
import com.lightgame.utils.Utils;
|
||||
@ -83,7 +83,7 @@ public class CommentUtils {
|
||||
|
||||
List<String> dialogType = new ArrayList<>();
|
||||
|
||||
if (commentEntity.getUserData() == null || !commentEntity.getUserData().isCommentOwn()) {
|
||||
if (commentEntity.getMe() == null || !commentEntity.getMe().isCommentOwn()) {
|
||||
dialogType.add("回复");
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ public class CommentUtils {
|
||||
|
||||
break;
|
||||
case "查看对话":
|
||||
context.startActivity(CommentDetailActivity.getIntent(context, commentEntity.getId()));
|
||||
context.startActivity(CommentDetailActivity.getIntent(context, commentEntity.getId(), null));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -156,7 +156,7 @@ public class CommentUtils {
|
||||
|
||||
List<String> dialogType = new ArrayList<>();
|
||||
|
||||
if (commentEntity.getUserData() == null || !commentEntity.getUserData().isAnswerCommented()) {
|
||||
if (commentEntity.getMe() == null || !commentEntity.getMe().isAnswerCommented()) {
|
||||
dialogType.add("回复");
|
||||
}
|
||||
|
||||
@ -433,7 +433,7 @@ public class CommentUtils {
|
||||
|
||||
// 设置评论item 用户相关的view(点赞/头像/用户名)
|
||||
public static void setCommentUserView(Context mContext, CommentViewHolder holder, CommentEntity entity) {
|
||||
UserDataEntity userDataEntity = entity.getUserData();
|
||||
MeEntity userDataEntity = entity.getMe();
|
||||
holder.commentLikeCountTv.setTextColor(ContextCompat.getColor(mContext, R.color.hint));
|
||||
holder.commentLikeIv.setImageResource(R.drawable.ic_like_unselect);
|
||||
|
||||
@ -451,14 +451,14 @@ public class CommentUtils {
|
||||
//检查是否是自身评论
|
||||
UserInfoEntity userInfo = UserManager.getInstance().getUserInfoEntity();
|
||||
if (userDataEntity != null && userDataEntity.isCommentOwn() && userInfo != null) {
|
||||
if (entity.getUserData() != null && entity.getUserData().isAnswerOwn()) {
|
||||
if (entity.getMe() != null && entity.getMe().isAnswerOwn()) {
|
||||
holder.commentUserNameTv.setText(userInfo.getName() + "(作者)");
|
||||
} else {
|
||||
holder.commentUserNameTv.setText(userInfo.getName());
|
||||
}
|
||||
ImageUtils.Companion.display(holder.commentUserIconDv, userInfo.getIcon());
|
||||
} else {
|
||||
if (entity.getUserData() != null && entity.getUserData().isAnswerOwn()) {
|
||||
if (entity.getMe() != null && entity.getMe().isAnswerOwn()) {
|
||||
holder.commentUserNameTv.setText(entity.getUser().getName() + "(作者)");
|
||||
} else {
|
||||
holder.commentUserNameTv.setText(entity.getUser().getName());
|
||||
|
||||
@ -118,7 +118,7 @@ public class DataCollectionUtils {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("type", Build.MODEL);
|
||||
map.put("system", Build.VERSION.SDK_INT + "=" + Build.VERSION.RELEASE);
|
||||
map.put("install", PackageManager.getInstalledList());
|
||||
map.put("install", PackageManager.INSTANCE.getInstalledList());
|
||||
DataCollectionManager.upsert(context, "user", map);
|
||||
}
|
||||
|
||||
|
||||
@ -3,10 +3,14 @@ package com.gh.common.util;
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.config.CommonDebug;
|
||||
import com.lightgame.utils.Util_System_Phone_State;
|
||||
import com.tencent.bugly.crashreport.CrashReport;
|
||||
import com.tencent.stat.MtaSDkException;
|
||||
import com.tencent.stat.StatConfig;
|
||||
@ -64,8 +68,13 @@ public class DataUtils {
|
||||
StatConfig.setDebugEnable(false);
|
||||
|
||||
// 设置数据上报策略
|
||||
StatConfig.setStatSendStrategy(StatReportStrategy.PERIOD);
|
||||
StatConfig.setSendPeriodMinutes(5);
|
||||
// 测试渠道的时候即时上传,方便查看日志
|
||||
if ("GH_TEST".equals(HaloApp.getInstance().getChannel())) {
|
||||
StatConfig.setStatSendStrategy(StatReportStrategy.INSTANT);
|
||||
} else {
|
||||
StatConfig.setStatSendStrategy(StatReportStrategy.PERIOD);
|
||||
StatConfig.setSendPeriodMinutes(5);
|
||||
}
|
||||
|
||||
// 设置启用Tlink
|
||||
StatConfig.setTLinkStatus(true);
|
||||
@ -103,9 +112,9 @@ public class DataUtils {
|
||||
|
||||
// MTA ->【次数统计】Key-Value参数的事件
|
||||
public static void onMtaEvent(Context context, String eventId, String... kv) {
|
||||
if (CommonDebug.IS_DEBUG && (kv == null || kv.length % 2 != 0)) {
|
||||
throw new IllegalStateException("onEvent kv 必须不为空且数量为偶数");
|
||||
}
|
||||
// if (CommonDebug.IS_DEBUG && (kv == null || kv.length % 2 != 0)) {
|
||||
// throw new IllegalStateException("onEvent kv 必须不为空且数量为偶数");
|
||||
// }
|
||||
Properties prop = new Properties();
|
||||
for (int i = 0; i < kv.length; i++) {
|
||||
if (i % 2 != 0 || i != 0) {
|
||||
@ -157,20 +166,24 @@ public class DataUtils {
|
||||
// 游戏下载
|
||||
public static void onGameDownloadEvent(Context context, String gameName, String platform, String entrance, String status) {
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
|
||||
platform = PlatformUtils.getInstance(HaloApp.getInstance().getApplication()).getPlatformName(platform);
|
||||
|
||||
kv.put("版本", platform);
|
||||
kv.put("状态", status);
|
||||
kv.put("用户机型", Build.MODEL);
|
||||
kv.put("设备IMEI", Util_System_Phone_State.getDeviceId(HaloApp.getInstance().getApplication()));
|
||||
kv.put("网络状态", DeviceUtils.getNetwork(HaloApp.getInstance().getApplication()));
|
||||
kv.put("光环助手版本", BuildConfig.VERSION_NAME);
|
||||
onEvent(context, "游戏下载", gameName, kv);
|
||||
|
||||
Map<String, Object> kv2 = new HashMap<>();
|
||||
kv2.put("版本", platform);
|
||||
kv2.put("状态", status);
|
||||
kv2.put("位置", entrance);
|
||||
kv2.put("游戏分平台", gameName + "-" + platform);
|
||||
kv2.put("光环助手版本", BuildConfig.VERSION_NAME);
|
||||
onEvent(context, "游戏下载位置", gameName, kv2);
|
||||
|
||||
Map<String, Object> kv3 = new HashMap<>();
|
||||
kv3.put(entrance, "下载数");
|
||||
kv3.put(entrance, status);
|
||||
onEvent(context, "应用数据", gameName, kv3);
|
||||
}
|
||||
|
||||
// 游戏更新
|
||||
|
||||
@ -77,7 +77,7 @@ public class DetailDownloadUtils {
|
||||
case neterror:
|
||||
case waiting:
|
||||
viewHolder.mDownloadPb.setText(R.string.downloading);
|
||||
if (downloadEntity.isPluggable() && PackageManager.isInstalled(downloadEntity.getPackageName())) {
|
||||
if (downloadEntity.isPluggable() && PackageManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.DOWNLOADING_PLUGIN);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.DOWNLOADING_NORMAL);
|
||||
@ -86,7 +86,7 @@ public class DetailDownloadUtils {
|
||||
case done:
|
||||
viewHolder.mDownloadPb.setText(R.string.install);
|
||||
if (downloadEntity.isPluggable()
|
||||
&& PackageManager.isInstalled(downloadEntity.getPackageName())) {
|
||||
&& PackageManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_PLUGIN);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_NORMAL);
|
||||
|
||||
@ -8,6 +8,7 @@ import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.gh.gamecenter.kuaichuan.WifiMgr;
|
||||
import com.lightgame.utils.Util_System_Phone_State;
|
||||
@ -16,8 +17,10 @@ import com.tencent.stat.StatConfig;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.LineNumberReader;
|
||||
import java.io.Reader;
|
||||
@ -71,7 +74,7 @@ public class DeviceUtils {
|
||||
return object;
|
||||
}
|
||||
|
||||
private static String getMac(Context context) {
|
||||
public static String getMac(Context context) {
|
||||
String str = "";
|
||||
String macSerial = "";
|
||||
try {
|
||||
@ -80,7 +83,7 @@ public class DeviceUtils {
|
||||
InputStreamReader ir = new InputStreamReader(pp.getInputStream());
|
||||
LineNumberReader input = new LineNumberReader(ir);
|
||||
|
||||
for (; null != str; ) {
|
||||
while (null != str) {
|
||||
str = input.readLine();
|
||||
if (str != null) {
|
||||
macSerial = str.trim();// 去空格
|
||||
@ -196,4 +199,44 @@ public class DeviceUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// get sim
|
||||
public static String getSim(Context context) {
|
||||
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
String imsi = tm.getSubscriberId();
|
||||
if (imsi == null) {
|
||||
return "";
|
||||
}
|
||||
if (imsi.startsWith("46000") || imsi.startsWith("46002") || imsi.startsWith("46007")) {
|
||||
return "中国移动";
|
||||
}
|
||||
if (imsi.startsWith("46001")) {
|
||||
return "中国联通";
|
||||
}
|
||||
if (imsi.startsWith("46003")) {
|
||||
return "中国电信";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
// ping domain
|
||||
public static String ping(String domain) {
|
||||
try {
|
||||
Process process = Runtime.getRuntime().exec("ping -c 5 " + domain);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
|
||||
String line;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
builder.append("\n");
|
||||
}
|
||||
return builder.toString();
|
||||
} catch (IOException e) {
|
||||
return Log.getStackTraceString(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -381,7 +381,7 @@ public class DialogUtils {
|
||||
* @param cmListener 确认按钮监听
|
||||
* @param clListener 取消按钮监听
|
||||
*/
|
||||
public static void showAlertDialog(Context context, String title, CharSequence message
|
||||
public static Dialog showAlertDialog(Context context, String title, CharSequence message
|
||||
, String positive, String negative, final ConfirmListener cmListener, final CancelListener clListener) {
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
@ -420,7 +420,7 @@ public class DialogUtils {
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -687,21 +687,13 @@ public class DialogUtils {
|
||||
titleTv.setText(title);
|
||||
positiveTv.setText(positive);
|
||||
|
||||
negativeTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
negativeTv.setOnClickListener(view -> dialog.dismiss());
|
||||
|
||||
positiveTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
positiveTv.setOnClickListener(view -> {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
@ -3,6 +3,8 @@ package com.gh.common.util;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.halo.assistant.HaloApp;
|
||||
|
||||
public class DisplayUtils {
|
||||
|
||||
/**
|
||||
@ -21,6 +23,15 @@ public class DisplayUtils {
|
||||
return (int) (pxValue / scale + 0.5f);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据手机的分辨率从 dip(像素) 的单位 转成为 px
|
||||
*/
|
||||
public static int dip2px(float dpValue) {
|
||||
final float scale = HaloApp.getInstance().getApplication().getResources().getDisplayMetrics().density;
|
||||
return (int) (dpValue * scale + 0.5f);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将px值转换为sp值,保证文字大小不变
|
||||
*
|
||||
|
||||
@ -3,6 +3,7 @@ package com.gh.common.util;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Message;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@ -11,6 +12,8 @@ import android.view.View;
|
||||
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.view.DownloadDialog;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.DownloadManagerActivity;
|
||||
@ -151,8 +154,8 @@ public class DownloadItemUtils {
|
||||
if (gameEntity.isPluggable()) {
|
||||
holder.gameDownloadBtn.setText(R.string.pluggable);
|
||||
setwhat(context, holder, apkEntity, packageName);
|
||||
} else if (PackageManager.isInstalled(packageName)) {
|
||||
if (PackageManager.isCanUpdate(gameEntity.getId(), packageName)) {
|
||||
} else if (PackageManager.INSTANCE.isInstalled(packageName)) {
|
||||
if (PackageManager.INSTANCE.isCanUpdate(gameEntity.getId(), packageName)) {
|
||||
holder.gameDownloadBtn.setText(R.string.update);
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
|
||||
} else {
|
||||
@ -165,7 +168,7 @@ public class DownloadItemUtils {
|
||||
} else if (gh_id == null || gh_id.equals(gameEntity.getId())) {
|
||||
holder.gameDownloadBtn.setText(R.string.launch);
|
||||
holder.gameDownloadBtn.setTextColor(ContextCompat.getColor(context, R.color.theme));
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.detail_downloading_normal_style);
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.detail_download_open_style);
|
||||
} else {
|
||||
holder.gameDownloadBtn.setText(R.string.download);
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
|
||||
@ -298,7 +301,7 @@ public class DownloadItemUtils {
|
||||
holder.gameDownloadBtn.setText("安装");
|
||||
holder.gameDownloadBtn.setTextColor(Color.WHITE);
|
||||
if (downloadEntity.isPluggable()
|
||||
&& PackageManager.isInstalled(downloadEntity.getPackageName())) {
|
||||
&& PackageManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
|
||||
} else {
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
|
||||
@ -315,20 +318,22 @@ public class DownloadItemUtils {
|
||||
final String entrance,
|
||||
final String location) {
|
||||
|
||||
setOnClickListener(context, downloadBtn, gameEntity, position, adapter, entrance, location, null);
|
||||
}
|
||||
|
||||
public static void setOnClickListener(final Context context,
|
||||
final TextView downloadBtn,
|
||||
final GameEntity gameEntity,
|
||||
final int position,
|
||||
final RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter,
|
||||
final String entrance,
|
||||
final String location,
|
||||
final ExposureEvent traceEvent) {
|
||||
|
||||
if (gameEntity.getApk().size() == 1) {
|
||||
downloadBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onNormalClick(context, downloadBtn, gameEntity, position, adapter, entrance, location);
|
||||
}
|
||||
});
|
||||
downloadBtn.setOnClickListener(v -> onNormalClick(context, downloadBtn, gameEntity, position, adapter, entrance, location, traceEvent));
|
||||
} else {
|
||||
downloadBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
DownloadDialog.getInstance(context).showPopupWindow(v, gameEntity, entrance, location);
|
||||
}
|
||||
});
|
||||
downloadBtn.setOnClickListener(v -> DownloadDialog.getInstance(context).showPopupWindow(v, gameEntity, entrance, location, traceEvent));
|
||||
}
|
||||
|
||||
}
|
||||
@ -340,37 +345,44 @@ public class DownloadItemUtils {
|
||||
final RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter,
|
||||
final String entrance,
|
||||
final String location) {
|
||||
onNormalClick(context, downloadBtn, gameEntity, position, adapter, entrance, location, null);
|
||||
}
|
||||
|
||||
public static void onNormalClick(final Context context,
|
||||
final TextView downloadBtn,
|
||||
final GameEntity gameEntity,
|
||||
final int position,
|
||||
final RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter,
|
||||
final String entrance,
|
||||
final String location,
|
||||
@Nullable final ExposureEvent traceEvent) {
|
||||
|
||||
String str = downloadBtn.getText().toString();
|
||||
switch (str) {
|
||||
case "下载":
|
||||
if (NetworkUtils.isWifiConnected(context)) {
|
||||
download(context, gameEntity, downloadBtn, entrance, location);
|
||||
download(context, gameEntity, downloadBtn, entrance, location, traceEvent);
|
||||
} else {
|
||||
DialogUtils.showDownloadDialog(context, new DialogUtils.ConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
download(context, gameEntity, downloadBtn, entrance, location);
|
||||
}
|
||||
});
|
||||
DialogUtils.showDownloadDialog(context, () -> download(context, gameEntity, downloadBtn, entrance, location, traceEvent));
|
||||
}
|
||||
break;
|
||||
case "插件化":
|
||||
if (entrance.contains("我的游戏")) {
|
||||
DataUtils.onMtaEvent(context, "我的游戏_启动", "插件化", gameEntity.getName());
|
||||
}
|
||||
if (NetworkUtils.isWifiConnected(context)) {
|
||||
plugin(context, gameEntity, downloadBtn, entrance, location);
|
||||
plugin(context, gameEntity, downloadBtn, entrance, location, traceEvent);
|
||||
} else {
|
||||
DialogUtils.showDownloadDialog(context, new DialogUtils.ConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
plugin(context, gameEntity, downloadBtn, entrance, location);
|
||||
}
|
||||
});
|
||||
DialogUtils.showDownloadDialog(context, () -> plugin(context, gameEntity, downloadBtn, entrance, location, traceEvent));
|
||||
}
|
||||
break;
|
||||
case "安装":
|
||||
install(context, gameEntity, position, adapter);
|
||||
break;
|
||||
case "启动":
|
||||
if (entrance.contains("我的游戏")) {
|
||||
DataUtils.onMtaEvent(context, "我的游戏_启动", "启动", gameEntity.getName());
|
||||
}
|
||||
DataUtils.onGameLaunchEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), location);
|
||||
|
||||
PackageUtils.launchApplicationByPackageName(context, gameEntity.getApk().get(0).getPackageName());
|
||||
@ -380,15 +392,13 @@ public class DownloadItemUtils {
|
||||
DownloadManagerActivity.getDownloadMangerIntent(context, gameEntity.getApk().get(0).getUrl(), entrance + "+(" + location.split(":")[0] + ")"));
|
||||
break;
|
||||
case "更新":
|
||||
if (entrance.contains("我的游戏")) {
|
||||
DataUtils.onMtaEvent(context, "我的游戏_启动", "更新", gameEntity.getName());
|
||||
}
|
||||
if (NetworkUtils.isWifiConnected(context)) {
|
||||
update(context, gameEntity, entrance, location);
|
||||
update(context, gameEntity, entrance, location, traceEvent);
|
||||
} else {
|
||||
DialogUtils.showDownloadDialog(context, new DialogUtils.ConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
update(context, gameEntity, entrance, location);
|
||||
}
|
||||
});
|
||||
DialogUtils.showDownloadDialog(context, () -> update(context, gameEntity, entrance, location, traceEvent));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -399,12 +409,15 @@ public class DownloadItemUtils {
|
||||
GameEntity gameEntity,
|
||||
TextView downloadBtn,
|
||||
String entrance,
|
||||
String location) {
|
||||
String location,
|
||||
@Nullable ExposureEvent traceEvent) {
|
||||
String msg = FileUtils.isCanDownload(context, gameEntity.getApk().get(0).getSize());
|
||||
if (TextUtils.isEmpty(msg)) {
|
||||
DataUtils.onGameDownloadEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), entrance, "下载开始");
|
||||
|
||||
DownloadManager.createDownload(context, gameEntity, context.getString(R.string.download), entrance, location);
|
||||
ExposureEvent downloadExposureEvent = ExposureUtils.INSTANCE.logADownloadExposureEvent(gameEntity, gameEntity.getApk().get(0).getPlatform(), traceEvent, ExposureUtils.DownloadType.DOWNLOAD);
|
||||
|
||||
DownloadManager.createDownload(context, gameEntity, context.getString(R.string.download), entrance, location, downloadExposureEvent);
|
||||
Utils.toast(context, gameEntity.getName() + "已加入下载队列");
|
||||
|
||||
downloadBtn.setText(R.string.downloading);
|
||||
@ -419,12 +432,14 @@ public class DownloadItemUtils {
|
||||
|
||||
//插件化
|
||||
private static void plugin(Context context, GameEntity gameEntity, TextView downloadBtn, String entrance,
|
||||
String location) {
|
||||
String location, @Nullable ExposureEvent traceEvent) {
|
||||
String msg = FileUtils.isCanDownload(context, gameEntity.getApk().get(0).getSize());
|
||||
if (TextUtils.isEmpty(msg)) {
|
||||
DataUtils.onGameDownloadEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), entrance, "下载开始");
|
||||
|
||||
DownloadManager.createDownload(context, gameEntity, "插件化", entrance, location);
|
||||
ExposureEvent downloadExposureEvent = ExposureUtils.INSTANCE.logADownloadExposureEvent(gameEntity, gameEntity.getApk().get(0).getPlatform(), traceEvent, ExposureUtils.DownloadType.PLUGIN_DOWNLOAD);
|
||||
|
||||
DownloadManager.createDownload(context, gameEntity, "插件化", entrance, location, downloadExposureEvent);
|
||||
Utils.toast(context, gameEntity.getName() + "已加入下载队列");
|
||||
|
||||
downloadBtn.setText(R.string.downloading);
|
||||
@ -458,9 +473,10 @@ public class DownloadItemUtils {
|
||||
}
|
||||
|
||||
//更新
|
||||
private static void update(Context context, GameEntity gameEntity, String entrance, String location) {
|
||||
private static void update(Context context, GameEntity gameEntity, String entrance, String location, @Nullable ExposureEvent traceEvent) {
|
||||
DataUtils.onGameUpdateEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), "下载开始");
|
||||
DownloadManager.createDownload(context, gameEntity, "更新", entrance, location);
|
||||
ExposureEvent downloadExposureEvent = ExposureUtils.INSTANCE.logADownloadExposureEvent(gameEntity, gameEntity.getApk().get(0).getPlatform(), traceEvent, ExposureUtils.DownloadType.UPDATE);
|
||||
DownloadManager.createDownload(context, gameEntity, "更新", entrance, location, downloadExposureEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -73,6 +73,16 @@ public class EntranceUtils {
|
||||
public static final String KEY_VERSION_UPDATE = "versionUpdate";
|
||||
public static final String KEY_CHECK_QUESTION_CONCERN = "check_question_concern";
|
||||
public static final String KEY_DRAFT_ID = "draft_id";
|
||||
public static final String KEY_KAIFU_LIST = "kaifuList";
|
||||
public static final String KEY_CATEGORY_ID = "category_id";
|
||||
public static final String KEY_CATEGORY_TITLE = "category_title";
|
||||
public static final String KEY_CATEGORY_INIT_TITLE = "category_init_title";
|
||||
public static final String KEY_BLOCK_DATA = "blockData";
|
||||
public static final String KEY_ASK_TAG = "askTag";
|
||||
public static final String KEY_ASK_COLUMN_TAG = "askColumnTag";
|
||||
public static final String KEY_COMMUNITY_DATA = "communityData";
|
||||
public static final String KEY_TRACE_EVENT = "trace_event";
|
||||
public static final String KEY_SUBJECT_DATA = "subjectData";
|
||||
|
||||
public static void jumpActivity(Context context, Bundle bundle) {
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import android.widget.TextView;
|
||||
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.manager.PackageManager;
|
||||
@ -70,6 +71,15 @@ public class GameUtils {
|
||||
DownloadEntity downloadEntity;
|
||||
Object gh_id;
|
||||
for (ApkEntity apkEntity : gameEntity.getApk()) {
|
||||
|
||||
// 去除下载合集判断
|
||||
boolean isCollection = false;
|
||||
for (GameCollectionEntity collectionEntity : gameEntity.getCollection()) {
|
||||
if (collectionEntity.getPackage().contains(apkEntity.getPackageName()))
|
||||
isCollection = true;
|
||||
}
|
||||
if (isCollection) continue;
|
||||
|
||||
downloadEntity = DownloadManager.getInstance(context).getDownloadEntityByUrl(apkEntity.getUrl());
|
||||
if (downloadEntity != null) {
|
||||
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
|
||||
@ -80,10 +90,10 @@ public class GameUtils {
|
||||
updateCount++;
|
||||
}
|
||||
}
|
||||
if (PackageManager.isCanUpdate(gameEntity.getId(), apkEntity.getPackageName())) {
|
||||
if (PackageManager.INSTANCE.isCanUpdate(gameEntity.getId(), apkEntity.getPackageName())) {
|
||||
updateCount++;
|
||||
}
|
||||
if (PackageManager.isInstalled(apkEntity.getPackageName())) {
|
||||
if (PackageManager.INSTANCE.isInstalled(apkEntity.getPackageName())) {
|
||||
gh_id = PackageUtils.getMetaData(context, apkEntity.getPackageName(), "gh_id");
|
||||
if (gameEntity.getTag() != null && gameEntity.getTag().size() != 0
|
||||
&& !TextUtils.isEmpty(apkEntity.getGhVersion())
|
||||
|
||||
@ -12,6 +12,7 @@ import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.entity.TagStyleEntity;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -30,17 +31,17 @@ import java.util.TimeZone;
|
||||
*/
|
||||
public class GameViewUtils {
|
||||
|
||||
public static void setLabelList(Context context, LinearLayout labelLayout, List<String> tag, String tagType) {
|
||||
public static void setLabelList(Context context, LinearLayout labelLayout, List<String> tag, String tagType, List<TagStyleEntity> tagStyle) {
|
||||
labelLayout.removeAllViews();
|
||||
if (tag == null || tag.isEmpty()) {
|
||||
labelLayout.addView(getGameTagView(context, "官方版", 0, tagType));
|
||||
labelLayout.addView(getGameTagView(context, "官方版", 0, tagType, null));
|
||||
} else {
|
||||
for (int i = 0, size = tag.size(); i < size; i++) {
|
||||
View view;
|
||||
if (i == size - 1) {
|
||||
view = getGameTagView(context, tag.get(i), 0, tagType);
|
||||
view = getGameTagView(context, tag.get(i), 0, tagType, tagStyle.size() > i ? tagStyle.get(i) : null);
|
||||
} else {
|
||||
view = getGameTagView(context, tag.get(i), DisplayUtils.dip2px(context, 6), tagType);
|
||||
view = getGameTagView(context, tag.get(i), DisplayUtils.dip2px(context, 6), tagType, tagStyle.size() > i ? tagStyle.get(i) : null);
|
||||
}
|
||||
if (view != null) {
|
||||
labelLayout.addView(view);
|
||||
@ -52,7 +53,7 @@ public class GameViewUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static TextView getGameTagView(Context context, String tagStr, int rightMargin, String tagType) {
|
||||
private static TextView getGameTagView(Context context, String tagStr, int rightMargin, String tagType, TagStyleEntity tagEntity) {
|
||||
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
lparams.rightMargin = rightMargin;
|
||||
@ -65,22 +66,33 @@ public class GameViewUtils {
|
||||
tag.setTextColor(ContextCompat.getColor(context, R.color.tag_green));
|
||||
} else {
|
||||
String colorStr;
|
||||
if (!TextUtils.isEmpty(tagType) && "type".equals(tagType)) { // 游戏标签
|
||||
colorStr = "#ff6a28";
|
||||
|
||||
if (!TextUtils.isEmpty(tagType) && "type".equals(tagType) && tagEntity != null) { // 游戏标签
|
||||
colorStr = "#" + tagEntity.getColor();
|
||||
GradientDrawable gradientDrawable = new GradientDrawable();
|
||||
|
||||
if ("border".equals(tagEntity.getStyle())) {
|
||||
gradientDrawable.setColor(Color.TRANSPARENT);
|
||||
gradientDrawable.setStroke(DisplayUtils.dip2px(context, 0.6f), Color.parseColor(colorStr));
|
||||
tag.setTextColor(Color.parseColor(colorStr));
|
||||
} else {
|
||||
gradientDrawable.setColor(Color.parseColor(colorStr));
|
||||
gradientDrawable.setShape(GradientDrawable.RECTANGLE);
|
||||
tag.setTextColor(Color.WHITE);
|
||||
}
|
||||
tag.setBackgroundDrawable(gradientDrawable);
|
||||
} else {
|
||||
colorStr = TagUtils.getInstance(context).getColor(tagStr);
|
||||
if (colorStr == null) {
|
||||
return null;
|
||||
}
|
||||
int color = Color.parseColor(colorStr);
|
||||
GradientDrawable gradientDrawable = new GradientDrawable();
|
||||
gradientDrawable.setColor(Color.TRANSPARENT);
|
||||
gradientDrawable.setStroke(DisplayUtils.dip2px(context, 0.6f), color);
|
||||
tag.setBackgroundDrawable(gradientDrawable);
|
||||
tag.setTextColor(color);
|
||||
}
|
||||
|
||||
if (colorStr == null) {
|
||||
return null;
|
||||
}
|
||||
int color = Color.parseColor(colorStr);
|
||||
GradientDrawable gradientDrawable = new GradientDrawable();
|
||||
gradientDrawable.setColor(Color.TRANSPARENT);
|
||||
gradientDrawable.setStroke(DisplayUtils.dip2px(context, 0.6f), color);
|
||||
tag.setBackgroundDrawable(gradientDrawable);
|
||||
// tag.setBackgroundResource(R.drawable.border_blue_bg);
|
||||
tag.setTextColor(color);
|
||||
}
|
||||
tag.setLayoutParams(lparams);
|
||||
tag.setPadding(DisplayUtils.dip2px(context, 3),
|
||||
|
||||
@ -7,7 +7,7 @@ import android.widget.Toast;
|
||||
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.login.LoginTag;
|
||||
import com.gh.gamecenter.user.LoginTag;
|
||||
import com.lightgame.utils.RuntimeUtils;
|
||||
import com.lightgame.utils.Utils;
|
||||
import com.sina.weibo.sdk.WbSdk;
|
||||
|
||||
@ -30,6 +30,7 @@ import org.json.JSONObject
|
||||
import retrofit2.HttpException
|
||||
import rx.Observable
|
||||
import rx.Observer
|
||||
import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
||||
import java.io.File
|
||||
@ -37,6 +38,14 @@ import java.net.HttpURLConnection
|
||||
|
||||
class ImageUtils private constructor() {
|
||||
|
||||
|
||||
fun display(simpleDraweeView: SimpleDraweeView?, url: String?, listener: BaseControllerListener<ImageInfo>) {
|
||||
simpleDraweeView?.controller = Fresco.newDraweeControllerBuilder()
|
||||
.setUri(url)
|
||||
.setControllerListener(listener)
|
||||
.build()
|
||||
}
|
||||
|
||||
// 自适应图片宽高
|
||||
fun display(simpleDraweeView: SimpleDraweeView?, url: String?, width: Int) {
|
||||
val listener = object : BaseControllerListener<ImageInfo>() {
|
||||
@ -64,7 +73,7 @@ class ImageUtils private constructor() {
|
||||
return
|
||||
}
|
||||
val layoutParams = simpleDraweeView?.layoutParams
|
||||
val scale = imageInfo.width.toFloat()/imageInfo.height.toFloat()
|
||||
val scale = imageInfo.width.toFloat() / imageInfo.height.toFloat()
|
||||
layoutParams?.width = (height * scale).toInt()
|
||||
simpleDraweeView?.layoutParams = layoutParams
|
||||
}
|
||||
@ -154,7 +163,7 @@ class ImageUtils private constructor() {
|
||||
var index = 0
|
||||
for (s in imgArr) {
|
||||
path = context.getCacheDir().path + File.separator + System.currentTimeMillis() + index + ".jpg"
|
||||
if (BitmapUtils.savePicture(path, s, 200000)) {
|
||||
if (BitmapUtils.savePicture(path, s, 1024 * 1024)) {
|
||||
subscriber.onNext(FileUtils.uploadFile(Config.API_HOST + "images?type=community", path, s, UserManager.getInstance().token))
|
||||
index++
|
||||
} else {
|
||||
@ -192,11 +201,11 @@ class ImageUtils private constructor() {
|
||||
})
|
||||
}
|
||||
|
||||
fun postImage(context: Context?, picturePath: String?, listener: OnPostImageListener) {
|
||||
if (context == null || TextUtils.isEmpty(picturePath)) return
|
||||
Observable.create(Observable.OnSubscribe<JSONObject> { subscriber ->
|
||||
fun postImage(context: Context?, picturePath: String?, listener: OnPostImageListener): Subscription? {
|
||||
if (context == null || TextUtils.isEmpty(picturePath)) return null
|
||||
return Observable.create(Observable.OnSubscribe<JSONObject> { subscriber ->
|
||||
val path = context.getCacheDir().path + File.separator + System.currentTimeMillis() + ".jpg"
|
||||
if (BitmapUtils.savePicture(path, picturePath, 200000)) {
|
||||
if (BitmapUtils.savePicture(path, picturePath, 1024 * 1024)) {
|
||||
subscriber.onNext(FileUtils.uploadFile(Config.API_HOST + "images?type=community", path, UserManager.getInstance().token))
|
||||
} else {
|
||||
subscriber.onNext(FileUtils.uploadFile(Config.API_HOST + "images?type=community", picturePath, UserManager.getInstance().token))
|
||||
@ -211,7 +220,7 @@ class ImageUtils private constructor() {
|
||||
listener.postSuccess(response)
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException) {
|
||||
override fun onFailure(e: HttpException?) {
|
||||
listener.postError()
|
||||
}
|
||||
})
|
||||
|
||||
@ -6,6 +6,9 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.gh.gamecenter.category.CategoryListActivity;
|
||||
import com.gh.gamecenter.entity.CategoryEntity;
|
||||
|
||||
/**
|
||||
* @author CsHeng
|
||||
* @Date 17/05/2017
|
||||
@ -53,4 +56,9 @@ public class IntentUtils {
|
||||
"http://www.ghzs.com/link?source=appshare333");
|
||||
return data;
|
||||
}
|
||||
|
||||
public static void startCategoryListActivity(Context context, String categoryTitle, CategoryEntity category) {
|
||||
DataUtils.onMtaEvent(context, "分类大全", categoryTitle, category.getName());
|
||||
context.startActivity(CategoryListActivity.Companion.getIntent(context, categoryTitle, category, "全部"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,20 +11,22 @@ import com.gh.gamecenter.R;
|
||||
public class KaiFuUtils {
|
||||
|
||||
public static void setKaiFuType(TextView textView, String type) {
|
||||
if (type == null) return;
|
||||
textView.setText(type);
|
||||
switch (type) {
|
||||
case "不删档内测":
|
||||
textView.setBackgroundColor(ContextCompat.getColor(textView.getContext(), R.color.content));
|
||||
break;
|
||||
case "删档内测":
|
||||
textView.setBackgroundColor(ContextCompat.getColor(textView.getContext(), R.color.content));
|
||||
break;
|
||||
case "公测":
|
||||
textView.setBackgroundColor(ContextCompat.getColor(textView.getContext(), R.color.tag_yellow));
|
||||
break;
|
||||
default:
|
||||
textView.setBackgroundColor(ContextCompat.getColor(textView.getContext(), R.color.tag_yellow));
|
||||
break;
|
||||
}
|
||||
textView.setBackgroundColor(ContextCompat.getColor(textView.getContext(), R.color.tag_yellow));
|
||||
// switch (type) {
|
||||
// case "不删档内测":
|
||||
// textView.setBackgroundColor(ContextCompat.getColor(textView.getContext(), R.color.content));
|
||||
// break;
|
||||
// case "删档内测":
|
||||
// textView.setBackgroundColor(ContextCompat.getColor(textView.getContext(), R.color.content));
|
||||
// break;
|
||||
// case "公测":
|
||||
// textView.setBackgroundColor(ContextCompat.getColor(textView.getContext(), R.color.tag_yellow));
|
||||
// break;
|
||||
// default:
|
||||
// textView.setBackgroundColor(ContextCompat.getColor(textView.getContext(), R.color.tag_yellow));
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.LibaoDetailAdapter;
|
||||
import com.gh.gamecenter.entity.LibaoEntity;
|
||||
import com.gh.gamecenter.entity.LibaoStatusEntity;
|
||||
import com.gh.gamecenter.entity.UserDataEntity;
|
||||
import com.gh.gamecenter.entity.MeEntity;
|
||||
import com.gh.gamecenter.entity.UserDataLibaoEntity;
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.eventbus.EBUISwitch;
|
||||
@ -586,7 +586,7 @@ public class LibaoUtils {
|
||||
libaoEntity.setBeforeStatus(libaoStatusEntity.getStatus());
|
||||
libaoStatusEntity.setBeforeStatus(libaoStatusEntity.getStatus());
|
||||
|
||||
UserDataEntity userData = libaoEntity.getUserData();
|
||||
MeEntity userData = libaoEntity.getMe();
|
||||
if (userData != null && userData.getUserDataLibaoList() != null && userData.getUserDataLibaoList().size() > 0) {
|
||||
List<UserDataLibaoEntity> userDataLibaoList = userData.getUserDataLibaoList();
|
||||
UserDataLibaoEntity userDataLibaoEntity = userDataLibaoList.get(userDataLibaoList.size() - 1);
|
||||
@ -611,7 +611,7 @@ public class LibaoUtils {
|
||||
libaoEntity.setBeforeStatus(libaoStatusEntity.getStatus());
|
||||
libaoStatusEntity.setBeforeStatus(libaoStatusEntity.getStatus());
|
||||
|
||||
UserDataEntity userData = libaoEntity.getUserData();
|
||||
MeEntity userData = libaoEntity.getMe();
|
||||
if (userData != null && userData.getUserDataLibaoList() != null && userData.getUserDataLibaoList().size() > 0) {
|
||||
List<UserDataLibaoEntity> userDataLibaoList = userData.getUserDataLibaoList();
|
||||
UserDataLibaoEntity userDataLibaoEntity = userDataLibaoList.get(userDataLibaoList.size() - 1);
|
||||
|
||||
@ -81,7 +81,7 @@ public class LoginUtils {
|
||||
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"), content.toString());
|
||||
RetrofitManager.getInstance(context)
|
||||
.getUsersea()
|
||||
.getApi()
|
||||
.loginByCaptcha(body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -127,7 +127,7 @@ public class LoginUtils {
|
||||
public static void logout(final Context context, final OnLogoutListener listener) {
|
||||
|
||||
RetrofitManager.getInstance(context)
|
||||
.getUsersea()
|
||||
.getApi()
|
||||
.logout()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -321,7 +321,7 @@ public class LoginUtils {
|
||||
case 400801:
|
||||
Utils.toast(context, "访问过于频繁");
|
||||
break;
|
||||
case 403001:
|
||||
case 403007:
|
||||
Utils.toast(context, "设备异常,获取验证码失败,请更换登陆方式或明天再试");
|
||||
break;
|
||||
case 403202:
|
||||
|
||||
@ -81,7 +81,7 @@ public class MessageShareUtils {
|
||||
|
||||
@Override
|
||||
public void onError(UiError uiError) {
|
||||
Utils.toast(mContext, "分享失败");
|
||||
Utils.toast(mContext, "分享失败!请检查是否已安装QQ");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -7,6 +7,7 @@ import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.Signature;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
@ -147,7 +148,7 @@ public class PackageUtils {
|
||||
if (TextUtils.isEmpty(packageName)) {
|
||||
return true;
|
||||
}
|
||||
boolean isContain = com.gh.gamecenter.manager.PackageManager.isInstalled(packageName);
|
||||
boolean isContain = com.gh.gamecenter.manager.PackageManager.INSTANCE.isInstalled(packageName);
|
||||
if (!isContain) {
|
||||
return true;
|
||||
}
|
||||
@ -273,6 +274,20 @@ public class PackageUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 获取apk的版本
|
||||
*/
|
||||
public static Drawable getIconByPackage(Context context, String packageName) {
|
||||
try {
|
||||
PackageManager packageManager = context.getApplicationContext().getPackageManager();
|
||||
return packageManager.getApplicationIcon(packageName);
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取所有已安装的软件的包名、版本(非系统应用)
|
||||
*/
|
||||
|
||||
@ -457,7 +457,7 @@ public class ShareUtils {
|
||||
Intent sendIntent = IntentUtils.getSMSIntent(smsBody);
|
||||
mContext.startActivity(sendIntent);
|
||||
} catch (Exception e) {
|
||||
Utils.toast(mContext, "系统异常,分享失败");
|
||||
Utils.toast(mContext, "设备短信服务异常,分享失败");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@ -520,8 +520,13 @@ public class ShareUtils {
|
||||
} else if (mShareType != ShareType.shareGh) {
|
||||
copyLink(shareUrl);
|
||||
} else {
|
||||
Intent data = IntentUtils.getEmailToGHIntent();
|
||||
mContext.startActivity(data);
|
||||
try {
|
||||
Intent data = IntentUtils.getEmailToGHIntent();
|
||||
mContext.startActivity(data);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Utils.toast(mContext, "设备邮件服务异常,分享失败");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
|
||||
@ -4,6 +4,7 @@ import android.support.v4.util.ArrayMap;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.common.constant.Constants;
|
||||
import com.halo.assistant.HaloApp;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -41,39 +42,40 @@ public class TimestampUtils {
|
||||
*/
|
||||
public static String addTimestamp(String url) {
|
||||
|
||||
// // TODO: 22/12/17 刷新版
|
||||
// if (TextUtils.isEmpty(url)) {
|
||||
// return url;
|
||||
// }
|
||||
// if (url.contains("?")) {
|
||||
// String u = url + "×tamp=" + System.currentTimeMillis();
|
||||
// return u;
|
||||
// } else {
|
||||
// String u = url + "?timestamp=" + System.currentTimeMillis();
|
||||
// return u;
|
||||
// }
|
||||
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return url;
|
||||
}
|
||||
int cd = 0;
|
||||
for (String key : getCdMap().keySet()) {
|
||||
if (Pattern.matches(key, url)) {
|
||||
cd = getCdMap().get(key);
|
||||
break;
|
||||
if ("GH_REFRESH".equals(HaloApp.getInstance().getChannel())) {
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return url;
|
||||
}
|
||||
if (url.contains("?")) {
|
||||
String u = url + "×tamp=" + System.currentTimeMillis();
|
||||
return u;
|
||||
} else {
|
||||
String u = url + "?timestamp=" + System.currentTimeMillis();
|
||||
return u;
|
||||
}
|
||||
}
|
||||
if (cd == 0) {
|
||||
return url;
|
||||
}
|
||||
if (url.contains("?")) {
|
||||
String u = url + "×tamp=" + getTimestamp(url, cd);
|
||||
// Utils.log("url = " + u);
|
||||
return u;
|
||||
} else {
|
||||
String u = url + "?timestamp=" + getTimestamp(url, cd);
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return url;
|
||||
}
|
||||
int cd = 0;
|
||||
for (String key : getCdMap().keySet()) {
|
||||
if (Pattern.matches(key, url)) {
|
||||
cd = getCdMap().get(key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cd == 0) {
|
||||
return url;
|
||||
}
|
||||
if (url.contains("?")) {
|
||||
String u = url + "×tamp=" + getTimestamp(url, cd);
|
||||
// Utils.log("url = " + u);
|
||||
return u;
|
||||
return u;
|
||||
} else {
|
||||
String u = url + "?timestamp=" + getTimestamp(url, cd);
|
||||
// Utils.log("url = " + u);
|
||||
return u;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,295 @@
|
||||
package com.gh.common.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Animatable;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.scwang.smartrefresh.layout.api.RefreshInternal;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshKernel;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.constant.SpinnerStyle;
|
||||
import com.scwang.smartrefresh.layout.internal.ArrowDrawable;
|
||||
import com.scwang.smartrefresh.layout.internal.InternalAbstract;
|
||||
import com.scwang.smartrefresh.layout.internal.ProgressDrawable;
|
||||
import com.scwang.smartrefresh.layout.util.DensityUtil;
|
||||
|
||||
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
import static com.scwang.smartrefresh.layout.util.SmartUtil.getColor;
|
||||
|
||||
public abstract class AbstractSwipeRefreshHeader<T extends AbstractSwipeRefreshHeader> extends InternalAbstract implements RefreshInternal {
|
||||
public static final byte ID_TEXT_TITLE = 1;
|
||||
public static final byte ID_IMAGE_ARROW = 2;
|
||||
public static final byte ID_IMAGE_PROGRESS = 3;
|
||||
|
||||
protected TextView mTitleText;
|
||||
protected ImageView mArrowView;
|
||||
protected ImageView mProgressView;
|
||||
protected LinearLayout mCenterLayout;
|
||||
protected RefreshKernel mRefreshKernel;
|
||||
protected ArrowDrawable mArrowDrawable;
|
||||
protected ProgressDrawable mProgressDrawable;
|
||||
protected Integer mAccentColor;
|
||||
protected Integer mPrimaryColor;
|
||||
protected int mBackgroundColor;
|
||||
protected int mFinishDuration = 500;
|
||||
|
||||
private DensityUtil mDensityUtil = new DensityUtil();
|
||||
|
||||
public AbstractSwipeRefreshHeader(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
|
||||
mSpinnerStyle = SpinnerStyle.Translate;
|
||||
mArrowView = new ImageView(context);
|
||||
mProgressView = new ImageView(context);
|
||||
mTitleText = new TextView(context);
|
||||
mTitleText.setTextColor(0xff5d5d5d);
|
||||
mCenterLayout = new LinearLayout(context);
|
||||
mCenterLayout.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
mCenterLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
|
||||
final View thisView = this;
|
||||
final ViewGroup thisGroup = this;
|
||||
final View arrowView = mArrowView;
|
||||
final View titleView = mTitleText;
|
||||
final View progressView = mProgressView;
|
||||
final ViewGroup centerLayout = mCenterLayout;
|
||||
|
||||
titleView.setId(ID_TEXT_TITLE);
|
||||
arrowView.setId(ID_IMAGE_ARROW);
|
||||
progressView.setId(ID_IMAGE_PROGRESS);
|
||||
centerLayout.setId(android.R.id.widget_frame);
|
||||
|
||||
LinearLayout.LayoutParams lpHeaderText = new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
|
||||
centerLayout.addView(titleView, lpHeaderText);
|
||||
|
||||
RelativeLayout.LayoutParams lpHeaderLayout = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
|
||||
lpHeaderLayout.addRule(CENTER_IN_PARENT);
|
||||
thisGroup.addView(centerLayout, lpHeaderLayout);
|
||||
|
||||
RelativeLayout.LayoutParams lpArrow = new RelativeLayout.LayoutParams(mDensityUtil.dip2px(15), mDensityUtil.dip2px(15));
|
||||
lpArrow.addRule(CENTER_VERTICAL);
|
||||
lpArrow.addRule(LEFT_OF, android.R.id.widget_frame);
|
||||
thisGroup.addView(arrowView, lpArrow);
|
||||
|
||||
RelativeLayout.LayoutParams lpProgress = new RelativeLayout.LayoutParams((ViewGroup.LayoutParams) lpArrow);
|
||||
lpProgress.addRule(CENTER_VERTICAL);
|
||||
lpProgress.addRule(LEFT_OF, android.R.id.widget_frame);
|
||||
progressView.animate().setInterpolator(new LinearInterpolator());
|
||||
thisGroup.addView(progressView, lpProgress);
|
||||
|
||||
if (thisView.isInEditMode()) {
|
||||
arrowView.setVisibility(GONE);
|
||||
} else {
|
||||
progressView.setVisibility(GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
final View arrowView = mArrowView;
|
||||
final View progressView = mProgressView;
|
||||
arrowView.animate().cancel();
|
||||
progressView.animate().cancel();
|
||||
}
|
||||
final Drawable drawable = mProgressView.getDrawable();
|
||||
if (drawable instanceof Animatable) {
|
||||
if (((Animatable) drawable).isRunning()) {
|
||||
((Animatable) drawable).stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected T self() {
|
||||
//noinspection unchecked
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitialized(@NonNull RefreshKernel kernel, int height, int maxDragHeight) {
|
||||
mRefreshKernel = kernel;
|
||||
mRefreshKernel.requestDrawBackgroundFor(this, mBackgroundColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartAnimator(@NonNull RefreshLayout refreshLayout, int height, int maxDragHeight) {
|
||||
if (mProgressView.getVisibility() != VISIBLE) {
|
||||
mProgressView.setVisibility(VISIBLE);
|
||||
Drawable drawable = mProgressView.getDrawable();
|
||||
if (drawable instanceof Animatable) {
|
||||
((Animatable) drawable).start();
|
||||
} else {
|
||||
mProgressView.animate().rotation(36000).setDuration(100000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReleased(@NonNull RefreshLayout refreshLayout, int height, int maxDragHeight) {
|
||||
onStartAnimator(refreshLayout, height, maxDragHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onFinish(@NonNull RefreshLayout refreshLayout, boolean success) {
|
||||
Drawable drawable = mProgressView.getDrawable();
|
||||
if (drawable instanceof Animatable) {
|
||||
if (((Animatable) drawable).isRunning()) {
|
||||
((Animatable) drawable).stop();
|
||||
}
|
||||
} else {
|
||||
mProgressView.animate().rotation(0).setDuration(0);
|
||||
}
|
||||
mProgressView.setVisibility(GONE);
|
||||
return mFinishDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setPrimaryColors(@ColorInt int... colors) {
|
||||
if (colors.length > 0) {
|
||||
final View thisView = this;
|
||||
if (!(thisView.getBackground() instanceof BitmapDrawable) && mPrimaryColor == null) {
|
||||
setPrimaryColor(colors[0]);
|
||||
mPrimaryColor = null;
|
||||
}
|
||||
if (mAccentColor == null) {
|
||||
if (colors.length > 1) {
|
||||
setAccentColor(colors[1]);
|
||||
}
|
||||
mAccentColor = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public T setProgressDrawable(Drawable drawable) {
|
||||
mProgressDrawable = null;
|
||||
mProgressView.setImageDrawable(drawable);
|
||||
return self();
|
||||
}
|
||||
|
||||
public T setProgressResource(@DrawableRes int resId) {
|
||||
mProgressDrawable = null;
|
||||
mProgressView.setImageResource(resId);
|
||||
return self();
|
||||
}
|
||||
|
||||
public T setArrowDrawable(Drawable drawable) {
|
||||
mArrowDrawable = null;
|
||||
mArrowView.setImageDrawable(drawable);
|
||||
return self();
|
||||
}
|
||||
|
||||
public T setArrowResource(@DrawableRes int resId) {
|
||||
mArrowDrawable = null;
|
||||
mArrowView.setImageResource(resId);
|
||||
return self();
|
||||
}
|
||||
|
||||
public T setSpinnerStyle(SpinnerStyle style) {
|
||||
this.mSpinnerStyle = style;
|
||||
return self();
|
||||
}
|
||||
|
||||
public T setPrimaryColor(@ColorInt int primaryColor) {
|
||||
mBackgroundColor = mPrimaryColor = primaryColor;
|
||||
if (mRefreshKernel != null) {
|
||||
mRefreshKernel.requestDrawBackgroundFor(this, mPrimaryColor);
|
||||
}
|
||||
return self();
|
||||
}
|
||||
|
||||
public T setAccentColor(@ColorInt int accentColor) {
|
||||
mAccentColor = accentColor;
|
||||
mTitleText.setTextColor(accentColor);
|
||||
if (mArrowDrawable != null) {
|
||||
mArrowDrawable.setColor(accentColor);
|
||||
}
|
||||
if (mProgressDrawable != null) {
|
||||
mProgressDrawable.setColor(accentColor);
|
||||
}
|
||||
return self();
|
||||
}
|
||||
|
||||
public T setPrimaryColorId(@ColorRes int colorId) {
|
||||
final View thisView = this;
|
||||
setPrimaryColor(getColor(thisView.getContext(), colorId));
|
||||
return self();
|
||||
}
|
||||
|
||||
public T setAccentColorId(@ColorRes int colorId) {
|
||||
final View thisView = this;
|
||||
setAccentColor(getColor(thisView.getContext(), colorId));
|
||||
return self();
|
||||
}
|
||||
|
||||
public T setFinishDuration(int delay) {
|
||||
mFinishDuration = delay;
|
||||
return self();
|
||||
}
|
||||
|
||||
public T setTextSizeTitle(float size) {
|
||||
mTitleText.setTextSize(size);
|
||||
if (mRefreshKernel != null) {
|
||||
mRefreshKernel.requestRemeasureHeightFor(this);
|
||||
}
|
||||
return self();
|
||||
}
|
||||
|
||||
public T setDrawableMarginRight(float dp) {
|
||||
final View arrowView = mArrowView;
|
||||
final View progressView = mProgressView;
|
||||
MarginLayoutParams lpArrow = (MarginLayoutParams) arrowView.getLayoutParams();
|
||||
MarginLayoutParams lpProgress = (MarginLayoutParams) progressView.getLayoutParams();
|
||||
lpArrow.rightMargin = lpProgress.rightMargin = DensityUtil.dp2px(dp);
|
||||
arrowView.setLayoutParams(lpArrow);
|
||||
progressView.setLayoutParams(lpProgress);
|
||||
return self();
|
||||
}
|
||||
|
||||
public T setDrawableSize(float dp) {
|
||||
final View arrowView = mArrowView;
|
||||
final View progressView = mProgressView;
|
||||
ViewGroup.LayoutParams lpArrow = arrowView.getLayoutParams();
|
||||
ViewGroup.LayoutParams lpProgress = progressView.getLayoutParams();
|
||||
lpArrow.width = lpProgress.width = DensityUtil.dp2px(dp);
|
||||
lpArrow.height = lpProgress.height = DensityUtil.dp2px(dp);
|
||||
arrowView.setLayoutParams(lpArrow);
|
||||
progressView.setLayoutParams(lpProgress);
|
||||
return self();
|
||||
}
|
||||
|
||||
public T setDrawableArrowSize(float dp) {
|
||||
final View arrowView = mArrowView;
|
||||
ViewGroup.LayoutParams lpArrow = arrowView.getLayoutParams();
|
||||
lpArrow.height = lpArrow.width = DensityUtil.dp2px(dp);
|
||||
arrowView.setLayoutParams(lpArrow);
|
||||
return self();
|
||||
}
|
||||
|
||||
public T setDrawableProgressSize(float dp) {
|
||||
final View progressView = mProgressView;
|
||||
ViewGroup.LayoutParams lpProgress = progressView.getLayoutParams();
|
||||
lpProgress.height = lpProgress.width = DensityUtil.dp2px(dp);
|
||||
progressView.setLayoutParams(lpProgress);
|
||||
return self();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,8 +1,7 @@
|
||||
package com.gh.common.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v4.view.ViewPager.OnPageChangeListener;
|
||||
import android.view.Gravity;
|
||||
@ -16,6 +15,7 @@ import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.common.exposure.ExposureEvent;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
@ -86,6 +86,7 @@ public class DownloadDialog implements OnCollectionCallBackListener {
|
||||
private LinearLayout dialog_ll_collection_hint;
|
||||
private String entrance;
|
||||
private String location;
|
||||
private ExposureEvent traceEvent;
|
||||
private final int row = 3;
|
||||
private final int column = 3;
|
||||
private boolean isLoadPlatform;
|
||||
@ -103,6 +104,10 @@ public class DownloadDialog implements OnCollectionCallBackListener {
|
||||
}
|
||||
|
||||
public void showPopupWindow(View view, GameEntity gameEntity, String entrance, String location) {
|
||||
showPopupWindow(view, gameEntity, entrance, location, null);
|
||||
}
|
||||
|
||||
public void showPopupWindow(View view, GameEntity gameEntity, String entrance, String location, @Nullable ExposureEvent traceEvent) {
|
||||
|
||||
if (isShow && (popupWindow == null || !popupWindow.isShowing())) {
|
||||
isShow = false;
|
||||
@ -115,8 +120,8 @@ public class DownloadDialog implements OnCollectionCallBackListener {
|
||||
this.gameEntity = gameEntity;
|
||||
this.entrance = entrance;
|
||||
this.location = location;
|
||||
this.traceEvent = traceEvent;
|
||||
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
gameApk = sortApk(new ArrayList<>(gameEntity.getApk()));
|
||||
|
||||
if (gameEntity.getCollection() != null) {
|
||||
@ -210,12 +215,12 @@ public class DownloadDialog implements OnCollectionCallBackListener {
|
||||
downloadEntity = DownloadManager.getInstance(mContext).getDownloadEntityByUrl(apkEntity.getUrl());
|
||||
if (downloadEntity == null) {
|
||||
packageName = apkEntity.getPackageName();
|
||||
if (PackageManager.isInstalled(packageName)) {
|
||||
if (PackageManager.INSTANCE.isInstalled(packageName)) {
|
||||
gh_id = PackageUtils.getMetaData(mContext, packageName, "gh_id");
|
||||
if (gh_id == null || gh_id.equals(gameEntity.getId())) {
|
||||
if (!PackageUtils.isSignature(mContext, packageName)) {
|
||||
apkEntity.setOrder(8);
|
||||
} else if (PackageManager.isCanUpdate(gameEntity.getId(), packageName)) {
|
||||
} else if (PackageManager.INSTANCE.isCanUpdate(gameEntity.getId(), packageName)) {
|
||||
apkEntity.setOrder(5);
|
||||
} else {
|
||||
apkEntity.setOrder(2);
|
||||
@ -343,7 +348,7 @@ public class DownloadDialog implements OnCollectionCallBackListener {
|
||||
currentItem = viewPager.getCurrentItem();
|
||||
}
|
||||
Utils.log("currentItem = " + currentItem);
|
||||
adapter = new PlatformPagerAdapter(mContext, this, gameEntity, apkList, entrance, location);
|
||||
adapter = new PlatformPagerAdapter(mContext, this, gameEntity, apkList, entrance, location, traceEvent);
|
||||
viewPager.setAdapter(adapter);
|
||||
viewPager.setCurrentItem(currentItem);
|
||||
}
|
||||
@ -431,7 +436,7 @@ public class DownloadDialog implements OnCollectionCallBackListener {
|
||||
addHintPoint(dialog_ll_collection_hint, size);
|
||||
|
||||
collectionAdapter = new PlatformPagerAdapter(
|
||||
mContext, this, gameEntity, gameCollectionEntity.getSaveApkEntity(), entrance, location);
|
||||
mContext, null, gameEntity, gameCollectionEntity.getSaveApkEntity(), entrance, location, traceEvent);
|
||||
collectionViewPager.setAdapter(collectionAdapter);
|
||||
|
||||
collectionViewPager.addOnPageChangeListener(new MyPageChangeListener(dialog_ll_collection_hint));
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.common.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
@ -19,6 +20,9 @@ import com.gh.gamecenter.R;
|
||||
|
||||
public class DownloadProgressBar extends ProgressBar {
|
||||
private static final int MAX_LENGTH = 1000;
|
||||
private static final int DOWNLOAD_NORMAL_STYLE = 0;
|
||||
private static final int DOWNLOAD_RECT_STYLE = 1;
|
||||
private static final int DOWNLOAD_IMAGE_STYLE = 2;
|
||||
|
||||
public enum DownloadType {
|
||||
NORMAL,
|
||||
@ -38,7 +42,9 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
|
||||
private String mText;
|
||||
|
||||
private int mDownloadStyle;
|
||||
private int mDefaultColor;
|
||||
private int mTextSize;
|
||||
|
||||
public DownloadProgressBar(Context context) {
|
||||
super(context);
|
||||
@ -46,6 +52,12 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
|
||||
public DownloadProgressBar(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
if (attrs != null) {
|
||||
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.DownloadProgressBar);
|
||||
mDownloadStyle = ta.getInteger(R.styleable.DownloadProgressBar_downloadStyle, DOWNLOAD_NORMAL_STYLE);
|
||||
mTextSize = ta.getDimensionPixelSize(R.styleable.DownloadProgressBar_textSize, DisplayUtils.sp2px(getContext(), 14));
|
||||
ta.recycle();
|
||||
}
|
||||
setMax(MAX_LENGTH);
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.game_item_btn_download_style));
|
||||
}
|
||||
@ -66,7 +78,7 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
if (TextUtils.isEmpty(mText)) return;
|
||||
|
||||
mPaint.setColor(mDefaultColor == 0 ? ContextCompat.getColor(getContext(), R.color.theme) : mDefaultColor); // 初始化颜色
|
||||
mPaint.setTextSize(DisplayUtils.sp2px(getContext(), 14));
|
||||
mPaint.setTextSize(mTextSize);
|
||||
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||
mPaint.setXfermode(null);
|
||||
create();
|
||||
@ -77,7 +89,9 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
mPaint.setTextAlign(Paint.Align.CENTER);
|
||||
srcCanvas.drawText(mText, getWidth() / 2, baseline, mPaint);
|
||||
mPaint.setXfermode(mDuffXFerMode);
|
||||
mPaint.setColor(Color.WHITE); // 反向颜色
|
||||
if (getProgress() != 0 && getProgress() != MAX_LENGTH) {
|
||||
mPaint.setColor(DOWNLOAD_IMAGE_STYLE == mDownloadStyle ? Color.BLACK : Color.WHITE); // 反向颜色
|
||||
}
|
||||
|
||||
srcCanvas.drawRect(rectF, mPaint);
|
||||
canvas.drawBitmap(srcBitmap, 0, 0, null);
|
||||
@ -94,35 +108,74 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
|
||||
public void setText(@StringRes int res) {
|
||||
setText(getResources().getString(res));
|
||||
invalidate(); // 文字绘制没有同步 就重绘多几遍吧 虽然不知到有没有用
|
||||
}
|
||||
|
||||
public void setDownloadType(DownloadType downloadType) {
|
||||
switch (downloadType) {
|
||||
case NORMAL:
|
||||
case INSTALL_NORMAL:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.game_item_btn_download_style));
|
||||
mDefaultColor = Color.WHITE;
|
||||
switch (mDownloadStyle) {
|
||||
case DOWNLOAD_RECT_STYLE:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.detail_download_normal_rect_style));
|
||||
mDefaultColor = Color.WHITE;
|
||||
break;
|
||||
case DOWNLOAD_IMAGE_STYLE:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.detail_download_normal_image_style));
|
||||
mDefaultColor = Color.BLACK;
|
||||
break;
|
||||
default:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.game_item_btn_download_style));
|
||||
mDefaultColor = Color.WHITE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PLUGIN:
|
||||
case INSTALL_PLUGIN:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.game_item_btn_plugin_style));
|
||||
setProgressDrawable(getResources().getDrawable(mDownloadStyle == DOWNLOAD_RECT_STYLE
|
||||
? R.drawable.detail_download_plugin_install_rect_style : R.drawable.game_item_btn_plugin_style));
|
||||
mDefaultColor = Color.WHITE;
|
||||
break;
|
||||
case NONE:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.news_detail_comment)); // todo 是否需要点击效果
|
||||
setProgressDrawable(getResources().getDrawable(mDownloadStyle == DOWNLOAD_RECT_STYLE
|
||||
? R.drawable.detail_download_none_rect_style : R.drawable.news_detail_comment));
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.hint);
|
||||
break;
|
||||
case LAUNCH_OR_OPEN:
|
||||
setProgress(0);
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_style)); // todo 背景是否需要与下载中区分
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
|
||||
switch (mDownloadStyle) {
|
||||
case DOWNLOAD_RECT_STYLE:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.detail_download_open_rect_style));
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
|
||||
break;
|
||||
case DOWNLOAD_IMAGE_STYLE:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.detail_download_open_image_style));
|
||||
mDefaultColor = Color.WHITE;
|
||||
break;
|
||||
default:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.detail_download_open_style));
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DOWNLOADING_NORMAL: // todo bug 和列表用相同的drawable会复用
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_style2));
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
|
||||
case DOWNLOADING_NORMAL:
|
||||
switch (mDownloadStyle) {
|
||||
case DOWNLOAD_RECT_STYLE:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_rect_style));
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
|
||||
break;
|
||||
case DOWNLOAD_IMAGE_STYLE:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_image_style));
|
||||
mDefaultColor = Color.WHITE;
|
||||
break;
|
||||
default:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_style));
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DOWNLOADING_PLUGIN:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_plugin_style));
|
||||
setProgressDrawable(getResources().getDrawable(mDownloadStyle == DOWNLOAD_RECT_STYLE
|
||||
? R.drawable.detail_downloading_plugin_rect_style : R.drawable.detail_downloading_plugin_style));
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.btn_plugin);
|
||||
break;
|
||||
}
|
||||
|
||||
26
app/src/main/java/com/gh/common/view/DumbRefreshLayout.java
Normal file
26
app/src/main/java/com/gh/common/view/DumbRefreshLayout.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.gh.common.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.constant.RefreshState;
|
||||
|
||||
public class DumbRefreshLayout extends SmartRefreshLayout {
|
||||
|
||||
public DumbRefreshLayout(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public DumbRefreshLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public DumbRefreshLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public boolean isRefreshing() {
|
||||
return mState != RefreshState.None;
|
||||
}
|
||||
}
|
||||
113
app/src/main/java/com/gh/common/view/ExpendTextView.java
Normal file
113
app/src/main/java/com/gh/common/view/ExpendTextView.java
Normal file
@ -0,0 +1,113 @@
|
||||
package com.gh.common.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.text.Layout;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextPaint;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
|
||||
public class ExpendTextView extends android.support.v7.widget.AppCompatTextView {
|
||||
|
||||
private CharSequence mSnapshotText;
|
||||
|
||||
private String mExpendText = "...全文";
|
||||
|
||||
private int mMaxLines = 3; // 由于sdk版本限制(getMaxLines) 这里设置默认值
|
||||
|
||||
private boolean mInitLayout = false;
|
||||
private boolean mOpenLayout = false;
|
||||
|
||||
public ExpendTextView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public ExpendTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public ExpendTextView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
mMaxLines = getMaxLines();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
if (mInitLayout && !mOpenLayout && getLineCount() > mMaxLines) {
|
||||
mSnapshotText = getText();
|
||||
mInitLayout = false;
|
||||
showExpendButton();
|
||||
}
|
||||
}
|
||||
|
||||
public void setExpendText(String text) {
|
||||
this.mExpendText = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(CharSequence text, BufferType type) {
|
||||
mInitLayout = true;
|
||||
super.setText(text, type);
|
||||
}
|
||||
|
||||
private void showExpendButton() {
|
||||
Layout layout = getLayout();
|
||||
int start = layout.getLineStart(0);
|
||||
int lastLineEnd = layout.getLineEnd(mMaxLines - 1);
|
||||
int lastLineStart = layout.getLineStart(mMaxLines - 1);
|
||||
float lastLineRight = layout.getLineRight(mMaxLines - 1);
|
||||
|
||||
int viewWidth = getWidth() - getPaddingRight() - getPaddingLeft();
|
||||
|
||||
TextPaint paint = getPaint();
|
||||
float expendTextWidth = paint.measureText(mExpendText);
|
||||
CharSequence content = mSnapshotText.subSequence(start, lastLineEnd);
|
||||
if (viewWidth - lastLineRight > expendTextWidth) {
|
||||
content = content.toString().trim() + mExpendText;
|
||||
} else {
|
||||
CharSequence lastText = mSnapshotText.subSequence(lastLineStart, lastLineEnd);
|
||||
for (int i = lastText.length() - 1; i > 0; i--) {
|
||||
CharSequence sequence = lastText.subSequence(0, i);
|
||||
float w = paint.measureText(sequence.toString());
|
||||
if (viewWidth - w - DisplayUtils.dip2px(5) > expendTextWidth) {
|
||||
content = mSnapshotText.subSequence(start, lastLineStart + i) + mExpendText;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SpannableStringBuilder msp = new SpannableStringBuilder(content);
|
||||
int length = msp.length();
|
||||
msp.replace(length - mExpendText.length(), length, mExpendText);
|
||||
msp.setSpan(new ClickableSpan() {
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setColor(ContextCompat.getColor(getContext(), R.color.theme));
|
||||
ds.setUnderlineText(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View widget) {
|
||||
mOpenLayout = true;
|
||||
setMaxLines(Integer.MAX_VALUE);
|
||||
setText(mSnapshotText);
|
||||
|
||||
}
|
||||
}, length - mExpendText.length(), length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
||||
setText(msp);
|
||||
setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,10 +1,12 @@
|
||||
package com.gh.common.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
|
||||
/**
|
||||
* Created by khy on 2/04/18.
|
||||
@ -20,7 +22,13 @@ public class LimitHeightScrollView extends ScrollView {
|
||||
|
||||
public LimitHeightScrollView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mLimitHeight = DisplayUtils.dip2px(getContext(), 240);
|
||||
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 LimitHeightScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
|
||||
105
app/src/main/java/com/gh/common/view/NestedRecyclerView.kt
Normal file
105
app/src/main/java/com/gh/common/view/NestedRecyclerView.kt
Normal file
@ -0,0 +1,105 @@
|
||||
package com.gh.common.view
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.support.v4.view.NestedScrollingParent
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
|
||||
open class NestedRecyclerView : RecyclerView, NestedScrollingParent {
|
||||
|
||||
private var nestedScrollTarget: View? = null
|
||||
private var nestedScrollTargetIsBeingDragged = false
|
||||
private var nestedScrollTargetWasUnableToScroll = false
|
||||
private var skipsTouchInterception = false
|
||||
|
||||
|
||||
constructor(context: Context) :
|
||||
super(context)
|
||||
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet?) :
|
||||
super(context, attrs)
|
||||
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) :
|
||||
super(context, attrs, defStyleAttr)
|
||||
|
||||
|
||||
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
|
||||
val temporarilySkipsInterception = nestedScrollTarget != null
|
||||
if (temporarilySkipsInterception) {
|
||||
// If a descendent view is scrolling we set a flag to temporarily skip our onInterceptTouchEvent implementation
|
||||
skipsTouchInterception = true
|
||||
}
|
||||
|
||||
// First dispatch, potentially skipping our onInterceptTouchEvent
|
||||
var handled = super.dispatchTouchEvent(ev)
|
||||
|
||||
if (temporarilySkipsInterception) {
|
||||
skipsTouchInterception = false
|
||||
|
||||
// If the first dispatch yielded no result or we noticed that the descendent view is unable to scroll in the
|
||||
// direction the user is scrolling, we dispatch once more but without skipping our onInterceptTouchEvent.
|
||||
// Note that RecyclerView automatically cancels active touches of all its descendents once it starts scrolling
|
||||
// so we don't have to do that.
|
||||
if (!handled || nestedScrollTargetWasUnableToScroll) {
|
||||
handled = super.dispatchTouchEvent(ev)
|
||||
}
|
||||
}
|
||||
|
||||
return handled
|
||||
}
|
||||
|
||||
|
||||
// Skips RecyclerView's onInterceptTouchEvent if requested
|
||||
override fun onInterceptTouchEvent(e: MotionEvent) =
|
||||
!skipsTouchInterception && super.onInterceptTouchEvent(e)
|
||||
|
||||
|
||||
override fun onNestedScroll(target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int) {
|
||||
if (target === nestedScrollTarget && !nestedScrollTargetIsBeingDragged) {
|
||||
if (dyConsumed != 0) {
|
||||
// The descendent was actually scrolled, so we won't bother it any longer.
|
||||
// It will receive all future events until it finished scrolling.
|
||||
nestedScrollTargetIsBeingDragged = true
|
||||
nestedScrollTargetWasUnableToScroll = false
|
||||
}
|
||||
else if (dyConsumed == 0 && dyUnconsumed != 0) {
|
||||
// The descendent tried scrolling in response to touch movements but was not able to do so.
|
||||
// We remember that in order to allow RecyclerView to take over scrolling.
|
||||
nestedScrollTargetWasUnableToScroll = true
|
||||
target.parent?.requestDisallowInterceptTouchEvent(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onNestedScrollAccepted(child: View, target: View, axes: Int) {
|
||||
if (axes and View.SCROLL_AXIS_VERTICAL != 0) {
|
||||
// A descendent started scrolling, so we'll observe it.
|
||||
nestedScrollTarget = target
|
||||
nestedScrollTargetIsBeingDragged = false
|
||||
nestedScrollTargetWasUnableToScroll = false
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
super.onNestedScrollAccepted(child, target, axes)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// We only support vertical scrolling.
|
||||
override fun onStartNestedScroll(child: View, target: View, nestedScrollAxes: Int) =
|
||||
(nestedScrollAxes and View.SCROLL_AXIS_VERTICAL != 0)
|
||||
|
||||
|
||||
override fun onStopNestedScroll(child: View) {
|
||||
// The descendent finished scrolling. Clean up!
|
||||
nestedScrollTarget = null
|
||||
nestedScrollTargetIsBeingDragged = false
|
||||
nestedScrollTargetWasUnableToScroll = false
|
||||
}
|
||||
}
|
||||
58
app/src/main/java/com/gh/common/view/SubCategoryView.kt
Normal file
58
app/src/main/java/com/gh/common/view/SubCategoryView.kt
Normal file
@ -0,0 +1,58 @@
|
||||
package com.gh.common.view
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import com.gh.common.util.DataUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.category.CategoryListActivity
|
||||
import com.gh.gamecenter.entity.CategoryEntity
|
||||
|
||||
class SubCategoryView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : LinearLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
var leftTv: TextView
|
||||
var centerTv: TextView
|
||||
var rightTv: TextView
|
||||
|
||||
var leftDivider: View
|
||||
var rightDivider: View
|
||||
|
||||
var primeCategory: CategoryEntity? = null
|
||||
var categoryTitle: String? = ""
|
||||
|
||||
init {
|
||||
View.inflate(context, R.layout.layout_sub_category, this)
|
||||
|
||||
leftTv = findViewById(R.id.tv_left_sub_category)
|
||||
centerTv = findViewById(R.id.tv_center_sub_category)
|
||||
rightTv = findViewById(R.id.tv_right_sub_category)
|
||||
|
||||
leftDivider = findViewById(R.id.divider_left)
|
||||
rightDivider = findViewById(R.id.divider_right)
|
||||
}
|
||||
|
||||
fun setLeftCategory(category: CategoryEntity) {
|
||||
setCategory(leftTv, category)
|
||||
}
|
||||
|
||||
fun setCenterCategory(category: CategoryEntity) {
|
||||
setCategory(centerTv, category)
|
||||
leftDivider.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
fun setRightCategory(category: CategoryEntity) {
|
||||
setCategory(rightTv, category)
|
||||
rightDivider.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
private fun setCategory(tv: TextView, category: CategoryEntity) {
|
||||
tv.text = category.name
|
||||
tv.setOnClickListener {
|
||||
DataUtils.onMtaEvent(context, "分类大全", categoryTitle, primeCategory?.name!! + "-" + category.name!!)
|
||||
tv.context.startActivity(CategoryListActivity.getIntent(tv.context, categoryTitle!!, primeCategory!!, category.name!!))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
176
app/src/main/java/com/gh/common/view/SwipeRefreshHeader.java
Normal file
176
app/src/main/java/com/gh/common/view/SwipeRefreshHeader.java
Normal file
@ -0,0 +1,176 @@
|
||||
package com.gh.common.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.scwang.smartrefresh.layout.R;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshHeader;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.constant.RefreshState;
|
||||
import com.scwang.smartrefresh.layout.constant.SpinnerStyle;
|
||||
import com.scwang.smartrefresh.layout.internal.ArrowDrawable;
|
||||
import com.scwang.smartrefresh.layout.internal.ProgressDrawable;
|
||||
import com.scwang.smartrefresh.layout.util.DensityUtil;
|
||||
|
||||
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
|
||||
@SuppressWarnings({"unused", "UnusedReturnValue"})
|
||||
public class SwipeRefreshHeader extends AbstractSwipeRefreshHeader<SwipeRefreshHeader> implements RefreshHeader {
|
||||
|
||||
public static final byte ID_TEXT_UPDATE = 4;
|
||||
|
||||
public static String REFRESH_HEADER_PULLING = "下拉可以刷新";//"下拉可以刷新";
|
||||
public static String REFRESH_HEADER_REFRESHING = "正在刷新...";//"正在刷新...";
|
||||
public static String REFRESH_HEADER_LOADING = "刷新中...";//"正在加载...";
|
||||
public static String REFRESH_HEADER_RELEASE = "释放立即刷新";//"释放立即刷新";
|
||||
public static String REFRESH_HEADER_FINISH = "刷新完成";//"刷新完成";
|
||||
public static String REFRESH_HEADER_FAILED = "获取失败,请检查网络设置";//"刷新失败";
|
||||
|
||||
private TextView successView;
|
||||
|
||||
public SwipeRefreshHeader(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public SwipeRefreshHeader(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public SwipeRefreshHeader(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
|
||||
final View arrowView = mArrowView;
|
||||
final View progressView = mProgressView;
|
||||
final DensityUtil density = new DensityUtil();
|
||||
|
||||
successView = (TextView) LayoutInflater.from(context).inflate(com.gh.gamecenter.R.layout.piece_refresh_hint, null);
|
||||
LinearLayout.LayoutParams successViewLp = new LinearLayout.LayoutParams(MATCH_PARENT, density.dip2px(45));
|
||||
addView(successView, successViewLp);
|
||||
|
||||
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ClassicsHeader);
|
||||
|
||||
LayoutParams lpArrow = (LayoutParams) arrowView.getLayoutParams();
|
||||
LayoutParams lpProgress = (LayoutParams) progressView.getLayoutParams();
|
||||
LinearLayout.LayoutParams lpUpdateText = new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
|
||||
lpUpdateText.topMargin = ta.getDimensionPixelSize(R.styleable.ClassicsHeader_srlTextTimeMarginTop, density.dip2px(0));
|
||||
lpProgress.rightMargin = ta.getDimensionPixelSize(R.styleable.ClassicsFooter_srlDrawableMarginRight, density.dip2px(10));
|
||||
lpArrow.rightMargin = lpProgress.rightMargin;
|
||||
|
||||
lpArrow.width = ta.getLayoutDimension(R.styleable.ClassicsHeader_srlDrawableArrowSize, lpArrow.width);
|
||||
lpArrow.height = ta.getLayoutDimension(R.styleable.ClassicsHeader_srlDrawableArrowSize, lpArrow.height);
|
||||
lpProgress.width = ta.getLayoutDimension(R.styleable.ClassicsHeader_srlDrawableProgressSize, lpProgress.width);
|
||||
lpProgress.height = ta.getLayoutDimension(R.styleable.ClassicsHeader_srlDrawableProgressSize, lpProgress.height);
|
||||
|
||||
lpArrow.width = ta.getLayoutDimension(R.styleable.ClassicsHeader_srlDrawableSize, lpArrow.width);
|
||||
lpArrow.height = ta.getLayoutDimension(R.styleable.ClassicsHeader_srlDrawableSize, lpArrow.height);
|
||||
lpProgress.width = ta.getLayoutDimension(R.styleable.ClassicsHeader_srlDrawableSize, lpProgress.width);
|
||||
lpProgress.height = ta.getLayoutDimension(R.styleable.ClassicsHeader_srlDrawableSize, lpProgress.height);
|
||||
|
||||
mFinishDuration = ta.getInt(R.styleable.ClassicsHeader_srlFinishDuration, 1000);
|
||||
mSpinnerStyle = SpinnerStyle.values()[ta.getInt(R.styleable.ClassicsHeader_srlClassicsSpinnerStyle, mSpinnerStyle.ordinal())];
|
||||
|
||||
if (ta.hasValue(R.styleable.ClassicsHeader_srlDrawableArrow)) {
|
||||
mArrowView.setImageDrawable(ta.getDrawable(R.styleable.ClassicsHeader_srlDrawableArrow));
|
||||
} else {
|
||||
mArrowDrawable = new ArrowDrawable();
|
||||
mArrowDrawable.setColor(0xff666666);
|
||||
mArrowView.setImageDrawable(mArrowDrawable);
|
||||
}
|
||||
|
||||
if (ta.hasValue(R.styleable.ClassicsHeader_srlDrawableProgress)) {
|
||||
mProgressView.setImageDrawable(ta.getDrawable(R.styleable.ClassicsHeader_srlDrawableProgress));
|
||||
} else {
|
||||
mProgressDrawable = new ProgressDrawable();
|
||||
mProgressDrawable.setColor(0xff666666);
|
||||
mProgressView.setImageDrawable(mProgressDrawable);
|
||||
}
|
||||
|
||||
if (ta.hasValue(R.styleable.ClassicsHeader_srlTextSizeTitle)) {
|
||||
mTitleText.setTextSize(TypedValue.COMPLEX_UNIT_PX, ta.getDimensionPixelSize(R.styleable.ClassicsHeader_srlTextSizeTitle, DensityUtil.dp2px(12)));
|
||||
} else {
|
||||
mTitleText.setTextSize(12);
|
||||
}
|
||||
|
||||
if (ta.hasValue(R.styleable.ClassicsHeader_srlPrimaryColor)) {
|
||||
setPrimaryColor(ta.getColor(R.styleable.ClassicsHeader_srlPrimaryColor, 0));
|
||||
}
|
||||
if (ta.hasValue(R.styleable.ClassicsHeader_srlAccentColor)) {
|
||||
setAccentColor(ta.getColor(R.styleable.ClassicsHeader_srlAccentColor, 0));
|
||||
}
|
||||
|
||||
ta.recycle();
|
||||
|
||||
mTitleText.setText(this.isInEditMode() ? REFRESH_HEADER_REFRESHING : REFRESH_HEADER_PULLING);
|
||||
}
|
||||
|
||||
public void setFinishText(String text) {
|
||||
REFRESH_HEADER_FINISH = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onFinish(@NonNull RefreshLayout layout, boolean success) {
|
||||
mCenterLayout.setVisibility(GONE);
|
||||
mArrowView.setVisibility(GONE);
|
||||
mProgressView.setVisibility(GONE);
|
||||
if (success) {
|
||||
successView.setVisibility(VISIBLE);
|
||||
successView.setText(REFRESH_HEADER_FINISH);
|
||||
return super.onFinish(layout, success);
|
||||
} else {
|
||||
successView.setVisibility(GONE);
|
||||
super.onFinish(layout, success);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChanged(@NonNull RefreshLayout refreshLayout, @NonNull RefreshState oldState, @NonNull RefreshState newState) {
|
||||
switch (newState) {
|
||||
case PullDownToRefresh:
|
||||
successView.setVisibility(GONE);
|
||||
mCenterLayout.setVisibility(VISIBLE);
|
||||
mTitleText.setText(REFRESH_HEADER_PULLING);
|
||||
mArrowView.setVisibility(VISIBLE);
|
||||
mArrowView.animate().rotation(0);
|
||||
break;
|
||||
case Refreshing:
|
||||
case RefreshReleased:
|
||||
successView.setVisibility(GONE);
|
||||
mCenterLayout.setVisibility(VISIBLE);
|
||||
mTitleText.setText(REFRESH_HEADER_REFRESHING);
|
||||
mArrowView.setVisibility(GONE);
|
||||
break;
|
||||
case ReleaseToRefresh:
|
||||
successView.setVisibility(GONE);
|
||||
mCenterLayout.setVisibility(VISIBLE);
|
||||
mTitleText.setText(REFRESH_HEADER_RELEASE);
|
||||
mArrowView.animate().rotation(180);
|
||||
break;
|
||||
case Loading:
|
||||
successView.setVisibility(GONE);
|
||||
mCenterLayout.setVisibility(VISIBLE);
|
||||
mArrowView.setVisibility(GONE);
|
||||
mTitleText.setText(REFRESH_HEADER_LOADING);
|
||||
break;
|
||||
case None:
|
||||
successView.setVisibility(GONE);
|
||||
REFRESH_HEADER_FINISH = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public SwipeRefreshHeader setAccentColor(@ColorInt int accentColor) {
|
||||
return super.setAccentColor(accentColor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,8 +7,10 @@ import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
|
||||
import com.gh.common.exposure.ExposureEvent;
|
||||
import com.gh.common.util.AppDebugConfig;
|
||||
import com.gh.common.util.DataCollectionUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
@ -18,6 +20,7 @@ import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus;
|
||||
import com.gh.gamecenter.manager.PackageManager;
|
||||
import com.google.gson.Gson;
|
||||
import com.lightgame.config.CommonDebug;
|
||||
import com.lightgame.download.ConnectionUtils;
|
||||
import com.lightgame.download.DataChanger;
|
||||
@ -44,6 +47,7 @@ import static android.os.Build.MANUFACTURER;
|
||||
public class DownloadManager implements DownloadStatusListener {
|
||||
|
||||
private static DownloadManager mInstance;
|
||||
private static Gson gson = new Gson();
|
||||
|
||||
private Context mContext;
|
||||
private Handler mHandler;
|
||||
@ -60,7 +64,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
@Override
|
||||
public void onTaskCancelled(DownloadEntity entity) {
|
||||
EBDownloadStatus status = new EBDownloadStatus("delete", entity.getName(),
|
||||
entity.getPlatform(), entity.getUrl(), entity.getPackageName());
|
||||
entity.getPlatform(), entity.getUrl(), entity.getPackageName(), entity.getGameId());
|
||||
status.setPluggable(entity.isPluggable());
|
||||
EventBus.getDefault().post(status);
|
||||
|
||||
@ -181,8 +185,9 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
GameEntity gameEntity,
|
||||
String method,
|
||||
String entrance,
|
||||
String location) {
|
||||
createDownload(context, gameEntity.getApk().get(0), gameEntity, method, entrance, location);
|
||||
String location,
|
||||
@Nullable ExposureEvent traceEvent) {
|
||||
createDownload(context, gameEntity.getApk().get(0), gameEntity, method, entrance, location, traceEvent);
|
||||
}
|
||||
|
||||
public static void createDownload(final Context context,
|
||||
@ -190,7 +195,8 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
GameEntity gameEntity,
|
||||
String method,
|
||||
String entrance,
|
||||
String location) {
|
||||
String location,
|
||||
@Nullable ExposureEvent traceEvent) {
|
||||
|
||||
// 安装指引
|
||||
if ("Huawei".equalsIgnoreCase(MANUFACTURER) || "Oppo".equalsIgnoreCase(MANUFACTURER)) {
|
||||
@ -198,12 +204,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
final SharedPreferences.Editor edit = sp.edit();
|
||||
if (sp.getBoolean("InstallHint" + PackageUtils.getVersionName(context), true)) {
|
||||
DialogUtils.showInstallHintDialog(context,
|
||||
new DialogUtils.ConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
edit.putBoolean("InstallHint" + PackageUtils.getVersionName(context), false).apply();
|
||||
}
|
||||
});
|
||||
() -> edit.putBoolean("InstallHint" + PackageUtils.getVersionName(context), false).apply());
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,11 +219,12 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
downloadEntity.setPackageName(apkEntity.getPackageName());
|
||||
downloadEntity.setGameId(gameEntity.getId());
|
||||
downloadEntity.setEntrance(entrance);
|
||||
downloadEntity.setExposureTrace(gson.toJson(traceEvent));
|
||||
downloadEntity.setLocation(location);
|
||||
downloadEntity.setVersionName(apkEntity.getVersion());
|
||||
int installed = 0;
|
||||
for (ApkEntity apk : gameEntity.getApk()) {
|
||||
if (PackageManager.isInstalled(apk.getPackageName())) {
|
||||
if (PackageManager.INSTANCE.isInstalled(apk.getPackageName())) {
|
||||
installed++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,6 +74,7 @@ public class DownloadNotification {
|
||||
}
|
||||
int downloadingSize = 0;
|
||||
final List<DownloadEntity> list = DownloadManager.getInstance(context).getAll();
|
||||
if (list == null) return;
|
||||
for (DownloadEntity entity : list) {
|
||||
if (entity.getStatus().equals(DownloadStatus.downloading)
|
||||
|| entity.getStatus().equals(DownloadStatus.waiting)
|
||||
|
||||
@ -2,8 +2,10 @@ package com.gh.gamecenter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.halo.assistant.fragment.AboutFragment;
|
||||
|
||||
/**
|
||||
@ -12,12 +14,10 @@ import com.halo.assistant.fragment.AboutFragment;
|
||||
public class AboutActivity extends NormalActivity {
|
||||
|
||||
@NonNull
|
||||
public static Intent getIntent(Context context) {
|
||||
|
||||
// return new IntentFactory.Builder(context)
|
||||
// .setActivity(AboutActivity.class)
|
||||
// .setFragment(AboutFragment.class).build();
|
||||
return getTargetIntent(context, AboutActivity.class, AboutFragment.class);
|
||||
public static Intent getIntent(Context context, boolean isUpdate) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean(EntranceUtils.KEY_VERSION_UPDATE, isUpdate);
|
||||
return getTargetIntent(context, AboutActivity.class, AboutFragment.class, bundle);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
20
app/src/main/java/com/gh/gamecenter/BlockActivity.kt
Normal file
20
app/src/main/java/com/gh/gamecenter/BlockActivity.kt
Normal file
@ -0,0 +1,20 @@
|
||||
package com.gh.gamecenter
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.gh.common.util.EntranceUtils
|
||||
import com.gh.gamecenter.entity.SubjectRecommendEntity
|
||||
import com.gh.gamecenter.game.GameFragment
|
||||
|
||||
class BlockActivity : NormalActivity() {
|
||||
|
||||
companion object {
|
||||
fun getIntent(context: Context, blockData: SubjectRecommendEntity): Intent {
|
||||
val args = Bundle()
|
||||
args.putParcelable(EntranceUtils.KEY_BLOCK_DATA, blockData)
|
||||
return getTargetIntent(context, BlockActivity::class.java, GameFragment::class.java, args)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,7 +5,6 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@ -13,9 +12,8 @@ import android.os.Message;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.Html;
|
||||
import android.view.Gravity;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.view.animation.Animation;
|
||||
@ -107,6 +105,8 @@ public class ChooseReceiverActivity extends BaseActivity implements View.OnClick
|
||||
@BindView(R.id.choosereceiver_roket_right)
|
||||
ImageView mRoketAnimRight;
|
||||
|
||||
View mToolbarContainer;
|
||||
|
||||
private static final String KET_SHOWCONNHINTDIALOG = "showConnHintDialog";
|
||||
|
||||
private List<ScanResult> mScanResultList;
|
||||
@ -142,41 +142,11 @@ public class ChooseReceiverActivity extends BaseActivity implements View.OnClick
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setNavigationTitle(R.string.title_choose_activity, android.R.color.white);
|
||||
setNavigationTitle(R.string.title_choose_activity);
|
||||
setToolbarMenu(R.menu.menu_receive);
|
||||
|
||||
// 添加分享图标
|
||||
TextView hintTv = new TextView(this);
|
||||
hintTv.setText("操作说明");
|
||||
hintTv.setTextColor(Color.WHITE);
|
||||
hintTv.setGravity(Gravity.CENTER);
|
||||
hintTv.setPadding(DisplayUtils.dip2px(this, 13), 0, DisplayUtils.dip2px(this, 13), 0);
|
||||
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||
params.addRule(RelativeLayout.CENTER_VERTICAL);
|
||||
RelativeLayout reuse_actionbar = (RelativeLayout) findViewById(R.id.reuse_actionbar);
|
||||
reuse_actionbar.addView(hintTv, params);
|
||||
mToolbarContainer = findViewById(R.id.normal_toolbar_container);
|
||||
|
||||
init();
|
||||
|
||||
hintTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showConnHintDialog();
|
||||
}
|
||||
});
|
||||
|
||||
boolean showConnHintDialog = sp.getBoolean(KET_SHOWCONNHINTDIALOG, true);
|
||||
if (showConnHintDialog || (getIntent() != null && getIntent().getExtras() != null
|
||||
&& getIntent().getExtras().getBoolean(KET_SHOWCONNHINTDIALOG))) {
|
||||
if (showConnHintDialog) {
|
||||
sp.edit().putBoolean(KET_SHOWCONNHINTDIALOG, false).apply();
|
||||
}
|
||||
showConnHintDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
conUserIconTag = 1;
|
||||
mRadarView.setSearching(true);
|
||||
@ -196,6 +166,26 @@ public class ChooseReceiverActivity extends BaseActivity implements View.OnClick
|
||||
|
||||
updateWifiScanResult();
|
||||
handler.sendEmptyMessageDelayed(0, 2000);
|
||||
|
||||
boolean showConnHintDialog = sp.getBoolean(KET_SHOWCONNHINTDIALOG, true);
|
||||
if (showConnHintDialog || (getIntent() != null && getIntent().getExtras() != null
|
||||
&& getIntent().getExtras().getBoolean(KET_SHOWCONNHINTDIALOG))) {
|
||||
if (showConnHintDialog) {
|
||||
sp.edit().putBoolean(KET_SHOWCONNHINTDIALOG, false).apply();
|
||||
}
|
||||
showConnHintDialog();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int provideNavigationIcon() {
|
||||
return R.drawable.ic_filereceive_back;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
if (item.getItemId() == R.id.menu_receive_hint) showConnHintDialog();
|
||||
return super.onMenuItemClick(item);
|
||||
}
|
||||
|
||||
private void showConnHintDialog() {
|
||||
@ -504,7 +494,7 @@ public class ChooseReceiverActivity extends BaseActivity implements View.OnClick
|
||||
|
||||
// 连接中-动画
|
||||
private void readyAnimView() {
|
||||
getSupportActionBar().hide();
|
||||
mToolbarContainer.setVisibility(View.GONE);
|
||||
mRoketRl.setVisibility(View.VISIBLE);
|
||||
mRoketRl.animate()
|
||||
.alpha(1f)
|
||||
@ -592,7 +582,7 @@ public class ChooseReceiverActivity extends BaseActivity implements View.OnClick
|
||||
|
||||
// 连接失败-动画
|
||||
private void connFailedAnimView() {
|
||||
getSupportActionBar().show();
|
||||
mToolbarContainer.setVisibility(View.VISIBLE);
|
||||
toast("连接失败");
|
||||
if (mScaleAnimation != null) {
|
||||
mScaleAnimation.cancel();
|
||||
|
||||
@ -5,7 +5,8 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.gamecenter.ask.viewmodel.AnswerCommentConversationFragment;
|
||||
import com.gh.gamecenter.entity.MessageEntity;
|
||||
import com.gh.gamecenter.qa.answer.detail.comment.AnswerCommentConversationFragment;
|
||||
import com.halo.assistant.fragment.comment.CommentDetailFragment;
|
||||
|
||||
/**
|
||||
@ -13,9 +14,11 @@ import com.halo.assistant.fragment.comment.CommentDetailFragment;
|
||||
*/
|
||||
public class CommentDetailActivity extends NormalActivity {
|
||||
|
||||
public static Intent getIntent(Context context, String commentId) {
|
||||
// article 不为空则显示跳转原文按钮
|
||||
public static Intent getIntent(Context context, String commentId, MessageEntity.Article article) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(EntranceUtils.KEY_COMMENTID, commentId);
|
||||
args.putParcelable(MessageEntity.Article.TAG, article);
|
||||
// return new IntentFactory.Builder(context)
|
||||
// .setActivity(CommentDetailActivity.class)
|
||||
// .setFragment(CommentDetailFragment.class).setArgs(args).build();
|
||||
|
||||
@ -187,18 +187,16 @@ public class FileReceiverActivity extends BaseActivity implements OnReceiverCanc
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onHandleBackPressed() {
|
||||
|
||||
public void onBackPressed() {
|
||||
backHint();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void backHint() {
|
||||
if (isReceivesOver) {
|
||||
closePage();
|
||||
} else {
|
||||
DialogUtils.showWarningDialog(FileReceiverActivity.this, "退出提示", "退出会中断接收,确定要退出吗?"
|
||||
, "取消", "确定"
|
||||
DialogUtils.showWarningDialog(FileReceiverActivity.this, "退出传送", "文件正在传送中,确定退出吗?"
|
||||
, "点错了", "坚决退出"
|
||||
, new DialogUtils.ConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
@ -261,7 +259,7 @@ public class FileReceiverActivity extends BaseActivity implements OnReceiverCanc
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setNavigationTitle(R.string.title_file_receive, android.R.color.white);
|
||||
setNavigationTitle(R.string.title_file_receive);
|
||||
|
||||
isDestroy = false;
|
||||
|
||||
@ -495,12 +493,6 @@ public class FileReceiverActivity extends BaseActivity implements OnReceiverCanc
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onNavigationIconClicked() {
|
||||
backHint();
|
||||
return true;
|
||||
}
|
||||
|
||||
@OnClick({R.id.sender_keep_send, R.id.sender_back})
|
||||
public void back(View view) {
|
||||
switch (view.getId()) {
|
||||
|
||||
@ -171,15 +171,14 @@ public class FileSenderActivity extends BaseActivity implements FileSenderAdapte
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onHandleBackPressed() {
|
||||
public void onBackPressed() {
|
||||
backHint();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setNavigationTitle(R.string.title_file_sender, android.R.color.white);
|
||||
setNavigationTitle(R.string.title_file_sender);
|
||||
|
||||
mFileInfos = (List<FileInfo>) HaloApp.get(KcSelectGameActivity.KEY_FILE_INFO, false);
|
||||
|
||||
@ -196,14 +195,6 @@ public class FileSenderActivity extends BaseActivity implements FileSenderAdapte
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onNavigationIconClicked() {
|
||||
|
||||
backHint();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
|
||||
Utils.log("FileSenderActivity == init()");
|
||||
@ -227,7 +218,7 @@ public class FileSenderActivity extends BaseActivity implements FileSenderAdapte
|
||||
private void backHint() {
|
||||
if (!isSendOver) {
|
||||
DialogUtils.showWarningDialog(FileSenderActivity.this,
|
||||
"退出传送", "退出会中断所有游戏的传送,确定要退出吗?", "取消", "确定", new DialogUtils.ConfirmListener() {
|
||||
"退出传送", "文件正在传送中,确定退出吗?", "点错了", "坚决退出", new DialogUtils.ConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
closePage();
|
||||
|
||||
@ -4,6 +4,10 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.gh.common.exposure.ExposureEvent;
|
||||
import com.gh.common.exposure.ExposureManager;
|
||||
import com.gh.common.exposure.ExposureTraceUtils;
|
||||
import com.gh.common.exposure.ExposureType;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
@ -15,7 +19,6 @@ import com.gh.gamecenter.gamedetail.GameDetailFragment;
|
||||
*/
|
||||
public class GameDetailActivity extends NormalActivity {
|
||||
|
||||
|
||||
@Override
|
||||
protected Intent provideNormalIntent() {
|
||||
return getTargetIntent(this, GameDetailActivity.class, GameDetailFragment.class);
|
||||
@ -47,15 +50,32 @@ public class GameDetailActivity extends NormalActivity {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param switchToFirstTag 是否跳转到动态 tab
|
||||
* 启动游戏详情页面 with 曝光事件
|
||||
*/
|
||||
public static void startGameDetailActivity(Context context, String gameId, String entrance, boolean switchToFirstTag) {
|
||||
public static void startGameDetailActivity(Context context, GameEntity gameEntity, String entrance, ExposureEvent traceEvent) {
|
||||
DataUtils.onMtaEvent(context, "详情页面", "游戏详情", gameEntity != null ? gameEntity.getName() : "");
|
||||
|
||||
ExposureEvent clickEvent = ExposureEvent.Companion.createEvent(gameEntity, traceEvent.getSource(), ExposureTraceUtils.INSTANCE.appendTrace(traceEvent), ExposureType.CLICK);
|
||||
ExposureManager.INSTANCE.log(clickEvent, false);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
|
||||
bundle.putParcelable(GameEntity.TAG, gameEntity);
|
||||
bundle.putParcelable(EntranceUtils.KEY_TRACE_EVENT, clickEvent);
|
||||
context.startActivity(getTargetIntent(context, GameDetailActivity.class, GameDetailFragment.class, bundle));
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动游戏详情页面 with 曝光事件
|
||||
*/
|
||||
public static void startGameDetailActivity(Context context, String gameId, String entrance, ExposureEvent traceEvent) {
|
||||
|
||||
ExposureEvent clickEvent = ExposureEvent.Companion.createEvent(new GameEntity(gameId), traceEvent.getSource(), ExposureTraceUtils.INSTANCE.appendTrace(traceEvent), ExposureType.CLICK);
|
||||
ExposureManager.INSTANCE.log(clickEvent, false);
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(EntranceUtils.KEY_GAMEID, gameId);
|
||||
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
|
||||
bundle.putBoolean(EntranceUtils.KEY_TARGET, switchToFirstTag);
|
||||
// context.startActivity(new IntentFactory.Builder(context).setActivity(GameDetailActivity.class)
|
||||
// .setFragment(GameDetailFragment.class).setArgs(bundle).build());
|
||||
bundle.putParcelable(EntranceUtils.KEY_TRACE_EVENT, clickEvent);
|
||||
context.startActivity(getTargetIntent(context, GameDetailActivity.class, GameDetailFragment.class, bundle));
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ import static com.gh.gamecenter.FileSenderActivity.KC_REPEAT_RESULT;
|
||||
*/
|
||||
public class KcSelectGameActivity extends BaseActivity {
|
||||
|
||||
public static final String KEY_FILE_INFO = KcSelectGameActivity.KEY_FILE_INFO;
|
||||
public static final String KEY_FILE_INFO = "FileInfo";
|
||||
@BindView(R.id.select_game_rv)
|
||||
RecyclerView mSelectRv;
|
||||
@BindView(R.id.select_game_send)
|
||||
|
||||
@ -30,7 +30,7 @@ import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.LibaoEntity;
|
||||
import com.gh.gamecenter.entity.LibaoStatusEntity;
|
||||
import com.gh.gamecenter.entity.UserDataEntity;
|
||||
import com.gh.gamecenter.entity.MeEntity;
|
||||
import com.gh.gamecenter.entity.UserDataLibaoEntity;
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus;
|
||||
import com.gh.gamecenter.eventbus.EBPackage;
|
||||
@ -144,7 +144,7 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
|
||||
private DetailViewHolder getDetailViewHolder() {
|
||||
// 每次获取需要重新创建, 防止数据刷新
|
||||
return new DetailViewHolder(mContentView, mGameEntity, mDownloadEntity, mDownloadOffText, mDownloadAddWord,
|
||||
false, mEntrance, mName, mTitle); // 下载按钮ViewHolder
|
||||
false, mEntrance, mName, mTitle, null); // 下载按钮ViewHolder
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -242,14 +242,14 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
|
||||
|
||||
// 检查礼包是否可以重复领取
|
||||
private void checkLibaoStatus() {
|
||||
if (mLibaoEntity != null && mLibaoEntity.getRepeat() > 0 && mLibaoEntity.getUserData() != null
|
||||
&& mLibaoEntity.getUserData().getUserDataLibaoList() != null) {
|
||||
if (mLibaoEntity != null && mLibaoEntity.getRepeat() > 0 && mLibaoEntity.getMe() != null
|
||||
&& mLibaoEntity.getMe().getUserDataLibaoList() != null) {
|
||||
|
||||
mTitle = mLibaoEntity.getName();
|
||||
String status = mLibaoEntity.getStatus();
|
||||
String beforeStatus = mLibaoEntity.getBeforeStatus();
|
||||
|
||||
UserDataEntity userData = mLibaoEntity.getUserData();
|
||||
MeEntity userData = mLibaoEntity.getMe();
|
||||
List<UserDataLibaoEntity> userDataLibaoList = userData.getUserDataLibaoList();
|
||||
|
||||
int repeat = mLibaoEntity.getRepeat();
|
||||
@ -298,7 +298,7 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
|
||||
* 最后领取/淘号时间不是当天
|
||||
*/
|
||||
public boolean isCanLing() {
|
||||
List<UserDataLibaoEntity> userDataLibaoList = mLibaoEntity.getUserData().getUserDataLibaoList();
|
||||
List<UserDataLibaoEntity> userDataLibaoList = mLibaoEntity.getMe().getUserDataLibaoList();
|
||||
UserDataLibaoEntity userDataLibaoEntity = userDataLibaoList.get(userDataLibaoList.size() - 1);
|
||||
SimpleDateFormat formatDay = new SimpleDateFormat("dd", Locale.CHINA);
|
||||
long lingTime = userDataLibaoEntity.getTime() * 1000;
|
||||
@ -365,17 +365,13 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
|
||||
mDownloadOffText = mGameEntity.getDownloadOffText();
|
||||
DetailDownloadUtils.detailInitDownload(getDetailViewHolder(), true);
|
||||
|
||||
mAdapter.addLibaoDetail(LibaoDetailActivity.this);
|
||||
mAdapter.addLibaoDetail(LibaoDetailActivity.this, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException e) {
|
||||
if (e != null && e.code() == 404) {
|
||||
mLibaoDetailRv.setVisibility(View.GONE);
|
||||
mLlLoading.setVisibility(View.GONE);
|
||||
mLibaoDetailRv.setPadding(0, 0, 0, 0);
|
||||
mNoneDataTv.setText("天了噜~页面不见了");
|
||||
mNoneData.setVisibility(View.VISIBLE);
|
||||
mAdapter.addLibaoDetail(LibaoDetailActivity.this, false);
|
||||
} else {
|
||||
loadError();
|
||||
}
|
||||
@ -395,8 +391,7 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onHandleBackPressed() {
|
||||
//TODO 哎,绝望的这里会崩啊。。。。。。。NPE啊!!!!
|
||||
public boolean handleBackPressed() {
|
||||
// 重置领取状态
|
||||
if (mLibaoEntity == null) {
|
||||
return false;
|
||||
@ -416,10 +411,10 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
|
||||
}
|
||||
|
||||
// 从存号箱进入 获取userData后 检查领取状态(是否可以重复领取/重复淘号)
|
||||
if (mLibaoEntity.isActive() && mLibaoEntity.getUserData() != null) {
|
||||
if (mLibaoEntity.isActive() && mLibaoEntity.getMe() != null) {
|
||||
|
||||
if ("ling".equals(mLibaoEntity.getStatus()) || "tao".equals(mLibaoEntity.getStatus())) {
|
||||
List<UserDataLibaoEntity> userLibaooList = mLibaoEntity.getUserData().getUserDataLibaoList();
|
||||
List<UserDataLibaoEntity> userLibaooList = mLibaoEntity.getMe().getUserDataLibaoList();
|
||||
if (userLibaooList != null && userLibaooList.size() > 0) {
|
||||
UserDataLibaoEntity userDataLibaoEntity = userLibaooList.get(userLibaooList.size() - 1);
|
||||
if ("ling".equals(userDataLibaoEntity.getType())) {
|
||||
@ -455,10 +450,14 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
|
||||
public void loadEmpty() {
|
||||
mLibaoDetailRv.setVisibility(View.GONE);
|
||||
mLlLoading.setVisibility(View.GONE);
|
||||
mLibaoDetailRv.setPadding(0, 0, 0, 0);
|
||||
mNoneDataTv.setText("页面不见了~");
|
||||
mNoneData.setVisibility(View.VISIBLE);
|
||||
toast("内容可能已被删除");
|
||||
mLibaoDetailRv.setPadding(0, 0, 0, 0);
|
||||
if (mAdapter.getLibaoDetailEntity() == null) {
|
||||
mNoneDataTv.setText("页面不见了~");
|
||||
toast("内容可能已被删除");
|
||||
} else {
|
||||
mNoneDataTv.setText("天了噜~页面不见了");
|
||||
}
|
||||
}
|
||||
|
||||
// 领取/淘号失败,根据返回的时间重新倒数
|
||||
|
||||
@ -9,6 +9,7 @@ import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
@ -29,6 +30,8 @@ import com.gh.base.AppUncaughtHandler;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.base.fragment.BaseFragment_ViewPager;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.exposure.ExposureUtils;
|
||||
import com.gh.common.exposure.meta.MetaUtil;
|
||||
import com.gh.common.util.ClassUtils;
|
||||
import com.gh.common.util.ConcernUtils;
|
||||
import com.gh.common.util.DataCollectionUtils;
|
||||
@ -52,7 +55,6 @@ import com.gh.gamecenter.entity.GameDigestEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity;
|
||||
import com.gh.gamecenter.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus;
|
||||
import com.gh.gamecenter.eventbus.EBNetworkState;
|
||||
import com.gh.gamecenter.eventbus.EBPackage;
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
@ -79,6 +81,7 @@ import com.lightgame.download.DownloadConfig;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.download.DownloadStatus;
|
||||
import com.lightgame.download.FileUtils;
|
||||
import com.lightgame.utils.Util_System_Phone_State;
|
||||
import com.lightgame.utils.Utils;
|
||||
import com.tencent.bugly.beta.tinker.TinkerManager;
|
||||
import com.tencent.bugly.crashreport.CrashReport;
|
||||
@ -113,6 +116,8 @@ import rx.schedulers.Schedulers;
|
||||
|
||||
import static com.gh.common.util.EntranceUtils.KEY_TO;
|
||||
import static com.gh.gamecenter.fragment.MainWrapperFragment.INDEX_PERSONAL;
|
||||
import static com.gh.gamecenter.personal.PersonalFragment.LOGIN_TAG;
|
||||
import static com.gh.gamecenter.personal.PersonalFragment.LOGOUT_TAG;
|
||||
|
||||
/**
|
||||
* 项目的主Activity,3个Fragment都嵌入在这里。
|
||||
@ -238,18 +243,12 @@ public class MainActivity extends BaseActivity {
|
||||
android.content.pm.PackageManager pm = getApplicationContext().getPackageManager();
|
||||
PackageInfo packageInfo = pm.getPackageArchiveInfo(downloadEntity.getPath(), android.content.pm.PackageManager.GET_ACTIVITIES);
|
||||
if (packageInfo == null) {
|
||||
/**
|
||||
* 解析包错误信息收集
|
||||
* 1.真实下载Url
|
||||
* 2.下载次数()
|
||||
* 3.
|
||||
*/
|
||||
|
||||
DataUtils.onMtaEvent(getApplication(), "解析包错误分析"
|
||||
, "游戏名字", downloadEntity.getName() + ":"
|
||||
+ PlatformUtils.getInstance(getApplicationContext()).getPlatformName(downloadEntity.getPlatform())
|
||||
, "网络状态", DeviceUtils.getNetwork(getApplication()));
|
||||
|
||||
, "网络状态", DeviceUtils.getNetwork(getApplication())
|
||||
, "用户机型", Build.MODEL
|
||||
, "设备IMEI", Util_System_Phone_State.getDeviceId(getApplication()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -281,12 +280,21 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
// 统计下载完成事件
|
||||
private void statDoneEvent(DownloadEntity downloadEntity) {
|
||||
ExposureUtils.DownloadType type;
|
||||
String platform = PlatformUtils.getInstance(HaloApp.getInstance().getApplication()).getPlatformName(downloadEntity.getPlatform());
|
||||
|
||||
Map<String, Object> kv1 = new HashMap<>();
|
||||
kv1.put("版本", downloadEntity.getPlatform());
|
||||
kv1.put("版本", platform);
|
||||
kv1.put("状态", "下载完成");
|
||||
kv1.put("用户机型", Build.MODEL);
|
||||
kv1.put("设备IMEI", Util_System_Phone_State.getDeviceId(HaloApp.getInstance().getApplication()));
|
||||
kv1.put("网络状态", DeviceUtils.getNetwork(HaloApp.getInstance().getApplication()));
|
||||
kv1.put("光环助手版本", BuildConfig.VERSION_NAME);
|
||||
if (downloadEntity.isUpdate()) {
|
||||
type = ExposureUtils.DownloadType.UPDATE;
|
||||
DataUtils.onEvent(MainActivity.this, "游戏更新", downloadEntity.getName(), kv1);
|
||||
} else {
|
||||
type = ExposureUtils.DownloadType.DOWNLOAD;
|
||||
DataUtils.onEvent(MainActivity.this, "游戏下载", downloadEntity.getName(), kv1);
|
||||
}
|
||||
|
||||
@ -294,6 +302,8 @@ public class MainActivity extends BaseActivity {
|
||||
kv2.put("版本", downloadEntity.getPlatform());
|
||||
kv2.put("状态", "下载完成");
|
||||
kv2.put("位置", downloadEntity.getEntrance());
|
||||
kv2.put("游戏分平台", downloadEntity.getName() + "-" + platform);
|
||||
kv2.put("光环助手版本", BuildConfig.VERSION_NAME);
|
||||
DataUtils.onEvent(MainActivity.this, "游戏下载位置", downloadEntity.getName(), kv2);
|
||||
|
||||
if (downloadEntity.isPluggable()) {
|
||||
@ -301,9 +311,12 @@ public class MainActivity extends BaseActivity {
|
||||
kv3.put("下载", "下载完成");
|
||||
kv3.put("版本", downloadEntity.getPlatform());
|
||||
kv3.put("位置", downloadEntity.getEntrance());
|
||||
type = ExposureUtils.DownloadType.PLUGIN_DOWNLOAD;
|
||||
DataUtils.onEvent(MainActivity.this, "插件化", downloadEntity.getName(), kv3);
|
||||
}
|
||||
|
||||
ExposureUtils.INSTANCE.logADownloadCompleteExposureEvent(new GameEntity(downloadEntity.getGameId()), downloadEntity.getPlatform(), downloadEntity.getExposureTrace(), type);
|
||||
|
||||
DataCollectionUtils.uploadDownload(this, downloadEntity, "完成");
|
||||
}
|
||||
|
||||
@ -416,7 +429,7 @@ public class MainActivity extends BaseActivity {
|
||||
private void getInstalledListFromServer() {
|
||||
ArrayList<String> list = PackageUtils.getAllPackageName(getApplicationContext());
|
||||
|
||||
PackageManager.init(list);
|
||||
PackageManager.INSTANCE.initData(list);
|
||||
|
||||
//应用上报
|
||||
uploadAppList();
|
||||
@ -498,7 +511,7 @@ public class MainActivity extends BaseActivity {
|
||||
if (installInfo != null && response.getApk().size() != 0) {
|
||||
HashMap<String, Boolean> packageNames = new HashMap<>();
|
||||
for (ApkEntity apkEntity : response.getApk()) {
|
||||
if (PackageManager.isInstalled(apkEntity.getPackageName())) {
|
||||
if (PackageManager.INSTANCE.isInstalled(apkEntity.getPackageName())) {
|
||||
packageNames.put(apkEntity.getPackageName(), true);
|
||||
} else {
|
||||
packageNames.put(apkEntity.getPackageName(), false);
|
||||
@ -533,7 +546,7 @@ public class MainActivity extends BaseActivity {
|
||||
int quantity = 0;
|
||||
HashMap<String, Boolean> packageNames = new HashMap<>();
|
||||
for (String packageName : concernEntity.getPackageNames().keySet()) {
|
||||
if (PackageManager.isInstalled(packageName)) {
|
||||
if (PackageManager.INSTANCE.isInstalled(packageName)) {
|
||||
quantity++;
|
||||
packageNames.put(packageName, true);
|
||||
installed.add(packageName);
|
||||
@ -626,8 +639,7 @@ public class MainActivity extends BaseActivity {
|
||||
public void onResponse(GameEntity response) {
|
||||
List<GameUpdateEntity> updateList = PackageUtils.isCanUpdate(getApplication(), response);
|
||||
if (updateList.size() > 0) {
|
||||
PackageManager.addUpdateList(updateList);
|
||||
EventBus.getDefault().post(new EBDownloadStatus("update"));
|
||||
PackageManager.INSTANCE.addUpdateList(updateList);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -651,7 +663,7 @@ public class MainActivity extends BaseActivity {
|
||||
if (apkEntity.getPackageName().equals(key)
|
||||
&& !TextUtils.isEmpty(apkEntity.getGhVersion())
|
||||
&& !PackageUtils.isSignature(this, apkEntity.getPackageName())) {
|
||||
PackageManager.addUpdate(GameUtils.getGameUpdateEntity(gameEntity, apkEntity));
|
||||
PackageManager.INSTANCE.addUpdate(GameUtils.getGameUpdateEntity(gameEntity, apkEntity));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -663,7 +675,6 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
}
|
||||
EventBus.getDefault().post(new EBDownloadStatus("plugin"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -693,10 +704,9 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
mInstallManager = new InstallManager(getApplicationContext());
|
||||
|
||||
if (!isNewFirstLaunch && sp.getBoolean("autoupdate", true)) {
|
||||
// 检查助手更新
|
||||
UpdateManager.getInstance(this).checkUpdate(true, null);
|
||||
}
|
||||
// 检查助手更新
|
||||
UpdateManager.getInstance(this).checkUpdate(true, null);
|
||||
|
||||
if (isNewFirstLaunch) {
|
||||
getPluginUpdate();
|
||||
sp.edit().putBoolean("isNewFirstLaunchV" + PackageUtils.getVersionName(this), false).apply();
|
||||
@ -754,11 +764,15 @@ public class MainActivity extends BaseActivity {
|
||||
GsonUtils.Companion.getInstance().toJson(response.getSuggestion()));
|
||||
edit.apply();
|
||||
|
||||
// 设置默认社区
|
||||
if (TextUtils.isEmpty(UserManager.getInstance().getCommunityId(getApplication())) &&
|
||||
response.getCommunity() != null) {
|
||||
SettingsEntity.Community community = response.getCommunity();
|
||||
UserManager.getInstance().setCommunityId(getApplication(), community.getId(), community.getName());
|
||||
// // 设置默认社区
|
||||
// if (TextUtils.isEmpty(UserManager.getInstance().getCommunity().getId()) &&
|
||||
// response.getCommunity() != null) {
|
||||
// CommunityEntity community = response.getCommunity();
|
||||
// UserManager.getInstance().setCommunityData(community);
|
||||
// }
|
||||
|
||||
if (!sp.getBoolean("isFixDownload", false) && Config.isShow()) {
|
||||
sp.edit().putBoolean("isFixDownload", true).apply();
|
||||
}
|
||||
|
||||
EventBus.getDefault().post(new EBReuse("Refresh"));
|
||||
@ -991,7 +1005,7 @@ public class MainActivity extends BaseActivity {
|
||||
nManager.cancel(packageName.hashCode());
|
||||
|
||||
// 添加进已安装map中
|
||||
PackageManager.addInstalled(packageName);
|
||||
PackageManager.INSTANCE.addInstalled(packageName);
|
||||
|
||||
if (mDownloadEntity != null) {
|
||||
if (mDownloadEntity.isPluggable()) {
|
||||
@ -1046,9 +1060,9 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
if ("卸载".equals(busFour.getType())) {
|
||||
// 删除map中数据
|
||||
PackageManager.removeInstalled(packageName);
|
||||
PackageManager.INSTANCE.removeInstalled(packageName);
|
||||
|
||||
if (mDownloadEntity != null) {
|
||||
if (mDownloadEntity != null && mDownloadEntity.isPluggable()) {
|
||||
Map<String, Object> kv6 = new HashMap<>();
|
||||
kv6.put("安装或卸载", "卸载完成");
|
||||
DataUtils.onEvent(this, "插件化", mDownloadEntity.getName(), kv6);
|
||||
@ -1071,7 +1085,7 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
if ("卸载".equals(busFour.getType()) || "安装".equals(busFour.getType())) {
|
||||
PackageManager.removeUpdate(packageName);
|
||||
PackageManager.INSTANCE.removeUpdate(packageName);
|
||||
}
|
||||
DataCollectionUtils.uploadInorunstall(this, busFour.getType(), busFour.getPackageName());
|
||||
}
|
||||
@ -1091,8 +1105,7 @@ public class MainActivity extends BaseActivity {
|
||||
if (packageName.equals(apkEntity.getPackageName())
|
||||
&& !TextUtils.isEmpty(apkEntity.getGhVersion())
|
||||
&& !PackageUtils.isSignature(getApplicationContext(), apkEntity.getPackageName())) {
|
||||
PackageManager.addUpdate(GameUtils.getGameUpdateEntity(response, apkEntity));
|
||||
EventBus.getDefault().post(new EBDownloadStatus("plugin"));
|
||||
PackageManager.INSTANCE.addUpdate(GameUtils.getGameUpdateEntity(response, apkEntity));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1101,4 +1114,12 @@ public class MainActivity extends BaseActivity {
|
||||
});
|
||||
}
|
||||
|
||||
// 接收登录和登出更新事件统计的 Meta
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMainThread(EBReuse reuse) {
|
||||
if (reuse.getType().equals(LOGIN_TAG) || reuse.getType().equals(LOGOUT_TAG)) {
|
||||
MetaUtil.INSTANCE.refreshMeta();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
265
app/src/main/java/com/gh/gamecenter/NetworkDiagnosisActivity.kt
Normal file
265
app/src/main/java/com/gh/gamecenter/NetworkDiagnosisActivity.kt
Normal file
@ -0,0 +1,265 @@
|
||||
package com.gh.gamecenter
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Paint
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.Spanned
|
||||
import android.text.TextPaint
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.text.style.ClickableSpan
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import android.widget.ScrollView
|
||||
import android.widget.TextView
|
||||
import com.gh.base.BaseActivity
|
||||
import com.gh.common.util.CommentUtils
|
||||
import com.gh.common.util.DeviceUtils
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import kotterknife.bindView
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import rx.Observable
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
|
||||
|
||||
class NetworkDiagnosisActivity : BaseActivity() {
|
||||
|
||||
data class ProgressAndDetail(val progress: Int, val detail: String)
|
||||
|
||||
private val mResult by bindView<TextView>(R.id.network_diagnosis_result)
|
||||
private val mProgress by bindView<TextView>(R.id.network_diagnosis_progress)
|
||||
private val mWebView by bindView<WebView>(R.id.network_diagnosis_web)
|
||||
private val mScrollView by bindView<ScrollView>(R.id.network_diagnosis_scrollview)
|
||||
|
||||
private val builder = SpannableStringBuilder()
|
||||
|
||||
private val mSuccessHint = "诊断完毕。( 点击复制 )\n"
|
||||
|
||||
private var mProgressData = 0
|
||||
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.activity_network_diagnosis
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setNavigationTitle("网络诊断")
|
||||
// 5.0后,Android对WebView做了优化,此为关闭该优化
|
||||
if (android.os.Build.VERSION.SDK_INT >= 21) {
|
||||
WebView.enableSlowWholeDocumentDraw()
|
||||
}
|
||||
|
||||
Observable
|
||||
.create(Observable.OnSubscribe<ProgressAndDetail> {
|
||||
|
||||
var progress = 0
|
||||
|
||||
// 1.获取当前网络情况,network/ip/mac/sim
|
||||
|
||||
// Network 2G/3G/4G/WIFI
|
||||
builder.append("Network:")
|
||||
builder.append(DeviceUtils.getNetwork(applicationContext))
|
||||
builder.append("\n")
|
||||
|
||||
progress += 3
|
||||
it.onNext(ProgressAndDetail(progress, builder.toString()))
|
||||
|
||||
// IP
|
||||
builder.append("IP:")
|
||||
builder.append(DeviceUtils.getIPAddress(applicationContext))
|
||||
builder.append("\n")
|
||||
|
||||
progress += 3
|
||||
it.onNext(ProgressAndDetail(progress, builder.toString()))
|
||||
|
||||
// MAC
|
||||
builder.append("MAC:")
|
||||
builder.append(DeviceUtils.getMac(applicationContext))
|
||||
builder.append("\n")
|
||||
|
||||
progress += 3
|
||||
it.onNext(ProgressAndDetail(progress, builder.toString()))
|
||||
|
||||
// SIM
|
||||
builder.append("SIM:")
|
||||
builder.append(DeviceUtils.getSim(applicationContext))
|
||||
builder.append("\n")
|
||||
|
||||
progress += 3
|
||||
it.onNext(ProgressAndDetail(progress, builder.toString()))
|
||||
|
||||
builder.append("-----------------------------------------------------------------------\n")
|
||||
|
||||
// 2.ping域名
|
||||
val domains = arrayOf("api.ghzs.com", "download.ghzs.com", "apk.ghzs666.com", "image.ghzs666.com", "image.ghzhushou.com")
|
||||
for (domain in domains) {
|
||||
builder.append(DeviceUtils.ping(domain))
|
||||
builder.append("-----------------------------------------------------------------------\n")
|
||||
progress += 7
|
||||
it.onNext(ProgressAndDetail(progress, builder.toString()))
|
||||
}
|
||||
|
||||
// 3.okhttp访问链接
|
||||
val urls = arrayOf("https://api.ghzs.com/v3d3/index/columns", "https://download.ghzs.com/game?id=55097638fc1a6fa45f8b4568&platform=9u", "https://apk.ghzs666.com/packed/5af00abc02b30f7c038b456c.apk", "http://image.ghzs666.com/pic/5b29b3c92924bcaf5d438d38.jpg", "http://image.ghzhushou.com/pic/586cad378ab49e0f1b91b3e8.png")
|
||||
for (url in urls) {
|
||||
builder.append("Url:")
|
||||
builder.append(url)
|
||||
builder.append("\n")
|
||||
|
||||
val client = OkHttpClient()
|
||||
val request = Request.Builder()
|
||||
.head()
|
||||
.url(url)
|
||||
.build()
|
||||
try {
|
||||
val response = client.newCall(request).execute()
|
||||
builder.append("Success:\n")
|
||||
builder.append("Response:\n")
|
||||
builder.append(response.toString())
|
||||
builder.append("\n")
|
||||
builder.append("Response Header:\n")
|
||||
builder.append(response.headers().toString())
|
||||
builder.append("\n")
|
||||
} catch (e: IOException) {
|
||||
builder.append("Error:\n")
|
||||
builder.append(Log.getStackTraceString(e))
|
||||
}
|
||||
builder.append("-----------------------------------------------------------------------\n")
|
||||
progress += 7
|
||||
it.onNext(ProgressAndDetail(progress, builder.toString()))
|
||||
}
|
||||
|
||||
it.onCompleted()
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ProgressAndDetail>() {
|
||||
override fun onNext(response: ProgressAndDetail?) {
|
||||
mResult.text = response?.detail
|
||||
setResultProgress(response?.progress ?: 0)
|
||||
}
|
||||
|
||||
override fun onCompleted() {
|
||||
initWebView()
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun setResultProgress(progress: Int) {
|
||||
mProgress.text = "正在进行网络诊断 $progress%"
|
||||
mBaseHandler.post(Runnable {
|
||||
mScrollView.fullScroll(ScrollView.FOCUS_DOWN)
|
||||
})
|
||||
|
||||
mProgressData = progress
|
||||
}
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
fun initWebView() {
|
||||
mWebView.loadUrl("https://cdn.dns-detect.alicdn.com/https/doc.html")
|
||||
// 开启JavaScript
|
||||
mWebView.settings.javaScriptEnabled = true
|
||||
// 开启LocalStorage
|
||||
mWebView.settings.domStorageEnabled = true
|
||||
// 监听页面加载完成
|
||||
mWebView.webViewClient = object : WebViewClient() {
|
||||
override fun onPageFinished(view: WebView, url: String) {
|
||||
super.onPageFinished(view, url)
|
||||
|
||||
// 等待10秒,等待js检查完成
|
||||
view.postDelayed({
|
||||
// WebView生成长图,也就是超过一屏的图片,代码中的bitmap就是最后生成的长图
|
||||
mWebView.measure(View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED),
|
||||
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED))
|
||||
mWebView.layout(0, 0, mWebView.measuredWidth, mWebView.measuredHeight)
|
||||
mWebView.isDrawingCacheEnabled = true
|
||||
mWebView.buildDrawingCache()
|
||||
val bitmap = Bitmap.createBitmap(mWebView.measuredWidth,
|
||||
mWebView.measuredHeight, Bitmap.Config.ARGB_8888)
|
||||
|
||||
// 画布的宽高和WebView的网页保持一致
|
||||
val canvas = Canvas(bitmap)
|
||||
val paint = Paint()
|
||||
canvas.drawBitmap(bitmap, 0F, mWebView.measuredHeight.toFloat(), paint)
|
||||
mWebView.draw(canvas)
|
||||
|
||||
// 保存成文件
|
||||
val filePath = bitmap2File(bitmap)
|
||||
|
||||
// TODO upload image or copy image to share
|
||||
|
||||
builder.append("WebView Long Image Path:\n")
|
||||
builder.append(filePath)
|
||||
builder.append("\n")
|
||||
builder.append("\n")
|
||||
builder.append(mSuccessHint)
|
||||
|
||||
builder.setSpan(object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = resources.getColor(R.color.theme)
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
|
||||
override fun onClick(widget: View) {
|
||||
CommentUtils.copyText(builder.toString().replace(mSuccessHint, ""), applicationContext)
|
||||
}
|
||||
}, builder.length - mSuccessHint.length, builder.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
|
||||
mResult.text = builder
|
||||
mResult.setMovementMethod(LinkMovementMethod.getInstance())
|
||||
setResultProgress(100)
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun bitmap2File(bitmap: Bitmap): String {
|
||||
try {
|
||||
val file = File(Environment.getExternalStorageDirectory().absolutePath + "/Pictures/ghzhushou/"
|
||||
+ (UUID.randomUUID().toString().replace("-".toRegex(), ""))
|
||||
+ ".jpg"
|
||||
)
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs()
|
||||
file.createNewFile()
|
||||
}
|
||||
val fos = FileOutputStream(file)
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fos)
|
||||
fos.flush()
|
||||
fos.close()
|
||||
return file.getAbsolutePath();
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
override fun handleBackPressed(): Boolean {
|
||||
if (mProgressData < 100) {
|
||||
DialogUtils.showAlertDialog(this, "确认退出", "网络诊断还未完成,退出会终止所有诊断进程,确定退出吗?"
|
||||
,"确定", "取消", DialogUtils.ConfirmListener {
|
||||
finish()
|
||||
}, null)
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -12,12 +12,11 @@ import android.support.v4.view.MotionEventCompat;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.Window;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
@ -26,6 +25,7 @@ import com.gh.base.BaseActivity;
|
||||
import com.gh.base.OnRequestCallBackListener;
|
||||
import com.gh.common.util.ApkActiveUtils;
|
||||
import com.gh.common.util.CheckLoginUtils;
|
||||
import com.gh.common.util.ClickUtils;
|
||||
import com.gh.common.util.CollectionUtils;
|
||||
import com.gh.common.util.DataCollectionUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
@ -37,9 +37,9 @@ import com.gh.common.view.VerticalItemDecoration;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.adapter.viewholder.DetailViewHolder;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.MeEntity;
|
||||
import com.gh.gamecenter.entity.NewsDetailEntity;
|
||||
import com.gh.gamecenter.entity.NewsEntity;
|
||||
import com.gh.gamecenter.entity.UserDataEntity;
|
||||
import com.gh.gamecenter.eventbus.EBConcernChanged;
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus;
|
||||
import com.gh.gamecenter.eventbus.EBNetworkState;
|
||||
@ -47,7 +47,6 @@ import com.gh.gamecenter.eventbus.EBPackage;
|
||||
import com.gh.gamecenter.newsdetail.NewsDetailAdapter;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.jakewharton.rxbinding.view.RxView;
|
||||
import com.lightgame.download.DataWatcher;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.utils.Utils;
|
||||
@ -57,12 +56,10 @@ import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import butterknife.BindView;
|
||||
import retrofit2.HttpException;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.functions.Action1;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
|
||||
@ -88,8 +85,8 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
|
||||
@BindView(R.id.news_detail_ll_coment)
|
||||
RelativeLayout mDetailCommentLl;
|
||||
|
||||
View mNewsShare;
|
||||
ImageView mNewsCollection;
|
||||
MenuItem mNewsShare;
|
||||
MenuItem mNewsCollection;
|
||||
|
||||
private NewsDetailAdapter adapter;
|
||||
|
||||
@ -155,7 +152,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
|
||||
private DetailViewHolder getDetailViewHolder() {
|
||||
// 每次获取需要重新创建, 防止数据刷新
|
||||
return new DetailViewHolder(mContentView, gameEntity, mDownloadEntity, downloadOffText, null,
|
||||
true, mEntrance, "新闻详情", adapter.getTitle()); // 下载按钮ViewHolder
|
||||
true, mEntrance, "新闻详情", adapter.getTitle(), null); // 下载按钮ViewHolder
|
||||
}
|
||||
|
||||
/**
|
||||
@ -226,44 +223,22 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_news_detail;
|
||||
}
|
||||
// @Override
|
||||
// public boolean onCreateOptionsMenu(Menu menu) {
|
||||
//
|
||||
// getMenuInflater().inflate(R.menu.menu_share, menu);
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// return super.onOptionsItemSelected(item);
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// init toolbar
|
||||
setNavigationTitle("");
|
||||
setToolbarMenu(R.menu.menu_news_detail);
|
||||
mNewsShare = getMenuItem(R.id.menu_share);
|
||||
mNewsCollection = getMenuItem(R.id.menu_collect);
|
||||
mNewsShare.setVisible(false);
|
||||
mNewsCollection.setVisible(false);
|
||||
|
||||
mNoneDataTv.setText("页面不见咯");
|
||||
|
||||
// 增加actionBar Button
|
||||
RelativeLayout reuse_actionbar = findViewById(R.id.reuse_actionbar);
|
||||
mNewsShare = LayoutInflater.from(this).inflate(R.layout.menu_action_share, reuse_actionbar, false); // 绑定parentView 否则会丢失宽高
|
||||
mNewsShare.setVisibility(View.GONE);
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mNewsShare.getLayoutParams();
|
||||
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||
params.addRule(RelativeLayout.CENTER_VERTICAL);
|
||||
params.setMargins(0, 0, DisplayUtils.dip2px(this, 4), 0);
|
||||
reuse_actionbar.addView(mNewsShare, params);
|
||||
|
||||
mNewsCollection = (ImageView) LayoutInflater.from(this).inflate(R.layout.menu_action_collection, reuse_actionbar, false);
|
||||
mNewsCollection.setVisibility(View.GONE);
|
||||
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mNewsCollection.getLayoutParams();
|
||||
params2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||
params2.addRule(RelativeLayout.CENTER_VERTICAL);
|
||||
params2.setMargins(0, 0, params.width - DisplayUtils.dip2px(this, 7), 0);
|
||||
reuse_actionbar.addView(mNewsCollection, params2);
|
||||
|
||||
// init RecyclerView
|
||||
mDetailRv.setHasFixedSize(true);
|
||||
mDetailRv.setLayoutManager(new LinearLayoutManager(this));
|
||||
mDetailRv.addItemDecoration(new VerticalItemDecoration(this, 8, false));
|
||||
@ -283,7 +258,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
|
||||
adapter.setType(mNewsEntity.getType());
|
||||
adapter.setTitle(mNewsEntity.getTitle());
|
||||
adapter.getNewsDetail();
|
||||
mNewsShare.setVisibility(View.VISIBLE);
|
||||
mNewsShare.setVisible(true);
|
||||
}
|
||||
} else {
|
||||
getNewsDigest(newsId);
|
||||
@ -313,36 +288,79 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
|
||||
|
||||
mNoConn.setOnClickListener(this);
|
||||
mDetailCommentLl.setOnClickListener(this);
|
||||
mNewsCollection.setOnClickListener(this);
|
||||
}
|
||||
|
||||
// 防抖处理
|
||||
RxView.clicks(mNewsShare)
|
||||
.throttleFirst(1, TimeUnit.SECONDS)
|
||||
.subscribe(new Action1<Void>() {
|
||||
@Override
|
||||
public void call(Void aVoid) {
|
||||
if (adapter != null && adapter.getNewsDetailEntity() != null) {
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
kv.put("名字", adapter.getNewsDetailEntity().getTitle());
|
||||
kv.put("位置", "分享");
|
||||
DataUtils.onEvent(NewsDetailActivity.this, "点击", "新闻详情", kv);
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_share:
|
||||
if (adapter != null && adapter.getNewsDetailEntity() != null && !ClickUtils.isFastDoubleClick(R.id.menu_question_post)) {
|
||||
DataCollectionUtils.uploadClick(NewsDetailActivity.this, "分享", "新闻详情"
|
||||
, adapter.getNewsDetailEntity().getTitle());
|
||||
|
||||
DataCollectionUtils.uploadClick(NewsDetailActivity.this, "分享", "新闻详情"
|
||||
, adapter.getNewsDetailEntity().getTitle());
|
||||
String url = "http://www.ghzs666.com/article/" +
|
||||
adapter.getNewsDetailEntity().getId() + ".html";
|
||||
String shareIcon;
|
||||
if (gameEntity == null) {
|
||||
shareIcon = getString(R.string.gh_icon_url);
|
||||
} else {
|
||||
shareIcon = gameEntity.getIcon();
|
||||
}
|
||||
showShare(url, shareIcon, adapter.getNewsDetailEntity().getTitle(),
|
||||
"来自光环助手(最强卡牌神器)", ShareUtils.ShareType.news);
|
||||
}
|
||||
break;
|
||||
case R.id.menu_collect:
|
||||
CheckLoginUtils.checkLogin(this, () -> {
|
||||
final NewsDetailEntity newsDetailEntity = adapter.getNewsDetailEntity();
|
||||
mNewsCollection.setEnabled(false);
|
||||
if (newsDetailEntity.getMe() != null && newsDetailEntity.getMe().isArticleFavorite()) {
|
||||
CollectionUtils.INSTANCE.deleteCollection(NewsDetailActivity.this, mNewsEntity.getId(),
|
||||
CollectionUtils.CollectionType.article,
|
||||
new CollectionUtils.OnCollectionListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
newsDetailEntity.getMe().setArticleFavorite(false);
|
||||
mNewsCollection.setEnabled(true);
|
||||
mNewsCollection.setIcon(R.drawable.menu_ic_collect_unselect);
|
||||
toast(R.string.collection_cancel);
|
||||
}
|
||||
|
||||
String url = "http://www.ghzs666.com/article/" +
|
||||
adapter.getNewsDetailEntity().getId() + ".html";
|
||||
String shareIcon;
|
||||
if (gameEntity == null) {
|
||||
shareIcon = getString(R.string.gh_icon_url);
|
||||
} else {
|
||||
shareIcon = gameEntity.getIcon();
|
||||
}
|
||||
showShare(url, shareIcon, adapter.getNewsDetailEntity().getTitle(),
|
||||
"来自光环助手(最强卡牌神器)", ShareUtils.ShareType.news);
|
||||
}
|
||||
@Override
|
||||
public void onError() {
|
||||
mNewsCollection.setEnabled(true);
|
||||
toast(R.string.collection_cancel_failure);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
CollectionUtils.INSTANCE.postCollection(NewsDetailActivity.this, mNewsEntity.getId(),
|
||||
CollectionUtils.CollectionType.article,
|
||||
new CollectionUtils.OnCollectionListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
MeEntity userData = newsDetailEntity.getMe();
|
||||
if (userData == null) {
|
||||
userData = new MeEntity();
|
||||
newsDetailEntity.setMe(userData);
|
||||
}
|
||||
userData.setArticleFavorite(true);
|
||||
mNewsCollection.setEnabled(true);
|
||||
mNewsCollection.setIcon(R.drawable.menu_ic_collect_select);
|
||||
toast(R.string.collection_success);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
mNewsCollection.setEnabled(true);
|
||||
toast(R.string.collection_failure);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
return super.onMenuItemClick(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -405,12 +423,12 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
|
||||
|
||||
@Override
|
||||
public void loadDone() { // 通知更新收藏按钮
|
||||
mNewsCollection.setVisibility(View.VISIBLE);
|
||||
mNewsCollection.setVisible(true);
|
||||
NewsDetailEntity newsDetailEntity = adapter.getNewsDetailEntity();
|
||||
if (newsDetailEntity.getUserData() != null && newsDetailEntity.getUserData().isArticleFavorite()) {
|
||||
mNewsCollection.setImageResource(R.drawable.menu_ic_collect_select);
|
||||
if (newsDetailEntity.getMe() != null && newsDetailEntity.getMe().isArticleFavorite()) {
|
||||
mNewsCollection.setIcon(R.drawable.menu_ic_collect_select);
|
||||
} else {
|
||||
mNewsCollection.setImageResource(R.drawable.menu_ic_collect_unselect);
|
||||
mNewsCollection.setIcon(R.drawable.menu_ic_collect_unselect);
|
||||
}
|
||||
}
|
||||
|
||||
@ -462,7 +480,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
|
||||
adapter.setTitle(response.getTitle());
|
||||
adapter.getNewsDetail();
|
||||
|
||||
mNewsShare.setVisibility(View.VISIBLE);
|
||||
mNewsShare.setVisible(true);
|
||||
|
||||
DataUtils.onMtaEvent(NewsDetailActivity.this, "详情页面", "文章详情", response.getTitle());
|
||||
}
|
||||
@ -551,56 +569,6 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
|
||||
, mEntrance + "(新闻详情[" + adapter.getTitle() + "])");
|
||||
startActivity(intent);
|
||||
});
|
||||
} else if (v == mNewsCollection) {
|
||||
CheckLoginUtils.checkLogin(this, () -> {
|
||||
final NewsDetailEntity newsDetailEntity = adapter.getNewsDetailEntity();
|
||||
mNewsCollection.setEnabled(false);
|
||||
if (newsDetailEntity.getUserData() != null && newsDetailEntity.getUserData().isArticleFavorite()) {
|
||||
CollectionUtils.INSTANCE.deleteCollection(NewsDetailActivity.this, mNewsEntity.getId(),
|
||||
CollectionUtils.CollectionType.article,
|
||||
new CollectionUtils.OnCollectionListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
newsDetailEntity.getUserData().setArticleFavorite(false);
|
||||
mNewsCollection.setEnabled(true);
|
||||
mNewsCollection.setImageResource(R.drawable.menu_ic_collect_unselect);
|
||||
toast(R.string.collection_cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
mNewsCollection.setEnabled(true);
|
||||
toast(R.string.collection_cancel_failure);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
// Map<String, String> map = new HashMap<>();
|
||||
// map.put("_id", mNewsEntity.getId());
|
||||
CollectionUtils.INSTANCE.postCollection(NewsDetailActivity.this, mNewsEntity.getId(),
|
||||
CollectionUtils.CollectionType.article,
|
||||
new CollectionUtils.OnCollectionListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
UserDataEntity userData = newsDetailEntity.getUserData();
|
||||
if (userData == null) {
|
||||
userData = new UserDataEntity();
|
||||
newsDetailEntity.setUserData(userData);
|
||||
}
|
||||
userData.setArticleFavorite(true);
|
||||
mNewsCollection.setEnabled(true);
|
||||
mNewsCollection.setImageResource(R.drawable.menu_ic_collect_select);
|
||||
toast(R.string.collection_success);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
mNewsCollection.setEnabled(true);
|
||||
toast(R.string.collection_failure);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -647,10 +615,10 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
|
||||
public void onEventMainThread(EBConcernChanged changed) {
|
||||
NewsDetailEntity newsDetailEntity = adapter.getNewsDetailEntity();
|
||||
if (newsDetailEntity != null && gameEntity != null && changed.isSingle() && changed.getGameId().equals(gameEntity.getId())) {
|
||||
if (newsDetailEntity.getUserData() == null) {
|
||||
newsDetailEntity.setUserData(new UserDataEntity());
|
||||
if (newsDetailEntity.getMe() == null) {
|
||||
newsDetailEntity.setMe(new MeEntity());
|
||||
}
|
||||
newsDetailEntity.getUserData().setGameConcerned(changed.isConcern());
|
||||
newsDetailEntity.getMe().setGameConcerned(changed.isConcern());
|
||||
adapter.notifyItemChanged(1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,36 +3,19 @@ package com.gh.gamecenter;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.MenuRes;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.gamecenter.normal.NormalFragment;
|
||||
import com.gh.gamecenter.normal.ToolbarController;
|
||||
import com.lightgame.OnTitleClickListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
||||
/**
|
||||
* Created by khy on 17/10/17.
|
||||
*/
|
||||
|
||||
public abstract class NormalActivity extends BaseActivity implements ToolbarController, Toolbar.OnMenuItemClickListener {
|
||||
|
||||
@BindView(R.id.normal_toolbar)
|
||||
Toolbar mNormalToolbar;
|
||||
@BindView(R.id.normal_title)
|
||||
TextView mNormalTitle;
|
||||
public abstract class NormalActivity extends BaseActivity {
|
||||
|
||||
private Fragment mTargetFragment;
|
||||
|
||||
@ -91,22 +74,6 @@ public abstract class NormalActivity extends BaseActivity implements ToolbarCont
|
||||
}
|
||||
}
|
||||
}
|
||||
// setSupportActionBar(mNormalToolbar); // 替换actionBar后 toolBar无法控制
|
||||
mNormalToolbar.setNavigationIcon(R.drawable.ic_bar_back);
|
||||
mNormalToolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
onBackPressed();
|
||||
}
|
||||
});
|
||||
mNormalTitle.setOnClickListener(view -> {
|
||||
final List<Fragment> fragmentList = getSupportFragmentManager().getFragments();
|
||||
for (Fragment fragment : fragmentList) {
|
||||
if (fragment instanceof OnTitleClickListener) {
|
||||
((OnTitleClickListener) fragment).onTitleClick();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -131,52 +98,11 @@ public abstract class NormalActivity extends BaseActivity implements ToolbarCont
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNavigationTitle(@StringRes int res) {
|
||||
if (mNormalTitle == null) return;
|
||||
mNormalTitle.setText(res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNavigationTitle(String res) {
|
||||
if (mNormalTitle == null) return;
|
||||
if (res != null)
|
||||
mNormalTitle.setText(res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToolbarMenu(@MenuRes int res) {
|
||||
if (mNormalToolbar == null) return;
|
||||
mNormalToolbar.inflateMenu(res);
|
||||
mNormalToolbar.setOnMenuItemClickListener(this);
|
||||
|
||||
Menu menu = mNormalToolbar.getMenu();
|
||||
for (int i = 0; i < menu.size(); i++) {
|
||||
MenuItem menuItem = menu.getItem(i);
|
||||
// menu设置actionLayout后,无法捕捉点击事件,以icon为tag,如果icon is null 手动设置menuItem点击事件
|
||||
if (menuItem != null && menuItem.getIcon() == null) {
|
||||
if (menuItem.getActionView() != null) {
|
||||
menuItem.getActionView().setOnClickListener((v) -> this.onMenuItemClick(menuItem));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuItem getMenuItem(int res) {
|
||||
if (mNormalToolbar == null) return null; //后续页面做好判断
|
||||
return mNormalToolbar.getMenu().findItem(res);
|
||||
}
|
||||
|
||||
public Menu getMenu() {
|
||||
return mNormalToolbar.getMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem menuItem) {
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
if (mTargetFragment instanceof NormalFragment) {
|
||||
((NormalFragment) mTargetFragment).onMenuItemClick(menuItem);
|
||||
((NormalFragment) mTargetFragment).onMenuItemClick(item);
|
||||
}
|
||||
return false;
|
||||
return super.onMenuItemClick(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.gamecenter.ask.QuestionsEditFragment;
|
||||
import com.gh.gamecenter.ask.entity.QuestionsDetailEntity;
|
||||
|
||||
/**
|
||||
* Created by khy on 10/04/18.
|
||||
*/
|
||||
|
||||
public class QuestionEditActivity extends NormalActivity {
|
||||
|
||||
public static Intent getIntent(Context context, String searchKey) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(EntranceUtils.KEY_SEARCHKEY, searchKey);
|
||||
return getTargetIntent(context, QuestionEditActivity.class, QuestionsEditFragment.class, bundle);
|
||||
}
|
||||
|
||||
public static Intent getIntent(Context context) {
|
||||
return getTargetIntent(context, QuestionEditActivity.class, QuestionsEditFragment.class);
|
||||
}
|
||||
|
||||
public static Intent getIntent(Context context, QuestionsDetailEntity entity) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable(QuestionsDetailEntity.TAG, entity);
|
||||
return getTargetIntent(context, QuestionEditActivity.class, QuestionsEditFragment.class, bundle);
|
||||
}
|
||||
}
|
||||
@ -13,7 +13,6 @@ import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
@ -98,7 +97,8 @@ public class ReceiverWaitingActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onHandleBackPressed() {
|
||||
public void onBackPressed() {
|
||||
Utils.log("============onBackPressed");
|
||||
|
||||
unregisterReceiver(mWifiAPBroadcastReceiver);
|
||||
|
||||
@ -109,31 +109,24 @@ public class ReceiverWaitingActivity extends BaseActivity {
|
||||
if (isOpenWifi) {
|
||||
WifiMgr.getInstance(this).openWifi();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
if (item.getItemId() == R.id.menu_receive_hint) showConnHintDialog();
|
||||
return super.onMenuItemClick(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
||||
getMenuInflater().inflate(R.menu.menu_receive, menu);
|
||||
|
||||
MenuItem menuItem = menu.findItem(R.id.menu_button);
|
||||
final TextView textView = menuItem.getActionView().findViewById(R.id.tv_menu_receive);
|
||||
textView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
showConnHintDialog();
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
public int provideNavigationIcon() {
|
||||
return R.drawable.ic_filereceive_back;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setNavigationTitle(R.string.title_receive_waiting, android.R.color.white);
|
||||
setNavigationTitle(R.string.title_receive_waiting);
|
||||
|
||||
setToolbarMenu(R.menu.menu_receive);
|
||||
|
||||
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
mIsInitialized = false;
|
||||
|
||||
@ -3,15 +3,16 @@ package com.gh.gamecenter;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
@ -42,8 +43,8 @@ public class ShareCardActivity extends BaseActivity {
|
||||
ImageView mShareQrCodeDv;
|
||||
@BindView(R.id.sharecard_screenshot)
|
||||
LinearLayout mShareScreenshotLl;
|
||||
@BindView(R.id.reuse_actionbar)
|
||||
RelativeLayout mActionbar;
|
||||
@BindView(R.id.normal_toolbar_container)
|
||||
View mActionbar;
|
||||
@BindView(R.id.sharecard_bottom)
|
||||
LinearLayout mShareBottomLl;
|
||||
String gameName;
|
||||
@ -85,6 +86,7 @@ public class ShareCardActivity extends BaseActivity {
|
||||
picName = "shareImg.jpg";
|
||||
|
||||
setNavigationTitle(getString(R.string.title_share_card));
|
||||
((TextView) findViewById(R.id.normal_title)).setTextColor(Color.WHITE);
|
||||
|
||||
//修改沉浸栏以及ActionBar 颜色
|
||||
mActionbar.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), android.R.color.black));
|
||||
|
||||
@ -10,6 +10,7 @@ import android.os.Bundle;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
@ -61,8 +62,8 @@ public class ShareCardPicActivity extends BaseActivity {
|
||||
SimpleDraweeView mShareContentImgRv;
|
||||
@BindView(R.id.sharecard_screenshot)
|
||||
ScrollView mShareScreenshotRl;
|
||||
@BindView(R.id.reuse_actionbar)
|
||||
RelativeLayout mActionbar;
|
||||
@BindView(R.id.normal_toolbar_container)
|
||||
View mActionbar;
|
||||
@BindView(R.id.sharecard_chang_img)
|
||||
RelativeLayout mShareChangImageRl;
|
||||
@BindView(R.id.sharecard_share_btn)
|
||||
@ -133,6 +134,7 @@ public class ShareCardPicActivity extends BaseActivity {
|
||||
currentImgPosition = 0;
|
||||
|
||||
setNavigationTitle(getString(R.string.title_share_card_pic));
|
||||
((TextView) findViewById(R.id.normal_title)).setTextColor(Color.WHITE);
|
||||
|
||||
shareArrImg = new Vector<>();
|
||||
if (arrImg != null) shareArrImg.addAll(arrImg);
|
||||
|
||||
@ -91,7 +91,7 @@ public class ShareGhWfifActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onHandleBackPressed() {
|
||||
public void onBackPressed() {
|
||||
DialogUtils.showWarningDialog(this, "退出分享", "退出本页面即会关闭分享热点,确定退出吗?"
|
||||
, "取消", "确定"
|
||||
, new DialogUtils.ConfirmListener() {
|
||||
@ -131,7 +131,6 @@ public class ShareGhWfifActivity extends BaseActivity {
|
||||
finish();
|
||||
}
|
||||
}, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -8,6 +8,8 @@ import android.text.TextUtils;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.gamecenter.qa.answer.detail.AnswerDetailActivity;
|
||||
import com.gh.gamecenter.qa.questions.detail.QuestionsDetailActivity;
|
||||
import com.lightgame.config.CommonDebug;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
|
||||
@ -27,6 +27,8 @@ import com.gh.common.util.TimestampUtils;
|
||||
import com.gh.common.util.TokenUtils;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.manager.FilterManager;
|
||||
import com.gh.gamecenter.room.AppDatabase;
|
||||
import com.gh.gamecenter.user.UserRepository;
|
||||
import com.lightgame.download.FileUtils;
|
||||
import com.lightgame.utils.AppManager;
|
||||
import com.lightgame.utils.Utils;
|
||||
@ -88,6 +90,8 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
UserRepository.getInstance(AppDatabase.getInstance(getApplication()), getApplication()); // 初始化登录
|
||||
|
||||
// if (!AppManager.getInstance().isEmpty()) {
|
||||
// redirectAndFinish(getRedirectIntents(this, getIntent().getData()));
|
||||
// return;
|
||||
|
||||
@ -7,6 +7,7 @@ import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
@ -189,6 +190,7 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
mAdapter.addFileList(picturePath);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException e) {
|
||||
mAdapter.addFileList(picturePath);
|
||||
@ -235,6 +237,7 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
|
||||
if (!TextUtils.isEmpty(suggestContent)) {
|
||||
mSuggestContentEt.setText(suggestContent);
|
||||
mSuggestContentEt.setSelection(mSuggestContentEt.getText().length());
|
||||
}
|
||||
|
||||
initSuggest(curType);
|
||||
@ -273,7 +276,7 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
showHintDialog(service);
|
||||
}
|
||||
break;
|
||||
case "report" :
|
||||
case "report":
|
||||
List<String> report = typeEntity.getReport();
|
||||
if (report != null && report.size() > 0) {
|
||||
showHintDialog(report);
|
||||
@ -287,6 +290,11 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
if (userInfo != null && !TextUtils.isEmpty(userInfo.getContact())) {
|
||||
mSuggestEmailEt.setText(userInfo.getContact());
|
||||
}
|
||||
|
||||
mSuggestContentEt.setFocusable(true);
|
||||
mSuggestContentEt.setFocusableInTouchMode(true);
|
||||
mSuggestContentEt.requestFocus();
|
||||
Util_System_Keyboard.showSoftKeyboard(this, mSuggestContentEt);
|
||||
}
|
||||
|
||||
private void initSuggest(int type) {
|
||||
@ -359,6 +367,7 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
public void onClick(View v) {
|
||||
dialog.cancel();
|
||||
mSuggestContentEt.setText(mSuggestContentEt.getText().toString() + reportTv.getText().toString());
|
||||
mSuggestContentEt.setSelection(mSuggestContentEt.getText().length());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -399,6 +408,7 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
switch (view.getId()) {
|
||||
case R.id.suggest_post_btn:
|
||||
if (TextUtils.isEmpty(mSuggestContentEt.getText().toString())) {
|
||||
toast("请输入反馈内容");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -525,6 +535,7 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
params.put("version", android.os.Build.VERSION.RELEASE);
|
||||
params.put("source", getString(R.string.app_name));
|
||||
params.put("imei", Util_System_Phone_State.getDeviceId(this));
|
||||
params.put("manufacturer", Build.MANUFACTURER);
|
||||
|
||||
if ((curType == 6 || curType == 5) && !TextUtils.isEmpty(mSuggestNewsLinkEt.getText().toString())) {
|
||||
params.put("url", mSuggestNewsLinkEt.getText().toString().trim());
|
||||
|
||||
@ -5,7 +5,7 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.gh.gamecenter.login.UserViewModel;
|
||||
import com.gh.gamecenter.user.UserViewModel;
|
||||
import com.halo.assistant.fragment.user.UserInfoEditFragment;
|
||||
|
||||
/**
|
||||
|
||||
@ -13,7 +13,6 @@ import android.widget.LinearLayout;
|
||||
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.DataCollectionUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.NewsUtils;
|
||||
import com.gh.common.util.StringUtils;
|
||||
@ -32,9 +31,7 @@ import com.lightgame.adapter.BaseRecyclerAdapter;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import retrofit2.HttpException;
|
||||
import rx.Observable;
|
||||
@ -206,11 +203,6 @@ public class GameNewsAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
kv.put("名字", newsEntity.getTitle());
|
||||
kv.put("位置", String.valueOf(viewHolder.getPosition() + 1));
|
||||
DataUtils.onEvent(mContext, "点击", "游戏新闻列表", kv);
|
||||
|
||||
DataCollectionUtils.uploadClick(mContext, mNewsType, "游戏新闻列表", newsEntity.getTitle());
|
||||
|
||||
// 统计阅读量
|
||||
|
||||
@ -22,9 +22,7 @@ import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.SubjectActivity;
|
||||
import com.gh.gamecenter.entity.SlideEntity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ImagePagerAdapter
|
||||
@ -40,13 +38,16 @@ public class ImagePagerAdapter extends RecyclingPagerAdapter {
|
||||
private int mSize;
|
||||
private boolean mIsInfiniteLoop;
|
||||
|
||||
private String mSource;
|
||||
|
||||
// private ImageIndicator indicator;
|
||||
|
||||
public ImagePagerAdapter(Context context, List<SlideEntity> slideEntityList, boolean isInfiniteLoop) {
|
||||
public ImagePagerAdapter(Context context, List<SlideEntity> slideEntityList, boolean isInfiniteLoop, String source) {
|
||||
mContext = context;
|
||||
mSlideEntityList = slideEntityList;
|
||||
mSize = getSize(slideEntityList);
|
||||
mIsInfiniteLoop = isInfiniteLoop;
|
||||
mSource = source;
|
||||
}
|
||||
|
||||
public int getSize(List<SlideEntity> sourceList) {
|
||||
@ -65,7 +66,10 @@ public class ImagePagerAdapter extends RecyclingPagerAdapter {
|
||||
view = new SimpleDraweeView(mContext);
|
||||
}
|
||||
|
||||
final SlideEntity slideEntity = mSlideEntityList.get(getPosition(position));
|
||||
int index = getPosition(position);
|
||||
if (index >= mSlideEntityList.size()) return view;
|
||||
|
||||
final SlideEntity slideEntity = mSlideEntityList.get(index);
|
||||
|
||||
ImageUtils.Companion.getInstance().display(mContext.getResources(), (SimpleDraweeView) view,
|
||||
slideEntity.getImage(), R.drawable.preload);
|
||||
@ -76,11 +80,6 @@ public class ImagePagerAdapter extends RecyclingPagerAdapter {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
kv.put("名字", slideEntity.getName());
|
||||
kv.put("位置", getPosition(position) + 1);
|
||||
DataUtils.onEvent(mContext, "点击", "游戏-专题-滚动图", kv);
|
||||
|
||||
// 首页轮播图数据统计
|
||||
DataLogUtils.uploadLunbotuLog(mContext, slideEntity.getType(),
|
||||
slideEntity.getName(), String.valueOf(getPosition(position) + 1));
|
||||
@ -91,6 +90,8 @@ public class ImagePagerAdapter extends RecyclingPagerAdapter {
|
||||
, "=", String.valueOf(getPosition(position) + 1)
|
||||
, "])");
|
||||
|
||||
DataUtils.onMtaEvent(mContext, "轮播图", mSource, String.valueOf(position));
|
||||
|
||||
switch (slideEntity.getType()) {
|
||||
case "game":
|
||||
GameDetailActivity.startGameDetailActivity(mContext, slideEntity.getLink(), entrance);
|
||||
@ -139,4 +140,12 @@ public class ImagePagerAdapter extends RecyclingPagerAdapter {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void checkResetData(List<SlideEntity> list) {
|
||||
if (mSlideEntityList != list) {
|
||||
mSlideEntityList = list;
|
||||
mSize = getSize(list);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -8,7 +8,6 @@ import android.graphics.drawable.Drawable;
|
||||
import android.preference.PreferenceManager;
|
||||
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;
|
||||
@ -17,7 +16,6 @@ import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.common.util.ApkActiveUtils;
|
||||
import com.gh.common.util.BitmapUtils;
|
||||
import com.gh.common.util.DataCollectionUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.DownloadItemUtils;
|
||||
import com.gh.common.util.GameViewUtils;
|
||||
@ -49,7 +47,6 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -242,7 +239,7 @@ public class InstallFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
for (String id : ids) {
|
||||
sequences.add(RetrofitManager.getInstance(mContext).getApi().getGameDigest(id));
|
||||
}
|
||||
Observable.merge(sequences)
|
||||
Observable.mergeDelayError(sequences)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<GameEntity>() {
|
||||
@ -251,6 +248,11 @@ public class InstallFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
processingData(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
processingData(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GameEntity response) {
|
||||
ApkActiveUtils.filterHideApk(response);
|
||||
@ -399,33 +401,22 @@ public class InstallFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
|
||||
holder.swipeText.setPadding(0, 0, DisplayUtils.dip2px(mContext, 15), 0);
|
||||
|
||||
ImageUtils.Companion.display(holder.gameThumb, gameEntity.getIcon());
|
||||
|
||||
if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()
|
||||
|| gameEntity.getTag() == null || gameEntity.getTag().isEmpty()) {
|
||||
if (gameEntity.getApk() != null && gameEntity.getApk().size() > 0
|
||||
&& !TextUtils.isEmpty(gameEntity.getApk().get(0).getVersion())) {
|
||||
holder.gameDes.setText(String.format("V%s", gameEntity.getApk().get(0).getVersion()));
|
||||
} else {
|
||||
holder.gameDes.setText(gameEntity.getBrief());
|
||||
}
|
||||
holder.gameName.setText(gameEntity.getName());
|
||||
} else {
|
||||
if (gameEntity.getApk().size() > 0) {
|
||||
holder.gameThumb.setImageDrawable(PackageUtils.getIconByPackage(mContext, gameEntity.getApk().get(0).getPackageName()));
|
||||
holder.gameName.setText(String.format("%s - %s", gameEntity.getName(),
|
||||
PlatformUtils.getInstance(mContext).getPlatformName(gameEntity.getApk().get(0).getPlatform())));
|
||||
holder.gameDes.setText(String.format("V%s", gameEntity.getApk().get(0).getVersion()));
|
||||
holder.gameDes.setText(String.format("V%s", PackageUtils.getVersionByPackage(mContext, gameEntity.getApk().get(0).getPackageName())));
|
||||
} else {
|
||||
ImageUtils.Companion.display(holder.gameThumb, gameEntity.getIcon());
|
||||
holder.gameName.setText(gameEntity.getName());
|
||||
holder.gameDes.setText(gameEntity.getBrief());
|
||||
}
|
||||
GameViewUtils.setLabelList(mContext, holder.gameLabelList, gameEntity.getTag(), "");
|
||||
GameViewUtils.setLabelList(mContext, holder.gameLabelList, gameEntity.getTag(), "", gameEntity.getTagStyle());
|
||||
|
||||
holder.cardView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!isSwipe) {
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
kv.put("名字", gameEntity.getName());
|
||||
kv.put("位置", String.valueOf(holder.getPosition() + 1));
|
||||
DataUtils.onEvent(mContext, "点击", "我的光环-我的游戏", kv);
|
||||
|
||||
DataCollectionUtils.uploadClick(mContext, "列表", "我的光环-我的游戏", gameEntity.getName());
|
||||
|
||||
GameDetailActivity.startGameDetailActivity(mContext, gameEntity.getId(), "(我的光环:我的游戏)");
|
||||
@ -521,6 +512,7 @@ public class InstallFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
|
||||
public interface onSmoothLayoutListener {
|
||||
void onSmooth();
|
||||
|
||||
void onOpen(); // 启动跳转
|
||||
}
|
||||
|
||||
|
||||
@ -368,7 +368,7 @@ public class KcSelectGameAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
if (count == 0) {
|
||||
mSelectCount.setText(R.string.kc_send);
|
||||
} else {
|
||||
mSelectCount.setText(mContext.getString(R.string.kc_installed_count, count));
|
||||
mSelectCount.setText("发送(" + count + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ import com.gh.gamecenter.adapter.viewholder.LibaoDetailTopViewHolder;
|
||||
import com.gh.gamecenter.entity.LibaoDetailEntity;
|
||||
import com.gh.gamecenter.entity.LibaoEntity;
|
||||
import com.gh.gamecenter.entity.LibaoStatusEntity;
|
||||
import com.gh.gamecenter.entity.UserDataEntity;
|
||||
import com.gh.gamecenter.entity.MeEntity;
|
||||
import com.gh.gamecenter.entity.UserDataLibaoEntity;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
@ -69,7 +69,7 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
mEntrance = entrance;
|
||||
}
|
||||
|
||||
public void addLibaoDetail(Context context) {
|
||||
public void addLibaoDetail(Context context, boolean isExistGameData) {
|
||||
RetrofitManager.getInstance(context).getApi().getLibaoDetail(mLibaoEntity.getId())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -77,13 +77,17 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
@Override
|
||||
public void onResponse(LibaoDetailEntity response) {
|
||||
mLibaoDetailEntity = response;
|
||||
UserDataEntity userData = response.getUserData();
|
||||
if (mLibaoEntity.isActive()) { // 以active判断礼包入口 true 为存号箱入口
|
||||
// 合并userData数据
|
||||
mLibaoEntity.setUserData(userData);
|
||||
if (isExistGameData) {
|
||||
MeEntity userData = response.getMe();
|
||||
if (mLibaoEntity.isActive()) { // 以active判断礼包入口 true 为存号箱入口
|
||||
// 合并userData数据
|
||||
mLibaoEntity.setMe(userData);
|
||||
}
|
||||
mOnRequestCallBackListener.loadDone(); // 回调 检查领取状态(是否可以重复领取/重复淘号)
|
||||
notifyDataSetChanged();
|
||||
} else {
|
||||
mOnRequestCallBackListener.loadEmpty();
|
||||
}
|
||||
mOnRequestCallBackListener.loadDone(); // 回调 检查领取状态(是否可以重复领取/重复淘号)
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -178,9 +182,9 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
}
|
||||
|
||||
//已领取或已淘号
|
||||
if (mLibaoEntity.getUserData() != null && mLibaoEntity.getUserData().getUserDataLibaoList() != null
|
||||
&& mLibaoEntity.getUserData().getUserDataLibaoList().size() > 0) {
|
||||
List<UserDataLibaoEntity> userDataLibaoList = mLibaoEntity.getUserData().getUserDataLibaoList();
|
||||
if (mLibaoEntity.getMe() != null && mLibaoEntity.getMe().getUserDataLibaoList() != null
|
||||
&& mLibaoEntity.getMe().getUserDataLibaoList().size() > 0) {
|
||||
List<UserDataLibaoEntity> userDataLibaoList = mLibaoEntity.getMe().getUserDataLibaoList();
|
||||
LibaoUtils.initLibaoBtn(mContext, holder.libaoCopyBtn, mLibaoEntity,
|
||||
mLibaoDetailEntity.getInstallRequired(), this,
|
||||
StringUtils.buildString(mEntrance, "+(礼包详情[", mLibaoEntity.getName(), "])"));
|
||||
@ -245,7 +249,7 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
|
||||
if (mLibaoEntity.getContent() != null) {
|
||||
holder.mLibaodetailContentLl.setVisibility(View.VISIBLE);
|
||||
holder.mLibaodetailContent.setText(mLibaoEntity.getContent());
|
||||
holder.mLibaodetailContent.setText(Html.fromHtml(mLibaoEntity.getContent()));
|
||||
}
|
||||
if (mLibaoDetailEntity != null) {
|
||||
holder.mLibaodetailTimeLl.setVisibility(View.VISIBLE);
|
||||
@ -284,11 +288,15 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
mLibaoEntity = libaoEntity;
|
||||
}
|
||||
|
||||
public LibaoDetailEntity getLibaoDetailEntity() {
|
||||
return mLibaoDetailEntity;
|
||||
}
|
||||
|
||||
public void initLibaoCode(UserDataLibaoEntity userDataLibaoEntity) {
|
||||
UserDataEntity userData = mLibaoEntity.getUserData();
|
||||
MeEntity userData = mLibaoEntity.getMe();
|
||||
if (userData == null) {
|
||||
userData = new UserDataEntity();
|
||||
mLibaoEntity.setUserData(userData);
|
||||
userData = new MeEntity();
|
||||
mLibaoEntity.setMe(userData);
|
||||
}
|
||||
|
||||
List<UserDataLibaoEntity> userDataLibaoList = userData.getUserDataLibaoList();
|
||||
|
||||
@ -14,7 +14,6 @@ import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.CommentUtils;
|
||||
import com.gh.common.util.ConcernContentUtils;
|
||||
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.ImageUtils;
|
||||
@ -44,10 +43,8 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
@ -307,10 +304,6 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
kv.put("名字", mConcernEntity.getTitle());
|
||||
DataUtils.onEvent(mContext, "点击", "消息详情", kv);
|
||||
|
||||
DataCollectionUtils.uploadClick(mContext, "详情", "消息详情", mConcernEntity.getTitle());
|
||||
|
||||
// 统计阅读量
|
||||
|
||||
@ -2,14 +2,13 @@ package com.gh.gamecenter.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ClipDrawable;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.os.Build;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.text.TextUtils;
|
||||
import android.util.SparseArray;
|
||||
@ -18,7 +17,10 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.common.exposure.ExposureEvent;
|
||||
import com.gh.common.exposure.ExposureUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DeviceUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
@ -26,18 +28,21 @@ import com.gh.common.util.NetworkUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.DownloadManagerActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.VoteActivity;
|
||||
import com.gh.gamecenter.adapter.viewholder.PlatformViewHolder;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.CollectionColseEntity;
|
||||
import com.gh.gamecenter.entity.CollectionCloseEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.manager.PackageManager;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.download.DownloadStatus;
|
||||
import com.lightgame.download.FileUtils;
|
||||
import com.lightgame.utils.Util_System_Phone_State;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -49,17 +54,18 @@ import java.util.Map;
|
||||
*/
|
||||
public class PlatformAdapter extends BaseRecyclerAdapter<PlatformViewHolder> {
|
||||
|
||||
private OnCollectionCallBackListener mOnCollectionCallBackListener;
|
||||
private OnCollectionCallBackListener mOnCollectionCallBackListener; // 为空则是合集ViewPager
|
||||
|
||||
private List<ApkEntity> mPlatformList;
|
||||
private ArrayMap<String, DownloadEntity> mEntryMap;
|
||||
private SparseArray<PlatformAdapter> mAdapterMap;
|
||||
|
||||
private GameEntity mGameEntity;
|
||||
private CollectionColseEntity mCloseEntity;
|
||||
private CollectionCloseEntity mCloseEntity;
|
||||
|
||||
private String mEntrance;
|
||||
private String mLocation;
|
||||
private ExposureEvent mTraceEvent;
|
||||
|
||||
private int mAdapterPosition;
|
||||
private int mCount;
|
||||
@ -67,13 +73,11 @@ public class PlatformAdapter extends BaseRecyclerAdapter<PlatformViewHolder> {
|
||||
private final int mColumn = 3;
|
||||
|
||||
public PlatformAdapter(Context context, OnCollectionCallBackListener listener, GameEntity gameEntity,
|
||||
CollectionColseEntity closeEntity, ArrayMap<String, DownloadEntity> eMap,
|
||||
CollectionCloseEntity closeEntity, ArrayMap<String, DownloadEntity> eMap,
|
||||
SparseArray<PlatformAdapter> aMap, List<ApkEntity> list, String entrance, String location,
|
||||
int position) {
|
||||
int position, ExposureEvent traceEvent) {
|
||||
super(context);
|
||||
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
|
||||
mOnCollectionCallBackListener = listener;
|
||||
mGameEntity = gameEntity;
|
||||
mCloseEntity = closeEntity;
|
||||
@ -83,6 +87,7 @@ public class PlatformAdapter extends BaseRecyclerAdapter<PlatformViewHolder> {
|
||||
mEntrance = entrance;
|
||||
mLocation = location;
|
||||
mAdapterPosition = position;
|
||||
mTraceEvent = traceEvent;
|
||||
if (mPlatformList.size() <= (mRow * mColumn)) {
|
||||
mCount = mPlatformList.size();
|
||||
} else if (mPlatformList.size() - (mRow * mColumn) * mAdapterPosition >= (mRow * mColumn)) {
|
||||
@ -130,12 +135,7 @@ public class PlatformAdapter extends BaseRecyclerAdapter<PlatformViewHolder> {
|
||||
if (NetworkUtils.isWifiConnected(mContext)) {
|
||||
download(apkEntity, viewHolder.mDownloadItemTvStatus, "下载");
|
||||
} else {
|
||||
DialogUtils.showDownloadDialog(mContext, new DialogUtils.ConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
download(apkEntity, viewHolder.mDownloadItemTvStatus, "下载");
|
||||
}
|
||||
});
|
||||
DialogUtils.showDownloadDialog(mContext, () -> download(apkEntity, viewHolder.mDownloadItemTvStatus, "下载"));
|
||||
}
|
||||
} else {
|
||||
String status = viewHolder.mDownloadItemTvStatus.getText().toString();
|
||||
@ -147,6 +147,7 @@ public class PlatformAdapter extends BaseRecyclerAdapter<PlatformViewHolder> {
|
||||
mContext.startActivity(DownloadManagerActivity.getDownloadMangerIntent(mContext, apkEntity.getUrl()
|
||||
, mEntrance + "(" + mLocation.split(":")[0] + ")"));
|
||||
break;
|
||||
case "已安装":
|
||||
case "启动":
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
kv.put("版本", apkEntity.getPlatform());
|
||||
@ -162,12 +163,7 @@ public class PlatformAdapter extends BaseRecyclerAdapter<PlatformViewHolder> {
|
||||
if (NetworkUtils.isWifiConnected(mContext)) {
|
||||
download(apkEntity, viewHolder.mDownloadItemTvStatus, "插件化");
|
||||
} else {
|
||||
DialogUtils.showDownloadDialog(mContext, new DialogUtils.ConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
download(apkEntity, viewHolder.mDownloadItemTvStatus, "插件化");
|
||||
}
|
||||
});
|
||||
DialogUtils.showDownloadDialog(mContext, () -> download(apkEntity, viewHolder.mDownloadItemTvStatus, "插件化"));
|
||||
}
|
||||
break;
|
||||
case "安装插件":
|
||||
@ -177,12 +173,7 @@ public class PlatformAdapter extends BaseRecyclerAdapter<PlatformViewHolder> {
|
||||
if (NetworkUtils.isWifiConnected(mContext)) {
|
||||
update(apkEntity);
|
||||
} else {
|
||||
DialogUtils.showDownloadDialog(mContext, new DialogUtils.ConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
update(apkEntity);
|
||||
}
|
||||
});
|
||||
DialogUtils.showDownloadDialog(mContext, () -> update(apkEntity));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -191,7 +182,7 @@ public class PlatformAdapter extends BaseRecyclerAdapter<PlatformViewHolder> {
|
||||
});
|
||||
|
||||
Object gh_id = PackageUtils.getMetaData(mContext, apkEntity.getPackageName(), "gh_id");
|
||||
if (PackageManager.isInstalled(apkEntity.getPackageName())
|
||||
if (PackageManager.INSTANCE.isInstalled(apkEntity.getPackageName())
|
||||
&& (gh_id == null || gh_id.equals(mGameEntity.getId()))) {
|
||||
// 已安装
|
||||
viewHolder.mDownloadItemIvPic.setVisibility(View.GONE);
|
||||
@ -226,10 +217,14 @@ public class PlatformAdapter extends BaseRecyclerAdapter<PlatformViewHolder> {
|
||||
viewHolder.itemView.setClickable(false);
|
||||
viewHolder.mDownloadItemProgressbar.setProgress(0);
|
||||
}
|
||||
} else if (PackageManager.isCanUpdate(mGameEntity.getId(), apkEntity.getPackageName())) {
|
||||
} else if (PackageManager.INSTANCE.isCanUpdate(mGameEntity.getId(), apkEntity.getPackageName())) {
|
||||
viewHolder.mDownloadItemTvStatus.setText(R.string.update);
|
||||
} else {
|
||||
viewHolder.mDownloadItemTvStatus.setText(R.string.launch);
|
||||
if (mOnCollectionCallBackListener == null) {
|
||||
viewHolder.mDownloadItemTvStatus.setText("已安装");
|
||||
} else {
|
||||
viewHolder.mDownloadItemTvStatus.setText(R.string.launch);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
viewHolder.mDownloadItemProgressbar.setProgress((int) (downloadEntity.getPercent() * 10));
|
||||
@ -361,35 +356,33 @@ public class PlatformAdapter extends BaseRecyclerAdapter<PlatformViewHolder> {
|
||||
public void download(ApkEntity apkEntity, TextView mDownloadItemTvStatus, String method) {
|
||||
String msg = FileUtils.isCanDownload(mContext, apkEntity.getSize());
|
||||
if (TextUtils.isEmpty(msg)) {
|
||||
String platform = PlatformUtils.getInstance(HaloApp.getInstance().getApplication()).getPlatformName(apkEntity.getPlatform());
|
||||
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
kv.put("版本", apkEntity.getPlatform());
|
||||
kv.put("版本", platform);
|
||||
kv.put("状态", "下载开始");
|
||||
kv.put("用户机型", Build.MODEL);
|
||||
kv.put("设备IMEI", Util_System_Phone_State.getDeviceId(HaloApp.getInstance().getApplication()));
|
||||
kv.put("网络状态", DeviceUtils.getNetwork(HaloApp.getInstance().getApplication()));
|
||||
kv.put("光环助手版本", BuildConfig.VERSION_NAME);
|
||||
DataUtils.onEvent(mContext, "游戏下载", mGameEntity.getName(), kv);
|
||||
|
||||
Map<String, Object> kv2 = new HashMap<>();
|
||||
kv2.put("版本", apkEntity.getPlatform());
|
||||
kv2.put("状态", "下载开始");
|
||||
kv2.put("位置", mEntrance + "-开始");
|
||||
kv2.put("游戏分平台", mGameEntity.getName() + "-" + platform);
|
||||
kv2.put("光环助手版本", BuildConfig.VERSION_NAME);
|
||||
DataUtils.onEvent(mContext, "游戏下载位置", mGameEntity.getName(), kv2);
|
||||
|
||||
Map<String, Object> kv3 = new HashMap<>();
|
||||
kv3.put(mEntrance, "下载数");
|
||||
kv3.put(mEntrance, "下载开始");
|
||||
DataUtils.onEvent(mContext, "应用数据", mGameEntity.getName(), kv3);
|
||||
|
||||
if (mEntrance.contains("游戏详情")) {
|
||||
Map<String, Object> kv5 = new HashMap<>();
|
||||
kv5.put("下载", "下载开始");
|
||||
kv5.put("下载", apkEntity.getPlatform());
|
||||
DataUtils.onEvent(mContext, "插件数据", mGameEntity.getName(), kv5);
|
||||
}
|
||||
|
||||
Map<String, Object> kv6 = new HashMap<>();
|
||||
kv6.put("下载", "下载开始");
|
||||
kv6.put("版本", apkEntity.getPlatform());
|
||||
DataUtils.onEvent(mContext, "插件化", mGameEntity.getName(), kv6);
|
||||
|
||||
DownloadManager.createDownload(mContext, apkEntity, mGameEntity, method, mEntrance, mLocation);
|
||||
ExposureEvent downloadExposureEvent = ExposureUtils.INSTANCE.logADownloadExposureEvent(mGameEntity, apkEntity.getPlatform(), mTraceEvent, ExposureUtils.DownloadType.PLUGIN_DOWNLOAD);
|
||||
|
||||
DownloadManager.createDownload(mContext, apkEntity, mGameEntity, method, mEntrance, mLocation, downloadExposureEvent);
|
||||
// DownloadManager.getInstance(mContext).putStatus(apkEntity.getUrl(), "downloading");
|
||||
|
||||
mDownloadItemTvStatus.setText("0.0%");
|
||||
@ -451,7 +444,9 @@ public class PlatformAdapter extends BaseRecyclerAdapter<PlatformViewHolder> {
|
||||
kv.put("状态", "下载开始");
|
||||
DataUtils.onEvent(mContext, "游戏更新", mGameEntity.getName(), kv);
|
||||
|
||||
DownloadManager.createDownload(mContext, apkEntity, mGameEntity, "更新", mEntrance, mLocation);
|
||||
ExposureEvent downloadExposureEvent = ExposureUtils.INSTANCE.logADownloadExposureEvent(mGameEntity, apkEntity.getPlatform(), mTraceEvent, ExposureUtils.DownloadType.PLUGIN_UPDATE);
|
||||
|
||||
DownloadManager.createDownload(mContext, apkEntity, mGameEntity, "更新", mEntrance, mLocation, downloadExposureEvent);
|
||||
}
|
||||
|
||||
private GradientDrawable getGradientDrawable(int color) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user