Compare commits

..

12 Commits
v2.4 ... v2.5

394 changed files with 19824 additions and 6079 deletions

13
.gitignore vendored
View File

@ -1,9 +1,8 @@
/.idea
.idea/misc.xml
.idea/
*.iml
.gradle
/local.properties
.gradle/
local.properties
# sign.properties
.DS_Store
/build
/captures
/PushSDK/build
captures/
build/

View File

@ -1,51 +0,0 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 11
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}

View File

@ -1,156 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.umeng.message.lib.test" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="22" />
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:functionalTest="false"
android:handleProfiling="false"
android:label="Tests for com.umeng.message.lib.test"
android:targetPackage="com.umeng.message.lib.test" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_ADDED" />
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_CHANGED" />
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_INSTALL" />
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_REPLACED" />
<uses-permission android:name="android.permission.RESTART_PACKAGES" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<application>
<uses-library android:name="android.test.runner" />
<service
android:name="com.taobao.accs.ChannelService"
android:exported="true"
android:process=":channel" >
<intent-filter>
<action android:name="com.taobao.accs.intent.action.SERVICE" />
</intent-filter>
<intent-filter>
<action android:name="com.taobao.accs.intent.action.ELECTION" />
</intent-filter>
</service>
<service
android:name="com.taobao.accs.data.MsgDistributeService"
android:exported="true" >
<intent-filter>
<action android:name="com.taobao.accs.intent.action.RECEIVE" />
</intent-filter>
</service>
<receiver
android:name="com.taobao.accs.EventReceiver"
android:process=":channel" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver
android:name="com.taobao.accs.ServiceReceiver"
android:exported="false"
android:process=":channel" >
<intent-filter>
<action android:name="com.taobao.accs.intent.action.COMMAND" />
</intent-filter>
<intent-filter>
<action android:name="com.taobao.accs.intent.action.START_FROM_AGOO" />
</intent-filter>
</receiver>
<service
android:name="com.taobao.accs.ChannelService$KernelService"
android:process=":channel" >
</service>
<service
android:name="org.android.agoo.accs.AgooService"
android:exported="true" >
<intent-filter>
<action android:name="com.taobao.accs.intent.action.RECEIVE" />
</intent-filter>
</service>
<service
android:name="com.umeng.message.UmengIntentService"
android:exported="true"
android:process=":channel" >
<intent-filter>
<action android:name="org.agoo.android.intent.action.RECEIVE" />
</intent-filter>
</service>
<receiver
android:name="com.taobao.agoo.AgooCommondReceiver"
android:exported="true" >
<intent-filter>
<action android:name="com.gh.gamecenter.intent.action.COMMAND" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
<receiver
android:name="com.umeng.message.NotificationProxyBroadcastReceiver"
android:exported="false" />
<service
android:name="com.umeng.message.UmengMessageCallbackHandlerService"
android:exported="false" >
<intent-filter>
<action android:name="com.umeng.messge.registercallback.action" />
</intent-filter>
<intent-filter>
<action android:name="com.umeng.message.enablecallback.action" />
</intent-filter>
<intent-filter>
<action android:name="com.umeng.message.disablecallback.action" />
</intent-filter>
<intent-filter>
<action android:name="com.umeng.message.message.handler.action" />
</intent-filter>
</service>
<service
android:name="com.umeng.message.UmengDownloadResourceService"
android:exported="false" />
<service
android:name="com.umeng.message.UmengMessageIntentReceiverService"
android:exported="true"
android:process=":channel" >
<intent-filter>
<action android:name="org.android.agoo.client.MessageReceiverService" />
</intent-filter>
</service>
<provider
android:name="com.umeng.message.provider.MessageProvider"
android:authorities="com.gh.gamecenter.umeng.message"
android:exported="false" >
<grant-uri-permission android:pathPattern=".*" />
</provider>
</application>
</manifest>

View File

@ -1,12 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-19
android.library=true

4
README.md Normal file
View File

@ -0,0 +1,4 @@
# 光环助手
### Ver 2.5
* xxx

1
app/.gitignore vendored
View File

@ -1 +0,0 @@
/build

View File

@ -1,8 +1,14 @@
apply plugin: 'com.android.application'
//butterknife
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 21
buildToolsVersion "23.0.3"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
dexOptions {
jumboMode = true
@ -15,45 +21,40 @@ android {
aaptOptions.useNewCruncher = false
defaultConfig {
applicationId "com.gh.gamecenter"
minSdkVersion 14
targetSdkVersion 21
versionCode 19
versionName "2.4"
// jackOptions {
// enabled true
// }
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode rootProject.ext.versionCode
versionName rootProject.ext.versionName
applicationId rootProject.ext.applicationId
// multiDexEnabled true
}
/**
* 签名设置
*/
signingConfigs {
debug {
}
release {
storeFile file("gh.keystore")
keyAlias "gh.keystore"
keyPassword "20150318"
storePassword "20150318"
}
}
buildTypes {
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
zipAlignEnabled false
// versionNameSuffix "-debug"
}
release {
debuggable false
minifyEnabled false
zipAlignEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
// sourceSets {
// main {
// jniLibs.srcDirs = ['libs']
// }
// }
/**
* 多渠道打包
*/
@ -95,21 +96,13 @@ android {
}
}
//butterknife
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:21.0.0'
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:23.2.1'
// compile 'com.android.support:cardview-v7:21.0.0'
// fresco图片框架
compile 'com.facebook.fresco:fresco:0.12.0'
@ -139,15 +132,48 @@ dependencies {
compile 'com.jakewharton.rxbinding:rxbinding:0.3.0'
// compile 'com.jakewharton.rxbinding:rxbinding-appcompat-v7:0.3.0'
// compile 'com.jakewharton.rxbinding:rxbinding-design:0.3.0'
//添加友盟依赖工程
compile project(':PushSDK')
// zxing 二维码扫描以及生成
compile 'com.google.zxing:core:3.2.1'
compile 'com.google.zxing:android-core:3.2.1'
//tinker
// compile("com.tencent.tinker:tinker-android-lib:${TINKER_VERSION}") { changing = true }
// compile "com.android.support:multidex:1.0.1"
}
// 依赖插件脚本
//apply from: 'tinker-support.gradle'
compile project(':libraries:EventBus')
compile project(':libraries:MiPush')
compile project(':libraries:MTA')
compile project(':libraries:QQShare')
compile project(':libraries:TalkingData')
compile project(':libraries:UmengPush')
compile project(':libraries:WechatShare')
compile project(':libraries:WeiboShare')
}
File propFile = file('sign.properties');
if (propFile.exists()) {
def Properties props = new Properties()
props.load(new FileInputStream(propFile))
if (props.containsKey('keyAlias') && props.containsKey('keyPassword') &&
props.containsKey('storeFile') && props.containsKey('storePassword')) {
android.signingConfigs {
// debug {
// keyAlias props.get('keyAlias')
// keyPassword props.get('keyPassword')
// storeFile file(props.get('storeFile'))
// storePassword props.get('storePassword')
// }
release {
keyAlias props.get('keyAlias')
keyPassword props.get('keyPassword')
storeFile file(props.get('storeFile'))
storePassword props.get('storePassword')
}
}
} else {
android.buildTypes.release.signingConfig = null
}
} else {
android.buildTypes.release.signingConfig = null
}

Binary file not shown.

View File

@ -15,3 +15,7 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keepattributes *Annotation*,Signature,InnerClasses,EnclosingMethod
-dontwarn InnerClasses
-dontoptimize

4
app/sign.properties Normal file
View File

@ -0,0 +1,4 @@
storeFile=gh.keystore
storePassword=20150318
keyAlias=gh.keystore
keyPassword=20150318

View File

@ -66,23 +66,18 @@
android:value="GH_TEST"/>
<!--android:value="${CHANNEL_VALUE}"-->
<!-- MTA -->
<meta-data
android:name="TA_APPKEY"
android:value="APV567FTBS7J"/>
<meta-data
android:name="InstallChannel"
android:value="GH_TEST"/>
<!--android:value="${CHANNEL_VALUE}"-->
<!-- 友盟推送 -->
<meta-data
android:name="UMENG_APPKEY"
android:value="585a29fa8f4a9d327600023e">
android:value="58e5b0b9c62dca35a00005e6">
<!-- TODO 585a29fa8f4a9d327600023e -->
</meta-data>
<meta-data
android:name="UMENG_MESSAGE_SECRET"
android:value="8bcce6bed547ee624f5c2cc64d39a9e9">
android:value="ca08596492f8a7fde2ab48dceab8c1f3">
<!-- TODO 8bcce6bed547ee624f5c2cc64d39a9e9 -->
</meta-data>
<activity
@ -111,20 +106,13 @@
<activity
android:name="com.gh.gamecenter.SearchActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible" />
<activity
android:name="com.gh.gamecenter.GameDetailActivity"
android:screenOrientation="portrait" />
android:configChanges="keyboardHidden" />
<activity
android:name="com.gh.gamecenter.NewsDetailActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.SettingActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.SuggestionActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible" />
<activity
android:name="com.gh.gamecenter.ConcernActivity"
android:screenOrientation="portrait" />
@ -155,9 +143,6 @@
<activity
android:name="com.gh.gamecenter.MessageDetailActivity"
android:screenOrientation="portrait"/>
<activity
android:name="com.gh.gamecenter.StrategyActivity"
android:screenOrientation="portrait"/>
<activity
android:name="com.gh.gamecenter.LibaoActivity"
android:screenOrientation="portrait"/>
@ -194,6 +179,29 @@
<activity
android:name="com.gh.gamecenter.AboutActivity"
android:screenOrientation="portrait"/>
<activity
android:name="com.gh.gamecenter.NewsNormalActivity"
android:screenOrientation="portrait"/>
<activity
android:name="com.gh.gamecenter.KaiFuActivity"
android:screenOrientation="portrait"/>
<activity
android:name="com.gh.gamecenter.CommentDetailActivity"
android:screenOrientation="portrait"/>
<activity
android:name="com.gh.gamecenter.GameDetailActivity"
android:screenOrientation="portrait"/>
<activity
android:name="com.gh.gamecenter.SuggestSelectActivity"
android:screenOrientation="portrait"/>
<activity
android:name=".SuggestionActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize" />
<activity
android:name="com.gh.gamecenter.VoteActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"/>
<activity
android:name="com.gh.gamecenter.SkipActivity"
android:theme="@android:style/Theme.Translucent">

View File

@ -30,10 +30,10 @@ public class AppController extends Application {
//public class AppController extends TinkerApplication {
public static final String TAG = AppController.class.getSimpleName();
// xiaomi push appid
public static final String APP_ID = "2882303761517352993";
// xiaomi push appkey
public static final String APP_KEY = "5451735292993";
// TODO xiaomi push appid 2882303761517352993
public static final String APP_ID = "2882303761517564447";
// TODO xiaomi push appkey 5451735292993
public static final String APP_KEY = "5761756481447";
private static AppController mInstance;
private static ArrayMap<String, Object> objectMap = new ArrayMap<>();

View File

@ -3,6 +3,7 @@ package com.gh.base;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
@ -68,7 +69,7 @@ public class BaseActivity extends Activity implements OnCallBackListener {
setTranslucentStatus(true);
tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
tintManager.setStatusBarTintResource(R.color.theme);
tintManager.setStatusBarTintColor(Color.BLACK);
SystemBarConfig config = tintManager.getConfig();
contentView.setPadding(0, config.getPixelInsetTop(false), 0,
config.getPixelInsetBottom());
@ -80,7 +81,7 @@ public class BaseActivity extends Activity implements OnCallBackListener {
int actionbar_height = getSharedPreferences(Config.PREFERENCE,
Context.MODE_PRIVATE).getInt("actionbar_height",
DisplayUtils.dip2px(getApplicationContext(), 48));
DisplayUtils.dip2px(getApplicationContext(), 55));
RelativeLayout reuse_actionbar = (RelativeLayout) findViewById(R.id.reuse_actionbar);
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(

View File

@ -2,6 +2,7 @@ package com.gh.base;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
@ -65,7 +66,7 @@ public class BaseFragmentActivity extends FragmentActivity {
setTranslucentStatus(true);
SystemBarTintManager tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
tintManager.setStatusBarTintResource(R.color.theme);
tintManager.setStatusBarTintColor(Color.BLACK);
SystemBarConfig config = tintManager.getConfig();
contentView.setPadding(0, config.getPixelInsetTop(false), 0,
config.getPixelInsetBottom());

View File

@ -8,10 +8,12 @@ import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.ScaleAnimation;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -28,6 +30,8 @@ import com.gh.gamecenter.eventbus.EBDownloadStatus;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.manager.PackageManager;
import java.util.ArrayList;
import de.greenrobot.event.EventBus;
/**
@ -43,13 +47,16 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
private TextView downloadHint;
private TextView searchHint;
private String hint;
private AlphaAnimation mAlphaAnimation;
private ArrayList<String> hintList;
private int hintIndex;
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if (!TextUtils.isEmpty(hint)) {
outState.putString("hint", hint);
if (hintList != null && !hintList.isEmpty()) {
outState.putStringArrayList("hint", hintList);
}
}
@ -58,17 +65,18 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
hint = savedInstanceState.getString("hint");
hintList = savedInstanceState.getStringArrayList("hint");
}
hintIndex = 0;
view = View.inflate(getActivity(), R.layout.fragment_home, null);
SharedPreferences sp = getActivity().getSharedPreferences(
Config.PREFERENCE, Context.MODE_PRIVATE);
LinearLayout home_actionbar = (LinearLayout) view.findViewById(R.id.home_actionbar);
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, sp.getInt("actionbar_height",
DisplayUtils.dip2px(getActivity(), 48)));
LinearLayout.LayoutParams.MATCH_PARENT,DisplayUtils.dip2px(getActivity(), 55));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
int top = DisplayUtils.getStatusBarHeight(getResources());
@ -79,6 +87,70 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
initActionBar();
final ScaleAnimation scaleAnimation = new ScaleAnimation(0.4f, 1.0f, 0.4f, 1.0f
, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
scaleAnimation.setDuration(500);
mAlphaAnimation = new AlphaAnimation(1f, 0.2f);
mAlphaAnimation.setDuration(300);
mAlphaAnimation.setStartOffset(5000);
scaleAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
if (mAlphaAnimation != null) {
searchHint.setAnimation(mAlphaAnimation);
mAlphaAnimation.start();
}
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
mAlphaAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
// 切换数据
if (hintIndex > hintList.size() - 1) {
hintIndex = 0;
}
searchHint.setHint(hintList.get(hintIndex));
hintIndex ++;
if (scaleAnimation != null) {
searchHint.setAnimation(scaleAnimation);
scaleAnimation.start();
}
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
if (hintList != null && hintList.size() > 0) {
if (hintList.size() > 1) {
searchHint.setAnimation(mAlphaAnimation);
} else {
String hint = hintList.get(0);
searchHint.setHint(hint);
}
}
EventBus.getDefault().register(this);
}
@ -96,6 +168,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
view.findViewById(R.id.actionbar_rl_download).setOnClickListener(this);
view.findViewById(R.id.actionbar_iv_search).setOnClickListener(this);
view.findViewById(R.id.actionbar_notification).setOnClickListener(this);
view.findViewById(R.id.actionbar_search_rl).setOnClickListener(this);
if (Config.isShow(getActivity())) {
view.findViewById(R.id.actionbar_rl_download).setVisibility(View.VISIBLE);
@ -118,9 +191,6 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
searchHint = (TextView) view.findViewById(R.id.actionbar_search_input);
searchHint.setOnClickListener(this);
if (!TextUtils.isEmpty(hint)) {
searchHint.setHint(hint);
}
}
@Override
@ -140,16 +210,16 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
Intent intent = new Intent(getActivity(), SearchActivity.class);
intent.putExtra("clicked", true);
intent.putExtra("hint", hint);
intent.putExtra("hint", searchHint.getHint().toString());
intent.putExtra("entrance", "(工具栏)");
startActivity(intent);
} else if (id == R.id.actionbar_search_input) {
} else if (id == R.id.actionbar_search_input || id == R.id.actionbar_search_rl) {
DataUtils.onEvent(getActivity(), "主页", "搜索框");
DataCollectionUtils.uploadClick(getActivity(), "搜索框", "主页");
Intent intent = new Intent(getActivity(), SearchActivity.class);
intent.putExtra("clicked", false);
intent.putExtra("hint", hint);
intent.putExtra("hint", searchHint.getHint().toString());
intent.putExtra("entrance", "(工具栏)");
startActivity(intent);
} else if (id == R.id.actionbar_notification) {
@ -173,11 +243,13 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
}
}
public void setHint(String hint) {
if (!TextUtils.isEmpty(hint)) {
this.hint = hint;
if (searchHint != null) {
searchHint.setHint(hint);
public void setHint(ArrayList<String> hint) {
if (hint != null && hint.size() > 0) {
hintList = hint;
if (hint.size() == 1 && searchHint != null) {
searchHint.setHint(hintList.get(0));
} else if (mAlphaAnimation != null && searchHint != null) {
searchHint.setAnimation(mAlphaAnimation);
}
}
}

View File

@ -6,11 +6,11 @@ import android.content.SharedPreferences;
public class Config {
public static final String HOST = "http://api.ghzhushou.com/v2d4/";
public static final String USER_HOST = "http://user.ghzhushou.com/v1d2/";
public static final String COMMENT_HOST = "http://comment.ghzhushou.com/v1d1/";
public static final String HOST = "http://dev.api2.ghzhushou.com/v2d5/";
public static final String USER_HOST = "http://dev.user2.ghzhushou.com/v1d2/";
public static final String COMMENT_HOST = "http://dev.comment2.ghzhushou.com/v1d2/";
public static final String DATA_HOST = "http://data.ghzhushou.com/";
public static final String LIBAO_HOST = "http://libao.ghzhushou.com/v1d1/";
public static final String LIBAO_HOST = "http://dev.libao2.ghzhushou.com/v1d2/";
public static final String PREFERENCE = "ghzhushou";
public static boolean isShow(Context context) {

View File

@ -23,5 +23,6 @@ public class ItemViewType {
public static final int LIBAO_NORMAL = 15; // 礼包正常布局
public static final int LIBAO_SKIP_CONCERN = 16; // 跳转关注管理页面布局
public static final int KC_HINT = 16;
public static final int ZIXUNTOP_TOP = 7; // 有料顶部布局
}

View File

@ -0,0 +1,206 @@
package com.gh.common.util;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gh.base.AppController;
import com.gh.gamecenter.CommentDetailActivity;
import com.gh.gamecenter.MessageDetailActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.MessageDetailAdapter;
import com.gh.gamecenter.db.CommentDao;
import com.gh.gamecenter.entity.CommentEntity;
import org.json.JSONException;
import org.json.JSONObject;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
/**
* Created by khy on 2017/3/22.
*/
public class CommentUtils {
public static void setCommentTime(TextView textView, long time) {
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd", Locale.getDefault());
try {
long today = format.parse(format.format(new Date())).getTime();
long day = time * 1000;
if (day >= today && day < today + 86400 * 1000) {
long min = new Date().getTime()/1000 - day/1000;
int hour = (int) (min/ (60 * 60));
if (hour == 0) {
if (min < 60) {
textView.setText("刚刚");
} else {
textView.setText(String.format(Locale.getDefault(), "%d分钟前", (int) (min / 60)));
}
} else {
textView.setText(String.format(Locale.getDefault(), "%d小时前", hour));
}
} else if (day >= today - 86400 * 1000 && day < today) {
format.applyPattern("HH:mm");
textView.setText("昨天 ");
} else {
format.applyPattern("yyyy-MM-dd");
textView.setText(format.format(day));
}
} catch (ParseException e) {
e.printStackTrace();
format.applyPattern("yyyy-MM-dd");
textView.setText(format.format(time * 1000));
}
}
public static void showReportDialog(final CommentEntity commentEntity, final Context mContext
, final MessageDetailAdapter.OnCommentCallBackListener mCallBackListener, final String newsId) {
CommentDao commentDao = new CommentDao(mContext);
final Dialog dialog = new Dialog(mContext);
LinearLayout container = new LinearLayout(mContext);
container.setOrientation(LinearLayout.VERTICAL);
container.setBackgroundColor(Color.WHITE);
container.setPadding(0, DisplayUtils.dip2px(mContext, 12), 0, DisplayUtils.dip2px(mContext, 12));
List<String> dialogType = new ArrayList<>();
if (!commentDao.isMyComment(commentEntity.getId())) {
dialogType.add("回复");
}
dialogType.add("复制");
dialogType.add("举报");
if (commentEntity.getParent() != null) {
dialogType.add("查看对话");
}
for (String s : dialogType) {
final TextView reportTv = new TextView(mContext);
reportTv.setPadding(DisplayUtils.dip2px(mContext, 20), DisplayUtils.dip2px(mContext, 12),
0, DisplayUtils.dip2px(mContext, 12));
reportTv.setText(s);
reportTv.setTextSize(17);
reportTv.setTextColor(mContext.getResources().getColor(R.color.title));
reportTv.setBackgroundResource(R.drawable.textview_white_style);
int widthPixels = mContext.getResources().getDisplayMetrics().widthPixels;
reportTv.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9)/10,
LinearLayout.LayoutParams.WRAP_CONTENT));
container.addView(reportTv);
reportTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.cancel();
switch (reportTv.getText().toString()) {
case "回复":
if (mCallBackListener != null) {
mCallBackListener.showSoftInput(commentEntity);
} else if (!TextUtils.isEmpty(newsId)){
Intent intent = new Intent(mContext, MessageDetailActivity.class);
AppController.put("CommentEntity", commentEntity);
intent.putExtra("commentNum", -1);
intent.putExtra("newsId", newsId);
intent.putExtra("openSoftInput", true);
mContext.startActivity(intent);
} else {
Utils.toast(mContext, "缺少关键属性");
}
break;
case "复制":
LibaoUtils.copyLink(commentEntity.getContent(), mContext);
break;
case "举报":
showReportTypeDialog(commentEntity, mContext);
break;
case "查看对话":
Intent intent = new Intent(mContext, CommentDetailActivity.class);
intent.putExtra("commentId", commentEntity.getId());
mContext.startActivity(intent);
break;
}
}
});
}
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(container);
dialog.show();
}
private static void showReportTypeDialog(final CommentEntity commentEntity, final Context mContext) {
final String[] arrReportType = new String[]{"垃圾广告营销", "恶意攻击谩骂", "淫秽色情信息",
"违法有害信息", "其它"};
int widthPixels = mContext.getResources().getDisplayMetrics().widthPixels;
final Dialog reportTypeDialog = new Dialog(mContext);
LinearLayout container = new LinearLayout(mContext);
container.setOrientation(LinearLayout.VERTICAL);
container.setPadding(0, DisplayUtils.dip2px(mContext, 12), 0, DisplayUtils.dip2px(mContext, 12));
container.setBackgroundColor(Color.WHITE);
for (final String s : arrReportType) {
TextView reportTypeTv = new TextView(mContext);
reportTypeTv.setText(s);
reportTypeTv.setTextSize(17);
reportTypeTv.setTextColor(mContext.getResources().getColor(R.color.title));
reportTypeTv.setBackgroundResource(R.drawable.textview_white_style);
reportTypeTv.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9)/10,
LinearLayout.LayoutParams.WRAP_CONTENT));
reportTypeTv.setPadding(DisplayUtils.dip2px(mContext, 20), DisplayUtils.dip2px(mContext, 12),
0, DisplayUtils.dip2px(mContext, 12));
container.addView(reportTypeTv);
reportTypeTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("comment_id", commentEntity.getId());
jsonObject.put("reason", s);
} catch (JSONException e) {
e.printStackTrace();
}
PostCommentUtils.addReportData(mContext, jsonObject.toString(), true,
new PostCommentUtils.PostCommentListener() {
@Override
public void postSucced(JSONObject response) {
Utils.toast(mContext, "感谢您的举报");
}
@Override
public void postFailed(Throwable error) {
Utils.toast(mContext, "举报失败,请检查网络设置");
}
});
reportTypeDialog.cancel();
}
});
}
reportTypeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
reportTypeDialog.setContentView(container);
reportTypeDialog.show();
}
}

View File

@ -133,15 +133,37 @@ public class DataCollectionUtils {
// 上传搜索数据
public static void uploadSearch(Context context, String... args) {
if (args.length < 2) {
if (args.length != 5) {
return;
}
Map<String, Object> map = new HashMap<>();
map.put("from", args[2]);
map.put("search_type", args[1]);
map.put("key", args[0]);
map.put("from", args[1]);
if (args.length == 3) {
map.put("click", args[2]);
map.put("game_id", args[3]);
map.put("game_name", args[4]);
map.put("netword", NetworkUtils.getConnectedType(context));
map.put("type", "search");
map.put("device_type", android.os.Build.MODEL);
map.put("device_system", android.os.Build.VERSION.SDK_INT + "=" + android.os.Build.VERSION.RELEASE);
DataCollectionManager.onEvent(context, "search", map);
}
// 上传搜索点击数据
public static void uploadSearchClick(Context context, String... args) {
if (args.length != 5) {
return;
}
Map<String, Object> map = new HashMap<>();
map.put("from", args[2]);
map.put("search_type", args[1]);
map.put("key", args[0]);
map.put("game_id", args[3]);
map.put("game_name", args[4]);
map.put("netword", NetworkUtils.getConnectedType(context));
map.put("type", "click");
map.put("device_type", android.os.Build.MODEL);
map.put("device_system", android.os.Build.VERSION.SDK_INT + "=" + android.os.Build.VERSION.RELEASE);
DataCollectionManager.onEvent(context, "search", map);
}
@ -157,4 +179,16 @@ public class DataCollectionUtils {
DataCollectionManager.onEvent(context, "concern", map);
}
//上传推荐位数据
public static void uploadPosition(Context context, String... args) {
if (args.length < 3) {
return;
}
Map<String, Object> map = new HashMap<>();
map.put("page", args[0]);
map.put("location", args[1]);
map.put("name", args[2]);
DataCollectionManager.onEvent(context, "position", map);
}
}

View File

@ -295,105 +295,85 @@ public class DownloadItemUtils {
}
private static void setNormalOnClickListener(final Context context,
public static void onNormalClick(final Context context,
final TextView downloadBtn,
final GameEntity gameEntity,
final int position,
final RecyclerView.Adapter<RecyclerView.ViewHolder> adapter,
final String entrance,
final String location, final boolean isCloseSoftInput) {
downloadBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isCloseSoftInput) {
InputMethodManager imm = (InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
final String location) {
String str = downloadBtn.getText().toString();
if ("下载".equals(str)) {
if (NetworkUtils.isWifiConnected(context)) {
String str = downloadBtn.getText().toString();
if ("下载".equals(str)) {
if (NetworkUtils.isWifiConnected(context)) {
download(context, gameEntity, downloadBtn, entrance, location);
} else {
DialogUtils.showDownloadDialog(context, new DialogUtils.ConfiremListener() {
@Override
public void onConfirem() {
download(context, gameEntity, downloadBtn, entrance, location);
} else {
DialogUtils.showDownloadDialog(context, new DialogUtils.ConfiremListener() {
@Override
public void onConfirem() {
download(context, gameEntity, downloadBtn, entrance, location);
}
});
}
} else if ("插件化".equals(str)) {
if (NetworkUtils.isWifiConnected(context)) {
});
}
} else if ("插件化".equals(str)) {
if (NetworkUtils.isWifiConnected(context)) {
plugin(context, gameEntity, downloadBtn, entrance, location);
} else {
DialogUtils.showDownloadDialog(context, new DialogUtils.ConfiremListener() {
@Override
public void onConfirem() {
plugin(context, gameEntity, downloadBtn, entrance, location);
} else {
DialogUtils.showDownloadDialog(context, new DialogUtils.ConfiremListener() {
@Override
public void onConfirem() {
plugin(context, gameEntity, downloadBtn, entrance, location);
}
});
}
} else if ("安装".equals(str)) {
install(context, gameEntity, position, adapter);
} else if ("启动".equals(str)) {
DataUtils.onGameLaunchEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), location);
});
}
} else if ("安装".equals(str)) {
install(context, gameEntity, position, adapter);
} else if ("启动".equals(str)) {
DataUtils.onGameLaunchEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), location);
PackageUtils.launchApplicationByPackageName(context, gameEntity.getApk().get(0).getPackageName());
} else if ("下载中".equals(str)) {
Intent intent = new Intent(context, DownloadManagerActivity.class);
intent.putExtra("currentItem", 1);
intent.putExtra("url", gameEntity.getApk().get(0).getUrl());
intent.putExtra("entrance", entrance + "+(" + location.split(":")[0] + ")");
context.startActivity(intent);
} else if ("更新".equals(str)) {
if (NetworkUtils.isWifiConnected(context)) {
PackageUtils.launchApplicationByPackageName(context, gameEntity.getApk().get(0).getPackageName());
} else if ("下载中".equals(str)) {
Intent intent = new Intent(context, DownloadManagerActivity.class);
intent.putExtra("currentItem", 1);
intent.putExtra("url", gameEntity.getApk().get(0).getUrl());
intent.putExtra("entrance", entrance + "+(" + location.split(":")[0] + ")");
context.startActivity(intent);
} else if ("更新".equals(str)) {
if (NetworkUtils.isWifiConnected(context)) {
update(context, gameEntity, entrance, location);
} else {
DialogUtils.showDownloadDialog(context, new DialogUtils.ConfiremListener() {
@Override
public void onConfirem() {
update(context, gameEntity, entrance, location);
} else {
DialogUtils.showDownloadDialog(context, new DialogUtils.ConfiremListener() {
@Override
public void onConfirem() {
update(context, gameEntity, entrance, location);
}
});
}
}
});
}
});
}
}
private static void setPluginOnClickListener(final Context context,
final TextView downloadBtn,
final GameEntity entity,
final String entrance,
final String location,
final boolean isCloseSoftInput) {
downloadBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
if (isCloseSoftInput) {
InputMethodManager imm = (InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
DownloadDialog.getInstance(context).showPopupWindow(v, entity, entrance, location);
}
});
}
public static void setOnClickListener(Context context,
TextView downloadBtn,
GameEntity gameEntity,
int position,
RecyclerView.Adapter<RecyclerView.ViewHolder> adapter,
String entrance,
String location,
boolean isCloseSoftInput) {
public static void setOnClickListener(final Context context,
final TextView downloadBtn,
final GameEntity gameEntity,
final int position,
final RecyclerView.Adapter<RecyclerView.ViewHolder> adapter,
final String entrance,
final String location) {
if (gameEntity.getApk().size() == 1) {
setNormalOnClickListener(context, downloadBtn, gameEntity, position, adapter, entrance, location, isCloseSoftInput);
downloadBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onNormalClick(context, downloadBtn, gameEntity, position, adapter, entrance, location);
}
});
} else {
setPluginOnClickListener(context, downloadBtn, gameEntity, entrance, location, isCloseSoftInput);
downloadBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DownloadDialog.getInstance(context).showPopupWindow(v, gameEntity, entrance, location);
}
});
}
}

View File

