添加downloadOffText,检查下载上传数据是否完整
This commit is contained in:
@ -60,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();
|
||||
|
||||
@ -166,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);
|
||||
|
||||
@ -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";
|
||||
}
|
||||
final String finalQq = qq;
|
||||
|
||||
@ -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;
|
||||
@ -271,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) {
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -22,12 +22,12 @@ 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 {
|
||||
|
||||
@ -82,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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -962,7 +962,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) {
|
||||
@ -971,7 +971,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"));
|
||||
@ -993,12 +993,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);
|
||||
|
||||
@ -339,6 +339,7 @@ public class NewsDetailActivity extends DetailActivity implements OnClickListene
|
||||
adapter.setGameEntity(gameEntity);
|
||||
adapter.notifyItemInserted(1);
|
||||
downloadAddWord = gameEntity.getDownloadAddWord();
|
||||
downloadOffText = gameEntity.getDownloadOffText();
|
||||
initDownload(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,6 @@ import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
import com.gh.common.view.Gh_RelativeLayout;
|
||||
import com.gh.common.view.Gh_RelativeLayout.OnSingleTapListener;
|
||||
|
||||
|
||||
@ -80,7 +80,9 @@ public class ConcernRecommendAdapter extends RecyclerView.Adapter<ConcernViewHol
|
||||
if (response.length() != 0) {
|
||||
Gson gson = new Gson();
|
||||
GameEntity gameEntity = gson.fromJson(response.toString(), GameEntity.class);
|
||||
gameList.add(gameEntity);
|
||||
if (gameEntity.isNewsExists()) {
|
||||
gameList.add(gameEntity);
|
||||
}
|
||||
}
|
||||
addCount();
|
||||
if (count == size) {
|
||||
|
||||
@ -96,14 +96,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);
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -328,7 +328,7 @@ public class News4Fragment extends BaseFragment implements SwipeRefreshLayout.On
|
||||
|
||||
if (finalI == size - 1) {
|
||||
recommendGameList.add(gameEntity);
|
||||
} else if (gameEntity.isExists()) {
|
||||
} else if (gameEntity.isNewsExists()) {
|
||||
installGameList.add(gameEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
@ -186,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 {
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -424,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");
|
||||
|
||||
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user