去除volley 中TAG的滥用导致无法重复加载同一url,项目整理

This commit is contained in:
huangzhuanghua
2016-11-29 10:49:45 +08:00
parent 47f978a4fa
commit a31d2cd28b
80 changed files with 461 additions and 610 deletions

View File

@ -19,8 +19,6 @@ package com.android.volley;
import android.os.Handler;
import android.os.Looper;
import com.gh.common.util.Utils;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
@ -206,9 +204,6 @@ public class RequestQueue {
cancelAll(new RequestFilter() {
@Override
public boolean apply(Request<?> request) {
Utils.log("111" + request.getTag().toString());
Utils.log("111" + tag);
Utils.log("111" + (request.getTag() == tag));
return request.getTag() == tag;
}
});

View File

@ -162,14 +162,6 @@ public class AppController extends Application {
getInstance().addRequest(request);
}
public static <T> void addToRequestQueue(Request<T> request, String tag) {
if (TextUtils.isEmpty(tag)) {
tag = TAG;
}
request.setTag(tag);
getInstance().addRequest(request);
}
public static void canclePendingRequests(String tag) {
if (TextUtils.isEmpty(tag)) {
tag = TAG;

View File

@ -41,8 +41,9 @@ import java.util.Map;
/**
* Created by Administrator on 2016/9/19.
* 游戏详情新闻详情基类控制底部下载栏
*/
public abstract class DetailActivity extends BaseActivity implements View.OnClickListener {
public abstract class BaseDetailActivity extends BaseActivity implements View.OnClickListener {
protected TextView actionbar_tv_title;
protected RecyclerView detail_rv_show;
@ -71,7 +72,7 @@ public abstract class DetailActivity extends BaseActivity implements View.OnClic
if (gameEntity != null && gameEntity.getApk().size() == 1) {
String url = gameEntity.getApk().get(0).getUrl();
if (url.equals(downloadEntity.getUrl())) {
if (!"pause".equals(DownloadManager.getInstance(DetailActivity.this).
if (!"pause".equals(DownloadManager.getInstance(BaseDetailActivity.this).
getStatus(downloadEntity.getUrl()))) {
mDownloadEntity = downloadEntity;
invalidate();
@ -393,7 +394,7 @@ public abstract class DetailActivity extends BaseActivity implements View.OnClic
Map<String, Object> kv = new HashMap<>();
kv.put("版本", gameEntity.getApk().get(0).getPlatform());
kv.put("页面", name);
DataUtils.onEvent(DetailActivity.this, "游戏启动", gameEntity.getName(), kv);
DataUtils.onEvent(BaseDetailActivity.this, "游戏启动", gameEntity.getName(), kv);
PackageUtils.launchApplicationByPackageName(this, gameEntity.getApk().get(0).getPackageName());
} else {
@ -411,19 +412,19 @@ public abstract class DetailActivity extends BaseActivity implements View.OnClic
Map<String, Object> kv = new HashMap<>();
kv.put("版本", apkEntity.getPlatform());
kv.put("状态", "下载开始");
DataUtils.onEvent(DetailActivity.this, "游戏下载", gameEntity.getName(), kv);
DataUtils.onEvent(BaseDetailActivity.this, "游戏下载", gameEntity.getName(), kv);
Map<String, Object> kv2 = new HashMap<>();
kv2.put("版本", apkEntity.getPlatform());
kv2.put("状态", "下载开始");
kv2.put("页面", name);
kv2.put("位置", entrance);
DataUtils.onEvent(DetailActivity.this, "游戏下载位置", gameEntity.getName(), kv2);
DataUtils.onEvent(BaseDetailActivity.this, "游戏下载位置", gameEntity.getName(), kv2);
Map<String, Object> kv3 = new HashMap<>();
kv3.put(entrance, "下载数");
kv3.put(entrance, "下载开始");
DataUtils.onEvent(DetailActivity.this, "应用数据", gameEntity.getName(), kv3);
DataUtils.onEvent(BaseDetailActivity.this, "应用数据", gameEntity.getName(), kv3);
Map<String, Object> map = new HashMap<>();
map.put("game", gameEntity.getName());
@ -446,7 +447,7 @@ public abstract class DetailActivity extends BaseActivity implements View.OnClic
detail_pb_progressbar.setProgress(0);
detail_tv_per.setText("0.0%");
DownloadManager.getInstance(DetailActivity.this).putStatus(apkEntity.getUrl(), "downloading");
DownloadManager.getInstance(BaseDetailActivity.this).putStatus(apkEntity.getUrl(), "downloading");
} else {
toast(msg);
}

View File

@ -15,7 +15,7 @@ import java.util.List;
/**
* Created by khy on 2016/11/8.
*
* 初始化z资讯关注-内容图片
* 初始化资讯关注-内容图片
*
**/
public class ConcernContentUtils {

View File

@ -1,8 +1,12 @@
package com.gh.common.util;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.security.KeyStore;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
@ -11,6 +15,7 @@ import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
/**
@ -26,7 +31,6 @@ public class HttpsUtils {
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
}
@ -42,7 +46,6 @@ public class HttpsUtils {
public boolean verify(String hostname, SSLSession session) {
return true;
}
}
private static SSLSocketFactory mSSLSocketFactory;
@ -53,8 +56,12 @@ public class HttpsUtils {
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null, new TrustManager[]{new MyTrustManager()}, new SecureRandom());
mSSLSocketFactory = sc.getSocketFactory();
// SSLContext sslContext = SSLContext.getInstance("TLS");
// sslContext.init(null, null, null);
// mSSLSocketFactory = sslContext.getSocketFactory();
mHostnameVerifier = new MyHostnameVerifier();
// mHostnameVerifier = OkHostnameVerifier.INSTANCE;
HttpsURLConnection.setDefaultSSLSocketFactory(mSSLSocketFactory);
HttpsURLConnection.setDefaultHostnameVerifier(mHostnameVerifier);
@ -62,4 +69,30 @@ public class HttpsUtils {
return (HttpsURLConnection) url.openConnection();
}
public SSLSocketFactory setCertificates(InputStream is) {
try {
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null);
keyStore.setCertificateEntry("0", certificateFactory.generateCertificate(is));
SSLContext sslContext = SSLContext.getInstance("TLS");
TrustManagerFactory trustManagerFactory =
TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init(keyStore);
sslContext.init(null, trustManagerFactory.getTrustManagers(), new SecureRandom());
return sslContext.getSocketFactory();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return null;
}
}

View File

@ -73,28 +73,19 @@ public class PackageUtils {
}
/*
* 判断是否可以更新
* 判断是否可以更新只判断gh_version的大小
*/
public static boolean isCanUpdate(Context context, GameUpdateEntity gameUpdateEntity) {
// 判断是否gh_version是否相同
// 判断是否gh_version是否存在
String gh_version = (String) PackageUtils.getMetaData(
context, gameUpdateEntity.getPackageName(), "gh_version");
if (gh_version != null) {
gh_version = gh_version.substring(2);
// 判断gh_version是否相同
if (gh_version.equals(gameUpdateEntity.getGhVersion())) {
// 判断version是否相同
String version = PackageUtils.getVersionByPackage(
context, gameUpdateEntity.getPackageName());
if (version != null && version.equals(gameUpdateEntity.getVersion())) {
// 版本相同,无需显示插件更新,继续查看是否有可更新的游戏包
return false;
}
}
// 判断gh_version的大小
return Long.parseLong(gh_version) < Long.parseLong(gameUpdateEntity.getGhVersion());
} else {
return false;
}
return true;
}
/*
@ -102,10 +93,7 @@ public class PackageUtils {
*/
public static boolean isSignature(Context context, String packageName) {
String signature = getApkSignatureByPackageName(context, packageName);
if (publicKey.equals(signature)) {
return true;
}
return false;
return publicKey.equals(signature);
}
/*

View File

@ -18,8 +18,12 @@ import org.json.JSONObject;
*/
public class PostCommentUtils {
public static void addCommentData(final String url, final String content, final Context context,
final PostCommentListener listener) {
public static void addCommentData(Context context, String url, String content, PostCommentListener listener) {
addCommentData(context, url, content, true, listener);
}
public static void addCommentData(final Context context, final String url, final String content,
final boolean isCheck, final PostCommentListener listener) {
new Thread(new Runnable() {
@Override
public void run() {
@ -36,8 +40,7 @@ public class PostCommentUtils {
@Override
public void onErrorResponse(VolleyError error) {
if (error.networkResponse != null && error.networkResponse.statusCode == 401) {
TokenUtils.getToken(context, false);
addCommentData(url, content, context, listener);
addCommentData(context, url, content, false, listener);
return;
}
if (listener != null){
@ -46,13 +49,17 @@ public class PostCommentUtils {
}
});
request.setShouldCache(false);
request.addHeader("TOKEN", TokenUtils.getToken(context));
request.addHeader("TOKEN", TokenUtils.getToken(context, isCheck));
AppController.addToRequestQueue(request);
}
}).start();
}
public static void addCommentVoto(final String newsId, final Context context) {
public static void addCommentVoto(final Context context, final String newsId) {
addCommentVoto(context, newsId, true);
}
public static void addCommentVoto(final Context context, final String newsId, final boolean isCheck) {
new Thread(new Runnable() {
@Override
public void run() {
@ -63,13 +70,12 @@ public class PostCommentUtils {
@Override
public void onErrorResponse(VolleyError error) {
if (error.networkResponse != null && error.networkResponse.statusCode == 401) {
TokenUtils.getToken(context, false);
addCommentVoto(newsId, context);
addCommentVoto(context, newsId, false);
}
}
});
request.setShouldCache(false);
request.addHeader("TOKEN", TokenUtils.getToken(context));
request.addHeader("TOKEN", TokenUtils.getToken(context, isCheck));
AppController.addToRequestQueue(request);
}
}).start();

View File

@ -85,8 +85,8 @@ public class RunningUtils {
.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningTaskInfo> infos = activityManager.getRunningTasks(100);
for (RunningTaskInfo info : infos) {
if (info.topActivity.getPackageName().equals(
context.getPackageName())) {
if (info.topActivity.getPackageName().equals(context.getPackageName())
&& info.baseActivity.getPackageName().equals(context.getPackageName())) {
return true;
}
}

View File

@ -49,6 +49,8 @@ public class TimestampUtils {
intervalMap.put("^" + Config.HOST + "support/setting/platform" + "$", 120);
intervalMap.put("^" + Config.HOST + "update/package/.+" + "$", 125);
intervalMap.put("^" + Config.HOST + "update/game/.+/package/.+" + "$", 130);
intervalMap.put("^" + Config.COMMENT_HOST + "article/.+/comment\\?limit=10\\&offset=.+" + "$", 135);
intervalMap.put("^" + Config.COMMENT_HOST + "article/.+/comment\\?order=hot\\&limit=10\\&offset=.+" + "$", 140);
}
private static void initCDMap() {
@ -79,6 +81,8 @@ public class TimestampUtils {
cdMap.put("^" + Config.HOST + "support/setting/platform" + "$", Constants.PLATFORM_CD);
cdMap.put("^" + Config.HOST + "update/package/.+" + "$", Constants.UPDATE_CD);
cdMap.put("^" + Config.HOST + "update/game/.+/package/.+" + "$", Constants.UPDATE_CD);
cdMap.put("^" + Config.COMMENT_HOST + "article/.+/comment\\?limit=10\\&offset=.+" + "$", Constants.COMMENT_CD);
cdMap.put("^" + Config.COMMENT_HOST + "article/.+/comment\\?order=hot\\&limit=10\\&offset=.+" + "$", Constants.COMMENT_CD);
cdMap.put("^" + Config.HOST + "device/.+/concern" + "$", 0);
cdMap.put("^" + Config.HOST + "device/.+/concern/.+" + "$", 0);
cdMap.put("^" + Config.HOST + "stat/download" + "$", 0);

View File

@ -123,6 +123,9 @@ public class DownloadTask implements DownloadListener {
|| status == DownloadStatus.notfound) {
entry.setProgress(0);
entry.setPercent(0);
if (status == DownloadStatus.hijack) {
entry.setError(error);
}
FileUtils.deleteFile(entry.getPath());
DownloadDao.getInstance(context).delete(entry.getUrl());
Utils.log(DownloadTask.class.getSimpleName(),

View File

@ -86,7 +86,7 @@ public class DownloadThread extends Thread {
//链接被劫持,抛出异常
Utils.log("eTag = " + eTag);
Utils.log("eTag2 = " + eTag2);
listener.onStatusChanged(DownloadStatus.hijack);
listener.onStatusChanged(DownloadStatus.hijack, connection.getURL().toString());
Utils.log(DownloadThread.class.getSimpleName(), "error-->链接被劫持");
return;
}

View File

@ -8,7 +8,6 @@ import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import com.gh.base.AppController;
import com.gh.base.BaseActivity;
import com.gh.common.constant.Config;
import com.gh.common.util.ConcernUtils;
@ -28,8 +27,6 @@ import java.util.List;
public class ConcernActivity extends BaseActivity implements OnClickListener {
public static final String TAG = ConcernActivity.class.getSimpleName();
private Concern_LinearLayout view;
private RecyclerView concern_rv_show, concern_rv_recommend;
private ConcernAdapter concernAdapter;
@ -210,7 +207,6 @@ public class ConcernActivity extends BaseActivity implements OnClickListener {
@Override
protected void onDestroy() {
super.onDestroy();
AppController.canclePendingRequests(TAG);
String uuid = TokenUtils.getDeviceId(this);
JSONArray data = new JSONArray();
for (ConcernInfo concernInfo : concernManager.getConcernGame()) {

View File

@ -10,11 +10,11 @@ import android.widget.RelativeLayout;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.gh.base.AppController;
import com.gh.base.DetailActivity;
import com.gh.base.BaseDetailActivity;
import com.gh.common.constant.Config;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DialogUtils;
import com.gh.gamecenter.changeskin.InitChangeSkinUtils;
import com.gh.gamecenter.changeskin.ChangeSkinUtils;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.eventbus.EBConcernChanged;
import com.gh.gamecenter.gamedetail.GameDetailAdapter;
@ -30,9 +30,7 @@ import java.util.Map;
/**
* Created by khy on 2016/8/12.
*/
public class GameDetailActivity extends DetailActivity implements View.OnClickListener{
public static final String TAG = GameDetailActivity.class.getSimpleName();
public class GameDetailActivity extends BaseDetailActivity implements View.OnClickListener{
private GameDetailAdapter adapter;
@ -176,7 +174,7 @@ public class GameDetailActivity extends DetailActivity implements View.OnClickLi
reuse_no_connection.setVisibility(View.VISIBLE);
}
});
AppController.addToRequestQueue(request, TAG);
AppController.addToRequestQueue(request);
}
// 关注事件
@ -224,15 +222,9 @@ public class GameDetailActivity extends DetailActivity implements View.OnClickLi
}
}
@Override
protected void onDestroy() {
super.onDestroy();
AppController.canclePendingRequests(TAG);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0 && InitChangeSkinUtils.isChecking) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0 && ChangeSkinUtils.isChecking) {
DialogUtils.showWarningDialog(GameDetailActivity.this, "退出提示",
"素材更新还在检测中,如果强行退出会中断所有进度,确定退出?",
"取消", "强行退出", new DialogUtils.ConfiremListener() {

View File

@ -11,7 +11,6 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.gh.base.AppController;
import com.gh.base.BaseActivity;
import com.gh.common.util.DisplayUtils;
import com.gh.gamecenter.adapter.GameNewsAdapter;
@ -25,8 +24,6 @@ import java.util.ArrayList;
*/
public class GameNewsActivity extends BaseActivity implements View.OnClickListener{
public static final String TAG = GameNewsActivity.class.getSimpleName();
private GameNewsAdapter adapter;
private GameNewsTypeListAdapter typeListAdapter;
@ -148,12 +145,6 @@ public class GameNewsActivity extends BaseActivity implements View.OnClickListen
typeListAdapter.setNewsType(change.getType(), change.getPosition());
}
@Override
protected void onDestroy() {
super.onDestroy();
AppController.canclePendingRequests(TAG);
}
@Override
public void onClick(View v) {
if (v == ivSearch){

View File

@ -131,6 +131,7 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
private boolean isShowDownload = false;
private boolean isNewFirstLaunch;
private boolean isSkipped;
private Handler handler = new Handler();
@ -442,6 +443,7 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("currentTab", currentTab);
outState.putBoolean("isSkipped", isSkipped);
}
@Override
@ -461,9 +463,12 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
sp = getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
isNewFirstLaunch = sp.getBoolean("isNewFirstLaunchV" + PackageUtils.getVersion(getApplicationContext()), true);
isSkipped = false;
initViews();
if (savedInstanceState != null) {
currentTab = savedInstanceState.getInt("currentTab");
isSkipped = savedInstanceState.getBoolean("isSkipped");
} else if (isNewFirstLaunch) {
currentTab = 1;
} else {
@ -1028,8 +1033,9 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
Runnable runnable = new Runnable() {
@Override
public void run() {
//TODO 重复跳转问题
if (getIntent() != null && getIntent().getExtras() != null) {
if (getIntent() != null && getIntent().getExtras() != null
&& !isSkipped) {
isSkipped = true;
String to = getIntent().getExtras().getString("to");
if(!TextUtils.isEmpty(to)){
Class<?> clazz = intentClass(to);

View File

@ -6,6 +6,7 @@ import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
@ -17,6 +18,7 @@ import android.widget.Toast;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.DiskBasedCache;
import com.facebook.drawee.view.SimpleDraweeView;
import com.gh.base.AppController;
import com.gh.base.BaseActivity;
import com.gh.common.constant.Config;
import com.gh.common.util.GzipUtils;
@ -36,8 +38,6 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.util.Date;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
@ -69,6 +69,12 @@ public class MessageDetailActivity extends BaseActivity {
private CommentDao mCommentDao;
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
AppController.put("ConcernEntity", adapter.getConcernEntity());
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -104,7 +110,7 @@ public class MessageDetailActivity extends BaseActivity {
});
//检查sp是否有用户信息
if (sp.getString("user_name", null) == null || sp.getString("user_name" , null).isEmpty()) {
if (TextUtils.isEmpty(sp.getString("user_name", null))) {
new Thread(new Runnable() {
@Override
public void run() {
@ -119,7 +125,6 @@ public class MessageDetailActivity extends BaseActivity {
});
}
}).start();
} else {
mMessageDetailIconDv.setImageURI(sp.getString("user_icon", "res:///"+
R.drawable.user_default_icon_comment));
@ -198,8 +203,9 @@ public class MessageDetailActivity extends BaseActivity {
}
final String newsId = adapter.getNewsId();
PostCommentUtils.addCommentData(Config.COMMENT_HOST + "article/" + newsId + "/comment"
, jsonObject.toString(), MessageDetailActivity.this, new PostCommentUtils.PostCommentListener() {
PostCommentUtils.addCommentData(MessageDetailActivity.this,
Config.COMMENT_HOST + "article/" + newsId + "/comment", jsonObject.toString(),
new PostCommentUtils.PostCommentListener() {
@Override
public void postSucced(JSONObject response) {
mToast.cancel();

View File

@ -19,7 +19,7 @@ import com.android.volley.Response;
import com.android.volley.TimeoutError;
import com.android.volley.VolleyError;
import com.gh.base.AppController;
import com.gh.base.DetailActivity;
import com.gh.base.BaseDetailActivity;
import com.gh.common.constant.Config;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DisplayUtils;
@ -42,9 +42,7 @@ import java.util.Map;
*
* @author 黄壮华
*/
public class NewsDetailActivity extends DetailActivity implements OnClickListener {
public static final String TAG = NewsDetailActivity.class.getSimpleName();
public class NewsDetailActivity extends BaseDetailActivity implements OnClickListener {
private NewsDetailAdapter adapter;
@ -261,7 +259,7 @@ public class NewsDetailActivity extends DetailActivity implements OnClickListene
}
}
});
AppController.addToRequestQueue(request, TAG);
AppController.addToRequestQueue(request);
}
private long[] mHits = new long[2];
@ -344,7 +342,7 @@ public class NewsDetailActivity extends DetailActivity implements OnClickListene
}
}
}, null);
AppController.addToRequestQueue(gameRequest, TAG);
AppController.addToRequestQueue(gameRequest);
}
// 关注事件
@ -417,10 +415,4 @@ public class NewsDetailActivity extends DetailActivity implements OnClickListene
}
}
@Override
protected void onDestroy() {
super.onDestroy();
AppController.canclePendingRequests(TAG);
}
}

View File

@ -44,11 +44,10 @@ import java.util.Map;
/**
* Created by khy on 2016/8/22.
* 新闻搜索界面
*/
public class NewsSearchActivity extends BaseActivity {
public static final String TAG = NewsSearchActivity.class.getSimpleName();
private RecyclerView gamedetail_news_rv;
private List<NewsEntity> newsEntities;
private NewsSearchAdapter searchAdapter;
@ -221,7 +220,7 @@ public class NewsSearchActivity extends BaseActivity {
searchAdapter.notifyItemChanged(searchAdapter.getItemCount() - 1);
}
});
AppController.addToRequestQueue(request, TAG);
AppController.addToRequestQueue(request);
}
private void removeDuplicateData(ArrayList<NewsEntity> newsList) {
@ -241,12 +240,6 @@ public class NewsSearchActivity extends BaseActivity {
}
}
@Override
protected void onDestroy() {
super.onDestroy();
AppController.canclePendingRequests(TAG);
}
public class NewsSearchAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
@Override
public int getItemViewType(int position) {

View File

@ -7,7 +7,6 @@ import android.view.View;
import android.widget.LinearLayout;
import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
import com.gh.base.AppController;
import com.gh.base.BaseActivity;
import com.gh.common.util.DownloadItemUtils;
import com.gh.download.DataWatcher;
@ -24,11 +23,10 @@ import java.util.List;
/**
* Created by LGT on 2016/7/6.
* 可插件化界面
*/
public class PluginActivity extends BaseActivity {
public static final String TAG = PluginActivity.class.getSimpleName();
private RecyclerView plugin_list;
private PluginAdapter adapter;
private ProgressBarCircularIndeterminate plugin_pb_loading;
@ -165,9 +163,4 @@ public class PluginActivity extends BaseActivity {
DownloadManager.getInstance(this).addObserver(dataWatcher);
}
@Override
protected void onDestroy() {
super.onDestroy();
AppController.canclePendingRequests(TAG);
}
}

View File

@ -65,8 +65,6 @@ import de.greenrobot.event.EventBus;
*/
public class SettingActivity extends BaseActivity implements OnClickListener {
public static final String TAG = SettingActivity.class.getSimpleName();
private SwitchButton setting_sb_autoinstall, setting_sb_autodelete,
setting_sb_deletedata, setting_sb_autoupdate, setting_sb_concerngame;
private TextView setting_tv_version, app_tv_speed, app_tv_percent,
@ -409,8 +407,7 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
appEntity = gson.fromJson(response.toString(),
AppEntity.class);
float version = Float.valueOf(appEntity
.getVersion());
float version = Float.valueOf(appEntity.getVersion());
float currentVersion = Float.valueOf(PackageUtils.getVersion(getApplicationContext()));
if (version > currentVersion) {
@ -450,7 +447,7 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
toast("检查更新失败");
}
});
AppController.addToRequestQueue(request, TAG);
AppController.addToRequestQueue(request);
}
private void showUpdateDialog(final String md5) {
@ -472,10 +469,7 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
@Override
public void onClick(View v) {
if (appEntity.isForce()) {
Intent data = new Intent();
data.putExtra("isForce", true);
setResult(RESULT_OK, data);
finish();
AppController.getInstance().finishActivity();
} else {
updateDialog.dismiss();
}
@ -525,10 +519,7 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
DownloadManager.getInstance(getApplicationContext()).cancel(
appEntity.getUrl());
if (appEntity.isForce()) {
Intent data = new Intent();
data.putExtra("isForce", true);
setResult(RESULT_OK, data);
finish();
AppController.getInstance().finishActivity();
} else {
downloadDialog.dismiss();
isShowDownload = false;
@ -586,7 +577,7 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
StringExtendedRequest request = new StringExtendedRequest(Request.Method.POST, url, null, null);
request.setParams(params);
request.setShouldCache(false);
AppController.addToRequestQueue(request, TAG);
AppController.addToRequestQueue(request);
Utils.log("提交更新数据" + new JSONObject(params).toString());
}
@ -609,6 +600,5 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
protected void onDestroy() {
saveCurrentSetting();
super.onDestroy();
AppController.canclePendingRequests(TAG);
}
}

View File

@ -1,10 +1,12 @@
package com.gh.gamecenter;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import com.gh.base.BaseActivity;
import com.gh.common.util.PlatformUtils;
import com.gh.common.util.RunningUtils;
/**
@ -59,7 +61,11 @@ public class SkipActivity extends BaseActivity {
intent.putExtra("id", id);
intent.putExtra("name", getIntent().getData().getQueryParameter("name"));
} else if ("suggestion".equals(host)) {
intent.putExtra("content", getIntent().getData().getQueryParameter("content"));
Uri uri = getIntent().getData();
String content = "" + uri.getQueryParameter("game_name")
+ "-" + PlatformUtils.getInstance(this).getPlatformName(uri.getQueryParameter("platform"))
+ "-V" + uri.getQueryParameter("version") + "";
intent.putExtra("content", content);
intent.putExtra("to", "SuggestionActivity");
}
}

View File

@ -7,7 +7,6 @@ import android.view.View;
import android.widget.LinearLayout;
import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
import com.gh.base.AppController;
import com.gh.base.BaseActivity;
import com.gh.common.util.DownloadItemUtils;
import com.gh.download.DataWatcher;

View File

@ -41,8 +41,6 @@ import java.util.regex.Pattern;
* */
public class SuggestionActivity extends BaseActivity implements OnClickListener {
public static final String TAG = SuggestionActivity.class.getSimpleName();
private TextView tv_suggest_connectway;
private EditText et_suggest_content, et_suggest_connectway;
private CardView btn_suggest_post;
@ -86,6 +84,12 @@ public class SuggestionActivity extends BaseActivity implements OnClickListener
}
});
String content = getIntent().getStringExtra("content");
if (!TextUtils.isEmpty(content)) {
et_suggest_content.setText(content);
et_suggest_content.setSelection(et_suggest_content.getText().length());
}
}
@Override
@ -223,7 +227,7 @@ public class SuggestionActivity extends BaseActivity implements OnClickListener
}
});
request.setShouldCache(false);
AppController.addToRequestQueue(request, TAG);
AppController.addToRequestQueue(request);
}
private boolean isEmailAddress(String email) {

View File

@ -92,7 +92,7 @@ public class ConcernAdapter extends RecyclerView.Adapter<ConcernViewHolder> {
}
}
});
AppController.addToRequestQueue(concernObjectRequest, ConcernActivity.TAG);
AppController.addToRequestQueue(concernObjectRequest);
}
}

View File

@ -98,7 +98,7 @@ public class ConcernRecommendAdapter extends RecyclerView.Adapter<ConcernViewHol
}
}
});
AppController.addToRequestQueue(request, ConcernActivity.TAG);
AppController.addToRequestQueue(request);
}
}
@ -134,7 +134,7 @@ public class ConcernRecommendAdapter extends RecyclerView.Adapter<ConcernViewHol
}
}
}, null);
AppController.addToRequestQueue(recommendRequest, ConcernActivity.TAG);
AppController.addToRequestQueue(recommendRequest);
}
@Override