@ -39,7 +39,7 @@ public class GameViewUtils {
if (i == size - 1) {
view = getGameTagView(context, tag.get(i), 0);
} else {
view = getGameTagView(context, tag.get(i), DisplayUtils.dip2px(context, 5));
view = getGameTagView(context, tag.get(i), DisplayUtils.dip2px(context, 6));
}
if (view != null) {
labelLayout.addView(view);

View File

@ -0,0 +1,78 @@
package com.gh.common.util;
import android.graphics.Color;
import android.widget.TextView;
import com.gh.gamecenter.R;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
/**
* Created by khy on 2017/3/19.
*/
public class KaiFuUtils {
public static void setKaiFuTime(TextView textView, long time) {
time = time * 1000;
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd", Locale.getDefault());
try {
long today = format.parse(format.format(new Date())).getTime();
if (time >= today && time < today + 86400 * 1000) {
format.applyPattern("HH:mm");
textView.setText(String.format("今天 %s", format.format(time)));
textView.setBackgroundResource(R.drawable.border_white_bg);
textView.setTextColor(Color.parseColor("#ffb13c"));
} else if (time >= today - 86400 * 1000 && time < today) {
format.applyPattern("HH:mm");
textView.setText(String.format("昨天 %s", format.format(time)));
textView.setBackgroundResource(R.drawable.kaifu_time_tag_gray);
textView.setTextColor(Color.parseColor("#c7c7c7"));
} else if (time > today && time < today + 86400 * 1000 * 2){
format.applyPattern("HH:mm");
textView.setText(String.format("明天 %s", format.format(time)));
textView.setBackgroundResource(R.drawable.border_white_bg);
textView.setTextColor(Color.parseColor("#ffb13c"));
} else if (time >= today - 86400 * 1000 * 2 && time < today){
format.applyPattern("HH:mm");
textView.setText(String.format("前天 %s", format.format(time)));
textView.setBackgroundResource(R.drawable.kaifu_time_tag_gray);
textView.setTextColor(Color.parseColor("#c7c7c7"));
} else if (time > today && time < today + 86400 * 1000 * 3){
format.applyPattern("HH:mm");
textView.setText(String.format("后天 %s", format.format(time)));
textView.setBackgroundResource(R.drawable.kaifu_time_tag_gray);
textView.setTextColor(Color.parseColor("#c7c7c7"));
} else {
format.applyPattern("MM-dd HH:mm");
textView.setText(format.format(time));
textView.setBackgroundResource(R.drawable.kaifu_time_tag_gray);
textView.setTextColor(Color.parseColor("#c7c7c7"));
}
} catch (ParseException e) {
e.printStackTrace();
format.applyPattern("yyyy年MM月dd日 HH:mm");
textView.setText(format.format(time));
}
}
public static void setKaiFuType(TextView textView, String type) {
textView.setText(type);
switch (type) {
case "不删档内测":
textView.setBackgroundColor(Color.parseColor("#c7c7c7"));
break;
case "删档内测":
textView.setBackgroundColor(Color.parseColor("#c7c7c7"));
break;
case "公测":
textView.setBackgroundColor(Color.parseColor("#06d0a8"));
break;
default:
textView.setBackgroundColor(Color.parseColor("#06d0a8"));
break;
}
}
}

View File

@ -79,7 +79,15 @@ public class LibaoUtils {
@Override
public void onResponse(List<LibaoEntity> response) {
LibaoDao libaoDao = new LibaoDao(context);
libaoDao.deleteAll(); // 清空之前所有数据
for (LibaoEntity libaoEntity : response) {
if ("ling".equals(libaoEntity.getStatus())) {
libaoEntity.setStatus("linged");
} else {
libaoEntity.setStatus("taoed");
}
LibaoInfo libaoInfo = LibaoInfo.createLibaoInfo(libaoEntity);
libaoInfo.setActive(libaoEntity.isActive());
libaoDao.add(libaoInfo);
@ -124,8 +132,6 @@ public class LibaoUtils {
return;
} else if (e.code() == 410) { // 该接口已废弃
Utils.toast(context, "领取失败,请安装最新版本的光环助手");
} else if (e.code() == 412) {
//TODO 需要验证码
}
listener.postFailed(e);
}
@ -213,7 +219,9 @@ public class LibaoUtils {
final boolean isInstallRequired, final LibaoDetailAdapter adapter, final String entrance) {
libaoBtn.setTextColor(Color.WHITE);
switch (libaoEntity.getStatus()) {
String status = libaoEntity.getStatus();
if (TextUtils.isEmpty(status)) return;
switch (status) {
case "coming":
libaoBtn.setText("未开抢");
libaoBtn.setBackgroundResource(R.drawable.textview_blue_style);
@ -321,20 +329,32 @@ public class LibaoUtils {
}
if (TextUtils.isEmpty(libaoCode)) {
Utils.toast(libaoBtn.getContext(), "淘号异常");
try {
String detail = responseBody.getString("detail");
if ("maintaining".equals(detail)) {
Utils.toast(libaoBtn.getContext(), "网络状态异常,请稍后再试");
} else if ("fail to compete".equals(detail)) {
Utils.toast(libaoBtn.getContext(), "淘号失败,稍后重试");
} else {
Utils.toast(libaoBtn.getContext(), "淘号异常");
}
} catch (JSONException e) {
e.printStackTrace();
}
return;
}
Utils.toast(libaoBtn.getContext(), "淘号成功");
libaoEntity.setStatus("taoed");
LibaoInfo libaoInfo = LibaoInfo.createLibaoInfo(libaoEntity);
libaoInfo.setCode(libaoCode);
// libaoInfo.setTime(String.valueOf(new Date().getTime()));
libaoInfo.setTime(Utils.getTime(libaoBtn.getContext()));
libaoDao.add(libaoInfo);
EventBus.getDefault().post(new EBReuse("libaoChanged"));
libaoEntity.setStatus("taoed");
adapter.initLibaoDao();
adapter.notifyDataSetChanged();
@ -432,13 +452,15 @@ public class LibaoUtils {
}
libaoEntity.setAvailable(libaoEntity.getAvailable() - 1);
libaoEntity.setStatus("linged");
LibaoInfo libaoInfo = LibaoInfo.createLibaoInfo(libaoEntity);
libaoInfo.setTime(Utils.getTime(libaoBtn.getContext()));
libaoInfo.setCode(libaoCode);
libaoDao.add(libaoInfo);
EventBus.getDefault().post(new EBReuse("libaoChanged"));
libaoEntity.setStatus("linged");
adapter.initLibaoDao();
adapter.notifyDataSetChanged();
@ -485,7 +507,7 @@ public class LibaoUtils {
} else if ("fetched".equals(detail)) {
Utils.toast(libaoBtn.getContext(), "你已领过这个礼包了");
getCunHaoXiang(libaoBtn.getContext(), true);
libaoBtn.setText("复制");
libaoBtn.setText("复制");// TODO
libaoBtn.setBackgroundResource(R.drawable.textview_blue_style);
} else if ("try tao".equals(detail) || "used up".equals(detail)) {

View File

@ -447,11 +447,7 @@ public class MessageShareUtils {
if (isToast) {
Utils.toast(context,"成功保存到相册");
//刷新手机图片库
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri uri = Uri.fromFile(_file);
intent.setData(uri);
context.sendBroadcast(intent);
Utils.log("保存分享图片路径:" + _file.getAbsolutePath());
refreshImage(_file, context);
}
}
}
@ -469,4 +465,12 @@ public class MessageShareUtils {
}
}
public static void refreshImage(File _file, Context context) {
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri uri = Uri.fromFile(_file);
intent.setData(uri);
context.sendBroadcast(intent);
Utils.log("保存分享图片路径:" + _file.getAbsolutePath());
}
}

View File

@ -35,6 +35,8 @@ public class NewsUtils {
return R.drawable.textview_orange_up;
} else if ("新游".equals(type)) {
return R.drawable.textview_green_up;
} else if ("热门".equals(type) || "置顶".equals(type)) {
return R.drawable.textview_all_red_up;
} else {
return R.drawable.textview_blue_up;
}
@ -98,8 +100,17 @@ public class NewsUtils {
/**
* 设置新闻类型
*/
public static void setNewsType(TextView textView, String type) {
textView.setText(type);
public static void setNewsType(TextView textView, String type, int priority, int position) {
if (priority != 0) {
if (position == 0) {
textView.setText("置顶");
} else {
textView.setText("热门");
}
} else {
textView.setText(type);
}
textView.setTextColor(Color.WHITE);
if ("活动".equals(type)) {
textView.setBackgroundResource(R.drawable.textview_orange_style);
@ -111,6 +122,10 @@ public class NewsUtils {
textView.setBackgroundResource(R.drawable.textview_orange_style);
} else if ("专题".equals(type)) {
textView.setBackgroundResource(R.drawable.textview_blue_style);
} else if ("置顶".equals(type)) {
textView.setBackgroundResource(R.drawable.textview_all_red_style);
} else if ("热门".equals(type)){
textView.setBackgroundResource(R.drawable.textview_all_red_style);
} else {
textView.setBackgroundResource(R.drawable.textview_blue_style);
}

View File

@ -228,11 +228,16 @@ public class PackageUtils {
*/
public static void launchApplicationByPackageName(Context context,
String packageName) {
Intent intent = context.getPackageManager().getLaunchIntentForPackage(
packageName);
if (intent != null) {
context.startActivity(intent);
} else {
try {
Intent intent = context.getPackageManager().getLaunchIntentForPackage(
packageName);
if (intent != null) {
context.startActivity(intent);
} else {
Toast.makeText(context, "启动失败", Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(context, "启动失败", Toast.LENGTH_SHORT).show();
}
}

View File

@ -2,6 +2,7 @@ package com.gh.common.util;
import android.content.Context;
import com.gh.gamecenter.entity.CommentEntity;
import com.gh.gamecenter.retrofit.JSONObjectResponse;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
@ -24,13 +25,19 @@ import rx.schedulers.Schedulers;
public class PostCommentUtils {
public static void addCommentData(final Context context, final String newsId, final String content,
final boolean isCheck, final PostCommentListener listener) {
final boolean isCheck, final CommentEntity commentEntity,
final PostCommentListener listener) {
TokenUtils.getToken(context, isCheck)
.flatMap(new Func1<String, Observable<ResponseBody>>() {
@Override
public Observable<ResponseBody> call(String token) {
RequestBody body = RequestBody.create(MediaType.parse("application/json"), content);
return RetrofitManager.getComment().postNewsComment(token, newsId, body);
if (commentEntity != null) {
return RetrofitManager.getComment().postReplyComment(token, commentEntity.getId(), body);
} else {
return RetrofitManager.getComment().postNewsComment(token, newsId, body);
}
}
})
.subscribeOn(Schedulers.io())
@ -47,10 +54,16 @@ public class PostCommentUtils {
}
}
@Override
public void onError(Throwable e) {
super.onError(e);
Utils.log("======" + e.toString());
}
@Override
public void onFailure(HttpException e) {
if (e != null && e.code() == 401) {
addCommentData(context, newsId, content, false, listener);
addCommentData(context, newsId, content, false, commentEntity, listener);
return;
}
if (listener != null){

View File

@ -0,0 +1,38 @@
package com.gh.common.util;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
/**
* Created by khy on 2017/3/30.
*/
public class QQUtils {
public static void startQQSession(Context context, String qq) {
if (ShareUtils.isQQClientAvailable(context)) {
//安装了QQ会直接调用QQ打开手机QQ进行会话 QQ号2586716223
String str = "mqqwpa://im/chat?chat_type=wpa&uin=" + qq + "&version=1&src_type=web&web_src=oicqzone.com";
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));
} else {
//没有安装QQ 复制账号
ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
cmb.setText(qq);
Utils.toast(context, "已复制" + qq);
}
}
public static boolean joinQQGroup(Context context, String key) {
Intent intent = new Intent();
intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + key));
// 此Flag可根据具体产品需要自定义如设置则在加群界面按返回返回手Q主界面不设置按返回会返回到呼起产品界面 //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
try {
context. startActivity(intent);
return true;
} catch (Exception e) {
// 未安装手Q或安装的版本不支持
return false;
}
}
}

View File

@ -250,6 +250,8 @@ public class DownloadDialog implements OnCollectionCallBackListener {
}
}
apkList.add(new ApkEntity()); // 添加一个跳转投票
dialog_ll_hint.removeAllViews();
int size = (int) Math.ceil(apkList.size() / (double) (row * column));
addHintPoint(dialog_ll_hint, size);

View File

@ -0,0 +1,134 @@
package com.gh.common.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
/**
* Created by khy on 2017/3/28.
*/
public class GridDivider extends RecyclerView.ItemDecoration {
private Drawable mDividerDarwable;
private int mDividerHight = 1;
private Paint mColorPaint;
public final int[] ATRRS = new int[]{android.R.attr.listDivider};
public GridDivider(Context context) {
final TypedArray ta = context.obtainStyledAttributes(ATRRS);
this.mDividerDarwable = ta.getDrawable(0);
ta.recycle();
}
/*
int dividerHight 分割线的线宽
int dividerColor 分割线的颜色
*/
public GridDivider(Context context, int dividerHight, int dividerColor) {
this(context);
mDividerHight = dividerHight;
mColorPaint = new Paint();
mColorPaint.setColor(dividerColor);
}
/*
int dividerHight 分割线的线宽
Drawable dividerDrawable 图片分割线
*/
public GridDivider(Context context, int dividerHight, Drawable dividerDrawable) {
this(context);
mDividerHight = dividerHight;
mDividerDarwable = dividerDrawable;
}
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
super.onDraw(c, parent, state);
//画水平和垂直分割线
drawHorizontalDivider(c, parent);
drawVerticalDivider(c, parent);
}
public void drawVerticalDivider(Canvas c, RecyclerView parent) {
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
final int top = child.getTop() - params.topMargin;
final int bottom = child.getBottom() + params.bottomMargin;
int left = 0;
int right = 0;
//左边第一列
if ((i % 7) == 0) {
//item左边分割线
left = child.getLeft();
right = left + mDividerHight;
mDividerDarwable.setBounds(left, top, right, bottom);
mDividerDarwable.draw(c);
if (mColorPaint != null) {
c.drawRect(left, top, right, bottom, mColorPaint);
}
//item右边分割线
left = child.getRight() + params.rightMargin - mDividerHight;
right = left + mDividerHight;
} else {
//非左边第一列
left = child.getRight() + params.rightMargin - mDividerHight;
right = left + mDividerHight;
}
//画分割线
mDividerDarwable.setBounds(left, top, right, bottom);
mDividerDarwable.draw(c);
if (mColorPaint != null) {
c.drawRect(left, top, right, bottom, mColorPaint);
}
}
}
public void drawHorizontalDivider(Canvas c, RecyclerView parent) {
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
final int left = child.getLeft() - params.leftMargin - mDividerHight;
final int right = child.getRight() + params.rightMargin;
int top = 0;
int bottom = 0;
// 最上面一行
if ((i / 7) == 0) {
//当前item最上面的分割线
top = child.getTop();
//当前item下面的分割线
bottom = top + mDividerHight;
mDividerDarwable.setBounds(left, top, right, bottom);
mDividerDarwable.draw(c);
if (mColorPaint != null) {
c.drawRect(left, top, right, bottom, mColorPaint);
}
top = child.getBottom() + params.bottomMargin;
bottom = top + mDividerHight;
} else {
top = child.getBottom() + params.bottomMargin;
bottom = top + mDividerHight;
}
//画分割线
mDividerDarwable.setBounds(left, top, right, bottom);
mDividerDarwable.draw(c);
if (mColorPaint != null) {
c.drawRect(left, top, right, bottom, mColorPaint);
}
}
}
}

View File

@ -0,0 +1,138 @@
package com.gh.common.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.ViewTreeObserver;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;
import android.widget.ViewFlipper;
import com.gh.common.util.DisplayUtils;
import com.gh.gamecenter.R;
import java.util.ArrayList;
import java.util.List;
/**
* Created by khy on 2017/3/29.
*/
public class MarqueeView extends ViewFlipper {
private Context mContext;
private List<String> notices;
private boolean isSetAnimDuration = false;
private int interval = 2000;
private int animDuration = 500;
private int textSize = 14;
private int textColor = 0xffffffff;
public MarqueeView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs, 0);
}
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
this.mContext = context;
if (notices == null) {
notices = new ArrayList<>();
}
TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.MarqueeViewStyle, defStyleAttr, 0);
interval = typedArray.getInteger(R.styleable.MarqueeViewStyle_mvInterval, interval);
isSetAnimDuration = typedArray.hasValue(R.styleable.MarqueeViewStyle_mvAnimDuration);
animDuration = typedArray.getInteger(R.styleable.MarqueeViewStyle_mvAnimDuration, animDuration);
if (typedArray.hasValue(R.styleable.MarqueeViewStyle_mvTextSize)) {
textSize = (int) typedArray.getDimension(R.styleable.MarqueeViewStyle_mvTextSize, textSize);
textSize = DisplayUtils.px2sp(mContext, textSize);
}
textColor = typedArray.getColor(R.styleable.MarqueeViewStyle_mvTextColor, textColor);
typedArray.recycle();
setFlipInterval(interval);
Animation animIn = AnimationUtils.loadAnimation(mContext, R.anim.anim_marquee_in);
if (isSetAnimDuration) animIn.setDuration(animDuration);
setInAnimation(animIn);
Animation animOut = AnimationUtils.loadAnimation(mContext, R.anim.anim_marquee_out);
if (isSetAnimDuration) animOut.setDuration(animDuration);
setOutAnimation(animOut);
}
// 根据公告字符串启动轮播
public void startWithText(final String notice) {
if (TextUtils.isEmpty(notice)) return;
getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
getViewTreeObserver().removeGlobalOnLayoutListener(this);
startWithFixedWidth(notice, getWidth());
}
});
}
// 根据公告字符串列表启动轮播
public void startWithList(List<String> notices) {
setNotices(notices);
start();
}
// 根据宽度和公告字符串启动轮播
private void startWithFixedWidth(String notice, int width) {
int noticeLength = notice.length();
int dpW = DisplayUtils.px2dip(mContext, width);
int limit = dpW/textSize;
if (dpW == 0) {
throw new RuntimeException("Please set MarqueeView width !");
}
if (noticeLength <= limit) {
notices.add(notice);
} else {
int size = noticeLength/limit + (noticeLength%limit != 0? 1:0);
for (int i=0; i<size; i++) {
int startIndex = i*limit;
int endIndex = ((i+1)*limit >= noticeLength? noticeLength:(i+1)*limit);
notices.add(notice.substring(startIndex, endIndex));
}
}
start();
}
// 启动轮播
public boolean start() {
if (notices == null || notices.size() == 0) return false;
removeAllViews();
for (String notice:notices) {
addView(createTextView(notice));
}
if (notices.size() > 1) {
startFlipping();
}
return true;
}
// 创建ViewFlipper下的TextView
private TextView createTextView(String text) {
TextView tv = new TextView(mContext);
tv.setGravity(Gravity.LEFT|Gravity.CENTER_VERTICAL);
tv.setText(text);
tv.setTextColor(textColor);
tv.setTextSize(textSize);
return tv;
}
public List<String> getNotices() {
return notices;
}
public void setNotices(List<String> notices) {
this.notices = notices;
}
}

View File

@ -0,0 +1,63 @@
package com.gh.common.view;
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
/**
* Created by khy on 2017/3/30.
*/
public class MeasureLinearLayoutManager extends LinearLayoutManager {
int height;
public MeasureLinearLayoutManager(Context context) {
super(context);
}
private int[] mMeasuredDimension = new int[1];
@Override
public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state,
int widthSpec, int heightSpec) {
super.onMeasure(recycler, state, widthSpec, heightSpec);
height = 0;
try {
for (int i = 0; i < getItemCount(); i++) {
measureScrapChild(recycler, i,
View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED),
View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED),
mMeasuredDimension);
height = height + mMeasuredDimension[0];
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void measureScrapChild(RecyclerView.Recycler recycler, int position, int widthSpec,
int heightSpec, int[] measuredDimension) throws Exception {
View view = recycler.getViewForPosition(position);
if (view.getVisibility() == View.GONE) {
measuredDimension[0] = 0;
return;
}
super.measureChildWithMargins(view, 0, 0);
RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams();
int childHeightSpec = ViewGroup.getChildMeasureSpec(
heightSpec,
getPaddingTop() + getPaddingBottom() + getDecoratedTop(view) + getDecoratedBottom(view),
p.height);
view.measure(0, childHeightSpec);
measuredDimension[0] = getDecoratedMeasuredHeight(view) + p.bottomMargin + p.topMargin;
recycler.recycleView(view);
}
public int getRvHeight() {
return height;
}
}

View File

@ -1,6 +1,5 @@
package com.gh.common.view;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
@ -10,27 +9,12 @@ import android.support.v4.view.GravityCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.ViewDragHelper;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.view.*;
import android.widget.*;
import com.gh.gamecenter.R;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 滑动的layout
@ -1625,8 +1609,9 @@ public class SwipeLayout extends FrameLayout {
setCurrentDragEdge(dragEdge);
}
@SuppressLint("Override")
protected void onViewRemoved(View child) {
@Override
public void onViewRemoved(View child) {
super.onViewRemoved(child);
for (Map.Entry<DragEdge, View> entry : new HashMap<DragEdge, View>(mDragEdges).entrySet()) {
if (entry.getValue() == child) {
mDragEdges.remove(entry.getKey());

View File

@ -14,30 +14,42 @@ public class VerticalItemDecoration extends RecyclerView.ItemDecoration {
private Paint paint;
private int mInterval = 0;
private boolean isShowIntervalTop;
public VerticalItemDecoration(Context context, int interval) {
public VerticalItemDecoration(Context context, int interval, boolean isShowIntervalTop) {
paint = new Paint();
paint.setColor(context.getResources().getColor(R.color.background));
paint.setColor(context.getResources().getColor(R.color.background ));
mInterval = DisplayUtils.dip2px(context, interval);
this.isShowIntervalTop = isShowIntervalTop;
}
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
int left = parent.getPaddingLeft();
int right = parent.getMeasuredWidth() - parent.getPaddingRight();
for (int i = 0, size = parent.getChildCount() - 1; i < size; i++) {
for (int i = 0, size = parent.getChildCount(); i < size; i++) {
View child = parent.getChildAt(i);
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child
.getLayoutParams();
int top = child.getBottom() + layoutParams.bottomMargin;
int bottom = top + mInterval;
c.drawRect(left, top, right, bottom, paint);
if (i == 0 && isShowIntervalTop) {
c.drawRect(left, 0, right, bottom, paint);
} else {
c.drawRect(left, top, right, bottom, paint);
}
}
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
RecyclerView.State state) {
outRect.set(0, 0, 0, mInterval);
int position = parent.getChildPosition(view);
if (position == 0 && isShowIntervalTop) {
outRect.set(0, mInterval, 0, mInterval);
} else {
outRect.set(0, 0, 0, mInterval);
}
}
}

View File

@ -25,6 +25,7 @@ public class ZoomSimpleDraweeView extends SimpleDraweeView {
private float mCurrentScale = 1f;
private Matrix mCurrentMatrix;
private setOnSingleClickListener mClickListener;
private setOnLongClickListener mLongClickListener;
private float imgagePro = -1; // 图片宽高比
@ -82,6 +83,14 @@ public class ZoomSimpleDraweeView extends SimpleDraweeView {
return true;
}
@Override
public void onLongPress(MotionEvent e) {
super.onLongPress(e);
if (mLongClickListener != null) {
mLongClickListener.onLongClick();
}
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (mCurrentScale > 1f) {
@ -273,6 +282,14 @@ public class ZoomSimpleDraweeView extends SimpleDraweeView {
mClickListener = listener;
}
public void setOnLongClickListener(setOnLongClickListener listener) {
mLongClickListener = listener;
}
public interface setOnLongClickListener {
void onLongClick();
}
public interface setOnSingleClickListener {
void onClick();
}

View File

@ -9,6 +9,7 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import com.gh.base.BaseActivity;
import com.gh.common.util.PackageUtils;
import com.gh.gamecenter.manager.UpdateManager;
import butterknife.BindView;
@ -43,6 +44,8 @@ public class AboutActivity extends BaseActivity {
View view = View.inflate(this, R.layout.activity_about, null);
init(view, "关于");
((TextView) findViewById(R.id.about_tv_version)).setText("V" + PackageUtils.getVersionName(this));
UpdateManager.getInstance(this).checkUpdate(false, handler); // 自动检出更新
}

View File

@ -82,6 +82,9 @@ public class ChooseReceiverActivity extends BaseActivity implements View.OnClick
@BindView(R.id.choosereceiver_roket_anim_top) ImageView mRoketTop;
@BindView(R.id.choosereceiver_roket_left) ImageView mRoketAnimLeft;
@BindView(R.id.choosereceiver_roket_right) ImageView mRoketAnimRight;
@BindView(R.id.actionbar_iv_back) ImageView mBackIv;
@BindView(R.id.actionbar_tv_title) TextView mTitleTv;
private List<ScanResult> mScanResultList;
@ -120,6 +123,9 @@ public class ChooseReceiverActivity extends BaseActivity implements View.OnClick
View contentView = View.inflate(this, R.layout.activity_choosereceiver, null);
init(contentView, "发送游戏");
mTitleTv.setTextColor(Color.WHITE);
mBackIv.setImageResource(R.drawable.reuse_kc_back);
// 添加分享图标
TextView hintTv = new TextView(this);

View File

@ -17,6 +17,7 @@ import android.widget.TextView;
import com.gh.base.BaseActivity;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.Utils;
import com.gh.common.view.VerticalItemDecoration;
import com.gh.gamecenter.adapter.CleanApkAdapter;
import com.gh.gamecenter.entity.InstallGameEntity;
import com.gh.gamecenter.eventbus.EBSkip;
@ -57,6 +58,7 @@ public class CleanApkActivity extends BaseActivity implements CleanApkAdapter.On
mAdapter = new CleanApkAdapter(this, mApkDeleteBtn, mApkSelectAll);
mApkRv.setLayoutManager(new LinearLayoutManager(this));
mApkRv.addItemDecoration(new VerticalItemDecoration(this, 8, true));
mApkRv.setAdapter(mAdapter);
mApkSelectAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

View File

@ -0,0 +1,46 @@
package com.gh.gamecenter;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.gh.base.BaseActivity;
import com.gh.gamecenter.adapter.CommentDetailAdapter;
import butterknife.BindView;
/**
* Created by khy on 2017/3/22.
*/
public class CommentDetailActivity extends BaseActivity {
@BindView(R.id.comment_detail_rv) RecyclerView mRecyclerView;
private CommentDetailAdapter mAdapter;
private LinearLayoutManager mLayoutManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View view = View.inflate(this, R.layout.activity_comment_detail, null);
init(view, "查看对话");
String commentId = getIntent().getExtras().getString("commentId");
mAdapter = new CommentDetailAdapter(this, commentId);
mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == RecyclerView.SCROLL_STATE_IDLE && !mAdapter.isOver() && !mAdapter.isLoading()) {
mAdapter.loadData(mAdapter.getItemCount());
}
}
});
}
}

View File

@ -1,248 +1,624 @@
package com.gh.gamecenter;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.*;
import butterknife.BindView;
import butterknife.OnClick;
import com.facebook.drawee.view.SimpleDraweeView;
import com.gh.base.AppController;
import com.gh.base.BaseDetailActivity;
import com.gh.common.util.DataCollectionUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DialogUtils;
import com.gh.gamecenter.changeskin.ChangeSkinUtils;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.eventbus.EBConcernChanged;
import com.gh.gamecenter.gamedetail.GameDetailAdapter;
import com.gh.base.BaseFragmentActivity;
import com.gh.common.constant.Config;
import com.gh.common.util.*;
import com.gh.common.view.DownloadDialog;
import com.gh.common.view.NoScrollableViewPager;
import com.gh.download.*;
import com.gh.gamecenter.adapter.FragmentAdapter;
import com.gh.gamecenter.entity.*;
import com.gh.gamecenter.eventbus.*;
import com.gh.gamecenter.gamedetail.FuliFragment;
import com.gh.gamecenter.gamedetail.XinXiFragment;
import com.gh.gamecenter.manager.ConcernManager;
import com.gh.gamecenter.manager.PackageManager;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.jakewharton.rxbinding.view.RxView;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import butterknife.BindView;
import com.tencent.tauth.Tencent;
import retrofit2.adapter.rxjava.HttpException;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import rx.schedulers.Schedulers;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* Created by khy on 2016/8/12.
*
* Created by khy on 2017/3/24.
* 游戏详情适配器
*/
public class GameDetailActivity extends BaseDetailActivity implements View.OnClickListener{
public class GameDetailActivity extends BaseFragmentActivity {
private GameDetailAdapter adapter;
@BindView(R.id.gamedetail_vp) NoScrollableViewPager mViewPager;
@BindView(R.id.gamedetail_top) RelativeLayout mTopLl;
@BindView(R.id.gamedetail_tabbar_rl) RelativeLayout mTabBarRl;
@BindView(R.id.reuse_ll_loading) LinearLayout mLoading;
@BindView(R.id.reuse_no_connection) LinearLayout mNoConnection;
@BindView(R.id.actionbar_tv_title) TextView mTitle;
@BindView(R.id.gamedetail_iv_thumb) SimpleDraweeView mGameIcon;
@BindView(R.id.gamedetail_tv_name) TextView mGameName;
@BindView(R.id.gamedetail_tv_info) TextView mGameInfo;
@BindView(R.id.gamedetail_tv_concern) TextView mGameConcern;
@BindView(R.id.gamedetail_tabbar) LinearLayout mTabBar;
@BindView(R.id.gamedetail_tabbar_fuli) TextView mTanBarFuLi;
@BindView(R.id.gamedetail_tabbar_xinxi) TextView mTanBarXinXi;
@BindView(R.id.gamedetail_tabbar_fuli_tv) TextView mTanBarFuLiTv;
@BindView(R.id.gamedetail_tabbar_xinxi_tv) TextView mTanBarXinXiTv;
@BindView(R.id.gamedetail_share) ImageView mShareIv;
@BindView(R.id.detail_ll_bottom) LinearLayout mDownloadBottom;
@BindView(R.id.detail_tv_download) TextView mDownloadTv;
@BindView(R.id.detail_tv_per) TextView mDownloadPer;
@BindView(R.id.detail_pb_progressbar) ProgressBar mDownloadPb;
private String gameId;
private RelativeLayout.LayoutParams top_rparams;
private long start;
private ConcernManager mConcernManager;
private boolean isSentReport;
private String mGameId;
@BindView(R.id.actionbar_rl_back) RelativeLayout actionbar_rl_back;
private GameEntity mGameEntity;
private DownloadEntity mDownloadEntity;
private String downloadAddWord;
private String downloadOffText;
private String name;
private String title;
private String shareCode;
private DataWatcher dataWatcher = new DataWatcher() {
@Override
public void onDataChanged(DownloadEntity downloadEntity) {
if (mGameEntity != null && mGameEntity.getApk().size() == 1) {
String url = mGameEntity.getApk().get(0).getUrl();
if (url.equals(downloadEntity.getUrl())) {
if (!"pause".equals(DownloadManager.getInstance(GameDetailActivity.this).
getStatus(downloadEntity.getUrl()))) {
mDownloadEntity = downloadEntity;
invalidate();
}
}
}
}
};
//接收QQ或者QQ空间分享回调
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
AppController.put("GameEntity", gameEntity);
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == com.tencent.connect.common.Constants.REQUEST_QQ_SHARE
|| requestCode == com.tencent.connect.common.Constants.REQUEST_QZONE_SHARE) {
Tencent.onActivityResultData(requestCode, resultCode, data, ShareUtils.getInstance(this).QqShareListener);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View view = View.inflate(GameDetailActivity.this, R.layout.activity_game_detail, null);
init(view);
start = System.currentTimeMillis();
mViewPager.setScrollable(false);
mConcernManager = new ConcernManager(GameDetailActivity.this);
name = "游戏详情";
isSentReport = false;
gameId = getIntent().getStringExtra("gameId");
mGameId = getIntent().getStringExtra("gameId");
if (getIntent().getBundleExtra("data") != null) {
gameId = getIntent().getBundleExtra("data").getString("gameId");
mGameId = getIntent().getBundleExtra("data").getString("gameId");
}
if (gameId == null) {
gameEntity = (GameEntity) AppController.get("GameEntity", true);
if (gameEntity != null) {
title = gameEntity.getName();
actionbar_tv_title.setText(gameEntity.getName());
if (mGameId == null) {
mGameEntity = (GameEntity) AppController.get("GameEntity", false);
if (mGameEntity != null) {
mGameId = mGameEntity.getId();
mTitle.setText(mGameEntity.getName());
name = mGameEntity.getName();
}
}
adapter = new GameDetailAdapter(this, entrance);
detail_rv_show.setLayoutManager(new LinearLayoutManager(this));
detail_rv_show.setAdapter(adapter);
detail_ll_bottom.setOnClickListener(this);
detail_tv_download.setOnClickListener(this);
detail_tv_per.setOnClickListener(this);
reuse_no_connection.setOnClickListener(this);
actionbar_rl_back.setOnClickListener(this);
if (gameEntity != null) {
adapter.setGameEntity(gameEntity);
adapter.getGameDetail();
} else if (gameId != null) {
if (mGameEntity != null) {
getGameDetail();
} else if (mGameId != null) {
getGameDigest();
} else {
reuse_ll_loading.setVisibility(View.GONE);
reuse_no_connection.setVisibility(View.VISIBLE);
mLoading.setVisibility(View.GONE);
mNoConnection.setVisibility(View.VISIBLE);
}
// 防抖处理
RxView.clicks(iv_share)
.throttleFirst(1, TimeUnit.SECONDS)
.subscribe(new Action1<Void>() {
@Override
public void call(Void aVoid) {
Map<String, Object> kv = new HashMap<>();
kv.put("点击", "分享");
DataUtils.onEvent(GameDetailActivity.this, "插件数据", gameEntity.getName(), kv);
DataCollectionUtils.uploadClick(GameDetailActivity.this, "分享", "游戏详情", gameEntity.getName());
String url = "http://www.ghzhushou.com/game/" + adapter.getGameDetailEntity().getShareCode();
showShare(url, gameEntity.getName(), gameEntity.getIcon(), null, gameEntity.getTag());
}
});
}
private void initGameDetailTop() {
@Override
public void loadDone() {
if (reuse_ll_loading.getVisibility() == View.VISIBLE) {
reuse_ll_loading.setVisibility(View.GONE);
mLoading.setVisibility(View.GONE);
mTopLl.setVisibility(View.VISIBLE);
top_rparams = (RelativeLayout.LayoutParams) mTopLl.getLayoutParams();
if (mConcernManager.isConcern(mGameEntity.getId())) {
mGameConcern.setText("取消关注");
mGameConcern.setBackgroundResource(R.drawable.border_red_bg);
mGameConcern.setTextColor(Color.parseColor("#ff4147"));
} else {
mGameConcern.setText("关注");
mGameConcern.setBackgroundResource(R.drawable.textview_concern_red_style);
mGameConcern.setTextColor(0xffffffff);
}
if (!TextUtils.isEmpty(adapter.getGameDetailEntity().getShareCode())) {
iv_share.setVisibility(View.VISIBLE);
mGameName.setText(mGameEntity.getName());
ImageUtils.display(mGameIcon, mGameEntity.getIcon());
if (mGameEntity.getApk() == null || mGameEntity.getApk().isEmpty()) {
mGameInfo.setText("");
} else {
ApkEntity apkEntity = mGameEntity.getApk().get(0);
mGameInfo.setText(String.format("V%s | %s", apkEntity.getVersion(), apkEntity.getSize()));
}
downloadAddWord = adapter.getGameDetailEntity().getDownloadAddWord();
downloadOffText = adapter.getGameDetailEntity().getDownloadOffText();
initDownload(true);
}
mGameConcern.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final TextView concern = (TextView) v;
if ("关注".equals(concern.getText().toString())) {
@Override
public void loadError() {
reuse_ll_loading.setVisibility(View.GONE);
reuse_no_connection.setVisibility(View.VISIBLE);
}
Map<String, Object> kv = new HashMap<>();
kv.put("状态", "关注");
DataUtils.onEvent(GameDetailActivity.this, "游戏关注", mGameEntity.getName(), kv);
@Override
public void onClick(View v) {
super.onClick(v);
if (v == reuse_no_connection) {
reuse_no_connection.setVisibility(View.GONE);
reuse_ll_loading.setVisibility(View.VISIBLE);
handler.postDelayed(new Runnable() {
@Override
public void run() {
if (gameEntity != null) {
adapter.getGameDetail();
} else if (gameId != null) {
getGameDigest();
} else {
reuse_ll_loading.setVisibility(View.GONE);
reuse_no_connection.setVisibility(View.VISIBLE);
}
Map<String, Object> kv2 = new HashMap<>();
kv2.put("点击", "关注");
DataUtils.onEvent(GameDetailActivity.this, "插件数据", mGameEntity.getName(), kv2);
DataCollectionUtils.uploadConcern(GameDetailActivity.this, mGameEntity.getName(), mGameEntity.getId(), "关注");
mConcernManager.addByEntity(mGameEntity);
concern.setText("取消关注");
concern.setBackgroundResource(R.drawable.border_red_bg);
concern.setTextColor(Color.parseColor("#ff4147"));
Toast.makeText(GameDetailActivity.this, "关注成功", Toast.LENGTH_SHORT).show();
// 添加关注
ConcernUtils.postConcernGameId(GameDetailActivity.this, mGameEntity.getId());
} else {
Map<String, Object> kv2 = new HashMap<>();
kv2.put("点击", "取消关注");
DataUtils.onEvent(GameDetailActivity.this, "插件数据", mGameEntity.getName(), kv2);
DialogUtils.showCancelDialog(GameDetailActivity.this, new DialogUtils.ConfiremListener() {
@Override
public void onConfirem() {
Map<String, Object> kv = new HashMap<>();
kv.put("状态", "取消关注");
DataUtils.onEvent(GameDetailActivity.this, "游戏关注", mGameEntity.getName(), kv);
DataCollectionUtils.uploadConcern(GameDetailActivity.this,
mGameEntity.getName(), mGameEntity.getId(), "取消关注");
mConcernManager.deleteConcern(mGameEntity.getId());
concern.setText("关注");
concern.setBackgroundResource(R.drawable.textview_concern_red_style);
concern.setTextColor(0xffffffff);
// 取消关注
ConcernUtils.deleteConcernData(GameDetailActivity.this, mGameEntity.getId());
}
});
}
}, 1000);
} else if (v == actionbar_rl_back) {
if (ChangeSkinUtils.isChecking) {
DialogUtils.showWarningDialog(GameDetailActivity.this, "退出提示",
"素材更新还在检测中,如果强行退出会中断所有进度,确定退出?",
"取消", "强行退出", new DialogUtils.ConfiremListener() {
@Override
public void onConfirem() {
finish();
}
}, null);
} else {
finish();
}
});
}
}
// 获取游戏摘要
private void getGameDigest() {
RetrofitManager.getApi().getGameDigest(gameId)
RetrofitManager.getApi().getGameDigest(mGameId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<GameEntity>() {
@Override
public void onResponse(GameEntity response) {
gameEntity = response;
mGameEntity = response;
AppController.put("GameEntity", response);
title = gameEntity.getName();
actionbar_tv_title.setText(gameEntity.getName());
adapter.setGameEntity(gameEntity);
adapter.getGameDetail();
mTitle.setText(mGameEntity.getName());
mGameId = response.getId();
name = mGameEntity.getName();
getGameDetail();
}
@Override
public void onFailure(HttpException e) {
reuse_no_connection.setVisibility(View.VISIBLE);
Utils.log("=======onError::getGameDetail" );
mLoading.setVisibility(View.GONE);
mNoConnection.setVisibility(View.VISIBLE);
}
});
}
// 关注事件
public void onEventMainThread(EBConcernChanged changed) {
if (!TextUtils.isEmpty(gameId) && changed.isSingle() && changed.getGameId().equals(gameId)) {
adapter.notifyItemChanged(0);
// 获取游戏详情
public void getGameDetail() {
RetrofitManager.getApi().getGameDetail(mGameId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<GameDetailEntity>() {
@Override
public void onResponse(GameDetailEntity response) {
// 过滤过期公告
if (response.getNotice() != null && response.getNotice().size() > 0) {
long l = System.currentTimeMillis();
for (int i = 0; i < response.getNotice().size(); i++) {
if (l > (response.getNotice().get(i).getOvertime()*1000)) {
response.getNotice().remove(i);
i --;
}
}
}
AppController.put("GameDetailEntity", response);
downloadAddWord = response.getDownloadAddWord();
downloadOffText = response.getDownloadOffText();
shareCode = response.getShareCode();
List<Fragment> list = new ArrayList<>();
if (mGameEntity != null && !mGameEntity.isLibaoExists()
&& TextUtils.isEmpty(response.getFulishuoming())
&& (response.getKaiFuServer() == null
|| (response.getKaiFuServer() != null
&& response.getKaiFuServer().size() == 0))) {
XinXiFragment xinXiFragment = new XinXiFragment();
xinXiFragment.setIsTabBar(true);
list.add(xinXiFragment);
mTabBar.setVisibility(View.GONE);
} else {
list.add(new FuliFragment());
list.add(new XinXiFragment());
}
mViewPager.setAdapter(new FragmentAdapter(getSupportFragmentManager(), list));
initGameDetailTop();
initDownload(true);
}
@Override
public void onError(Throwable e) {
super.onError(e);
Utils.log("=======onError::getGameDetail" + e.toString());
}
@Override
public void onFailure(HttpException e) {
}
});
}
public void onEventMainThread(EBMoveTop moveTop) {
if (moveTop.getType().equals("top")) {
if (moveTop.getVisibility() == View.VISIBLE && mTabBar.getVisibility() == View.VISIBLE) {
mTabBarRl.setVisibility(View.VISIBLE);
} else {
mTabBarRl.setVisibility( View.GONE);
}
int topMargin = moveTop.getTopMargin();
if (top_rparams != null && top_rparams.topMargin != topMargin) {
if (topMargin > -120) {
mTitle.setVisibility(View.GONE);
} else {
mTitle.setVisibility(View.VISIBLE);
}
top_rparams.topMargin = moveTop.getTopMargin();
mTopLl.setLayoutParams(top_rparams);
}
}
}
// 接收下载被删除消息
public void onEvent(EBDownloadStatus status) {
if ("delete".equals(status.getStatus())
&& mGameEntity != null
&& mGameEntity.getApk() != null
&& mGameEntity.getApk().size() == 1) {
String url = mGameEntity.getApk().get(0).getUrl();
if (url.equals(status.getUrl())) {
initDownload(false);
}
}
}
// 接受安装、卸载消息
public void onEventMainThread(EBPackage busFour) {
if (mGameEntity != null
&& mGameEntity.getApk() != null
&& mGameEntity.getApk().size() == 1) {
String packageName = mGameEntity.getApk().get(0).getPackageName();
if (packageName.equals(busFour.getPackageName())) {
initDownload(false);
}
}
}
@Override
protected void onResume() {
super.onResume();
if (mGameEntity != null
&& mGameEntity.getApk() != null
&& mGameEntity.getApk().size() == 1) {
initDownload(true);
}
DownloadManager.getInstance(this).addObserver(dataWatcher);
}
@Override
protected void onPause() {
super.onPause();
if (!isSentReport) {
long end = System.currentTimeMillis();
DownloadManager.getInstance(this).removeObserver(dataWatcher);
}
int seconds = (int) ((end - start) / 1000);
String cost;
if (seconds < 5) {
cost = "小于5秒";
} else if (seconds < 30) {
cost = "5秒30秒";
} else if (seconds < 60) {
cost = "30秒60秒";
@OnClick({R.id.detail_tv_download, R.id.detail_pb_progressbar
, R.id.detail_tv_per, R.id.gamedetail_tabbar_xinxi, R.id.gamedetail_tabbar_xinxi_tv
, R.id.gamedetail_tabbar_fuli, R.id.gamedetail_tabbar_fuli_tv, R.id.gamedetail_share})
public void onClick(View v) {
if (v == mDownloadTv) {
if (mGameEntity != null && !mGameEntity.getApk().isEmpty()) {
if (mGameEntity.getApk().size() == 1) {
if (NetworkUtils.isWifiConnected(this)) {
download();
} else {
DialogUtils.showDownloadDialog(this, new DialogUtils.ConfiremListener() {
@Override
public void onConfirem() {
download();
}
});
}
} else {
DownloadDialog.getInstance(this).showPopupWindow(v, mGameEntity, entrance, name + ":" + title);
}
} else {
cost = "大于60秒";
toast("稍等片刻~!游戏正在上传中...");
}
} else if (v == mDownloadPb || v == mDownloadPer) {
String str = mDownloadPer.getText().toString();
if ("下载中".equals(str)) {
Intent intent = new Intent(this, DownloadManagerActivity.class);
intent.putExtra("currentItem", 1);
intent.putExtra("url", mGameEntity.getApk().get(0).getUrl());
intent.putExtra("entrance", entrance + "+(" + name + "[" + title + "])");
startActivity(intent);
} else if ("安装".equals(str)) {
PackageUtils.launchSetup(this, mDownloadEntity.getPath());
}
} else if (v == mTanBarFuLi || v == mTanBarFuLiTv) {
mTanBarFuLi.setTextColor(Color.WHITE);
mTanBarFuLiTv.setTextColor(Color.WHITE);
mTanBarFuLi.setBackgroundResource(R.drawable.gamedetail_tag_select_bg);
mTanBarFuLiTv.setBackgroundResource(R.drawable.gamedetail_tag_select_bg);
mTanBarXinXi.setTextColor(Color.BLACK);
mTanBarXinXiTv.setTextColor(Color.BLACK);
mTanBarXinXi.setBackgroundDrawable(new ColorDrawable(0));
mTanBarXinXiTv.setBackgroundDrawable(new ColorDrawable(0));
mViewPager.setCurrentItem(0);
if (gameEntity != null && !TextUtils.isEmpty(gameEntity.getName())) {
Map<String, Object> kv = new HashMap<>();
kv.put("停留时长", cost);
DataUtils.onEvent(this, "插件数据", gameEntity.getName(), kv);
} else if (v == mTanBarXinXi || v == mTanBarXinXiTv) {
mTanBarXinXiTv.setTextColor(Color.WHITE);
mTanBarXinXi.setTextColor(Color.WHITE);
mTanBarXinXiTv.setBackgroundResource(R.drawable.gamedetail_tag_unselect_bg);
mTanBarXinXi.setBackgroundResource(R.drawable.gamedetail_tag_unselect_bg);
mTanBarFuLi.setTextColor(Color.BLACK);
mTanBarFuLiTv.setTextColor(Color.BLACK);
mTanBarFuLi.setBackgroundDrawable(new ColorDrawable(0));
mTanBarFuLiTv.setBackgroundDrawable(new ColorDrawable(0));
mViewPager.setCurrentItem(1);
} else if (v == mShareIv) {
if (TextUtils.isEmpty(shareCode)) return;
// 防抖处理
RxView.clicks(mShareIv)
.throttleFirst(1, TimeUnit.SECONDS)
.subscribe(new Action1<Void>() {
@Override
public void call(Void aVoid) {
Map<String, Object> kv = new HashMap<>();
kv.put("点击", "分享");
DataUtils.onEvent(GameDetailActivity.this, "插件数据", mGameEntity.getName(), kv);
if (seconds > 0) {
DataCollectionUtils.uploadGame(this, gameEntity, seconds, entrance);
DataCollectionUtils.uploadClick(GameDetailActivity.this, "分享", "游戏详情", mGameEntity.getName());
String url = "http://www.ghzhushou.com/game/" + shareCode;
showShare(url, mGameEntity.getName(), mGameEntity.getIcon(), null, mGameEntity.getTag());
}
});
}
}
private void download() {
String str = mDownloadTv.getText().toString();
if (str.contains("启动")) {
DataUtils.onGameLaunchEvent(this, mGameEntity.getName(), mGameEntity.getApk().get(0).getPlatform(), name);
PackageUtils.launchApplicationByPackageName(this, mGameEntity.getApk().get(0).getPackageName());
} else {
String method;
if (str.contains("更新")) {
method = "更新";
} else if (str.contains("插件化")) {
method = "插件化";
} else {
method = "下载";
}
ApkEntity apkEntity = mGameEntity.getApk().get(0);
String msg = FileUtils.isCanDownload(this, apkEntity.getSize());
if (TextUtils.isEmpty(msg)) {
DataUtils.onGameDownloadEvent(this, mGameEntity.getName(), apkEntity.getPlatform(), entrance, "下载开始");
DownloadManager.createDownload(this, apkEntity, mGameEntity, method, entrance, name + ":" + title);
mDownloadTv.setVisibility(View.GONE);
mDownloadPb.setVisibility(View.VISIBLE);
mDownloadPer.setVisibility(View.VISIBLE);
mDownloadPb.setProgress(0);
mDownloadPer.setText("0.0%");
DownloadManager.getInstance(GameDetailActivity.this).putStatus(apkEntity.getUrl(), "downloading");
} else {
toast(msg);
}
}
}
private void invalidate() {
mDownloadPb.setProgress((int) (mDownloadEntity.getPercent() * 10));
mDownloadPer.setTextColor(0xFFFFFFFF);
switch (mDownloadEntity.getStatus()) {
case downloading:
case pause:
case timeout:
case neterror:
case waiting:
mDownloadPer.setText("下载中");
break;
case done:
mDownloadPer.setText("安装");
if (mDownloadEntity.isPluggable()
&& PackageManager.isInstalled(mDownloadEntity.getPackageName())) {
mDownloadPb.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar_plugin_radius_style));
} else {
mDownloadPb.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar_normal_radius_style));
}
break;
case cancel:
case hijack:
case notfound:
initDownload(false);
break;
default:
break;
}
}
protected void initDownload(boolean isCheck) {
if (Config.isShow(this)) {
mDownloadBottom.setVisibility(View.VISIBLE);
} else {
mDownloadBottom.setVisibility(View.GONE);
}
if (mGameEntity != null && "光环助手".equals(mGameEntity.getName())) {
mDownloadBottom.setVisibility(View.GONE);
} else if (mGameEntity == null || mGameEntity.getApk().isEmpty()) {
mDownloadTv.setVisibility(View.VISIBLE);
mDownloadPb.setVisibility(View.GONE);
mDownloadPer.setVisibility(View.GONE);
if (TextUtils.isEmpty(downloadOffText)) {
mDownloadTv.setText("暂无下载");
} else {
mDownloadTv.setText(downloadOffText);
}
mDownloadTv.setBackgroundResource(R.drawable.game_item_btn_pause_style);
mDownloadTv.setTextColor(0xFF999999);
mDownloadTv.setClickable(false);
} else {
mDownloadTv.setVisibility(View.VISIBLE);
mDownloadPb.setVisibility(View.GONE);
mDownloadPer.setVisibility(View.GONE);
boolean isInstalled = false;
if (mGameEntity.getApk() != null && mGameEntity.getApk().size() == 1
&& PackageManager.isInstalled(mGameEntity.getApk().get(0).getPackageName())) {
isInstalled = true;
}
if (isInstalled) {
if (PackageManager.isCanUpdate(mGameEntity.getId(), mGameEntity.getApk().get(0).getPackageName())) {
if (TextUtils.isEmpty(downloadAddWord)) {
mDownloadTv.setBackgroundResource(
R.drawable.game_item_btn_download_style);
mDownloadTv.setText(String.format("更新《%s》",
mGameEntity.getName()));
} else {
mDownloadTv.setBackgroundResource(
R.drawable.game_item_btn_download_style);
mDownloadTv.setText(String.format("更新《%s》%s",
mGameEntity.getName(), downloadAddWord));
}
} else {
if (mGameEntity.getTag() != null && mGameEntity.getTag().size() != 0
&& !TextUtils.isEmpty(mGameEntity.getApk().get(0).getGhVersion())
&& !PackageUtils.isSignature(this, mGameEntity.getApk().get(0).getPackageName())) {
if (TextUtils.isEmpty(downloadAddWord)) {
mDownloadTv.setBackgroundResource(
R.drawable.game_item_btn_plugin_style);
mDownloadTv.setText(String.format("插件化《%s》",
mGameEntity.getName()));
} else {
mDownloadTv.setBackgroundResource(
R.drawable.game_item_btn_plugin_style);
mDownloadTv.setText(String.format("插件化《%s》%s",
mGameEntity.getName(), downloadAddWord));
}
} else {
if (TextUtils.isEmpty(downloadAddWord)) {
mDownloadTv.setBackgroundResource(
R.drawable.game_item_btn_launch_style);
mDownloadTv.setText(String.format("启动《%s》",
mGameEntity.getName()));
} else {
mDownloadTv.setBackgroundResource(
R.drawable.game_item_btn_launch_style);
mDownloadTv.setText(String.format("启动《%s》%s",
mGameEntity.getName(), downloadAddWord));
}
}
}
} else {
String status = GameUtils.getDownloadBtnText(this, mGameEntity);
if ("插件化".equals(status)) {
mDownloadTv.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
} else if ("打开".equals(status)) {
mDownloadTv.setBackgroundResource(R.drawable.game_item_btn_launch_style);
} else {
mDownloadTv.setBackgroundResource(R.drawable.game_item_btn_download_style);
}
if (TextUtils.isEmpty(downloadAddWord)) {
mDownloadTv.setText(String.format(status + "《%s》",
mGameEntity.getName()));
} else {
mDownloadTv.setText(String.format(status + "《%s》%s",
mGameEntity.getName(), downloadAddWord));
}
}
isSentReport = true;
}
if (isCheck && mGameEntity != null
&& mGameEntity.getApk() != null
&& mGameEntity.getApk().size() == 1) {
String url = mGameEntity.getApk().get(0).getUrl();
DownloadEntity downloadEntity = DownloadManager.getInstance(getApplicationContext()).get(url);
if (downloadEntity != null) {
mDownloadEntity = downloadEntity;
mDownloadTv.setVisibility(View.GONE);
mDownloadPb.setVisibility(View.VISIBLE);
mDownloadPer.setVisibility(View.VISIBLE);
invalidate();
}
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0 && ChangeSkinUtils.isChecking) {
DialogUtils.showWarningDialog(GameDetailActivity.this, "退出提示",
"素材更新还在检测中,如果强行退出会中断所有进度,确定退出?",
"取消", "强行退出", new DialogUtils.ConfiremListener() {
@Override
public void onConfirem() {
finish();
}
}, null);
return true;
}
return super.onKeyDown(keyCode, event);
}
}

View File

@ -5,6 +5,7 @@ import android.support.v4.util.ArrayMap;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
@ -16,10 +17,16 @@ import com.gh.common.util.DisplayUtils;
import com.gh.gamecenter.adapter.GameNewsAdapter;
import com.gh.gamecenter.adapter.GameNewsTypeListAdapter;
import com.gh.gamecenter.eventbus.EBTypeChange;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import retrofit2.adapter.rxjava.HttpException;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
/**
* Created by LGT on 2016/8/29.
@ -37,7 +44,7 @@ public class GameNewsActivity extends BaseActivity implements View.OnClickListen
private ArrayMap<String, GameNewsAdapter> adapterMap;
private ArrayList<String> typeList;
private List<String> typeList;
private String gameId;
private String entrance;
@ -71,17 +78,14 @@ public class GameNewsActivity extends BaseActivity implements View.OnClickListen
adapterMap = new ArrayMap<>();
typeList = getIntent().getStringArrayListExtra("articleTypes");
typeList.add(0, "全部");
typeList = new ArrayList<>();
gameId = getIntent().getStringExtra("gameId");
game_news_list.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
game_news_list.setLayoutManager(layoutManager);
adapter = new GameNewsAdapter(this, typeList, game_news_list, gameId, "全部", entrance);
adapterMap.put("全部", adapter);
game_news_list.setAdapter(adapter);
game_news_list.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
@ -100,7 +104,7 @@ public class GameNewsActivity extends BaseActivity implements View.OnClickListen
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == RecyclerView.SCROLL_STATE_IDLE
if (adapter != null && newState == RecyclerView.SCROLL_STATE_IDLE
&& layoutManager.findLastVisibleItemPosition() == adapter.getItemCount() - 1) {
if (!adapter.isRemove() && !adapter.isLoading() && !adapter.isNetworkError()) {
adapter.addList(adapter.getNewsList().size());
@ -111,12 +115,6 @@ public class GameNewsActivity extends BaseActivity implements View.OnClickListen
game_news_top_type_list.setHasFixedSize(true);
game_news_top_type_list.setLayoutManager(new GridLayoutManager(this, 5));
typeListAdapter = new GameNewsTypeListAdapter(typeList, "全部");
game_news_top_type_list.setAdapter(typeListAdapter);
ViewGroup.LayoutParams params = game_news_top_type_list.getLayoutParams();
params.height = (int) Math.ceil(typeList.size() / 5f) * DisplayUtils.dip2px(this, 35)+ DisplayUtils.dip2px(this, 12);
game_news_top_type_list.setLayoutParams(params);
//禁止由于滑动出现的阴影
game_news_top_type_list.setOnTouchListener(new View.OnTouchListener() {
@ -132,12 +130,47 @@ public class GameNewsActivity extends BaseActivity implements View.OnClickListen
return false;
}
});
if (!TextUtils.isEmpty(gameId)) {
getGameArticleType();
}
}
private void getGameArticleType() {
RetrofitManager.getApi()
.getGameArticleType(gameId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<List<String>>(){
@Override
public void onResponse(List<String> response) {
super.onResponse(response);
typeList = response;
typeList.add(0, "全部");
adapter = new GameNewsAdapter(GameNewsActivity.this, typeList, game_news_list, gameId, "全部", entrance);
adapterMap.put("全部", adapter);
game_news_list.setAdapter(adapter);
typeListAdapter = new GameNewsTypeListAdapter(typeList, "全部");
game_news_top_type_list.setAdapter(typeListAdapter);
ViewGroup.LayoutParams params = game_news_top_type_list.getLayoutParams();
params.height = (int) Math.ceil(typeList.size() / 5f) * DisplayUtils.dip2px(GameNewsActivity.this, 35)
+ DisplayUtils.dip2px(GameNewsActivity.this, 12);
game_news_top_type_list.setLayoutParams(params);
}
@Override
public void onFailure(HttpException e) {
super.onFailure(e);
}
});
}
public void onEventMainThread(EBTypeChange change) {
adapter = adapterMap.get(change.getType());
if (adapter == null) {
adapter = new GameNewsAdapter(this, typeList, game_news_list, gameId, change.getType(), entrance);
adapter = new GameNewsAdapter(GameNewsActivity.this, typeList, game_news_list, gameId, change.getType(), entrance);
adapterMap.put(change.getType(), adapter);
}
game_news_list.setAdapter(adapter);

View File

@ -0,0 +1,411 @@
package com.gh.gamecenter;
import android.animation.Animator;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
import com.gh.base.BaseActivity;
import com.gh.common.util.DownloadItemUtils;
import com.gh.common.util.MeasureHeightLayoutManager;
import com.gh.common.view.VerticalItemDecoration;
import com.gh.download.DataWatcher;
import com.gh.download.DownloadEntity;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.adapter.KaiFuAdapter;
import com.gh.gamecenter.adapter.KaiFuDialogAdapter;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.eventbus.EBDownloadStatus;
import com.gh.gamecenter.eventbus.EBNetworkState;
import com.gh.gamecenter.eventbus.EBPackage;
import com.jakewharton.rxbinding.view.RxView;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import butterknife.BindView;
import rx.functions.Action1;
/**
* Created by khy on 2017/3/16.
* 首页-开服表
*/
public class KaiFuActivity extends BaseActivity implements KaiFuDialogAdapter.OnKaiFuDialogCallBackListener
, KaiFuAdapter.OnScrollToKaiFuIndex, SwipeRefreshLayout.OnRefreshListener{
@BindView(R.id.kaifu_rv) RecyclerView mRecyclerView;
@BindView(R.id.kaifu_pb) ProgressBarCircularIndeterminate mPbLoading;
@BindView(R.id.kaifu_refresh) SwipeRefreshLayout mRefreshLayout;
@BindView(R.id.kaifu_game_name) TextView mGameName;
@BindView(R.id.popup_bg) View mPopupBg;
@BindView(R.id.kaifu_select_game_rl) RelativeLayout mSelectGameRl;
@BindView(R.id.reuse_no_connection) LinearLayout mNoConnection;
private PopupWindow mPopupWindow;
private KaiFuAdapter mAdapter;
private LinearLayoutManager layoutManager;
private boolean isEverpause = false;
private String kaifuType;
private int mDialogGamePosition; // 顶部弹窗过滤位置
private int kaifuOffset = 0;
private DataWatcher dataWatcher = new DataWatcher() {
@Override
public void onDataChanged(DownloadEntity downloadEntity) {
ArrayList<Integer> locationList = mAdapter.getLocationMap().get(downloadEntity.getPackageName());
if (locationList != null) {
GameEntity gameEntity;
for (int location : locationList) {
gameEntity = mAdapter.getSubjectList().get(location - getGameEntityIndex());
if (gameEntity != null) {
DownloadItemUtils.processDate(KaiFuActivity.this, gameEntity, downloadEntity,
mAdapter, location);
}
}
}
}
};
private int getGameEntityIndex() {
if (kaifuOffset != 0) {
return 1;
}
return 0;
}
Runnable runnable = new Runnable() {
@Override
public void run() {
mAdapter = new KaiFuAdapter(KaiFuActivity.this, kaifuType);
mRecyclerView.setAdapter(mAdapter);
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View view = View.inflate(this, R.layout.activity_kaifu, null);
init(view, "开服表");
kaifuType = "全部";
mRefreshLayout.setColorSchemeResources(R.color.theme);
mRefreshLayout.setOnRefreshListener(this);
mRefreshLayout.setEnabled(false);
mAdapter = new KaiFuAdapter(this, kaifuType);
layoutManager = new LinearLayoutManager(this);
mRecyclerView.addItemDecoration(new VerticalItemDecoration(this, 8, false));
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
//上拉加载
if (mAdapter.isLoadedBottom() && newState == RecyclerView.SCROLL_STATE_IDLE
&& mAdapter.getItemCount() == layoutManager.findLastVisibleItemPosition() + 1){
mAdapter.initListBottom(kaifuOffset + mAdapter.loadCountBottom());
}
//下拉加载
if (kaifuOffset >0 && mAdapter.isLoadedTop() && newState == RecyclerView.SCROLL_STATE_IDLE
&& layoutManager.findFirstVisibleItemPosition() == 0) {
int countTop = mAdapter.loadCountTop();
if (countTop%20 == 0) { // 不是20的倍数 证明加载完毕
int offset = kaifuOffset - countTop;
int limit = 20;
if (offset < 0) {
limit = limit + offset;
offset = 0;
}
if (limit == 0) return;
mAdapter.initListTop(offset, limit);
}
}
}
});
// 防抖处理
RxView.clicks(mSelectGameRl)
.throttleFirst(1, TimeUnit.SECONDS)
.subscribe(new Action1<Void>() {
@Override
public void call(Void aVoid) {
initSelectGameDialog();
}
});
mNoConnection.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mAdapter.initKaiFuOffset();
mNoConnection.setVisibility(View.GONE);
mPbLoading.setVisibility(View.VISIBLE);
}
});
}
private void initSelectGameDialog() {
isShowPopupBg(true);
View contentView = View.inflate(this, R.layout.dialog_kaifu_select_game, null);
RecyclerView selectGameRv = (RecyclerView) contentView.findViewById(R.id.dialog_kaifu_select_game_rv);
final TextView selectGameTitle = (TextView) contentView.findViewById(R.id.dialog_kaifu_title);
final MeasureHeightLayoutManager layout = new MeasureHeightLayoutManager(this);
selectGameRv.setLayoutManager(layout);
selectGameRv.setAdapter(new KaiFuDialogAdapter(this, mDialogGamePosition));
mPopupWindow = new PopupWindow(contentView, LinearLayout.LayoutParams.MATCH_PARENT
, LinearLayout.LayoutParams.MATCH_PARENT, true);
mPopupWindow.setAnimationStyle(R.style.scale_popwindow_anim_style);
mPopupWindow.showAtLocation(mSelectGameRl, 0, 0, 0);
selectGameRv.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (layout.findFirstVisibleItemPosition() >= 5) {
selectGameTitle.setVisibility(View.VISIBLE);
} else {
selectGameTitle.setVisibility(View.GONE);
}
}
});
selectGameRv.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK
&& event.getRepeatCount() == 0
&& mPopupWindow != null
&& mPopupWindow.isShowing()) {
isShowPopupBg(false);
}
return false;
}
});
contentView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
isShowPopupBg(false);
}
});
}
@Override
public void selectPosition(int position, String tag, String gameName) {
mDialogGamePosition = position;
if (!TextUtils.isEmpty(gameName)) {
mGameName.setText(gameName);
} else {
mGameName.setText(tag);
}
isShowPopupBg(false);
kaifuOffset = 0;
kaifuType = tag;
mRecyclerView.setVisibility(View.VISIBLE);
mPbLoading.setVisibility(View.VISIBLE);
mNoConnection.setVisibility(View.GONE);
mAdapter = new KaiFuAdapter(this, kaifuType);
mRecyclerView.setAdapter(mAdapter);
}
public void isShowPopupBg(boolean isShow) {
if(isShow) {
mPopupBg.setVisibility(View.VISIBLE);
mPopupBg.animate()
.alpha(1f)
.setDuration(300)
.setListener(null);
} else {
mPopupWindow.dismiss();
mPopupBg.animate()
.alpha(0f)
.setDuration(300)
.setListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
mPopupBg.setVisibility(View.GONE);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
}
}
@Override
public void loadError() {
if (mPbLoading != null && mPbLoading.getVisibility() == View.VISIBLE) {
mPbLoading.setVisibility(View.GONE);
}
toast("加载失败,请检查网络状态");
mPbLoading.setVisibility(View.GONE);
mNoConnection.setVisibility(View.VISIBLE);
}
@Override
public void loadDone() {
if (mPbLoading != null && mPbLoading.getVisibility() == View.VISIBLE) {
mPbLoading.setVisibility(View.GONE);
}
if (mRefreshLayout.isRefreshing()) {
mRefreshLayout.setRefreshing(false);
}
}
@Override
public void loadDone(Object obj) {
super.loadDone(obj);
kaifuOffset = (int) obj;
if (kaifuOffset == 0) {
mRefreshLayout.setEnabled(true);
} else {
mRefreshLayout.setEnabled(false);
}
}
// 下载被删除事件
public void onEventMainThread(EBDownloadStatus status) {
if ("delete".equals(status.getStatus())) {
DownloadManager.getInstance(this).removePlatform(status.getName(), status.getPlatform());
ArrayList<Integer> locationList = mAdapter.getLocationMap().get(status.getPackageName());
if (locationList != null) {
GameEntity gameEntity;
for (int location : locationList) {
gameEntity = mAdapter.getSubjectList().get(location - getGameEntityIndex());
if (gameEntity != null && gameEntity.getEntryMap() != null) {
gameEntity.getEntryMap().remove(status.getPlatform());
}
mAdapter.notifyItemChanged(location);
}
}
}
}
public void onEventMainThread(EBPackage busFour) {
ArrayList<Integer> locationList = mAdapter.getLocationMap().get(busFour.getPackageName());
if (locationList != null) {
GameEntity gameEntity;
for (int location : locationList) {
if ("安装".equals(busFour.getType())) {
gameEntity = mAdapter.getSubjectList().get(location - getGameEntityIndex());
for (ApkEntity apkEntity : gameEntity.getApk()) {
if (apkEntity.getPackageName().equals(busFour.getPackageName())) {
if (gameEntity.getEntryMap() != null) {
gameEntity.getEntryMap().remove(apkEntity.getPlatform());
}
mAdapter.notifyItemChanged(location + getGameEntityIndex());
break;
}
}
} else if ("卸载".equals(busFour.getType())) {
mAdapter.notifyItemChanged(location + getGameEntityIndex());
}
}
}
}
//连接上网络事件
public void onEventMainThread(EBNetworkState busNetworkState) {
if (busNetworkState.isNetworkConnected()) {
if (mNoConnection.getVisibility() == View.VISIBLE) {
mRecyclerView.setVisibility(View.VISIBLE);
mPbLoading.setVisibility(View.VISIBLE);
mNoConnection.setVisibility(View.GONE);
mAdapter = new KaiFuAdapter(KaiFuActivity.this, kaifuType);
mRecyclerView.setAdapter(mAdapter);
}
}
}
@Override
public void onResume() {
super.onResume();
if (isEverpause) {
for (GameEntity entity : mAdapter.getSubjectList()) {
entity.setEntryMap(DownloadManager.getInstance(this).getEntryMap(entity.getName()));
}
}
isEverpause = false;
DownloadManager.getInstance(getApplicationContext()).addObserver(dataWatcher);
}
@Override
public void onPause() {
super.onPause();
isEverpause = true;
DownloadManager.getInstance(getApplicationContext()).removeObserver(dataWatcher);
}
private void moveToPosition(int n) {
int firstItem = layoutManager.findFirstVisibleItemPosition();
int lastItem = layoutManager.findLastVisibleItemPosition();
if (n <= firstItem ){
mRecyclerView.scrollToPosition(n);
}else if ( n <= lastItem ){
int top = mRecyclerView.getChildAt(n - firstItem).getTop();
mRecyclerView.scrollBy(0, top);
}else{
mRecyclerView.scrollToPosition(n);
}
}
@Override
public void onScroll(int scrollPosition) {
moveToPosition(scrollPosition + getGameEntityIndex());
}
@Override
public void onRefresh() {
mRecyclerView.postDelayed(runnable, 1000);
}
}

