文件整理、修改
This commit is contained in:
@ -16,12 +16,14 @@ import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.Window;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -104,12 +106,10 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
public static ArrayMap<String, String> uninstallMap;
|
||||
public static String searchHint;
|
||||
|
||||
|
||||
private GameFragment gameFragment;
|
||||
private NewsFragment newsFragment;
|
||||
|
||||
private GameFragment pluginFragmentActivity;
|
||||
private PersonalFragment home3Fragment;
|
||||
private View home1Layout, home2Layout, home3Layout;
|
||||
private PersonalFragment personalFragment;
|
||||
private LinearLayout home1Layout, home2Layout, home3Layout;
|
||||
private ImageView home1Image, home2Image, home3Image;
|
||||
private TextView home1Title, home2Title, home3Title;
|
||||
|
||||
@ -133,10 +133,8 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
// 黄壮华 添加观察者 修改2015/8/15
|
||||
private DataWatcher dataWatcher = new DataWatcher() {
|
||||
@Override
|
||||
public void onDataChanged(
|
||||
HashMap<String, DownloadEntry> downloadingEntries) {
|
||||
for (Map.Entry<String, DownloadEntry> entry : downloadingEntries
|
||||
.entrySet()) {
|
||||
public void onDataChanged(HashMap<String, DownloadEntry> downloadingEntries) {
|
||||
for (Map.Entry<String, DownloadEntry> entry : downloadingEntries.entrySet()) {
|
||||
final DownloadEntry downloadEntry = entry.getValue();
|
||||
// 链接被劫持
|
||||
if (DownloadStatus.hijack.equals(downloadEntry.getStatus())) {
|
||||
@ -145,7 +143,7 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
// 弹出提示框
|
||||
EventBus.getDefault().post(new EBShowDialog("hijack"));
|
||||
//记录链接被劫持
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("url", downloadEntry.getUrl());
|
||||
map.put("game", downloadEntry.getName());
|
||||
map.put("platform", downloadEntry.getMeta().get("platform"));
|
||||
@ -154,10 +152,10 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
continue;
|
||||
}
|
||||
if (downloadEntry.getName().contains("光环助手") && isShowDownload) {
|
||||
app_tv_speed.setText(SpeedUtils.getSpeed(downloadEntry.getSpeed())
|
||||
+ "(剩" + SpeedUtils.getRemainTime(downloadEntry.getSize(),
|
||||
downloadEntry.getProgress(),
|
||||
downloadEntry.getSpeed() * 1024) + ")");
|
||||
app_tv_speed.setText(String.format("%s(剩%s)",
|
||||
SpeedUtils.getSpeed(downloadEntry.getSpeed()),
|
||||
SpeedUtils.getRemainTime(downloadEntry.getSize(),
|
||||
downloadEntry.getProgress(), downloadEntry.getSpeed() * 1024)));
|
||||
app_pb_progress.setProgress((int) (downloadEntry
|
||||
.getPercent() * 10));
|
||||
app_tv_percent.setText(downloadEntry.getPercent() + "%");
|
||||
@ -180,15 +178,12 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
}
|
||||
} else {
|
||||
|
||||
Map<String, Object> kv = new HashMap<String, Object>();
|
||||
kv.put("版本", downloadEntry.getMeta()
|
||||
.get("platform"));
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
kv.put("版本", downloadEntry.getMeta().get("platform"));
|
||||
kv.put("状态", "下载完成");
|
||||
|
||||
String isUpdate = downloadEntry.getMeta().get(
|
||||
"isUpdate");
|
||||
String entrance = downloadEntry.getMeta().get(
|
||||
"entrance");
|
||||
String isUpdate = downloadEntry.getMeta().get("isUpdate");
|
||||
String entrance = downloadEntry.getMeta().get("entrance");
|
||||
if (isUpdate != null && "true".equals(isUpdate)) {
|
||||
DataUtils.onEvent(MainActivity.this, "游戏更新",
|
||||
downloadEntry.getName(), kv);
|
||||
@ -196,7 +191,7 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
DataUtils.onEvent(MainActivity.this, "游戏下载",
|
||||
downloadEntry.getName(), kv);
|
||||
|
||||
Map<String, Object> kv2 = new HashMap<String, Object>();
|
||||
Map<String, Object> kv2 = new HashMap<>();
|
||||
kv2.put("版本",
|
||||
downloadEntry.getMeta().get("platform"));
|
||||
kv2.put("状态", "下载完成");
|
||||
@ -205,7 +200,7 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
downloadEntry.getName(), kv2);
|
||||
}
|
||||
if (downloadEntry.getMeta().get("isPlugin") != null) {
|
||||
Map<String, Object> kv6 = new HashMap<String, Object>();
|
||||
Map<String, Object> kv6 = new HashMap<>();
|
||||
kv6.put("下载", "下载完成");
|
||||
kv6.put("版本",
|
||||
downloadEntry.getMeta().get("platform"));
|
||||
@ -213,7 +208,7 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
downloadEntry.getName(), kv6);
|
||||
}
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("game", downloadEntry.getName());
|
||||
if (downloadEntry.getMeta().get("isPlugin") != null) {
|
||||
map.put("method", "插件化");
|
||||
@ -399,9 +394,9 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
initViews();
|
||||
setTabSelection(currentTab);
|
||||
|
||||
entryMap = new ArrayMap<String, String>();
|
||||
doneMap = new ArrayMap<String, String>();
|
||||
uninstallMap = new ArrayMap<String, String>();
|
||||
uninstallMap = new ArrayMap<>();
|
||||
entryMap = new ArrayMap<>();
|
||||
doneMap = new ArrayMap<>();
|
||||
|
||||
getSearchHints();
|
||||
|
||||
@ -429,18 +424,16 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ArrayList<String> concernList = new ArrayList<String>();
|
||||
ConcernManager concernManager = new ConcernManager(
|
||||
MainActivity.this);
|
||||
ArrayList<String> concernList = new ArrayList<>();
|
||||
ConcernManager concernManager = new ConcernManager(MainActivity.this);
|
||||
for (ConcernInfo entity : concernManager.getAllConcern()) {
|
||||
if (entity.isConcern()) {
|
||||
concernList.add(entity.getGameName());
|
||||
}
|
||||
}
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("type", Build.MODEL);
|
||||
map.put("system", Build.VERSION.SDK_INT + "="
|
||||
+ Build.VERSION.RELEASE);
|
||||
map.put("system", Build.VERSION.SDK_INT + "=" + Build.VERSION.RELEASE);
|
||||
map.put("install", PackageManager.getInstalledList());
|
||||
map.put("concern", concernList);
|
||||
map.put("createdOn", System.currentTimeMillis() / 1000);
|
||||
@ -458,50 +451,52 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
String version = PackageUtils.getVersion(getApplicationContext());
|
||||
String TD_CHANNEL_ID = (String) PackageUtils.getMetaData(this, getPackageName(), "TD_CHANNEL_ID");
|
||||
String url = "http://api.ghzhushou.com/v1d45/hotfix?channel=" + TD_CHANNEL_ID + "&version=" + version;
|
||||
JsonArrayExtendedRequest request = new JsonArrayExtendedRequest(url, new Response.Listener<JSONArray>() {
|
||||
@Override
|
||||
public void onResponse(JSONArray response) {
|
||||
Utils.log("hotfix = " + response.toString());
|
||||
try {
|
||||
for (int i = 0; i < response.length(); i++) {
|
||||
JSONObject jsonObject = response.getJSONObject(i);
|
||||
String clazz = jsonObject.getString("class");
|
||||
final String url = jsonObject.getString("url");
|
||||
String fileName = url.substring(url.lastIndexOf("/"));
|
||||
File directory = new File(getFilesDir().getAbsolutePath() + File.separator + "hotfix");
|
||||
if (!directory.exists() || !directory.isDirectory()) {
|
||||
directory.mkdirs();
|
||||
}
|
||||
File file = new File(directory.getAbsolutePath() + File.separator + fileName);
|
||||
if (file.exists()) {
|
||||
break;
|
||||
}
|
||||
//下载文件
|
||||
final String savePath = file.getAbsolutePath();
|
||||
new Thread(){
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
FileUtils.downloadFile(url, savePath);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Utils.log(savePath + " download success");
|
||||
}
|
||||
}.start();
|
||||
//存储class
|
||||
sp.edit().putString(file.getName(),clazz).apply();
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
Utils.log("hotfix = " + error.toString());
|
||||
}
|
||||
});
|
||||
JsonArrayExtendedRequest request = new JsonArrayExtendedRequest(url,
|
||||
new Response.Listener<JSONArray>() {
|
||||
@Override
|
||||
public void onResponse(JSONArray response) {
|
||||
Utils.log("hotfix = " + response.toString());
|
||||
try {
|
||||
for (int i = 0; i < response.length(); i++) {
|
||||
JSONObject jsonObject = response.getJSONObject(i);
|
||||
String clazz = jsonObject.getString("class");
|
||||
final String url = jsonObject.getString("url");
|
||||
String fileName = url.substring(url.lastIndexOf("/"));
|
||||
File directory = new File(getFilesDir().getAbsolutePath() + File.separator + "hotfix");
|
||||
if (!directory.exists() || !directory.isDirectory()) {
|
||||
directory.mkdirs();
|
||||
}
|
||||
File file = new File(directory.getAbsolutePath() + File.separator + fileName);
|
||||
if (file.exists()) {
|
||||
break;
|
||||
}
|
||||
//下载文件
|
||||
final String savePath = file.getAbsolutePath();
|
||||
new Thread(){
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
FileUtils.downloadFile(url, savePath);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Utils.log(savePath + " download success");
|
||||
}
|
||||
}.start();
|
||||
//存储class
|
||||
sp.edit().putString(file.getName(),clazz).apply();
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
Utils.log("hotfix = " + error.toString());
|
||||
}
|
||||
});
|
||||
AppController.addToRequestQueue(request, MainActivity.class);
|
||||
}
|
||||
|
||||
@ -510,82 +505,72 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
|
||||
Config.HOST + "v2/disclaimer",
|
||||
new Response.Listener<JSONObject>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
|
||||
Utils.log(response.toString());
|
||||
if (!isDestroy) {
|
||||
try {
|
||||
boolean isShow = response.getBoolean("isShow");
|
||||
sp.edit()
|
||||
.putBoolean("isShowDisclaimer", isShow)
|
||||
.apply();
|
||||
sp.edit().putBoolean("isShowDisclaimer", isShow).apply();
|
||||
if (isShow) {
|
||||
String content = response
|
||||
.getString("content");
|
||||
sp.edit().putString("disclaimer", content)
|
||||
.apply();
|
||||
String content = response.getString("content");
|
||||
sp.edit().putString("disclaimer", content).apply();
|
||||
if (isFirst) {
|
||||
DialogUtils.showDisclaimerDialog(MainActivity.this, content);
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
|
||||
Utils.log(error.toString());
|
||||
sp.edit().putBoolean("isShowDisclaimer", false).apply();
|
||||
}
|
||||
});
|
||||
AppController.addToRequestQueue(request, MainActivity.class);
|
||||
}
|
||||
private Class<?> intentClass(String to) {
|
||||
|
||||
Class aClass = null;
|
||||
private Class<?> intentClass(String to) {
|
||||
try {
|
||||
aClass = Class.forName("com.gh.gamecenter."+to);
|
||||
return Class.forName("com.gh.gamecenter." + to);
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return aClass;
|
||||
return null;
|
||||
}
|
||||
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
String to = getIntent().getExtras().getString("to");
|
||||
if(!TextUtils.isEmpty(to)){
|
||||
Intent toIntent = new Intent(getApplicationContext(),intentClass(to));
|
||||
|
||||
if("NewsActivity".equals(to)){
|
||||
Intent toIntent = new Intent(getApplicationContext(), intentClass(to));
|
||||
if ("NewsActivity".equals(to)) {
|
||||
toIntent.putExtra("newsId", getIntent().getExtras().getString("newsId"));
|
||||
toIntent.putExtra("entrance", getIntent().getExtras().getString("entrance"));
|
||||
}else if("DownloadManagerActivity".equals(to)){
|
||||
} else if("DownloadManagerActivity".equals(to)) {
|
||||
toIntent.putExtra("packageName" , getIntent().getExtras().getString("packageName"));
|
||||
toIntent.putExtra("currentItem" , 1);
|
||||
}else if ("GameDetailsActivity".equals(to)){
|
||||
} else if ("GameDetailsActivity".equals(to)) {
|
||||
toIntent.putExtra("gameId", getIntent().getExtras().getString("gameId"));
|
||||
toIntent.putExtra("entrance", getIntent().getExtras().getString("entrance"));
|
||||
}else if ("SubjectActivity".equals(to)){
|
||||
} else if ("SubjectActivity".equals(to)) {
|
||||
toIntent.putExtra("id", getIntent().getExtras().getString("id"));
|
||||
toIntent.putExtra("name", getIntent().getExtras().getString("name"));
|
||||
toIntent.putExtra("order", getIntent().getExtras().getBoolean("order"));
|
||||
}else if ("ViewImageActivity".equals(to)){
|
||||
} else if ("ViewImageActivity".equals(to)) {
|
||||
toIntent.putExtra("urls" , getIntent().getExtras().getStringArrayList("urls"));
|
||||
toIntent.putExtra("current" , getIntent().getExtras().getInt("current",0));
|
||||
toIntent.putExtra("ScaleType" , getIntent().getExtras().getString("ScaleType"));
|
||||
}
|
||||
startActivity(toIntent);
|
||||
}else {
|
||||
} else {
|
||||
String from = getIntent().getStringExtra("from");
|
||||
if (!TextUtils.isEmpty(from)) {
|
||||
if (from.equals("plugin")) {
|
||||
@ -613,7 +598,7 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
JSONObject jsonObject = new JSONObject(getIntent()
|
||||
.getStringExtra("data"));
|
||||
JSONArray jsonArray = jsonObject.getJSONArray("apk");
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject apk = jsonArray.getJSONObject(i);
|
||||
String packageName = apk.getString("package");
|
||||
@ -703,10 +688,8 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
+ "&channel=" + TD_CHANNEL_ID;
|
||||
JsonObjectExtendedRequest updateRequest = new JsonObjectExtendedRequest(
|
||||
url, new Response.Listener<JSONObject>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
|
||||
Utils.log("update=" + response.toString());
|
||||
if (!isDestroy) {
|
||||
if (response.length() != 0) {
|
||||
@ -771,10 +754,10 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
}
|
||||
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
|
||||
Utils.log("update=" + error.toString());
|
||||
}
|
||||
});
|
||||
@ -782,23 +765,23 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
}
|
||||
|
||||
private void showUpdateDialog(final String md5) {
|
||||
dialog = new Dialog(this);
|
||||
View view = View.inflate(this, R.layout.app_update_hint_dialog,
|
||||
null);
|
||||
TextView content = (TextView) view
|
||||
.findViewById(R.id.updeta_content);
|
||||
TextView size = (TextView) view
|
||||
.findViewById(R.id.update_app_size);
|
||||
TextView versison = (TextView) view.findViewById(R.id.update_app_version);
|
||||
final Dialog updateDialog = new Dialog(this);
|
||||
View view = View.inflate(this, R.layout.app_update_hint_dialog, null);
|
||||
|
||||
versison.setText("光环助手V"+appEntity.getVersion()+"更新内容:");
|
||||
size.setText("大小:"+appEntity.getSize());
|
||||
content.setText(appEntity.getContent()+"");
|
||||
TextView content = (TextView) view.findViewById(R.id.updeta_content);
|
||||
content.setText(Html.fromHtml(appEntity.getContent()));
|
||||
|
||||
TextView versison = (TextView) view.findViewById(R.id.update_app_version);
|
||||
versison.setText(String.format("光环助手V%s更新内容:",appEntity.getVersion()));
|
||||
|
||||
TextView size = (TextView) view.findViewById(R.id.update_app_size);
|
||||
size.setText(String.format("大小:%s", appEntity.getSize()));
|
||||
|
||||
if (appEntity.isIs_force()) {
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
dialog.setCancelable(false);
|
||||
updateDialog.setCanceledOnTouchOutside(false);
|
||||
updateDialog.setCancelable(false);
|
||||
}
|
||||
|
||||
view.findViewById(R.id.update_cannel).setOnClickListener(
|
||||
new OnClickListener() {
|
||||
@Override
|
||||
@ -806,7 +789,7 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
if (appEntity.isIs_force()) {
|
||||
finish();
|
||||
} else {
|
||||
dialog.dismiss();
|
||||
updateDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -814,11 +797,10 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.dismiss();
|
||||
updateDialog.dismiss();
|
||||
String path = FileUtils.getDownloadPath(
|
||||
MainActivity.this,
|
||||
"光环助手V" + appEntity.getVersion() + "_" + md5
|
||||
+ ".apk");
|
||||
"光环助手V" + appEntity.getVersion() + "_" + md5 + ".apk");
|
||||
File file = new File(path);
|
||||
if (file.exists() && file.length() > 0) {
|
||||
startActivity(PackageUtils.getInstallIntent(path));
|
||||
@ -828,9 +810,9 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
}
|
||||
}
|
||||
});
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
updateDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
updateDialog.setContentView(view);
|
||||
updateDialog.show();
|
||||
}
|
||||
|
||||
private void showDownloadDialog(String md5) {
|
||||
@ -878,7 +860,7 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
downloadEntry.setUrl(appEntity.getUrl());
|
||||
downloadEntry.setName("光环助手V" + appEntity.getVersion());
|
||||
downloadEntry.setPath(path);
|
||||
HashMap<String, String> meta = new HashMap<String, String>();
|
||||
HashMap<String, String> meta = new HashMap<>();
|
||||
meta.put("platform", "官方版");
|
||||
downloadEntry.setMeta(meta);
|
||||
|
||||
@ -926,15 +908,15 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
home1Layout = findViewById(R.id.home1_layout);
|
||||
home2Layout = findViewById(R.id.home2_layout);
|
||||
home3Layout = findViewById(R.id.home3_layout);
|
||||
home1Image = (ImageView) findViewById(R.id.message_image);
|
||||
home2Image = (ImageView) findViewById(R.id.contacts_image);
|
||||
home3Image = (ImageView) findViewById(R.id.news_image);
|
||||
home1Title = (TextView) findViewById(R.id.message_title);
|
||||
home2Title = (TextView) findViewById(R.id.contacts_title);
|
||||
home3Title = (TextView) findViewById(R.id.news_title);
|
||||
home1Layout = (LinearLayout) findViewById(R.id.main_ll_game);
|
||||
home2Layout = (LinearLayout) findViewById(R.id.main_ll_news);
|
||||
home3Layout = (LinearLayout) findViewById(R.id.main_ll_personal);
|
||||
home1Image = (ImageView) findViewById(R.id.main_iv_game);
|
||||
home2Image = (ImageView) findViewById(R.id.main_iv_news);
|
||||
home3Image = (ImageView) findViewById(R.id.main_iv_personal);
|
||||
home1Title = (TextView) findViewById(R.id.main_tv_game);
|
||||
home2Title = (TextView) findViewById(R.id.main_tv_news);
|
||||
home3Title = (TextView) findViewById(R.id.main_tv_personal);
|
||||
home1Layout.setOnClickListener(this);
|
||||
home2Layout.setOnClickListener(this);
|
||||
home3Layout.setOnClickListener(this);
|
||||
@ -943,15 +925,15 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.home1_layout:
|
||||
case R.id.main_ll_game:
|
||||
EventBus.getDefault().post(new EBUISwitch("MainActivity", 0));
|
||||
setTabSelection(0);
|
||||
break;
|
||||
case R.id.home2_layout:
|
||||
case R.id.main_ll_news:
|
||||
EventBus.getDefault().post(new EBUISwitch("MainActivity", 1));
|
||||
setTabSelection(1);
|
||||
break;
|
||||
case R.id.home3_layout:
|
||||
case R.id.main_ll_personal:
|
||||
EventBus.getDefault().post(new EBUISwitch("MainActivity", 2));
|
||||
setTabSelection(2);
|
||||
break;
|
||||
@ -969,23 +951,23 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
home1Layout.setClickable(false);
|
||||
home1Image.setImageResource(R.drawable.home1_selected);
|
||||
home1Title.setTextColor(getResources().getColor(R.color.theme));
|
||||
if (pluginFragmentActivity == null) {
|
||||
if (gameFragment == null) {
|
||||
List<Fragment> list = getSupportFragmentManager().getFragments();
|
||||
if (list != null) {
|
||||
for (Fragment fragment : list) {
|
||||
if (fragment.getClass().equals(GameFragment.class)) {
|
||||
pluginFragmentActivity = (GameFragment) fragment;
|
||||
transaction.show(pluginFragmentActivity);
|
||||
gameFragment = (GameFragment) fragment;
|
||||
transaction.show(gameFragment);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pluginFragmentActivity == null) {
|
||||
pluginFragmentActivity = new GameFragment();
|
||||
transaction.add(R.id.main_content, pluginFragmentActivity);
|
||||
if (gameFragment == null) {
|
||||
gameFragment = new GameFragment();
|
||||
transaction.add(R.id.main_content, gameFragment);
|
||||
}
|
||||
} else {
|
||||
transaction.show(pluginFragmentActivity);
|
||||
transaction.show(gameFragment);
|
||||
}
|
||||
currentTab = 0;
|
||||
break;
|
||||
@ -1017,23 +999,23 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
home3Layout.setClickable(false);
|
||||
home3Image.setImageResource(R.drawable.home3_selected);
|
||||
home3Title.setTextColor(getResources().getColor(R.color.theme));
|
||||
if (home3Fragment == null) {
|
||||
if (personalFragment == null) {
|
||||
List<Fragment> list = getSupportFragmentManager().getFragments();
|
||||
if (list != null) {
|
||||
for (Fragment fragment : list) {
|
||||
if (fragment.getClass().equals(PersonalFragment.class)) {
|
||||
home3Fragment = (PersonalFragment) fragment;
|
||||
transaction.show(home3Fragment);
|
||||
personalFragment = (PersonalFragment) fragment;
|
||||
transaction.show(personalFragment);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (home3Fragment == null) {
|
||||
home3Fragment = new PersonalFragment();
|
||||
transaction.add(R.id.main_content, home3Fragment);
|
||||
if (personalFragment == null) {
|
||||
personalFragment = new PersonalFragment();
|
||||
transaction.add(R.id.main_content, personalFragment);
|
||||
}
|
||||
} else {
|
||||
transaction.show(home3Fragment);
|
||||
transaction.show(personalFragment);
|
||||
}
|
||||
currentTab = 2;
|
||||
break;
|
||||
@ -1062,11 +1044,11 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
* 将所有的Fragment都置为隐藏状态。
|
||||
*/
|
||||
private void hideFragments(FragmentTransaction transaction) {
|
||||
if (home3Fragment != null) {
|
||||
transaction.hide(home3Fragment);
|
||||
if (personalFragment != null) {
|
||||
transaction.hide(personalFragment);
|
||||
}
|
||||
if (pluginFragmentActivity != null) {
|
||||
transaction.hide(pluginFragmentActivity);
|
||||
if (gameFragment != null) {
|
||||
transaction.hide(gameFragment);
|
||||
}
|
||||
if (newsFragment != null) {
|
||||
transaction.hide(newsFragment);
|
||||
@ -1081,18 +1063,19 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
}
|
||||
|
||||
private void uploadData(String id, String platform) {
|
||||
HashMap<String, String> params = new HashMap<String, String>();
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("game", id);
|
||||
params.put("platform", platform);
|
||||
JSONObject jsonObject = new JSONObject(params);
|
||||
JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
|
||||
Method.POST, Config.HOST + "v2/stat/download",
|
||||
jsonObject.toString(), new Response.Listener<JSONObject>() {
|
||||
Method.POST, Config.HOST + "v2/stat/download", jsonObject.toString(),
|
||||
new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
Utils.log("download = " + response);
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
Utils.log("download = " + error);
|
||||
@ -1127,7 +1110,7 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
getApplicationContext()).get(url);
|
||||
if (downloadEntry != null
|
||||
&& downloadEntry.getMeta().get("isPlugin") != null) {
|
||||
Map<String, Object> kv6 = new HashMap<String, Object>();
|
||||
Map<String, Object> kv6 = new HashMap<>();
|
||||
kv6.put("安装或卸载", "安装完成");
|
||||
DataUtils.onEvent(this, "插件化", downloadEntry.getName(), kv6);
|
||||
}
|
||||
@ -1143,7 +1126,7 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
if (downloadEntry.getMeta().get("isPlugin") != null
|
||||
&& downloadEntry.getMeta().get("package_name")
|
||||
.equals(packageName)) {
|
||||
Map<String, Object> kv6 = new HashMap<String, Object>();
|
||||
Map<String, Object> kv6 = new HashMap<>();
|
||||
kv6.put("安装或卸载", "卸载完成");
|
||||
DataUtils.onEvent(this, "插件化", downloadEntry.getName(), kv6);
|
||||
break;
|
||||
@ -1193,7 +1176,7 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
}
|
||||
if ("卸载".equals(busFour.getType())) {
|
||||
ArrayList<GameUpdateEntity> list = PackageManager.getUpdateList();
|
||||
GameUpdateEntity game = null;
|
||||
GameUpdateEntity game;
|
||||
int index = -1;
|
||||
for (int i = 0, size = list.size(); i < size; i++) {
|
||||
game = list.get(i);
|
||||
@ -1210,7 +1193,7 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("type", busFour.getType());
|
||||
map.put("packageName", busFour.getPackageName());
|
||||
map.put("createdOn", System.currentTimeMillis() / 1000);
|
||||
@ -1220,8 +1203,7 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
@Override
|
||||
public void finish() {
|
||||
// 上传数据
|
||||
DataCollectionManager.getInstance(getApplicationContext())
|
||||
.statClickData();
|
||||
DataCollectionManager.getInstance(getApplicationContext()).statClickData();
|
||||
super.finish();
|
||||
}
|
||||
|
||||
@ -1232,8 +1214,8 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
AppController.canclePendingRequests(GameFragment.class);
|
||||
AppController.canclePendingRequests(NewsFragment.class);
|
||||
DownloadManager.getInstance(this).removeObserver(dataWatcher);
|
||||
pluginFragmentActivity = null;
|
||||
home3Fragment = null;
|
||||
gameFragment = null;
|
||||
personalFragment = null;
|
||||
home1Layout = null;
|
||||
home2Layout = null;
|
||||
home3Layout = null;
|
||||
|
||||
Reference in New Issue
Block a user