View File

@ -19,7 +19,6 @@ 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.GameNewsActivity;
import com.gh.gamecenter.NewsSearchActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.GameNewsSearchViewHolder;
@ -139,7 +138,7 @@ public class GameNewsAdapter extends RecyclerView.Adapter {
isNetworkError = true;
}
});
AppController.addToRequestQueue(request, GameNewsActivity.TAG);
AppController.addToRequestQueue(request);
}
private void removeDuplicateData(List<NewsEntity> list) {

View File

@ -25,7 +25,6 @@ import com.gh.common.util.NewsUtils;
import com.gh.common.util.PostCommentUtils;
import com.gh.common.util.Utils;
import com.gh.common.view.CardLinearLayout;
import com.gh.gamecenter.GameNewsActivity;
import com.gh.gamecenter.MessageDetailActivity;
import com.gh.gamecenter.NewsDetailActivity;
import com.gh.gamecenter.R;
@ -114,12 +113,12 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
mConcernEntity = (ConcernEntity) AppController.get("ConcernEntity", true);
addHotComment(0);
}
}
private void addHotComment(int offset) {
String hotCommentUrl = Config.COMMENT_HOST + "article/" + mConcernEntity.getId() +
"/comment?order=hot&limit=" + 10 + "&offset=" + offset;
"/comment?order=hot&limit=10&offset=" + offset;
JsonArrayExtendedRequest request = new JsonArrayExtendedRequest(hotCommentUrl,
new Response.Listener<JSONArray>() {
@Override
@ -142,14 +141,14 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
}
});
AppController.addToRequestQueue(request, GameNewsActivity.TAG);
AppController.addToRequestQueue(request);
}
public void addNormalComment(int offset) {
isLoading = true;
String commentUrl = Config.COMMENT_HOST + "article/" + mConcernEntity.getId() +
"/comment?limit=" + 10 + "&offset=" + offset;
"/comment?limit=10&offset=" + offset;
JsonArrayExtendedRequest request = new JsonArrayExtendedRequest(commentUrl,
new Response.Listener<JSONArray>() {
@ -181,7 +180,7 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
}
});
AppController.addToRequestQueue(request, GameNewsActivity.TAG);
AppController.addToRequestQueue(request);
}
@ -510,7 +509,7 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
return;
}
finalCommentEntity.setVote(finalCommentEntity.getVote() + 1);
PostCommentUtils.addCommentVoto(finalCommentEntity.getId(), mContext);
PostCommentUtils.addCommentVoto(mContext, finalCommentEntity.getId());
holder.commentLikeCountTv.setTextColor(mContext.getResources().getColor(R.color.theme));
holder.commentLikeIv.setImageResource(R.drawable.comment_like_select);
holder.commentLikeCountTv.setText(String.valueOf(finalCommentEntity.getVote()));
@ -594,6 +593,10 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
return mConcernEntity.getId();
}
public ConcernEntity getConcernEntity() {
return mConcernEntity;
}
public boolean isLoading() {
return isLoading;
}