View File

@ -16,6 +16,7 @@ import com.gh.base.AppController;
import com.gh.base.BaseActivity;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.Utils;
import com.gh.common.view.VerticalItemDecoration;
import com.gh.gamecenter.adapter.KcSelectGameAdapter;
import com.gh.gamecenter.kuaichuan.FileInfo;
@ -70,6 +71,7 @@ public class KcSelectGameActivity extends BaseActivity {
mAdapter = new KcSelectGameAdapter(this, mSelectSend, installCount, installRl, mSelectPb);
layoutManager = new LinearLayoutManager(this);
mSelectRv.setLayoutManager(layoutManager);
mSelectRv.addItemDecoration(new VerticalItemDecoration(this, 8, false));
mSelectRv.setAdapter(mAdapter);
rparams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,

View File

@ -1,17 +1,24 @@
package com.gh.gamecenter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import com.gh.base.AppController;
import com.gh.base.BaseDetailActivity;
import com.gh.common.util.TokenUtils;
import com.gh.common.util.Utils;
import com.gh.common.view.VerticalItemDecoration;
import com.gh.gamecenter.adapter.LibaoDetailAdapter;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.LibaoEntity;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import java.util.Calendar;
import retrofit2.adapter.rxjava.HttpException;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
@ -20,12 +27,35 @@ import rx.schedulers.Schedulers;
* Created by khy on 2016/12/13.
*
*/
public class LibaoDetailActivity extends BaseDetailActivity {
public class LibaoDetailActivity extends BaseDetailActivity implements LibaoDetailAdapter.OnCodeScrollListener{
private LibaoDetailAdapter mAdapter;
private LibaoEntity mLibaoEntity;
private boolean mIsScroll;
Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what == 0) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 24);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.MILLISECOND, 0);
long targetTime = calendar.getTimeInMillis()/1000;
long delayedTime = (targetTime - Utils.getTime(LibaoDetailActivity.this)) * 1000;
Utils.log("=======" + delayedTime);
handler.sendEmptyMessageDelayed(1, 5000);
} else if (msg.what == 1) {
mLibaoEntity.setStatus(mLibaoEntity.getBeforeStatus());
mAdapter.notifyItemChanged(0);
}
}
};
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
@ -42,15 +72,32 @@ public class LibaoDetailActivity extends BaseDetailActivity {
iv_share.setVisibility(View.GONE);
mIsScroll = true;
mAdapter = new LibaoDetailAdapter(this, mLibaoEntity, detail_tv_download);
detail_rv_show.setLayoutManager(new LinearLayoutManager(this));
detail_rv_show.setLayoutManager(new LinearLayoutManager(this){
@Override
public boolean canScrollVertically() {
return mIsScroll;
}
});
detail_rv_show.addItemDecoration(new VerticalItemDecoration(this, 8, true));
detail_rv_show.setAdapter(mAdapter);
if (mLibaoEntity != null && mLibaoEntity.getGame() != null && mLibaoEntity.getGame().getId() != null) {
if (mLibaoEntity!= null && mLibaoEntity.getGame() != null
&& mLibaoEntity.getGame().getId() != null) {
title = mLibaoEntity.getName();
getGameDigest();
Utils.log( mLibaoEntity.getBeforeStatus() + "===========" + mLibaoEntity.getStatus());
String status = mLibaoEntity.getStatus();
if (mLibaoEntity.isReuse() && (status.equals("linged") || status.equals("taoed"))) {
TokenUtils.getTime(LibaoDetailActivity.this);
handler.sendEmptyMessageDelayed(0, 5000);
}
}
handler.sendEmptyMessageDelayed(0, 5000);
reuse_no_connection.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -120,4 +167,15 @@ public class LibaoDetailActivity extends BaseDetailActivity {
reuse_tv_none_data.setText("天了噜~页面不见了");
reuse_none_data.setVisibility(View.VISIBLE);
}
@Override
public void isScroll(boolean isScroll) {
mIsScroll = isScroll;
}
@Override
protected void onDestroy() {
super.onDestroy();
handler.removeCallbacksAndMessages(null);
}
}

View File

@ -38,19 +38,22 @@ import com.gh.common.util.GameUtils;
import com.gh.common.util.LibaoUtils;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.PlatformUtils;
import com.gh.common.util.RandomUtils;
import com.gh.common.util.TokenUtils;
import com.gh.common.util.TrafficUtils;
import com.gh.common.util.Utils;
import com.gh.download.DataWatcher;
import com.gh.download.DownloadEntity;
import com.gh.download.DownloadManager;
import com.gh.download.DownloadStatus;
import com.gh.gamecenter.db.MessageMarkReadDao;
import com.gh.gamecenter.db.info.ConcernInfo;
import com.gh.gamecenter.db.info.GameInfo;
import com.gh.gamecenter.db.info.MessageMarkReadInfo;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameDigestEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.GameUpdateEntity;
import com.gh.gamecenter.entity.SuggestionTypeEntity;
import com.gh.gamecenter.eventbus.EBDownloadStatus;
import com.gh.gamecenter.eventbus.EBPackage;
import com.gh.gamecenter.eventbus.EBShowDialog;
@ -63,6 +66,7 @@ import com.gh.gamecenter.manager.FilterManager;
import com.gh.gamecenter.manager.GameManager;
import com.gh.gamecenter.manager.PackageManager;
import com.gh.gamecenter.manager.UpdateManager;
import com.gh.gamecenter.message.MessageFragment;
import com.gh.gamecenter.news.NewsFragment;
import com.gh.gamecenter.personal.PersonalFragment;
import com.gh.gamecenter.retrofit.JSONObjectResponse;
@ -79,6 +83,7 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@ -100,19 +105,26 @@ import rx.schedulers.Schedulers;
public class MainActivity extends BaseFragmentActivity implements OnClickListener {
private NewsFragment newsFragment;
private MessageFragment messageFragment;
// private WenDaFragment wenDaFragment;
// private ZiXunFragment ziXunFragment;
private PersonalFragment personalFragment;
private GameFragment gameFragment;
private ImageView ivGame;
private ImageView ivNews;
// private ImageView ivWenDa;
private ImageView ivMessage;
private ImageView ivPersonal;
private TextView tvGame;
private TextView tvNews;
// private TextView tvWenDa;
private TextView tvMessage;
private TextView tvPersonal;
private SharedPreferences sp;
private ConcernManager concernManager;
private String searchHint;
private ArrayList<String> searchHint;
private int currentTab;
@ -392,6 +404,123 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
if (sp.getBoolean("changeDefaultIcon", false) && sp.getInt("default_user_icon", 0) != 0) {
postDefaultIcon(true, sp.getInt("default_user_icon", 0));
}
getSuggestionType();
checkMarkRead(); // 检查是否有记录已读消息
}
private void checkMarkRead() {
MessageMarkReadDao readDao = new MessageMarkReadDao(MainActivity.this);
List<MessageMarkReadInfo> readInfos = readDao.getAll();
if (readInfos == null || readInfos.size() == 0) {
return;
}
MessageMarkReadInfo readInfo = readInfos.get(0);
HashMap<String, Boolean> kefuIds = readInfo.getKefuIds();
HashMap<String, Boolean> noticeIds = readInfo.getNoticeIds();
if (kefuIds != null && kefuIds.size() > 0) {
Utils.log("======提交已读客服消息");
JSONArray array = new JSONArray();
for (String s : kefuIds.keySet()) {
array.put(s);
}
Utils.log("======客服id::" + array.toString());
RequestBody body = RequestBody.create(MediaType.parse("application/json"), array.toString());
postMarkRead("kefu", true, body, readDao);
}
if (noticeIds != null && noticeIds.size() > 0) {
Utils.log("======提交已读公告消息");
JSONArray array = new JSONArray();
for (String s : noticeIds.keySet()) {
array.put(s);
}
Utils.log("======客服id::" + array.toString());
RequestBody body = RequestBody.create(MediaType.parse("application/json"), array.toString());
postMarkRead("notice", true, body, readDao);
}
}
private void postMarkRead(final String type, boolean isCkeck, final RequestBody body, final MessageMarkReadDao readDao) {
TokenUtils
.getToken(MainActivity.this, isCkeck)
.flatMap(new Func1<String, Observable<ResponseBody>>() {
@Override
public Observable<ResponseBody> call(String token) {
if ("kefu".equals(type)){
return RetrofitManager.getApi().postMarkKeFuRead(body, token);
} else {
return RetrofitManager.getApi().postMarkNoticeRead(body, token);
}
}
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<ResponseBody>(){
@Override
public void onResponse(ResponseBody response) {
super.onResponse(response);
Utils.log("=========postMarkRead::" + type);
// if ("kefu".equals(type)) {
// readDao.cleanKeFu();
// } else {
// readDao.cleanNotice();
// }
}
@Override
public void onFailure(HttpException e) {
super.onFailure(e);
if (e != null && e.code() == 401) {
postMarkRead(type, false, body, readDao);
}
}
});
}
private void getSuggestionType() {
RetrofitManager
.getApi()
.getSuggestionType()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<SuggestionTypeEntity>(){
@Override
public void onResponse(SuggestionTypeEntity response) {
super.onResponse(response);
Set<String> suggestionGame = response.getGame();
Set<String> suggestionLibao = response.getLibao();
Set<String> suggestionPlugin = response.getPlugin();
Set<String> suggestionService = response.getService();
SharedPreferences.Editor edit = sp.edit();
if (suggestionGame.size() != 0) {
edit.putStringSet("suggestionGame", suggestionGame);
}
if (suggestionLibao.size() != 0) {
edit.putStringSet("suggestionLibao", suggestionLibao);
}
if (suggestionPlugin.size() != 0) {
edit.putStringSet("suggestionPlugin", suggestionPlugin);
}
if (suggestionService.size() != 0) {
edit.putStringSet("suggestionService", suggestionService);
}
edit.apply();
}
@Override
public void onError(Throwable e) {
super.onError(e);
Utils.log("反馈的问题选项::ERROR::" + e.toString());
}
});
}
// 更新用户使用的助手信息
@ -513,12 +642,18 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
private void initViews() {
findViewById(R.id.main_ll_game).setOnClickListener(this);
findViewById(R.id.main_ll_news).setOnClickListener(this);
// findViewById(R.id.main_ll_wenda).setOnClickListener(this);
findViewById(R.id.main_ll_message).setOnClickListener(this);
findViewById(R.id.main_ll_personal).setOnClickListener(this);
ivGame = (ImageView) findViewById(R.id.main_iv_game);
ivNews = (ImageView) findViewById(R.id.main_iv_news);
// ivWenDa = (ImageView) findViewById(R.id.main_iv_wenda);
ivMessage = (ImageView) findViewById(R.id.main_iv_message);
ivPersonal = (ImageView) findViewById(R.id.main_iv_personal);
tvGame = (TextView) findViewById(R.id.main_tv_game);
tvNews = (TextView) findViewById(R.id.main_tv_news);
// tvWenDa = (TextView) findViewById(R.id.main_tv_wenda);
tvMessage = (TextView) findViewById(R.id.main_tv_message);
tvPersonal = (TextView) findViewById(R.id.main_tv_personal);
}
@ -880,15 +1015,17 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
RetrofitManager.getApi().getSearchHints()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<List<String>>() {
.subscribe(new Response<ArrayList<String>>() {
@Override
public void onResponse(List<String> response) {
public void onResponse(ArrayList<String> response) {
if (response.size() != 0) {
if (response.size() == 1) {
searchHint = response.get(0);
} else {
searchHint = response.get(RandomUtils.nextInt(response.size()));
}
// if (response.size() == 1) {
// searchHint = response.get(0);
// } else {
// searchHint = response.get(RandomUtils.nextInt(response.size()));
// }
searchHint = response;
if (gameFragment != null) {
gameFragment.setHint(searchHint);
}
@ -943,9 +1080,15 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
} else if (id == R.id.main_ll_news) {
EventBus.getDefault().post(new EBUISwitch("MainActivity", 1));
setTabSelection(1);
}
// else if (id == R.id.main_ll_wenda) {
// setTabSelection(2);
// }
else if (id == R.id.main_ll_message){
setTabSelection(2);
} else if (id == R.id.main_ll_personal) {
EventBus.getDefault().post(new EBUISwitch("MainActivity", 2));
setTabSelection(2);
setTabSelection(3);
}
}
@ -970,7 +1113,7 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
}
if (gameFragment == null) {
gameFragment = new GameFragment();
if (!TextUtils.isEmpty(searchHint)) {
if (searchHint != null && searchHint.size() > 0) {
gameFragment.setHint(searchHint);
}
transaction.add(R.id.main_content, gameFragment);
@ -996,7 +1139,7 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
}
if (newsFragment == null) {
newsFragment = new NewsFragment();
if (!TextUtils.isEmpty(searchHint)) {
if (searchHint != null && searchHint.size() > 0) {
newsFragment.setHint(searchHint);
}
transaction.add(R.id.main_content, newsFragment);
@ -1006,7 +1149,55 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
}
currentTab = 1;
break;
// case 2:
// ivWenDa.setImageResource(R.drawable.ic_wenda_select);
// tvWenDa.setTextColor(getResources().getColor(R.color.theme));
// if (wenDaFragment == null) {
// List<Fragment> list = getSupportFragmentManager().getFragments();
// if (list != null) {
// for (Fragment fragment : list) {
// if (fragment.getClass().equals(WenDaFragment.class)) {
// wenDaFragment = (WenDaFragment) fragment;
// transaction.show(wenDaFragment);
// break;
// }
// }
// }
// if (wenDaFragment == null) {
// wenDaFragment = new WenDaFragment();
// transaction.add(R.id.main_content, wenDaFragment);
// }
// } else {
// transaction.show(wenDaFragment);
// }
// currentTab = 2;
// break;
case 2:
ivMessage.setImageResource(R.drawable.ic_message_select);
tvMessage.setTextColor(getResources().getColor(R.color.theme));
if (messageFragment == null) {
List<Fragment> list = getSupportFragmentManager().getFragments();
if (list != null) {
for (Fragment fragment : list) {
if (fragment.getClass().equals(MessageFragment.class)) {
messageFragment = (MessageFragment) fragment;
transaction.show(messageFragment);
break;
}
}
}
if (messageFragment == null) {
messageFragment = new MessageFragment();
transaction.add(R.id.main_content, messageFragment);
}
} else {
transaction.show(messageFragment);
}
currentTab = 2;
break;
case 3:
ivPersonal.setImageResource(R.drawable.ic_user_select);
tvPersonal.setTextColor(getResources().getColor(R.color.theme));
if (personalFragment == null) {
@ -1027,7 +1218,7 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
} else {
transaction.show(personalFragment);
}
currentTab = 2;
currentTab = 3;
break;
default:
break;
@ -1039,9 +1230,13 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
private void clearSelection() {
ivGame.setImageResource(R.drawable.ic_game_unselect);
ivNews.setImageResource(R.drawable.ic_news_unselect);
// ivWenDa.setImageResource(R.drawable.ic_wenda_unselect);
ivMessage.setImageResource(R.drawable.ic_message_unselect);
ivPersonal.setImageResource(R.drawable.ic_user_unselect);
tvGame.setTextColor(Color.parseColor("#a7a8b2"));
tvNews.setTextColor(Color.parseColor("#a7a8b2"));
// tvWenDa.setTextColor(Color.parseColor("#a7a8b2"));
tvMessage.setTextColor(Color.parseColor("#a7a8b2"));
tvPersonal.setTextColor(Color.parseColor("#a7a8b2"));
}
@ -1053,6 +1248,12 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
if (gameFragment != null) {
transaction.hide(gameFragment);
}
// if (wenDaFragment != null) {
// transaction.hide(wenDaFragment);
// }
if (messageFragment != null) {
transaction.hide(messageFragment);
}
if (newsFragment != null) {
transaction.hide(newsFragment);
}

View File

@ -89,6 +89,7 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
private CommentDao mCommentDao;
private ConcernEntity mConcernEntity;
private CommentEntity mCommentEntity; // 回复评论的实体 用完马上清空
private String newsId;
@ -106,6 +107,8 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
mConcernEntity = (ConcernEntity) AppController.get("ConcernEntity", true);
mCommentEntity = (CommentEntity) AppController.get("CommentEntity", true); // 来自新闻详情-评论回复
Intent intent = getIntent();
newsId = intent.getExtras().getString("newsId");
commentNum = intent.getExtras().getInt("commentNum");
@ -346,14 +349,13 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
newsId = mConcernEntity.getId();
}
PostCommentUtils.addCommentData(MessageDetailActivity.this, newsId, jsonObject.toString(), true,
PostCommentUtils.addCommentData(MessageDetailActivity.this, newsId, jsonObject.toString(), true, mCommentEntity,
new PostCommentUtils.PostCommentListener() {
@Override
public void postSucced(JSONObject response) {
mSendingDialog.dismiss();
toast("发表成功");
mMessageDetailEt.setText("");
setSoftInput(false);
try {
mCommentDao.add(new CommentInfo(response.getString("_id")));//添加评论id到数据库 后续判断是否是自身评论
@ -368,6 +370,15 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
cacheObject.put("vote", 0);
cacheObject.put("user", cacheUser);
if (mCommentEntity != null) {
JSONObject cacheParent = new JSONObject();
JSONObject cacheParentUser = new JSONObject();
cacheParentUser.put("_id", mCommentEntity.getId());
cacheParentUser.put("name", mCommentEntity.getUser().getName());
cacheParent.put("user", cacheParentUser);
cacheObject.put("parent", cacheParent);
}
CommentEntity commentEntity = new Gson().fromJson(cacheObject.toString(), CommentEntity.class);
if (mConcernEntity != null) {
adapter.addNormalComment(commentEntity);
@ -390,6 +401,8 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
showNoConnection(false);
}
setSoftInput(false);
}
@Override
@ -480,6 +493,12 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
mMessageDetailEt.requestFocus();
mColseCommentV.setVisibility(View.VISIBLE);
if (mCommentEntity != null && mCommentEntity.getUser() != null) {
mMessageDetailEt.setHint("回复 " + mCommentEntity.getUser().getName() + "");
} else {
mMessageDetailEt.setHint("优质评论会被优先展示");
}
} else {
imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0);
mMessageDetailCommentHintRl.setVisibility(View.VISIBLE);
@ -487,11 +506,18 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
mMessageDetailCommentRl.setVisibility(View.GONE);
mMessageDetailUserRl.setVisibility(View.GONE);
mColseCommentV.setVisibility(View.GONE);
if (mCommentEntity != null) {
mCommentEntity = null; // 清空当前评论实体
mMessageDetailEt.setHint("优质评论会被优先展示");
mMessageDetailEt.setText("");
}
}
}
@Override
public void showSoftInput() {
public void showSoftInput(CommentEntity entity) {
mCommentEntity = entity;
setSoftInput(true);
}

View File

@ -0,0 +1,647 @@
package com.gh.gamecenter;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.facebook.drawee.view.SimpleDraweeView;
import com.gh.base.AppController;
import com.gh.base.BaseFragmentActivity;
import com.gh.common.constant.Config;
import com.gh.common.util.ConcernUtils;
import com.gh.common.util.DataCollectionUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.FileUtils;
import com.gh.common.util.GameUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.NetworkUtils;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.ShareUtils;
import com.gh.common.view.DownloadDialog;
import com.gh.common.view.NoScrollableViewPager;
import com.gh.download.DataWatcher;
import com.gh.download.DownloadEntity;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.adapter.FragmentAdapter;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameDetailEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.eventbus.EBDownloadStatus;
import com.gh.gamecenter.eventbus.EBMoveTop;
import com.gh.gamecenter.eventbus.EBPackage;
import com.gh.gamecenter.gamedetail.FuliFragment;
import com.gh.gamecenter.gamedetail.XinXiFragment;
import com.gh.gamecenter.manager.ConcernManager;
import com.gh.gamecenter.manager.PackageManager;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.jakewharton.rxbinding.view.RxView;
import com.tencent.tauth.Tencent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import butterknife.BindView;
import butterknife.OnClick;
import retrofit2.adapter.rxjava.HttpException;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import rx.schedulers.Schedulers;
/**
* Created by khy on 2017/3/24.
* 游戏详情适配器
*/
public class NewGameDetailActivity extends BaseFragmentActivity {
@BindView(R.id.gamedetail_vp) NoScrollableViewPager mViewPager;
@BindView(R.id.gamedetail_top) RelativeLayout mTopLl;
@BindView(R.id.gamedetail_tabbar_rl) RelativeLayout mTabBarRl;
@BindView(R.id.reuse_ll_loading) LinearLayout mLoading;
@BindView(R.id.reuse_no_connection) LinearLayout mNoConnection;
@BindView(R.id.actionbar_tv_title) TextView mTitle;
@BindView(R.id.gamedetail_iv_thumb) SimpleDraweeView mGameIcon;
@BindView(R.id.gamedetail_tv_name) TextView mGameName;
@BindView(R.id.gamedetail_tv_info) TextView mGameInfo;
@BindView(R.id.gamedetail_tv_concern) TextView mGameConcern;
@BindView(R.id.gamedetail_tabbar) LinearLayout mTabBar;
@BindView(R.id.gamedetail_tabbar_fuli) TextView mTanBarFuLi;
@BindView(R.id.gamedetail_tabbar_xinxi) TextView mTanBarXinXi;
@BindView(R.id.gamedetail_tabbar_fuli_tv) TextView mTanBarFuLiTv;
@BindView(R.id.gamedetail_tabbar_xinxi_tv) TextView mTanBarXinXiTv;
@BindView(R.id.gamedetail_share) ImageView mShareIv;
@BindView(R.id.detail_ll_bottom) LinearLayout mDownloadBottom;
@BindView(R.id.detail_tv_download) TextView mDownloadTv;
@BindView(R.id.detail_tv_per) TextView mDownloadPer;
@BindView(R.id.detail_pb_progressbar) ProgressBar mDownloadPb;
private RelativeLayout.LayoutParams top_rparams;
private ConcernManager mConcernManager;
private String mGameId;
private GameEntity mGameEntity;
private DownloadEntity mDownloadEntity;
private String downloadAddWord;
private String downloadOffText;
private String name;
private String title;
private String shareCode;
private DataWatcher dataWatcher = new DataWatcher() {
@Override
public void onDataChanged(DownloadEntity downloadEntity) {
if (mGameEntity != null && mGameEntity.getApk().size() == 1) {
String url = mGameEntity.getApk().get(0).getUrl();
if (url.equals(downloadEntity.getUrl())) {
if (!"pause".equals(DownloadManager.getInstance(NewGameDetailActivity.this).
getStatus(downloadEntity.getUrl()))) {
mDownloadEntity = downloadEntity;
invalidate();
}
}
}
}
};
//接收QQ或者QQ空间分享回调
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == com.tencent.connect.common.Constants.REQUEST_QQ_SHARE
|| requestCode == com.tencent.connect.common.Constants.REQUEST_QZONE_SHARE) {
Tencent.onActivityResultData(requestCode, resultCode, data, ShareUtils.getInstance(this).QqShareListener);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View view = View.inflate(NewGameDetailActivity.this, R.layout.activity_game_detail, null);
init(view);
mViewPager.setScrollable(false);
mConcernManager = new ConcernManager(NewGameDetailActivity.this);
name = "游戏详情";
mGameId = getIntent().getStringExtra("gameId");
if (getIntent().getBundleExtra("data") != null) {
mGameId = getIntent().getBundleExtra("data").getString("gameId");
}
if (mGameId == null) {
mGameEntity = (GameEntity) AppController.get("GameEntity", false);
if (mGameEntity != null) {
mGameId = mGameEntity.getId();
mTitle.setText(mGameEntity.getName());
name = mGameEntity.getName();
}
}
if (mGameEntity != null) {
getGameDetail();
} else if (mGameId != null) {
getGameDigest();
} else {
mLoading.setVisibility(View.GONE);
mNoConnection.setVisibility(View.VISIBLE);
}
}
private void initGameDetailTop() {
mLoading.setVisibility(View.GONE);
mTopLl.setVisibility(View.VISIBLE);
top_rparams = (RelativeLayout.LayoutParams) mTopLl.getLayoutParams();
if (mConcernManager.isConcern(mGameEntity.getId())) {
mGameConcern.setText("取消关注");
mGameConcern.setBackgroundResource(R.drawable.border_red_bg);
mGameConcern.setTextColor(Color.parseColor("#ff4147"));
} else {
mGameConcern.setText("关注");
mGameConcern.setBackgroundResource(R.drawable.textview_concern_red_style);
mGameConcern.setTextColor(0xffffffff);
}
mGameName.setText(mGameEntity.getName());
ImageUtils.display(mGameIcon, mGameEntity.getIcon());
if (mGameEntity.getApk() == null || mGameEntity.getApk().isEmpty()) {
mGameInfo.setText("");
} else {
ApkEntity apkEntity = mGameEntity.getApk().get(0);
mGameInfo.setText(String.format("V%s | %s", apkEntity.getVersion(), apkEntity.getSize()));
}
mGameConcern.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final TextView concern = (TextView) v;
if ("关注".equals(concern.getText().toString())) {
Map<String, Object> kv = new HashMap<>();
kv.put("状态", "关注");
DataUtils.onEvent(NewGameDetailActivity.this, "游戏关注", mGameEntity.getName(), kv);
Map<String, Object> kv2 = new HashMap<>();
kv2.put("点击", "关注");
DataUtils.onEvent(NewGameDetailActivity.this, "插件数据", mGameEntity.getName(), kv2);
DataCollectionUtils.uploadConcern(NewGameDetailActivity.this, mGameEntity.getName(), mGameEntity.getId(), "关注");
mConcernManager.addByEntity(mGameEntity);
concern.setText("取消关注");
concern.setBackgroundResource(R.drawable.border_red_bg);
concern.setTextColor(Color.parseColor("#ff4147"));
Toast.makeText(NewGameDetailActivity.this, "关注成功", Toast.LENGTH_SHORT).show();
// 添加关注
ConcernUtils.postConcernGameId(NewGameDetailActivity.this, mGameEntity.getId());
} else {
Map<String, Object> kv2 = new HashMap<>();
kv2.put("点击", "取消关注");
DataUtils.onEvent(NewGameDetailActivity.this, "插件数据", mGameEntity.getName(), kv2);
DialogUtils.showCancelDialog(NewGameDetailActivity.this, new DialogUtils.ConfiremListener() {
@Override
public void onConfirem() {
Map<String, Object> kv = new HashMap<>();
kv.put("状态", "取消关注");
DataUtils.onEvent(NewGameDetailActivity.this, "游戏关注", mGameEntity.getName(), kv);
DataCollectionUtils.uploadConcern(NewGameDetailActivity.this,
mGameEntity.getName(), mGameEntity.getId(), "取消关注");
mConcernManager.deleteConcern(mGameEntity.getId());
concern.setText("关注");
concern.setBackgroundResource(R.drawable.textview_concern_red_style);
concern.setTextColor(0xffffffff);
// 取消关注
ConcernUtils.deleteConcernData(NewGameDetailActivity.this, mGameEntity.getId());
}
});
}
}
});
}
// 获取游戏摘要
private void getGameDigest() {
RetrofitManager.getApi().getGameDigest(mGameId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<GameEntity>() {
@Override
public void onResponse(GameEntity response) {
mGameEntity = response;
AppController.put("GameEntity", response);
mTitle.setText(mGameEntity.getName());
mGameId = response.getId();
name = mGameEntity.getName();
getGameDetail();
}
@Override
public void onFailure(HttpException e) {
mLoading.setVisibility(View.GONE);
mNoConnection.setVisibility(View.VISIBLE);
}
});
}
// 获取游戏详情
public void getGameDetail() {
RetrofitManager.getApi().getGameDetail(mGameId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<GameDetailEntity>() {
@Override
public void onResponse(GameDetailEntity response) {
// 过滤过期公告
if (response.getNotice() != null && response.getNotice().size() > 0) {
long l = System.currentTimeMillis();
for (int i = 0; i < response.getNotice().size(); i++) {
if (l > (response.getNotice().get(i).getOvertime()*1000)) {
response.getNotice().remove(i);
i --;
}
}
}
AppController.put("GameDetailEntity", response);
downloadAddWord = response.getDownloadAddWord();
downloadOffText = response.getDownloadOffText();
shareCode = response.getShareCode();
List<Fragment> list = new ArrayList<>();
if (mGameEntity != null && !mGameEntity.isLibaoExists()
&& TextUtils.isEmpty(response.getFulishuoming())
&& (response.getKaiFuServer() == null
|| (response.getKaiFuServer() != null
&& response.getKaiFuServer().size() == 0))) {
XinXiFragment xinXiFragment = new XinXiFragment();
xinXiFragment.setIsTabBar(true);
list.add(xinXiFragment);
mTabBar.setVisibility(View.GONE);
} else {
list.add(new FuliFragment());
list.add(new XinXiFragment());
}
mViewPager.setAdapter(new FragmentAdapter(getSupportFragmentManager(), list));
initGameDetailTop();
initDownload(true);
}
@Override
public void onError(Throwable e) {
super.onError(e);
}
@Override
public void onFailure(HttpException e) {
}
});
}
public void onEventMainThread(EBMoveTop moveTop) {
if (moveTop.getType().equals("top")) {
if (moveTop.getVisibility() == View.VISIBLE && mTabBar.getVisibility() == View.VISIBLE) {
mTabBarRl.setVisibility(View.VISIBLE);
} else {
mTabBarRl.setVisibility( View.GONE);
}
int topMargin = moveTop.getTopMargin();
if (top_rparams != null && top_rparams.topMargin != topMargin) {
if (topMargin > -120) {
mTitle.setVisibility(View.GONE);
} else {
mTitle.setVisibility(View.VISIBLE);
}
top_rparams.topMargin = moveTop.getTopMargin();
mTopLl.setLayoutParams(top_rparams);
}
}
}
// 接收下载被删除消息
public void onEvent(EBDownloadStatus status) {
if ("delete".equals(status.getStatus())
&& mGameEntity != null
&& mGameEntity.getApk() != null
&& mGameEntity.getApk().size() == 1) {
String url = mGameEntity.getApk().get(0).getUrl();
if (url.equals(status.getUrl())) {
initDownload(false);
}
}
}
// 接受安装、卸载消息
public void onEventMainThread(EBPackage busFour) {
if (mGameEntity != null
&& mGameEntity.getApk() != null
&& mGameEntity.getApk().size() == 1) {
String packageName = mGameEntity.getApk().get(0).getPackageName();
if (packageName.equals(busFour.getPackageName())) {
initDownload(false);
}
}
}
@Override
protected void onResume() {
super.onResume();
if (mGameEntity != null
&& mGameEntity.getApk() != null
&& mGameEntity.getApk().size() == 1) {
initDownload(true);
}
DownloadManager.getInstance(this).addObserver(dataWatcher);
}
@Override
protected void onPause() {
super.onPause();
DownloadManager.getInstance(this).removeObserver(dataWatcher);
}
@OnClick({R.id.detail_tv_download, R.id.detail_pb_progressbar
, R.id.detail_tv_per, R.id.gamedetail_tabbar_xinxi, R.id.gamedetail_tabbar_xinxi_tv
, R.id.gamedetail_tabbar_fuli, R.id.gamedetail_tabbar_fuli_tv, R.id.gamedetail_share})
public void onClick(View v) {
if (v == mDownloadTv) {
if (mGameEntity != null && !mGameEntity.getApk().isEmpty()) {
if (mGameEntity.getApk().size() == 1) {
if (NetworkUtils.isWifiConnected(this)) {
download();
} else {
DialogUtils.showDownloadDialog(this, new DialogUtils.ConfiremListener() {
@Override
public void onConfirem() {
download();
}
});
}
} else {
DownloadDialog.getInstance(this).showPopupWindow(v, mGameEntity, entrance, name + ":" + title);
}
} else {
toast("稍等片刻~!游戏正在上传中...");
}
} else if (v == mDownloadPb || v == mDownloadPer) {
String str = mDownloadPer.getText().toString();
if ("下载中".equals(str)) {
Intent intent = new Intent(this, DownloadManagerActivity.class);
intent.putExtra("currentItem", 1);
intent.putExtra("url", mGameEntity.getApk().get(0).getUrl());
intent.putExtra("entrance", entrance + "+(" + name + "[" + title + "])");
startActivity(intent);
} else if ("安装".equals(str)) {
PackageUtils.launchSetup(this, mDownloadEntity.getPath());
}
} else if (v == mTanBarFuLi || v == mTanBarFuLiTv) {
mTanBarFuLi.setTextColor(Color.WHITE);
mTanBarFuLiTv.setTextColor(Color.WHITE);
mTanBarFuLi.setBackgroundResource(R.drawable.gamedetail_tag_select_bg);
mTanBarFuLiTv.setBackgroundResource(R.drawable.gamedetail_tag_select_bg);
mTanBarXinXi.setTextColor(Color.BLACK);
mTanBarXinXiTv.setTextColor(Color.BLACK);
mTanBarXinXi.setBackgroundDrawable(new ColorDrawable(0));
mTanBarXinXiTv.setBackgroundDrawable(new ColorDrawable(0));
mViewPager.setCurrentItem(0);
} else if (v == mTanBarXinXi || v == mTanBarXinXiTv) {
mTanBarXinXiTv.setTextColor(Color.WHITE);
mTanBarXinXi.setTextColor(Color.WHITE);
mTanBarXinXiTv.setBackgroundResource(R.drawable.gamedetail_tag_unselect_bg);
mTanBarXinXi.setBackgroundResource(R.drawable.gamedetail_tag_unselect_bg);
mTanBarFuLi.setTextColor(Color.BLACK);
mTanBarFuLiTv.setTextColor(Color.BLACK);
mTanBarFuLi.setBackgroundDrawable(new ColorDrawable(0));
mTanBarFuLiTv.setBackgroundDrawable(new ColorDrawable(0));
mViewPager.setCurrentItem(1);
} else if (v == mShareIv) {
if (TextUtils.isEmpty(shareCode)) return;
// 防抖处理
RxView.clicks(mShareIv)
.throttleFirst(1, TimeUnit.SECONDS)
.subscribe(new Action1<Void>() {
@Override
public void call(Void aVoid) {
Map<String, Object> kv = new HashMap<>();
kv.put("点击", "分享");
DataUtils.onEvent(NewGameDetailActivity.this, "插件数据", mGameEntity.getName(), kv);
DataCollectionUtils.uploadClick(NewGameDetailActivity.this, "分享", "游戏详情", mGameEntity.getName());
String url = "http://www.ghzhushou.com/game/" + shareCode;
showShare(url, mGameEntity.getName(), mGameEntity.getIcon(), null, mGameEntity.getTag());
}
});
}
}
private void download() {
String str = mDownloadTv.getText().toString();
if (str.contains("启动")) {
DataUtils.onGameLaunchEvent(this, mGameEntity.getName(), mGameEntity.getApk().get(0).getPlatform(), name);
PackageUtils.launchApplicationByPackageName(this, mGameEntity.getApk().get(0).getPackageName());
} else {
String method;
if (str.contains("更新")) {
method = "更新";
} else if (str.contains("插件化")) {
method = "插件化";
} else {
method = "下载";
}
ApkEntity apkEntity = mGameEntity.getApk().get(0);
String msg = FileUtils.isCanDownload(this, apkEntity.getSize());
if (TextUtils.isEmpty(msg)) {
DataUtils.onGameDownloadEvent(this, mGameEntity.getName(), apkEntity.getPlatform(), entrance, "下载开始");
DownloadManager.createDownload(this, apkEntity, mGameEntity, method, entrance, name + ":" + title);
mDownloadTv.setVisibility(View.GONE);
mDownloadPb.setVisibility(View.VISIBLE);
mDownloadPer.setVisibility(View.VISIBLE);
mDownloadPb.setProgress(0);
mDownloadPer.setText("0.0%");
DownloadManager.getInstance(NewGameDetailActivity.this).putStatus(apkEntity.getUrl(), "downloading");
} else {
toast(msg);
}
}
}
private void invalidate() {
mDownloadPb.setProgress((int) (mDownloadEntity.getPercent() * 10));
mDownloadPer.setTextColor(0xFFFFFFFF);
switch (mDownloadEntity.getStatus()) {
case downloading:
case pause:
case timeout:
case neterror:
case waiting:
mDownloadPer.setText("下载中");
break;
case done:
mDownloadPer.setText("安装");
if (mDownloadEntity.isPluggable()
&& PackageManager.isInstalled(mDownloadEntity.getPackageName())) {
mDownloadPb.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar_plugin_radius_style));
} else {
mDownloadPb.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar_normal_radius_style));
}
break;
case cancel:
case hijack:
case notfound:
initDownload(false);
break;
default:
break;
}
}
protected void initDownload(boolean isCheck) {
if (Config.isShow(this)) {
mDownloadBottom.setVisibility(View.VISIBLE);
} else {
mDownloadBottom.setVisibility(View.GONE);
}
if (mGameEntity != null && "光环助手".equals(mGameEntity.getName())) {
mDownloadBottom.setVisibility(View.GONE);
} else if (mGameEntity == null || mGameEntity.getApk().isEmpty()) {
mDownloadTv.setVisibility(View.VISIBLE);
mDownloadPb.setVisibility(View.GONE);
mDownloadPer.setVisibility(View.GONE);
if (TextUtils.isEmpty(downloadOffText)) {
mDownloadTv.setText("暂无下载");
} else {
mDownloadTv.setText(downloadOffText);
}
mDownloadTv.setBackgroundResource(R.drawable.game_item_btn_pause_style);
mDownloadTv.setTextColor(0xFF999999);
mDownloadTv.setClickable(false);
} else {
mDownloadTv.setVisibility(View.VISIBLE);
mDownloadPb.setVisibility(View.GONE);
mDownloadPer.setVisibility(View.GONE);
boolean isInstalled = false;
if (mGameEntity.getApk() != null && mGameEntity.getApk().size() == 1
&& PackageManager.isInstalled(mGameEntity.getApk().get(0).getPackageName())) {
isInstalled = true;
}
if (isInstalled) {
if (PackageManager.isCanUpdate(mGameEntity.getId(), mGameEntity.getApk().get(0).getPackageName())) {
if (TextUtils.isEmpty(downloadAddWord)) {
mDownloadTv.setBackgroundResource(
R.drawable.game_item_btn_download_style);
mDownloadTv.setText(String.format("更新《%s》",
mGameEntity.getName()));
} else {
mDownloadTv.setBackgroundResource(
R.drawable.game_item_btn_download_style);
mDownloadTv.setText(String.format("更新《%s》%s",
mGameEntity.getName(), downloadAddWord));
}
} else {
if (mGameEntity.getTag() != null && mGameEntity.getTag().size() != 0
&& !TextUtils.isEmpty(mGameEntity.getApk().get(0).getGhVersion())
&& !PackageUtils.isSignature(this, mGameEntity.getApk().get(0).getPackageName())) {
if (TextUtils.isEmpty(downloadAddWord)) {
mDownloadTv.setBackgroundResource(
R.drawable.game_item_btn_plugin_style);
mDownloadTv.setText(String.format("插件化《%s》",
mGameEntity.getName()));
} else {
mDownloadTv.setBackgroundResource(
R.drawable.game_item_btn_plugin_style);
mDownloadTv.setText(String.format("插件化《%s》%s",
mGameEntity.getName(), downloadAddWord));
}
} else {
if (TextUtils.isEmpty(downloadAddWord)) {
mDownloadTv.setBackgroundResource(
R.drawable.game_item_btn_launch_style);
mDownloadTv.setText(String.format("启动《%s》",
mGameEntity.getName()));
} else {
mDownloadTv.setBackgroundResource(
R.drawable.game_item_btn_launch_style);
mDownloadTv.setText(String.format("启动《%s》%s",
mGameEntity.getName(), downloadAddWord));
}
}
}
} else {
String status = GameUtils.getDownloadBtnText(this, mGameEntity);
if ("插件化".equals(status)) {
mDownloadTv.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
} else if ("打开".equals(status)) {
mDownloadTv.setBackgroundResource(R.drawable.game_item_btn_launch_style);
} else {
mDownloadTv.setBackgroundResource(R.drawable.game_item_btn_download_style);
}
if (TextUtils.isEmpty(downloadAddWord)) {
mDownloadTv.setText(String.format(status + "《%s》",
mGameEntity.getName()));
} else {
mDownloadTv.setText(String.format(status + "《%s》%s",
mGameEntity.getName(), downloadAddWord));
}
}
}
if (isCheck && mGameEntity != null
&& mGameEntity.getApk() != null
&& mGameEntity.getApk().size() == 1) {
String url = mGameEntity.getApk().get(0).getUrl();
DownloadEntity downloadEntity = DownloadManager.getInstance(getApplicationContext()).get(url);
if (downloadEntity != null) {
mDownloadEntity = downloadEntity;
mDownloadTv.setVisibility(View.GONE);
mDownloadPb.setVisibility(View.VISIBLE);
mDownloadPer.setVisibility(View.VISIBLE);
invalidate();
}
}
}
}

