根据issues整理项目
This commit is contained in:
@ -7,6 +7,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
@ -77,12 +78,9 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
private SharedPreferences sp;
|
||||
private boolean isFirst;
|
||||
|
||||
public static boolean isShow = true;
|
||||
|
||||
private String from;
|
||||
|
||||
private long start = 0L;
|
||||
private long end = 0L;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -191,7 +189,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
// 第一次启动,把package.txt文件内容加载进数据库
|
||||
if (!sp.getBoolean("isLoadFilter", false)) {
|
||||
try {
|
||||
List<FilterInfo> list = new ArrayList<FilterInfo>();
|
||||
List<FilterInfo> list = new ArrayList<>();
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(getAssets().open(
|
||||
"package.txt")));
|
||||
@ -229,6 +227,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
getPlatform();
|
||||
}
|
||||
|
||||
// 获取下载按钮状态、开启or关闭
|
||||
getDownloadStatus();
|
||||
|
||||
getUISetting();
|
||||
@ -299,21 +298,28 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
|
||||
Config.HOST + "v1d45/support/setting/download/" + TD_CHANNEL_ID
|
||||
+ "/switch2?version="
|
||||
+ PackageUtils.getVersion(getApplicationContext()), new Response.Listener<JSONObject>() {
|
||||
|
||||
+ PackageUtils.getVersion(getApplicationContext()),
|
||||
new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
try {
|
||||
isShow = response.getBoolean("status");
|
||||
boolean isShow = response.getBoolean("status");
|
||||
sp.edit().putBoolean("isShow", isShow).apply();
|
||||
Config.getInstance().setShow(isShow);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
isShow = true;
|
||||
if (sp.getBoolean("isShow", false)) {
|
||||
Config.getInstance().setShow(true);
|
||||
} else {
|
||||
sp.edit().putBoolean("isShow", false).apply();
|
||||
Config.getInstance().setShow(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
AppController.addToRequestQueue(request, SplashScreenActivity.class);
|
||||
@ -351,7 +357,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
@Override
|
||||
public void onResponse(JSONArray response) {
|
||||
try {
|
||||
Set<String> pset = new HashSet<String>();
|
||||
Set<String> pset = new HashSet<>();
|
||||
for (int i = 0; i < response.length(); i++) {
|
||||
JSONObject jsonObject = response
|
||||
.getJSONObject(i);
|
||||
@ -383,11 +389,17 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
|
||||
private int iCount;
|
||||
|
||||
private void addInstalledCount() {
|
||||
synchronized (SplashScreenActivity.class) {
|
||||
iCount++;
|
||||
}
|
||||
}
|
||||
|
||||
private void getInstalledListFromServer() {
|
||||
List<String> list = PackageManager.getLocalPackageName(getApplicationContext());
|
||||
final int count = list.size();
|
||||
final List<JSONObject> data = new ArrayList<JSONObject>();
|
||||
final List<String> useParams = new ArrayList<String>();
|
||||
final List<JSONObject> data = new ArrayList<>();
|
||||
final List<String> useParams = new ArrayList<>();
|
||||
iCount = 0;
|
||||
for (int i = 0, size = list.size(); i < size; i++) {
|
||||
final String packageName = list.get(i);
|
||||
@ -397,20 +409,21 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
iCount++;
|
||||
if (response.length() != 0) {
|
||||
data.add(response);
|
||||
useParams.add(packageName);
|
||||
}
|
||||
addInstalledCount();
|
||||
if (iCount == count) {
|
||||
processingInstalledData(data, useParams);
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
iCount++;
|
||||
addInstalledCount();
|
||||
if (iCount == count) {
|
||||
processingInstalledData(data, useParams);
|
||||
}
|
||||
@ -422,7 +435,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
|
||||
private void processingInstalledData(List<JSONObject> data,
|
||||
List<String> useParams) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
Gson gson = new Gson();
|
||||
ConcernManager manager = new ConcernManager(getApplicationContext());
|
||||
for (int i = 0, size = data.size(); i < size; i++) {
|
||||
@ -489,7 +502,8 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
builder.delete(0, builder.length());
|
||||
for (int j = i * 10, sizej = (i + 1) * 10 > list.size() ? list
|
||||
.size() : (i + 1) * 10; j < sizej; j++) {
|
||||
builder.append(list.get(j) + "-");
|
||||
builder.append(list.get(j));
|
||||
builder.append("-");
|
||||
}
|
||||
if (builder.length() != 0) {
|
||||
packages = builder.substring(0, builder.length() - 1);
|
||||
@ -546,9 +560,15 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
|
||||
private int cCount;
|
||||
|
||||
private void addConcernCount() {
|
||||
synchronized (SplashScreenActivity.class) {
|
||||
cCount++;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateConcern() {
|
||||
|
||||
ArrayList<String> concernId = new ArrayList<String>();
|
||||
ArrayList<String> concernId = new ArrayList<>();
|
||||
for (ConcernInfo entity : concernManager.getAllConcern()) {
|
||||
concernId.add(entity.getId());
|
||||
}
|
||||
@ -563,8 +583,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
|
||||
cCount++;
|
||||
addConcernCount();
|
||||
Gson gson = new Gson();
|
||||
GameEntity gameEntity = gson.fromJson(
|
||||
response.toString(), GameEntity.class);
|
||||
@ -574,7 +593,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
ConcernInfo entity = map.get(gameEntity.getId());
|
||||
if (entity != null) {
|
||||
List<ApkEntity> list = gameEntity.getApk();
|
||||
HashMap<String, Boolean> packageNames = new HashMap<String, Boolean>();
|
||||
HashMap<String, Boolean> packageNames = new HashMap<>();
|
||||
for (int j = 0, sizej = list.size(); j < sizej; j++) {
|
||||
packageNames.put(list.get(j).getPackageName(), false);
|
||||
}
|
||||
@ -590,12 +609,12 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
update();
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
|
||||
cCount++;
|
||||
addConcernCount();
|
||||
if (cCount == count) {
|
||||
update();
|
||||
}
|
||||
@ -618,13 +637,12 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
/*
|
||||
* 更新关注列表数据
|
||||
*/
|
||||
TrafficUtils spy = TrafficUtils.getInstance(getApplicationContext(),
|
||||
true);
|
||||
TrafficUtils spy = TrafficUtils.getInstance(getApplicationContext(), true);
|
||||
List<ConcernInfo> concernEntities = concernManager.getAllConcern();
|
||||
for (ConcernInfo concernEntity : concernEntities) {
|
||||
concernEntity.setTime(System.currentTimeMillis());
|
||||
int quantity = 0;
|
||||
HashMap<String, Boolean> packageNames = new HashMap<String, Boolean>();
|
||||
HashMap<String, Boolean> packageNames = new HashMap<>();
|
||||
for (String packageName : concernEntity.getPackageNames().keySet()) {
|
||||
if (PackageManager.isInstalled(packageName)) {
|
||||
quantity++;
|
||||
@ -651,7 +669,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
weight = 1;
|
||||
}
|
||||
concernEntity.setTag(tag);
|
||||
long traffic = spy.getTraffic(new ArrayList<String>(concernEntity
|
||||
long traffic = spy.getTraffic(new ArrayList<>(concernEntity
|
||||
.getPackageNames().keySet()));
|
||||
concernEntity.setTraffic(traffic);
|
||||
if (traffic > 0) {
|
||||
@ -695,9 +713,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
end = System.currentTimeMillis();
|
||||
|
||||
Utils.log("time = " + (end - start));
|
||||
Utils.log("time = " + (System.currentTimeMillis() - start));
|
||||
|
||||
startActivity(intent);
|
||||
finish();
|
||||
@ -705,19 +721,19 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
}
|
||||
private void intentControl(Bundle bundle, Intent intent) {
|
||||
String to = bundle.getString("to");
|
||||
if("NewsActivity".equals(to)){
|
||||
if ("NewsActivity".equals(to)) {
|
||||
intent.putExtra("newsId" , bundle.getString("newsId"));
|
||||
intent.putExtra("entrance" , bundle.getString("entrance"));
|
||||
}else if("DownloadManagerActivity".equals(to)){
|
||||
} else if("DownloadManagerActivity".equals(to)) {
|
||||
intent.putExtra("packageName" , bundle.getString("packageName"));
|
||||
}else if ("GameDetailsActivity".equals(to)){
|
||||
} else if ("GameDetailsActivity".equals(to)) {
|
||||
intent.putExtra("gameId" , bundle.getString("gameId"));
|
||||
intent.putExtra("entrance" , bundle.getString("entrance"));
|
||||
}else if ("SubjectActivity".equals(to)){
|
||||
} else if ("SubjectActivity".equals(to)) {
|
||||
intent.putExtra("id" , bundle.getString("id"));
|
||||
intent.putExtra("name" , bundle.getString("name"));
|
||||
intent.putExtra("order" , bundle.getBoolean("order"));
|
||||
}else if ("ViewImageActivity".equals(to)){
|
||||
} else if ("ViewImageActivity".equals(to)) {
|
||||
intent.putExtra("urls" , bundle.getStringArrayList("urls"));
|
||||
intent.putExtra("current" , bundle.getInt("current",0));
|
||||
intent.putExtra("ScaleType" , bundle.getString("ScaleType"));
|
||||
|
||||
Reference in New Issue
Block a user