View File

@ -118,7 +118,7 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
}
}
});
AppController.addToRequestQueue(request, SubjectActivity.TAG);
AppController.addToRequestQueue(request);
}
private void processingData(JSONArray response, int page) {

View File

@ -10,12 +10,11 @@ import android.widget.TextView;
import com.gh.common.util.Utils;
import com.gh.gamecenter.R;
import com.gh.gamecenter.gamedetail.GameDetailSkinViewHolder;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.io.File;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -25,10 +24,10 @@ import java.util.TimerTask;
/**
* Created by khy on 2016/11/16.
*/
public class InitChangeSkinUtils {
public class ChangeSkinUtils {
private static List<PatchData> patchDatas = new ArrayList<PatchData>();
private static List<PatchData> updatePatchList;
private static List<PatchEntity> patchDatas = new ArrayList<PatchEntity>();
private static List<PatchEntity> updatePatchList;
private static Timer timer;
private static Timer poiTimer;
@ -65,13 +64,13 @@ public class InitChangeSkinUtils {
if( "".equals(jsonRuslt) ){
startCheckMD5Thread();
}else {
List<PatchData> patchData = parseDesPatchJson(jsonRuslt);
List<PatchEntity> patchData = parseDesPatchJson(jsonRuslt);
patchDatas.addAll(patchData);
if( patchData.size() < SkinConfig.perPage ) {
startCheckMD5Thread();
}else{
pageNum += 1;
String urlPath = SkinConfig.JSON_PATCHURL.replace( "*", ""+pageNum );
pageNum++;
String urlPath = SkinConfig.JSON_PATCHURL + pageNum;
DownloadUtils.downloadJson( urlPath, handler );
}
}
@ -179,7 +178,7 @@ public class InitChangeSkinUtils {
changeViewState( showTxt, "blue", SkinConfig.TYPE_DESUPDATE, false );
startSetPoint();
String urlPath = SkinConfig.JSON_PATCHURL.replace( "*", ""+pageNum );
String urlPath = SkinConfig.JSON_PATCHURL + pageNum;
//下载数据json
DownloadUtils.downloadJson( urlPath, handler);
}
@ -256,21 +255,21 @@ public class InitChangeSkinUtils {
}
//比较文件的MD5值返回MD5值不同的文件个数
private static void relMD5File( Map<String,String> dirMD5Map ) {
updatePatchList = new ArrayList<PatchData>();
private static void relMD5File( Map<String, String> dirMD5Map ) {
updatePatchList = new ArrayList<PatchEntity>();
int patchSize = 0;
curMD5Num = 0;
//获取目录下所有文件的 MD5
for ( int i = 0; i < patchDatas.size(); i++ ) {
PatchData data = patchDatas.get( i );
String path = data.filePath;
String updateMD5 = data.MD5;
PatchEntity data = patchDatas.get( i );
String path = data.path;
String updateMD5 = data.md5;
String updateUrl = data.url;
String updateSize = data.size;
//替换地址中标识符&
String replacePath = path.replace("&", SkinConfig.patchVersion);
patchDatas.get(i).filePath = replacePath;
patchDatas.get(i).path = replacePath;
String localMD5 = dirMD5Map.get( "/" + replacePath );
if ( localMD5 != null ) {
@ -298,8 +297,8 @@ public class InitChangeSkinUtils {
final Thread checkMD5Thrad = new Thread(new Runnable() {
@Override
public void run() {
localMD5Num = GetFileMD5Utils.getDirNum(new File(filePath));
Map<String, String> dirMD5Map = GetFileMD5Utils.getDirMD5(new File(filePath), true, handler);
localMD5Num = FileMD5Utils.getDirNum(new File(filePath));
Map<String, String> dirMD5Map = FileMD5Utils.getDirMD5(new File(filePath), handler);
Message msg = Message.obtain();
msg.obj = dirMD5Map;
msg.what = SkinConfig.MSG_MD5_OVER;
@ -310,32 +309,10 @@ public class InitChangeSkinUtils {
}
//解析json数据
private static List<PatchData> parseDesPatchJson(String jsonString) {
List<PatchData> patchList = new ArrayList<PatchData>();
JSONArray fileArray;
try {
fileArray = new JSONArray(jsonString);
for(int i = 0; i < fileArray.length(); i++ ) {
PatchData patchData = new PatchData();
JSONObject fileObject = fileArray.getJSONObject(i);
String md5 = fileObject.getString("md5");
String size = fileObject.getString("size");
String path = fileObject.getString("path");
String url = fileObject.getString("url");
patchData.MD5 = md5;
patchData.size = size;
patchData.filePath = path;
patchData.url = url;
patchList.add(patchData);
}
return patchList;
} catch (JSONException e) {
e.printStackTrace();
return null;
}
private static List<PatchEntity> parseDesPatchJson(String jsonString) {
Type listType = new TypeToken<ArrayList<PatchEntity>>() {}.getType();
Gson gson = new Gson();
return gson.fromJson(jsonString, listType);
}
//指定目录下载替换文件
@ -353,8 +330,8 @@ public class InitChangeSkinUtils {
}
downPosition = i;
PatchData patchData = updatePatchList.get( i );
String filePath = patchData.filePath;
PatchEntity patchData = updatePatchList.get( i );
String filePath = patchData.path;
Utils.log("updateProgress---" + updatePatchList.size() + "::" + i);
DownloadUtils.saveUrlToFile( filePath, patchData.url, handler );
}

View File

@ -5,10 +5,6 @@ import android.os.Message;
import com.gh.common.util.Utils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@ -17,57 +13,72 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
/**
* Created by yyq on 2016/11/3.
*
*/
public class DownloadUtils {
//下载需要替换的文件
public static void saveUrlToFile(String filePath, String destUrl, Handler handler) {
int BUFFER_SIZE = 2048 * 2048;
FileOutputStream fos = null;
BufferedInputStream bis = null;
HttpURLConnection httpUrl = null;
URL url = null;
byte[] buf = new byte[ BUFFER_SIZE ];
int size = 0;
private static final int BUFFER_SIZE = 2048 * 2048;
private static final int CONNECT_TIME = 5000;
private static final int READ_TIME = 5000;
//建立链接
//下载需要替换的文件
public static void saveUrlToFile(String filePath, String url, Handler handler) {
BufferedInputStream bis = null;
FileOutputStream fos = null;
try {
url = new URL( destUrl );
httpUrl = (HttpURLConnection) url.openConnection();
// 建立链接
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setRequestMethod("GET");
connection.setConnectTimeout(CONNECT_TIME);
connection.setReadTimeout(READ_TIME);
connection.setDoInput(true);
//连接指定的资源
httpUrl.connect();
connection.connect();
//获取网络输入流
bis = new BufferedInputStream( httpUrl.getInputStream() );
File file = new File( filePath );
bis = new BufferedInputStream(connection.getInputStream());
File file = new File(filePath);
if(!file.exists()) {
if( !file.getParentFile().exists() ) {
file.getParentFile().mkdirs();
File dir = file.getParentFile();
if (dir.exists() || dir.mkdirs()) {
file.createNewFile();
}
file.createNewFile();
}
Utils.log("createNewFile::" + file.getName() + "::" + file.getAbsolutePath() + "::" + file.exists() + "::" + file.isFile());
fos = new FileOutputStream(file);
//保存文件
while ( ( size = bis.read( buf ) ) != -1)
fos.write( buf, 0, size );
int size;
byte[] buffer = new byte[BUFFER_SIZE];
while ((size = bis.read(buffer)) != -1) {
fos.write(buffer, 0, size);
}
fos.flush();
Utils.log("updateProgress---saveUrlToFile");
handler.sendEmptyMessage( SkinConfig.MSG_PROGRESS_UPDATE );
fos.close();
bis.close();
httpUrl.disconnect();
} catch (Exception e) {
handler.sendEmptyMessage(SkinConfig.MSG_PROGRESS_UPDATE);
} catch (IOException e) {
Utils.log("saveUrlToFile::" + e.toString());
InitChangeSkinUtils.NetWorkErrorControl();
ChangeSkinUtils.NetWorkErrorControl();
//出现异常暂停下载
e.printStackTrace();
} finally {
if (bis != null) {
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
@ -124,37 +135,6 @@ public class DownloadUtils {
}
//解析json数据
private static List<PatchData> parseDesPatchJson(String jsonString) {
List<PatchData> patchList = new ArrayList<PatchData>();
JSONArray fileArray;
try {
fileArray = new JSONArray(jsonString);
for(int i = 0; i < fileArray.length(); i++ ) {
PatchData patchData = new PatchData();
JSONObject fileObject = fileArray.getJSONObject(i);
String md5 = fileObject.getString("md5");
String size = fileObject.getString("size");
String path = fileObject.getString("path");
String url = fileObject.getString("url");
patchData.MD5 = md5;
patchData.size = size;
patchData.filePath = path;
patchData.url = url;
patchList.add(patchData);
}
return patchList;
} catch (JSONException e) {
e.printStackTrace();
return null;
}
}
private static byte[] readStream(InputStream inputStream) throws IOException {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];

View File

@ -11,21 +11,21 @@ import java.util.Map;
/**
* Created by yyq on 2016/11/2.
*
*/
public class GetFileMD5Utils {
public class FileMD5Utils {
/**
* 获取单个文件的MD5值
* @param file
* @return
* @param file 文件
* @return md5
*/
public static String getFileMD5(File file) {
if (!file.isFile()) {
return null;
}
MessageDigest digest = null;
FileInputStream in = null;
MessageDigest digest;
FileInputStream in;
byte buffer[] = new byte[1024];
int len;
try {
@ -42,18 +42,17 @@ public class GetFileMD5Utils {
BigInteger bigInt = new BigInteger(1, digest.digest());
if(bigInt.toString().length()<39) {
if (bigInt.toString().length() < 39) {
int length = bigInt.toString(16).length();
if(length < 32){
if (length < 32) {
String bigStr = bigInt.toString(16);
for(int i=0; i<(32-length); i++){
for (int i = 0; i < (32 - length); i++) {
bigStr = "0" + bigStr;
}
return bigStr;
}
}
return bigInt.toString(16);
}
@ -62,48 +61,48 @@ public class GetFileMD5Utils {
/**
* 获取文件夹中文件的MD5值
*
* @param file
* @param listChild
* ;true递归子目录中的文件
* @param handler
* @return
* @param folder 文件夹
* @param handler handler
* @return 文件MD5 map
*/
public static Map<String, String> getDirMD5(File file, boolean listChild, Handler handler) {
if (!file.isDirectory()) {
return null;
public static Map<String, String> getDirMD5(File folder, Handler handler) {
Map<String, String> map = new HashMap<>();
if (!folder.isDirectory()) {
return map;
}
Map<String, String> map = new HashMap<String, String>();
String md5;
File files[] = file.listFiles();
for (int i = 0; i < files.length; i++) {
File f = files[i];
if (f.isDirectory() && listChild) {
map.putAll(getDirMD5(f, listChild, handler));
for (File file : folder.listFiles()) {
if (file.isDirectory()) {
map.putAll(getDirMD5(file, handler));
} else {
md5 = getFileMD5(f);
handler.sendEmptyMessage( SkinConfig.MSG_MD5_PROGRSS );
md5 = getFileMD5(file);
handler.sendEmptyMessage(SkinConfig.MSG_MD5_PROGRSS);
if (md5 != null) {
map.put(f.getPath(), md5);
map.put(file.getPath(), md5);
}
}
}
return map;
}
public static int getDirNum(File file) {
/**
* 获取文件夹下文件数量
* @param folder 文件夹
* @return 文件数量
*/
public static int getDirNum(File folder) {
int dirNum = 0;
File files[] = file.listFiles();
for (int i = 0; i < files.length; i++) {
File f = files[i];
if (f.isDirectory()) {
dirNum += getDirNum(f);
if (!folder.isDirectory()) {
return dirNum;
}
for (File file : folder.listFiles()) {
if (file.isDirectory()) {
dirNum += getDirNum(file);
} else {
dirNum ++;
dirNum++;
}
}
return dirNum;
}
}

View File

@ -8,6 +8,7 @@ import android.os.Message;
/**
* Created by yyq on 2016/11/4.
*
*/
public class NetSpeed {
@ -29,8 +30,7 @@ public class NetSpeed {
Message msg = handler.obtainMessage();
msg.what = SkinConfig.MSG_NETWORK_SPEED ;
String speeds = String.valueOf(speed) + " kb/s";
msg.obj = speeds;
msg.obj = String.valueOf(speed) + " kb/s";
handler.sendMessage(msg);//更新界面
}
}

View File

@ -2,10 +2,11 @@ package com.gh.gamecenter.changeskin;
/**
* Created by yyq on 2016/11/2.
*
*/
public class PatchData {
public String MD5;
public class PatchEntity {
public String md5;
public String size;
public String filePath;
public String path;
public String url;
}

View File

@ -2,14 +2,15 @@ package com.gh.gamecenter.changeskin;
/**
* Created by khy on 2016/11/16.
*
*/
public class SkinConfig {
public static int PG_STATE = 1;
/*
pageNum : 页数
perPage : 请求数量
* pageNum : 页数
* perPage : 请求数量
*/
public static int perPage = 300;
@ -26,10 +27,11 @@ public class SkinConfig {
public static final int MSG_MD5_OVER = 104;
public static final int MSG_NETWORK_ERROR = 200;
public static String GAME_ID = "57ce84f88ab49e83728b4572";
public static final String GAME_ID = "57ce84f88ab49e83728b4572";
// http://api.ghzhushou.com/v2d2/game/57ce84f88ab49e83728b4572/skin/data?page=1&per_page=1000
public static String JSON_PATCHURL = "http://api.ghzhushou.com/v2d2/game/" + GAME_ID + "/skin/data?page=*&per_page=" + perPage;
// http://api.ghzhushou.com/v2d2/game/57ce84f88ab49e83728b4572/skin/data?per_page=1000&page=1
public static final String JSON_PATCHURL = "http://api.ghzhushou.com/v2d2/game/"
+ GAME_ID + "/skin/data?per_page=" + perPage + "&page=";
// ewan.anfeng 安峰
public static String patchVersion = "com.netease.ma.ewan.anfeng";

View File

@ -29,7 +29,6 @@ import com.gh.gamecenter.R;
import com.gh.gamecenter.eventbus.EBDownloadChanged;
import com.gh.gamecenter.eventbus.EBMiPush;
import com.gh.gamecenter.eventbus.EBPackage;
import com.gh.gamecenter.eventbus.EBShowDone;
import com.gh.gamecenter.eventbus.EBSkip;
import com.gh.gamecenter.eventbus.EBUISwitch;
@ -331,12 +330,6 @@ public class GameDownLoadFragment extends Fragment implements View.OnClickListen
}
}
public void onEventMainThread(EBShowDone showDone) {
if ("下载管理".equals(showDone.getFrom()) && downloadmanager_rv_show != null) {
downloadmanager_rv_show.smoothScrollToPosition(showDone.getPosition());
}
}
@Override
public void onResume() {
super.onResume();

View File

@ -12,7 +12,6 @@ import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gh.base.AppController;
import com.gh.gamecenter.MainActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.eventbus.EBDownloadChanged;
@ -33,8 +32,6 @@ import de.greenrobot.event.EventBus;
*/
public class GameUpdateFragment extends Fragment {
public static final String TAG = GameUpdateFragment.class.getSimpleName();
private View view;
private RecyclerView gameupdate_rv_show;
private GameUpdateFragmentAdapter adapter;
@ -146,6 +143,5 @@ public class GameUpdateFragment extends Fragment {
public void onDestroy() {
super.onDestroy();
EventBus.getDefault().unregister(this);
AppController.canclePendingRequests(TAG);
}
}

View File

@ -155,7 +155,7 @@ public class GameUpdateFragmentAdapter extends RecyclerView.Adapter<RecyclerView
gameupdate_ll_loading.setVisibility(View.GONE);
}
});
AppController.addToRequestQueue(request, GameUpdateFragment.TAG);
AppController.addToRequestQueue(request);
}
private int mCount;
@ -209,7 +209,7 @@ public class GameUpdateFragmentAdapter extends RecyclerView.Adapter<RecyclerView
}
}
});
AppController.addToRequestQueue(request, GameUpdateFragment.TAG);
AppController.addToRequestQueue(request);
}
} else {
gameupdate_ll_loading.setVisibility(View.GONE);

View File

@ -1,12 +1,15 @@
package com.gh.gamecenter.entity;
import com.google.gson.annotations.SerializedName;
public class AppEntity {
private String version;
private String url;
private String size;
private String content;
private boolean force;
@SerializedName("force")
private boolean isForce;
private String alert;
public String getVersion() {
@ -42,11 +45,11 @@ public class AppEntity {
}
public boolean isForce() {
return force;
return isForce;
}
public void setForce(boolean force) {
this.force = force;
public void setForce(boolean isForce) {
this.isForce = isForce;
}
public String getAlert() {

View File

@ -31,6 +31,7 @@ public class GameCollectionEntity {
public void setColor(String color) {
this.color = color;
}
public String getColor() {
return color;
}
@ -38,6 +39,7 @@ public class GameCollectionEntity {
public void setIcon(String icon) {
this.icon = icon;
}
public String getIcon() {
return icon;
}
@ -45,6 +47,7 @@ public class GameCollectionEntity {
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
@ -52,6 +55,7 @@ public class GameCollectionEntity {
public void setPackage(List<String> packages) {
this.packages = packages;
}
public List<String> getPackage() {
return packages;
}

View File

@ -21,14 +21,14 @@ public class GameDetailEntity {
@SerializedName("download_off_text")
private String downloadOffText;
@SerializedName("skin_test")
private boolean skinTest;
private boolean isSkinTest;
public boolean isSkinTest() {
return skinTest;
return isSkinTest;
}
public void setSkinTest(boolean skinTest) {
this.skinTest = skinTest;
this.isSkinTest = skinTest;
}
public void setDownloadOffText(String downloadOffText) {

View File

@ -42,7 +42,7 @@ public class GameEntity {
private String link;
@SerializedName("concern_article_exists")
private boolean newsExists = true;
private boolean isNewsExists = true;
@SerializedName("download_off_text")
private String downloadOffText;
@ -56,11 +56,11 @@ public class GameEntity {
}
public boolean isNewsExists() {
return newsExists;
return isNewsExists;
}
public void setNewsExists(boolean newsExists) {
this.newsExists = newsExists;
this.isNewsExists = newsExists;
}
public String getLink() {
@ -211,7 +211,7 @@ public class GameEntity {
gameEntity.setType(type);
gameEntity.setPluggable(isPluggable);
gameEntity.setLink(link);
gameEntity.setNewsExists(newsExists);
gameEntity.setNewsExists(isNewsExists);
gameEntity.setDownloadOffText(downloadOffText);
return gameEntity;
}

View File

@ -1,7 +1,5 @@
package com.gh.gamecenter.entity;
import java.util.ArrayList;
public class GameInfoEntity {
private String id;
@ -10,8 +8,6 @@ public class GameInfoEntity {
private boolean isSignature;
private long installTime;
private ArrayList<String> packageList;
public String getId() {
return id;
}
@ -52,12 +48,4 @@ public class GameInfoEntity {
this.installTime = installTime;
}
public ArrayList<String> getPackageList() {
return packageList;
}
public void setPackageList(ArrayList<String> packageList) {
this.packageList = packageList;
}
}

View File

@ -29,18 +29,12 @@ public class GameUpdateEntity {
private boolean isPluggable;
private ApkEntity apk;
private String etag;
private String brief;
private ArrayList<String> tag;
public GameUpdateEntity() {
}
public String getBrief() {
return brief;
}
@ -145,22 +139,4 @@ public class GameUpdateEntity {
this.etag = etag;
}
public ApkEntity getApk() {
if (apk == null) {
apk = new ApkEntity();
apk.setGhVersion(ghVersion);
apk.setVersion(version);
apk.setPackageName(packageName);
apk.setPlatform(platform);
apk.setSize(size);
apk.setUrl(url);
apk.setEtag(etag);
}
return apk;
}
public void setApk(ApkEntity apk) {
this.apk = apk;
}
}

View File

@ -8,10 +8,15 @@ public class NewsDetailEntity {
@SerializedName("_id")
private String id;
private long time;
private String author;
private String content;
private String title;
private String type;
@SerializedName("game_id")

View File

@ -8,6 +8,7 @@ public class NewsEntity {
private String id;
private String type;
private String title;
@SerializedName("time")

View File

@ -60,5 +60,4 @@ public class SubjectEntity {
this.data = data;
}
}

View File

@ -31,10 +31,4 @@ public class TagEntity {
this.des = des;
}
@Override
public String toString() {
return "TagEntity [name=" + name + ", icon=" + icon + ", des=" + des
+ "]";
}
}

View File

@ -8,6 +8,7 @@ import java.util.List;
public class ThumbnailEntity {
private String type;
private List<String> url;
public String getType() {

View File

@ -12,6 +12,7 @@ public class UserEntity {
public void setIcon(String icon) {
this.icon = icon;
}
public String getIcon() {
return icon;
}
@ -19,6 +20,7 @@ public class UserEntity {
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}

View File

@ -6,7 +6,6 @@ public class EBPackage {
private String packageName;
public EBPackage(String type, String packageName) {
super();
this.type = type;
this.packageName = packageName;
}

View File

@ -6,6 +6,7 @@ package com.gh.gamecenter.eventbus;
public class EBSearch {
private String key;
private boolean isSearch;
public EBSearch(String key, boolean isSearch) {

View File

@ -11,6 +11,7 @@ public class EBTypeChange {
public EBTypeChange(String type, int position) {
this.type = type;
this.position = position;
}
public String getType() {

View File

@ -6,7 +6,6 @@ public class EBUISwitch {
private int position;
public EBUISwitch(String from, int position) {
super();
this.position = position;
this.from = from;
}

View File

@ -10,7 +10,6 @@ import android.widget.LinearLayout;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
import com.gh.base.AppController;
import com.gh.base.BaseFragment;
import com.gh.common.util.DownloadItemUtils;
import com.gh.download.DataWatcher;
@ -35,8 +34,6 @@ import java.util.List;
*/
public class Game1Fragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener {
public static final String TAG = Game1Fragment.class.getSimpleName();
private SwipeRefreshLayout fm_game_swipe_refresh;
private RecyclerView fm_game_rv_list;
private Game1FragmentAdapter adapter;
@ -295,10 +292,4 @@ public class Game1Fragment extends BaseFragment implements SwipeRefreshLayout.On
handler.postDelayed(runnable, 1000);
}
@Override
public void onDestroy() {
super.onDestroy();
AppController.canclePendingRequests(TAG);
}
}

View File

@ -176,7 +176,7 @@ public class Game1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
}
}
});
AppController.addToRequestQueue(slideRequest, Game1Fragment.TAG);
AppController.addToRequestQueue(slideRequest);
}
private void initSubjectList() {
@ -259,7 +259,7 @@ public class Game1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
}
}
});
AppController.addToRequestQueue(request, Game1Fragment.TAG);
AppController.addToRequestQueue(request);
}
public void initPlugin() {

View File

@ -1,7 +1,6 @@
package com.gh.gamecenter.game;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
@ -11,7 +10,6 @@ import android.widget.LinearLayout;
import android.widget.Toast;
import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
import com.gh.base.AppController;
import com.gh.base.BaseFragment;
import com.gh.common.util.DownloadItemUtils;
import com.gh.download.DataWatcher;
@ -34,18 +32,12 @@ import java.util.ArrayList;
*/
public class Game2Fragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener {
public static final String TAG = Game2Fragment.class.getSimpleName();
private SwipeRefreshLayout fm_game_swipe_refresh;
private RecyclerView fm_game_rv_list;
private Game2FragmentAdapter adapter;
private LinearLayout reuse_no_connection;
private ProgressBarCircularIndeterminate fm_game_pb_loading;
private boolean isEverpause;
private Handler handler = new Handler();
DataWatcher dataWatcher = new DataWatcher() {
@Override
public void onDataChanged(DownloadEntity downloadEntity) {
@ -71,8 +63,6 @@ public class Game2Fragment extends BaseFragment implements SwipeRefreshLayout.On
init(R.layout.fragment_game);
isEverpause = false;
reuse_no_connection.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -196,7 +186,6 @@ public class Game2Fragment extends BaseFragment implements SwipeRefreshLayout.On
@Override
public void onResume() {
super.onResume();
if (isEverpause) {
for (SubjectEntity subjectEntity : adapter.getSubectList()) {
for (GameEntity entity :subjectEntity.getData()) {
@ -205,21 +194,16 @@ public class Game2Fragment extends BaseFragment implements SwipeRefreshLayout.On
}
adapter.notifyDataSetChanged();
}
isEverpause = false;
super.onResume();
DownloadManager.getInstance(getActivity()).addObserver(dataWatcher);
}
@Override
public void onPause() {
super.onPause();
isEverpause = true;
DownloadManager.getInstance(getActivity()).removeObserver(dataWatcher);
}
public boolean isEverpause() {
return isEverpause;
}
Runnable runnable = new Runnable() {
@Override
public void run() {
@ -233,9 +217,4 @@ public class Game2Fragment extends BaseFragment implements SwipeRefreshLayout.On
handler.postDelayed(runnable, 1000);
}
@Override
public void onDestroy() {
super.onDestroy();
AppController.canclePendingRequests(TAG);
}
}

View File

@ -146,7 +146,7 @@ public class Game2FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
}
}
});
AppController.addToRequestQueue(request, Game2Fragment.TAG);
AppController.addToRequestQueue(request);
}
private void initLocationMap() {

View File

@ -1,7 +1,6 @@
package com.gh.gamecenter.game;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;
@ -11,7 +10,6 @@ import android.view.View;
import android.widget.LinearLayout;
import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
import com.gh.base.AppController;
import com.gh.base.BaseFragment;
import com.gh.common.util.DownloadItemUtils;
import com.gh.download.DataWatcher;
@ -38,8 +36,6 @@ import java.util.ArrayList;
*/
public class Game3Fragment extends BaseFragment implements OnRefreshListener {
public static final String TAG = Game3Fragment.class.getSimpleName();
private SwipeRefreshLayout fm_game_swipe_refresh;
private RecyclerView fm_game_rv_list;
private Game3FragmentAdapter adapter;
@ -47,10 +43,6 @@ public class Game3Fragment extends BaseFragment implements OnRefreshListener {
private LinearLayout reuse_no_connection;
private ProgressBarCircularIndeterminate fm_game_pb_loading;
private boolean isEverpause;
private Handler handler = new Handler();
// 黄壮华 添加观察者 修改2015/8/15
private DataWatcher dataWatcher = new DataWatcher() {
@Override
@ -77,8 +69,6 @@ public class Game3Fragment extends BaseFragment implements OnRefreshListener {
init(R.layout.fragment_game);
isEverpause = false;
reuse_no_connection.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -216,27 +206,21 @@ public class Game3Fragment extends BaseFragment implements OnRefreshListener {
}
}
public boolean isEverpause() {
return isEverpause;
}
@Override
public void onResume() {
super.onResume();
if (isEverpause) {
for (GameEntity entity : adapter.getGameList()) {
entity.setEntryMap(DownloadManager.getInstance(getActivity()).getEntryMap(entity.getName()));
}
adapter.notifyDataSetChanged();
}
isEverpause = false;
super.onResume();
DownloadManager.getInstance(getActivity()).addObserver(dataWatcher);
}
@Override
public void onPause() {
super.onPause();
isEverpause = true;
DownloadManager.getInstance(getActivity()).removeObserver(dataWatcher);
}
@ -253,10 +237,4 @@ public class Game3Fragment extends BaseFragment implements OnRefreshListener {
handler.postDelayed(runnable, 1000);
}
@Override
public void onDestroy() {
super.onDestroy();
AppController.canclePendingRequests(TAG);
}
}

View File

@ -121,7 +121,7 @@ public class Game3FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
}
});
AppController.addToRequestQueue(request, Game3Fragment.TAG);
AppController.addToRequestQueue(request);
}
private void processingData(JSONArray response, int offset) {

View File

@ -58,9 +58,8 @@ public class GameFragment extends HomeFragment implements OnPageChangeListener {
if (savedInstanceState != null) {
currentItem = savedInstanceState.getInt("currentItem");
}
home_vp_content.setCurrentItem(currentItem);
initTextView();
home_vp_content.setCurrentItem(currentItem);
DisplayMetrics outMetrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(outMetrics);

View File

@ -31,7 +31,7 @@ import com.gh.common.view.HorizontalItemDecoration;
import com.gh.gamecenter.GameDetailActivity;
import com.gh.gamecenter.GameNewsActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.changeskin.InitChangeSkinUtils;
import com.gh.gamecenter.changeskin.ChangeSkinUtils;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameDetailEntity;
import com.gh.gamecenter.entity.GameEntity;
@ -123,7 +123,7 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
}
}
});
AppController.addToRequestQueue(request, GameDetailActivity.TAG);
AppController.addToRequestQueue(request);
}
// 获取游戏新闻
@ -154,7 +154,7 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
notifyDataSetChanged();
}
});
AppController.addToRequestQueue(request, GameDetailActivity.TAG);
AppController.addToRequestQueue(request);
}
// 获取开发信息
@ -210,7 +210,7 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
}
}
}, null);
AppController.addToRequestQueue(request, GameDetailActivity.TAG);
AppController.addToRequestQueue(request);
}
@Override
@ -261,7 +261,7 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
}
private void initSkinViewHolder(GameDetailSkinViewHolder holder) {
InitChangeSkinUtils.changeSkinControl(holder, context);
ChangeSkinUtils.changeSkinControl(holder, context);
}
private void initNewsServerViewHolder(final GameDetailNewsServerViewHolder viewHolder) {

View File

@ -72,8 +72,6 @@ public class News1Fragment extends BaseFragment implements SwipeRefreshLayout.On
private ConcernManager concernManager;
private SharedPreferences sp;
private boolean isNewFirstLaunch;
Runnable runnable = new Runnable() {
@ -96,7 +94,7 @@ public class News1Fragment extends BaseFragment implements SwipeRefreshLayout.On
concernManager = new ConcernManager(getActivity());
concernMap = new ArrayMap<>();
sp = getActivity().getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
SharedPreferences sp = getActivity().getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
isNewFirstLaunch = sp.getBoolean("isNewFirstLaunchV" + PackageUtils.getVersion(getActivity()), true);

View File

@ -57,9 +57,8 @@ public class NewsFragment extends HomeFragment implements View.OnClickListener,
if (savedInstanceState != null) {
currentItem = savedInstanceState.getInt("currentItem");
}
home_vp_content.setCurrentItem(currentItem);
initTextView();
home_vp_content.setCurrentItem(currentItem);
DisplayMetrics outMetrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(outMetrics);

View File

@ -58,6 +58,7 @@ import java.util.Map;
/**
* Created by LGT on 2016/9/13.
* 新闻详情数据适配器
*/
public class NewsDetailAdapter extends RecyclerView.Adapter {
@ -111,7 +112,7 @@ public class NewsDetailAdapter extends RecyclerView.Adapter {
}
}
});
AppController.addToRequestQueue(request, NewsDetailActivity.TAG);
AppController.addToRequestQueue(request);
}
private void getNewsMore() {
@ -142,7 +143,7 @@ public class NewsDetailAdapter extends RecyclerView.Adapter {
}
}
}, null);
AppController.addToRequestQueue(request, NewsDetailActivity.TAG);
AppController.addToRequestQueue(request);
}
@Override

View File

@ -8,7 +8,6 @@ import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gh.base.AppController;
import com.gh.base.BaseFragment;
import com.gh.common.util.DownloadItemUtils;
import com.gh.download.DataWatcher;
@ -28,19 +27,16 @@ import de.greenrobot.event.EventBus;
/**
* Created by LGT on 2016/8/12.
* 我的光环-已关注界面
*/
public class ConcernFragment extends BaseFragment {
public static final String TAG = ConcernFragment.class.getSimpleName();
private RecyclerView fm_concern_rv_show;
private ConcernFragmentAdapter adapter;
private LinearLayout reuse_nodata_skip;
private TextView reuse_nodata_skip_tv_hint;
private TextView reuse_nodata_skip_tv_btn;
private boolean isEverpause;
private DataWatcher dataWatcher = new DataWatcher() {
@Override
public void onDataChanged(DownloadEntity downloadEntity) {
@ -62,8 +58,6 @@ public class ConcernFragment extends BaseFragment {
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
isEverpause = false;
init(R.layout.fm_concern);
reuse_nodata_skip.setVisibility(View.GONE);
@ -142,28 +136,20 @@ public class ConcernFragment extends BaseFragment {
@Override
public void onResume() {
super.onResume();
if (isEverpause) {
for (GameEntity entity : adapter.getGameList()) {
entity.setEntryMap(DownloadManager.getInstance(getActivity()).getEntryMap(entity.getName()));
}
adapter.notifyDataSetChanged();
}
isEverpause = false;
super.onResume();
DownloadManager.getInstance(getActivity()).addObserver(dataWatcher);
}
@Override
public void onPause() {
super.onPause();
isEverpause = true;
DownloadManager.getInstance(getActivity()).removeObserver(dataWatcher);
}
@Override
public void onDestroy() {
super.onDestroy();
AppController.canclePendingRequests(TAG);
}
}

View File

@ -41,6 +41,7 @@ import java.util.Map;
/**
* Created by LGT on 2016/8/15.
* 已关注界面-数据适配器
*/
public class ConcernFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@ -110,7 +111,7 @@ public class ConcernFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
}
}
});
AppController.addToRequestQueue(concernObjectRequest, ConcernFragment.TAG);
AppController.addToRequestQueue(concernObjectRequest);
}
}

View File

@ -8,7 +8,6 @@ import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gh.base.AppController;
import com.gh.base.BaseFragment;
import com.gh.common.util.DownloadItemUtils;
import com.gh.download.DataWatcher;
@ -26,19 +25,16 @@ import de.greenrobot.event.EventBus;
/**
* Created by LGT on 2016/8/12.
* 我的关注-已安装界面
*/
public class InstallFragment extends BaseFragment {
public static final String TAG = InstallFragment.class.getSimpleName();
private RecyclerView fm_install_rv_show;
private InstallFragmentAdapter adapter;
private LinearLayout reuse_nodata_skip;
private TextView reuse_nodata_skip_tv_hint;
private TextView reuse_nodata_skip_tv_btn;
private boolean isEverpause;
private DataWatcher dataWatcher = new DataWatcher() {
@Override
public void onDataChanged(DownloadEntity downloadEntity) {
@ -60,8 +56,6 @@ public class InstallFragment extends BaseFragment {
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
isEverpause = false;
init(R.layout.fm_install);
reuse_nodata_skip.setVisibility(View.GONE);
@ -105,27 +99,20 @@ public class InstallFragment extends BaseFragment {
@Override
public void onResume() {
super.onResume();
if (isEverpause) {
for (GameEntity entity : adapter.getGameList()) {
entity.setEntryMap(DownloadManager.getInstance(getActivity()).getEntryMap(entity.getName()));
}
adapter.notifyDataSetChanged();
}
isEverpause = false;
super.onResume();
DownloadManager.getInstance(getActivity()).addObserver(dataWatcher);
}
@Override
public void onPause() {
super.onPause();
isEverpause = true;
DownloadManager.getInstance(getActivity()).removeObserver(dataWatcher);
}
@Override
public void onDestroy() {
super.onDestroy();
AppController.canclePendingRequests(TAG);
}
}

View File

@ -218,7 +218,7 @@ public class InstallFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
final int size = ids.size();
count = 0;
for (int i = 0; i < ids.size(); i++) {
JsonObjectExtendedRequest objectRequest = new JsonObjectExtendedRequest(
JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
Config.HOST + "game/" + ids.get(i) + "/digest",
new Response.Listener<JSONObject>() {
@Override
@ -240,7 +240,7 @@ public class InstallFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
}
}
});
AppController.addToRequestQueue(objectRequest, InstallFragment.TAG);
AppController.addToRequestQueue(request);
}
}

View File

@ -62,17 +62,14 @@ import java.util.Map;
/**
*
* @author 温冠超
* @email 294299195@qq.com
* @date 2015-8-8 我的光环页面
* 294299195@qq.com
* 2015-8-8 我的光环页面
*/
public class PersonalFragment extends Fragment implements View.OnClickListener, ViewPager.OnPageChangeListener {
public static final String TAG = PersonalFragment.class.getSimpleName();
private View view;
private ViewPager me_vp_show;
private ImageView me_iv_top_setting;
private SimpleDraweeView me_iv_top_icon;
private TextView me_tv_top_install;
private TextView me_tv_top_concern;
@ -123,7 +120,7 @@ public class PersonalFragment extends Fragment implements View.OnClickListener,
me_tv_top_name = (TextView) view.findViewById(R.id.me_tv_top_name);
me_tv_top_name.setOnClickListener(this);
me_iv_top_setting = (ImageView) view.findViewById(R.id.me_iv_top_setting);
ImageView me_iv_top_setting = (ImageView) view.findViewById(R.id.me_iv_top_setting);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) me_iv_top_setting.getLayoutParams();
params.topMargin = DisplayUtils.getInternalDimensionSize(getResources(), "status_bar_height")
@ -383,8 +380,12 @@ public class PersonalFragment extends Fragment implements View.OnClickListener,
}.start();
}
private void modifyNickname(final String nickname) {
private void modifyNickname(String nickname) {
final Dialog waitDialog = DialogUtils.showWaitDialog(getActivity(), "修改中...");
modifyNickname(waitDialog, nickname, true);
}
private void modifyNickname(final Dialog waitDialog, final String nickname, final boolean isCheck) {
new Thread(){
@Override
public void run() {
@ -404,30 +405,31 @@ public class PersonalFragment extends Fragment implements View.OnClickListener,
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
if (error.networkResponse != null
&& error.networkResponse.statusCode == 401) {
modifyNickname(waitDialog, nickname, false);
return;
}
waitDialog.dismiss();
if (error.networkResponse != null) {
if (error.networkResponse.statusCode == 401) {
TokenUtils.getToken(getActivity(), false); // TODO 提示网络请求不能在UI线程执行
modifyNickname(nickname);
} else if (error.networkResponse.statusCode == 403) {
try {
JSONObject response = new JSONObject(new String(error.networkResponse.data));
String detail = response.getString("detail");
if ("too long".equals(detail)) {
Toast.makeText(getActivity(), "昵称太长", Toast.LENGTH_SHORT).show();
} else if ("invalid".equals(detail)) {
Toast.makeText(getActivity(), "非法字符", Toast.LENGTH_SHORT).show();
} else if ("repeat".equals(detail)) {
Toast.makeText(getActivity(), "昵称已存在", Toast.LENGTH_SHORT).show();
} else if ("no change".equals(detail)) {
Toast.makeText(getActivity(), "昵称一致", Toast.LENGTH_SHORT).show();
} else if ("too frequent".equals(detail)) {
Toast.makeText(getActivity(), "修改太频繁,请稍后再试", Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
Toast.makeText(getActivity(), "修改失败", Toast.LENGTH_SHORT).show();
if (error.networkResponse != null
&& error.networkResponse.statusCode == 403) {
try {
JSONObject response = new JSONObject(new String(error.networkResponse.data));
String detail = response.getString("detail");
if ("too long".equals(detail)) {
Toast.makeText(getActivity(), "昵称太长", Toast.LENGTH_SHORT).show();
} else if ("invalid".equals(detail)) {
Toast.makeText(getActivity(), "非法字符", Toast.LENGTH_SHORT).show();
} else if ("repeat".equals(detail)) {
Toast.makeText(getActivity(), "昵称已存在", Toast.LENGTH_SHORT).show();
} else if ("no change".equals(detail)) {
Toast.makeText(getActivity(), "昵称一致", Toast.LENGTH_SHORT).show();
} else if ("too frequent".equals(detail)) {
Toast.makeText(getActivity(), "修改太频繁,请稍后再试", Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
Toast.makeText(getActivity(), "修改失败", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(getActivity(), "修改失败", Toast.LENGTH_SHORT).show();
@ -435,8 +437,8 @@ public class PersonalFragment extends Fragment implements View.OnClickListener,
}
});
request.setShouldCache(false);
request.addHeader("TOKEN", TokenUtils.getToken(getActivity()));
AppController.addToRequestQueue(request, TAG);
request.addHeader("TOKEN", TokenUtils.getToken(getActivity(), isCheck));
AppController.addToRequestQueue(request);
}
}.start();
}
@ -468,16 +470,10 @@ public class PersonalFragment extends Fragment implements View.OnClickListener,
Config.USER_HOST + "device/" + TokenUtils.getDeviceId(getActivity()),
new JSONObject(params).toString(), null, null);
request.addHeader("TOKEN", TokenUtils.getToken(getActivity()));
AppController.addToRequestQueue(request, TAG);
AppController.addToRequestQueue(request);
}
}.start();
}
}
@Override
public void onDestroy() {
super.onDestroy();
AppController.canclePendingRequests(TAG);
}
}

View File

@ -11,6 +11,7 @@ import com.gh.gamecenter.SplashScreenActivity;
/**
* Created by khy on 2016/9/1.
* 光环插件跳转助手
*/
public class ActivitySkipReceiver extends BroadcastReceiver {

View File

@ -14,6 +14,7 @@ import de.greenrobot.event.EventBus;
/**
* Created by LGT on 2016/10/10.
* notification下载跳转
*/
public class DownloadReceiver extends BroadcastReceiver {

View File

@ -19,8 +19,6 @@ public class InstallAndUninstallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// 接收安装广播
if (intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED)) {
String packageName = intent.getDataString();

View File

@ -15,6 +15,7 @@ import de.greenrobot.event.EventBus;
/**
* Created by LGT on 2016/10/10.
* notification安装跳转
*/
public class InstallReceiver extends BroadcastReceiver {

View File

@ -14,10 +14,7 @@ public class NetworkStateReceiver extends BroadcastReceiver {
// 监听网络状态的变化
@Override
public void onReceive(Context context, Intent intent) {
EventBus.getDefault().post(
new EBNetworkState(NetworkUtils
.isNetworkConnected(context)));
EventBus.getDefault().post(new EBNetworkState(NetworkUtils.isNetworkConnected(context)));
}
}

View File

@ -12,10 +12,9 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import com.gh.gamecenter.R;
import com.gh.gamecenter.listener.OnCallBackListener;
public class SearchGameDetailFragment extends Fragment {
public static final String TAG = SearchGameDetailFragment.class.getSimpleName();
public class SearchGameDetailFragment extends Fragment implements OnCallBackListener {
private View view;
private RecyclerView search_detail;
@ -41,8 +40,7 @@ public class SearchGameDetailFragment extends Fragment {
search_detail = (RecyclerView) view.findViewById(R.id.search_detail);
search_detail.setHasFixedSize(true);
search_detail.setLayoutManager(new LinearLayoutManager(getActivity()));
search_detail.setAdapter(new SearchGameDetailFragmentAdapter(getActivity(), search_detail,
search_loading, reuse_none_date, reuse_no_connection, key));
search_detail.setAdapter(new SearchGameDetailFragmentAdapter(SearchGameDetailFragment.this, key));
}
@Nullable
@ -59,9 +57,33 @@ public class SearchGameDetailFragment extends Fragment {
this.key = key;
}
public void search(String key) {
search_detail.setAdapter(new SearchGameDetailFragmentAdapter(getActivity(), search_detail,
search_loading, reuse_none_date, reuse_no_connection, key));
@Override
public void loadDone() {
search_loading.setVisibility(View.GONE);
search_detail.setVisibility(View.VISIBLE);
reuse_none_date.setVisibility(View.GONE);
reuse_no_connection.setVisibility(View.GONE);
}
@Override
public void loadDone(Object obj) {
}
@Override
public void loadError() {
search_loading.setVisibility(View.GONE);
search_detail.setVisibility(View.GONE);
reuse_none_date.setVisibility(View.GONE);
reuse_no_connection.setVisibility(View.VISIBLE);
}
@Override
public void loadEmpty() {
search_loading.setVisibility(View.GONE);
search_detail.setVisibility(View.GONE);
reuse_none_date.setVisibility(View.VISIBLE);
reuse_no_connection.setVisibility(View.GONE);
}
}

View File

@ -9,7 +9,6 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.LinearLayout;
import com.android.volley.Response;
import com.android.volley.VolleyError;
@ -24,6 +23,7 @@ import com.gh.common.view.DownloadDialog;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.GameNormalViewHolder;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.listener.OnCallBackListener;
import com.gh.gamecenter.manager.DataCollectionManager;
import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
import com.google.gson.Gson;
@ -40,43 +40,25 @@ import java.util.Map;
public class SearchGameDetailFragmentAdapter extends RecyclerView.Adapter<GameNormalViewHolder> {
private Context context;
private RecyclerView search_detail;
private LinearLayout search_loading;
private LinearLayout search_nogame;
private LinearLayout search_connection;
private OnCallBackListener listener;
private List<GameEntity> gameList;
private String key;
public SearchGameDetailFragmentAdapter(Context context,
RecyclerView search_detail,
LinearLayout search_loading,
LinearLayout search_nogame,
LinearLayout search_connection,
String key) {
this.context = context;
this.search_detail = search_detail;
this.search_loading = search_loading;
this.search_nogame = search_nogame;
this.search_connection = search_connection;
public SearchGameDetailFragmentAdapter(SearchGameDetailFragment fragment, String key) {
this.context = fragment.getActivity();
this.listener = fragment;
gameList = new ArrayList<>();
this.key = key;
if (!TextUtils.isEmpty(key)) {
search_loading.setVisibility(View.VISIBLE);
search_detail.setVisibility(View.GONE);
search_nogame.setVisibility(View.GONE);
search_connection.setVisibility(View.GONE);
search(key);
} else {
search_loading.setVisibility(View.GONE);
search_detail.setVisibility(View.GONE);
search_nogame.setVisibility(View.VISIBLE);
search_connection.setVisibility(View.GONE);
if (listener != null) {
listener.loadEmpty();
}
}
}
@ -86,27 +68,30 @@ public class SearchGameDetailFragmentAdapter extends RecyclerView.Adapter<GameNo
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
search_loading.setVisibility(View.GONE);
Type listType = new TypeToken<ArrayList<GameEntity>>() {}.getType();
Gson gson = new Gson();
List<GameEntity> list = gson.fromJson(response.toString(), listType);
if (list != null && list.size() > 0) {
search_detail.setVisibility(View.VISIBLE);
if (list != null && list.size() != 0) {
if (listener != null) {
listener.loadDone();
}
gameList = list;
notifyItemRangeInserted(0, gameList.size());
} else {
search_nogame.setVisibility(View.VISIBLE);
if (listener != null) {
listener.loadEmpty();
}
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
search_loading.setVisibility(View.GONE);
search_connection.setVisibility(View.VISIBLE);
if (listener != null) {
listener.loadError();
}
}
});
AppController.addToRequestQueue(request, SearchGameDetailFragment.TAG);
AppController.addToRequestQueue(request);
}
@Override

View File

@ -12,12 +12,15 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import com.gh.gamecenter.R;
import com.gh.gamecenter.listener.OnCallBackListener;
public class SearchGameListFragment extends Fragment {
public static final String TAG = SearchGameListFragment.class.getSimpleName();
public class SearchGameListFragment extends Fragment implements OnCallBackListener {
private View view;
private RecyclerView search_detail;
private LinearLayout search_loading;
private LinearLayout reuse_none_date;
private LinearLayout reuse_no_connection;
private String key;
@ -30,15 +33,14 @@ public class SearchGameListFragment extends Fragment {
TextView reuse_tv_none_data = (TextView) view.findViewById(R.id.reuse_tv_none_data);
reuse_tv_none_data.setText("搜索为空");
LinearLayout search_loading = (LinearLayout) view.findViewById(R.id.search_gamedetail_ll_loading);
LinearLayout search_nogame = (LinearLayout) view.findViewById(R.id.reuse_none_data);
LinearLayout search_connection = (LinearLayout) view.findViewById(R.id.reuse_no_connection);
search_loading = (LinearLayout) view.findViewById(R.id.search_gamedetail_ll_loading);
reuse_none_date = (LinearLayout) view.findViewById(R.id.reuse_none_data);
reuse_no_connection = (LinearLayout) view.findViewById(R.id.reuse_no_connection);
RecyclerView search_detail = (RecyclerView) view.findViewById(R.id.search_detail);
search_detail = (RecyclerView) view.findViewById(R.id.search_detail);
search_detail.setHasFixedSize(true);
search_detail.setLayoutManager(new LinearLayoutManager(getActivity()));
search_detail.setAdapter(new SearchGameListFragmentAdapter(getActivity(), search_detail,
search_loading, search_nogame, search_connection, key));
search_detail.setAdapter(new SearchGameListFragmentAdapter(SearchGameListFragment.this, key));
}
@Nullable
@ -55,4 +57,32 @@ public class SearchGameListFragment extends Fragment {
this.key = key;
}
@Override
public void loadDone() {
search_loading.setVisibility(View.GONE);
search_detail.setVisibility(View.VISIBLE);
reuse_none_date.setVisibility(View.GONE);
reuse_no_connection.setVisibility(View.GONE);
}
@Override
public void loadDone(Object obj) {
}
@Override
public void loadError() {
search_loading.setVisibility(View.GONE);
search_detail.setVisibility(View.GONE);
reuse_none_date.setVisibility(View.GONE);
reuse_no_connection.setVisibility(View.VISIBLE);
}
@Override
public void loadEmpty() {
search_loading.setVisibility(View.GONE);
search_detail.setVisibility(View.GONE);
reuse_none_date.setVisibility(View.VISIBLE);
reuse_no_connection.setVisibility(View.GONE);
}
}

View File

@ -8,7 +8,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.LinearLayout;
import com.android.volley.Response;
import com.android.volley.VolleyError;
@ -24,6 +23,7 @@ import com.gh.common.view.DownloadDialog;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.GameNormalViewHolder;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.listener.OnCallBackListener;
import com.gh.gamecenter.manager.DataCollectionManager;
import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
import com.google.gson.Gson;
@ -40,42 +40,25 @@ import java.util.Map;
public class SearchGameListFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context;
private RecyclerView search_detail;
private LinearLayout search_loading;
private LinearLayout search_nogame;
private LinearLayout search_connection;
private OnCallBackListener listener;
private List<GameEntity> gameList;
private String key;
public SearchGameListFragmentAdapter(Context context,
RecyclerView search_detail,
LinearLayout search_loading,
LinearLayout search_nogame,
LinearLayout search_connection,
String key) {
this.context = context;
this.search_detail = search_detail;
this.search_loading = search_loading;
this.search_nogame = search_nogame;
this.search_connection = search_connection;
public SearchGameListFragmentAdapter(SearchGameListFragment fragment, String key) {
this.context = fragment.getActivity();
this.listener = fragment;
gameList = new ArrayList<>();
this.key = key;
if (!TextUtils.isEmpty(key)) {
search_loading.setVisibility(View.VISIBLE);
search_detail.setVisibility(View.GONE);
search_nogame.setVisibility(View.GONE);
search_connection.setVisibility(View.GONE);
searchGame(key);
} else {
search_loading.setVisibility(View.GONE);
search_detail.setVisibility(View.GONE);
search_nogame.setVisibility(View.VISIBLE);
search_connection.setVisibility(View.GONE);
if (listener != null) {
listener.loadEmpty();
}
}
}
@ -85,27 +68,30 @@ public class SearchGameListFragmentAdapter extends RecyclerView.Adapter<Recycler
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
search_loading.setVisibility(View.GONE);
Type listType = new TypeToken<ArrayList<GameEntity>>() {}.getType();
Gson gson = new Gson();
List<GameEntity> list = gson.fromJson(response.toString(), listType);
if (list != null && list.size() > 0) {
search_detail.setVisibility(View.VISIBLE);
if (list != null && list.size() != 0) {
if (listener != null) {
listener.loadDone();
}
gameList = list;
notifyItemRangeInserted(0, gameList.size());
} else {
search_nogame.setVisibility(View.VISIBLE);
if (listener != null) {
listener.loadEmpty();
}
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
search_loading.setVisibility(View.GONE);
search_connection.setVisibility(View.VISIBLE);
if (listener != null) {
listener.loadError();
}
}
});
AppController.addToRequestQueue(request, SearchGameListFragment.TAG);
AppController.addToRequestQueue(request);
}
@Override