View File

@ -34,6 +34,7 @@ import com.gh.common.util.NetworkUtils;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.ShareUtils;
import com.gh.common.view.DownloadDialog;
import com.gh.common.view.VerticalItemDecoration;
import com.gh.download.DataWatcher;
import com.gh.download.DownloadEntity;
import com.gh.download.DownloadManager;
@ -157,6 +158,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener
detail_rv_show.setHasFixedSize(true);
detail_rv_show.setLayoutManager(new LinearLayoutManager(this));
detail_rv_show.addItemDecoration(new VerticalItemDecoration(this, 8, false));
adapter = new NewsDetailAdapter(this, entrance);
detail_rv_show.setAdapter(adapter);

View File

@ -0,0 +1,123 @@
package com.gh.gamecenter;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;
import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
import com.gh.base.BaseActivity;
import com.gh.common.view.VerticalItemDecoration;
import com.gh.gamecenter.adapter.NewsNormalAdapter;
import com.gh.gamecenter.eventbus.EBNetworkState;
import butterknife.BindView;
import butterknife.OnClick;
/**
* Created by khy on 2017/3/15.
*
* 原创 + 资讯
*/
public class NewsNormalActivity extends BaseActivity implements SwipeRefreshLayout.OnRefreshListener{
@BindView(R.id.newsnormal_srl)
SwipeRefreshLayout mRefreshLayout;
@BindView(R.id.newsnormal_rv)
RecyclerView mRecyclerView;
@BindView(R.id.newsnormal_pb)
ProgressBarCircularIndeterminate loadingLayout;
@BindView(R.id.reuse_no_connection) LinearLayout mNoConnectionLayout;
private LinearLayoutManager layoutManager;
private NewsNormalAdapter mAdapter;
private String mNewsType;
Runnable runnable = new Runnable() {
@Override
public void run() {
mAdapter = new NewsNormalAdapter(NewsNormalActivity.this, mNewsType);
mRecyclerView.setAdapter(mAdapter);
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mNewsType = getIntent().getExtras().getString("newsType");
View view = View.inflate(this, R.layout.activity_newsnormal, null);
if ("yuanchuang".equals(mNewsType)) {
init(view, "原创");
} else {
init(view, "资讯");
}
mRefreshLayout.setColorSchemeResources(R.color.theme);
mRefreshLayout.setOnRefreshListener(this);
mRecyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(layoutManager);
mAdapter = new NewsNormalAdapter(NewsNormalActivity.this, mNewsType);
mRecyclerView.addItemDecoration(new VerticalItemDecoration(this, 8, true));
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_IDLE
&& layoutManager.findLastVisibleItemPosition() + 1 == mAdapter.getItemCount()) {
if (!mAdapter.isOver() && !mAdapter.isLoading() && !mAdapter.isNetworkError()) {
mAdapter.addList(mAdapter.getNewsListSize());
}
}
}
});
}
@OnClick(R.id.reuse_no_connection)
public void reconnection() { // 重新连接
mRefreshLayout.setRefreshing(true);
mRecyclerView.setVisibility(View.VISIBLE);
loadingLayout.setVisibility(View.VISIBLE);
mNoConnectionLayout.setVisibility(View.GONE);
mRecyclerView.postDelayed(runnable, 1000);
}
@Override
public void loadDone() { // 数据加载成功回调
mRefreshLayout.setRefreshing(false);
loadingLayout.setVisibility(View.GONE);
}
@Override
public void loadError() { // 数据加载失败回调
mRefreshLayout.setRefreshing(false);
loadingLayout.setVisibility(View.GONE);
mRecyclerView.setVisibility(View.GONE);
mNoConnectionLayout.setVisibility(View.VISIBLE);
}
// 连接上网络事件
public void onEventMainThread(EBNetworkState busNetworkState) {
if (busNetworkState.isNetworkConnected()) {
if (mNoConnectionLayout.getVisibility() == View.VISIBLE) {
reconnection();
} else if (mAdapter.isNetworkError()) {
mAdapter.setNetworkError(false);
mAdapter.notifyItemChanged(mAdapter.getItemCount() - 1);
mAdapter.addList(mAdapter.getNewsListSize());
}
}
}
@Override
public void onRefresh() {
mRecyclerView.postDelayed(runnable, 1000);
}
}

View File

