Merge remote-tracking branch 'origin/2.1' into 2.1

# Conflicts:
#	app/src/main/java/com/gh/gamecenter/news/News4Fragment.java
This commit is contained in:
khy
2016-10-25 14:56:42 +08:00
45 changed files with 443 additions and 350 deletions

View File

@ -36,7 +36,6 @@ import com.gh.gamecenter.manager.PackageManager;
import com.tencent.tauth.Tencent;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -61,6 +60,7 @@ public abstract class DetailActivity extends BaseActivity implements View.OnClic
protected String name;
protected String title;
protected String downloadAddWord;
protected String downloadOffText;
protected Handler handler = new Handler();
@ -167,7 +167,11 @@ public abstract class DetailActivity extends BaseActivity implements View.OnClic
detail_tv_download.setVisibility(View.VISIBLE);
detail_pb_progressbar.setVisibility(View.GONE);
detail_tv_per.setVisibility(View.GONE);
detail_tv_download.setText("暂无下载");
if (TextUtils.isEmpty(downloadOffText)) {
detail_tv_download.setText("暂无下载");
} else {
detail_tv_download.setText(downloadOffText);
}
detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_pause_style);
detail_tv_download.setTextColor(0xFF999999);
detail_tv_download.setClickable(false);
@ -240,16 +244,13 @@ public abstract class DetailActivity extends BaseActivity implements View.OnClic
&& gameEntity.getApk() != null
&& gameEntity.getApk().size() == 1) {
String url = gameEntity.getApk().get(0).getUrl();
List<DownloadEntity> list = DownloadManager.getInstance(getApplicationContext()).getAll();
for (DownloadEntity entry : list) {
if (url.equals(entry.getUrl())) {
mDownloadEntity = entry;
detail_tv_download.setVisibility(View.GONE);
detail_pb_progressbar.setVisibility(View.VISIBLE);
detail_tv_per.setVisibility(View.VISIBLE);
invalidate();
break;
}
DownloadEntity downloadEntity = DownloadManager.getInstance(getApplicationContext()).get(url);
if (downloadEntity != null) {
mDownloadEntity = downloadEntity;
detail_tv_download.setVisibility(View.GONE);
detail_pb_progressbar.setVisibility(View.VISIBLE);
detail_tv_per.setVisibility(View.VISIBLE);
invalidate();
}
}
}

View File

