Merge remote-tracking branch 'origin/2.1' into 2.1
This commit is contained in:
@ -195,8 +195,8 @@ public abstract class DetailActivity extends BaseActivity implements View.OnClic
|
||||
}
|
||||
} else {
|
||||
if (gameEntity.getTag() != null && gameEntity.getTag().size() != 0
|
||||
&& !PackageUtils.isSignature(this, gameEntity.getApk().get(0).getPackageName())
|
||||
) {
|
||||
&& !TextUtils.isEmpty(gameEntity.getApk().get(0).getGhVersion())
|
||||
&& !PackageUtils.isSignature(this, gameEntity.getApk().get(0).getPackageName())) {
|
||||
if (TextUtils.isEmpty(downloadAddWord)) {
|
||||
detail_tv_download.setBackgroundResource(
|
||||
R.drawable.game_item_btn_plugin_style);
|
||||
@ -276,6 +276,7 @@ public abstract class DetailActivity extends BaseActivity implements View.OnClic
|
||||
break;
|
||||
case cancel:
|
||||
case hijack:
|
||||
case notfound:
|
||||
initDownload(false);
|
||||
break;
|
||||
default:
|
||||
|
||||
@ -196,7 +196,6 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
|
||||
}
|
||||
|
||||
public void onEventMainThread(EBDownloadStatus status) {
|
||||
downloadHint = (TextView) view.findViewById(R.id.action_tip);
|
||||
int updateSize = PackageManager.getUpdateListSize();
|
||||
int downloadSize = DownloadManager.getInstance(getActivity()).getAll().size();
|
||||
if (downloadSize != 0) {
|
||||
|
||||
24
app/src/main/java/com/gh/common/constant/ItemViewType.java
Normal file
24
app/src/main/java/com/gh/common/constant/ItemViewType.java
Normal file
@ -0,0 +1,24 @@
|
||||
package com.gh.common.constant;
|
||||
|
||||
/**
|
||||
* Created by LGT on 2016/10/16.
|
||||
*/
|
||||
public class ItemViewType {
|
||||
|
||||
public static final int COLUMN_HEADER = 0; // 专题头部布局
|
||||
public static final int GAME_SLIDE = 1; // 滚动图布局
|
||||
public static final int GAME_NORMAL = 2; // 正常游戏布局
|
||||
public static final int GAME_TEST = 3; // 测试游戏布局
|
||||
public static final int GAME_IMAGE = 4; // 游戏大图布局
|
||||
public static final int NEWS_HEADER = 5; // 新闻头部布局
|
||||
public static final int NEWS_TEXT = 6; // 新闻文本布局
|
||||
public static final int NEWS_IMAGE = 7; // 新闻带图布局
|
||||
public static final int NEWS_IMAGE1 = 8; // 新闻带一张小图布局
|
||||
public static final int NEWS_IMAGE2 = 9; // 新闻带三张小图布局
|
||||
public static final int NEWS_IMAGE3 = 10; // 新闻带一张大图布局
|
||||
public static final int NEWS_DIGEST = 11; // 新闻摘要布局
|
||||
public static final int SEARCH_NORMAL = 12; // 搜索正常布局
|
||||
public static final int SEARCH_DELETE = 13; // 清空历史记录布局
|
||||
public static final int LOADING = 14; // 加载布局
|
||||
|
||||
}
|
||||
@ -120,7 +120,8 @@ public class DownloadItemUtils {
|
||||
downloadBtn.setText("插件化");
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(context).getByPackage(
|
||||
gameEntity.getApk().get(0).getPackageName());
|
||||
if (downloadEntity == null) {
|
||||
if (downloadEntity == null
|
||||
|| downloadEntity.getUrl().equals(gameEntity.getApk().get(0).getUrl())) {
|
||||
downloadBtn.setClickable(true);
|
||||
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
|
||||
} else {
|
||||
@ -133,11 +134,13 @@ public class DownloadItemUtils {
|
||||
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
|
||||
} else {
|
||||
if (gameEntity.getTag() != null && gameEntity.getTag().size() != 0
|
||||
&& !TextUtils.isEmpty(gameEntity.getApk().get(0).getGhVersion())
|
||||
&& !PackageUtils.isSignature(context, gameEntity.getApk().get(0).getPackageName())) {
|
||||
downloadBtn.setText("插件化");
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(context).getByPackage(
|
||||
gameEntity.getApk().get(0).getPackageName());
|
||||
if (downloadEntity == null) {
|
||||
if (downloadEntity == null
|
||||
|| downloadEntity.getUrl().equals(gameEntity.getApk().get(0).getUrl())) {
|
||||
downloadBtn.setClickable(true);
|
||||
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
|
||||
} else {
|
||||
@ -602,8 +605,8 @@ public class DownloadItemUtils {
|
||||
if (FileUtils.isEmptyFile(path)) {
|
||||
Toast.makeText(context, "解析包出错(可能被误删了),请重新下载", Toast.LENGTH_SHORT).show();
|
||||
DownloadManager.getInstance(context).cancel(downloadEntity.getUrl());
|
||||
if (gameEntity.getEntryMap() != null && !gameEntity.getEntryMap().isEmpty()) {
|
||||
gameEntity.getEntryMap().remove(gameEntity.getEntryMap().keyAt(0));
|
||||
if (gameEntity.getEntryMap() != null) {
|
||||
gameEntity.getEntryMap().remove(gameEntity.getApk().get(0).getPlatform());
|
||||
}
|
||||
adapter.notifyItemChanged(position);
|
||||
} else {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
package com.gh.download;
|
||||
|
||||
public enum DownloadStatus {
|
||||
add, pause, cancel, downloading, done, waiting, resume, timeout, neterror, hijack
|
||||
add, pause, cancel, downloading, done, waiting, resume, timeout, neterror, hijack, notfound
|
||||
}
|
||||
|
||||
@ -119,7 +119,8 @@ public class DownloadTask implements DownloadListener {
|
||||
@Override
|
||||
public void onStatusChanged(DownloadStatus status, String error) {
|
||||
if (status == DownloadStatus.cancel
|
||||
|| status == DownloadStatus.hijack) {
|
||||
|| status == DownloadStatus.hijack
|
||||
|| status == DownloadStatus.notfound) {
|
||||
entry.setProgress(0);
|
||||
entry.setPercent(0);
|
||||
FileUtils.deleteFile(entry.getPath());
|
||||
|
||||
@ -13,6 +13,7 @@ import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
@ -38,6 +39,8 @@ public class DownloadThread extends Thread {
|
||||
public void run() {
|
||||
super.run();
|
||||
|
||||
BufferedInputStream bis = null;
|
||||
BufferedOutputStream bos = null;
|
||||
try {
|
||||
File targetFile = new File(entry.getPath());
|
||||
if (!targetFile.exists()) {
|
||||
@ -47,13 +50,12 @@ public class DownloadThread extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
FileOutputStream fileOutputStream;
|
||||
if (targetFile.length() > 0) {
|
||||
fileOutputStream = new FileOutputStream(entry.getPath(), true);
|
||||
} else {
|
||||
fileOutputStream = new FileOutputStream(entry.getPath());
|
||||
if (TextUtils.isEmpty(entry.getUrl())) {
|
||||
listener.onStatusChanged(DownloadStatus.notfound);
|
||||
Utils.log(DownloadThread.class.getSimpleName(),
|
||||
"error-->url is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
URL url = new URL(entry.getUrl());
|
||||
Utils.log("url = " + entry.getUrl());
|
||||
|
||||
@ -92,11 +94,24 @@ public class DownloadThread extends Thread {
|
||||
"startPosition-->" + targetFile.length());
|
||||
//设置自动重定向
|
||||
connection.setInstanceFollowRedirects(true);
|
||||
|
||||
code = connection.getResponseCode();
|
||||
}
|
||||
if (code == HttpStatus.SC_NOT_FOUND) {
|
||||
// 404 Not Found
|
||||
listener.onStatusChanged(DownloadStatus.notfound);
|
||||
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()));
|
||||
}
|
||||
|
||||
BufferedInputStream bis = new BufferedInputStream(connection.getInputStream());
|
||||
BufferedOutputStream bos = new BufferedOutputStream(fileOutputStream);
|
||||
long conentLength = connection.getContentLength();
|
||||
String eTag = connection.getHeaderField("ETag");
|
||||
if (!TextUtils.isEmpty(eTag) && eTag.startsWith("\"") && eTag.endsWith("\"")) {
|
||||
eTag = eTag.substring(1, eTag.length() - 1);
|
||||
@ -109,45 +124,41 @@ public class DownloadThread extends Thread {
|
||||
listener.onStatusChanged(DownloadStatus.hijack);
|
||||
Utils.log(DownloadThread.class.getSimpleName(),
|
||||
"error-->链接被劫持");
|
||||
interrupt();
|
||||
} else {
|
||||
// 第一次下载记录文件长度
|
||||
if (entry.getSize() == 0) {
|
||||
entry.setSize(conentLength);
|
||||
DownloadDao.getInstance(context).newOrUpdate(entry);
|
||||
Utils.log(DownloadThread.class.getSimpleName(),
|
||||
"记录第一次长度");
|
||||
}
|
||||
Utils.log(DownloadThread.class.getSimpleName(),
|
||||
"progress:" + entry.getProgress() + "/curfilesize:"
|
||||
+ targetFile.length() + "=====contentLength:"
|
||||
+ conentLength + "/ totalSize:" + entry.getSize());
|
||||
|
||||
byte[] buffer = new byte[2048];
|
||||
int len;
|
||||
while ((len = bis.read(buffer)) != -1) {
|
||||
bos.write(buffer, 0, len);
|
||||
listener.onProgressChanged(targetFile.length(), len);
|
||||
if (status == DownloadStatus.pause
|
||||
|| status == DownloadStatus.cancel) {
|
||||
listener.onStatusChanged(status);
|
||||
break;
|
||||
}
|
||||
}
|
||||
bos.flush();
|
||||
Utils.log(DownloadThread.class.getSimpleName(),
|
||||
"flush==>" + targetFile.length() + ",progress==>"
|
||||
+ entry.getProgress() + ",size==>" + entry.getSize());
|
||||
return;
|
||||
}
|
||||
|
||||
bis.close();
|
||||
bos.close();
|
||||
// if (status != DownloadStatus.pause && status != DownloadStatus.cancel) {
|
||||
// listener.onStatusChanged(DownloadStatus.done);
|
||||
// }
|
||||
if (targetFile.length() == entry.getSize()) {
|
||||
listener.onStatusChanged(DownloadStatus.done);
|
||||
long conentLength = connection.getContentLength();
|
||||
// 第一次下载记录文件长度
|
||||
if (entry.getSize() == 0) {
|
||||
entry.setSize(conentLength);
|
||||
DownloadDao.getInstance(context).newOrUpdate(entry);
|
||||
Utils.log(DownloadThread.class.getSimpleName(),
|
||||
"记录第一次长度");
|
||||
}
|
||||
Utils.log(DownloadThread.class.getSimpleName(),
|
||||
"progress:" + entry.getProgress() + "/curfilesize:"
|
||||
+ targetFile.length() + "=====contentLength:"
|
||||
+ conentLength + "/ totalSize:" + entry.getSize());
|
||||
|
||||
byte[] buffer = new byte[2048];
|
||||
int len;
|
||||
while ((len = bis.read(buffer)) != -1) {
|
||||
bos.write(buffer, 0, len);
|
||||
listener.onProgressChanged(targetFile.length(), len);
|
||||
if (status == DownloadStatus.pause
|
||||
|| status == DownloadStatus.cancel) {
|
||||
listener.onStatusChanged(status);
|
||||
break;
|
||||
}
|
||||
}
|
||||
bos.flush();
|
||||
Utils.log(DownloadThread.class.getSimpleName(),
|
||||
"flush==>" + targetFile.length() + ",progress==>"
|
||||
+ entry.getProgress() + ",size==>" + entry.getSize());
|
||||
|
||||
if (targetFile.length() == entry.getSize()) {
|
||||
listener.onStatusChanged(DownloadStatus.done);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String errorMsg = Log.getStackTraceString(e);
|
||||
|
||||
@ -159,6 +170,21 @@ public class DownloadThread extends Thread {
|
||||
}
|
||||
Utils.log(DownloadThread.class.getSimpleName(),
|
||||
"exception-->" + e.toString());
|
||||
} finally {
|
||||
if (bis != null) {
|
||||
try {
|
||||
bis.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (bos != null) {
|
||||
try {
|
||||
bos.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -53,7 +53,6 @@ import com.gh.download.DownloadManager;
|
||||
import com.gh.download.DownloadStatus;
|
||||
import com.gh.gamecenter.db.info.ConcernInfo;
|
||||
import com.gh.gamecenter.db.info.GameInfo;
|
||||
import com.gh.gamecenter.db.info.SuspectedGameInfo;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.AppEntity;
|
||||
import com.gh.gamecenter.entity.GameDigestEntity;
|
||||
@ -71,7 +70,6 @@ import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
import com.gh.gamecenter.manager.FilterManager;
|
||||
import com.gh.gamecenter.manager.GameManager;
|
||||
import com.gh.gamecenter.manager.PackageManager;
|
||||
import com.gh.gamecenter.manager.SuspectedGameManager;
|
||||
import com.gh.gamecenter.news.NewsFragment;
|
||||
import com.gh.gamecenter.personal.PersonalFragment;
|
||||
import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
|
||||
@ -141,10 +139,17 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
private DataWatcher dataWatcher = new DataWatcher() {
|
||||
@Override
|
||||
public void onDataChanged(DownloadEntity downloadEntity) {
|
||||
// 链接被劫持
|
||||
if (DownloadStatus.hijack.equals(downloadEntity.getStatus())) {
|
||||
// 链接被劫持
|
||||
processHijack(downloadEntity);
|
||||
return;
|
||||
} else if (DownloadStatus.notfound.equals(downloadEntity.getStatus())) {
|
||||
// 404 Not Found
|
||||
// 删除任务
|
||||
downloadEntity.setStatus(DownloadStatus.cancel);
|
||||
DownloadManager.getInstance(getApplicationContext()).cancel(downloadEntity.getUrl());
|
||||
toast("该链接已失效!请联系管理员。");
|
||||
return;
|
||||
} else if (DownloadStatus.neterror.equals(downloadEntity.getStatus())
|
||||
|| DownloadStatus.timeout.equals(downloadEntity.getStatus())) {
|
||||
toast("网络不稳定,下载任务已暂停");
|
||||
@ -344,9 +349,14 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
}
|
||||
}
|
||||
if (downloadEntity != null) {
|
||||
String msg = "《" + downloadEntity.getName() + "-"
|
||||
+ PlatformUtils.getInstance(getApplicationContext()).getPlatformName(downloadEntity.getPlatform())
|
||||
+ "》已下载完但还未安装,是否立即安装?";
|
||||
String msg;
|
||||
if (downloadEntity.isPlugin()) {
|
||||
msg = "《" + downloadEntity.getName() + "-"
|
||||
+ PlatformUtils.getInstance(getApplicationContext()).getPlatformName(downloadEntity.getPlatform())
|
||||
+ "》已下载完但还未安装,是否立即安装?";
|
||||
} else {
|
||||
msg = "《" + downloadEntity.getName() + "》已下载完但还未安装,是否立即安装?";
|
||||
}
|
||||
final String path = downloadEntity.getPath();
|
||||
DialogUtils.showWarningDialog(this, "提示", msg, "直接退出", "立即安装",
|
||||
new DialogUtils.ConfiremListener() {
|
||||
@ -556,10 +566,6 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
}
|
||||
|
||||
private void updateConcern() {
|
||||
// 移除疑似游戏数据库中所有数据
|
||||
SuspectedGameManager suspectedGameManager = new SuspectedGameManager(getApplicationContext());
|
||||
suspectedGameManager.deleteAll();
|
||||
|
||||
ArrayList<String> concernIdList = new ArrayList<>();
|
||||
for (ConcernInfo entity : concernManager.getAllConcern()) {
|
||||
concernIdList.add(entity.getId());
|
||||
@ -716,43 +722,41 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
}
|
||||
|
||||
private void checkGameUpdate() {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
List<ConcernInfo> infos = concernManager.getInstalledGame();
|
||||
for (ConcernInfo info : infos) {
|
||||
for (String packageName : info.getPackageNames().keySet()) {
|
||||
if (info.getPackageNames().get(packageName)
|
||||
&& PackageUtils.getMetaData(this, packageName, "gh_version") != null) {
|
||||
list.add(packageName);
|
||||
checkGameUpdate(packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Object gh_id;
|
||||
for (String packageName : list) {
|
||||
gh_id = PackageUtils.getMetaData(this, packageName, "gh_id");
|
||||
String url;
|
||||
if (gh_id == null) {
|
||||
url = Config.HOST + "update/package/" + packageName;
|
||||
} else {
|
||||
url = Config.HOST + "update/game/" + gh_id + "/package/" + packageName;
|
||||
}
|
||||
JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(url,
|
||||
new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
if (response.length() != 0) {
|
||||
Gson gson = new Gson();
|
||||
GameUpdateEntity gameUpdateEntity = gson.fromJson(
|
||||
response.toString(), GameUpdateEntity.class);
|
||||
if (PackageUtils.isCanUpdate(MainActivity.this, gameUpdateEntity)) {
|
||||
PackageManager.addUpdate(gameUpdateEntity);
|
||||
EventBus.getDefault().post(new EBDownloadStatus("update"));
|
||||
}
|
||||
private void checkGameUpdate(String packageName) {
|
||||
Object gh_id = PackageUtils.getMetaData(this, packageName, "gh_id");
|
||||
String url;
|
||||
if (gh_id == null) {
|
||||
url = Config.HOST + "update/package/" + packageName;
|
||||
} else {
|
||||
url = Config.HOST + "update/game/" + gh_id + "/package/" + packageName;
|
||||
}
|
||||
JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(url,
|
||||
new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
if (response.length() != 0) {
|
||||
Gson gson = new Gson();
|
||||
GameUpdateEntity gameUpdateEntity = gson.fromJson(
|
||||
response.toString(), GameUpdateEntity.class);
|
||||
if (PackageUtils.isCanUpdate(MainActivity.this, gameUpdateEntity)) {
|
||||
PackageManager.addUpdate(gameUpdateEntity);
|
||||
EventBus.getDefault().post(new EBDownloadStatus("update"));
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
AppController.addToRequestQueue(request, TAG);
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
AppController.addToRequestQueue(request, TAG);
|
||||
}
|
||||
|
||||
private int count;
|
||||
@ -810,25 +814,12 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
&& gameEntity.getApk() != null) {
|
||||
map = info.getPackageNames();
|
||||
for (String key : map.keySet()) {
|
||||
if (map.get(key) && !PackageUtils.isSignature(this, key)) {
|
||||
if (map.get(key)) {
|
||||
for (ApkEntity apkEntity : gameEntity.getApk()) {
|
||||
if (apkEntity.getPackageName().equals(key)) {
|
||||
GameUpdateEntity gameUpdateEntity = new GameUpdateEntity();
|
||||
gameUpdateEntity.setId(gameEntity.getId());
|
||||
gameUpdateEntity.setIcon(gameEntity.getIcon());
|
||||
gameUpdateEntity.setName(gameEntity.getName());
|
||||
gameUpdateEntity.setPackageName(apkEntity.getPackageName());
|
||||
gameUpdateEntity.setSize(apkEntity.getSize());
|
||||
gameUpdateEntity.setVersion(apkEntity.getVersion());
|
||||
gameUpdateEntity.setGhVersion(apkEntity.getGhVersion());
|
||||
gameUpdateEntity.setUrl(apkEntity.getUrl());
|
||||
gameUpdateEntity.setPlatform(apkEntity.getPlatform());
|
||||
gameUpdateEntity.setEtag(apkEntity.getEtag());
|
||||
gameUpdateEntity.setPluggable(true);
|
||||
gameUpdateEntity.setTag(gameEntity.getTag());
|
||||
gameUpdateEntity.setBrief(gameEntity.getBrief());
|
||||
|
||||
PackageManager.addUpdate(gameUpdateEntity);
|
||||
if (apkEntity.getPackageName().equals(key)
|
||||
&& !TextUtils.isEmpty(apkEntity.getGhVersion())
|
||||
&& !PackageUtils.isSignature(this, apkEntity.getPackageName())) {
|
||||
PackageManager.addUpdate(getGameUpdateEntity(gameEntity, apkEntity));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -843,6 +834,24 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
EventBus.getDefault().post(new EBDownloadStatus("plugin"));
|
||||
}
|
||||
|
||||
private GameUpdateEntity getGameUpdateEntity(GameEntity gameEntity, ApkEntity apkEntity) {
|
||||
GameUpdateEntity gameUpdateEntity = new GameUpdateEntity();
|
||||
gameUpdateEntity.setId(gameEntity.getId());
|
||||
gameUpdateEntity.setIcon(gameEntity.getIcon());
|
||||
gameUpdateEntity.setName(gameEntity.getName());
|
||||
gameUpdateEntity.setPackageName(apkEntity.getPackageName());
|
||||
gameUpdateEntity.setSize(apkEntity.getSize());
|
||||
gameUpdateEntity.setVersion(apkEntity.getVersion());
|
||||
gameUpdateEntity.setGhVersion(apkEntity.getGhVersion());
|
||||
gameUpdateEntity.setUrl(apkEntity.getUrl());
|
||||
gameUpdateEntity.setPlatform(apkEntity.getPlatform());
|
||||
gameUpdateEntity.setEtag(apkEntity.getEtag());
|
||||
gameUpdateEntity.setPluggable(true);
|
||||
gameUpdateEntity.setTag(gameEntity.getTag());
|
||||
gameUpdateEntity.setBrief(gameEntity.getBrief());
|
||||
return gameUpdateEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
@ -1401,7 +1410,6 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
DownloadManager.getInstance(getApplicationContext()).cancel(
|
||||
mDownloadEntity.getUrl(), sp.getBoolean("autodelete", true));
|
||||
}
|
||||
|
||||
} else if ("卸载".equals(busFour.getType())) {
|
||||
Map<String, Object> kv6 = new HashMap<>();
|
||||
kv6.put("安装或卸载", "卸载完成");
|
||||
@ -1412,45 +1420,19 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
}
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
GameManager gameManager = new GameManager(getApplicationContext());
|
||||
GameInfo gameEntity = gameManager.findGame(packageName);
|
||||
if (gameEntity != null) {
|
||||
concernManager.updateByEntity(gameEntity);
|
||||
} else {
|
||||
FilterManager filterManager = new FilterManager(getApplicationContext());
|
||||
if (!filterManager.isFilter(packageName)) {
|
||||
SuspectedGameManager suspectedGameManager = new SuspectedGameManager(getApplicationContext());
|
||||
suspectedGameManager.addGame(new SuspectedGameInfo(
|
||||
packageName, System.currentTimeMillis()));
|
||||
}
|
||||
GameInfo gameInfo = gameManager.findGame(packageName);
|
||||
if (gameInfo != null) {
|
||||
concernManager.updateByEntity(gameInfo);
|
||||
}
|
||||
} else if ("卸载".equals(busFour.getType())) {
|
||||
FilterManager filterManager = new FilterManager(getApplicationContext());
|
||||
if (!filterManager.isFilter(packageName)) {
|
||||
SuspectedGameManager suspectedGameManager = new SuspectedGameManager(getApplicationContext());
|
||||
suspectedGameManager.deleteSuspectedGame(packageName);
|
||||
|
||||
concernManager.updateByPackageName(packageName);
|
||||
}
|
||||
}
|
||||
if ("卸载".equals(busFour.getType())) {
|
||||
ArrayList<GameUpdateEntity> list = PackageManager.getUpdateList();
|
||||
GameUpdateEntity game;
|
||||
int index = -1;
|
||||
for (int i = 0, size = list.size(); i < size; i++) {
|
||||
game = list.get(i);
|
||||
if (!game.isPluggable()) {
|
||||
continue;
|
||||
}
|
||||
if (game.getPackageName().equals(packageName)) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index != -1) {
|
||||
PackageManager.removeUpdate(packageName);
|
||||
}
|
||||
if ("卸载".equals(busFour.getType()) || "安装".equals(busFour.getType())) {
|
||||
PackageManager.removeUpdate(packageName);
|
||||
}
|
||||
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
// 安装后关注游戏
|
||||
JsonArrayExtendedRequest request = new JsonArrayExtendedRequest(
|
||||
@ -1468,7 +1450,11 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
gameInfo.setPackageName(packageName);
|
||||
gameInfo.setGameName(gameDigestEntity.getName());
|
||||
concernManager.updateByEntity(gameInfo);
|
||||
concernGame(gameDigestEntity.getId());
|
||||
concernGame(gameDigestEntity.getId(), packageName);
|
||||
if (PackageUtils.getMetaData(getApplicationContext(),
|
||||
packageName, "gh_version") != null) {
|
||||
checkGameUpdate(packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1482,20 +1468,35 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
DataCollectionManager.onEvent(this, "inorunstall", map);
|
||||
}
|
||||
|
||||
private void concernGame(String id) {
|
||||
if (!concernManager.isConcern(id)) {
|
||||
JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
|
||||
Config.HOST + "game/" + id + "/digest",
|
||||
new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
Gson gson = new Gson();
|
||||
GameEntity gameEntity = gson.fromJson(response.toString(), GameEntity.class);
|
||||
private void concernGame(final String id, final String packageName) {
|
||||
JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
|
||||
Config.HOST + "game/" + id + "/digest",
|
||||
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);
|
||||
}
|
||||
}, null);
|
||||
AppController.addToRequestQueue(request, TAG);
|
||||
}
|
||||
// 检查是否能插件化
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
AppController.addToRequestQueue(request, TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -138,7 +138,9 @@ public class SubjectActivity extends BaseActivity {
|
||||
gameEntity = adapter.getSubjectList().get(location);
|
||||
for (ApkEntity apkEntity : gameEntity.getApk()) {
|
||||
if (apkEntity.getPackageName().equals(busFour.getPackageName())) {
|
||||
gameEntity.getEntryMap().remove(apkEntity.getPlatform());
|
||||
if (gameEntity.getEntryMap() != null) {
|
||||
gameEntity.getEntryMap().remove(apkEntity.getPlatform());
|
||||
}
|
||||
adapter.notifyItemChanged(location);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -202,10 +202,12 @@ public class PlatformAdapter extends RecyclerView.Adapter<PlatformViewHolder> {
|
||||
if (downloadEntity == null) {
|
||||
viewHolder.download_item_progressbar.setProgress(1000);
|
||||
if (gameEntity.getTag() != null && gameEntity.getTag().size() != 0
|
||||
&& !TextUtils.isEmpty(apkEntity.getGhVersion())
|
||||
&& !PackageUtils.isSignature(context, apkEntity.getPackageName())) {
|
||||
viewHolder.download_item_tv_status.setText("插件化");
|
||||
downloadEntity = DownloadManager.getInstance(context).getByPackage(apkEntity.getPackageName());
|
||||
if (downloadEntity == null) {
|
||||
if (downloadEntity == null
|
||||
|| downloadEntity.getUrl().equals(apkEntity.getUrl())) {
|
||||
viewHolder.itemView.setClickable(true);
|
||||
viewHolder.download_item_progressbar.setProgress(1000);
|
||||
} else {
|
||||
@ -238,7 +240,8 @@ public class PlatformAdapter extends RecyclerView.Adapter<PlatformViewHolder> {
|
||||
DownloadEntity downloadEntity = entryMap.get(apkEntity.getUrl());
|
||||
if (downloadEntity == null
|
||||
|| downloadEntity.getStatus().equals(DownloadStatus.cancel)
|
||||
|| downloadEntity.getStatus().equals(DownloadStatus.hijack)) {
|
||||
|| downloadEntity.getStatus().equals(DownloadStatus.hijack)
|
||||
|| downloadEntity.getStatus().equals(DownloadStatus.notfound)) {
|
||||
int id = PlatformUtils.getInstance(context).getPlatformPic(
|
||||
apkEntity.getPlatform());
|
||||
if (id != 0) {
|
||||
|
||||
@ -14,6 +14,7 @@ import com.android.volley.TimeoutError;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.DownloadItemUtils;
|
||||
@ -59,7 +60,6 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
|
||||
private List<GameEntity> subjectList;
|
||||
private boolean order;
|
||||
private static final int FOOTER_ITEM = 101;
|
||||
private boolean isLoaded;
|
||||
|
||||
private ArrayMap<String, ArrayList<Integer>> locationMap;
|
||||
@ -192,36 +192,40 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (subjectList.size()<1){
|
||||
if (subjectList.size() < 1) {
|
||||
return 0;
|
||||
}
|
||||
return subjectList.size()+1;
|
||||
return subjectList.size() + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (subjectList.size() == position) {
|
||||
return FOOTER_ITEM;
|
||||
if (position == subjectList.size()) {
|
||||
return ItemViewType.LOADING;
|
||||
}
|
||||
if (subjectList.get(position).getTest() != null) {
|
||||
return ItemViewType.GAME_TEST;
|
||||
} else {
|
||||
return ItemViewType.GAME_NORMAL;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
||||
if (i == FOOTER_ITEM){
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
if (viewType == ItemViewType.LOADING){
|
||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(
|
||||
R.layout.refresh_footerview, viewGroup, false);
|
||||
return new FooterViewHolder(view);
|
||||
}
|
||||
if (subjectList.get(i).getTest() != null) {
|
||||
} else if (viewType == ItemViewType.GAME_TEST) {
|
||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(
|
||||
R.layout.game_test_item, viewGroup, false);
|
||||
return new GameTestViewHolder(view);
|
||||
} else {
|
||||
} else if (viewType == ItemViewType.GAME_NORMAL) {
|
||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(
|
||||
R.layout.game_normal_item, viewGroup, false);
|
||||
return new GameNormalViewHolder(view);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -10,7 +10,6 @@ import com.gh.gamecenter.db.info.DataCollectionInfo;
|
||||
import com.gh.gamecenter.db.info.FilterInfo;
|
||||
import com.gh.gamecenter.db.info.GameInfo;
|
||||
import com.gh.gamecenter.db.info.SearchHistoryInfo;
|
||||
import com.gh.gamecenter.db.info.SuspectedGameInfo;
|
||||
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
|
||||
import com.j256.ormlite.dao.Dao;
|
||||
import com.j256.ormlite.support.ConnectionSource;
|
||||
@ -57,7 +56,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||
TableUtils.createTable(connectionSource, ConcernInfo.class);
|
||||
TableUtils.createTable(connectionSource, SearchHistoryInfo.class);
|
||||
TableUtils.createTable(connectionSource, GameInfo.class);
|
||||
TableUtils.createTable(connectionSource, SuspectedGameInfo.class);
|
||||
TableUtils.createTable(connectionSource, FilterInfo.class);
|
||||
TableUtils.createTable(connectionSource, DataCollectionInfo.class);
|
||||
} catch (SQLException e) {
|
||||
@ -75,7 +73,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||
TableUtils.dropTable(connectionSource, ConcernInfo.class, true);
|
||||
TableUtils.dropTable(connectionSource, SearchHistoryInfo.class, true);
|
||||
TableUtils.dropTable(connectionSource, GameInfo.class, true);
|
||||
TableUtils.dropTable(connectionSource, SuspectedGameInfo.class, true);
|
||||
TableUtils.dropTable(connectionSource, FilterInfo.class, true);
|
||||
TableUtils.dropTable(connectionSource, DataCollectionInfo.class, true);
|
||||
onCreate(database, connectionSource);
|
||||
|
||||
@ -1,99 +0,0 @@
|
||||
package com.gh.gamecenter.db;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.gh.gamecenter.db.info.SuspectedGameInfo;
|
||||
import com.j256.ormlite.dao.Dao;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
public class SuspectedGameDao {
|
||||
|
||||
private DatabaseHelper helper;
|
||||
private Dao<SuspectedGameInfo, String> dao;
|
||||
|
||||
public SuspectedGameDao(Context context) {
|
||||
try {
|
||||
helper = DatabaseHelper.getHelper(context);
|
||||
dao = helper.getDao(SuspectedGameInfo.class);
|
||||
} catch (SQLException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加一个疑似游戏
|
||||
*/
|
||||
public void add(SuspectedGameInfo entity) {
|
||||
try {
|
||||
dao.create(entity);
|
||||
} catch (SQLException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一个疑似游戏
|
||||
*/
|
||||
public void delete(String packageName) {
|
||||
try {
|
||||
dao.deleteById(packageName);
|
||||
} catch (SQLException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据包名获取某一个疑似游戏
|
||||
*/
|
||||
public SuspectedGameInfo find(String packageName) {
|
||||
try {
|
||||
return dao.queryForId(packageName);
|
||||
} catch (SQLException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有的疑似游戏
|
||||
*/
|
||||
public List<SuspectedGameInfo> getAll() {
|
||||
try {
|
||||
return dao.queryForAll();
|
||||
} catch (SQLException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新疑似游戏
|
||||
*/
|
||||
public void update(SuspectedGameInfo entity) {
|
||||
try {
|
||||
dao.update(entity);
|
||||
} catch (SQLException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteAll() {
|
||||
try {
|
||||
List<SuspectedGameInfo> list = dao.queryForAll();
|
||||
for (int i = 0, size = list.size(); i < size; i++) {
|
||||
dao.deleteById(list.get(i).getPackageName());
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
package com.gh.gamecenter.db.info;
|
||||
|
||||
import com.j256.ormlite.field.DatabaseField;
|
||||
import com.j256.ormlite.table.DatabaseTable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@DatabaseTable(tableName = "tb_suspectedgame")
|
||||
public class SuspectedGameInfo implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5623387326449838895L;
|
||||
|
||||
@DatabaseField(id = true, columnName = "packageName")
|
||||
private String packageName;
|
||||
|
||||
@DatabaseField(columnName = "time")
|
||||
private long time;
|
||||
|
||||
public SuspectedGameInfo() {
|
||||
|
||||
}
|
||||
|
||||
public SuspectedGameInfo(String packageName, long time) {
|
||||
super();
|
||||
this.packageName = packageName;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SuspectedGameEntity [packageName=" + packageName + ", time="
|
||||
+ time + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@ -53,7 +53,6 @@ public class GameDownLoadFragment extends Fragment implements View.OnClickListen
|
||||
private TextView downloadmanager_tv_allstart;
|
||||
private RelativeLayout.LayoutParams rparams;
|
||||
|
||||
private String path;
|
||||
private String url;
|
||||
|
||||
private boolean isScroll;
|
||||
@ -161,7 +160,7 @@ public class GameDownLoadFragment extends Fragment implements View.OnClickListen
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
path = getActivity().getIntent().getStringExtra("path");
|
||||
String path = getActivity().getIntent().getStringExtra("path");
|
||||
url = getActivity().getIntent().getStringExtra("url");
|
||||
|
||||
isScroll = false;
|
||||
@ -293,26 +292,31 @@ public class GameDownLoadFragment extends Fragment implements View.OnClickListen
|
||||
Integer location = adapter.getLocation(url);
|
||||
if (location != null) {
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
if (adapter.getDownloadingList().isEmpty() && adapter.getDoneList().size() == 1) {
|
||||
adapter.getDoneList().remove(location.intValue());
|
||||
adapter.getLocationMap().clear();
|
||||
adapter.notifyDataSetChanged();
|
||||
EventBus.getDefault().post(new EBDownloadChanged("download", View.GONE, 0));
|
||||
if (reuse_nodata_skip.getVisibility() == View.GONE) {
|
||||
reuse_nodata_skip.setVisibility(View.VISIBLE);
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(getActivity()).get(url);
|
||||
if (downloadEntity == null
|
||||
|| !downloadEntity.isPlugin() // 不是插件游戏,自己删除数据库数据和安装包
|
||||
|| PackageUtils.isSignature(getActivity(), packageName)) {// 是插件游戏,判断签名是否相同,是才删除数据库数据和安装包
|
||||
if (adapter.getDownloadingList().isEmpty() && adapter.getDoneList().size() == 1) {
|
||||
adapter.getDoneList().remove(location.intValue());
|
||||
adapter.getLocationMap().clear();
|
||||
adapter.notifyDataSetChanged();
|
||||
EventBus.getDefault().post(new EBDownloadChanged("download", View.GONE, 0));
|
||||
if (reuse_nodata_skip.getVisibility() == View.GONE) {
|
||||
reuse_nodata_skip.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else if (adapter.getDoneList().size() == 1) {
|
||||
adapter.getDoneList().remove(location.intValue());
|
||||
adapter.initLocationMap();
|
||||
adapter.notifyItemRangeRemoved(0, 2);
|
||||
EventBus.getDefault().post(new EBDownloadChanged("download", View.VISIBLE,
|
||||
adapter.getDoneList().size() + adapter.getDownloadingList().size()));
|
||||
} else {
|
||||
adapter.getDoneList().remove(location.intValue());
|
||||
adapter.initLocationMap();
|
||||
adapter.notifyItemRemoved(location + 1);
|
||||
EventBus.getDefault().post(new EBDownloadChanged("download", View.VISIBLE,
|
||||
adapter.getDoneList().size() + adapter.getDownloadingList().size()));
|
||||
}
|
||||
} else if (adapter.getDoneList().size() == 1) {
|
||||
adapter.getDoneList().remove(location.intValue());
|
||||
adapter.initLocationMap();
|
||||
adapter.notifyItemRangeRemoved(0, 2);
|
||||
EventBus.getDefault().post(new EBDownloadChanged("download", View.VISIBLE,
|
||||
adapter.getDoneList().size() + adapter.getDownloadingList().size()));
|
||||
} else {
|
||||
adapter.getDoneList().remove(location.intValue());
|
||||
adapter.initLocationMap();
|
||||
adapter.notifyItemRemoved(location + 1);
|
||||
EventBus.getDefault().post(new EBDownloadChanged("download", View.VISIBLE,
|
||||
adapter.getDoneList().size() + adapter.getDownloadingList().size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,8 +5,6 @@ import android.graphics.Color;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.util.SparseArray;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -28,6 +26,7 @@ import com.gh.common.view.CardLinearLayout;
|
||||
import com.gh.common.view.CardRelativeLayout;
|
||||
import com.gh.download.DownloadEntity;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.download.DownloadStatus;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.db.info.ConcernInfo;
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity;
|
||||
@ -60,10 +59,7 @@ public class GameUpdateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
private LinearLayout gameupdate_ll_loading;
|
||||
private LinearLayout gameupdate_tv_none;
|
||||
|
||||
private ArrayMap<String, Integer> locationMap;
|
||||
private ArrayMap<String, String> packageNameMap;
|
||||
private SparseBooleanArray successMap;
|
||||
private SparseArray<DownloadEntity> entryMap;
|
||||
private ArrayMap<String, ArrayList<Integer>> locationMap;
|
||||
|
||||
private List<GameUpdateEntity> updateList;
|
||||
|
||||
@ -81,9 +77,6 @@ public class GameUpdateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
this.packageName = packageName;
|
||||
|
||||
locationMap = new ArrayMap<>();
|
||||
packageNameMap = new ArrayMap<>();
|
||||
successMap = new SparseBooleanArray();
|
||||
entryMap = new SparseArray<>();
|
||||
|
||||
updateList = new ArrayList<>();
|
||||
if (packageName != null) {
|
||||
@ -91,16 +84,25 @@ public class GameUpdateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
} else if (isUpdate) {
|
||||
getUpdateListFromServer();
|
||||
} else {
|
||||
for (GameUpdateEntity updateEntity : PackageManager.getUpdateList()) {
|
||||
updateList.add(updateEntity);
|
||||
}
|
||||
sortUpdateList(updateList);
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
initMap();
|
||||
public void init() {
|
||||
updateList.clear();
|
||||
for (GameUpdateEntity updateEntity : PackageManager.getUpdateList()) {
|
||||
updateList.add(updateEntity);
|
||||
}
|
||||
sortUpdateList(updateList);
|
||||
|
||||
if (updateList.isEmpty()) {
|
||||
gameupdate_tv_none.setVisibility(View.VISIBLE);
|
||||
}
|
||||
initLocationMap();
|
||||
|
||||
if (updateList.isEmpty()) {
|
||||
gameupdate_tv_none.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
gameupdate_tv_none.setVisibility(View.GONE);
|
||||
EventBus.getDefault().post(
|
||||
new EBDownloadChanged("update", View.VISIBLE, updateList.size()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +138,7 @@ public class GameUpdateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
PackageManager.addUpdate(gameUpdateEntity);
|
||||
EventBus.getDefault().post(new EBDownloadChanged("update",
|
||||
View.VISIBLE, updateList.size()));
|
||||
initMap();
|
||||
initLocationMap();
|
||||
}
|
||||
|
||||
if (updateList.isEmpty()) {
|
||||
@ -223,7 +225,7 @@ public class GameUpdateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
notifyItemRangeInserted(0, 1 + updateList.size());
|
||||
|
||||
EventBus.getDefault().post(new EBDownloadChanged("update", View.VISIBLE, updateList.size()));
|
||||
initMap();
|
||||
initLocationMap();
|
||||
|
||||
if (updateList.isEmpty()) {
|
||||
gameupdate_tv_none.setVisibility(View.VISIBLE);
|
||||
@ -233,19 +235,20 @@ public class GameUpdateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
gameupdate_ll_loading.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// 初始化map等变量
|
||||
private void initMap() {
|
||||
List<DownloadEntity> entries = DownloadManager.getInstance(context).getAll();
|
||||
// 初始化map
|
||||
public void initLocationMap() {
|
||||
locationMap.clear();
|
||||
|
||||
String packageName;
|
||||
ArrayList<Integer> list;
|
||||
for (int i = 0, size = updateList.size(); i < size; i++) {
|
||||
locationMap.put(updateList.get(i).getPackageName(), i);
|
||||
packageNameMap.put(updateList.get(i).getUrl(), updateList.get(i).getPackageName());
|
||||
successMap.put(i, false);
|
||||
for (DownloadEntity downloadEntity : entries) {
|
||||
if (updateList.get(i).getUrl().equals(downloadEntity.getUrl())) {
|
||||
entryMap.put(i, downloadEntity);
|
||||
break;
|
||||
}
|
||||
packageName = updateList.get(i).getPackageName();
|
||||
list = locationMap.get(packageName);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
locationMap.put(packageName, list);
|
||||
}
|
||||
list.add(i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,11 +314,12 @@ public class GameUpdateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
String str = updateList.get(i).getSize();
|
||||
str = str.substring(0, str.lastIndexOf("M"));
|
||||
size += Float.valueOf(str);
|
||||
if (entryMap.get(i) != null) {
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(context).get(updateList.get(i).getUrl());
|
||||
if (downloadEntity != null) {
|
||||
count++;
|
||||
}
|
||||
if (successMap.get(i)) {
|
||||
done++;
|
||||
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
|
||||
done++;
|
||||
}
|
||||
}
|
||||
}
|
||||
CardRelativeLayout cardRelativeLayout = (CardRelativeLayout) viewHolder.itemView;
|
||||
@ -341,7 +345,7 @@ public class GameUpdateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
if (NetworkUtils.isWifiConnected(context)) {
|
||||
viewHolder.dm_item_head_tv_allstart.setText("更新中");
|
||||
for (int i = 0; i < updateList.size(); i++) {
|
||||
if (entryMap.get(i) == null) {
|
||||
if (DownloadManager.getInstance(context).get(updateList.get(i).getUrl()) == null) {
|
||||
addUpdateDownload(i);
|
||||
notifyItemChanged(i + 1);
|
||||
}
|
||||
@ -352,7 +356,7 @@ public class GameUpdateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
public void onConfirem() {
|
||||
viewHolder.dm_item_head_tv_allstart.setText("更新中");
|
||||
for (int i = 0; i < updateList.size(); i++) {
|
||||
if (entryMap.get(i) == null) {
|
||||
if (DownloadManager.getInstance(context).get(updateList.get(i).getUrl()) == null) {
|
||||
addUpdateDownload(i);
|
||||
notifyItemChanged(i + 1);
|
||||
}
|
||||
@ -409,35 +413,6 @@ public class GameUpdateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
|
||||
viewHolder.gu_item_tv_new.setText("新版:V" + updateEntity.getVersion() + " | " + updateEntity.getSize());
|
||||
|
||||
if (successMap.get(position - 1)) {
|
||||
viewHolder.gu_item_btv_update.setText("启动");
|
||||
viewHolder.gu_item_btv_update.setTextColor(Color.WHITE);
|
||||
viewHolder.gu_item_btv_update.setBackgroundResource(R.drawable.game_item_btn_launch_style);
|
||||
} else {
|
||||
DownloadEntity entry = entryMap.get(position - 1);
|
||||
if (entry != null) {
|
||||
if (updateEntity.isPluggable()) {
|
||||
viewHolder.gu_item_btv_update.setText("插件化中");
|
||||
viewHolder.gu_item_btv_update.setTextColor(context.getResources().getColorStateList(R.color.text_plugining_style));
|
||||
viewHolder.gu_item_btv_update.setBackgroundResource(R.drawable.game_item_btn_plugining_style);
|
||||
} else {
|
||||
viewHolder.gu_item_btv_update.setText("更新中");
|
||||
viewHolder.gu_item_btv_update.setTextColor(context.getResources().getColorStateList(R.color.text_downloading_style));
|
||||
viewHolder.gu_item_btv_update.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
|
||||
}
|
||||
} else {
|
||||
if (updateEntity.isPluggable()) {
|
||||
viewHolder.gu_item_btv_update.setText("插件化");
|
||||
viewHolder.gu_item_btv_update.setTextColor(Color.WHITE);
|
||||
viewHolder.gu_item_btv_update.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
|
||||
} else {
|
||||
viewHolder.gu_item_btv_update.setText("更新");
|
||||
viewHolder.gu_item_btv_update.setTextColor(Color.WHITE);
|
||||
viewHolder.gu_item_btv_update.setBackgroundResource(R.drawable.game_item_btn_download_style);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewHolder.gu_item_btv_update.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -491,6 +466,46 @@ public class GameUpdateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
}
|
||||
});
|
||||
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(context).get(updateEntity.getUrl());
|
||||
if (downloadEntity == null) {
|
||||
if (updateEntity.isPluggable()) {
|
||||
viewHolder.gu_item_btv_update.setText("插件化");
|
||||
viewHolder.gu_item_btv_update.setTextColor(Color.WHITE);
|
||||
downloadEntity = DownloadManager.getInstance(context).getByPackage(
|
||||
updateEntity.getPackageName());
|
||||
if (downloadEntity == null
|
||||
|| downloadEntity.getUrl().equals(updateEntity.getUrl())) {
|
||||
viewHolder.gu_item_btv_update.setClickable(true);
|
||||
viewHolder.gu_item_btv_update.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
|
||||
} else {
|
||||
viewHolder.gu_item_btv_update.setClickable(false);
|
||||
viewHolder.gu_item_btv_update.setBackgroundResource(R.drawable.game_item_btn_pause_up);
|
||||
}
|
||||
} else {
|
||||
viewHolder.gu_item_btv_update.setText("更新");
|
||||
viewHolder.gu_item_btv_update.setTextColor(Color.WHITE);
|
||||
viewHolder.gu_item_btv_update.setBackgroundResource(R.drawable.game_item_btn_download_style);
|
||||
}
|
||||
} else {
|
||||
if (PackageManager.isCanUpdate(updateEntity.getId(), updateEntity.getPackageName())) {
|
||||
viewHolder.gu_item_btv_update.setText("启动");
|
||||
viewHolder.gu_item_btv_update.setTextColor(Color.WHITE);
|
||||
viewHolder.gu_item_btv_update.setBackgroundResource(R.drawable.game_item_btn_launch_style);
|
||||
} else {
|
||||
if (updateEntity.isPluggable()) {
|
||||
viewHolder.gu_item_btv_update.setText("插件化中");
|
||||
viewHolder.gu_item_btv_update.setTextColor(
|
||||
context.getResources().getColorStateList(R.color.text_plugining_style));
|
||||
viewHolder.gu_item_btv_update.setBackgroundResource(R.drawable.game_item_btn_plugining_style);
|
||||
} else {
|
||||
viewHolder.gu_item_btv_update.setText("更新中");
|
||||
viewHolder.gu_item_btv_update.setTextColor(
|
||||
context.getResources().getColorStateList(R.color.text_downloading_style));
|
||||
viewHolder.gu_item_btv_update.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (packageName != null) {
|
||||
viewHolder.gu_item_btv_update.performClick();
|
||||
packageName = null;
|
||||
@ -577,7 +592,6 @@ public class GameUpdateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
DownloadManager.getInstance(context).pauseAll();
|
||||
}
|
||||
DownloadManager.getInstance(context).add(downloadEntity);
|
||||
entryMap.put(position, downloadEntity);
|
||||
|
||||
notifyItemChanged(0);
|
||||
EventBus.getDefault().post(new EBSkip("DownloadManagerActivity", 0));
|
||||
@ -587,20 +601,23 @@ public class GameUpdateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
return updateList;
|
||||
}
|
||||
|
||||
public ArrayMap<String, Integer> getLocationMap() {
|
||||
public ArrayMap<String, ArrayList<Integer>> getLocationMap() {
|
||||
return locationMap;
|
||||
}
|
||||
|
||||
public SparseBooleanArray getSuccessMap() {
|
||||
return successMap;
|
||||
}
|
||||
|
||||
public ArrayMap<String, String> getPackageNameMap() {
|
||||
return packageNameMap;
|
||||
}
|
||||
|
||||
public SparseArray<DownloadEntity> getEntryMap() {
|
||||
return entryMap;
|
||||
public void removeUpdate(String packageName) {
|
||||
for (int i = 0; i < updateList.size(); i++) {
|
||||
if (updateList.get(i).getPackageName().equals(packageName)) {
|
||||
updateList.remove(i);
|
||||
if (updateList.isEmpty()) {
|
||||
notifyItemRangeRemoved(0, 2);
|
||||
break;
|
||||
}
|
||||
notifyItemRemoved(i + 1);
|
||||
notifyItemChanged(0);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ 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;
|
||||
@ -22,6 +23,8 @@ import com.gh.gamecenter.eventbus.EBPackage;
|
||||
import com.gh.gamecenter.eventbus.EBSkip;
|
||||
import com.gh.gamecenter.manager.PackageManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
/**
|
||||
@ -102,46 +105,36 @@ public class GameUpdateFragment extends Fragment {
|
||||
|
||||
public void onEventMainThread(EBDownloadStatus status) {
|
||||
if ("delete".equals(status.getStatus())) {
|
||||
String packageName = adapter.getPackageNameMap().get(status.getUrl());
|
||||
if (packageName != null) {
|
||||
Integer location = adapter.getLocationMap().get(packageName);
|
||||
adapter.getEntryMap().remove(location);
|
||||
gameupdate_rv_show.getAdapter().notifyItemChanged(location + 1);
|
||||
ArrayList<Integer> locationList = adapter.getLocationMap().get(status.getPackageName());
|
||||
if (locationList != null) {
|
||||
for (int location : locationList) {
|
||||
gameupdate_rv_show.getAdapter().notifyItemChanged(location);
|
||||
}
|
||||
gameupdate_rv_show.getAdapter().notifyItemChanged(0);
|
||||
}
|
||||
} else if ("update".equals(status.getStatus()) || "plugin".equals(status.getStatus())) {
|
||||
adapter.init();
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void onEventMainThread(EBPackage busFour) {
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
Integer location = adapter.getLocationMap().get(busFour.getPackageName());
|
||||
if (location != null) {
|
||||
adapter.getSuccessMap().put(location, true);
|
||||
EventBus.getDefault().post(
|
||||
new EBDownloadChanged("update", View.VISIBLE, -1));
|
||||
gameupdate_rv_show.getAdapter().notifyItemChanged(location + 1);
|
||||
gameupdate_rv_show.getAdapter().notifyItemChanged(0);
|
||||
PackageManager.removeUpdate(busFour.getPackageName());
|
||||
}
|
||||
} else if ("卸载".equals(busFour.getType())) {
|
||||
Integer location = adapter.getLocationMap().get(busFour.getPackageName());
|
||||
if (location != null && adapter.getUpdateList().size() != 0) {
|
||||
if (adapter.getUpdateList().get(location).isPluggable()) {
|
||||
EventBus.getDefault().post(
|
||||
new EBDownloadChanged("update", View.VISIBLE, -1));
|
||||
if (adapter.getUpdateList().size() == 1) {
|
||||
adapter.getUpdateList().remove(location.intValue());
|
||||
adapter.notifyItemRangeRemoved(0, 2);
|
||||
if (reuse_nodata_skip.getVisibility() == View.GONE) {
|
||||
reuse_nodata_skip.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
adapter.getUpdateList().remove(location.intValue());
|
||||
adapter.notifyItemRemoved(location + 1);
|
||||
adapter.notifyItemChanged(0);
|
||||
ArrayList<Integer> locationList = adapter.getLocationMap().get(busFour.getPackageName());
|
||||
if (locationList != null) {
|
||||
for (int location : locationList) {
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
gameupdate_rv_show.getAdapter().notifyItemChanged(location + 1);
|
||||
gameupdate_rv_show.getAdapter().notifyItemChanged(0);
|
||||
} else if ("卸载".equals(busFour.getType())) {
|
||||
adapter.removeUpdate(busFour.getPackageName());
|
||||
if (adapter.getUpdateList().isEmpty()) {
|
||||
reuse_nodata_skip.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
EventBus.getDefault().post(
|
||||
new EBDownloadChanged("update", View.VISIBLE, -1));
|
||||
}
|
||||
adapter.initLocationMap();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -163,23 +163,4 @@ public class GameUpdateEntity {
|
||||
this.apk = apk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GameUpdateEntity{" +
|
||||
"id='" + id + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", icon='" + icon + '\'' +
|
||||
", packageName='" + packageName + '\'' +
|
||||
", size='" + size + '\'' +
|
||||
", version='" + version + '\'' +
|
||||
", ghVersion='" + ghVersion + '\'' +
|
||||
", url='" + url + '\'' +
|
||||
", platform='" + platform + '\'' +
|
||||
", isPluggable=" + isPluggable +
|
||||
", apk=" + apk +
|
||||
", etag='" + etag + '\'' +
|
||||
", brief='" + brief + '\'' +
|
||||
", tag=" + tag +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,13 +139,10 @@ public class Game1Fragment extends BaseFragment implements SwipeRefreshLayout.On
|
||||
Runnable initPluginRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (PackageManager.getPluggableSize() != 0
|
||||
&& adapter.getPluginList().isEmpty()) {
|
||||
if (adapter.isInitPlugin()) {
|
||||
adapter.initPlugin();
|
||||
} else {
|
||||
handler.postDelayed(initPluginRunnable, 100);
|
||||
}
|
||||
if (adapter.isInitPlugin()) {
|
||||
handler.postDelayed(initPluginRunnable, 100);
|
||||
} else {
|
||||
adapter.initPlugin();
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -164,15 +161,21 @@ public class Game1Fragment extends BaseFragment implements SwipeRefreshLayout.On
|
||||
List<GameEntity> list = adapter.getPluginList();
|
||||
for (int i = 0, size = list.size(); i < size; i++) {
|
||||
if (list.get(i).getApk().get(0).getPackageName().equals(busFour.getPackageName())) {
|
||||
list.remove(i);
|
||||
if (list.isEmpty()) {
|
||||
adapter.initItemCount();
|
||||
adapter.notifyItemRangeRemoved(1, 2);
|
||||
if ("卸载".equals(busFour.getType())
|
||||
&& DownloadManager.getInstance(getActivity()).get(
|
||||
list.get(i).getApk().get(0).getUrl()) != null) {
|
||||
adapter.notifyItemChanged(2 + i);
|
||||
} else {
|
||||
adapter.initItemCount();
|
||||
adapter.notifyItemRemoved(location);
|
||||
list.remove(i);
|
||||
if (list.isEmpty()) {
|
||||
adapter.initItemCount();
|
||||
adapter.notifyItemRangeRemoved(1, 2);
|
||||
} else {
|
||||
adapter.initItemCount();
|
||||
adapter.notifyItemRemoved(location);
|
||||
adapter.notifyItemChanged(1);
|
||||
}
|
||||
}
|
||||
adapter.initLocationMap();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -181,7 +184,9 @@ public class Game1Fragment extends BaseFragment implements SwipeRefreshLayout.On
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
for (ApkEntity apkEntity : gameEntity.getApk()) {
|
||||
if (apkEntity.getPackageName().equals(busFour.getPackageName())) {
|
||||
gameEntity.getEntryMap().remove(apkEntity.getPlatform());
|
||||
if (gameEntity.getEntryMap() != null) {
|
||||
gameEntity.getEntryMap().remove(apkEntity.getPlatform());
|
||||
}
|
||||
adapter.notifyItemChanged(location);
|
||||
break;
|
||||
}
|
||||
@ -192,6 +197,7 @@ public class Game1Fragment extends BaseFragment implements SwipeRefreshLayout.On
|
||||
}
|
||||
}
|
||||
}
|
||||
adapter.initLocationMap();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@ import com.android.volley.TimeoutError;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.DownloadItemUtils;
|
||||
@ -71,15 +72,6 @@ import java.util.Map;
|
||||
*/
|
||||
public class Game1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private class ITEM_TYPE {
|
||||
public static final int slide = 0; // 滚动图
|
||||
public static final int head = 1; // 专题头部
|
||||
public static final int game_normal_type = 2; // 游戏布局1
|
||||
public static final int game_test_type = 3; // 游戏布局2
|
||||
public static final int image = 4; // 大图布局
|
||||
public static final int footer_view = 5; // 加载布局
|
||||
}
|
||||
|
||||
private Game1Fragment fragment;
|
||||
private Context context;
|
||||
private OnCallBackListener listener;
|
||||
@ -272,15 +264,18 @@ public class Game1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
}
|
||||
|
||||
public void initPlugin() {
|
||||
if (isInitPlugin) {
|
||||
return;
|
||||
}
|
||||
isInitPlugin = true;
|
||||
ArrayList<GameUpdateEntity> updateList = PackageManager.getUpdateList();
|
||||
if (updateList.isEmpty()) {
|
||||
if (!isInitPlugin) {
|
||||
isInitPlugin = true;
|
||||
}
|
||||
isInitPlugin = false;
|
||||
return;
|
||||
}
|
||||
List<GameEntity> list = new ArrayList<>();
|
||||
GameUpdateEntity gameUpdateEntity;
|
||||
pluginSize = 0;
|
||||
for (int i = 0, size= updateList.size(); i < size; i++) {
|
||||
gameUpdateEntity = updateList.get(i);
|
||||
if (gameUpdateEntity.isPluggable()) {
|
||||
@ -316,17 +311,20 @@ public class Game1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
gEntity.setEntryMap(DownloadManager.getInstance(context).
|
||||
getEntryMap(gEntity.getName()));
|
||||
}
|
||||
pluginList = list;
|
||||
initItemCount();
|
||||
notifyItemRangeInserted(1, pluginList.size() + 1);
|
||||
if (getItemCount() > pluginList.size() + 2) {
|
||||
notifyItemChanged(pluginList.size() + 2);
|
||||
if (pluginList.isEmpty()) {
|
||||
pluginList = list;
|
||||
initItemCount();
|
||||
notifyItemRangeInserted(1, pluginList.size() + 1);
|
||||
if (getItemCount() > pluginList.size() + 2) {
|
||||
notifyItemChanged(pluginList.size() + 2);
|
||||
}
|
||||
} else {
|
||||
pluginList = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
initLocationMap();
|
||||
}
|
||||
if (!isInitPlugin) {
|
||||
isInitPlugin = true;
|
||||
}
|
||||
isInitPlugin = false;
|
||||
}
|
||||
|
||||
private void showView() {
|
||||
@ -419,15 +417,15 @@ public class Game1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
public int getItemViewType(int position) {
|
||||
|
||||
if (position == 0) {
|
||||
return ITEM_TYPE.slide;
|
||||
return ItemViewType.GAME_SLIDE;
|
||||
}
|
||||
|
||||
if (!pluginList.isEmpty()) {
|
||||
if (position == 1) {
|
||||
return ITEM_TYPE.head;
|
||||
return ItemViewType.COLUMN_HEADER;
|
||||
}
|
||||
if (position > 1 && position <= 1 + pluginList.size()) {
|
||||
return ITEM_TYPE.game_normal_type;
|
||||
return ItemViewType.GAME_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -444,29 +442,29 @@ public class Game1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
}
|
||||
gameEntity = subjectList.get(i).getData().get(index);
|
||||
if (position == offset && !TextUtils.isEmpty(gameEntity.getImage())){
|
||||
return ITEM_TYPE.image;
|
||||
return ItemViewType.GAME_IMAGE;
|
||||
}else if (position == offset){
|
||||
return ITEM_TYPE.head;
|
||||
return ItemViewType.COLUMN_HEADER;
|
||||
}
|
||||
if (position == offset+1&&!TextUtils.isEmpty(subjectList.get(i).getData().get(0).getImage())){
|
||||
return ITEM_TYPE.head;
|
||||
return ItemViewType.COLUMN_HEADER;
|
||||
}
|
||||
if (!TextUtils.isEmpty(gameEntity.getImage())) {
|
||||
return ITEM_TYPE.image;
|
||||
return ItemViewType.GAME_IMAGE;
|
||||
}
|
||||
if (gameEntity.getTest() != null) {
|
||||
return ITEM_TYPE.game_test_type;
|
||||
return ItemViewType.GAME_TEST;
|
||||
}
|
||||
return ITEM_TYPE.game_normal_type;
|
||||
return ItemViewType.GAME_NORMAL;
|
||||
}
|
||||
offset = subjectList.get(i).getData().size() + offset + 1;
|
||||
}
|
||||
return ITEM_TYPE.footer_view;
|
||||
return ItemViewType.LOADING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == ITEM_TYPE.slide) {
|
||||
if (viewType == ItemViewType.GAME_SLIDE) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.plugin1_autoscrollviewpager_viewholder, parent, false);
|
||||
DisplayMetrics outMetrics = new DisplayMetrics();
|
||||
@ -475,19 +473,19 @@ public class Game1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
LinearLayout.LayoutParams.MATCH_PARENT, (int) (outMetrics.widthPixels / 16f * 7f));
|
||||
view.setLayoutParams(params);
|
||||
return new AutoScrollViewpagerViewHolder(view);
|
||||
} else if (viewType == ITEM_TYPE.head) {
|
||||
} else if (viewType == ItemViewType.COLUMN_HEADER) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.home_game_head_item, parent, false);
|
||||
return new GameHeadViewHolder(view);
|
||||
} else if (viewType == ITEM_TYPE.game_normal_type) {
|
||||
} else if (viewType == ItemViewType.GAME_NORMAL) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.game_normal_item, parent, false);
|
||||
return new GameNormalViewHolder(view);
|
||||
} else if (viewType == ITEM_TYPE.game_test_type) {
|
||||
} else if (viewType == ItemViewType.GAME_TEST) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.game_test_item, parent, false);
|
||||
return new GameTestViewHolder(view);
|
||||
} else if (viewType == ITEM_TYPE.image) {
|
||||
} else if (viewType == ItemViewType.GAME_IMAGE) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.home_game_image_item, parent, false);
|
||||
return new GameImageViewHolder(view);
|
||||
|
||||
@ -153,7 +153,9 @@ public class Game2Fragment extends BaseFragment implements SwipeRefreshLayout.On
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
for (ApkEntity apkEntity : gameEntity.getApk()) {
|
||||
if (apkEntity.getPackageName().equals(busFour.getPackageName())) {
|
||||
gameEntity.getEntryMap().remove(apkEntity.getPlatform());
|
||||
if (gameEntity.getEntryMap() != null) {
|
||||
gameEntity.getEntryMap().remove(apkEntity.getPlatform());
|
||||
}
|
||||
adapter.notifyItemChanged(location);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ import com.android.volley.TimeoutError;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.DownloadItemUtils;
|
||||
@ -56,14 +57,6 @@ import java.util.Map;
|
||||
*/
|
||||
public class Game2FragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private class ITEM_TYPE {
|
||||
public final static int HEAD = 100;// 专题头部
|
||||
public final static int GAME_NORMAL = 101;// 游戏布局1
|
||||
public final static int GAME_TEST = 102;// 游戏布局2
|
||||
public final static int IMAGE = 103;// 大图布局
|
||||
public final static int FOOTER = 104;// 加载布局
|
||||
}
|
||||
|
||||
private Game2Fragment fragment;
|
||||
private Context context;
|
||||
private OnCallBackListener listener;
|
||||
@ -224,47 +217,48 @@ public class Game2FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
}
|
||||
gameEntity = subjectList.get(i).getData().get(index);
|
||||
if (position == offset && !TextUtils.isEmpty(gameEntity.getImage())){
|
||||
return ITEM_TYPE.IMAGE;
|
||||
return ItemViewType.GAME_IMAGE;
|
||||
}else if (position == offset){
|
||||
return ITEM_TYPE.HEAD;
|
||||
return ItemViewType.COLUMN_HEADER;
|
||||
}
|
||||
if (position == offset+1 && !TextUtils.isEmpty(subjectList.get(i).getData().get(0).getImage())) {
|
||||
return ITEM_TYPE.HEAD;
|
||||
return ItemViewType.COLUMN_HEADER;
|
||||
}
|
||||
if (gameEntity.getTest() != null) {
|
||||
return ITEM_TYPE.GAME_TEST;
|
||||
return ItemViewType.GAME_TEST;
|
||||
}
|
||||
return ITEM_TYPE.GAME_NORMAL;
|
||||
return ItemViewType.GAME_NORMAL;
|
||||
}
|
||||
offset = subjectList.get(i).getData().size() + offset + 1;
|
||||
}
|
||||
}
|
||||
return ITEM_TYPE.FOOTER;
|
||||
return ItemViewType.LOADING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == ITEM_TYPE.HEAD) {
|
||||
if (viewType == ItemViewType.COLUMN_HEADER) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.home_game_head_item, parent, false);
|
||||
return new GameHeadViewHolder(view);
|
||||
} else if (viewType == ITEM_TYPE.IMAGE) {
|
||||
} else if (viewType == ItemViewType.GAME_IMAGE) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.home_game_image_item, parent, false);
|
||||
return new GameImageViewHolder(view);
|
||||
} else if (viewType == ITEM_TYPE.GAME_TEST) {
|
||||
} else if (viewType == ItemViewType.GAME_TEST) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.game_test_item, parent, false);
|
||||
return new GameTestViewHolder(view);
|
||||
} else if (viewType == ITEM_TYPE.GAME_NORMAL) {
|
||||
} else if (viewType == ItemViewType.GAME_NORMAL) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.game_normal_item, parent, false);
|
||||
return new GameNormalViewHolder(view);
|
||||
} else {
|
||||
} else if (viewType == ItemViewType.LOADING) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.refresh_footerview, parent, false);
|
||||
return new FooterViewHolder(view);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -174,7 +174,9 @@ public class Game3Fragment extends BaseFragment implements OnRefreshListener {
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
for (ApkEntity apkEntity : gameEntity.getApk()) {
|
||||
if (apkEntity.getPackageName().equals(busFour.getPackageName())) {
|
||||
gameEntity.getEntryMap().remove(apkEntity.getPlatform());
|
||||
if (gameEntity.getEntryMap() != null) {
|
||||
gameEntity.getEntryMap().remove(apkEntity.getPlatform());
|
||||
}
|
||||
adapter.notifyItemChanged(location);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ import com.android.volley.TimeoutError;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.DownloadItemUtils;
|
||||
@ -203,20 +204,25 @@ public class Game3FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
if (position == gameList.size()) {
|
||||
return ItemViewType.LOADING;
|
||||
} else {
|
||||
return ItemViewType.GAME_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
||||
if (i == gameList.size()) {
|
||||
if (i == ItemViewType.LOADING) {
|
||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(
|
||||
R.layout.refresh_footerview, viewGroup, false);
|
||||
return new FooterViewHolder(view);
|
||||
} else {
|
||||
} else if (i == ItemViewType.GAME_NORMAL) {
|
||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(
|
||||
R.layout.game_normal_item, viewGroup, false);
|
||||
return new GameNormalViewHolder(view);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -183,9 +183,10 @@ public class PackageManager {
|
||||
* @param packageName 包名
|
||||
*/
|
||||
public static void removeUpdate(String packageName) {
|
||||
for (int i = 0, size = getUpdateList().size(); i < size; i++) {
|
||||
for (int i = 0; i < getUpdateList().size(); i++) {
|
||||
if (packageName.equals(getUpdateList().get(i).getPackageName())) {
|
||||
getUpdateList().remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,42 +0,0 @@
|
||||
package com.gh.gamecenter.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.gh.gamecenter.db.SuspectedGameDao;
|
||||
import com.gh.gamecenter.db.info.SuspectedGameInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SuspectedGameManager {
|
||||
|
||||
private SuspectedGameDao dao;
|
||||
|
||||
public SuspectedGameManager(Context context) {
|
||||
dao = new SuspectedGameDao(context);
|
||||
}
|
||||
|
||||
public void addGame(SuspectedGameInfo entity) {
|
||||
dao.add(entity);
|
||||
}
|
||||
|
||||
public SuspectedGameInfo findSuspectedGame(String packageName) {
|
||||
return dao.find(packageName);
|
||||
}
|
||||
|
||||
public void deleteSuspectedGame(String packageName) {
|
||||
dao.delete(packageName);
|
||||
}
|
||||
|
||||
public List<SuspectedGameInfo> getAllGame() {
|
||||
return dao.getAll();
|
||||
}
|
||||
|
||||
public void updateGame(SuspectedGameInfo entity) {
|
||||
dao.update(entity);
|
||||
}
|
||||
|
||||
public void deleteAll() {
|
||||
dao.deleteAll();
|
||||
}
|
||||
|
||||
}
|
||||
@ -19,6 +19,7 @@ import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.DiskBasedCache;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.GzipUtils;
|
||||
@ -55,13 +56,6 @@ import java.util.Map;
|
||||
*/
|
||||
public class News1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
|
||||
|
||||
private class ITEM_TYPE {
|
||||
public static final int normal = 0;//正常布局
|
||||
public static final int special1 = 1;//一张1:3图
|
||||
public static final int special2 = 2;//三张4:3图
|
||||
public static final int footer = 3;//页脚
|
||||
}
|
||||
|
||||
private News1Fragment fragment;
|
||||
private Context context;
|
||||
private OnCallBackListener listener;
|
||||
@ -206,23 +200,24 @@ public class News1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == ITEM_TYPE.normal) {
|
||||
if (viewType == ItemViewType.NEWS_IMAGE1) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.fm_read_item, parent, false);
|
||||
return new NewsImage1ViewHolder(view);
|
||||
} else if (viewType == ITEM_TYPE.special1) {
|
||||
} else if (viewType == ItemViewType.NEWS_IMAGE3) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.fm_read2_special1, parent, false);
|
||||
return new NewsImage3ViewHolder(view);
|
||||
} else if (viewType == ITEM_TYPE.special2) {
|
||||
} else if (viewType == ItemViewType.NEWS_IMAGE2) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.fm_read2_special2, parent, false);
|
||||
return new NewsImage2ViewHolder(view);
|
||||
} else {
|
||||
} else if (viewType == ItemViewType.LOADING) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.refresh_footerview, parent, false);
|
||||
return new FooterViewHolder(view);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -439,16 +434,16 @@ public class News1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == newsList.size()) {
|
||||
return ITEM_TYPE.footer;
|
||||
return ItemViewType.LOADING;
|
||||
}
|
||||
NewsEntity newsEntity = newsList.get(position);
|
||||
if ("4x3".equals(newsEntity.getThumbnail().getType()) && newsEntity.getThumbnail().getUrl().size() == 3){
|
||||
return ITEM_TYPE.special2;
|
||||
return ItemViewType.NEWS_IMAGE2;
|
||||
}
|
||||
if ("3x1".equals(newsEntity.getThumbnail().getType())) {
|
||||
return ITEM_TYPE.special1;
|
||||
return ItemViewType.NEWS_IMAGE3;
|
||||
}
|
||||
return ITEM_TYPE.normal;
|
||||
return ItemViewType.NEWS_IMAGE1;
|
||||
}
|
||||
|
||||
private void statNewsViews(final String news_id, final int position) {
|
||||
|
||||
@ -20,6 +20,7 @@ import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.DiskBasedCache;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.GzipUtils;
|
||||
@ -56,13 +57,6 @@ import java.util.Map;
|
||||
*/
|
||||
public class News2FragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
|
||||
|
||||
private class ITEM_TYPE {
|
||||
public static final int normal = 0;//正常布局
|
||||
public static final int special1 = 1;//一张1:3图
|
||||
public static final int special2 = 2;//三张4:3图
|
||||
public static final int footer = 3;//页脚
|
||||
}
|
||||
|
||||
private News2Fragment fragment;
|
||||
private Context context;
|
||||
private OnCallBackListener listener;
|
||||
@ -207,23 +201,24 @@ public class News2FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == ITEM_TYPE.normal) {
|
||||
if (viewType == ItemViewType.NEWS_IMAGE1) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.fm_read_item, parent, false);
|
||||
return new NewsImage1ViewHolder(view);
|
||||
} else if (viewType == ITEM_TYPE.special1) {
|
||||
} else if (viewType == ItemViewType.NEWS_IMAGE3) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.fm_read2_special1, parent, false);
|
||||
return new NewsImage3ViewHolder(view);
|
||||
} else if (viewType == ITEM_TYPE.special2) {
|
||||
} else if (viewType == ItemViewType.NEWS_IMAGE2) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.fm_read2_special2, parent, false);
|
||||
return new NewsImage2ViewHolder(view);
|
||||
} else {
|
||||
} else if (viewType == ItemViewType.LOADING) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.refresh_footerview, parent, false);
|
||||
return new FooterViewHolder(view);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -435,16 +430,16 @@ public class News2FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == newsList.size()) {
|
||||
return ITEM_TYPE.footer;
|
||||
return ItemViewType.LOADING;
|
||||
}
|
||||
NewsEntity newsEntity = newsList.get(position);
|
||||
if ("4x3".equals(newsEntity.getThumbnail().getType()) && newsEntity.getThumbnail().getUrl().size() == 3){
|
||||
return ITEM_TYPE.special2;
|
||||
return ItemViewType.NEWS_IMAGE2;
|
||||
}
|
||||
if ("3x1".equals(newsEntity.getThumbnail().getType())) {
|
||||
return ITEM_TYPE.special1;
|
||||
return ItemViewType.NEWS_IMAGE3;
|
||||
}
|
||||
return ITEM_TYPE.normal;
|
||||
return ItemViewType.NEWS_IMAGE1;
|
||||
}
|
||||
|
||||
private void statNewsViews(final String news_id, final int position) {
|
||||
|
||||
@ -17,6 +17,7 @@ import com.android.volley.TimeoutError;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.NewsUtils;
|
||||
@ -51,15 +52,7 @@ import java.util.Map;
|
||||
* @email 294299195@qq.com
|
||||
* @date 2015-8-5 modified 2015-8-21 资讯首页模块
|
||||
*/
|
||||
public class News3FragmentAdapter extends
|
||||
RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
public static class ITEM_TYPE {
|
||||
public static final int head = 1;// head
|
||||
public static final int news_text = 2;// 新闻列表1类型
|
||||
public static final int news_image = 3;// 新闻列表2类型
|
||||
public static final int refresh_footer = 4;// 刷新布局类型
|
||||
}
|
||||
public class News3FragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private int position_today = -1;// 今天head的位置
|
||||
private int position_before = -1;// 昨天/以前head的位置
|
||||
@ -279,53 +272,54 @@ public class News3FragmentAdapter extends
|
||||
|
||||
if (position_today != -1) {
|
||||
if (position == position_today) {
|
||||
return ITEM_TYPE.head;
|
||||
return ItemViewType.NEWS_HEADER;
|
||||
}
|
||||
if (position == position_today + 1) {
|
||||
if (!TextUtils.isEmpty(todayNewsList.get(0).getThumb())) {
|
||||
return ITEM_TYPE.news_image;
|
||||
return ItemViewType.NEWS_IMAGE;
|
||||
} else {
|
||||
return ITEM_TYPE.news_text;
|
||||
return ItemViewType.NEWS_TEXT;
|
||||
}
|
||||
}
|
||||
if (position > position_today + 1
|
||||
&& position <= todayNewsList.size() + position_today) {
|
||||
return ITEM_TYPE.news_text;
|
||||
return ItemViewType.NEWS_TEXT;
|
||||
}
|
||||
}
|
||||
|
||||
if (position_before != -1) {
|
||||
if (position == position_before) {
|
||||
return ITEM_TYPE.head;
|
||||
return ItemViewType.NEWS_HEADER;
|
||||
}
|
||||
if (position > position_before
|
||||
&& position <= beforeNewsList.size() + position_before) {
|
||||
return ITEM_TYPE.news_text;
|
||||
return ItemViewType.NEWS_TEXT;
|
||||
}
|
||||
}
|
||||
|
||||
return ITEM_TYPE.refresh_footer;
|
||||
return ItemViewType.LOADING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == ITEM_TYPE.head) {
|
||||
if (viewType == ItemViewType.NEWS_HEADER) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.news_list_item_category, parent, false);
|
||||
return new NewsHeadViewHolder(view);
|
||||
} else if (viewType == ITEM_TYPE.news_image) {
|
||||
} else if (viewType == ItemViewType.NEWS_IMAGE) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.home_list_item_newsimage_type, parent, false);
|
||||
return new NewsImageViewHolder(view);
|
||||
} else if (viewType == ITEM_TYPE.news_text) {
|
||||
} else if (viewType == ItemViewType.NEWS_TEXT) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.home_list_item_newsnormal_type, parent, false);
|
||||
return new NewsTextViewHolder(view);
|
||||
} else {
|
||||
} else if (viewType == ItemViewType.LOADING) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.gamedetail_item_loading, parent, false);
|
||||
return new NewsFooterViewHolder(view);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -21,6 +21,7 @@ import com.facebook.drawee.drawable.ScalingUtils;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.common.util.ConcernUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
@ -411,20 +412,25 @@ public class News4FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
if (position == concernList.size()) {
|
||||
return ItemViewType.LOADING;
|
||||
} else {
|
||||
return ItemViewType.NEWS_DIGEST;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == concernList.size()){
|
||||
if (viewType == ItemViewType.LOADING) {
|
||||
View view = LayoutInflater.from(parent.getContext()).
|
||||
inflate(R.layout.refresh_footerview, parent, false);
|
||||
return new FooterViewHolder(view);
|
||||
} else {
|
||||
} else if (viewType == ItemViewType.NEWS_DIGEST) {
|
||||
View view = LayoutInflater.from(context).
|
||||
inflate(R.layout.concern_rv_item, parent, false);
|
||||
return new NewsConcernViewHolder(view);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -125,7 +125,9 @@ public class ConcernFragment extends BaseFragment {
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
for (ApkEntity apkEntity : gameEntity.getApk()) {
|
||||
if (apkEntity.getPackageName().equals(busFour.getPackageName())) {
|
||||
gameEntity.getEntryMap().remove(apkEntity.getPlatform());
|
||||
if (gameEntity.getEntryMap() != null) {
|
||||
gameEntity.getEntryMap().remove(apkEntity.getPlatform());
|
||||
}
|
||||
adapter.notifyItemChanged(location);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.DownloadItemUtils;
|
||||
@ -159,15 +160,16 @@ public class ConcernFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == 1) {
|
||||
if (viewType == ItemViewType.GAME_NORMAL) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.game_normal_item, parent, false);
|
||||
return new GameNormalViewHolder(view);
|
||||
} else {
|
||||
} else if (viewType == ItemViewType.LOADING) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.refresh_footerview, parent, false);
|
||||
return new FooterViewHolder(view);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -191,9 +193,9 @@ public class ConcernFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (gameList.size() != 0 && position >= 0 && position < gameList.size()) {
|
||||
return 1;
|
||||
return ItemViewType.GAME_NORMAL;
|
||||
}
|
||||
return 0;
|
||||
return ItemViewType.LOADING;
|
||||
}
|
||||
|
||||
private void initGameNormal(final GameNormalViewHolder holder, final GameEntity gameEntity, int i) {
|
||||
|
||||
@ -11,6 +11,7 @@ import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.DownloadItemUtils;
|
||||
@ -323,15 +324,16 @@ public class InstallFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == 1) {
|
||||
if (viewType == ItemViewType.GAME_NORMAL) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.game_normal_item, parent, false);
|
||||
return new GameNormalViewHolder(view);
|
||||
} else {
|
||||
} else if (viewType == ItemViewType.LOADING) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.refresh_footerview, parent, false);
|
||||
return new FooterViewHolder(view);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -355,9 +357,9 @@ public class InstallFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (gameList.size() != 0 && position >= 0 && position < gameList.size()) {
|
||||
return 1;
|
||||
return ItemViewType.GAME_NORMAL;
|
||||
}
|
||||
return 0;
|
||||
return ItemViewType.LOADING;
|
||||
}
|
||||
|
||||
private void initGameNormal(final GameNormalViewHolder holder, final GameEntity gameEntity, int i) {
|
||||
|
||||
@ -176,9 +176,11 @@ public class SearchGameDetailFragmentAdapter extends RecyclerView.Adapter<GameNo
|
||||
}
|
||||
});
|
||||
|
||||
if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) {
|
||||
if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()
|
||||
|| !Config.isShow(context)) {
|
||||
viewHolder.downloadBtn.setVisibility(View.GONE);
|
||||
} else {
|
||||
viewHolder.downloadBtn.setVisibility(View.VISIBLE);
|
||||
viewHolder.downloadBtn.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
@ -199,12 +201,6 @@ public class SearchGameDetailFragmentAdapter extends RecyclerView.Adapter<GameNo
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (Config.isShow(context)) {
|
||||
viewHolder.downloadBtn.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
viewHolder.downloadBtn.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.GameUtils;
|
||||
@ -113,7 +114,11 @@ public class SearchGameListFragmentAdapter extends RecyclerView.Adapter<Recycler
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
if (position == 0) {
|
||||
return ItemViewType.GAME_NORMAL;
|
||||
} else {
|
||||
return ItemViewType.SEARCH_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -162,9 +167,11 @@ public class SearchGameListFragmentAdapter extends RecyclerView.Adapter<Recycler
|
||||
}
|
||||
});
|
||||
|
||||
if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) {
|
||||
if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()
|
||||
|| !Config.isShow(context)) {
|
||||
viewHolder.downloadBtn.setVisibility(View.GONE);
|
||||
} else {
|
||||
viewHolder.downloadBtn.setVisibility(View.VISIBLE);
|
||||
viewHolder.downloadBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
@ -185,12 +192,6 @@ public class SearchGameListFragmentAdapter extends RecyclerView.Adapter<Recycler
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (Config.isShow(context)) {
|
||||
viewHolder.downloadBtn.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
viewHolder.downloadBtn.setVisibility(View.GONE);
|
||||
}
|
||||
} else if (holder instanceof SearchHistoryViewHolder) {
|
||||
SearchHistoryViewHolder viewHolder = (SearchHistoryViewHolder) holder;
|
||||
|
||||
@ -234,15 +235,16 @@ public class SearchGameListFragmentAdapter extends RecyclerView.Adapter<Recycler
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
if (viewType == 0) {
|
||||
if (viewType == ItemViewType.GAME_NORMAL) {
|
||||
View itemView = LayoutInflater.from(viewGroup.getContext())
|
||||
.inflate(R.layout.game_normal_item, viewGroup, false);
|
||||
return new GameNormalViewHolder(itemView);
|
||||
} else {
|
||||
} else if (viewType == ItemViewType.SEARCH_NORMAL) {
|
||||
View itemView = LayoutInflater.from(viewGroup.getContext())
|
||||
.inflate(R.layout.fm_search_history_item, viewGroup, false);
|
||||
return new SearchHistoryViewHolder(itemView);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.view.CardLinearLayout;
|
||||
@ -57,20 +58,25 @@ public class SearchHistoryFragmentAdapter extends RecyclerView.Adapter<ViewHolde
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
if (position == historyList.size()) {
|
||||
return ItemViewType.SEARCH_DELETE;
|
||||
} else {
|
||||
return ItemViewType.SEARCH_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
if (viewType == historyList.size()) {
|
||||
if (viewType == ItemViewType.SEARCH_DELETE) {
|
||||
View itemView = LayoutInflater.from(context).inflate(
|
||||
R.layout.fm_search_history_delete_item, viewGroup, false);
|
||||
return new ReuseViewHolder(itemView);
|
||||
} else {
|
||||
} else if (viewType == ItemViewType.SEARCH_NORMAL) {
|
||||
View view = LayoutInflater.from(context).inflate(
|
||||
R.layout.fm_search_history_item, viewGroup, false);
|
||||
return new SearchHistoryViewHolder(view);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user