@ -2,7 +2,6 @@ package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.widget.RecyclerView;
@ -18,15 +17,13 @@ import android.widget.TextView;
import android.widget.Toast;
import com.gh.base.BaseActivity;
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.MeasureHeightLayoutManager;
import com.gh.common.util.NewsUtils;
import com.gh.common.view.CardLinearLayout;
import com.gh.common.view.VerticalItemDecoration;
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
import com.gh.gamecenter.adapter.viewholder.NewsTextViewHolder;
import com.gh.gamecenter.entity.NewsEntity;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
@ -54,7 +51,6 @@ public class NewsSearchActivity extends BaseActivity {
@BindView(R.id.et_search) EditText et_search;
@BindView(R.id.gamedetail_news_ll_loading) LinearLayout gamedetail_news_ll_loading;
@BindView(R.id.reuse_no_connection) LinearLayout reuse_no_connection;
@BindView(R.id.gamedetail_news_cardView) CardLinearLayout gamedetail_news_cardView;
private MeasureHeightLayoutManager layoutManager;
private List<NewsEntity> newsEntities;
@ -89,14 +85,6 @@ public class NewsSearchActivity extends BaseActivity {
DisplayMetrics outMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
ViewGroup.LayoutParams params = gamedetail_news_cardView.getLayoutParams();
params.height = outMetrics.heightPixels
- DisplayUtils.dip2px(this, 38 + 16 + 8 + 8)
- getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE).getInt("actionbar_height",
DisplayUtils.dip2px(getApplicationContext(), 48))
- DisplayUtils.getStatusBarHeight(getResources());
gamedetail_news_cardView.setLayoutParams(params);
newsEntities = new ArrayList<>();
searchAdapter = new NewsSearchAdapter();
@ -104,7 +92,7 @@ public class NewsSearchActivity extends BaseActivity {
gamedetail_news_rv.setLayoutManager(layoutManager);
gamedetail_news_rv.setAdapter(searchAdapter);
gamedetail_news_rv.addItemDecoration(new VerticalItemDecoration(NewsSearchActivity.this, 1));
gamedetail_news_rv.addItemDecoration(new VerticalItemDecoration(NewsSearchActivity.this, 1, false));
et_search.setText(searchKey);
@ -124,7 +112,6 @@ public class NewsSearchActivity extends BaseActivity {
searchAdapter.notifyDataSetChanged();
gamedetail_news_ll_loading.setVisibility(View.VISIBLE);
reuse_none_data.setVisibility(View.GONE);
gamedetail_news_cardView.setVisibility(View.GONE);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
handler.postDelayed(new Runnable() {
@ -160,7 +147,6 @@ public class NewsSearchActivity extends BaseActivity {
public void onClick(View v) {
reuse_no_connection.setVisibility(View.GONE);
gamedetail_news_ll_loading.setVisibility(View.VISIBLE);
gamedetail_news_cardView.setVisibility(View.GONE);
handler.postDelayed(new Runnable() {
@Override
public void run() {
@ -173,8 +159,8 @@ public class NewsSearchActivity extends BaseActivity {
}
private void loadNewsData(final int page) {
DataUtils.onEvent(this, "游戏新闻搜索", searchKey);
DataCollectionUtils.uploadSearch(this, searchKey, "游戏新闻搜索");
// DataUtils.onEvent(this, "游戏新闻搜索", searchKey);
// DataCollectionUtils.uploadSearch(this, searchKey, "游戏新闻搜索");
RetrofitManager.getApi().getSearchNews(gameId, searchKey, page, 20)
.map(new Func1<List<NewsEntity>, List<NewsEntity>>() {
@ -191,7 +177,6 @@ public class NewsSearchActivity extends BaseActivity {
public void onResponse(List<NewsEntity> response) {
isLoadOver = true;
gamedetail_news_ll_loading.setVisibility(View.GONE);
gamedetail_news_cardView.setVisibility(View.VISIBLE);
reuse_none_data.setVisibility(View.GONE);
if (response.size() != 0) {
@ -199,7 +184,6 @@ public class NewsSearchActivity extends BaseActivity {
searchAdapter.notifyDataSetChanged();
} else {
if (page == 1) {
gamedetail_news_cardView.setVisibility(View.GONE);
reuse_none_data.setVisibility(View.VISIBLE);
}
@ -243,31 +227,20 @@ public class NewsSearchActivity extends BaseActivity {
R.layout.refresh_footerview, parent, false);
return new FooterViewHolder(view);
} else {
LinearLayout linearLayout = new LinearLayout(parent.getContext());
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
linearLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
linearLayout.setBackgroundResource(R.drawable.cardview_item_style);
TextView textView = new TextView(parent.getContext());
textView.setPadding(DisplayUtils.dip2px(NewsSearchActivity.this,10),DisplayUtils.dip2px(NewsSearchActivity.this,10)
,0, DisplayUtils.dip2px(NewsSearchActivity.this,10));
textView.setTextColor(Color.parseColor("#3a3a3a"));
textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
textView.setSingleLine();
textView.setTextSize(15);
linearLayout.addView(textView);
return new ViewHolder(linearLayout);
View view = LayoutInflater.from(parent.getContext()).inflate(
R.layout.news_text_item, parent, false);
return new NewsTextViewHolder(view);
}
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
if (holder instanceof ViewHolder){
ViewHolder viewHolder = (ViewHolder) holder;
viewHolder.tvTitle.setText(Html.fromHtml(newsEntities.get(position).getTitle()));
viewHolder.linearLayout.setOnClickListener(new View.OnClickListener() {
if (holder instanceof NewsTextViewHolder){
NewsTextViewHolder viewHolder = (NewsTextViewHolder) holder;
viewHolder.title.setText(Html.fromHtml(newsEntities.get(position).getTitle()));
viewHolder.type.setVisibility(View.GONE);
viewHolder.line.setVisibility(View.GONE);
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NewsEntity newsEntity = newsEntities.get(holder.getPosition());
@ -321,14 +294,5 @@ public class NewsSearchActivity extends BaseActivity {
return newsEntities.size() + 1;
}
public class ViewHolder extends RecyclerView.ViewHolder{
LinearLayout linearLayout;
TextView tvTitle;
public ViewHolder(View itemView) {
super(itemView);
linearLayout = (LinearLayout) itemView;
tvTitle = (TextView) linearLayout.getChildAt(0);
}
}
}
}

View File

@ -13,6 +13,7 @@ import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
@ -61,6 +62,8 @@ public class ReceiverWaitingActivity extends BaseActivity {
@BindView(R.id.reuse_actionbar) RelativeLayout mActionbar;
@BindView(R.id.waiting_gprs_hint) TextView mGPRSHint;
@BindView(R.id.waiting_no_conn_hint) TextView mNoConnHint;
@BindView(R.id.actionbar_iv_back) ImageView mBackIv;
@BindView(R.id.actionbar_tv_title) TextView mTitleTv;
private WifiAPBroadcastReceiver mWifiAPBroadcastReceiver;
@ -114,6 +117,9 @@ public class ReceiverWaitingActivity extends BaseActivity {
View contentView = View.inflate(this, R.layout.activity_receiver_waiting, null);
init(contentView, "接收游戏");
mTitleTv.setTextColor(Color.WHITE);
mBackIv.setImageResource(R.drawable.reuse_kc_back);
// 添加分享图标
TextView hintTv = new TextView(this);
hintTv.setText("操作说明");

View File

@ -44,6 +44,7 @@ public class SearchActivity extends BaseFragmentActivity {
private SearchHistoryDao dao;
private String searchKey;
private String searchType;
private int currentTab;
@ -53,7 +54,7 @@ public class SearchActivity extends BaseFragmentActivity {
@Override
public void handleMessage(Message msg) {
if (msg.what == 1){
setResultPresentModel(1);
search("auto", searchKey);
}
}
};
@ -63,6 +64,7 @@ public class SearchActivity extends BaseFragmentActivity {
super.onSaveInstanceState(outState);
outState.putInt("currentTab", currentTab);
outState.putString("searchKey", searchKey);
outState.putString("searchType", searchType);
}
@Override
@ -75,7 +77,7 @@ public class SearchActivity extends BaseFragmentActivity {
setTranslucentStatus(true);
SystemBarTintManager tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
tintManager.setStatusBarTintResource(R.color.theme);
tintManager.setStatusBarTintResource(R.color.back);
SystemBarConfig config = tintManager.getConfig();
contentView.setPadding(0, config.getPixelInsetTop(false), 0,
config.getPixelInsetBottom());
@ -87,30 +89,32 @@ public class SearchActivity extends BaseFragmentActivity {
boolean isFromHome = getIntent().getBooleanExtra("clicked", false);
String hint = getIntent().getStringExtra("hint");
setActionBarLayout(hint, isFromHome);
setActionBarLayout();
currentTab = 0;
if (savedInstanceState != null) {
currentTab = savedInstanceState.getInt("currentTab", 0);
searchKey = savedInstanceState.getString("searchKey", null);
if (TextUtils.isEmpty(searchKey)) {
currentTab = 0;
} else {
isSearchDetail = true;
searchInput.setText(searchKey);
searchInput.setSelection(searchInput.getText().length());
searchType = savedInstanceState.getString("searchType", null);
if (currentTab != 0 && !TextUtils.isEmpty(searchKey)) {
search(searchType, searchKey);
}
} else if (!TextUtils.isEmpty(hint)) {
searchInput.setHint(hint);
if (isFromHome) {
currentTab = 2;
search("default", hint);
}
} else {
currentTab = 0;
if (isFromHome && !TextUtils.isEmpty(hint)) {
searchKey = hint;
currentTab = 2;
}
searchInput.setHint("搜索游戏...");
}
setResultPresentModel(currentTab);
if (currentTab == 0) {
setResultPresentModel(0);
}
}
public void setActionBarLayout(final String hint, final boolean isFromHome) {
public void setActionBarLayout() {
int actionbar_height = getSharedPreferences(Config.PREFERENCE,
Context.MODE_PRIVATE).getInt("actionbar_height",
DisplayUtils.dip2px(getApplicationContext(), 48));
@ -127,24 +131,7 @@ public class SearchActivity extends BaseFragmentActivity {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
String newSearchKey = searchInput.getText().toString().trim();
if (newSearchKey.length() < 1) {
if (!TextUtils.isEmpty(hint)) {
newSearchKey = searchInput.getHint().toString();
isSearchDetail = true;
searchInput.setText(hint);
searchInput.setSelection(searchInput.getText().length());
}
}
if (!newSearchKey.equals(searchKey) || currentTab != 2) {
searchKey = newSearchKey;
if (!TextUtils.isEmpty(searchKey)) {
setResultPresentModel(2);
dao.add(searchKey);
} else {
toast("请输入搜索内容");
}
}
search("initiative", null);
}
return false;
}
@ -152,40 +139,12 @@ public class SearchActivity extends BaseFragmentActivity {
searchButton = (TextView) findViewById(R.id.btnSearch);
searchCancel = (ImageView) findViewById(R.id.ivDeleteText);
if (isFromHome && !TextUtils.isEmpty(hint)) {
isSearchDetail = true;
searchInput.setText(hint);
searchInput.setSelection(searchInput.getText().length());
} else if (!TextUtils.isEmpty(hint)) {
searchInput.setHint(hint);
} else {
searchInput.setHint("搜索游戏...");
}
searchButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
String newSearchKey = searchInput.getText().toString().trim();
if (newSearchKey.length() < 1) {
if (!TextUtils.isEmpty(hint)) {
newSearchKey = searchInput.getHint().toString();
isSearchDetail = true;
searchInput.setText(hint);
searchInput.setSelection(searchInput.getText().length());
}
}
if (!newSearchKey.equals(searchKey) || currentTab != 2) {
searchKey = newSearchKey;
if (!TextUtils.isEmpty(searchKey)) {
setResultPresentModel(2);
dao.add(searchKey);
isSearchDetail = false;
} else {
toast("请输入搜索内容");
}
}
search("initiative", null);
}
});
@ -195,7 +154,6 @@ public class SearchActivity extends BaseFragmentActivity {
searchCancel.setVisibility(View.GONE);
searchInput.setText("");
}
});
searchInput.addTextChangedListener(new TextWatcher() {
@ -234,7 +192,57 @@ public class SearchActivity extends BaseFragmentActivity {
finish();
}
});
}
private void search(String type, String key) {
searchType = type;
if ("auto".equals(type)) {
//自动搜索
searchKey = key;
setResultPresentModel(1);
} else if ("default".equals(type)) {
//默认搜索
isSearchDetail = true;
searchKey = key;
searchInput.setText(key);
searchInput.setSelection(searchInput.getText().length());
setResultPresentModel(2);
isSearchDetail = false;
} else if ("remen".equals(type)) {
//热门搜索
isSearchDetail = true;
searchKey = key;
searchInput.setText(key);
searchInput.setSelection(searchInput.getText().length());
setResultPresentModel(2);
isSearchDetail = false;
} else if ("history".equals(type)) {
//历史搜索
isSearchDetail = true;
searchKey = key;
searchInput.setText(key);
searchInput.setSelection(searchInput.getText().length());
setResultPresentModel(2);
isSearchDetail = false;
} else if ("initiative".equals(type)) {
//主动搜索
String newSearchKey = searchInput.getText().toString().trim();
if (newSearchKey.length() < 1) {
String hint = searchInput.getHint().toString();
if (!TextUtils.isEmpty(hint) && !"搜索游戏...".equals(hint)) {
dao.add(hint);
search("default", hint);
}
} else if (!newSearchKey.equals(searchKey) || currentTab != 2) {
searchKey = newSearchKey;
if (!TextUtils.isEmpty(searchKey)) {
dao.add(searchKey);
setResultPresentModel(2);
} else {
toast("请输入搜索内容");
}
}
}
}
private void setResultPresentModel(int model) {
@ -247,16 +255,13 @@ public class SearchActivity extends BaseFragmentActivity {
break;
case 1:
SearchGameListFragment game_list_fragment = new SearchGameListFragment();
game_list_fragment.setKey(searchKey);
game_list_fragment.setParams(searchKey, searchType);
transaction.replace(R.id.search_result, game_list_fragment);
currentTab = 1;
break;
case 2:
DataUtils.onEvent(SearchActivity.this, "搜索页面", searchKey);
DataCollectionUtils.uploadSearch(this, searchKey, "搜索页面");
SearchGameDetailFragment game_detail_fragment = new SearchGameDetailFragment();
game_detail_fragment.setKey(searchKey);
game_detail_fragment.setParams(searchKey, searchType);
transaction.replace(R.id.search_result, game_detail_fragment);
currentTab = 2;
break;
@ -267,22 +272,17 @@ public class SearchActivity extends BaseFragmentActivity {
}
public void onEvent(EBSearch search) {
isSearchDetail = true;
String str = search.getKey();
searchInput.setText(str);
searchInput.setFocusable(true);
searchInput.requestFocus();
searchInput.setSelection(str.length());
if (search.isSearch()) {
searchButton.performClick();
if ("history".equals(search.getType())) {
search("history", search.getKey());
} else if ("remen".equals(search.getType())) {
search("remen", search.getKey());
} else if ("click".equals(search.getType())) {
DataCollectionUtils.uploadSearchClick(this, searchKey, searchType, "搜索页面",
search.getGameId(), search.getGameName());
} else if ("search".equals(search.getType())) {
DataCollectionUtils.uploadSearch(this, searchKey, searchType, "搜索页面",
search.getGameId(), search.getGameName());
}
}
@Override
public void finish() {
super.finish();
DataUtils.onEvent(this, "搜索页面", searchKey);
DataCollectionUtils.uploadSearch(this, searchKey, "搜索页面");
}
}

View File

@ -71,7 +71,7 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
findViewById(R.id.setting_rl_autoinstall).setOnClickListener(this);
findViewById(R.id.setting_rl_autodelete).setOnClickListener(this);
findViewById(R.id.setting_rl_deletedata).setOnClickListener(this);
findViewById(R.id.setting_rl_feedback).setOnClickListener(this);
// findViewById(R.id.setting_rl_feedback).setOnClickListener(this);
findViewById(R.id.setting_rl_cache).setOnClickListener(this);
findViewById(R.id.setting_cv_font_size).setOnClickListener(this);
findViewById(R.id.setting_rl_concerngame).setOnClickListener(this);
@ -189,11 +189,11 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
}
});
break;
case R.id.setting_rl_feedback:
Intent intent = new Intent(SettingActivity.this, SuggestionActivity.class);
intent.putExtra("entrance", "(设置)");
startActivity(intent);
break;
// case R.id.setting_rl_feedback:
// Intent intent = new Intent(SettingActivity.this, SuggestionActivity.class);
// intent.putExtra("entrance", "(设置)");
// startActivity(intent);
// break;
case R.id.setting_cv_font_size:
fontSize();
break;

View File

@ -47,6 +47,7 @@ public class SkipActivity extends BaseActivity {
+ "-" + PlatformUtils.getInstance(this).getPlatformName(uri.getQueryParameter("platform"))
+ "-V" + uri.getQueryParameter("version") + "";
intent.putExtra("content", content);
intent.putExtra("suggestHintType", "plugin");
intent.setClass(this, SuggestionActivity.class);
} else if ("download".equals(host)) {
intent.setClass(this, DownloadManagerActivity.class);

View File

@ -325,12 +325,6 @@ public class SplashScreenActivity extends BaseActivity {
bundle = getIntent().getBundleExtra("data");
}
if (sp.getBoolean("isNewFirstLaunchV" + PackageUtils.getVersionName(getApplicationContext()), true)) {
bundle = new Bundle();
bundle.putString("to", "DownloadManagerActivity");
bundle.putInt("currentItem", 0);
}
Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
intent.putExtra("data", bundle);
startActivity(intent);

View File

@ -1,218 +0,0 @@
package com.gh.gamecenter;
import android.animation.Animator;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gh.base.BaseActivity;
import com.gh.common.util.MeasureHeightLayoutManager;
import com.gh.gamecenter.adapter.StrategyAdapter;
import com.gh.gamecenter.adapter.StrategyDialogAdapter;
import com.gh.gamecenter.db.info.ConcernInfo;
import com.gh.gamecenter.manager.ConcernManager;
import com.jakewharton.rxbinding.view.RxView;
import java.util.List;
import java.util.concurrent.TimeUnit;
import butterknife.BindView;
import rx.functions.Action1;
/**
* Created by khy on 2016/12/5.
*
*/
public class StrategyActivity extends BaseActivity implements StrategyDialogAdapter.OnStrategyDialogCallBackListener{
@BindView(R.id.strategy_game_name) TextView mGameName;
@BindView(R.id.strategy_select_game_rl) RelativeLayout mSelectGameRl;
@BindView(R.id.strategy_rv) RecyclerView mStrategyRv;
@BindView(R.id.popup_bg) View popupBg;
@BindView(R.id.reuse_none_data) LinearLayout mNoData;
private StrategyAdapter mStrategyAdapter;
private PopupWindow mPopupWindow;
private static int mDialogGamePosition = -1;
private static String gameId;
private static String gameName;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View contentView = View.inflate(this, R.layout.activity_strategy, null);
init(contentView, "攻略");
ConcernManager concernManager = new ConcernManager(this);
List<ConcernInfo> concernGame = concernManager.getConcernGame();
if (!TextUtils.isEmpty(gameName)) {
for (ConcernInfo concernInfo : concernGame) {
if (gameName.equals(concernInfo.getGameName())) {
mGameName.setText(gameName);
break;
}
}
}
String str = mGameName.getText().toString();
if (TextUtils.isEmpty(str) || str.equals("全部游戏")) {
gameId = null;
gameName = null;
mDialogGamePosition = -1;
}
mStrategyAdapter = new StrategyAdapter(this, gameId, mNoData);
final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
mStrategyRv.setLayoutManager(layoutManager);
mStrategyRv.setAdapter(mStrategyAdapter);
mStrategyRv.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if(layoutManager.findLastVisibleItemPosition() + 1 == mStrategyAdapter.getItemCount()
&& newState == RecyclerView.SCROLL_STATE_IDLE && mStrategyAdapter.isCanLoading()) {
mStrategyAdapter.addList(mStrategyAdapter.getItemCount()-1);
}
}
});
if (concernGame.size() >1 || (concernGame.size() == 1
&& !concernGame.get(0).getId().equals("5618b86e8ab49e17088b4575"))) {
mSelectGameRl.setVisibility(View.VISIBLE);
}
// 防抖处理
RxView.clicks(mSelectGameRl)
.throttleFirst(1, TimeUnit.SECONDS)
.subscribe(new Action1<Void>() {
@Override
public void call(Void aVoid) {
OnSelectGameClickListener();
}
});
}
public void OnSelectGameClickListener() {
isShowPopupBg(true);
View contentView = View.inflate(this, R.layout.dialog_strategy_select_game, null);
RecyclerView selectGameRv = (RecyclerView) contentView.findViewById(R.id.dialog_strategy_select_game_rv);
ImageView selectIcon = (ImageView) contentView.findViewById(R.id.dialog_strategy_select_game_icon);
RelativeLayout allGameRl = (RelativeLayout) contentView.findViewById(R.id.dialog_strategy_select_game_rl);
allGameRl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mGameName.setText("全部游戏");
mDialogGamePosition = -1;
gameId = null;
isShowPopupBg(false);
mStrategyAdapter = new StrategyAdapter(StrategyActivity.this, gameId, mNoData);
mStrategyRv.setAdapter(mStrategyAdapter);
}
});
if (mDialogGamePosition == -1) {
selectIcon.setImageResource(R.drawable.strategy_game_select);
} else {
selectIcon.setImageDrawable(new ColorDrawable(0));
}
selectGameRv.setLayoutManager(new MeasureHeightLayoutManager(this));
selectGameRv.setAdapter(new StrategyDialogAdapter(this, mDialogGamePosition));
mPopupWindow = new PopupWindow(contentView, LinearLayout.LayoutParams.MATCH_PARENT
, LinearLayout.LayoutParams.MATCH_PARENT, true);
mPopupWindow.setAnimationStyle(R.style.scale_popwindow_anim_style);
mPopupWindow.showAtLocation(mSelectGameRl, 0, 0, 0);
selectGameRv.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK
&& event.getRepeatCount() == 0
&& mPopupWindow != null
&& mPopupWindow.isShowing()) {
isShowPopupBg(false);
}
return false;
}
});
contentView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
isShowPopupBg(false);
}
});
}
public void isShowPopupBg(boolean isShow) {
if(isShow) {
popupBg.setVisibility(View.VISIBLE);
popupBg.animate()
.alpha(1f)
.setDuration(300)
.setListener(null);
} else {
mPopupWindow.dismiss();
popupBg.animate()
.alpha(0f)
.setDuration(300)
.setListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
popupBg.setVisibility(View.GONE);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
}
}
public boolean selectRlIsVisible() {
return mSelectGameRl.getVisibility() == View.VISIBLE;
}
@Override
public void selectPosition(int position, ConcernInfo concernInfo) {
gameId = concernInfo.getId();
gameName = concernInfo.getGameName();
mNoData.setVisibility(View.GONE);
mDialogGamePosition = position;
mGameName.setText(gameName);
isShowPopupBg(false);
mStrategyAdapter = new StrategyAdapter(this, gameId, mNoData);
mStrategyRv.setAdapter(mStrategyAdapter);
}
}

View File

@ -1,20 +1,26 @@
package com.gh.gamecenter;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
import com.gh.base.BaseActivity;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.DownloadItemUtils;
import com.gh.common.util.Utils;
import com.gh.common.view.VerticalItemDecoration;
import com.gh.download.DataWatcher;
import com.gh.download.DownloadEntity;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.adapter.SubjectAdapter;
import com.gh.gamecenter.adapter.SubjectTypeAdapter;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.eventbus.EBDownloadStatus;
@ -32,9 +38,10 @@ import butterknife.BindView;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
public class SubjectActivity extends BaseActivity {
public class SubjectActivity extends BaseActivity implements SubjectTypeAdapter.OnSelectTypeListener {
@BindView(R.id.subject_list) RecyclerView subject_list;
@BindView(R.id.subject_type_list) RecyclerView subject_type_list;
@BindView(R.id.subject_pb_loading) ProgressBarCircularIndeterminate subject_pb_loading;
@BindView(R.id.reuse_no_connection) LinearLayout reuse_no_connection;
@ -43,6 +50,8 @@ public class SubjectActivity extends BaseActivity {
private int page = 1;
private String type;
private boolean isEverpause = false;
// 黄壮华 添加观察者 修改2015/8/15
@ -76,40 +85,52 @@ public class SubjectActivity extends BaseActivity {
}
init(contentView, name);
type = "全部";
reuse_no_connection.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
subject_pb_loading.setVisibility(View.VISIBLE);
subject_list.setVisibility(View.VISIBLE);
reuse_no_connection.setVisibility(View.GONE);
adapter = new SubjectAdapter(SubjectActivity.this);
adapter = new SubjectAdapter(SubjectActivity.this, type);
subject_list.setAdapter(adapter);
}
});
layoutManager = new LinearLayoutManager(this);
subject_list.addItemDecoration(new VerticalItemDecoration(this, 8, true));
subject_list.setHasFixedSize(true);
subject_list.setLayoutManager(layoutManager);
adapter = new SubjectAdapter(this);
adapter = new SubjectAdapter(this, type);
subject_list.setAdapter(adapter);
subject_list.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (adapter.isLoaded() && newState == RecyclerView.SCROLL_STATE_IDLE
if (!adapter.isRemove() && adapter.isLoaded() && newState == RecyclerView.SCROLL_STATE_IDLE
&& adapter.getItemCount() == layoutManager.findLastVisibleItemPosition() + 1){
page++;
adapter.initList(page);
adapter.initList(page, type);
}
}
});
GridLayoutManager layout = new GridLayoutManager(this, 4){
@Override
public boolean canScrollVertically() {
return false;
}
};
subject_type_list.setLayoutManager(layout);
if (TextUtils.isEmpty(name) && !TextUtils.isEmpty(id)) {
getSubjectName(id);
}
}
private void getSubjectName(String id) {
@ -145,6 +166,22 @@ public class SubjectActivity extends BaseActivity {
if (subject_pb_loading != null && subject_pb_loading.getVisibility() == View.VISIBLE) {
subject_pb_loading.setVisibility(View.GONE);
}
page ++;
}
@Override
public void loadDone(Object obj) {
super.loadDone(obj);
// 初始化顶部分类标签
if (!type.equals("全部")) return;
ArrayList<String> gameType = (ArrayList<String>) obj;
gameType.add(0, "全部");
ViewGroup.LayoutParams params = subject_type_list.getLayoutParams();
params.height = (int) Math.ceil(gameType.size() / 4f) * DisplayUtils.dip2px(this, 37);
subject_type_list.setLayoutParams(params);
SubjectTypeAdapter adapter = new SubjectTypeAdapter(SubjectActivity.this, gameType);
subject_type_list.setAdapter(adapter);
}
// 下载被删除事件
@ -196,7 +233,7 @@ public class SubjectActivity extends BaseActivity {
subject_list.setVisibility(View.VISIBLE);
subject_pb_loading.setVisibility(View.VISIBLE);
reuse_no_connection.setVisibility(View.GONE);
adapter = new SubjectAdapter(SubjectActivity.this);
adapter = new SubjectAdapter(SubjectActivity.this, type);
subject_list.setAdapter(adapter);
}
}
@ -221,4 +258,15 @@ public class SubjectActivity extends BaseActivity {
DownloadManager.getInstance(getApplicationContext()).removeObserver(dataWatcher);
}
@Override
public void onSelectType(String type) {
Utils.toast(this, type);
page = 1;
this.type = type;
subject_list.setVisibility(View.VISIBLE);
subject_pb_loading.setVisibility(View.VISIBLE);
reuse_no_connection.setVisibility(View.GONE);
adapter = new SubjectAdapter(this, type);
subject_list.setAdapter(adapter);
}
}

View File

@ -0,0 +1,76 @@
package com.gh.gamecenter;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gh.base.BaseActivity;
import com.gh.common.util.QQUtils;
import butterknife.BindView;
import butterknife.OnClick;
/**
* Created by khy on 2017/3/31.
*/
public class SuggestSelectActivity extends BaseActivity {
@BindView(R.id.suggest_type1) RelativeLayout mType1;
@BindView(R.id.suggest_type2) RelativeLayout mType2;
@BindView(R.id.suggest_type3) RelativeLayout mType3;
@BindView(R.id.suggest_type4) RelativeLayout mType4;
@BindView(R.id.suggest_type5) RelativeLayout mType5;
@BindView(R.id.suggest_type6) RelativeLayout mType6;
@BindView(R.id.suggest_qqun) TextView mQqun;
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0x121 && resultCode == 0x122) {
finish();
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View view = View.inflate(this, R.layout.activity_suggest_select, null);
init(view, "意见反馈");
}
@OnClick({R.id.suggest_type1, R.id.suggest_type2, R.id.suggest_type3
, R.id.suggest_type4, R.id.suggest_type5, R.id.suggest_type6, R.id.suggest_qqun_rl})
public void OnClick(View view){
int type = 1;
switch (view.getId()) {
case R.id.suggest_type1:
type = 1;
break;
case R.id.suggest_type2:
type = 2;
break;
case R.id.suggest_type3:
type = 3;
break;
case R.id.suggest_type4:
type = 4;
break;
case R.id.suggest_type5:
type = 5;
break;
case R.id.suggest_type6:
type = 6;
break;
case R.id.suggest_qqun_rl:
QQUtils.joinQQGroup(SuggestSelectActivity.this, "vd754P2_uNUJqDcgX4V-pyXEGZZVH0DE");
return;
}
Intent intent = new Intent(this, SuggestionActivity.class);
intent.putExtra("suggestType", type);
intent.putExtra("suggestHintType", "Normal");
startActivityForResult(intent, 0x121);
}
}

View File

@ -2,224 +2,684 @@ package com.gh.gamecenter;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.telephony.TelephonyManager;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import com.gh.base.BaseActivity;
import com.gh.common.constant.Config;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.FileUtils;
import com.gh.common.util.PackageUtils;
import com.gh.common.view.CardLinearLayout;
import com.gh.common.util.TokenUtils;
import com.gh.common.util.Utils;
import com.gh.gamecenter.entity.InstallGameEntity;
import com.gh.gamecenter.retrofit.JSONObjectResponse;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.gh.gamecenter.suggest.SuggestPicAdapter;
import com.gh.gamecenter.suggest.SuggestSelectGameAdapter;
import com.gh.gamecenter.suggest.SuggestTypeAdapter;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import butterknife.BindView;
import butterknife.OnClick;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.adapter.rxjava.HttpException;
import rx.Observable;
import rx.Observer;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Func1;
import rx.schedulers.Schedulers;
/**
* @author fang
* @from SettingActivity
* @function 填写反馈页面
*
* */
public class SuggestionActivity extends BaseActivity implements OnClickListener {
* Created by khy on 2017/3/31.
*/
public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapter.OnSelectTypeListener {
@BindView(R.id.tv_suggest_connectway) TextView tv_suggest_connectway;
@BindView(R.id.et_suggest_content) EditText et_suggest_content;
@BindView(R.id.et_suggest_connectway) EditText et_suggest_connectway;
@BindView(R.id.btn_suggest_post) CardLinearLayout btn_suggest_post;
@BindView(R.id.suggest_content_et)
EditText mSuggestContentEt;
@BindView(R.id.suggest_pic_rv)
RecyclerView mSuggestPicRv;
@BindView(R.id.suggest_news_link_et)
EditText mSuggestNewsLinkEt;
@BindView(R.id.suggest_news_link_ll)
LinearLayout mSuggestNewsLinkLl;
@BindView(R.id.suggest_email_et)
EditText mSuggestEmailEt;
@BindView(R.id.suggest_post_btn)
TextView mSuggestPostBtn;
@BindView(R.id.suggest_post_ll)
LinearLayout suggestPostLl;
@BindView(R.id.suggest_type_rv)
RecyclerView mTypeRv;
@BindView(R.id.suggest_select_game)
TextView mSuggestSelectGame;
@BindView(R.id.suggest_game_text)
TextView mSuggestGameText;
@BindView(R.id.suggest_game_ll)
LinearLayout mSuggestGameLl;
@BindView(R.id.suggest_scrollview)
ScrollView mScrollView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
private SuggestPicAdapter mAdapter;
View contentView = View.inflate(this, R.layout.activity_suggest, null);
private Dialog selectGameDialog;
private Dialog postDialog;
init(contentView, "意见反馈");
private String[] arrType = {"普通反馈", "功能建议", "发生闪退", "游戏问题", "游戏收录", "文章投稿"};
btn_suggest_post.setOnClickListener(this);
btn_suggest_post.setClickable(false);
private int curType = -1;
et_suggest_content.requestFocus();
private SharedPreferences sp;
tv_suggest_connectway.setText("邮箱");
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (data != null && requestCode == 0x233) {
Uri selectedImage = data.getData();
if (selectedImage == null) {
return;
}
String[] filePathColumn = { MediaStore.Images.Media.DATA };
et_suggest_content.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
if (cursor == null) {
return;
}
cursor.moveToFirst();
}
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
if (s.length() > 0) {
btn_suggest_post.setClickable(true);
} else {
btn_suggest_post.setClickable(false);
}
}
Utils.log("picturePath = " + picturePath);
@Override
public void afterTextChanged(Editable s) {
mAdapter.addFileList(picturePath);
}
});
}
}
String content = getIntent().getStringExtra("content");
if (getIntent().getBundleExtra("data") != null) {
content = getIntent().getBundleExtra("data").getString("content");
}
if (!TextUtils.isEmpty(content)) {
et_suggest_content.setText(content);
et_suggest_content.setSelection(et_suggest_content.getText().length());
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View view = View.inflate(this, R.layout.activity_suggest, null);
init(view, "意见反馈");
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.actionbar_rl_back:
finish();
break;
case R.id.btn_suggest_post:
String email = et_suggest_connectway.getText().toString().trim();
if (TextUtils.isEmpty(email)) {
showConfirmDialog(email);
} else if (isEmailAddress(email)) {
Dialog dialog = new Dialog(this);
View view = View.inflate(this, R.layout.set_wait_dialog, null);
TextView message = (TextView) view
.findViewById(R.id.set_wait_message);
message.setText("正在反馈...");
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(view);
dialog.setCanceledOnTouchOutside(false);
dialog.setCancelable(false);
dialog.show();
sendSuggestion(dialog, email);
} else {
toast("邮箱错误");
}
break;
default:
break;
}
}
curType = getIntent().getExtras().getInt("suggestType");
String suggestContent = getIntent().getExtras().getString("content");
String suggestHintType = getIntent().getExtras().getString("suggestHintType");
// 弹出确认对话框
private void showConfirmDialog(final String email) {
DialogUtils.showWarningDialog(this, "温馨提示", "填写联系方式有助于我们更好地一对一解决您的问题,确定不填写吗?",
"直接提交", "我要填写",
new DialogUtils.ConfiremListener() {
@Override
public void onConfirem() {
et_suggest_connectway.requestFocus();
new Thread() {
public void run() {
try {
sleep(300);
} catch (InterruptedException e) {
if (getIntent().getBundleExtra("data") != null) {
suggestContent = getIntent().getBundleExtra("data").getString("content");
}
e.printStackTrace();
}
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(et_suggest_connectway, 0);
}
}.start();
}
},
new DialogUtils.CancelListener() {
@Override
public void onCancel() {
Dialog dialog = new Dialog(SuggestionActivity.this);
View view = View.inflate(SuggestionActivity.this,
R.layout.set_wait_dialog, null);
TextView message = (TextView) view
.findViewById(R.id.set_wait_message);
message.setText("正在反馈...");
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(view);
dialog.setCanceledOnTouchOutside(false);
dialog.setCancelable(false);
dialog.show();
sendSuggestion(dialog, email);
}
});
}
sp = getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
private void sendSuggestion(final Dialog dialog, String email) {
Map<String, String> params = new HashMap<>();
params.put("message", et_suggest_content.getText().toString().trim());
params.put("from", email);
params.put("ghversion", PackageUtils.getVersionName(this));
params.put("channel", (String) PackageUtils.getMetaData(this, getPackageName(), "TD_CHANNEL_ID"));
params.put("type", android.os.Build.MODEL);
params.put("sdk", String.valueOf(android.os.Build.VERSION.SDK_INT));
params.put("version", android.os.Build.VERSION.RELEASE);
params.put("imei", ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId());
// 意见反馈类型
mTypeRv.setLayoutManager(new GridLayoutManager(this, 2){
@Override
public boolean canScrollVertically() {
return false;
}
});
mTypeRv.setAdapter(new SuggestTypeAdapter(this, curType, arrType));
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
new JSONObject(params).toString());
RetrofitManager.getApi().postSuggestion(body)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new JSONObjectResponse() {
@Override
public void onResponse(JSONObject response) {
dialog.dismiss();
// 意见反馈上传图片列表
mSuggestPicRv.setLayoutManager(new GridLayoutManager(this, 5){
@Override
public boolean canScrollVertically() {
return false;
}
});
mAdapter = new SuggestPicAdapter(this);
mSuggestPicRv.setAdapter(mAdapter);
if (response.length() != 0) {
try {
if ("ok".equals(response.getString("status"))) {
toast("提交成功,感谢您的反馈!");
finish();
} else {
toast("提交失败,请稍后尝试!");
}
} catch (JSONException e) {
e.printStackTrace();
}
} else {
toast("提交失败,请稍后尝试!");
}
}
if (Build.VERSION.SDK_INT >= 19) {
//解决透明沉浸栏和软键盘冲突重置ScrollView高度
final View decorView=getWindow().getDecorView();
decorView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Rect rect=new Rect();
decorView.getWindowVisibleDisplayFrame(rect);
int screenHeight = decorView.getRootView().getHeight();
int heightDifference = screenHeight-rect.bottom;//计算软键盘占有的高度 = 屏幕高度 - 视图可见高度
RelativeLayout.LayoutParams layoutParams= (RelativeLayout.LayoutParams) mScrollView.getLayoutParams();
layoutParams.setMargins(0,0,0,heightDifference);//设置ScrollView的marginBottom的值为软键盘占有的高度即可
mScrollView.requestLayout();
}
});
}
@Override
public void onFailure(HttpException e) {
dialog.dismiss();
if (!TextUtils.isEmpty(suggestContent)) {
mSuggestContentEt.setText(suggestContent);
}
toast("提交失败,请检查网络状态");
}
});
}
if (curType == 5) {
mSuggestGameLl.setVisibility(View.GONE);
mSuggestContentEt.setVisibility(View.VISIBLE);
} else {
initSuggest(curType);
}
private boolean isEmailAddress(String email) {
Pattern p = Pattern
.compile("^\\s*\\w+(?:\\.{0,1}[\\w-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\\.[a-zA-Z]+\\s*$");
Matcher m = p.matcher(email);
return m.matches();
}
if (TextUtils.isEmpty(suggestHintType)) {
suggestHintType = "plugin";
}
switch (suggestHintType) {
case "plugin":
Set<String> plugin = sp.getStringSet("suggestionPlugin", null);
if (plugin != null) {
showHintDialog(plugin);
}
break;
case "game":
Set<String> game = sp.getStringSet("suggestionGame", null);
if (game != null) {
showHintDialog(game);
}
break;
case "libao":
Set<String> libao = sp.getStringSet("suggestionLibao", null);
if (libao != null) {
showHintDialog(libao);
}
break;
case "service":
Set<String> service = sp.getStringSet("suggestionService", null);
if (service != null) {
showHintDialog(service);
}
break;
}
}
private void showHintDialog(Set<String> dialogType) {
final Dialog dialog = new Dialog(SuggestionActivity.this);
LinearLayout container = new LinearLayout(SuggestionActivity.this);
container.setOrientation(LinearLayout.VERTICAL);
container.setBackgroundColor(Color.WHITE);
container.setPadding(0, DisplayUtils.dip2px(SuggestionActivity.this, 12), 0, DisplayUtils.dip2px(SuggestionActivity.this, 12));
for (String s : dialogType) {
final TextView reportTv = new TextView(SuggestionActivity.this);
reportTv.setPadding(DisplayUtils.dip2px(SuggestionActivity.this, 20), DisplayUtils.dip2px(SuggestionActivity.this, 12),
0, DisplayUtils.dip2px(SuggestionActivity.this, 12));
reportTv.setText(s);
reportTv.setTextSize(17);
reportTv.setTextColor(SuggestionActivity.this.getResources().getColor(R.color.title));
reportTv.setBackgroundResource(R.drawable.textview_white_style);
int widthPixels = SuggestionActivity.this.getResources().getDisplayMetrics().widthPixels;
reportTv.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9)/10,
LinearLayout.LayoutParams.WRAP_CONTENT));
container.addView(reportTv);
reportTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.cancel();
mSuggestContentEt.setText(mSuggestContentEt.getText().toString() + reportTv.getText().toString());
}
});
}
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(container);
dialog.show();
}
@OnClick({ R.id.suggest_post_btn, R.id.suggest_select_game, R.id.suggest_game_text})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.suggest_post_btn:
if (TextUtils.isEmpty(mSuggestContentEt.getText().toString())) {
return;
}
String email = mSuggestEmailEt.getText().toString().trim();
if (TextUtils.isEmpty(email)) {
showConfirmDialog(email);
} else if (isEmailAddress(email)) {
postDialog = new Dialog(SuggestionActivity.this);
View content = View.inflate(SuggestionActivity.this, R.layout.set_wait_dialog, null);
TextView message = (TextView) content
.findViewById(R.id.set_wait_message);
message.setText("正在反馈...");
postDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
postDialog.setContentView(content);
postDialog.setCanceledOnTouchOutside(false);
postDialog.setCancelable(false);
postDialog.show();
List<String> fileList = mAdapter.getFileList();
if (fileList != null && fileList.size() > 0) {
postPic(email);
} else {
initPostData(email, null);
}
} else {
toast("邮箱错误");
}
break;
case R.id.suggest_select_game:
showSelectDialog();
break;
case R.id.suggest_game_text:
mSuggestGameLl.setVisibility(View.GONE);
mSuggestContentEt.setVisibility(View.VISIBLE);
break;
}
}
// 弹出确认对话框
private void showConfirmDialog(final String email) {
DialogUtils.showWarningDialog(this, "温馨提示", "填写联系方式有助于我们更好地一对一解决您的问题,确定不填写吗?",
"直接提交", "我要填写",
new DialogUtils.ConfiremListener() {
@Override
public void onConfirem() {
mSuggestEmailEt.requestFocus();
new Thread() {
public void run() {
try {
sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mSuggestEmailEt, 0);
}
}.start();
}
},
new DialogUtils.CancelListener() {
@Override
public void onCancel() {
postDialog = new Dialog(SuggestionActivity.this);
View view = View.inflate(SuggestionActivity.this,
R.layout.set_wait_dialog, null);
TextView message = (TextView) view
.findViewById(R.id.set_wait_message);
message.setText("正在反馈...");
postDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
postDialog.setContentView(view);
postDialog.setCanceledOnTouchOutside(false);
postDialog.setCancelable(false);
postDialog.show();
List<String> fileList = mAdapter.getFileList();
if (fileList != null && fileList.size() > 0) {
postPic(email);
} else {
initPostData(email, null);
}
}
});
}
public boolean savePicture(String newPath, String filePath) {
BitmapFactory.Options options = new BitmapFactory.Options();
// options.inSampleSize = 2;
Bitmap bitmap = BitmapFactory.decodeFile(filePath, options);
File file = new File(newPath);
int quality = 80;
do {
try {
BufferedOutputStream bos = new BufferedOutputStream(
new FileOutputStream(file));
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, bos);
bos.flush();
bos.close();
} catch (IOException e) {
file.delete();
e.printStackTrace();
return false;
}
quality -= 10;
} while (file.length() > 81920);
return true;
}
private void postPic(final String email) {
final JSONArray picArray = new JSONArray();
Observable.create(new Observable.OnSubscribe<JSONObject>() {
@Override
public void call(Subscriber<? super JSONObject> subscriber) {
String path;
int index = 0;
for (String s : mAdapter.getFileList()) {
path = getCacheDir() + File.separator + System.currentTimeMillis() + index + ".jpg";
if (savePicture(path, s)) {
subscriber.onNext(FileUtils.uploadFile(Config.HOST + "support/user/suggestion/img", path, null));
index ++;
} else {
subscriber.onNext(FileUtils.uploadFile(Config.HOST + "support/user/suggestion/img", s, null));
}
}
subscriber.onCompleted();
}
}).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<JSONObject>() {
@Override
public void onCompleted() {
Utils.log("=========完成" );
initPostData(email, picArray);
}
@Override
public void onError(Throwable e) {
Utils.log("=========错误" + e.toString());
}
@Override
public void onNext(JSONObject result) {
if (result != null) {
try {
Utils.log("===========" + result);
int statusCode = result.getInt("statusCode");
if (statusCode == HttpURLConnection.HTTP_OK) {
picArray.put(result.getString("img"));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
}
private void initPostData(String email, JSONArray picArray) {
Map<String, String> params = new HashMap<>();
params.put("message", mSuggestContentEt.getText().toString().trim());
params.put("from", email);
params.put("ghversion", PackageUtils.getVersionName(this));
params.put("channel", (String) PackageUtils.getMetaData(this, getPackageName(), "TD_CHANNEL_ID"));
params.put("type", android.os.Build.MODEL);
params.put("sdk", String.valueOf(android.os.Build.VERSION.SDK_INT));
params.put("version", android.os.Build.VERSION.RELEASE);
params.put("source", "光环助手");
params.put("imei", ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId());
if (curType == 6 && !TextUtils.isEmpty(mSuggestNewsLinkEt.getText().toString())) {
params.put("url", mSuggestNewsLinkEt.getText().toString().trim());
}
if (curType > 0) {
params.put("suggestion_type", arrType[curType - 1]);
}
if (curType == 3) {
params.put("log", readFromFile());
}
JSONObject jsonObject = new JSONObject(params);
if (picArray != null && picArray.length() > 0) {
try {
jsonObject.put("pic", picArray);
} catch (JSONException e) {
e.printStackTrace();
}
}
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
jsonObject.toString());
Utils.log("=======postBody" + jsonObject.toString());
sendSuggestion(body, true);
}
private void sendSuggestion(final RequestBody body, boolean isCheck) {
TokenUtils.getToken(SuggestionActivity.this, isCheck).flatMap(new Func1<String, Observable<ResponseBody>>() {
@Override
public Observable<ResponseBody> call(String token) {
return RetrofitManager.getApi().postSuggestion(body, token);
}
}).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new JSONObjectResponse(){
@Override
public void onResponse(JSONObject response) {
if (postDialog != null) {
postDialog.dismiss();
}
Utils.log("======onResponse" + response.toString());
if (response.length() != 0) {
try {
if ("ok".equals(response.getString("status"))) {
toast("感谢您的反馈!");
setResult(0x122);
finish();
} else {
toast("提交失败,请稍后尝试!");
}
} catch (JSONException e) {
e.printStackTrace();
}
} else {
toast("提交失败,请稍后尝试!");
}
}
@Override
public void onError(Throwable e) {
super.onError(e);
Utils.log("======ERROR" + e.toString());
}
@Override
public void onFailure(HttpException e) {
try {
if (e != null) {
String string = e.response().errorBody().string();
Utils.log("===========onFailure" + string);
}
} catch (IOException e1) {
e1.printStackTrace();
}
if (e != null && e.code() == 401) {
sendSuggestion(body, false);
return;
} else {
if (postDialog != null) {
postDialog.dismiss();
}
toast("提交失败,请检查网络状态");
}
}
});
}
private void showSelectDialog() {
View view = View.inflate(this, R.layout.dialog_suggest_select_game, null);
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.dialog_suggest_game_rv);
TextView back = (TextView) view.findViewById(R.id.dialog_suggest_game_back);
ProgressBar pb = (ProgressBar) view.findViewById(R.id.dialog_suggest_game_load);
recyclerView.setLayoutManager(new GridLayoutManager(this, 4));
recyclerView.setAdapter(new SuggestSelectGameAdapter(this, pb));
selectGameDialog = new Dialog(this);
selectGameDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
selectGameDialog.setCanceledOnTouchOutside(false);
selectGameDialog.setContentView(view);
selectGameDialog.show();
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectGameDialog.cancel();
}
});
}
@Override
public void onType(int type) {
curType = type;
mSuggestPicRv.postDelayed(new Runnable() {
@Override
public void run() {
//将ScrollView滚动到底
mScrollView.fullScroll(View.FOCUS_DOWN);
}
}, 100);
initSuggest(type);
}
private void initSuggest(int type) {
switch (type) {
case 1:
mSuggestContentEt.setHint("请详细描述你遇到的问题... \n ↓↓你还可以上传截图");
mSuggestNewsLinkLl.setVisibility(View.GONE);
mSuggestContentEt.setVisibility(View.VISIBLE);
mSuggestGameLl.setVisibility(View.GONE);
break;
case 2:
mSuggestContentEt.setHint("请详细描述你的建议... \n ↓↓你还可以上传截图");
mSuggestNewsLinkLl.setVisibility(View.GONE);
mSuggestContentEt.setVisibility(View.VISIBLE);
mSuggestGameLl.setVisibility(View.GONE);
break;
case 3:
mSuggestContentEt.setHint("请详细描述闪退之前你所进行的操作... \n ↓↓你还可以上传截图");
mSuggestNewsLinkLl.setVisibility(View.GONE);
mSuggestContentEt.setVisibility(View.VISIBLE);
mSuggestGameLl.setVisibility(View.GONE);
break;
case 4:
mSuggestContentEt.setHint("请写上游戏名字,以及具体遇到的问题... \n ↓↓你还可以上传截图");
mSuggestNewsLinkLl.setVisibility(View.GONE);
mSuggestContentEt.setVisibility(View.VISIBLE);
mSuggestGameLl.setVisibility(View.GONE);
break;
case 5:
mSuggestNewsLinkLl.setVisibility(View.GONE);
mSuggestGameLl.setVisibility(View.VISIBLE);
mSuggestContentEt.setVisibility(View.GONE);
break;
case 6:
mSuggestContentEt.setHint("简单介绍文章内容,然后在下面填写文章链接... \n ↓↓你还可以上传截图");
mSuggestNewsLinkLl.setVisibility(View.VISIBLE);
mSuggestContentEt.setVisibility(View.VISIBLE);
mSuggestGameLl.setVisibility(View.GONE);
break;
}
}
@Override
public void loadDone(Object obj) {
super.loadDone(obj);
if (selectGameDialog != null) {
selectGameDialog.cancel();
}
mSuggestGameLl.setVisibility(View.GONE);
mSuggestContentEt.setVisibility(View.VISIBLE);
InstallGameEntity entity = (InstallGameEntity) obj;
mSuggestContentEt.setText("推荐收录:" + entity.getGameName() + "(" + entity.getPackageName() + ", " + entity.getGameVersion() + ")");
}
public String readFromFile(){
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
File file = new File(getExternalFilesDir(null).getPath() + "/log");
if (file.isFile()) return "检测log文件夹是文件";
File[] files = file.listFiles();
if (files == null || files.length == 0) return "log文件夹为空" + file.getPath();
File targetFile = files[files.length - 1];
try{
if(!targetFile.exists()){
targetFile.createNewFile();
return "No File error ";
}else{
InputStream in = new BufferedInputStream(new FileInputStream(targetFile));
BufferedReader br= new BufferedReader(new InputStreamReader(in, "UTF-8"));
String tmp;
StringBuffer string = new StringBuffer();
while((tmp=br.readLine())!=null){
string.append(tmp);
}
br.close();
in.close();
return string.toString();
}
} catch (Exception e) {
return e.toString();
}
}else{
return "SD Card error";
}
}
private boolean isEmailAddress(String email) {
Pattern p = Pattern
.compile("^\\s*\\w+(?:\\.{0,1}[\\w-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\\.[a-zA-Z]+\\s*$");
Matcher m = p.matcher(email);
return m.matches();
}
}

