App List v1.4.1版本的 MD5 值为:83af4eccc4c2dbeaca363142fe3c4495
以下内容为反编译后的 a.java 源代码,内容仅作参考
package com.cvte.tv.appstore.c;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.cvte.myou.R;
import com.cvte.tv.appstore.AppStoreApplication;
import com.cvte.tv.appstore.d.a.a;
import com.cvte.tv.appstore.d.a.e;
import com.cvte.tv.appstore.modules.download.c.a;
import com.cvte.tv.appstore.modules.download.services.DownloadService;
import com.cvte.tv.appstore.modules.webclient.NetWorkReceiver;
import com.cvte.tv.appstore.modules.webclient.impl.AppStoreApiImpl;
import com.cvte.tv.appstore.utils.AppInfoUtil;
import com.cvte.tv.appstore.utils.j;
import com.cvte.tv.appstore.widget.AppStoreProgressWrapper;
import com.cvte.tv.appstore.widget.ImagePreviewPopup;
import com.cvte.tv.appstore.widget.b;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.squareup.a.t;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
public class a extends com.cvte.tv.appstore.c.b implements View.OnFocusChangeListener, NetWorkReceiver.a {
private int aA;
private com.cvte.tv.appstore.d.a.a aB;
private com.cvte.tv.appstore.d.a.e aC;
private com.cvte.tv.appstore.modules.download.b.a aD;
private List<String> aE;
private int aH;
LinearLayout aa;
ImageView ab;
TextView ac;
TextView ad;
TextView ae;
TextView af;
TextView ag;
TextView ah;
TextView ai;
TextView aj;
TextView ak;
AppStoreProgressWrapper al;
RelativeLayout am;
RecyclerView an;
ImagePreviewPopup ao;
AppStoreApiImpl ap;
Context aq;
AlertDialog ar;
private c ax;
private C0039a ay;
private b az;
private static String at = a.class.getSimpleName();
public static String Z = "appid";
private static String au = "http://starkapp.cvte.com/download/apk/";
private static String av = ".apk";
private static String aw = "http://starkapp.cvte.com/download/icon/";
private boolean aF = false;
private Handler aG = new Handler(Looper.getMainLooper()) {
@Override
public void dispatchMessage(Message message) {
super.dispatchMessage(message);
switch (message.what) {
case 10:
if (a.this.c() == null) {
j.a(a.at, "init data,NO data!!!");
return;
}
if (a.this.aB == null) {
j.a(a.at, "init data,NO data!!!");
return;
}
j.a(a.at, "Init data finish,data:" + a.this.aB.toString());
a.this.S();
a.this.a(a.this.aB);
a.this.b(a.this.aB);
a.this.R();
if (a.this.aH == 7) {
a.this.b(a.this.aH);
a.this.b(true);
return;
} else {
if (a.this.Q()) {
return;
}
a.this.aH = 1;
if (a.this.T()) {
a.this.aH = 6;
}
a.this.b(a.this.aH);
a.this.b(true);
return;
}
case 11:
a.this.aH = 5;
if (a.this.T()) {
a.this.aH = 6;
}
a.this.b(a.this.aH);
a.this.b(true);
return;
case 12:
a.this.aH = 2;
if (a.this.T()) {
a.this.aH = 6;
}
a.this.b(a.this.aH);
a.this.b(true);
return;
case 13:
a.this.b(a.this.b().getString(R.string.net_error));
a.this.c().finish();
return;
default:
return;
}
}
};
int as = 100;
public class C0039a extends BroadcastReceiver {
C0039a() {
}
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.intent.action.PACKAGE_ADDED")) {
if (intent.getData().getSchemeSpecificPart().equals(a.this.aB.h)) {
a.this.b(5);
}
} else if (intent.getAction().equals("android.intent.action.PACKAGE_REMOVED")) {
intent.getData().getSchemeSpecificPart();
} else if (intent.getAction().equals("android.intent.action.PACKAGE_REPLACED") && intent.getData().getSchemeSpecificPart().equals(a.this.aB.h)) {
a.this.b(5);
}
}
}
public class b extends BroadcastReceiver {
b() {
}
@Override
public void onReceive(Context context, Intent intent) {
if ("ACTION_DOWNLOAD_TIMEOUT".equals(intent.getAction())) {
int intExtra = intent.getIntExtra("task_id", 0);
j.a("download", "DownloadErrorReceiver,ACTION_DOWNLOAD_TIMEOUT,id = " + intExtra);
if (intExtra == a.this.aB.d) {
j.a("download", "收到任务id为" + intExtra + "的广播,显示网络出错界面");
a.this.c(true);
a.this.as = 101;
return;
}
return;
}
if ("ACTION_INIT_DOWNLOAD_ERROR".equals(intent.getAction())) {
j.a("download", "DownloadErrorReceiver,ACTION_INIT_DOWNLOAD_ERROR");
if (intent.getIntExtra("task_id", 0) == a.this.aB.d) {
a.this.c(true);
a.this.as = 102;
return;
}
return;
}
if ("ACTION_DOWNLOAD_ERROR".equals(intent.getAction())) {
j.a("download", "DownloadErrorReceiver,ACTION_DOWNLOAD_ERROR");
int intExtra2 = intent.getIntExtra("task_id", 0);
Toast.makeText(a.this.b(), a.this.a(R.string.app_download_error), 0).show();
if (intExtra2 == a.this.aB.d) {
a.this.b(1);
}
}
}
}
public class c extends BroadcastReceiver {
c() {
}
@Override
public void onReceive(Context context, Intent intent) {
if ("ACTION_UPDATE".equals(intent.getAction())) {
a.this.as = 100;
int intExtra = intent.getIntExtra("task_id", -1);
double doubleExtra = intent.getDoubleExtra("show_progress", 0.0d);
intent.getIntExtra("progress", 0);
if (a.this.aB == null || intExtra != a.this.aB.d) {
return;
}
j.a("download", "UI,update service,showProgress:" + doubleExtra);
if (a.this.aH != 3) {
a.this.b(3);
}
a.this.al.setProgress((int) (doubleExtra * 100.0d));
if (doubleExtra == 1.0d) {
a.this.al.setProgress((int) (doubleExtra * 100.0d));
a.this.b(4);
}
}
}
}
private void O() {
this.ax = new c();
c().registerReceiver(this.ax, new IntentFilter("ACTION_UPDATE"));
this.ay = new C0039a();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.intent.action.PACKAGE_ADDED");
intentFilter.addAction("android.intent.action.PACKAGE_REMOVED");
intentFilter.addAction("android.intent.action.PACKAGE_REPLACED");
intentFilter.addDataScheme("package");
c().registerReceiver(this.ay, intentFilter);
this.az = new b();
IntentFilter intentFilter2 = new IntentFilter();
intentFilter2.addAction("ACTION_DOWNLOAD_TIMEOUT");
intentFilter2.addAction("ACTION_INIT_DOWNLOAD_ERROR");
intentFilter2.addAction("ACTION_DOWNLOAD_ERROR");
c().registerReceiver(this.az, intentFilter2);
}
private void P() {
c().unregisterReceiver(this.ax);
c().unregisterReceiver(this.ay);
c().unregisterReceiver(this.az);
}
public boolean Q() {
if (!AppInfoUtil.hasApplication(b(), this.aB.h)) {
return false;
}
final PackageInfo packageInfo = null;
try {
try {
packageInfo = b().getPackageManager().getPackageInfo(this.aB.h, 0);
if (packageInfo == null) {
j.a(at, "No such app which packageName is " + this.aB.h);
return false;
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
if (0 == 0) {
j.a(at, "No such app which packageName is " + this.aB.h);
return false;
}
}
j.a(at, "This system has such app like :" + packageInfo.toString());
com.cvte.tv.appstore.d.a.c cVar = new com.cvte.tv.appstore.d.a.c();
cVar.f660a = this.aB.g;
cVar.b = packageInfo.packageName;
cVar.c = packageInfo.versionCode;
com.cvte.tv.appstore.d.a.d dVar = new com.cvte.tv.appstore.d.a.d();
dVar.f662a = 1;
dVar.b = "huawei";
dVar.c = new ArrayList();
dVar.c.add(cVar);
final String json = new Gson().toJson(dVar);
new Thread(new Runnable() {
@Override
public void run() {
boolean z = false;
j.a(a.at, "Query update thread start,json:" + json);
JsonObject upgradeSoftWare = a.this.ap.getUpgradeSoftWare(json);
j.a(a.at, "jo:" + upgradeSoftWare);
com.cvte.tv.appstore.d.b.b a2 = com.cvte.tv.appstore.d.b.b.a();
if (upgradeSoftWare == null) {
return;
}
a.this.aC = (com.cvte.tv.appstore.d.a.e) a2.a(upgradeSoftWare, com.cvte.tv.appstore.d.a.e.class);
if (a.this.aC.k != null && a.this.aC.k.size() != 0) {
Iterator<e.a> it = a.this.aC.k.iterator();
while (it.hasNext()) {
z = packageInfo.packageName.equals(it.next().e) ? true : z;
}
}
j.a(a.at, "need update?" + z);
if (a.this.aC == null || a.this.aC.q || !z) {
a.this.aG.sendEmptyMessage(11);
} else {
a.this.aG.sendEmptyMessage(12);
}
}
}).start();
return true;
} catch (Throwable th) {
if (0 != 0) {
throw th;
}
j.a(at, "No such app which packageName is " + this.aB.h);
return false;
}
}
public void R() {
a.C0042a a2;
if (this.aB == null || (a2 = com.cvte.tv.appstore.modules.download.c.a.a(this.aA)) == null) {
return;
}
final String a3 = a2.a();
j.a(at, "onQueryFile,file path:" + a3);
if (a3 != null) {
File file = new File(a3);
if (file.exists()) {
if (!AppInfoUtil.hasApplication(b(), this.aB.h)) {
if (com.cvte.tv.appstore.modules.download.c.b.a(this.aB.d)) {
this.aH = 6;
return;
}
this.aH = 7;
b(this.aH);
this.ak.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
a.this.aH = 4;
a.this.b(a.this.aH);
a.this.c(a3);
}
});
j.a(at, "onQueryFile,local not installed this app,set PREPARE_INSTALL");
return;
}
com.cvte.tv.appstore.d.a installedApp = AppInfoUtil.getInstalledApp(b(), this.aB.h);
if (installedApp != null) {
if (a2.b() > installedApp.g()) {
this.aH = 7;
b(this.aH);
this.ak.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
a.this.aH = 4;
a.this.b(a.this.aH);
a.this.c(a3);
}
});
j.a(at, "onQueryFile,local app version is older,set PREPARE_INSTALL");
return;
}
try {
file.delete();
} catch (Exception e) {
e.printStackTrace();
}
com.cvte.tv.appstore.modules.download.c.a.b(this.aB.d);
j.a(at, "onQueryFile,local app version is newer,delete apk");
}
}
}
}
public void S() {
this.aD = new com.cvte.tv.appstore.modules.download.b.a();
this.aD.a(this.aB.d);
this.aD.a(this.aB.l);
this.aD.b(this.aB.g + av);
this.aD.c(this.aB.h);
this.aD.b(0);
this.aD.c(0);
this.aD.d(this.aB.o);
j.a(at, "Got a FileInfo:" + this.aD.toString());
}
public boolean T() {
if (this.aB == null) {
return false;
}
boolean a2 = com.cvte.tv.appstore.modules.download.c.b.a(this.aB.d);
j.a(at, "onQueryDownloadTask,isContain" + a2);
return a2;
}
public void U() {
j.a(at, "startDownload");
if (this.aD == null) {
return;
}
Intent intent = new Intent(b(), (Class<?>) DownloadService.class);
intent.setAction("ACTION_START");
intent.putExtra("fileInfo", this.aD);
b().startService(intent);
b(6);
}
private void a(int i, int i2) {
if (this.aD == null) {
return;
}
j.a("download", "restart the download task");
Intent intent = new Intent(b(), (Class<?>) DownloadService.class);
intent.setAction("ACTION_RESTART");
intent.putExtra("current_id", i);
intent.putExtra("progress", i2);
b().startService(intent);
}
private void a(View view) {
this.ah = (TextView) view.findViewById(R.id.app_size);
this.ac = (TextView) view.findViewById(R.id.title);
this.aj = (TextView) view.findViewById(R.id.detail);
this.aa = (LinearLayout) view.findViewById(R.id.root);
this.ai = (TextView) view.findViewById(R.id.version);
this.ak = (TextView) view.findViewById(R.id.download);
this.ab = (ImageView) view.findViewById(R.id.app_icon);
this.ae = (TextView) view.findViewById(R.id.extra_info1);
this.af = (TextView) view.findViewById(R.id.extra_info2);
this.ag = (TextView) view.findViewById(R.id.update_date);
this.ad = (TextView) view.findViewById(R.id.environment);
this.al = (AppStoreProgressWrapper) view.findViewById(R.id.progress);
this.am = (RelativeLayout) view.findViewById(R.id.top_container);
this.an = (RecyclerView) view.findViewById(R.id.bottom_container);
this.ao = new ImagePreviewPopup(b());
this.am.setOnFocusChangeListener(this);
this.an.setOnFocusChangeListener(this);
this.ak.setOnFocusChangeListener(this);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(b());
linearLayoutManager.b(0);
this.an.setLayoutManager(linearLayoutManager);
}
public void a(com.cvte.tv.appstore.d.a.a aVar) {
j.a(at, "app icon url:" + aw + aVar.m);
t.a(AppStoreApplication.a()).a(aVar.m).a(R.drawable.icon_no_network05).b(R.drawable.icon_no_network05).a(this.ab);
this.ac.setText(aVar.g);
this.ai.setText(aVar.i);
this.ag.setText(aVar.j);
this.ah.setText(String.format("%.2f", Double.valueOf((aVar.e / 1024.0d) / 1024.0d)) + "MB");
this.aj.setText(a(R.string.introduction) + aVar.f);
}
public void b(int i) {
j.a(at, "appDetailFragment set status:" + i);
this.aH = i;
switch (i) {
case 0:
this.ak.setVisibility(0);
this.al.setVisibility(4);
this.ak.requestFocus();
this.ak.setText(a(R.string.download));
this.ak.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
return;
case 1:
this.ak.setVisibility(0);
this.ak.setText(a(R.string.download));
this.al.setVisibility(4);
this.ak.requestFocus();
this.ak.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
a.this.U();
}
});
return;
case 2:
this.ak.setVisibility(0);
this.al.setVisibility(4);
this.ak.requestFocus();
this.ak.setCompoundDrawablesWithIntrinsicBounds(R.drawable.app_detail_icon_update, 0, 0, 0);
this.ak.setText(d().getString(R.string.update_now));
this.al.setText(d().getString(R.string.updating));
return;
case 3:
this.al.setVisibility(0);
this.ak.setVisibility(4);
this.al.setText(d().getString(R.string.downloading));
this.al.requestFocus();
return;
case 4:
this.al.invalidate();
this.al.setProgress(100);
this.ak.setVisibility(8);
this.al.setVisibility(0);
this.al.requestFocus();
this.al.setText(d().getString(R.string.installing));
return;
case 5:
this.ak.setVisibility(0);
this.al.setVisibility(4);
this.ak.requestFocus();
this.ak.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
this.ak.setText(d().getString(R.string.open));
this.ak.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (a.this.aB == null || a.this.aB.h == null) {
return;
}
PackageManager packageManager = a.this.b().getPackageManager();
if (com.cvte.tv.appstore.utils.g.b(packageManager, a.this.aB.h)) {
Intent launchIntentForPackage = packageManager.getLaunchIntentForPackage(a.this.aB.h);
launchIntentForPackage.setFlags(268435456);
a.this.b().startActivity(launchIntentForPackage);
}
}
});
return;
case 6:
this.ak.setVisibility(8);
this.al.setText(d().getString(R.string.waitting));
this.al.setProgress(0);
this.al.setVisibility(0);
this.al.requestFocus();
a(0, 0);
return;
case 7:
this.al.invalidate();
this.al.setProgress(100);
this.ak.setVisibility(0);
this.ak.setText(d().getString(R.string.cilck_to_install));
this.al.setVisibility(4);
this.al.setText(d().getString(R.string.installing));
return;
default:
return;
}
}
public void b(com.cvte.tv.appstore.d.a.a aVar) {
j.a(at, "screenshots:" + aVar.p.toString());
ArrayList arrayList = new ArrayList();
this.aE = new ArrayList();
for (a.C0041a c0041a : aVar.p) {
arrayList.add(c0041a.b);
this.aE.add(c0041a.f658a);
}
com.cvte.tv.appstore.widget.b bVar = new com.cvte.tv.appstore.widget.b(AppStoreApplication.a(), arrayList);
bVar.a(new b.a() {
@Override
public void a(View view, int i) {
j.a("rf_click", "position:" + i);
a.this.ao.showAtLocation(a.this.aa, 17, 0, 0);
a.this.ao.a(i);
}
});
this.an.setAdapter(bVar);
this.ao.a(this.aE);
}
public void b(String str) {
Toast.makeText(b(), str, 0).show();
}
public void b(boolean z) {
j.a(at, "setInitStateReady:" + z);
this.aF = z;
this.ak.setEnabled(this.aF);
}
public void c(String str) {
if (this.aD == null) {
return;
}
j.a("download", "startInstall apk path:" + DownloadService.f681a + this.aD.c());
File file = new File(str);
if (file == null || !file.exists() || this.aB.o == null || !this.aB.o.equals(com.cvte.tv.appstore.utils.e.a(file))) {
j.a(at, String.format(a(R.string.app_download_error), this.aB.g));
b(1);
Toast.makeText(b(), String.format(a(R.string.app_download_error), this.aB.g), 0).show();
}
com.cvte.tv.appstore.utils.g.a(b(), str);
}
public void c(boolean z) {
if (!z) {
if (this.ar != null) {
this.ar.dismiss();
}
} else if (this.ar == null || !this.ar.isShowing()) {
j.a("download", "create a new dialog");
AlertDialog.Builder builder = new AlertDialog.Builder(this.aq);
builder.setView(c().getLayoutInflater().inflate(R.layout.dialog_net_error, (ViewGroup) null));
this.ar = builder.create();
j.a("download", "got dialog end");
this.ar.show();
}
}
public void K() {
b(false);
this.ab.setImageResource(R.drawable.icon_no_network05);
this.ac.setText(R.string.loading);
this.ai.setText("");
this.ag.setText("");
this.ah.setText("");
this.aj.setText("");
this.an.setAdapter(null);
this.ao.dismiss();
b(0);
}
public void L() {
Uri data = c().getIntent().getData();
if (data != null) {
try {
this.aA = Integer.parseInt(data.getQueryParameter("appid"));
j.a(at, "appid" + this.aA);
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void M() {
if (this.aA == 0) {
return;
}
this.aH = 1;
b(false);
b(this.aH);
this.ap = (AppStoreApiImpl) com.cvte.tv.appstore.modules.webclient.c.a().b(AppStoreApiImpl.class);
new Thread(new Runnable() {
@Override
public void run() {
j.a(a.at, "start init data");
com.cvte.tv.appstore.d.b.b a2 = com.cvte.tv.appstore.d.b.b.a();
String str = Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getCountry();
j.a(a.at, "locale :" + str);
JsonObject software = a.this.ap.getSoftware(str, a.this.aA + "");
j.a(a.at, "json object:" + software);
if (software != null) {
a.this.aB = (com.cvte.tv.appstore.d.a.a) a2.a(software, com.cvte.tv.appstore.d.a.a.class);
if (a.this.aB != null && !a.this.aB.q) {
a.this.aG.sendEmptyMessage(10);
}
} else {
a.this.aG.sendEmptyMessage(13);
}
j.a(a.at, "end init data");
}
}).start();
}
@Override
public View a(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
View inflate = layoutInflater.inflate(R.layout.fragment_app_detail, viewGroup, false);
a(inflate);
O();
j.a(at, "fragment onCreate");
this.aq = c();
this.aH = 1;
return inflate;
}
@Override
public void a(Iterator<NetWorkReceiver.a> it, boolean z) {
j.a("download", "is available" + z);
if (z) {
c(false);
if (this.aH == 6 && this.as == 102) {
a(0, 0);
}
}
}
@Override
public boolean a(KeyEvent keyEvent) {
j.a(at, "keycode" + keyEvent.getKeyCode());
if (!this.an.hasFocus() && (keyEvent.getKeyCode() == 21 || keyEvent.getKeyCode() == 22)) {
return true;
}
j.a("rf_key", "popup is showing?" + this.ao.isShowing());
if (this.ao.isShowing()) {
return this.ao.a(keyEvent);
}
if (keyEvent.getAction() != 0 || keyEvent.getKeyCode() != 4) {
return false;
}
j.a(at, "KEYCODE_BACK");
c().finish();
return true;
}
@Override
public void k() {
super.k();
j.a(at, "onStart");
j.a(at, "fragment onStart");
L();
M();
}
@Override
public void l() {
super.l();
j.a(at, "onResume");
j.a(at, "fragment onResume");
if (this.aH == 4) {
R();
b(this.aH);
}
NetWorkReceiver.a(this);
j.a(at, "popup is showing?" + this.ao.isShowing());
if (this.ao.isShowing()) {
this.ao.a();
}
}
@Override
public void m() {
super.m();
this.as = 100;
NetWorkReceiver.b(this);
this.ao.dismiss();
j.a(at, "fragment onPause");
}
@Override
public void n() {
super.n();
j.a(at, "fragment onStop");
b(false);
}
@Override
public void onFocusChange(View view, boolean z) {
j.a(at, "On focus change" + view.getClass().getName());
if (view != this.am) {
if (view == this.an && z && this.an.getChildCount() > 0) {
this.an.getChildAt(0).requestFocus();
return;
}
return;
}
if (z) {
j.a(at, "download focus " + this.ak.isFocused());
if (this.ak.getVisibility() == 0) {
this.ak.requestFocus();
} else if (this.al.getVisibility() == 0) {
this.al.requestFocus();
}
}
}
@Override
public void p() {
super.p();
P();
this.aH = 1;
this.as = 100;
j.a(at, "fragment onDestroy");
}
}