@ -0,0 +1,87 @@
package com.gh.common.util;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
import java.io.IOException;
/**
* Created by LGT on 2016/10/21.
*/
public class BitmapUtils {
/**
* 根据文件路径返回bitmap
* @param filepath 文件路径
* @param w 宽
* @param h 高
* @return bitmap
*/
public static Bitmap getBitmapByFile(String filepath, int w, int h) {
try {
BitmapFactory.Options options = new BitmapFactory.Options();
// 设置为ture只获取图片大小
options.inJustDecodeBounds = true;
options.inPreferredConfig = Bitmap.Config.RGB_565;
// 返回为空
BitmapFactory.decodeFile(filepath, options);
int width = options.outWidth;
int height = options.outHeight;
float scaleWidth = 0.f, scaleHeight = 0.f;
if (width > w || height > h) {
// 缩放
scaleWidth = ((float) width) / w;
scaleHeight = ((float) height) / h;
}
options.inJustDecodeBounds = false;
int scale = (int) Math.ceil(Math.max(scaleWidth, scaleHeight));
if (scale % 2 == 1) {
scale += 1;
}
options.inSampleSize = scale;
Bitmap bitmap = BitmapFactory.decodeFile(filepath, options);
bitmap = rotatePicture(filepath, bitmap);
if (bitmap != null) {
return bitmap;
}
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static Bitmap rotatePicture(String path, Bitmap bitmap) {
int rotate = 0;
try {
ExifInterface exifInterface = new ExifInterface(path);
int orientation = exifInterface.getAttributeInt(
ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
rotate = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
rotate = 270;
break;
}
} catch (IOException e) {
e.printStackTrace();
}
if (rotate != 0) {
Matrix matrix = new Matrix();
matrix.setRotate(rotate);
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
bitmap.getHeight(), matrix, true);
} else {
return bitmap;
}
}
}

View File

@ -101,8 +101,8 @@ public class DialogUtils {
}
// 网络劫持时 打开QQ客户端创建临时会话
public static void showQqSessionDialog(final Context context, String qq){
if (qq == null){
public static void showQqSessionDialog(final Context context, String qq) {
if (qq == null) {
qq = "2586716223";// 默认客服QQ
}
final String finalQq = qq;

View File

@ -5,7 +5,6 @@ import android.os.Environment;
import android.os.StatFs;
import android.os.StrictMode;
import org.apache.http.HttpStatus;
import org.json.JSONObject;
import java.io.DataInputStream;
@ -96,21 +95,6 @@ public class FileUtils {
}
return true;
}
public static void checkDirExists(String dirName) {
File file = Environment.getExternalStorageDirectory();
if (file.isDirectory()) {
File[] fs = file.listFiles();
for (int i = 0; i < fs.length; i++) {
if (fs[i].isDirectory()
&& fs[i].getName().equalsIgnoreCase(dirName)
&& !fs[i].getName().equals(dirName)) {
fs[i].delete();
break;
}
}
}
}
public static boolean isMounted() {
return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
@ -286,14 +270,14 @@ public class FileUtils {
int statusCode = connection.getResponseCode();
Utils.log("statusCode = " + statusCode);
if (statusCode == HttpStatus.SC_OK) {
if (statusCode == HttpURLConnection.HTTP_OK) {
// {"icon":"http:\/\/gh-test-1.oss-cn-qingdao.aliyuncs.com\/pic\/57e4f4d58a3200042d29492f.jpg"}
JSONObject response = new JSONObject(b.toString().trim());
response.put("statusCode", HttpStatus.SC_OK);
response.put("statusCode", HttpURLConnection.HTTP_OK);
return response;
} else if (statusCode == HttpStatus.SC_FORBIDDEN) {
} else if (statusCode == HttpURLConnection.HTTP_FORBIDDEN) {
JSONObject response = new JSONObject(b.toString().trim());
response.put("statusCode", HttpStatus.SC_FORBIDDEN);
response.put("statusCode", HttpURLConnection.HTTP_FORBIDDEN);
return response;
}
} catch (Exception e) {

View File

@ -41,22 +41,6 @@ public class GameViewUtils {
}
}
// 获取游戏标签列表视图
public static void setLabelList(Context context, LinearLayout labelLayout, String tag) {
labelLayout.removeAllViews();
// 添加tag标签
if (tag != null && !tag.isEmpty()) {
String[] tags = tag.split(",");
for (int i = 0; i < tags.length; i++) {
if (i == tags.length - 1) {
labelLayout.addView(getGameTagView(context, tags[i], 0));
} else {
labelLayout.addView(getGameTagView(context, tags[i], DisplayUtils.dip2px(context, 5)));
}
}
}
}
public static TextView getGameTagView(Context context, String tagStr, int rightMargin) {
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

View File

@ -15,13 +15,13 @@ import com.gh.gamecenter.R;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
import org.apache.http.HttpStatus;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Properties;
@ -175,7 +175,7 @@ public class PlatformUtils {
+ url.substring(url.lastIndexOf("/") + 1);
try {
int code = FileUtils.downloadFile(url, savePath);
if (code == HttpStatus.SC_OK) {
if (code == HttpURLConnection.HTTP_OK) {
success++;
}
} catch (IOException e) {

View File

@ -105,6 +105,9 @@ public class DownloadDialog implements OnCollectionCallBackListener {
public void showPopupWindow(View view, GameEntity gameEntity, String entrance, String location) {
if (isShow && (popupWindow == null || !popupWindow.isShowing())) {
isShow = false;
}
if (isShow) {
return;
}

View File

@ -7,8 +7,6 @@ import android.util.Log;
import com.gh.common.util.HttpsUtils;
import com.gh.common.util.Utils;
import org.apache.http.HttpStatus;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
@ -52,66 +50,34 @@ public class DownloadThread extends Thread {
if (TextUtils.isEmpty(entry.getUrl())) {
listener.onStatusChanged(DownloadStatus.notfound);
Utils.log(DownloadThread.class.getSimpleName(),
"error-->url is empty");
Utils.log(DownloadThread.class.getSimpleName(), "error-->url is empty");
return;
}
URL url = new URL(entry.getUrl());
Utils.log("url = " + entry.getUrl());
HttpURLConnection connection;
if ("https".equals(url.getProtocol())) {
connection = HttpsUtils.getHttpsURLConnection(url);
} else {
connection = (HttpURLConnection) url.openConnection();
}
HttpURLConnection connection = openConnection(new URL(entry.getUrl()), targetFile.length());
connection.setRequestMethod("GET");
connection.setConnectTimeout(CONNECT_TIME);
connection.setReadTimeout(READ_TIME);
connection.setRequestProperty("RANGE",
"bytes=" + targetFile.length() + "-");
Utils.log(DownloadThread.class.getSimpleName(),
"startPosition-->" + targetFile.length());
//设置自动重定向
connection.setInstanceFollowRedirects(true);
Utils.log(DownloadThread.class.getSimpleName(), "startPosition-->" + targetFile.length());
int code = connection.getResponseCode();
Utils.log("code = " +code);
if (code == HttpStatus.SC_MOVED_PERMANENTLY
|| code == HttpStatus.SC_MOVED_TEMPORARILY) {
if (code == HttpURLConnection.HTTP_MOVED_PERM
|| code == HttpURLConnection.HTTP_MOVED_TEMP) {
//未自动重定向
String location = connection.getHeaderField("Location");
Utils.log("location = " + location);
url = new URL(location);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setConnectTimeout(CONNECT_TIME);
connection.setReadTimeout(READ_TIME);
connection.setRequestProperty("RANGE",
"bytes=" + targetFile.length() + "-");
Utils.log(DownloadThread.class.getSimpleName(),
"startPosition-->" + targetFile.length());
//设置自动重定向
connection.setInstanceFollowRedirects(true);
connection = openConnection(new URL(location), targetFile.length());
code = connection.getResponseCode();
}
if (code == HttpStatus.SC_NOT_FOUND) {
if (code == HttpURLConnection.HTTP_NOT_FOUND) {
// 404 Not Found
listener.onStatusChanged(DownloadStatus.notfound);
Utils.log(DownloadThread.class.getSimpleName(),
"error-->404 Not Found");
Utils.log(DownloadThread.class.getSimpleName(), "error-->404 Not Found");
return;
}
bis = new BufferedInputStream(connection.getInputStream());
if (targetFile.length() > 0) {
bos = new BufferedOutputStream(new FileOutputStream(entry.getPath(), true));
} else {
bos = new BufferedOutputStream(new FileOutputStream(entry.getPath()));
}
String eTag = connection.getHeaderField("ETag");
if (!TextUtils.isEmpty(eTag) && eTag.startsWith("\"") && eTag.endsWith("\"")) {
eTag = eTag.substring(1, eTag.length() - 1);
@ -122,8 +88,7 @@ public class DownloadThread extends Thread {
Utils.log("eTag = " + eTag);
Utils.log("eTag2 = " + eTag2);
listener.onStatusChanged(DownloadStatus.hijack);
Utils.log(DownloadThread.class.getSimpleName(),
"error-->链接被劫持");
Utils.log(DownloadThread.class.getSimpleName(), "error-->链接被劫持");
return;
}
@ -132,14 +97,20 @@ public class DownloadThread extends Thread {
if (entry.getSize() == 0) {
entry.setSize(conentLength);
DownloadDao.getInstance(context).newOrUpdate(entry);
Utils.log(DownloadThread.class.getSimpleName(),
"记录第一次长度");
Utils.log(DownloadThread.class.getSimpleName(), "记录第一次长度");
}
Utils.log(DownloadThread.class.getSimpleName(),
"progress:" + entry.getProgress() + "/curfilesize:"
+ targetFile.length() + "=====contentLength:"
+ conentLength + "/ totalSize:" + entry.getSize());
bis = new BufferedInputStream(connection.getInputStream());
if (targetFile.length() > 0) {
bos = new BufferedOutputStream(new FileOutputStream(entry.getPath(), true));
} else {
bos = new BufferedOutputStream(new FileOutputStream(entry.getPath()));
}
byte[] buffer = new byte[2048];
int len;
while ((len = bis.read(buffer)) != -1) {
@ -160,16 +131,15 @@ public class DownloadThread extends Thread {
listener.onStatusChanged(DownloadStatus.done);
}
} catch (Exception e) {
String errorMsg = Log.getStackTraceString(e);
// TODO 默认第一次错误自动恢复一次下载
//e.getMessage() will null error
String errorMsg = Log.getStackTraceString(e);
if (!TextUtils.isEmpty(e.getMessage()) && e.getMessage().contains("connection timeout")) {
listener.onStatusChanged(DownloadStatus.timeout, errorMsg);
} else {
listener.onStatusChanged(DownloadStatus.neterror, errorMsg);
}
Utils.log(DownloadThread.class.getSimpleName(),
"exception-->" + e.toString());
Utils.log(DownloadThread.class.getSimpleName(), "exception-->" + e.toString());
} finally {
if (bis != null) {
try {
@ -188,6 +158,23 @@ public class DownloadThread extends Thread {
}
}
private HttpURLConnection openConnection(URL url, long range) throws Exception {
HttpURLConnection connection;
if ("https".equals(url.getProtocol())) {
connection = HttpsUtils.getHttpsURLConnection(url);
} else {
connection = (HttpURLConnection) url.openConnection();
}
connection.setRequestMethod("GET");
connection.setConnectTimeout(CONNECT_TIME);
connection.setReadTimeout(READ_TIME);
connection.setDoInput(true);
connection.setRequestProperty("RANGE", "bytes=" + range + "-");
//设置自动重定向
connection.setInstanceFollowRedirects(true);
return connection;
}
public void setStatus(DownloadStatus status) {
this.status = status;
}

View File

@ -2,33 +2,39 @@ package com.gh.gamecenter;
import android.app.Dialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gh.base.BaseActivity;
import com.gh.common.constant.Config;
import com.gh.common.util.BitmapUtils;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.FileUtils;
import com.gh.common.util.TokenUtils;
import com.gh.common.view.CropImageCustom;
import org.apache.http.HttpStatus;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.lang.ref.SoftReference;
import java.net.HttpURLConnection;
public class CropImageActivity extends BaseActivity {
private CropImageCustom cropimage_custom;
private SoftReference<Bitmap> reference;
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
@ -76,13 +82,13 @@ public class CropImageActivity extends BaseActivity {
if (result != null) {
try {
int statusCode = result.getInt("statusCode");
if (statusCode == HttpStatus.SC_OK) {
if (statusCode == HttpURLConnection.HTTP_OK) {
Intent data = new Intent();
data.putExtra("url", result.getString("icon"));
setResult(RESULT_OK, data);
finish();
handler.sendEmptyMessage(0);
} else if (statusCode == HttpStatus.SC_FORBIDDEN
} else if (statusCode == HttpURLConnection.HTTP_FORBIDDEN
&& "too frequent".equals(result.getString("detail"))) {
handler.sendEmptyMessage(2);
}
@ -106,13 +112,27 @@ public class CropImageActivity extends BaseActivity {
rparams.addRule(RelativeLayout.CENTER_VERTICAL);
confirm.setLayoutParams(rparams);
reuse_actionbar.addView(confirm);
String path = getIntent().getStringExtra("path");
// TODO displayFile
// ImageUtils.getInstance(getApplicationContext()).displayFile(
// "file://" + path, cropimage_custom.getCropImageZoomView());
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus && (reference == null || reference.get() == null)) {
ImageView imageView = cropimage_custom.getCropImageZoomView();
Bitmap bitmap = BitmapUtils.getBitmapByFile(getIntent().getStringExtra("path"),
imageView.getWidth(), imageView.getHeight());
if (bitmap != null) {
reference = new SoftReference<>(bitmap);
imageView.setImageBitmap(reference.get());
}
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (reference != null) {
reference.get().recycle();
}
}
}

View File

@ -91,6 +91,7 @@ public class GameDetailActivity extends DetailActivity implements View.OnClickLi
iv_share.setVisibility(View.VISIBLE);
}
downloadAddWord = adapter.getGameDetailEntity().getDownloadAddWord();
downloadOffText = gameEntity.getDownloadOffText();
initDownload(true);
}
@ -142,12 +143,16 @@ public class GameDetailActivity extends DetailActivity implements View.OnClickLi
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Gson gson = new Gson();
gameEntity = gson.fromJson(response.toString(), GameEntity.class);
title = gameEntity.getName();
actionbar_tv_title.setText(gameEntity.getName());
adapter.setGameEntity(gameEntity);
adapter.getGameDetail();
if (response.length() != 0) {
Gson gson = new Gson();
gameEntity = gson.fromJson(response.toString(), GameEntity.class);
title = gameEntity.getName();
actionbar_tv_title.setText(gameEntity.getName());
adapter.setGameEntity(gameEntity);
adapter.getGameDetail();
} else {
reuse_no_connection.setVisibility(View.VISIBLE);
}
}
}, new Response.ErrorListener() {
@Override

View File

@ -677,7 +677,6 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
concernInfo.setPackageNames(packageNames);
concernManager.updateByConcern(concernInfo);
}
if (isNewFirstLaunch) {
//默认安装即为关注
if (!concernManager.isConcern(gameEntity.getId())) {
@ -685,7 +684,6 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
}
}
}
addConcernCount();
if (cCount == size) {
update();
@ -854,9 +852,11 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Gson gson = new Gson();
GameEntity gameEntity = gson.fromJson(response.toString(), GameEntity.class);
list.add(gameEntity);
if (response.length() != 0) {
Gson gson = new Gson();
GameEntity gameEntity = gson.fromJson(response.toString(), GameEntity.class);
list.add(gameEntity);
}
addCount();
if (count == size) {
processPluginData(list);
@ -993,18 +993,20 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
boolean isShow = response.getBoolean("isShow");
sp.edit().putBoolean("isShowDisclaimer", isShow).apply();
if (isShow) {
String content = response.getString("content");
sp.edit().putString("disclaimer", content).apply();
if (isFirst) {
DialogUtils.showDisclaimerDialog(MainActivity.this, content);
if (response.length() != 0) {
try {
boolean isShow = response.getBoolean("isShow");
sp.edit().putBoolean("isShowDisclaimer", isShow).apply();
if (isShow) {
String content = response.getString("content");
sp.edit().putString("disclaimer", content).apply();
if (isFirst) {
DialogUtils.showDisclaimerDialog(MainActivity.this, content);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, null);
@ -1036,7 +1038,7 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
Intent toIntent = new Intent(MainActivity.this, clazz);
if ("NewsActivity".equals(to) || "NewsDetailActivity".equals(to)) {
toIntent.putExtra("newsId", getIntent().getExtras().getString("newsId"));
toIntent.putExtra("entrance", getIntent().getExtras().getString("entrance"));
toIntent.putExtra("entrance", "(插件跳转)");
} else if("DownloadManagerActivity".equals(to)) {
String packageName = getIntent().getExtras().getString("packageName");
if (packageName != null) {
@ -1045,7 +1047,7 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
}
} else if ("GameDetailsActivity".equals(to) || "GameDetailActivity".equals(to)) {
toIntent.putExtra("gameId", getIntent().getExtras().getString("gameId"));
toIntent.putExtra("entrance", getIntent().getExtras().getString("entrance"));
toIntent.putExtra("entrance", "(插件跳转)");
} else if ("SubjectActivity".equals(to)) {
toIntent.putExtra("id", getIntent().getExtras().getString("id"));
toIntent.putExtra("name", getIntent().getExtras().getString("name"));
@ -1067,12 +1069,12 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
startActivity(intent);
} else if (from.equals("mipush_news")) {
Intent intent = new Intent(MainActivity.this, NewsDetailActivity.class);
intent.putExtra("entrance", "小米推送");
intent.putExtra("entrance", "(小米推送)");
intent.putExtra("newsId", getIntent().getStringExtra("newsId"));
startActivity(intent);
} else if (from.equals("mipush_new_game")) {
Intent intent = new Intent(MainActivity.this, GameDetailActivity.class);
intent.putExtra("entrance", "小米推送");
intent.putExtra("entrance", "(小米推送)");
startActivity(intent);
} else if (from.equals("mipush_plugin")) {
Intent intent = new Intent(MainActivity.this, DownloadManagerActivity.class);
@ -1550,23 +1552,25 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Gson gson = new Gson();
GameEntity gameEntity = gson.fromJson(response.toString(), GameEntity.class);
GameManager manager = new GameManager(getApplicationContext());
manager.addOrUpdate(gameEntity.getApk(), gameEntity.getId(), gameEntity.getName());
if (!concernManager.isConcern(id)) {
concernManager.addByEntity(gameEntity);
}
// 检查是否能插件化
if (gameEntity.getTag() != null && gameEntity.getTag().size() != 0
&& gameEntity.getApk() != null) {
for (ApkEntity apkEntity : gameEntity.getApk()) {
if (apkEntity.getPackageName().equals(packageName)
&& !TextUtils.isEmpty(apkEntity.getGhVersion())
&& !PackageUtils.isSignature(getApplicationContext(), apkEntity.getPackageName())) {
PackageManager.addUpdate(getGameUpdateEntity(gameEntity, apkEntity));
EventBus.getDefault().post(new EBDownloadStatus("plugin"));
break;
if (response.length() != 0) {
Gson gson = new Gson();
GameEntity gameEntity = gson.fromJson(response.toString(), GameEntity.class);
GameManager manager = new GameManager(getApplicationContext());
manager.addOrUpdate(gameEntity.getApk(), gameEntity.getId(), gameEntity.getName());
if (!concernManager.isConcern(id)) {
concernManager.addByEntity(gameEntity);
}
// 检查是否能插件化
if (gameEntity.getTag() != null && gameEntity.getTag().size() != 0
&& gameEntity.getApk() != null) {
for (ApkEntity apkEntity : gameEntity.getApk()) {
if (apkEntity.getPackageName().equals(packageName)
&& !TextUtils.isEmpty(apkEntity.getGhVersion())
&& !PackageUtils.isSignature(getApplicationContext(), apkEntity.getPackageName())) {
PackageManager.addUpdate(getGameUpdateEntity(gameEntity, apkEntity));
EventBus.getDefault().post(new EBDownloadStatus("plugin"));
break;
}
}
}
}

View File

@ -224,20 +224,28 @@ public class NewsDetailActivity extends DetailActivity implements OnClickListene
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Gson gson = new Gson();
NewsEntity newsEntity = gson.fromJson(response.toString(), NewsEntity.class);
if (newsEntity.getType() != null) {
actionbar_tv_title.setText(newsEntity.getType());
if (response.length() != 0) {
Gson gson = new Gson();
NewsEntity newsEntity = gson.fromJson(response.toString(), NewsEntity.class);
if (newsEntity.getType() != null) {
actionbar_tv_title.setText(newsEntity.getType());
}
adapter.setId(news_id);
adapter.setType(newsEntity.getType());
adapter.setTitle(newsEntity.getTitle());
adapter.getNewsDetail();
title = newsEntity.getTitle();
iv_share.setVisibility(View.VISIBLE);
} else {
detail_rv_show.setVisibility(View.GONE);
reuse_ll_loading.setVisibility(View.GONE);
detail_ll_bottom.setVisibility(View.GONE);
detail_rv_show.setPadding(0, 0, 0, 0);
reuse_no_connection.setVisibility(View.VISIBLE);
}
adapter.setId(news_id);
adapter.setType(newsEntity.getType());
adapter.setTitle(newsEntity.getTitle());
adapter.getNewsDetail();
title = newsEntity.getTitle();
iv_share.setVisibility(View.VISIBLE);
}
}, new Response.ErrorListener() {
@Override
@ -325,12 +333,15 @@ public class NewsDetailActivity extends DetailActivity implements OnClickListene
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Gson gson = new Gson();
gameEntity = gson.fromJson(response.toString(), GameEntity.class);
adapter.setGameEntity(gameEntity); //出现空指针 找不到原因
adapter.notifyItemInserted(1);
downloadAddWord = gameEntity.getDownloadAddWord();
initDownload(true);
if (response.length() != 0) {
Gson gson = new Gson();
gameEntity = gson.fromJson(response.toString(), GameEntity.class);
adapter.setGameEntity(gameEntity);
adapter.notifyItemInserted(1);
downloadAddWord = gameEntity.getDownloadAddWord();
downloadOffText = gameEntity.getDownloadOffText();
initDownload(true);
}
}
}, null);
AppController.addToRequestQueue(gameRequest, TAG);

View File

@ -136,12 +136,12 @@ public class PluginActivity extends BaseActivity {
if (list.get(i).getApk().get(0).getPackageName().equals(busFour.getPackageName())) {
list.remove(i);
adapter.notifyItemRemoved(location);
adapter.initLocationMap();
break;
}
}
}
}
adapter.initLocationMap();
}
}

View File

@ -26,7 +26,6 @@ import com.gh.common.constant.Config;
import com.gh.common.util.FileUtils;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.TimestampUtils;
import com.gh.common.util.Utils;
import com.gh.download.DownloadManager;
import com.gh.download.DownloadService;
import com.gh.gamecenter.db.info.FilterInfo;
@ -295,18 +294,19 @@ public class SplashScreenActivity extends BaseActivity {
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Utils.log(response.toString());
try {
Editor editor = sp.edit();
editor.putInt("download_box_row",
response.getJSONObject("download_box").getInt("row"));
editor.putInt("download_box_column",
response.getJSONObject("download_box").getInt("column"));
editor.putInt("game_detail_news_type_tab_column",
response.getJSONObject("game_detail_news_type_tab").getInt("column"));
editor.apply();
} catch (JSONException e) {
e.printStackTrace();
if (response.length() != 0) {
try {
Editor editor = sp.edit();
editor.putInt("download_box_row",
response.getJSONObject("download_box").getInt("row"));
editor.putInt("download_box_column",
response.getJSONObject("download_box").getInt("column"));
editor.putInt("game_detail_news_type_tab_column",
response.getJSONObject("game_detail_news_type_tab").getInt("column"));
editor.apply();
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}, null);
@ -325,16 +325,18 @@ public class SplashScreenActivity extends BaseActivity {
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
String status = response.getString("status");
if ("on".equals(status)) {
sp.edit().putBoolean("isShow", true).apply();
} else {
sp.edit().putBoolean("isShow", false).apply();
if (response.length() != 0) {
try {
String status = response.getString("status");
if ("on".equals(status)) {
sp.edit().putBoolean("isShow", true).apply();
} else {
sp.edit().putBoolean("isShow", false).apply();
}
EventBus.getDefault().post(new EBReuse("Refresh"));
} catch (JSONException e) {
e.printStackTrace();
}
EventBus.getDefault().post(new EBReuse("Refresh"));
} catch (JSONException e) {
e.printStackTrace();
}
}
}, null);

View File

@ -194,19 +194,23 @@ public class SuggestionActivity extends BaseActivity implements OnClickListener
Config.HOST + "support/suggestion", new JSONObject(map),
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject object) {
public void onResponse(JSONObject response) {
isShowing = false;
dialog.dismiss();
try {
if ("ok".equals(object.getString("status"))) {
toast("提交成功,感谢您的反馈!");
finish();
} else {
toast("提交失败,请稍后尝试!");
if (response.length() != 0) {
try {
if ("ok".equals(response.getString("status"))) {
toast("提交成功,感谢您的反馈!");
finish();
} else {
toast("提交失败,请稍后尝试!");
}
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException e) {
e.printStackTrace();
} else {
toast("提交失败,请稍后尝试!");
}
}

View File

@ -237,12 +237,7 @@ public class ViewImageActivity extends BaseActivity implements
connection.setReadTimeout(5 * 1000);
connection.connect();
int code = connection.getResponseCode();
if (code == 200) {
//图片存在
if (urls == null) {
return;
}
//urls出现空指针
if (code == 200 && urls != null) {
for (int i = 0, size = urls.size(); i < size; i++) {
if (urls.get(i).equals(url)) {
newUrls.put(i, newUrl);

View File

@ -75,8 +75,10 @@ public class ConcernAdapter extends RecyclerView.Adapter<ConcernViewHolder> {
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
if (response.length() != 0) {
result.add(response);
}
addConcernCount();
result.add(response);
if (cCount == count) {
processingConcernGame(result);
}

View File

@ -77,9 +77,13 @@ public class ConcernRecommendAdapter extends RecyclerView.Adapter<ConcernViewHol
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Gson gson = new Gson();
GameEntity gameEntity = gson.fromJson(response.toString(), GameEntity.class);
gameList.add(gameEntity);
if (response.length() != 0) {
Gson gson = new Gson();
GameEntity gameEntity = gson.fromJson(response.toString(), GameEntity.class);
if (gameEntity.isNewsExists()) {
gameList.add(gameEntity);
}
}
addCount();
if (count == size) {
initRecommendGame();

View File

@ -94,14 +94,14 @@ public class ImagePagerAdapter extends RecyclingPagerAdapter {
DataUtils.onEvent(context, "点击", "游戏-插件-滚动图", kv);
if ("game".equals(slideEntity.getType())) {
GameUtils.startGameDetailActivity(context, slideEntity.getLink(), "游戏-插件-滚动图");
GameUtils.startGameDetailActivity(context, slideEntity.getLink(), "(游戏-插件:滚动图)");
} else if ("news".equals(slideEntity.getType())) {
// 统计阅读量
NewsUtils.statNewsViews(slideEntity.getLink());
Intent intent = new Intent(context, NewsDetailActivity.class);
intent.putExtra("newsId", slideEntity.getLink());
intent.putExtra("entrance", "游戏-插件-滚动图");
intent.putExtra("entrance", "(游戏-插件:滚动图)");
context.startActivity(intent);
} else if ("column".equals(slideEntity.getType())) {
Intent intent = new Intent(context, SubjectActivity.class);

View File

@ -318,7 +318,7 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
map.put("game_id", gameEntity.getId());
DataCollectionManager.onEvent(context, "click-item", map);
GameUtils.startGameDetailActivity(context, gameEntity, entrance + "(" + name + ")");
GameUtils.startGameDetailActivity(context, gameEntity, entrance + "+(" + name + ")");
}
});
@ -329,7 +329,7 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
holder.downloadBtn.setVisibility(View.VISIBLE);
DownloadItemUtils.setOnClickListener(context,
holder.downloadBtn, gameEntity, position,
SubjectAdapter.this, entrance + "(" + name + ")", name + ":" + gameEntity.getName());
SubjectAdapter.this, entrance + "+(" + name + ")", name + ":" + gameEntity.getName());
} else {
long endTime = Long.valueOf(gameEntity.getTest().getEnd()
+ "000");
@ -342,7 +342,7 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
holder.downloadBtn.setVisibility(View.VISIBLE);
DownloadItemUtils.setOnClickListener(context,
holder.downloadBtn, gameEntity, position,
SubjectAdapter.this, entrance + "(" + name + ")", name + ":" + gameEntity.getName());
SubjectAdapter.this, entrance + "+(" + name + ")", name + ":" + gameEntity.getName());
}
}
}
@ -403,12 +403,12 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
map.put("game_id", gameEntity.getId());
DataCollectionManager.onEvent(context, "click-item", map);
GameUtils.startGameDetailActivity(context, gameEntity, entrance + "(" + name + ")");
GameUtils.startGameDetailActivity(context, gameEntity, entrance + "+(" + name + ")");
}
});
DownloadItemUtils.setOnClickListener(context, holder.downloadBtn,
gameEntity, position, this, entrance + "(" + name + ")", name + ":" + gameEntity.getName());
gameEntity, position, this, entrance + "+(" + name + ")", name + ":" + gameEntity.getName());
DownloadItemUtils.updateItem(context, holder.gameDes,
holder.game_progressbar, holder.game_ll_info,

View File

@ -29,7 +29,6 @@ public class DataCollectionDao {
try {
return dao.queryForEq("type", type);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;

View File

@ -146,8 +146,8 @@ public class GameUpdateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
} else {
gameupdate_tv_none.setVisibility(View.GONE);
}
gameupdate_ll_loading.setVisibility(View.GONE);
}
gameupdate_ll_loading.setVisibility(View.GONE);
}
}, new Response.ErrorListener() {
@Override
@ -566,7 +566,7 @@ public class GameUpdateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
}
map.put("platform", PlatformUtils.getInstance(context)
.getPlatformName(updateEntity.getPlatform()));
map.put("location", "游戏更新");
map.put("location", "游戏更新:列表");
map.put("entrance", "(下载管理:游戏更新)");
map.put("network", NetworkUtils.getConnectedType(context));
DataCollectionManager.onEvent(context, "download", map);

View File

@ -15,13 +15,11 @@ import android.widget.TextView;
import com.gh.base.AppController;
import com.gh.gamecenter.MainActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.entity.GameUpdateEntity;
import com.gh.gamecenter.eventbus.EBDownloadChanged;
import com.gh.gamecenter.eventbus.EBDownloadStatus;
import com.gh.gamecenter.eventbus.EBMiPush;
import com.gh.gamecenter.eventbus.EBPackage;
import com.gh.gamecenter.eventbus.EBSkip;
import com.gh.gamecenter.manager.PackageManager;
import java.util.ArrayList;

View File

@ -18,6 +18,16 @@ public class GameDetailEntity {
private ArrayList<String> articleTypes;
@SerializedName("share_code")
private String shareCode;
@SerializedName("download_off_text")
private String downloadOffText;
public void setDownloadOffText(String downloadOffText) {
this.downloadOffText = downloadOffText;
}
public String getDownloadOffText() {
return downloadOffText;
}
public ArrayList<String> getArticleTypes() {
return articleTypes;

View File

@ -42,14 +42,25 @@ public class GameEntity {
private String link;
@SerializedName("concern_article_exists")
private boolean exists = true;
private boolean newsExists = true;
public boolean isExists() {
return exists;
@SerializedName("download_off_text")
private String downloadOffText;
public void setDownloadOffText(String downloadOffText) {
this.downloadOffText = downloadOffText;
}
public void setExists(boolean exists) {
this.exists = exists;
public String getDownloadOffText() {
return downloadOffText;
}
public boolean isNewsExists() {
return newsExists;
}
public void setNewsExists(boolean newsExists) {
this.newsExists = newsExists;
}
public String getLink() {
@ -181,15 +192,27 @@ public class GameEntity {
gameEntity.setIcon(icon);
gameEntity.setName(name);
gameEntity.setBrief(brief);
gameEntity.setTag(new ArrayList<>(tag));
gameEntity.setApk(new ArrayList<>(apk));
if (tag != null) {
gameEntity.setTag(new ArrayList<>(tag));
}
if (apk != null) {
gameEntity.setApk(new ArrayList<>(apk));
}
if (collection != null) {
gameEntity.setCollection(new ArrayList<>(collection));
}
gameEntity.setSlide(slide);
gameEntity.setTest(test);
gameEntity.setDownloadAddWord(downloadAddWord);
gameEntity.setEntryMap(new ArrayMap<String, DownloadEntity>(entryMap));
if (entryMap != null) {
gameEntity.setEntryMap(new ArrayMap<String, DownloadEntity>(entryMap));
}
gameEntity.setImage(image);
gameEntity.setType(type);
gameEntity.setPluggable(isPluggable);
gameEntity.setLink(link);
gameEntity.setNewsExists(newsExists);
gameEntity.setDownloadOffText(downloadOffText);
return gameEntity;
}

View File

@ -25,7 +25,6 @@ import com.gh.gamecenter.eventbus.EBNetworkState;
import com.gh.gamecenter.eventbus.EBPackage;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.eventbus.EBUISwitch;
import com.gh.gamecenter.manager.PackageManager;
import java.util.ArrayList;
import java.util.List;
@ -159,7 +158,7 @@ public class Game1Fragment extends BaseFragment implements SwipeRefreshLayout.On
// 插件化列表
if ("安装".equals(busFour.getType()) || "卸载".equals(busFour.getType())) {
List<GameEntity> list = adapter.getPluginList();
for (int i = 0, size = list.size(); i < size; i++) {
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getApk().get(0).getPackageName().equals(busFour.getPackageName())) {
if ("卸载".equals(busFour.getType())
&& DownloadManager.getInstance(getActivity()).get(

View File

@ -199,6 +199,7 @@ public class Game1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
if (subjectEntity.getData().size() == 1
&& !TextUtils.isEmpty(subjectEntity.getData().get(0).getImage())){
list.remove(j);
j--;
continue;
}
for (int i = 0; i < subjectEntity.getData().size(); i++) {
@ -872,7 +873,8 @@ public class Game1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
index = 0;
}
gameEntity = subjectList.get(i).getData().get(index);
if (position == offset && TextUtils.isEmpty(gameEntity.getImage()) || position == offset+1&&!TextUtils.isEmpty(subjectList.get(i).getData().get(0).getImage())) {
if (position == offset && TextUtils.isEmpty(gameEntity.getImage()) || position == offset + 1
&& !TextUtils.isEmpty(subjectList.get(i).getData().get(0).getImage())) {
if (TextUtils.isEmpty(subjectList.get(i).getData().get(0).getImage())
&& pluginList.isEmpty() && i == 0) {
((CardLinearLayout) holder.itemView).setmTop(DisplayUtils.dip2px(context, 8));
@ -931,8 +933,7 @@ public class Game1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
@Override
public void onPageSelected(int position) {
for (int i = 0, size = viewpager_ll_hint
.getChildCount(); i < size; i++) {
for (int i = 0, size = viewpager_ll_hint.getChildCount(); i < size; i++) {
if (i == position % size) {
((ImageView) viewpager_ll_hint.getChildAt(i))
.setImageResource(R.drawable.oval_hint_up);

View File

@ -89,7 +89,6 @@ public class Game2FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Type listType = new TypeToken<ArrayList<SubjectEntity>>() {}.getType();
Gson gson = new Gson();
List<SubjectEntity> list = gson.fromJson(response.toString(), listType);
@ -102,6 +101,7 @@ public class Game2FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
if (subjectEntity.getData().size() == 1
&& !TextUtils.isEmpty(subjectEntity.getData().get(0).getImage())){
list.remove(j);
j--;
continue;
}
for (int i = 0; i < subjectEntity.getData().size(); i++) {
@ -211,17 +211,17 @@ public class Game2FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
GameEntity gameEntity;
for (int i = 0; i < subjectList.size(); i++) {
if (position >= offset && position <= subjectList.get(i).getData().size() + offset) {
int index = position -offset-1;
int index = position - offset - 1;
if (index < 0) {
index = 0;
}
gameEntity = subjectList.get(i).getData().get(index);
if (position == offset && !TextUtils.isEmpty(gameEntity.getImage())){
if (position == offset && !TextUtils.isEmpty(gameEntity.getImage())) {
return ItemViewType.GAME_IMAGE;
}else if (position == offset){
} else if (position == offset) {
return ItemViewType.COLUMN_HEADER;
}
if (position == offset+1 && !TextUtils.isEmpty(subjectList.get(i).getData().get(0).getImage())) {
if (position == offset + 1 && !TextUtils.isEmpty(subjectList.get(i).getData().get(0).getImage())) {
return ItemViewType.COLUMN_HEADER;
}
if (gameEntity.getTest() != null) {
@ -335,7 +335,7 @@ public class Game2FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
GameEntity gameEntity;
for (int i = 0, size = subjectList.size(); i < size; i++) {
if (position > offset && position <= subjectList.get(i).getData().size() + offset) {
int index = position -offset-1;
int index = position - offset - 1;
if (index<0){
index = 0;
}

View File

@ -97,7 +97,6 @@ public class Game3FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
JsonArrayExtendedRequest request = new JsonArrayExtendedRequest(
Config.HOST + "game/danjiyouxi?limit=20&offset=" + offset,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
processingData(response, offset);
@ -105,7 +104,6 @@ public class Game3FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
isLoading = false;

View File

@ -103,12 +103,16 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Gson gson = new Gson();
gameDetailEntity = gson.fromJson(response.toString(), GameDetailEntity.class);
if (response.length() != 0) {
Gson gson = new Gson();
gameDetailEntity = gson.fromJson(response.toString(), GameDetailEntity.class);
getGameNews();
getGameNews();
getNewsServer();
getNewsServer();
} else if (listener != null) {
listener.loadError();
}
}
}, new Response.ErrorListener() {
@Override
@ -159,51 +163,49 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
if (response.length() != 0) {
try {
ArrayList<ServerEntity> serverInfo = new ArrayList<>();
SimpleDateFormat format = new SimpleDateFormat(
"Mdd", Locale.getDefault());
int today = Integer.valueOf(format.format(new Date()));
for (int j = 0, sizej = response.length(); j < sizej; j++) {
ServerEntity entity = new ServerEntity();
JSONObject jsonObject2;
jsonObject2 = response.getJSONObject(j);
String server = jsonObject2.getString("server");
if (server.length() > 4) {
server = server.substring(0, 4);
}
entity.setServer(server);
entity.setTime(Long.valueOf(jsonObject2.getString("time") + "000"));
int day = Integer.valueOf(format.format(new Date(entity.getTime())));
if (day == today + 1) {
entity.setTag("明天");
serverInfo.add(entity);
} else if (day == today - 1) {
entity.setTag("昨天");
serverInfo.add(entity);
} else if (day == today) {
entity.setTag("今天");
serverInfo.add(entity);
}
try {
ArrayList<ServerEntity> serverInfo = new ArrayList<>();
SimpleDateFormat format = new SimpleDateFormat(
"Mdd", Locale.getDefault());
int today = Integer.valueOf(format.format(new Date()));
for (int i = 0, size = response.length(); i < size; i++) {
ServerEntity entity = new ServerEntity();
JSONObject jsonObject2;
jsonObject2 = response.getJSONObject(i);
String server = jsonObject2.getString("server");
if (server.length() > 4) {
server = server.substring(0, 4);
}
Comparator<ServerEntity> comparator = new Comparator<ServerEntity>() {
@Override
public int compare(ServerEntity lhs, ServerEntity rhs) {
return (int) (lhs.getTime() - rhs.getTime());
}
};
Collections.sort(serverInfo, comparator);
gameDetailEntity.setServerInfo(serverInfo);
initPosition();
if (position_newsserver != -1) {
notifyItemInserted(position_newsserver);
entity.setServer(server);
entity.setTime(Long.valueOf(jsonObject2.getString("time") + "000"));
int day = Integer.valueOf(format.format(new Date(entity.getTime())));
if (day == today + 1) {
entity.setTag("明天");
serverInfo.add(entity);
} else if (day == today - 1) {
entity.setTag("昨天");
serverInfo.add(entity);
} else if (day == today) {
entity.setTag("今天");
serverInfo.add(entity);
}
} catch (JSONException e) {
e.printStackTrace();
}
Comparator<ServerEntity> comparator = new Comparator<ServerEntity>() {
@Override
public int compare(ServerEntity lhs, ServerEntity rhs) {
return (int) (lhs.getTime() - rhs.getTime());
}
};
Collections.sort(serverInfo, comparator);
gameDetailEntity.setServerInfo(serverInfo);
initPosition();
if (position_newsserver != -1) {
notifyItemInserted(position_newsserver);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, null);

View File

@ -247,7 +247,6 @@ public class DataCollectionManager {
@Override
public void onResponse(JSONObject response) {
isUploading = false;
Utils.log(response);
try {
if ("success".equals(response.getString("status"))) {
// 上传成功,删除本地数据
@ -262,7 +261,6 @@ public class DataCollectionManager {
public void onErrorResponse(VolleyError error) {
isUploading = false;
// 上传失败,检查网络状态,继续上传
Utils.log(error);
if (error.networkResponse != null) {
Utils.log(new String(error.networkResponse.data));
}

View File

@ -7,7 +7,6 @@ import com.android.volley.Request;
import com.android.volley.Response;
import com.gh.base.AppController;
import com.gh.common.constant.Config;
import com.gh.common.util.Utils;
import com.gh.gamecenter.db.FilterDao;
import com.gh.gamecenter.db.info.FilterInfo;
import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
@ -56,11 +55,8 @@ public class FilterManager {
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Utils.log("getFilterFromServer=" + response.toString());
try {
List<FilterInfo> list = new ArrayList<FilterInfo>();
List<FilterInfo> list = new ArrayList<>();
for (int i = 0, size = response.length(); i < size; i++) {
list.add(new FilterInfo(response.getString(i)));
}

View File

@ -182,7 +182,6 @@ public class News1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Utils.log("response = " + response);
try {
JSONObject jsonObject;
for (int i = 0, size = response.length(); i < size; i++) {

View File

@ -183,7 +183,6 @@ public class News2FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Utils.log("response = " + response);
try {
JSONObject jsonObject;
for (int i = 0, size = response.length(); i < size; i++) {
@ -453,7 +452,7 @@ public class News2FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
if ("success".equals(response.getString("status"))) {
Integer views = viewsMap.get(news_id);
if (views == null) {
views = new Integer(0);
views = 0;
}
views += 1;
viewsMap.put(news_id, views);

View File

@ -99,10 +99,8 @@ public class News3FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
Config.HOST + "news?type_group=" + Uri.encode("攻略")
+ "&offset=" + offset + "&limit=20",
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Type listType = new TypeToken<ArrayList<NewsEntity>>() {}.getType();
Gson gson = new Gson();
List<NewsEntity> list = gson.fromJson(response.toString(), listType);
@ -187,7 +185,6 @@ public class News3FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
}
}
}
});
AppController.addToRequestQueue(request, News3Fragment.TAG);
}

View File

@ -322,13 +322,13 @@ public class News4Fragment extends BaseFragment implements SwipeRefreshLayout.On
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
if (response.length() != 0){
if (response.length() != 0) {
Gson gson = new Gson();
GameEntity gameEntity = gson.fromJson(response.toString(), GameEntity.class);
if (finalI == size - 1){
if (finalI == size - 1) {
recommendGameList.add(gameEntity);
}else if (gameEntity.isExists()){
} else if (gameEntity.isNewsExists()) {
installGameList.add(gameEntity);
}
}
@ -386,10 +386,10 @@ public class News4Fragment extends BaseFragment implements SwipeRefreshLayout.On
//自由排序
if (recommendGameList.size() < 4){
for (GameEntity gameEntity : installGameList) {
if (recommendGameList.size() >= 4 || concernManager.isConcern(gameEntity.getId())){
continue;
if (recommendGameList.size() < 4
&& !concernManager.isConcern(gameEntity.getId())) {
recommendGameList.add(gameEntity);
}
recommendGameList.add(gameEntity);
}
}

View File

@ -46,13 +46,13 @@ import com.gh.gamecenter.volley.extended.JsonObjectExtendedRequest;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.apache.http.HttpStatus;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -152,6 +152,7 @@ public class News4FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
@Override
public void onResponse(JSONArray response) {
isLoading = false;
Type listType = new TypeToken<ArrayList<ConcernEntity>>() {}.getType();
Gson gson = new Gson();
List<ConcernEntity> list = gson.fromJson(response.toString(), listType);
@ -185,7 +186,7 @@ public class News4FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
public void onErrorResponse(VolleyError error) {
isLoading = false;
if (error.networkResponse != null
&& error.networkResponse.statusCode == HttpStatus.SC_CONFLICT) {
&& error.networkResponse.statusCode == HttpURLConnection.HTTP_CONFLICT) {
loadDataByGameId(offset);
updateConcern();
} else {
@ -220,6 +221,7 @@ public class News4FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
@Override
public void onResponse(JSONArray response) {
isLoading = false;
Type listType = new TypeToken<ArrayList<ConcernEntity>>() {}.getType();
Gson gson = new Gson();
List<ConcernEntity> list = gson.fromJson(response.toString(), listType);
@ -328,7 +330,6 @@ public class News4FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Utils.log("response = " + response);
try {
JSONObject jsonObject;
for (int i = 0, size = response.length(); i < size; i++) {

View File

@ -105,7 +105,6 @@ public class NewsDetailAdapter extends RecyclerView.Adapter {
listener.loadError();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
@ -136,7 +135,7 @@ public class NewsDetailAdapter extends RecyclerView.Adapter {
}
}
List<NewsEntity> more = new ArrayList<>();
// TODO 随机三篇文章
// 随机三篇文章
int[] index = RandomUtils.getRandomArray(list.size() > 3 ? 3 : list.size(), list.size());
for (int i : index) {
more.add(list.get(i));

View File

@ -93,7 +93,9 @@ public class ConcernFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
result.add(response);
if (response.length() != 0) {
result.add(response);
}
addCount();
if (count == size) {
processingConcernGame(result);

View File

@ -225,7 +225,9 @@ public class InstallFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
result.add(response);
if (response.length() != 0) {
result.add(response);
}
addCount();
if (count == size) {
processingData(result);
@ -308,7 +310,6 @@ public class InstallFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
ArrayList<Integer> list;
for (int i = 0; i < gameList.size(); i++) {
gameEntity = gameList.get(i);
// TODO ERROR IndexOutOfBoundsException InstallFragmentAdapter initLocationMap 290
if (gameEntity.getApk() != null && gameEntity.getApk().size() != 0) {
for (ApkEntity apkEntity : gameEntity.getApk()) {
list = locationMap.get(apkEntity.getPackageName());

View File

@ -52,10 +52,10 @@ import com.gh.gamecenter.manager.DataCollectionManager;
import com.gh.gamecenter.volley.extended.StringExtendedRequest;
import com.tencent.stat.StatConfig;
import org.apache.http.HttpStatus;
import org.json.JSONException;
import org.json.JSONObject;
import java.net.HttpURLConnection;
import java.util.HashMap;
import java.util.Map;
@ -294,7 +294,6 @@ public class PersonalFragment extends Fragment implements View.OnClickListener,
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0x123 && data != null) {
Uri selectedImage = data.getData();
// TODO 华为手机选择图片后有自带预览如在预览时取消getData()返回为null
if (selectedImage == null) {
return;
}
@ -425,7 +424,7 @@ public class PersonalFragment extends Fragment implements View.OnClickListener,
public void onErrorResponse(VolleyError error) {
waitDialog.dismiss();
if (error.networkResponse != null
&& error.networkResponse.statusCode == HttpStatus.SC_FORBIDDEN) {
&& error.networkResponse.statusCode == HttpURLConnection.HTTP_FORBIDDEN) {
try {
JSONObject response = new JSONObject(new String(error.networkResponse.data));
String detail = response.getString("detail");

View File

@ -86,6 +86,7 @@ public class SearchGameListFragmentAdapter extends RecyclerView.Adapter<Recycler
@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);

View File

@ -12,10 +12,9 @@ import com.gh.common.util.GzipUtils;
import com.gh.common.util.TimestampUtils;
import com.gh.common.util.Utils;
import org.apache.http.HttpStatus;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.util.HashMap;
import java.util.Map;
@ -65,9 +64,9 @@ public abstract class ExtendedRequest<T> extends Request<T> {
String responseString = null;
String charset = HttpHeaderParser.parseCharset(response.headers);
if (HttpStatus.SC_NOT_MODIFIED == response.statusCode
if (HttpURLConnection.HTTP_NOT_MODIFIED == response.statusCode
|| (mGzipEnabled && isGzipped(response.headers))
|| HttpStatus.SC_OK == response.statusCode) {
|| HttpURLConnection.HTTP_OK == response.statusCode) {
try {
byte[] data = GzipUtils.decompressBytes(response.data);
responseString = new String(data, charset);