View File

@ -1,9 +1,13 @@
package com.gh.gamecenter;
import android.app.Dialog;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.Animatable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.support.v4.view.PagerAdapter;
@ -11,23 +15,37 @@ import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.facebook.common.executors.CallerThreadExecutor;
import com.facebook.common.references.CloseableReference;
import com.facebook.datasource.DataSource;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.controller.BaseControllerListener;
import com.facebook.drawee.drawable.ScalingUtils;
import com.facebook.drawee.interfaces.DraweeController;
import com.facebook.imagepipeline.core.ImagePipeline;
import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber;
import com.facebook.imagepipeline.image.CloseableImage;
import com.facebook.imagepipeline.image.ImageInfo;
import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequestBuilder;
import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
import com.gh.base.BaseActivity;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.MessageShareUtils;
import com.gh.common.util.Utils;
import com.gh.common.view.Gh_RelativeLayout;
import com.gh.common.view.Gh_RelativeLayout.OnSingleTapListener;
import com.gh.common.view.Gh_ViewPager;
import com.gh.common.view.ZoomSimpleDraweeView;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
@ -188,11 +206,110 @@ public class ViewImageActivity extends BaseActivity implements OnPageChangeListe
}
});
//长按
imageView.setOnLongClickListener(new ZoomSimpleDraweeView.setOnLongClickListener() {
@Override
public void onLongClick() {
final Dialog dialog = new Dialog(ViewImageActivity.this);
LinearLayout container = new LinearLayout(ViewImageActivity.this);
container.setOrientation(LinearLayout.VERTICAL);
container.setBackgroundColor(Color.WHITE);
final TextView reportTv = new TextView(ViewImageActivity.this);
reportTv.setPadding(DisplayUtils.dip2px(ViewImageActivity.this, 20), DisplayUtils.dip2px(ViewImageActivity.this, 12),
0, DisplayUtils.dip2px(ViewImageActivity.this, 12));
reportTv.setText("保存图片");
reportTv.setTextSize(17);
reportTv.setTextColor(ViewImageActivity.this.getResources().getColor(R.color.title));
reportTv.setBackgroundResource(R.drawable.textview_white_style);
int widthPixels = ViewImageActivity.this.getResources().getDisplayMetrics().widthPixels;
reportTv.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9)/10,
LinearLayout.LayoutParams.WRAP_CONTENT));
container.addView(reportTv);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(container);
dialog.show();
reportTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
findImageBM();
dialog.cancel();
}
});
}
});
view.setTag(position);
container.addView(view);
return view;
}
private void findImageBM() {
String key = urls.get(viewimage_vp_show.getCurrentItem());
String hdKey = "http://image.ghzhushou.com/pic/hq" + key.substring(key.lastIndexOf("/"));
ImagePipeline imagePipeline = Fresco.getImagePipeline();
String curUrl = null;
if (imagePipeline.isInBitmapMemoryCache(Uri.parse(hdKey))) {
curUrl = hdKey;
} else if (imagePipeline.isInBitmapMemoryCache(Uri.parse(key))){
curUrl = key;
} else {
return;
}
ImageRequest imageRequest = ImageRequestBuilder
.newBuilderWithSource(Uri.parse(key))
.setProgressiveRenderingEnabled(true)
.build();
DataSource<CloseableReference<CloseableImage>>
dataSource = imagePipeline.fetchDecodedImage(imageRequest, ViewImageActivity.this);
final String finalCurUrl = curUrl;
dataSource.subscribe(new BaseBitmapDataSubscriber() {
@Override
protected void onNewResultImpl(Bitmap bitmap) {
saveImage(bitmap, finalCurUrl);
}
@Override
protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
}
}, CallerThreadExecutor.getInstance());
}
private void saveImage(Bitmap bitmap, String curUrl) {
String fileName = curUrl.substring(curUrl.lastIndexOf("/"));
String savePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/ghzhushou/";
try {
File file = new File(savePath);
if (!file.exists()) {
file.mkdirs();
}
File f = new File(savePath, fileName);
if (f.exists()) {
f.delete();
}
FileOutputStream out = new FileOutputStream(f);
bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
out.flush();
out.close();
Utils.log("========保存成功");
MessageShareUtils.refreshImage(new File(savePath), ViewImageActivity.this);
} catch (IOException e) {
Utils.log("========保存失败" + e.toString());
System.out.println(e);
}
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;

View File

@ -0,0 +1,172 @@
package com.gh.gamecenter;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
import com.gh.base.BaseActivity;
import com.gh.common.util.DisplayUtils;
import com.gh.gamecenter.adapter.VoteAdapter;
import butterknife.BindView;
/**
* Created by khy on 2017/4/11.
* 求版本投票页面
*/
public class VoteActivity extends BaseActivity {
@BindView(R.id.vote_rv)
RecyclerView mVoteRv;
@BindView(R.id.vote_refresh)
SwipeRefreshLayout mVoteRefresh;
@BindView(R.id.vote_loading)
ProgressBarCircularIndeterminate mVoteLoading;
@BindView(R.id.reuse_no_connection)
LinearLayout mNoConnection;
@BindView(R.id.vote_add_tv)
TextView mAddTv;
private ImageView addVote;
private VoteAdapter mAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String gameName = getIntent().getExtras().getString("gameName");
View view = View.inflate(this, R.layout.activity_vote, null);
// 添加添加图标
addVote = new ImageView(this);
addVote.setImageResource(R.drawable.add_vote_icon);
addVote.setPadding(DisplayUtils.dip2px(this, 13), DisplayUtils.dip2px(this, 15)
, DisplayUtils.dip2px(this, 15), DisplayUtils.dip2px(this, 15));
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
DisplayUtils.dip2px(this, 48), DisplayUtils.dip2px(this, 48));
params.addRule(RelativeLayout.CENTER_VERTICAL);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
RelativeLayout reuse_actionbar = (RelativeLayout) view.findViewById(
R.id.reuse_actionbar);
reuse_actionbar.addView(addVote, params);
init(view, gameName + " - 求版本");
addVote.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showAddVoteDialog();
}
});
mVoteRv.setLayoutManager(new LinearLayoutManager(this));
mAdapter = new VoteAdapter(this);
mVoteRv.setAdapter(mAdapter);
mAddTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showAddVoteDialog();
}
});
}
private void showAddVoteDialog() {
final Dialog dialog = new Dialog(VoteActivity.this);
View view = View.inflate(VoteActivity.this, R.layout.dialog_modify_nickname, null);
TextView title = (TextView) view.findViewById(R.id.dialog_nickname_title);
title.setText("输入选项名字");
final EditText input = (EditText) view.findViewById(R.id.dialog_nickname_input);
input.setHint("");
input.setSelection(input.getText().length());
input.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
String nickname = input.getText().toString().trim();
if (TextUtils.isEmpty(nickname)) {
Toast.makeText(VoteActivity.this, "请输入名字", Toast.LENGTH_SHORT).show();
return true;
}
dialog.dismiss();
return true;
}
return false;
}
});
// 取消按钮
TextView cancel = (TextView) view.findViewById(R.id.dialog_nickname_cannel);
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
// 确定按钮
TextView confirm = (TextView) view.findViewById(R.id.dialog_nickname_confirm);
confirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String nickname = input.getText().toString().trim();
if (TextUtils.isEmpty(nickname)) {
Toast.makeText(VoteActivity.this, "请输入名字", Toast.LENGTH_SHORT).show();
return;
}
dialog.dismiss();
}
});
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
InputMethodManager imm = (InputMethodManager) VoteActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
}
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(view);
dialog.show();
new Thread() {
@Override
public void run() {
try {
sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
InputMethodManager imm = (InputMethodManager) VoteActivity.this
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(input, InputMethodManager.SHOW_FORCED);
}
}.start();
}
}

View File

@ -117,9 +117,9 @@ public class WebActivity extends BaseActivity {
@Override
public void onProgressChanged(WebView view, int newProgress) {
progressBar.setProgress(newProgress);
if (newProgress == 100 && newsId != null){
if (newProgress == 100){
progressBar.setVisibility(View.GONE);
if (newsBottom.getVisibility() == View.GONE) {
if (newsBottom.getVisibility() == View.GONE && newsId != null) {
newsBottom.setVisibility(View.VISIBLE);
}
} else {

View File

@ -18,7 +18,7 @@ import android.widget.TextView;
import com.gh.common.util.BitmapUtils;
import com.gh.common.util.PackageUtils;
import com.gh.common.view.CardLinearLayout;
import com.gh.common.util.Utils;
import com.gh.gamecenter.CleanApkActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.KcSelectGameViewHolder;
@ -205,19 +205,19 @@ public class CleanApkAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
final InstallGameEntity gameEntity = mApkList.get(position);
if (viewHolder instanceof KcSelectGameViewHolder) {
final KcSelectGameViewHolder holder = (KcSelectGameViewHolder) viewHolder;
// 第一个
if (position == 0) {
((CardLinearLayout) holder.itemView).setmTop(cardMargin);
} else {
((CardLinearLayout) holder.itemView).setmTop(0);
}
// 最后一个
if (position == mApkList.size() - 1) {
((CardLinearLayout) holder.itemView).setBottom(true);
} else {
((CardLinearLayout) holder.itemView).setBottom(false);
}
// // 第一个
// if (position == 0) {
// ((CardLinearLayout) holder.itemView).setmTop(cardMargin);
// } else {
// ((CardLinearLayout) holder.itemView).setmTop(0);
// }
//
// // 最后一个
// if (position == mApkList.size() - 1) {
// ((CardLinearLayout) holder.itemView).setBottom(true);
// } else {
// ((CardLinearLayout) holder.itemView).setBottom(false);
// }
double size = (((float)gameEntity.getGameSize()/1024)/1024);
DecimalFormat df = new DecimalFormat("#.00");
@ -233,6 +233,7 @@ public class CleanApkAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
holder.selectCB.setChecked(false);
}
Utils.log(gameEntity.getGamePath() + "=========" + gameEntity.getGameName());
holder.gameNameAndSize.setText(gameEntity.getGameName());
holder.gameDes.setText("版本V" + gameEntity.getGameVersion() + " | " + sizeName);
holder.gameDes.setTextColor(mContext.getResources().getColor(R.color.content));

View File

@ -0,0 +1,259 @@
package com.gh.gamecenter.adapter;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.gh.common.constant.Config;
import com.gh.common.constant.ItemViewType;
import com.gh.common.util.CommentUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.PostCommentUtils;
import com.gh.common.util.Utils;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.CommentViewHolder;
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
import com.gh.gamecenter.db.CommentDao;
import com.gh.gamecenter.db.VoteDao;
import com.gh.gamecenter.db.info.VoteInfo;
import com.gh.gamecenter.entity.CommentEntity;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import retrofit2.adapter.rxjava.HttpException;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
/**
* Created by khy on 2017/3/22.
*/
public class CommentDetailAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context mContext;
private SharedPreferences sp;
private List<CommentEntity> mCommentList;
private VoteDao mVoteDao;
private CommentDao mCommentDao;
private String userName; //用户名
private String userIcon; //用户icon
private String commentId;
private boolean isOver;
private boolean isLoading;
private boolean isNetworkError;
public CommentDetailAdapter(Context context, String commentId) {
this.mContext = context;
this.commentId = commentId;
mVoteDao = new VoteDao(context);
mCommentDao = new CommentDao(context);
sp = context.getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
userName = sp.getString("user_name", null);
userIcon = sp.getString("user_icon", null);
mCommentList = new ArrayList<>();
loadData(0);
}
public void loadData(int offset) {
isLoading = true;
RetrofitManager.getComment()
.getCommentTrace(commentId, 20, offset)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<List<CommentEntity>>(){
@Override
public void onResponse(List<CommentEntity> response) {
super.onResponse(response);
mCommentList.addAll(response);
if (response.size() < 20) {
isOver = true;
}
isLoading = false;
notifyItemRangeChanged(0, getItemCount() - 1);
}
@Override
public void onFailure(HttpException e) {
super.onFailure(e);
Utils.toast(mContext, "评论加载失败, 请检查网络设置");
isNetworkError = true;
isLoading = false;
notifyItemChanged(getItemCount() - 1);
}
});
}
@Override
public int getItemViewType(int position) {
if (position == getItemCount() - 1) {
return ItemViewType.LOADING;
}
return 100;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == ItemViewType.LOADING) {
View view = LayoutInflater.from(mContext).inflate(R.layout.refresh_footerview, parent, false);
return new FooterViewHolder(view);
} else {
View view = LayoutInflater.from(mContext).inflate(R.layout.comment_item, parent, false);
return new CommentViewHolder(view);
}
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof CommentViewHolder) {
initCommentViewHolder((CommentViewHolder) holder, position);
} else if (holder instanceof FooterViewHolder) {
initFooterViewHolder((FooterViewHolder) holder);
}
}
private void initFooterViewHolder(FooterViewHolder holder) {
if(isNetworkError) {
holder.loading.setVisibility(View.GONE);
holder.hint.setText("网络错误,点击重试!");
}else if (!isOver) {
holder.hint.setText("加载中...");
holder.loading.setVisibility(View.VISIBLE);
} else if (mCommentList.size() == 0) {
holder.loading.setVisibility(View.GONE);
holder.hint.setText("目前还没有评论");
} else {
holder.hint.setText("没有更多评论啦");
holder.loading.setVisibility(View.GONE);
}
}
private void initCommentViewHolder(final CommentViewHolder holder, int position) {
final CommentEntity commentEntity = mCommentList.get(position);
ImageUtils.display(holder.commentUserIconDv, commentEntity.getUser().getIcon());
holder.commentLikeCountTv.setTextColor(mContext.getResources().getColor(R.color.hint));
holder.commentLikeIv.setImageResource(R.drawable.ic_like_unselect);
if (commentEntity.getVote() == 0) {
holder.commentLikeCountTv.setVisibility(View.GONE);
} else { // 检查是否已点赞
if (mVoteDao.isVote(commentEntity.getId()) && commentEntity.getVote() >= 1) {
holder.commentLikeCountTv.setTextColor(mContext.getResources().getColor(R.color.theme));
holder.commentLikeIv.setImageResource(R.drawable.ic_like_select);
}
holder.commentLikeCountTv.setVisibility(View.VISIBLE);
holder.commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
}
//检查是否是自身评论
if (userName != null && userIcon != null && !userIcon.isEmpty()&&
!userIcon.isEmpty() && mCommentDao.isMyComment(commentEntity.getId())){
holder.commentUserNameTv.setText(sp.getString("user_name", null));
ImageUtils.display(holder.commentUserIconDv, sp.getString("user_icon", null));
} else {
holder.commentUserNameTv.setText(commentEntity.getUser().getName());
if(commentEntity.getUser().getIcon().isEmpty()) {
holder.commentUserIconDv.setImageURI(Uri.parse("res:///" + R.drawable.user_default_icon_comment));
} else {
ImageUtils.display(holder.commentUserIconDv, commentEntity.getUser().getIcon());
}
}
CommentUtils.setCommentTime(holder.commentTimeTv, commentEntity.getTime());
if (commentEntity.getParent() != null) {
holder.commentContentTv.setText("@"+ commentEntity.getParent().getUser().getName() + ": " + commentEntity.getContent());
} else {
holder.commentContentTv.setText(commentEntity.getContent());
}
holder.commentLikeIv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (holder.commentLikeCountTv.getCurrentTextColor() == mContext.getResources().getColor(R.color.theme)) {
Utils.toast(mContext, "已经点过赞啦!");
return;
}
commentEntity.setVote(commentEntity.getVote() + 1);
holder.commentLikeCountTv.setTextColor(mContext.getResources().getColor(R.color.theme));
holder.commentLikeIv.setImageResource(R.drawable.ic_like_select);
holder.commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
holder.commentLikeCountTv.setVisibility(View.VISIBLE);
PostCommentUtils.addCommentVoto(mContext, commentEntity.getId(), true,
new PostCommentUtils.PostCommentListener() {
@Override
public void postSucced(JSONObject response) {
mVoteDao.add(new VoteInfo(commentEntity.getId()));
}
@Override
public void postFailed(Throwable error) {
commentEntity.setVote(commentEntity.getVote() - 1);
holder.commentLikeCountTv.setTextColor(mContext.getResources().getColor(R.color.hint));
holder.commentLikeIv.setImageResource(R.drawable.ic_like_unselect);
holder.commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
if (commentEntity.getVote() == 0) {
holder.commentLikeCountTv.setVisibility(View.GONE);
} else {
holder.commentLikeCountTv.setVisibility(View.VISIBLE);
}
if (error instanceof HttpException) {
HttpException exception = (HttpException) error;
if (exception.code() == 403) {
try {
if (new JSONObject(exception.response().errorBody().string())
.getString("detail").equals("voted")) {
Utils.toast(mContext, "已经点过赞啦!");
}
} catch (Exception ex) {
ex.printStackTrace();
}
return;
}
}
Utils.toast(mContext, "网络异常,点赞失败");
}
});
}
});
}
@Override
public int getItemCount() {
return mCommentList.size() + 1;
}
public boolean isOver() {
return isOver;
}
public boolean isLoading() {
return isLoading;
}
}

View File

@ -2,16 +2,9 @@ package com.gh.gamecenter.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.*;
import android.widget.Toast;
import com.gh.common.util.DataCollectionUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.GameUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.*;
import com.gh.gamecenter.ConcernActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.ConcernViewHolder;
@ -21,18 +14,12 @@ import com.gh.gamecenter.listener.OnCallBackListener;
import com.gh.gamecenter.manager.ConcernManager;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import java.util.*;
/**
* Created by LGT on 2016/9/20.
*

View File

@ -15,7 +15,6 @@ 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.view.CardLinearLayout;
import com.gh.gamecenter.NewsSearchActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.GameNewsSearchViewHolder;
@ -47,7 +46,7 @@ public class GameNewsAdapter extends RecyclerView.Adapter {
private RecyclerView game_news_list;
private ArrayList<NewsEntity> newsList;
private ArrayList<String> typeList;
private List<String> typeList;
private String gameId;
private String newsType;
@ -59,7 +58,7 @@ public class GameNewsAdapter extends RecyclerView.Adapter {
private boolean isOpenKeyBoard;
public GameNewsAdapter(Context context,
ArrayList<String> tList,
List<String> tList,
RecyclerView game_news_list,
String id,
String type,
@ -181,20 +180,10 @@ public class GameNewsAdapter extends RecyclerView.Adapter {
// 第一个
if (position - 2 == 0) {
viewHolder.line.setVisibility(View.GONE);
// ((CardLinearLayout) holder.itemView).setmTop(DisplayUtils.dip2px(context, 8));
} else {
viewHolder.line.setVisibility(View.VISIBLE);
((CardLinearLayout) holder.itemView).setmTop(0);
}
// 最后一个
if (position - 1 == newsList.size()) {
((CardLinearLayout) viewHolder.itemView).setBottom(true);
((CardLinearLayout) viewHolder.itemView).setmBottom(DisplayUtils.dip2px(context, 8));
} else {
((CardLinearLayout) viewHolder.itemView).setBottom(false);
((CardLinearLayout) viewHolder.itemView).setmBottom(0);
}
final NewsEntity newsEntity = newsList.get(position - 2);
viewHolder.type.setBackgroundResource(NewsUtils.getDrawableIdByType(newsEntity.getType()));

View File

@ -12,7 +12,7 @@ import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.GameNewsTypeViewHolder;
import com.gh.gamecenter.eventbus.EBTypeChange;
import java.util.ArrayList;
import java.util.List;
import de.greenrobot.event.EventBus;
@ -21,13 +21,13 @@ import de.greenrobot.event.EventBus;
*/
public class GameNewsTypeListAdapter extends RecyclerView.Adapter<GameNewsTypeViewHolder> {
private ArrayList<String> typeList;
private List<String> typeList;
private String newsType;
private int currentPosition;
public GameNewsTypeListAdapter(ArrayList<String> tList, String type) {
public GameNewsTypeListAdapter(List<String> tList, String type) {
typeList = tList;

View File

@ -0,0 +1,478 @@
package com.gh.gamecenter.adapter;
import android.content.Context;
import android.support.v4.util.ArrayMap;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.gh.common.constant.ItemViewType;
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.GameUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.KaiFuUtils;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.KaiFuActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
import com.gh.gamecenter.adapter.viewholder.GameNormalViewHolder;
import com.gh.gamecenter.adapter.viewholder.GameTestViewHolder;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.listener.OnCallBackListener;
import com.gh.gamecenter.manager.GameManager;
import com.gh.gamecenter.retrofit.JSONObjectResponse;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import retrofit2.adapter.rxjava.HttpException;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
/**
* Created by khy on 2017/3/16.
*/
public class KaiFuAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context;
private OnCallBackListener listener;
private OnScrollToKaiFuIndex scrollToKaiFuIndex;
private List<GameEntity> subjectList;
private ArrayMap<String, ArrayList<Integer>> locationMap;
private String kaifuType;
private int kaifuIndex = 0; // 开服零界点
private int initOffset;
private int loadCountTop; // 记录加载数量 上
private int loadCountBottom;// 记录加载数量 下
private boolean isRemoveBottom;
private boolean isRemoveTop;
private boolean isNetworkError;
private boolean isLoadedBottom;
private boolean isLoadedTop;
public KaiFuAdapter(KaiFuActivity activity, String kaifuType) {
this.context = activity;
this.listener = activity;
this.kaifuType = kaifuType;
this.scrollToKaiFuIndex = activity;
locationMap = new ArrayMap<>();
subjectList = new ArrayList<>();
isLoadedTop = false;
isLoadedBottom = false;
isNetworkError = false;
kaifuIndex = 0;
loadCountBottom = 0;
loadCountTop = 0;
if ("全部".equals(kaifuType)) {
this.kaifuType = "all";
}
initKaiFuOffset();
}
public void initKaiFuOffset() {
RetrofitManager.getApi()
.getKaiFuOffset(kaifuType)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new JSONObjectResponse(){
@Override
public void onResponse(JSONObject response) {
super.onResponse(response);
JSONObject jsonObject = response;
int offset = 0;
try {
offset = jsonObject.getInt("offset");
} catch (JSONException e) {
e.printStackTrace();
}
initOffset = offset;
listener.loadDone(offset);
initListBottom(offset);
}
@Override
public void onFailure(HttpException e) {
super.onFailure(e);
listener.loadError();
}
});
}
public void initListBottom(final int offset) {
isLoadedBottom = false;
RetrofitManager.getApi().getKaiFuData(kaifuType, offset, 20)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<List<GameEntity>>() {
@Override
public void onResponse(List<GameEntity> response) {
GameManager manager = new GameManager(context);
if (response.size() != 0) {
if (offset == initOffset) {
long curTime = System.currentTimeMillis()/1000;
for (int i = 0; i < response.size(); i++) {
long time = response.get(i).getServerEntity().getTime();
long l = time - curTime;
if (l > 0) {
kaifuIndex = i + 1;
}
}
}
for (GameEntity entity : response) {
// 黄壮华 初始化游戏状态 修改2015/8/15
entity.setEntryMap(DownloadManager.getInstance(context).getEntryMap(entity.getName()));
manager.addOrUpdate(entity.getApk(), entity.getId(), entity.getName());
}
subjectList.addAll(response);
notifyItemRangeInserted(getItemCount() - 1 - response.size(), response.size());
if (offset == initOffset) {
isLoadedTop = true; //首次加载 手动设置下拉加载完成
loadCountTop = response.size();//首次加载 下拉加载减去初始加载值 获取正确偏移量
subjectList.add(kaifuIndex, new GameEntity()); // 添加一个空的实体当做 零界点ITEM
}
if (response.size() < 20) {
isRemoveBottom = true;
notifyItemChanged(getItemCount() - 1);
}
loadCountBottom = loadCountBottom + response.size();
} else {
isRemoveBottom = true;
notifyDataSetChanged();
}
initLocationMap();
if (listener != null) {
listener.loadDone();
}
isLoadedBottom = true;
if (offset == initOffset) { //定位到开服零界点
scrollToKaiFuIndex.onScroll(kaifuIndex);
}
}
@Override
public void onFailure(HttpException e) {
if (offset == initOffset){
if (listener != null) {
listener.loadError();
}
}else {
Toast.makeText(context, "加载失败,请检查网络状态", Toast.LENGTH_SHORT).show();
isNetworkError = true;
notifyDataSetChanged();
}
}
});
}
public void initListTop(final int offset, int limit) {
isLoadedTop = false;
RetrofitManager.getApi().getKaiFuData(kaifuType, offset, limit)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<List<GameEntity>>() {
@Override
public void onResponse(List<GameEntity> response) {
GameManager manager = new GameManager(context);
if (response.size() != 0) {
for (GameEntity entity : response) {
// 黄壮华 初始化游戏状态 修改2015/8/15
entity.setEntryMap(DownloadManager.getInstance(context).getEntryMap(entity.getName()));
manager.addOrUpdate(entity.getApk(), entity.getId(), entity.getName());
}
subjectList.addAll(0, response);
notifyItemRangeInserted(0, response.size());
if (response.size() < 20 || offset == 0) {
isRemoveTop = true;
notifyItemChanged(getItemCount() - 1);
}
loadCountTop = loadCountTop + response.size();
} else {
isRemoveTop = true;
notifyDataSetChanged();
}
initLocationMap();
isLoadedTop = true;
}
@Override
public void onFailure(HttpException e) {
if (offset == initOffset){
if (listener != null) {
listener.loadError();
}
}else {
Toast.makeText(context, "加载失败,请检查网络状态", Toast.LENGTH_SHORT).show();
isNetworkError = true;
notifyDataSetChanged();
}
}
});
}
private void initLocationMap() {
ArrayList<Integer> list;
GameEntity gameEntity;
for (int i = 0, size = subjectList.size(); i < size; i++) {
int index = 0;
if (initOffset != 0) {
index ++;
}
gameEntity = subjectList.get(i);
if (gameEntity.getApk() != null && gameEntity.getApk().size() != 0) {
for (ApkEntity apkEntity : gameEntity.getApk()) {
list = locationMap.get(apkEntity.getPackageName());
if (list == null) {
list = new ArrayList<>();
locationMap.put(apkEntity.getPackageName(), list);
}
list.add(i + index);
}
}
}
}
@Override
public int getItemCount() {
if (subjectList.size() < 1) {
return 0;
}
if (initOffset != 0) {
return subjectList.size() + 2;
}
return subjectList.size() + 1;
}
@Override
public int getItemViewType(int position) {
int index = 0;
if (initOffset != 0) {
index ++;
}
if (position == getItemCount() - 1 || (position == 0 && initOffset != 0)) {
return ItemViewType.LOADING;
}
if (TextUtils.isEmpty(subjectList.get(position- index).getId())) {
return 100;
} else {
return ItemViewType.GAME_TEST;
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
if (viewType == ItemViewType.LOADING){
View view = LayoutInflater.from(viewGroup.getContext()).inflate(
R.layout.refresh_footerview, viewGroup, false);
return new FooterViewHolder(view);
} else if (viewType == ItemViewType.GAME_TEST) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(
R.layout.game_test_item, viewGroup, false);
return new GameTestViewHolder(view);
} else if (viewType == ItemViewType.GAME_NORMAL) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(
R.layout.game_normal_item, viewGroup, false);
return new GameNormalViewHolder(view);
} else if (viewType == 100) {
TextView textView = new TextView(context);
textView.setText("↓当前开服 · 即将开服↑");
textView.setTextColor(context.getResources().getColor(R.color.hint));
textView.setTextSize(13);
textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT
, DisplayUtils.dip2px(context, 42)));
textView.setGravity(Gravity.CENTER);
return new KaiFuIndexViewHolder(textView);
}
return null;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
int index = 0;
if (initOffset != 0) {
index ++;
}
if (viewHolder instanceof GameTestViewHolder) {
initGameTestViewHolder((GameTestViewHolder) viewHolder, position - index);
} else if (viewHolder instanceof FooterViewHolder) {
initFooterViewHolder((FooterViewHolder) viewHolder, position);
}
}
private void initFooterViewHolder(FooterViewHolder viewHolder, final int position) {
if (isNetworkError) {
viewHolder.loading.setVisibility(View.GONE);
viewHolder.hint.setText("加载失败,点击重试");
viewHolder.itemView.setClickable(true);
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
isNetworkError = false;
notifyDataSetChanged();
if (position == getItemCount() - 1) {
initListBottom(kaifuIndex + loadCountBottom);
} else {
int offset = kaifuIndex - loadCountTop;
int limit = 20;
if (offset < 0) {
limit = limit + offset;
offset = 0;
}
initListTop(offset, limit);
}
}
});
} else if ((isRemoveBottom && position == getItemCount() - 1)
|| (isRemoveTop && position == 0)) {
viewHolder.loading.setVisibility(View.GONE);
viewHolder.hint.setText("加载完毕");
viewHolder.itemView.setClickable(false);
viewHolder.lineLeft.setVisibility(View.VISIBLE);
viewHolder.lineRight.setVisibility(View.VISIBLE);
} else {
viewHolder.loading.setVisibility(View.VISIBLE);
viewHolder.hint.setText("加载中...");
viewHolder.itemView.setClickable(false);
}
}
private void initGameTestViewHolder(final GameTestViewHolder holder, int position) {
holder.gameOrder.setVisibility(View.GONE);
final GameEntity gameEntity = subjectList.get(position);
ImageUtils.display(holder.gameThumb, gameEntity.getIcon());
holder.gameName.setText(gameEntity.getName());
if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) {
holder.gameDes.setText(gameEntity.getBrief());
} else {
holder.gameDes.setText(String.format("%s %s", gameEntity.getApk().get(0).getSize(), gameEntity.getBrief()));
}
KaiFuUtils.setKaiFuTime( holder.gameTestType, gameEntity.getServerEntity().getTime());
String type = gameEntity.getServerEntity().getType();
if ("不删档内测".equals(type) || "删档内测".equals(type)) {
KaiFuUtils.setKaiFuType(holder.gameTestTime, gameEntity.getServerEntity().getType());
} else if ("公测".equals(type)){
String note = gameEntity.getServerEntity().getNote();
if (TextUtils.isEmpty(note)) {
KaiFuUtils.setKaiFuType(holder.gameTestTime, gameEntity.getServerEntity().getType());
} else {
KaiFuUtils.setKaiFuType(holder.gameTestTime, gameEntity.getServerEntity().getType() + "" + note);
}
} else {
KaiFuUtils.setKaiFuType(holder.gameTestTime, gameEntity.getServerEntity().getNote());
}
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Map<String, Object> kv = new HashMap<>();
kv.put("名字", gameEntity.getName());
kv.put("位置", String.valueOf(holder.getPosition() + 1));
DataUtils.onEvent(context, "点击", "开服表", kv);
DataCollectionUtils.uploadClick(context, "列表", "开服表", gameEntity.getName());
GameUtils.startGameDetailActivity(context, gameEntity, "主页-游戏" + "+(" + "开服表" + "[" + (holder.getPosition()) + "])");
}
});
DownloadItemUtils.setOnClickListener(context,
holder.gameDownloadBtn, gameEntity, position,
KaiFuAdapter.this, "主页游戏" + "+(" + "开服表" + "[" + (holder.getPosition()) + "])", "开服表 :" + gameEntity.getName());
DownloadItemUtils.updateItem(context, gameEntity, holder, true);
}
public List<GameEntity> getSubjectList() {
return subjectList;
}
public ArrayMap<String, ArrayList<Integer>> getLocationMap() {
return locationMap;
}
public boolean isLoadedBottom(){
return isLoadedBottom;
}
public boolean isLoadedTop(){
return isLoadedTop;
}
public int loadCountTop() {
return loadCountTop;
}
public int loadCountBottom() {
return loadCountBottom;
}
public class KaiFuIndexViewHolder extends RecyclerView.ViewHolder {
public KaiFuIndexViewHolder(View itemView) {
super(itemView);
}
}
public interface OnScrollToKaiFuIndex {
void onScroll(int scrollPosition);
}
}

View File

@ -0,0 +1,130 @@
package com.gh.gamecenter.adapter;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gh.common.util.DisplayUtils;
import com.gh.gamecenter.KaiFuActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.StrategyDialogViewHolder;
import com.gh.gamecenter.db.info.ConcernInfo;
import com.gh.gamecenter.manager.ConcernManager;
import java.util.List;
/**
* Created by khy on 2016/12/5.
*/
public class KaiFuDialogAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context mContext;
private OnKaiFuDialogCallBackListener callBackListener;
private List<ConcernInfo> mConcernGame;
private int mSelectPosition;
private String[] arrKaiFuTag = {"全部", "删档内测", "不删档内测" , "公测", "新服"};
public KaiFuDialogAdapter(KaiFuActivity kaiFuActivity, int selectPosition) {
this.mContext = kaiFuActivity;
this.mSelectPosition = selectPosition;
this.callBackListener = kaiFuActivity;
ConcernManager concernManager = new ConcernManager(kaiFuActivity);
List<ConcernInfo> concernGame = concernManager.getConcernGame();
for (int i = 0; i < concernGame.size(); i++) {
if ("5618b86e8ab49e17088b4575".equals(concernGame.get(i).getId())) {
concernGame.remove(i);
}
}
mConcernGame = concernGame;
}
@Override
public int getItemViewType(int position) {
if (!mConcernGame.isEmpty() && position == 5) {
return 0;
}
return 1;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == 0) {
TextView textView = new TextView(mContext);
textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT
, DisplayUtils.dip2px(mContext, 25)));
textView.setText("以下是已关注的游戏");
textView.setBackgroundColor(Color.parseColor("#ededed"));
textView.setGravity(Gravity.CENTER);
return new TitleViewHolder(textView);
} else {
View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_strategy_item, parent, false);
return new StrategyDialogViewHolder(view);
}
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
if (holder instanceof StrategyDialogViewHolder) {
StrategyDialogViewHolder viewHolder = ((StrategyDialogViewHolder) holder);
if (position <= 5) {
viewHolder.gameName.setText(arrKaiFuTag[position]);
} else {
viewHolder.gameName.setText(mConcernGame.get(position - 6).getGameName());
}
if (position == mSelectPosition) {
viewHolder.selectIcon.setImageResource(R.drawable.strategy_game_select);
} else {
viewHolder.selectIcon.setImageDrawable(new ColorDrawable(0));
}
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String tag;
String gameName = null;
if (position <= 5) {
tag = arrKaiFuTag[position];
} else {
tag = mConcernGame.get(position - 6).getId();
gameName = mConcernGame.get(position - 6).getGameName();
}
callBackListener.selectPosition(position, tag, gameName);
}
});
}
}
@Override
public int getItemCount() {
if (mConcernGame.isEmpty()) {
return 5;
}
return mConcernGame.size() + 6;
}
public class TitleViewHolder extends RecyclerView.ViewHolder {
public TitleViewHolder(View itemView) {
super(itemView);
}
}
public interface OnKaiFuDialogCallBackListener{
void selectPosition(int position, String tag, String gameName);
}
}

View File

