解决冲突
This commit is contained in:
@ -82,13 +82,6 @@ public class PluginActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadEmpty() {
|
||||
plugin_list.setVisibility(View.GONE);
|
||||
plugin_pb_loading.setVisibility(View.GONE);
|
||||
reuse_no_connection.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDone() {
|
||||
if (plugin_pb_loading != null && plugin_pb_loading.getVisibility() == View.VISIBLE) {
|
||||
|
||||
@ -29,6 +29,7 @@ import com.gh.gamecenter.adapter.viewholder.GameNormalViewHolder;
|
||||
import com.gh.gamecenter.db.info.ConcernInfo;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity;
|
||||
import com.gh.gamecenter.listener.OnCallBackListener;
|
||||
import com.gh.gamecenter.manager.ConcernManager;
|
||||
import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
@ -69,102 +70,41 @@ public class PluginAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
locationMap = new ArrayMap<>();
|
||||
nameMap = new ArrayMap<>();
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
}
|
||||
}).start();
|
||||
init();
|
||||
}
|
||||
|
||||
private int count;
|
||||
|
||||
private void addCount() {
|
||||
synchronized (PluginAdapter.class) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
//检查可以插件化的游戏
|
||||
// 检查可以插件化的游戏
|
||||
private void init() {
|
||||
ConcernManager concernManager = new ConcernManager(context);
|
||||
List<ConcernInfo> infos = concernManager.getInstalledGame();
|
||||
final int size = infos.size();
|
||||
final List<GameEntity> list = new ArrayList<>();
|
||||
count = 0;
|
||||
for (ConcernInfo info : infos) {
|
||||
JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
|
||||
TimestampUtils.addTimestamp(
|
||||
Config.HOST + "v2d0/game/" + info.getId() + "/digest",
|
||||
Constants.GAME_CD),
|
||||
new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
Gson gson = new Gson();
|
||||
GameEntity gameEntity = gson.fromJson(response.toString(), GameEntity.class);
|
||||
list.add(gameEntity);
|
||||
addCount();
|
||||
if (count == size) {
|
||||
processingData(list);
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
addCount();
|
||||
if (count == size) {
|
||||
if (list.isEmpty()) {
|
||||
if (listener != null) {
|
||||
listener.loadEmpty();
|
||||
}
|
||||
} else {
|
||||
processingData(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
AppController.addToRequestQueue(request, PluginActivity.TAG);
|
||||
}
|
||||
}
|
||||
|
||||
private void processingData(List<GameEntity> list) {
|
||||
if (listener != null) {
|
||||
listener.loadDone();
|
||||
}
|
||||
if (list == null || list.isEmpty()) {
|
||||
ArrayList<GameUpdateEntity> updateList = PackageManager.getUpdateList();
|
||||
if (updateList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ConcernManager concernManager = new ConcernManager(context);
|
||||
PackageManager mPackageManager = new PackageManager(context);
|
||||
List<ConcernInfo> infos = concernManager.getInstalledGame();
|
||||
HashMap<String, Boolean> map;
|
||||
GameEntity gameEntity;
|
||||
for (ConcernInfo info : infos) {
|
||||
map = info.getPackageNames();
|
||||
for (int i = 0, size = list.size(); i < size; i++) {
|
||||
gameEntity = list.get(i);
|
||||
if (gameEntity.getId().equals(info.getId())
|
||||
&& gameEntity.getTag() != null && gameEntity.getTag().size() != 0
|
||||
&& gameEntity.getApk() != null) {
|
||||
for (String key : map.keySet()) {
|
||||
if (map.get(key)) {
|
||||
if (!mPackageManager.isSignature(key)) {
|
||||
for (ApkEntity apkEntity : gameEntity.getApk()) {
|
||||
if (apkEntity.getPackageName().equals(key)) {
|
||||
GameEntity entity = gameEntity.clone();
|
||||
entity.setPluggable(true);
|
||||
ArrayList<ApkEntity> apkList = new ArrayList<>();
|
||||
apkList.add(apkEntity);
|
||||
entity.setApk(apkList);
|
||||
pluginList.add(entity);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
GameUpdateEntity gameUpdateEntity;
|
||||
for (int i = 0, size= updateList.size(); i < size; i++) {
|
||||
gameUpdateEntity = updateList.get(i);
|
||||
if (gameUpdateEntity.isPluggable()) {
|
||||
GameEntity gameEntity = new GameEntity();
|
||||
gameEntity.setId(gameUpdateEntity.getId());
|
||||
gameEntity.setName(gameUpdateEntity.getName());
|
||||
gameEntity.setIcon(gameUpdateEntity.getIcon());
|
||||
gameEntity.setTag(gameUpdateEntity.getTag());
|
||||
gameEntity.setBrief(gameUpdateEntity.getBrief());
|
||||
gameEntity.setPluggable(true);
|
||||
|
||||
ApkEntity apkEntity = new ApkEntity();
|
||||
apkEntity.setUrl(gameUpdateEntity.getUrl());
|
||||
apkEntity.setPackageName(gameUpdateEntity.getPackageName());
|
||||
apkEntity.setSize(gameUpdateEntity.getSize());
|
||||
apkEntity.setVersion(gameUpdateEntity.getVersion());
|
||||
apkEntity.setGhVersion(gameUpdateEntity.getGhVersion());
|
||||
apkEntity.setPlatform(gameUpdateEntity.getPlatform());
|
||||
apkEntity.setEtag(gameUpdateEntity.getEtag());
|
||||
|
||||
ArrayList<ApkEntity> apk = new ArrayList<>();
|
||||
apk.add(apkEntity);
|
||||
gameEntity.setApk(apk);
|
||||
|
||||
pluginList.add(gameEntity);
|
||||
}
|
||||
}
|
||||
if (!pluginList.isEmpty()) {
|
||||
@ -175,6 +115,9 @@ public class PluginAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
}
|
||||
notifyItemRangeInserted(0, pluginList.size());
|
||||
initLocationMap();
|
||||
if (listener != null) {
|
||||
listener.loadDone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user