@ -24,7 +24,6 @@ import com.gh.common.constant.ItemViewType;
import com.gh.common.util.BitmapUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.Utils;
import com.gh.common.view.CardLinearLayout;
import com.gh.gamecenter.KcSelectGameActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
@ -271,23 +270,23 @@ public class KcSelectGameAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
private void initGameNormal(final KcSelectGameViewHolder holder, final InstallGameEntity gameEntity, final int i) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT
, ViewGroup.LayoutParams.WRAP_CONTENT);
// 第一个
if (i == 0 || i == gameList.size() + 1 || (gameList.isEmpty() && i == 1)) {
if (i == 0) {
((CardLinearLayout) holder.itemView).setmTop(DisplayUtils.dip2px(context, 49));
} else {
((CardLinearLayout) holder.itemView).setmTop(cardMargin);
}
if (i == 0) {
params.setMargins(0, DisplayUtils.dip2px(context, 49), 0, 0);
} else {
((CardLinearLayout) holder.itemView).setmTop(0);
params.setMargins(0, 0, 0, 0);
}
// 最后一个
if (i == gameList.size() - 1) {
((CardLinearLayout) holder.itemView).setBottom(true);
} else {
((CardLinearLayout) holder.itemView).setBottom(false);
}
holder.itemView.setLayoutParams(params);
// // 最后一个
// if (i == gameList.size() - 1) {
// ((CardLinearLayout) holder.itemView).setBottom(true);
// } else {
// ((CardLinearLayout) holder.itemView).setBottom(false);
// }
double size = (((float)gameEntity.getGameSize()/1024)/1024);
DecimalFormat df = new DecimalFormat("0.00");

View File

@ -0,0 +1,63 @@
package com.gh.gamecenter.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.gh.common.util.LibaoUtils;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.LiBaoCodeViewHolder;
import com.gh.gamecenter.db.info.LibaoInfo;
import java.util.List;
/**
* Created by khy on 2017/3/23.
*/
public class LiBaoCodeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context mContext;
private List<LibaoInfo> mCodeMap;
public LiBaoCodeAdapter(Context context, List<LibaoInfo> codes) {
this.mContext = context;
mCodeMap = codes;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mContext).inflate(R.layout.libao_code_item, parent, false);
return new LiBaoCodeViewHolder(view);
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
final LibaoInfo libaoInfo = mCodeMap.get(position);
if (holder instanceof LiBaoCodeViewHolder) {
LiBaoCodeViewHolder viewHolder = (LiBaoCodeViewHolder) holder;
if ("ling".equals(libaoInfo.getStatus()) || "linged".equals(libaoInfo.getStatus())) {
viewHolder.code.setText(Html.fromHtml(" "+ position +" &nbsp 已领取:" + "<font color=\"#00B7FA\">" +libaoInfo.getCode()+ "</font>"));
} else {
viewHolder.code.setText(Html.fromHtml(" "+ position +" &nbsp 已淘号:" + "<font color=\"#ffb13c\">" +libaoInfo.getCode()+ "</font>"));
}
viewHolder.copy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LibaoUtils.copyLink(libaoInfo.getCode(), mContext);
}
});
}
}
@Override
public int getItemCount() {
return mCodeMap.size();
}
}

View File

@ -1,15 +1,17 @@
package com.gh.gamecenter.adapter;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.text.Spanned;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gh.common.util.DisplayUtils;
@ -17,7 +19,9 @@ import com.gh.common.util.ImageUtils;
import com.gh.common.util.LibaoUtils;
import com.gh.common.util.PlatformUtils;
import com.gh.gamecenter.LibaoDetailActivity;
import com.gh.gamecenter.SuggestionActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
import com.gh.gamecenter.adapter.viewholder.LibaoDetailTopViewHolder;
import com.gh.gamecenter.db.LibaoDao;
import com.gh.gamecenter.db.info.LibaoInfo;
@ -44,6 +48,7 @@ public class LibaoDetailAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
private Context mContext;
private OnCallBackListener mCallBackListener;
private OnCodeScrollListener scrollListener;
private TextView mDownloadTv;
@ -59,6 +64,7 @@ public class LibaoDetailAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
public LibaoDetailAdapter(LibaoDetailActivity libaoDetailActivity, LibaoEntity libaoEntity, TextView tvDownload) {
this.mContext = libaoDetailActivity;
this.mCallBackListener = libaoDetailActivity;
this.scrollListener = libaoDetailActivity;
this.mLibaoEntity = libaoEntity;
this.mDownloadTv = tvDownload;
@ -90,6 +96,9 @@ public class LibaoDetailAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
@Override
public int getItemViewType(int position) {
if (position == getItemCount() - 1) {
return 100;
}
return position;
}
@ -98,6 +107,9 @@ public class LibaoDetailAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
if (viewType == 0) {
View view = LayoutInflater.from(mContext).inflate(R.layout.libaodetail_item_top, parent, false);
return new LibaoDetailTopViewHolder(view);
} else if (viewType == 100) {
View view = LayoutInflater.from(mContext).inflate(R.layout.refresh_footerview, parent, false);
return new FooterViewHolder(view);
} else {
View view = LayoutInflater.from(mContext).inflate(R.layout.gamedetail_item_news, parent, false);
return new GameDetailNewsViewHolder(view);
@ -110,16 +122,31 @@ public class LibaoDetailAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
initLibaoDetailTop((LibaoDetailTopViewHolder)holder);
} else if (holder instanceof GameDetailNewsViewHolder) {
initLibaoDetailContent((GameDetailNewsViewHolder)holder, position);
} else if (holder instanceof FooterViewHolder) {
FooterViewHolder viewHolder = (FooterViewHolder) holder;
viewHolder.loading.setVisibility(View.GONE);
viewHolder.hint.setText("此礼包有问题?点击反馈");
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, SuggestionActivity.class);
intent.putExtra("suggestType", 1);
intent.putExtra("suggestHintType", "libao");
intent.putExtra("content", mLibaoEntity.getGame().getName() + "" + mLibaoEntity.getName() + "有问题:");
mContext.startActivity(intent);
}
});
}
}
@Override
public int getItemCount() {
int index = 0;
int index = 1;
if (mLibaoDetailEntity != null) {
if (mLibaoEntity != null) {
index = 2;
index = index + 2;
}
if (mLibaoDetailEntity.getTime() != null || mLibaoDetailEntity.getInstallRequired()) {
@ -176,7 +203,7 @@ public class LibaoDetailAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
tvTime.setText("领取时间:" + start + " - " + end);
holder.gamedetail_item_news_list.addView(tvTime);
}
} else if (mLibaoDetailEntity.getDes() != null && position == getItemCount() -1) {
} else if (mLibaoDetailEntity.getDes() != null && position == getItemCount() - 2) {
holder.gamedetail_item_news_title.setText("使用说明");
TextView desTv = new TextView(mContext);
desTv.setTextColor(Color.parseColor("#717171"));
@ -186,11 +213,7 @@ public class LibaoDetailAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
}
private void initLibaoDetailTop(LibaoDetailTopViewHolder holder) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT
, LinearLayout.LayoutParams.WRAP_CONTENT);
params.setMargins(0, DisplayUtils.dip2px(mContext, 5),0,0);
holder.itemView.setLayoutParams(params);
// holder.libaoGameIcon.setImageURI(mLibaoEntity.getIcon());
ImageUtils.display(holder.libaoGameIcon, mLibaoEntity.getIcon());
holder.libaoName.setText(mLibaoEntity.getName());
if (TextUtils.isEmpty(mLibaoEntity.getPlatform())) {
@ -200,6 +223,8 @@ public class LibaoDetailAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
.getPlatformName(mLibaoEntity.getPlatform()));
}
holder.libaoCodeRv.setLayoutManager(new LinearLayoutManager(mContext));
int count = (int)(((float)mLibaoEntity.getAvailable()/(float)mLibaoEntity.getTotal()) * 100);
Spanned content = null;
String status = mLibaoEntity.getStatus();
@ -220,43 +245,73 @@ public class LibaoDetailAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
}
if (libaoInfo.getLibaoId().equals(mLibaoEntity.getId())) {
holder.libaoCopyBtn.setBackgroundResource(R.drawable.textview_blue_style);
holder.libaoCopyBtn.setTextColor(Color.WHITE);
holder.libaoCopyBtn.setText("复制");
holder.libaoCopyBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mLibaoDetailEntity != null && mLibaoDetailEntity.getInstallRequired()) {
Spanned msg;
if ("ling".equals(libaoInfo.getStatus())) {
msg = Html.fromHtml("礼包码:" + "<font color=\"#00B7FA\">" + libaoInfo.getCode() + "</font>" + " 复制成功" +
"<br/>请尽快进入游戏兑换");
} else {
msg = Html.fromHtml("礼包码:" +"<font color=\"#ffb13c\">" + libaoInfo.getCode() + "</font>" + " 复制成功" +
"<br/>淘号礼包不保证可用,请尽快进入游戏尝试兑换");
}
LibaoUtils.initLibaoBtn(holder.libaoCopyBtn, mLibaoEntity, mLibaoDao,
mLibaoDetailEntity.getInstallRequired(), this, entrance + "+(礼包详情[" + mLibaoEntity.getName() + "])");
LibaoUtils.lunningAppDialog(mContext, msg, mLibaoEntity);
// holder.libaoCopyBtn.setBackgroundResource(R.drawable.textview_blue_style);
// holder.libaoCopyBtn.setTextColor(Color.WHITE);
// holder.libaoCopyBtn.setText("复制");
// holder.libaoCopyBtn.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// if (mLibaoDetailEntity != null && mLibaoDetailEntity.getInstallRequired()) {
// Spanned msg;
// if ("ling".equals(libaoInfo.getStatus())) {
// msg = Html.fromHtml("礼包码:" + "<font color=\"#00B7FA\">" + libaoInfo.getCode() + "</font>" + " 复制成功" +
// "<br/>请尽快进入游戏兑换");
// } else {
// msg = Html.fromHtml("礼包码:" +"<font color=\"#ffb13c\">" + libaoInfo.getCode() + "</font>" + " 复制成功" +
// "<br/>淘号礼包不保证可用,请尽快进入游戏尝试兑换");
// }
//
// LibaoUtils.lunningAppDialog(mContext, msg, mLibaoEntity);
// }
// LibaoUtils.copyLink(libaoInfo.getCode(), mContext);
// }
// });
// Spanned libaoCode;
// if ("ling".equals(libaoInfo.getStatus())) {
// libaoCode = Html.fromHtml("已领取:" + "<font color=\"#00B7FA\">" +libaoInfo.getCode()+ "</font>");
// if (count == 0) {
// content = Html.fromHtml("剩余:" + count + "%");
// } else {
// content = Html.fromHtml("剩余:" + "<font color=\"#06D0A8\">" + count + "%" + "</font>");
// }
// } else {
// libaoCode = Html.fromHtml("已淘号:" + "<font color=\"#ffb13c\">" +libaoInfo.getCode()+ "</font>");
// content = Html.fromHtml("剩余:" + count + "%" );
// }
// holder.libaoCode.setVisibility(View.VISIBLE);
// holder.libaoCode.setText(libaoCode);
holder.libaoDes.setText(content);
final List<LibaoInfo> codes = mLibaoDao.findCodes(mLibaoEntity.getId());
if (codes == null && codes.isEmpty()) return;
holder.libaoCodeRv.setVisibility(View.VISIBLE);
holder.libaoCodeRv.setAdapter(new LiBaoCodeAdapter(mContext, codes));
ViewGroup.LayoutParams params = holder.libaoCodeRv.getLayoutParams();
if (codes.size() <= 3) {
params.height = codes.size() * DisplayUtils.dip2px(mContext, 40);
} else {
params.height = 3 * DisplayUtils.dip2px(mContext, 40);
}
holder.libaoCodeRv.setLayoutParams(params);
holder.libaoCodeRv.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
scrollListener.isScroll(false);
} else if (event.getAction() == MotionEvent.ACTION_UP) {
scrollListener.isScroll(true);
}
LibaoUtils.copyLink(libaoInfo.getCode(), mContext);
return false;
}
});
Spanned libaoCode;
if ("ling".equals(libaoInfo.getStatus())) {
libaoCode = Html.fromHtml("已领取:" + "<font color=\"#00B7FA\">" +libaoInfo.getCode()+ "</font>");
if (count == 0) {
content = Html.fromHtml("剩余:" + count + "%");
} else {
content = Html.fromHtml("剩余:" + "<font color=\"#06D0A8\">" + count + "%" + "</font>");
}
} else {
libaoCode = Html.fromHtml("已淘号:" + "<font color=\"#ffb13c\">" +libaoInfo.getCode()+ "</font>");
content = Html.fromHtml("剩余:" + count + "%" );
}
holder.libaoCode.setVisibility(View.VISIBLE);
holder.libaoCode.setText(libaoCode);
holder.libaoDes.setText(content);
return;
}
}
@ -304,4 +359,8 @@ public class LibaoDetailAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
public void openDownload() {
mDownloadTv.performClick();
}
public interface OnCodeScrollListener {
void isScroll(boolean isScroll);
}
}

View File

@ -1,10 +1,8 @@
package com.gh.gamecenter.adapter;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
@ -13,11 +11,10 @@ import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.TextView;
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;
@ -27,7 +24,6 @@ import com.gh.common.util.NewsUtils;
import com.gh.common.util.PostCommentUtils;
import com.gh.common.util.TimestampUtils;
import com.gh.common.util.Utils;
import com.gh.common.view.CardLinearLayout;
import com.gh.gamecenter.MessageDetailActivity;
import com.gh.gamecenter.NewsDetailActivity;
import com.gh.gamecenter.R;
@ -53,10 +49,7 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@ -135,7 +128,7 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
} else if (mConcernEntity != null) {
isOver = true;
notifyItemChanged(getItemCount() - 1);
mCallBackListener.showSoftInput();
mCallBackListener.showSoftInput(null);
}
}
@ -247,7 +240,6 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
} else if (holder instanceof FooterViewHolder) {
initFooterViewHolder((FooterViewHolder) holder);
} else if (holder instanceof CommentHeadViewHolder) {
((CardLinearLayout) holder.itemView).setmTop(DisplayUtils.dip2px(mContext, 4));
if (mHotCommentList.size() != 0 && position == 1) {
((CommentHeadViewHolder) holder).commentHeadTitleTv.setText("热门评论");
} else {
@ -331,8 +323,6 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
}
private void initNewsDigestViewHolder(final NewsDigestViewHolder viewHolder) {
((CardLinearLayout) viewHolder.itemView).setmTop(DisplayUtils.dip2px(mContext, 8));
((CardLinearLayout) viewHolder.itemView).setmBottom(DisplayUtils.dip2px(mContext, 4));
if (mConcernEntity.getViews() != 0) {
viewHolder.read.setText(String.format(Locale.getDefault(), "阅读 %d", mConcernEntity.getViews()));
@ -445,7 +435,7 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
viewHolder.comment.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCallBackListener.showSoftInput();
mCallBackListener.showSoftInput(null);
}
});
@ -484,29 +474,24 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
commentEntity = mHotCommentList.get(position -2);
isHotComment = true;
if (mHotCommentList.size() == position - 1) {
((CardLinearLayout) holder.itemView).setmBottom(DisplayUtils.dip2px(mContext, 4));
} else {
((CardLinearLayout) holder.itemView).setmBottom(0);
}
} else if (mNormalCommentList.size() != 0 &&
mNormalCommentList.size() > position - mHotCommentList.size() - index) {
commentPosition = position - mHotCommentList.size() - index;
commentEntity = mNormalCommentList.get(position - mHotCommentList.size() - index);
isHotComment = false;
if ( mNormalCommentList.size() == position - mHotCommentList.size() - index + 1) {
((CardLinearLayout) holder.itemView).setmBottom(DisplayUtils.dip2px(mContext, 4));
} else {
((CardLinearLayout) holder.itemView).setmBottom(0);
}
}
if (commentEntity == null) {
return;
}
holder.commentContentTv.setText(commentEntity.getContent());
if (commentEntity.getParent() != null) {
holder.commentContentTv.setText("回复"+ commentEntity.getParent().getUser().getName() + ": " + commentEntity.getContent());
} else {
holder.commentContentTv.setText(commentEntity.getContent());
}
holder.commentLikeCountTv.setTextColor(mContext.getResources().getColor(R.color.hint));
holder.commentLikeIv.setImageResource(R.drawable.ic_like_unselect);
@ -538,34 +523,7 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
}
}
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd", Locale.getDefault());
try {
long today = format.parse(format.format(new Date())).getTime();
long day = commentEntity.getTime() * 1000;
if (day >= today && day < today + 86400 * 1000) {
long min = new Date().getTime()/1000 - day/1000;
int hour = (int) (min/ (60 * 60));
if (hour == 0) {
if (min < 60) {
holder.commentTimeTv.setText("刚刚");
} else {
holder.commentTimeTv.setText(String.format(Locale.getDefault(), "%d分钟前", (int) (min / 60)));
}
} else {
holder.commentTimeTv.setText(String.format(Locale.getDefault(), "%d小时前", hour));
}
} else if (day >= today - 86400 * 1000 && day < today) {
format.applyPattern("HH:mm");
holder.commentTimeTv.setText("昨天 ");
} else {
format.applyPattern("yyyy-MM-dd");
holder.commentTimeTv.setText(format.format(day));
}
} catch (ParseException e) {
e.printStackTrace();
format.applyPattern("yyyy-MM-dd");
holder.commentTimeTv.setText(format.format(commentEntity.getTime() * 1000));
}
CommentUtils.setCommentTime(holder.commentTimeTv, commentEntity.getTime());
final CommentEntity finalCommentEntity = commentEntity;
final boolean finalIsHotComment = isHotComment;
@ -640,96 +598,14 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showReportDialog(finalCommentEntity.getId());
CommentUtils.showReportDialog(finalCommentEntity, mContext, mCallBackListener, null);
}
});
}
private void showReportDialog(final String commentId) {
LinearLayout container = new LinearLayout(mContext);
TextView reportTv = new TextView(mContext);
reportTv.setPadding(DisplayUtils.dip2px(mContext, 20), DisplayUtils.dip2px(mContext, 12),
0, DisplayUtils.dip2px(mContext, 12));
reportTv.setText("举报");
reportTv.setTextSize(17);
reportTv.setTextColor(mContext.getResources().getColor(R.color.title));
reportTv.setBackgroundResource(R.drawable.textview_white_style);
int widthPixels = mContext.getResources().getDisplayMetrics().widthPixels;
reportTv.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9)/10,
LinearLayout.LayoutParams.WRAP_CONTENT));
container.addView(reportTv);
final Dialog dialog = new Dialog(mContext);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(container);
dialog.show();
reportTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.cancel();
showReportTypeDialog(commentId);
}
});
}
private void showReportTypeDialog(final String commentId) {
final String[] arrReportType = new String[]{"垃圾广告营销", "恶意攻击谩骂", "淫秽色情信息",
"违法有害信息", "其它"};
int widthPixels = mContext.getResources().getDisplayMetrics().widthPixels;
final Dialog reportTypeDialog = new Dialog(mContext);
LinearLayout container = new LinearLayout(mContext);
container.setOrientation(LinearLayout.VERTICAL);
container.setPadding(0, DisplayUtils.dip2px(mContext, 12), 0, DisplayUtils.dip2px(mContext, 12));
container.setBackgroundColor(Color.WHITE);
for (final String s : arrReportType) {
TextView reportTypeTv = new TextView(mContext);
reportTypeTv.setText(s);
reportTypeTv.setTextSize(17);
reportTypeTv.setTextColor(mContext.getResources().getColor(R.color.title));
reportTypeTv.setBackgroundResource(R.drawable.textview_white_style);
reportTypeTv.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9)/10,
LinearLayout.LayoutParams.WRAP_CONTENT));
reportTypeTv.setPadding(DisplayUtils.dip2px(mContext, 20), DisplayUtils.dip2px(mContext, 12),
0, DisplayUtils.dip2px(mContext, 12));
container.addView(reportTypeTv);
reportTypeTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("comment_id", commentId);
jsonObject.put("reason", s);
} catch (JSONException e) {
e.printStackTrace();
}
PostCommentUtils.addReportData(mContext, jsonObject.toString(), true,
new PostCommentUtils.PostCommentListener() {
@Override
public void postSucced(JSONObject response) {
Utils.toast(mContext, "感谢您的举报");
}
@Override
public void postFailed(Throwable error) {
Utils.toast(mContext, "举报失败,请检查网络设置");
}
});
reportTypeDialog.cancel();
}
});
}
reportTypeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
reportTypeDialog.setContentView(container);
reportTypeDialog.show();
}
private void statNewsViews(final String news_id) {
RetrofitManager.getData().postNewsViews(news_id)
@ -815,6 +691,6 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
}
public interface OnCommentCallBackListener {
void showSoftInput();
void showSoftInput(CommentEntity entity);
}
}

View File

@ -0,0 +1,445 @@
package com.gh.gamecenter.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.gh.common.constant.ItemViewType;
import com.gh.common.util.DataCollectionUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.NewsUtils;
import com.gh.gamecenter.NewsNormalActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
import com.gh.gamecenter.adapter.viewholder.NewsImage1ViewHolder;
import com.gh.gamecenter.adapter.viewholder.NewsImage2ViewHolder;
import com.gh.gamecenter.adapter.viewholder.NewsImage3ViewHolder;
import com.gh.gamecenter.entity.NewsEntity;
import com.gh.gamecenter.entity.ViewsEntity;
import com.gh.gamecenter.listener.OnCallBackListener;
import com.gh.gamecenter.manager.VisitManager;
import com.gh.gamecenter.retrofit.JSONObjectResponse;
import com.gh.gamecenter.retrofit.ObservableUtil;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
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 retrofit2.adapter.rxjava.HttpException;
import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import rx.functions.Func1;
import rx.schedulers.Schedulers;
/**
* Created by khy on 2017/3/15.
*/
public class NewsNormalAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private NewsNormalActivity activity;
private Context context;
private OnCallBackListener listener;
private List<NewsEntity> newsList;
private String mNewsType;
private int itemCount;
private int cardMargin;
private boolean isLoading;
private boolean isOver;
private boolean isNetworkError;
public NewsNormalAdapter(NewsNormalActivity activity, String newsType) {
this.activity = activity;
this.context = activity;
this.listener = activity;
this.mNewsType = newsType;
newsList = new ArrayList<>();
itemCount = 0;
isLoading = false;
isOver = false;
isNetworkError = false;
cardMargin = (int)context.getResources().getDimension(R.dimen.cardview_margin);
addList(0);
}
// 加载数据
public void addList(final int offset) {
if (isLoading) {
return;
}
isLoading = true;
Observable<List<NewsEntity>> observable;
if ("yuanchuang".equals(mNewsType)) {
observable = RetrofitManager.getApi().getYuanChuang(offset);
} else {
observable = RetrofitManager.getApi().getZiXun(offset);
}
observable.map(new Func1<List<NewsEntity>, List<NewsEntity>>() {
@Override
public List<NewsEntity> call(List<NewsEntity> list) {
// 去掉重复数据
return NewsUtils.removeDuplicateData(newsList, list);
}
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<List<NewsEntity>>(){
@Override
public void onResponse(List<NewsEntity> response) {
isLoading = false;
if (response.size() != 0) {
newsList.addAll(response);
itemCount += response.size();
notifyItemRangeInserted(newsList.size() - response.size(), response.size());
} else {
isOver = true;
notifyItemChanged(getItemCount() - 1);
}
if (offset == 0 && listener != null) {
listener.loadDone();
}
// 获取新闻阅读量
getNewsViews(response, offset);
}
@Override
public void onFailure(HttpException e) {
isLoading = false;
// 网络错误
if (offset == 0) {
if (listener != null) {
listener.loadError();
}
} else {
Toast.makeText(context, "加载失败,请检查网络状态", Toast.LENGTH_SHORT).show();
isNetworkError = true;
notifyItemChanged(getItemCount() - 1);
}
}
});
}
// 获取新闻阅读量
private void getNewsViews(final List<NewsEntity> list, final int start) {
if (list == null || list.isEmpty()) {
return;
}
ObservableUtil.computation(new Observable.OnSubscribe<String>() {
@Override
public void call(Subscriber<? super String> subscriber) {
StringBuilder builder = new StringBuilder();
for (int i = 0, size = list.size(); i < size; i++) {
builder.append(list.get(i).getId());
builder.append("-");
}
builder.deleteCharAt(builder.length() - 1);
String ids = builder.toString();
VisitManager.getInstance().addUrl(ids);
subscriber.onNext(ids);
subscriber.onCompleted();
}
}, new Action1<String>() {
@Override
public void call(String ids) {
RetrofitManager.getData()
.getNewsViews(ids)
.map(new Func1<List<ViewsEntity>, String>() {
@Override
public String call(List<ViewsEntity> list) {
for (ViewsEntity viewsEntity : list) {
for (NewsEntity newsEntity : newsList) {
if (viewsEntity.getId().equals(newsEntity.getId())) {
newsEntity.setViews(viewsEntity.getViews());
break;
}
}
}
return null;
}
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<String>() {
@Override
public void onResponse(String response) {
notifyItemRangeChanged(start, list.size());
}
});
}
});
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == ItemViewType.NEWS_IMAGE1) {
View view = LayoutInflater.from(parent.getContext()).inflate(
R.layout.news_image1_item, parent, false);
return new NewsImage1ViewHolder(view);
} else if (viewType == ItemViewType.NEWS_IMAGE2) {
View view = LayoutInflater.from(parent.getContext()).inflate(
R.layout.news_image2_item, parent, false);
return new NewsImage2ViewHolder(view);
} else if (viewType == ItemViewType.NEWS_IMAGE3) {
View view = LayoutInflater.from(parent.getContext()).inflate(
R.layout.news_image3_item, parent, false);
return new NewsImage3ViewHolder(view);
} else if (viewType == ItemViewType.LOADING) {
View view = LayoutInflater.from(parent.getContext()).inflate(
R.layout.refresh_footerview, parent, false);
return new FooterViewHolder(view);
}
return null;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof NewsImage1ViewHolder) {
initNewsImage1ViewHolder((NewsImage1ViewHolder) holder, position);
} else if (holder instanceof NewsImage2ViewHolder) {
initNewsImage2ViewHolder((NewsImage2ViewHolder) holder, position);
} else if (holder instanceof NewsImage3ViewHolder) {
initNewsImage3ViewHolder((NewsImage3ViewHolder) holder, position);
} else if (holder instanceof FooterViewHolder) {
initFooterViewHolder((FooterViewHolder) holder);
}
}
private void initNewsImage1ViewHolder(final NewsImage1ViewHolder viewHolder, int position) {
final NewsEntity newsEntity = newsList.get(position);
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(context, "点击", "资讯-资讯", kv);
DataCollectionUtils.uploadClick(context, "列表", "资讯-资讯", newsEntity.getTitle());
//统计阅读量
statNewsViews(newsEntity, viewHolder.getPosition());
NewsUtils.startNewsDetailActivity(context, newsEntity, "(资讯-资讯)");
}
});
// viewHolder.thumb.setImageURI(newsEntity.getThumbnail().getUrl().get(0));
ImageUtils.display(viewHolder.thumb, newsEntity.getThumbnail().getUrl().get(0));
viewHolder.title.setText(newsEntity.getTitle());
int views = newsEntity.getViews();
if (views == 0) {
viewHolder.read.setVisibility(View.GONE);
} else {
viewHolder.read.setVisibility(View.VISIBLE);
viewHolder.read.setText(String.format(Locale.getDefault(), "阅读 %d", views));
}
NewsUtils.setNewsType(viewHolder.type, newsEntity.getType(), newsEntity.getPriority(), position);
}
private void initNewsImage2ViewHolder(final NewsImage2ViewHolder viewHolder, int position) {
final NewsEntity newsEntity = newsList.get(position);
DisplayMetrics outMetrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
int width = (outMetrics.widthPixels - DisplayUtils.dip2px(context, 56)) / 3;
int height = (int) (width * 3 / 4f);
LinearLayout.LayoutParams lparams1 = new LinearLayout.LayoutParams(width, height);
viewHolder.thumb1.setLayoutParams(lparams1);
LinearLayout.LayoutParams lparams2 = new LinearLayout.LayoutParams(width, height);
lparams2.leftMargin = DisplayUtils.dip2px(context, 8);
viewHolder.thumb2.setLayoutParams(lparams2);
LinearLayout.LayoutParams lparams3 = new LinearLayout.LayoutParams(width, height);
lparams3.leftMargin = DisplayUtils.dip2px(context, 8);
viewHolder.thumb3.setLayoutParams(lparams3);
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(context, "点击", "资讯-资讯", kv);
DataCollectionUtils.uploadClick(context, "列表", "资讯-资讯", newsEntity.getTitle());
//统计阅读量
statNewsViews(newsEntity, viewHolder.getPosition());
NewsUtils.startNewsDetailActivity(context, newsEntity, "(资讯-资讯)");
}
});
viewHolder.title.setText(newsEntity.getTitle());
// viewHolder.thumb1.setImageURI(newsEntity.getThumbnail().getUrl().get(0));
// viewHolder.thumb2.setImageURI(newsEntity.getThumbnail().getUrl().get(1));
// viewHolder.thumb3.setImageURI(newsEntity.getThumbnail().getUrl().get(2));
ImageUtils.display(viewHolder.thumb1, newsEntity.getThumbnail().getUrl().get(0));
ImageUtils.display(viewHolder.thumb2, newsEntity.getThumbnail().getUrl().get(1));
ImageUtils.display(viewHolder.thumb3, newsEntity.getThumbnail().getUrl().get(2));
int views = newsEntity.getViews();
if (views == 0) {
viewHolder.read.setVisibility(View.GONE);
} else {
viewHolder.read.setVisibility(View.VISIBLE);
viewHolder.read.setText(String.format(Locale.getDefault(), "阅读 %d", views));
}
NewsUtils.setNewsType(viewHolder.type, newsEntity.getType(), newsEntity.getPriority(), position);
}
private void initNewsImage3ViewHolder(final NewsImage3ViewHolder viewHolder, int position) {
final NewsEntity newsEntity = newsList.get(position);
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(context, "点击", "资讯-资讯", kv);
DataCollectionUtils.uploadClick(context, "列表", "资讯-资讯", newsEntity.getTitle());
//统计阅读量
statNewsViews(newsEntity, viewHolder.getPosition());
NewsUtils.startNewsDetailActivity(context, newsEntity, "(资讯-资讯)");
}
});
viewHolder.title.setText(newsEntity.getTitle());
ImageUtils.getInstance().display(viewHolder.thumb, newsEntity.getThumbnail().getUrl().get(0),
context.getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(context, 40));
int views = newsEntity.getViews();
if (views == 0) {
viewHolder.read.setVisibility(View.GONE);
} else {
viewHolder.read.setVisibility(View.VISIBLE);
viewHolder.read.setText(String.format(Locale.getDefault(), "阅读 %d", views));
}
NewsUtils.setNewsType(viewHolder.type, newsEntity.getType(), newsEntity.getPriority(), position);
}
private void initFooterViewHolder(FooterViewHolder viewHolder) {
if (isNetworkError) {
viewHolder.loading.setVisibility(View.GONE);
viewHolder.hint.setText("加载失败,点击重试");
viewHolder.itemView.setClickable(true);
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
isNetworkError = false;
notifyItemChanged(getItemCount() - 1);
addList(newsList.size());
}
});
} else if (isOver) {
viewHolder.loading.setVisibility(View.GONE);
viewHolder.hint.setText("加载完毕");
viewHolder.itemView.setClickable(false);
} else {
viewHolder.loading.setVisibility(View.VISIBLE);
viewHolder.hint.setText("加载中...");
viewHolder.itemView.setClickable(false);
}
}
@Override
public int getItemCount() {
if (itemCount == 0) {
return 0;
}
return itemCount + 1;
}
@Override
public int getItemViewType(int position) {
if (position == newsList.size()) {
return ItemViewType.LOADING;
}
NewsEntity newsEntity = newsList.get(position);
if ("4x3".equals(newsEntity.getThumbnail().getType()) && newsEntity.getThumbnail().getUrl().size() == 3){
return ItemViewType.NEWS_IMAGE2;
}
if ("3x1".equals(newsEntity.getThumbnail().getType())) {
return ItemViewType.NEWS_IMAGE3;
}
return ItemViewType.NEWS_IMAGE1;
}
// 统计新闻阅读量
private void statNewsViews(final NewsEntity newsEntity, final int position) {
RetrofitManager.getData().postNewsViews(newsEntity.getId())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new JSONObjectResponse(){
@Override
public void onResponse(JSONObject response) {
if (response.length() != 0) {
try {
if ("success".equals(response.getString("status"))) {
newsEntity.setViews(newsEntity.getViews() + 1);
notifyItemChanged(position);
// 更新okhttp缓存数据
VisitManager.updateOkhttpCache(newsEntity.getId());
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
});
}
public boolean isOver() {
return isOver;
}
public boolean isLoading() {
return isLoading;
}
public boolean isNetworkError() {
return isNetworkError;
}
public void setNetworkError(boolean networkError) {
isNetworkError = networkError;
}
public int getNewsListSize() {
return newsList.size();
}
}

View File

@ -35,6 +35,7 @@ import com.gh.download.DownloadManager;
import com.gh.download.DownloadStatus;
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;
@ -115,6 +116,24 @@ public class PlatformAdapter extends RecyclerView.Adapter<PlatformViewHolder> {
public void onBindViewHolder(final PlatformViewHolder viewHolder, int position) {
final ApkEntity apkEntity = platforms.get((row * column) * adapterPosition + position);
if (apkEntity == null || TextUtils.isEmpty(apkEntity.getPackageName())) {
viewHolder.download_item_iv_pic.setVisibility(View.VISIBLE);
viewHolder.download_item_tv_hint.setVisibility(View.GONE);
viewHolder.download_item_progressbar.setVisibility(View.GONE);
viewHolder.download_item_tv_name.setVisibility(View.GONE);
viewHolder.download_item_tv_status.setVisibility(View.GONE);
viewHolder.download_item_iv_pic.setImageURI(Uri.parse("res:///" + R.drawable.platform_vote));
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, VoteActivity.class);
intent.putExtra("gameName", gameEntity.getName());
context.startActivity(intent);
}
});
return;
}
if (apkEntity.getApkCollection() == null) {
// 非合集
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {

View File

@ -9,13 +9,11 @@ import android.view.ViewGroup;
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.GameUtils;
import com.gh.common.util.GameViewUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.PlatformUtils;
import com.gh.common.view.CardLinearLayout;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.PluginActivity;
import com.gh.gamecenter.R;
@ -139,19 +137,6 @@ public class PluginAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
if (holder instanceof GameNormalViewHolder) {
final GameNormalViewHolder viewHolder = (GameNormalViewHolder) holder;
// 第一个
if (position == 0) {
((CardLinearLayout) viewHolder.itemView).setmTop(DisplayUtils.dip2px(context, 8));
} else {
((CardLinearLayout) viewHolder.itemView).setmTop(0);
}
// 最后一个
if (position == pluginList.size() - 1) {
((CardLinearLayout) viewHolder.itemView).setBottom(true);
} else {
((CardLinearLayout) viewHolder.itemView).setBottom(false);
}
final GameEntity gameEntity = pluginList.get(position);
@ -187,7 +172,7 @@ public class PluginAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
});
DownloadItemUtils.setOnClickListener(context, viewHolder.gameDownloadBtn, gameEntity, position,
PluginAdapter.this, entrance + "+(插件化[" + (viewHolder.getPosition() + 1) + "])", "插件化:" + gameEntity.getName(), false);
PluginAdapter.this, entrance + "+(插件化[" + (viewHolder.getPosition() + 1) + "])", "插件化:" + gameEntity.getName());
DownloadItemUtils.updateItem(context, gameEntity, viewHolder, false);
}

View File

@ -1,236 +0,0 @@
package com.gh.gamecenter.adapter;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.NewsUtils;
import com.gh.common.view.CardLinearLayout;
import com.gh.gamecenter.R;
import com.gh.gamecenter.StrategyActivity;
import com.gh.gamecenter.adapter.viewholder.NewsFooterViewHolder;
import com.gh.gamecenter.adapter.viewholder.NewsTextViewHolder;
import com.gh.gamecenter.entity.NewsEntity;
import com.gh.gamecenter.manager.DataCollectionManager;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import retrofit2.adapter.rxjava.HttpException;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Func1;
import rx.schedulers.Schedulers;
/**
* Created by khy on 2016/12/5.
*
*/
public class StrategyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private StrategyActivity mStrategyActivity;
private LinearLayout mNoData;
private List<NewsEntity> mNewsList;
private String mGameId;
private String entrance;
private boolean isRemove;
private boolean isLoading;
private boolean isNetworkError;
public StrategyAdapter(StrategyActivity strategyActivity, String gameId, LinearLayout noData) {
this.mStrategyActivity = strategyActivity;
this.mGameId = gameId;
this.mNoData = noData;
entrance = strategyActivity.getIntent().getStringExtra("entrance");
mNewsList = new ArrayList<>();
isLoading = false;
isRemove = false;
isNetworkError = false;
addList(0);
}
public void addList(final int offset) {
isLoading = true;
if (offset == 0) {
mNewsList.clear();
notifyDataSetChanged();
}
Observable<List<NewsEntity>> gameNews;
if (mGameId == null) {
gameNews = RetrofitManager.getApi().getNews("攻略", 20, offset);
} else {
gameNews = RetrofitManager.getApi().getGameNews(mGameId, 20, "攻略", offset);
}
gameNews.map(new Func1<List<NewsEntity>, List<NewsEntity>>() {
@Override
public List<NewsEntity> call(List<NewsEntity> newsEntities) {
return NewsUtils.removeDuplicateData(mNewsList, newsEntities);
}
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<List<NewsEntity>>(){
@Override
public void onResponse(List<NewsEntity> response) {
if (response.size() != 0) {
mNewsList.addAll(response);
if (mNewsList.size() <= 20) {
notifyDataSetChanged();
} else {
notifyItemRangeInserted(mNewsList.size() - response.size(), response.size());
}
notifyItemChanged(getItemCount() - response.size() - 2);
}
if (response.size() < 20) {
isRemove = true;
notifyItemChanged(getItemCount() - 1);
}
if (mNewsList.size() == 0) {
mNoData.setVisibility(View.VISIBLE);
notifyItemChanged(0);
} else {
mNoData.setVisibility(View.GONE);
}
isLoading = false;
}
@Override
public void onFailure(HttpException e) {
isNetworkError = true;
isLoading = false;
notifyItemChanged(getItemCount() - 1);
}
});
}
@Override
public int getItemViewType(int position) {
if (position == getItemCount() - 1) {
return 0;
} else {
return 1;
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == 1) {
View view = LayoutInflater.from(mStrategyActivity).inflate(R.layout.news_text_item, parent, false);
return new NewsTextViewHolder(view);
} else {
View view = LayoutInflater.from(mStrategyActivity).inflate(R.layout.news_footer_item, parent, false);
return new NewsFooterViewHolder(view);
}
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof NewsTextViewHolder) {
final NewsTextViewHolder viewHolder = (NewsTextViewHolder) holder;
viewHolder.type.setVisibility(View.GONE);
// 第一个
if (position == 0) {
viewHolder.line.setVisibility(View.GONE);
if (mStrategyActivity.selectRlIsVisible()) {
((CardLinearLayout) viewHolder.itemView).setmTop(0);
} else {
((CardLinearLayout) viewHolder.itemView).setmTop(16);
}
} else {
viewHolder.line.setVisibility(View.VISIBLE);
((CardLinearLayout) holder.itemView).setmTop(0);
}
// 最后一个
if (position +1 == mNewsList.size()) {
((CardLinearLayout) viewHolder.itemView).setBottom(true);
((CardLinearLayout) viewHolder.itemView).setmBottom(DisplayUtils.dip2px(mStrategyActivity, 8));
} else {
((CardLinearLayout) viewHolder.itemView).setBottom(false);
((CardLinearLayout) viewHolder.itemView).setmBottom(0);
}
final NewsEntity newsEntity = mNewsList.get(position);
viewHolder.type.setBackgroundResource(NewsUtils.getDrawableIdByType(newsEntity.getType()));
viewHolder.type.setText(newsEntity.getType());
viewHolder.title.setText(newsEntity.getTitle());
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(mStrategyActivity, "点击", "游戏新闻详情", kv);
Map<String, Object> map = new HashMap<>();
map.put("page", "游戏新闻详情");
map.put("news", newsEntity.getTitle());
map.put("news_id", newsEntity.getId());
DataCollectionManager.onEvent(mStrategyActivity, "click-item", map);
// 统计阅读量
NewsUtils.statNewsViews(newsEntity.getId());
NewsUtils.startNewsDetailActivity(mStrategyActivity, newsEntity, entrance + "+(攻略[" + newsEntity.getTitle() + "])");
}
});
} else {
final NewsFooterViewHolder footerViewHolder = ((NewsFooterViewHolder) holder);
if (mNoData.getVisibility() == View.VISIBLE) {
footerViewHolder.itemView.setVisibility(View.GONE);
}else{
footerViewHolder.itemView.setVisibility(View.VISIBLE);
}
if (isRemove){
footerViewHolder.hint.setText("加载完毕");
footerViewHolder.loading.setVisibility(View.GONE);
}else if (isNetworkError){
footerViewHolder.hint.setText("网络错误,点击重试!");
footerViewHolder.loading.setVisibility(View.GONE);
} else {
footerViewHolder.hint.setText("加载中...");
footerViewHolder.loading.setVisibility(View.VISIBLE);
}
footerViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isNetworkError) {
isNetworkError = false;
footerViewHolder.hint.setText("加载中...");
footerViewHolder.loading.setVisibility(View.VISIBLE);
addList(mNewsList.size());
}
}
});
}
}
@Override
public int getItemCount() {
return mNewsList.size() + 1;
}
public boolean isCanLoading() {
return (!isNetworkError && !isLoading && !isRemove);
}
}

View File

@ -12,12 +12,10 @@ import android.widget.Toast;
import com.gh.common.constant.ItemViewType;
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.GameUtils;
import com.gh.common.util.GameViewUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.view.CardLinearLayout;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.R;
import com.gh.gamecenter.SubjectActivity;
@ -56,16 +54,18 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
private String id;
private String name;
private String entrance;
private String type;
private boolean isRemove;
private boolean isNetworkError;
private boolean order;
private boolean isLoaded;
public SubjectAdapter(SubjectActivity activity) {
public SubjectAdapter(SubjectActivity activity, String type) {
this.context = activity;
this.listener = activity;
this.type = type;
this.id = activity.getIntent().getStringExtra("id");
this.name = activity.getIntent().getStringExtra("name");
@ -83,16 +83,19 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
subjectList = new ArrayList<>();
isLoaded = false;
isNetworkError = false;
isRemove = false;
initList(1);
initList(1, type);
}
public void initList(final int page) {
// if (isLoaded) { //TODO 无法分页
// return;
// }
public void initList(final int page, String type) {
if ("全部".equals(type)) {
type = "";
}
isLoaded = false;
RetrofitManager.getApi().getColumn(id, page)
RetrofitManager.getApi().getColumn(id, page, type)
.map(new Func1<List<GameEntity>, List<GameEntity>>() {
@Override
public List<GameEntity> call(List<GameEntity> list) {
@ -111,10 +114,21 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
entity.setEntryMap(DownloadManager.getInstance(context).getEntryMap(entity.getName()));
manager.addOrUpdate(entity.getApk(), entity.getId(), entity.getName());
}
if (page == 1) {
if (response.get(0).getTag().size() != 0) {
listener.loadDone(response.get(0).getTag());
}
if (TextUtils.isEmpty(response.get(0).getToutu())) {
response.remove(0);
}
}
subjectList.addAll(response);
notifyItemRangeInserted(subjectList.size() - response.size(), response.size());
if (response.size() < 20) {
if (response.size() < 20 && page != 1 || response.size() < 19) {
isRemove = true;
notifyItemChanged(getItemCount() - 1);
}
@ -125,7 +139,7 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
initLocationMap();
if (listener != null) {
if (listener != null ) {
listener.loadDone();
}
@ -134,6 +148,8 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
@Override
public void onFailure(HttpException e) {
isLoaded = true;
if (page == 1){
if (listener != null) {
listener.loadError();
@ -238,10 +254,8 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
initFooterViewHolder((FooterViewHolder) viewHolder);
} else if (viewHolder instanceof GameImageViewHolder) {
GameImageViewHolder holder = ((GameImageViewHolder) viewHolder);
// holder.image.setImageURI(subjectList.get(position).getToutu());
holder.line.setVisibility(View.GONE);
ImageUtils.display(holder.image, subjectList.get(position).getToutu());
((CardLinearLayout) holder.itemView).setmTop(DisplayUtils.dip2px(context, 8));
((CardLinearLayout) holder.itemView).setmBottom(DisplayUtils.dip2px(context, 8));
}
}
@ -255,7 +269,7 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
public void onClick(View v) {
isNetworkError = false;
notifyDataSetChanged();
initList(subjectList.size() / 21);
initList((subjectList.size() / 20) + 1, type);
}
});
} else if (isRemove) {
@ -273,20 +287,6 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
private void initGameTestViewHolder(final GameTestViewHolder holder, int position) {
// 第一个
if (position == 0) {
((CardLinearLayout) holder.itemView).setmTop(DisplayUtils.dip2px(context, 8));
} else {
((CardLinearLayout) holder.itemView).setmTop(0);
}
// 最后一个
if (position == subjectList.size() - 1) {
((CardLinearLayout) holder.itemView).setBottom(true);
} else {
((CardLinearLayout) holder.itemView).setBottom(false);
}
if (order) {
int index = 1;
if (subjectList.get(0).getToutu() != null) {
@ -340,27 +340,13 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
DownloadItemUtils.setOnClickListener(context,
holder.gameDownloadBtn, gameEntity, position,
SubjectAdapter.this, entrance + "+(" + name + "[" + (holder.getPosition() + 1) + "])", name + ":" + gameEntity.getName(), false);
SubjectAdapter.this, entrance + "+(" + name + "[" + (holder.getPosition() + 1) + "])", name + ":" + gameEntity.getName());
DownloadItemUtils.updateItem(context, gameEntity, holder, true);
}
private void initGameNormalViewHolder(final GameNormalViewHolder holder, int position) {
// 第一个
if (position == 0) {
((CardLinearLayout) holder.itemView).setmTop(DisplayUtils.dip2px(context, 8));
} else {
((CardLinearLayout) holder.itemView).setmTop(0);
}
// 最后一个
if (position == subjectList.size() - 1) {
((CardLinearLayout) holder.itemView).setBottom(true);
} else {
((CardLinearLayout) holder.itemView).setBottom(false);
}
if (order) {
int index = 1;
if (subjectList.get(0).getToutu() != null) {
@ -400,7 +386,7 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
});
DownloadItemUtils.setOnClickListener(context, holder.gameDownloadBtn,
gameEntity, position, this, entrance + "+(" + name + "[" + (holder.getPosition() + 1) + "])", name + ":" + gameEntity.getName(), false);
gameEntity, position, this, entrance + "+(" + name + "[" + (holder.getPosition() + 1) + "])", name + ":" + gameEntity.getName());
DownloadItemUtils.updateItem(context, gameEntity, holder, true);
}
@ -417,4 +403,9 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
return isLoaded;
}
public boolean isRemove(){
return isRemove;
}
}

View File

@ -0,0 +1,118 @@
package com.gh.gamecenter.adapter;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.StateListDrawable;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gh.common.util.DisplayUtils;
import com.gh.gamecenter.R;
import com.gh.gamecenter.SubjectActivity;
import java.util.ArrayList;
/**
* Created by khy on 2017/3/16.
*/
public class SubjectTypeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context mContext;
private OnSelectTypeListener listener;
private ArrayList<String> mGameType;
private String mCurType;
public SubjectTypeAdapter(SubjectActivity subjectActivity, ArrayList<String> gameType) {
this.mContext = subjectActivity;
this.listener = subjectActivity;
mGameType = gameType;
mCurType = "全部";
}
public StateListDrawable selectorBg(){
StateListDrawable bg_install = new StateListDrawable();
bg_install.addState(new int[] { android.R.attr.state_pressed, android.R.attr.state_enabled },
new ColorDrawable(Color.parseColor("#59d3ff")));
bg_install.addState(new int[] { android.R.attr.state_selected, android.R.attr.state_enabled },
new ColorDrawable(Color.parseColor("#00B7FA")));
bg_install.addState(new int[] {}, new ColorDrawable(Color.WHITE));
return bg_install;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
RelativeLayout relativeLayout = new RelativeLayout(mContext);
relativeLayout.setBackgroundColor(Color.parseColor("#ededed"));
TextView textView = new TextView(mContext);
textView.setTextSize(13);
textView.setBackgroundDrawable(selectorBg());
textView.setTextColor(mContext.getResources().getColor(R.color.title));
textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT
, DisplayUtils.dip2px(mContext, 36)));
textView.setGravity(Gravity.CENTER);
// textView.setBackgroundColor(Color.WHITE);
relativeLayout.addView(textView);
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) textView.getLayoutParams();
int dp = DisplayUtils.dip2px(mContext, 1);
int dp2 = DisplayUtils.dip2px(mContext, 0.5f);
layoutParams.setMargins(dp2, dp, dp2, 0);
return new GameTypeViewHolder(relativeLayout);
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
if (holder instanceof GameTypeViewHolder) {
final GameTypeViewHolder viewHolder = (GameTypeViewHolder) holder;
viewHolder.type.setText(mGameType.get(position));
if (!TextUtils.isEmpty(mCurType) && mCurType.equals(mGameType.get(position))) {
viewHolder.type.setSelected(true);
viewHolder.type.setTextColor(Color.WHITE);
} else {
viewHolder.type.setSelected(false);
viewHolder.type.setTextColor(mContext.getResources().getColor(R.color.title));
}
((GameTypeViewHolder) holder).type.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
viewHolder.type.setSelected(true);
listener.onSelectType(mGameType.get(position));
mCurType = mGameType.get(position);
notifyItemRangeChanged(0, getItemCount());
}
});
}
}
@Override
public int getItemCount() {
return mGameType.size();
}
public class GameTypeViewHolder extends RecyclerView.ViewHolder {
private TextView type;
public GameTypeViewHolder(View itemView) {
super(itemView);
type = (TextView) ((RelativeLayout)itemView).getChildAt(0);
}
}
public interface OnSelectTypeListener {
void onSelectType(String type);
}
}

View File

@ -0,0 +1,96 @@
package com.gh.gamecenter.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.gh.common.util.Utils;
import com.gh.gamecenter.R;
import com.gh.gamecenter.VoteActivity;
import com.gh.gamecenter.adapter.viewholder.VoteViewHolder;
import java.util.ArrayList;
import java.util.List;
/**
* Created by khy on 2017/4/11.
* 求版本投票页面适配器
*/
public class VoteAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context mContext;
private float mPbwidth; //进度条原始最大宽度
private List<Float> voteList;
public VoteAdapter(VoteActivity activity) {
this.mContext = activity;
mPbwidth = (float) (activity.getResources().getDisplayMetrics().widthPixels * 0.65);
voteList = new ArrayList<>();
float max = 1000;
for (int i = 0; i < 50; i++) {
voteList.add(max);
max = max - 20;
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mContext).inflate(R.layout.vote_item, parent, false);
if (mPbwidth == -1) {
final View pb = view.findViewById(R.id.progressbar);
pb.post(new Runnable() {
@Override
public void run() {
mPbwidth = pb.getWidth();
}
});
}
return new VoteViewHolder(view);
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof VoteViewHolder) {
VoteViewHolder viewHolder = (VoteViewHolder) holder;
viewHolder.voteBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
View progressbar = viewHolder.progressbar;
ViewGroup.LayoutParams layoutParams = progressbar.getLayoutParams();
if (position > 0) {
float maxSize = voteList.get(0);
float curSize = voteList.get(position);
float f = curSize/maxSize;
Utils.log(maxSize + "======="+ curSize +"=======" + f + "====" + (int) (mPbwidth/f));
layoutParams.width = (int) (mPbwidth * f);
} else {
layoutParams.width = (int) mPbwidth;
Utils.log("==============" + mPbwidth);
}
viewHolder.count.setText(voteList.get(position) + "");
progressbar.setLayoutParams(layoutParams);
}
}
@Override
public int getItemCount() {
return voteList.size();
}
}

View File

@ -21,6 +21,7 @@ public class GameDownloadViewHolder extends RecyclerView.ViewHolder {
public TextView dm_item_tv_speed;
public ProgressBar dm_item_progressbar;
public TextView dm_item_tv_startorpause;
public View dm_item_line;
public GameDownloadViewHolder(View itemView) {
super(itemView);
@ -32,6 +33,7 @@ public class GameDownloadViewHolder extends RecyclerView.ViewHolder {
dm_item_tv_speed = (TextView) itemView.findViewById(R.id.dm_item_tv_speed);
dm_item_progressbar = (ProgressBar) itemView.findViewById(R.id.dm_item_progressbar);
dm_item_tv_startorpause = (TextView) itemView.findViewById(R.id.dm_item_tv_startorpause);
dm_item_line = itemView.findViewById(R.id.dm_item_line);
}

View File

@ -3,7 +3,6 @@ package com.gh.gamecenter.adapter.viewholder;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
@ -16,22 +15,20 @@ public class GameHeadViewHolder extends RecyclerView.ViewHolder {
public ImageView thumb;
public TextView title;
public LinearLayout link;
public TextView more;
public ProgressBar progressBar;
public ImageView moreIcon;
public View line;
public View lineTop;
public GameHeadViewHolder(View itemView) {
super(itemView);
this.thumb = (ImageView) itemView.findViewById(R.id.head_thumb);
this.title = (TextView) itemView.findViewById(R.id.head_title);
this.link = (LinearLayout) itemView.findViewById(R.id.head_link);
this.more = (TextView) itemView.findViewById(R.id.head_more);
this.progressBar = (ProgressBar) itemView.findViewById(R.id.head_pb);
this.moreIcon = (ImageView) itemView.findViewById(R.id.head_more_icon);
this.line = itemView.findViewById(R.id.head_line);
this.lineTop = itemView.findViewById(R.id.head_line_top);
}
}

View File

@ -12,11 +12,13 @@ import com.gh.gamecenter.R;
public class GameImageViewHolder extends RecyclerView.ViewHolder {
public SimpleDraweeView image;
public View line;
public GameImageViewHolder(View itemView) {
super(itemView);
image = (SimpleDraweeView) itemView.findViewById(R.id.home_game_iv_image);
line = itemView.findViewById(R.id.home_game_line);
}
}

View File

@ -7,7 +7,6 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.gh.common.view.CardLinearLayout;
import com.gh.common.view.SwipeLayout;
import com.gh.gamecenter.R;
@ -18,7 +17,7 @@ import static com.gh.gamecenter.R.id.home1_game_order;
*/
public class GameNormalSwipeViewHolder extends GameViewHolder {
public CardLinearLayout cardView;
public LinearLayout cardView;
public SwipeLayout swipeLayout;
public TextView swipeText;
public TextView swipeShareText;
@ -37,7 +36,7 @@ public class GameNormalSwipeViewHolder extends GameViewHolder {
gameProgressbar = (ProgressBar) itemView.findViewById(R.id.home1_game_progressbar);
gameDownloadSpeed = (TextView) itemView.findViewById(R.id.home1_download_speed);
gameDownloadPercentage = (TextView) itemView.findViewById(R.id.home1_download_percentage);
cardView = (CardLinearLayout) itemView.findViewById(R.id.home1_game_card);
cardView = (LinearLayout) itemView.findViewById(R.id.home1_game_card);
swipeLayout = (SwipeLayout) itemView.findViewById(R.id.swipeLayout);
swipeText = (TextView) itemView.findViewById(R.id.swipe_text);
swipeShareText = (TextView) itemView.findViewById(R.id.swipe_share_text);

View File

@ -0,0 +1,22 @@
package com.gh.gamecenter.adapter.viewholder;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import com.gh.gamecenter.R;
/**
* Created by khy on 2017/3/23.
*/
public class LiBaoCodeViewHolder extends RecyclerView.ViewHolder {
public TextView code;
public TextView copy;
public LiBaoCodeViewHolder(View itemView) {
super(itemView);
code = (TextView) itemView.findViewById(R.id.libao_code_tv);
copy = (TextView) itemView.findViewById(R.id.libao_copy_btn);
}
}

View File

@ -20,7 +20,7 @@ public class LibaoDetailTopViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.libaodetail_game_name) public TextView libaoGameName;
@BindView(R.id.libaodetail_copy_btn) public TextView libaoCopyBtn;
@BindView(R.id.libaodetail_game_icon) public SimpleDraweeView libaoGameIcon;
@BindView(R.id.libaodetail_libaocode) public TextView libaoCode;
@BindView(R.id.libaodetail_libaocode_rv) public RecyclerView libaoCodeRv;
public LibaoDetailTopViewHolder(View itemView) {
super(itemView);

View File

@ -0,0 +1,31 @@
package com.gh.gamecenter.adapter.viewholder;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import com.gh.gamecenter.R;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* Created by khy on 2017/4/11.
* 投票ITEM
*/
public class VoteViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.vote_item_name)
public TextView name;
@BindView(R.id.vote_item_btn)
public TextView voteBtn;
@BindView(R.id.progressbar)
public View progressbar;
@BindView(R.id.vote_item_count)
public TextView count;
public VoteViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
}

View File

@ -11,7 +11,10 @@ import com.gh.gamecenter.db.info.ConcernInfo;
import com.gh.gamecenter.db.info.DataCollectionInfo;
import com.gh.gamecenter.db.info.FilterInfo;
import com.gh.gamecenter.db.info.GameInfo;
import com.gh.gamecenter.db.info.KeFuMarkReadInfo;
import com.gh.gamecenter.db.info.LibaoInfo;
import com.gh.gamecenter.db.info.MessageMarkReadInfo;
import com.gh.gamecenter.db.info.NoticeMarkReadInfo;
import com.gh.gamecenter.db.info.PackageInfo;
import com.gh.gamecenter.db.info.SearchHistoryInfo;
import com.gh.gamecenter.db.info.VoteInfo;
@ -25,7 +28,7 @@ import java.sql.SQLException;
public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static final String DATABASE_NAME = "gh_assist.db";
private static final int DATABASE_VERSION = 5;
private static final int DATABASE_VERSION = 6;
private static DatabaseHelper instance;
private ArrayMap<String, Dao> daos = new ArrayMap<>();
@ -65,6 +68,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
TableUtils.createTable(connectionSource, LibaoInfo.class);
TableUtils.createTable(connectionSource, AppRunTimeInfo.class);
TableUtils.createTable(connectionSource, PackageInfo.class);
TableUtils.createTable(connectionSource, MessageMarkReadInfo.class);
TableUtils.createTable(connectionSource, KeFuMarkReadInfo.class);
TableUtils.createTable(connectionSource, NoticeMarkReadInfo.class);
} catch (SQLException e) {
e.printStackTrace();
}
@ -84,6 +90,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
TableUtils.dropTable(connectionSource, LibaoInfo.class, true);
TableUtils.dropTable(connectionSource, AppRunTimeInfo.class, true);
TableUtils.dropTable(connectionSource, PackageInfo.class, true);
TableUtils.dropTable(connectionSource, MessageMarkReadInfo.class, true);
TableUtils.dropTable(connectionSource, KeFuMarkReadInfo.class, true);
TableUtils.dropTable(connectionSource, NoticeMarkReadInfo.class, true);
onCreate(database, connectionSource);
} catch (SQLException e) {
e.printStackTrace();

View File

@ -0,0 +1,52 @@
package com.gh.gamecenter.db;
import android.content.Context;
import com.gh.gamecenter.db.info.KeFuMarkReadInfo;
import com.j256.ormlite.dao.Dao;
import java.sql.SQLException;
/**
* Created by khy on 2017/4/19.
*/
public class KeFuMarkReadDao {
private DatabaseHelper helper;
private Dao<KeFuMarkReadInfo, String> dao;
public KeFuMarkReadDao(Context context) {
try {
helper = DatabaseHelper.getHelper(context);
dao = helper.getDao(KeFuMarkReadInfo.class);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* 添加一条记录
*/
public void add(KeFuMarkReadInfo keFuMarkReadInfo) {
try {
dao.create(keFuMarkReadInfo);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* 检查是否已读
*/
public boolean isMarkRead(String id) {
try {
if (dao.queryForId(id) != null) {
return true;
}
return false;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
}

View File

@ -2,10 +2,13 @@ package com.gh.gamecenter.db;
import android.content.Context;
import com.gh.common.util.Utils;
import com.gh.gamecenter.db.info.LibaoInfo;
import com.j256.ormlite.dao.Dao;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
/**
@ -69,6 +72,17 @@ public class LibaoDao {
}
}
/**
* 删除所有礼包
*/
public void deleteAll() {
try {
dao.delete(getAll());
} catch (SQLException e) {
e.printStackTrace();
}
}
public boolean isExist(String gameId) {
try {
List<LibaoInfo> list = dao.queryBuilder().where().eq("gameId", gameId).query();
@ -80,4 +94,64 @@ public class LibaoDao {
}
return false;
}
public List<LibaoInfo> findCodes(String libaoId) {
List<LibaoInfo> list = new ArrayList<>();
try {
list.addAll(dao.queryBuilder().where().eq("libaoId", libaoId).query());
return list;
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
/**
* 存在淘号礼包
*/
public boolean isExistTao(String libaoId) {
try {
List<LibaoInfo> id = dao.queryForAll();
for (LibaoInfo libaoInfo : id) {
if (libaoId.equals(libaoInfo.getId())) {
Utils.log(libaoId + "======"+ libaoInfo.getId() +"====" + libaoInfo.getStatus());
}
}
List<LibaoInfo> infos = dao.queryBuilder().where().eq("id", libaoId).and().gt("status", "tao").query();
if (infos.size() > 0) {
return true;
} else {
return false;
}
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
/**
* 礼包重复领取
* 一个礼包最后领取时间不是当天
*/
public boolean isCanLing(String libaoId, Context context) {
try {
List<LibaoInfo> infos = dao.queryBuilder().orderBy("time", false).where().eq("id", libaoId).query();
if (infos.size() > 0) {
LibaoInfo libaoInfo = infos.get(0);
SimpleDateFormat formatDay = new SimpleDateFormat("dd");
long lingTime = libaoInfo.getTime() * 1000;
long curTime = Utils.getTime(context) * 1000;
int lingDay = Integer.parseInt(formatDay.format(lingTime));
int curDay = Integer.parseInt(formatDay.format(curTime));
if (curTime > lingTime && curDay > lingDay) {
return true;
} else {
return false;
}
}
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
}

View File

@ -0,0 +1,89 @@
package com.gh.gamecenter.db;
import android.content.Context;
import com.gh.gamecenter.db.info.MessageMarkReadInfo;
import com.j256.ormlite.dao.Dao;
import java.sql.SQLException;
import java.util.List;
/**
* Created by khy on 2017/4/17.
*/
public class MessageMarkReadDao {
private DatabaseHelper helper;
private Dao<MessageMarkReadInfo, String> dao;
public MessageMarkReadDao(Context context) {
try {
helper = DatabaseHelper.getHelper(context);
dao = helper.getDao(MessageMarkReadInfo.class);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* 更新已读id添加id
*/
public void update(MessageMarkReadInfo readInfo) {
try {
dao.update(readInfo);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* 添加已读信息
*/
public void add(MessageMarkReadInfo readInfo) {
try {
dao.create(readInfo);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* 获取已读信息
*/
public List<MessageMarkReadInfo> getAll() {
try {
return dao.queryForAll();
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
public void cleanKeFu() {
try {
List<MessageMarkReadInfo> readInfos = dao.queryForAll();
if (readInfos != null && readInfos.size() > 0) {
MessageMarkReadInfo readInfo = readInfos.get(0);
readInfo.getKefuIds().clear();
dao.update(readInfo);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public void cleanNotice() {
try {
List<MessageMarkReadInfo> readInfos = dao.queryForAll();
if (readInfos != null && readInfos.size() > 0) {
MessageMarkReadInfo readInfo = readInfos.get(0);
readInfo.getNoticeIds().clear();
dao.update(readInfo);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,66 @@
package com.gh.gamecenter.db;
import android.content.Context;
import com.gh.gamecenter.db.info.NoticeMarkReadInfo;
import com.j256.ormlite.dao.Dao;
import java.sql.SQLException;
import java.util.List;
/**
* Created by khy on 2017/4/19.
*/
public class NoticeMarkReadDao {
private DatabaseHelper helper;
private Dao<NoticeMarkReadInfo, String> dao;
public NoticeMarkReadDao(Context context) {
try {
helper = DatabaseHelper.getHelper(context);
dao = helper.getDao(NoticeMarkReadInfo.class);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* 添加一条记录
*/
public void add(NoticeMarkReadInfo noticeMarkReadInfo) {
try {
dao.create(noticeMarkReadInfo);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* 检查是否已读
*/
public boolean isMarkRead(String id) {
try {
if (dao.queryForId(id) != null) {
return true;
}
return false;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
public List<NoticeMarkReadInfo> getAll() {
try {
List<NoticeMarkReadInfo> noticeMarkReadInfos = dao.queryForAll();
return noticeMarkReadInfos;
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
}

View File

@ -0,0 +1,39 @@
package com.gh.gamecenter.db.info;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import java.io.Serializable;
/**
* Created by khy on 2017/4/19.
*/
@DatabaseTable(tableName = "tb_kefu_markread")
public class KeFuMarkReadInfo implements Serializable{
@DatabaseField(id = true, columnName = "kefu_id")
private String kefuId;
public KeFuMarkReadInfo() {
}
public KeFuMarkReadInfo(String kefuId) {
this.kefuId = kefuId;
}
public String getKefuId() {
return kefuId;
}
public void setKefuId(String kefuId) {
this.kefuId = kefuId;
}
@Override
public String toString() {
return "KeFuMarkReadInfo{" +
"kefuId='" + kefuId + '\'' +
'}';
}
}

View File

@ -7,6 +7,7 @@ import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import java.io.Serializable;
import java.util.UUID;
/**
* Created by khy on 2016/12/18.
@ -15,7 +16,10 @@ import java.io.Serializable;
@DatabaseTable(tableName = "tb_libao")
public class LibaoInfo implements Serializable {
@DatabaseField(id = true, columnName = "libaoId")
@DatabaseField(id = true, columnName = "id")
private String id;
@DatabaseField(columnName = "libaoId")
private String libaoId;
@DatabaseField(columnName = "content")
@ -54,10 +58,21 @@ public class LibaoInfo implements Serializable {
@DatabaseField(columnName = "packName")
private String packName;
@DatabaseField(columnName = "time")
private long time; // 领取时间
public LibaoInfo() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPackName() {
return packName;
}
@ -162,6 +177,14 @@ public class LibaoInfo implements Serializable {
this.gameName = gameName;
}
public long getTime() {
return time;
}
public void setTime(long time) {
this.time = time;
}
public static LibaoInfo createLibaoInfo(LibaoEntity libaoEntity) {
LibaoInfo libaoInfo = new LibaoInfo();
if (TextUtils.isEmpty(libaoEntity.getId())) {
@ -169,6 +192,7 @@ public class LibaoInfo implements Serializable {
} else {
libaoInfo.setLibaoId(libaoEntity.getId());
}
libaoInfo.setId(UUID.randomUUID().toString().replaceAll("-", ""));
libaoInfo.setContent(libaoEntity.getContent());
libaoInfo.setIcon(libaoEntity.getIcon());
libaoInfo.setName(libaoEntity.getName());

View File

@ -0,0 +1,52 @@
package com.gh.gamecenter.db.info;
import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import java.io.Serializable;
import java.util.HashMap;
/**
* Created by khy on 2017/4/17.
*/
@DatabaseTable(tableName = "tb_message_markread")
public class MessageMarkReadInfo implements Serializable {
@DatabaseField(id = true, columnName = "commentId")
private String readId; // 固定值 100
@DatabaseField(columnName = "kefuIds", dataType = DataType.SERIALIZABLE)
private HashMap<String, Boolean> kefuIds;
@DatabaseField(columnName = "noticeIds", dataType = DataType.SERIALIZABLE)
private HashMap<String, Boolean> noticeIds;
public MessageMarkReadInfo() {
}
public String getReadId() {
return readId;
}
public void setReadId(String readId) {
this.readId = readId;
}
public HashMap<String, Boolean> getKefuIds() {
return kefuIds;
}
public void setKefuIds(HashMap<String, Boolean> kefuIds) {
this.kefuIds = kefuIds;
}
public HashMap<String, Boolean> getNoticeIds() {
return noticeIds;
}
public void setNoticeIds(HashMap<String, Boolean> noticeIds) {
this.noticeIds = noticeIds;
}
}

View File

@ -0,0 +1,157 @@
package com.gh.gamecenter.db.info;
import com.gh.gamecenter.entity.MessageNoticeEntity;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import java.io.Serializable;
/**
* Created by khy on 2017/4/18.
*/
@DatabaseTable(tableName = "tb_message_notice")
public class MessageNoticeInfo implements Serializable{
@DatabaseField(id = true, columnName = "id")
private String id;
@DatabaseField(columnName = "isRead")
private boolean isRead;
@DatabaseField(columnName = "message")
private String message;
@DatabaseField(columnName = "time")
private long time;
@DatabaseField(columnName = "suggestion")
private String suggestion;
@DatabaseField(columnName = "document")
private String document;
@DatabaseField(columnName = "linkId")
private String linkId;
@DatabaseField(columnName = "linkType")
private String linkType;
@DatabaseField(columnName = "url")
private String url;
@DatabaseField(columnName = "qq")
private String qq;
@DatabaseField(columnName = "key")
private String key;
public MessageNoticeInfo() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public boolean isRead() {
return isRead;
}
public void setRead(boolean read) {
isRead = read;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public long getTime() {
return time;
}
public void setTime(long time) {
this.time = time;
}
public String getLinkId() {
return linkId;
}
public void setLinkId(String linkId) {
this.linkId = linkId;
}
public String getLinkType() {
return linkType;
}
public void setLinkType(String linkType) {
this.linkType = linkType;
}
public String getSuggestion() {
return suggestion;
}
public void setSuggestion(String suggestion) {
this.suggestion = suggestion;
}
public String getDocument() {
return document;
}
public void setDocument(String document) {
this.document = document;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getQq() {
return qq;
}
public void setQq(String qq) {
this.qq = qq;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public static MessageNoticeInfo createMessageNoticeInfo(MessageNoticeEntity noticeEntity) {
MessageNoticeInfo noticeInfo = new MessageNoticeInfo();
noticeInfo.setId(noticeEntity.getId());
noticeInfo.setRead(noticeEntity.isRead());
noticeInfo.setMessage(noticeEntity.getMessage());
noticeInfo.setTime(noticeEntity.getTime());
if (noticeEntity.getLink() != null) {
noticeInfo.setLinkId(noticeEntity.getLink().getId());
noticeInfo.setLinkType(noticeEntity.getLink().getType());
noticeInfo.setKey(noticeEntity.getLink().getKey());
noticeInfo.setUrl(noticeEntity.getLink().getUrl());
noticeInfo.setQq(noticeEntity.getLink().getQq());
noticeInfo.setDocument(noticeEntity.getLink().getDocument());
}
return noticeInfo;
}
}

View File

@ -0,0 +1,37 @@
package com.gh.gamecenter.db.info;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
/**
* Created by khy on 2017/4/19.
*/
@DatabaseTable(tableName = "tb_notice_markread")
public class NoticeMarkReadInfo {
@DatabaseField(id = true, columnName = "notice_id")
private String noticeId;
public NoticeMarkReadInfo() {
}
public NoticeMarkReadInfo(String noticeId) {
this.noticeId = noticeId;
}
public String getNoticeId() {
return noticeId;
}
public void setNoticeId(String noticeId) {
this.noticeId = noticeId;
}
@Override
public String toString() {
return "NoticeMarkReadInfo{" +
"noticeId='" + noticeId + '\'' +
'}';
}
}

View File

@ -20,15 +20,12 @@ import com.gh.common.constant.Constants;
import com.gh.common.util.BitmapUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.FileUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.NetworkUtils;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.PlatformUtils;
import com.gh.common.util.SpeedUtils;
import com.gh.common.view.CardLinearLayout;
import com.gh.common.view.CardRelativeLayout;
import com.gh.download.DownloadEntity;
import com.gh.download.DownloadManager;
import com.gh.download.DownloadStatus;
@ -112,54 +109,18 @@ class GameDownloadFragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
if (doneList.size() != 0 && position > 0 && position <= doneList.size()) {
downloadEntity = doneList.get(position - 1);
// // 第一个
// if (position == 1) {
// ((CardLinearLayout) holder.itemView).setmTop(DisplayUtils.dip2px(context, 8));
// } else {
// ((CardLinearLayout) holder.itemView).setmTop(0);
// }
// 最后一个
if (position == doneList.size() && downloadingList.size() != 0) {
((CardLinearLayout) holder.itemView).setBottom(false);
((CardLinearLayout) holder.itemView).setmBottom(0);
viewHolder.dm_item_line.setVisibility(View.GONE);
} else {
((CardLinearLayout) holder.itemView).setBottom(true);
((CardLinearLayout) holder.itemView).setmBottom(cardMargin);
viewHolder.dm_item_line.setVisibility(View.VISIBLE);
}
} else if (doneList.isEmpty()) {
downloadEntity = downloadingList.get(position - 1);
// // 第一个
// if (position == 1) {
// ((CardLinearLayout) holder.itemView).setmTop(DisplayUtils.dip2px(context, 8));
// } else {
// ((CardLinearLayout) holder.itemView).setmTop(0);
// }
// 最后一个
if (position == downloadingList.size()) {
((CardLinearLayout) holder.itemView).setBottom(true);
} else {
((CardLinearLayout) holder.itemView).setBottom(false);
}
((CardLinearLayout) holder.itemView).setmBottom(cardMargin);
viewHolder.dm_item_line.setVisibility(View.VISIBLE);
} else {
downloadEntity = downloadingList.get(position - doneList.size() - 2);
// // 第一个
// if (position - doneList.size() - 2 == 0) {
// ((CardLinearLayout) holder.itemView).setmTop(DisplayUtils.dip2px(context, 8));
// } else {
// ((CardLinearLayout) holder.itemView).setmTop(0);
// }
// 最后一个
if (position - doneList.size() - 1 == downloadingList.size()) {
((CardLinearLayout) holder.itemView).setBottom(true);
} else {
((CardLinearLayout) holder.itemView).setBottom(false);
}
((CardLinearLayout) holder.itemView).setmBottom(cardMargin);
viewHolder.dm_item_line.setVisibility(View.VISIBLE);
}
String icon = downloadEntity.getIcon();
@ -398,18 +359,18 @@ class GameDownloadFragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
} else if (holder instanceof DownloadHeadViewHolder) {
final DownloadHeadViewHolder viewHolder = (DownloadHeadViewHolder) holder;
if (position == 0 && doneList.size() != 0) {
CardRelativeLayout cardRelativeLayout = (CardRelativeLayout) viewHolder.itemView;
cardRelativeLayout.setmBottom(DisplayUtils.dip2px(context, 8));
// CardRelativeLayout cardRelativeLayout = (CardRelativeLayout) viewHolder.itemView;
// cardRelativeLayout.setmBottom(DisplayUtils.dip2px(context, 8));
viewHolder.dm_item_head_tv_task.setText("已完成");
viewHolder.dm_item_head_tv_allstart.setVisibility(View.GONE);
} else {
CardRelativeLayout cardRelativeLayout = (CardRelativeLayout) viewHolder.itemView;
if (doneList.isEmpty()) {
cardRelativeLayout.setmTop(0);
} else {
cardRelativeLayout.setmTop(DisplayUtils.dip2px(context, 8));
}
cardRelativeLayout.setmBottom(DisplayUtils.dip2px(context, 8));
// CardRelativeLayout cardRelativeLayout = (CardRelativeLayout) viewHolder.itemView;
// if (doneList.isEmpty()) {
// cardRelativeLayout.setmTop(0);
// } else {
// cardRelativeLayout.setmTop(DisplayUtils.dip2px(context, 8));
// }
// cardRelativeLayout.setmBottom(DisplayUtils.dip2px(context, 8));
viewHolder.dm_item_head_tv_task.setText("下载中");
viewHolder.dm_item_head_tv_allstart.setVisibility(View.VISIBLE);

View File

@ -15,15 +15,12 @@ import android.widget.LinearLayout;
import com.gh.common.util.DataCollectionUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.FileUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.MD5Utils;
import com.gh.common.util.NetworkUtils;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.PlatformUtils;
import com.gh.common.view.CardLinearLayout;
import com.gh.common.view.CardRelativeLayout;
import com.gh.download.DownloadEntity;
import com.gh.download.DownloadManager;
import com.gh.download.DownloadStatus;
@ -306,9 +303,9 @@ class GameUpdateFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
}
}
}
CardRelativeLayout cardRelativeLayout = (CardRelativeLayout) viewHolder.itemView;
cardRelativeLayout.setmBottom(DisplayUtils.dip2px(context, 8));
cardRelativeLayout.setmTop(0);
// CardRelativeLayout cardRelativeLayout = (CardRelativeLayout) viewHolder.itemView;
// cardRelativeLayout.setmBottom(DisplayUtils.dip2px(context, 8));
// cardRelativeLayout.setmTop(0);
viewHolder.dm_item_head_tv_task.setText("" + updateList.size() + "个游戏可更新,需" + getSize(size));
if (done == updateList.size()) {
@ -376,12 +373,12 @@ class GameUpdateFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
// ((CardLinearLayout) holder.itemView).setmTop(0);
// }
// 最后一个
if (position == updateList.size()) {
((CardLinearLayout) holder.itemView).setBottom(true);
} else {
((CardLinearLayout) holder.itemView).setBottom(false);
}
// // 最后一个
// if (position == updateList.size()) {
// ((CardLinearLayout) holder.itemView).setBottom(true);
// } else {
// ((CardLinearLayout) holder.itemView).setBottom(false);
// }
if (updateEntity.getName().contains("光环助手")) {
viewHolder.gu_item_iv_icon.setImageURI(Uri.parse("res:///" + R.drawable.logo));

Some files were not shown because too many files have changed in this diff Show More