智慧考勤 v1.0.28版本的 MD5 值为:12729d810518c958a6eb8d5a86a946dd
以下内容为反编译后的 GeneralAppVersionCheck.java 源代码,内容仅作参考
package net.itgoo.component.general.vendor.version;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.widget.ImageView;
import android.widget.Toast;
import androidx.fragment.app.FragmentActivity;
import com.meizu.cloud.pushsdk.constants.PushConstants;
import com.qiangxi.checkupdatelibrary.CheckUpdateOption;
import com.qiangxi.checkupdatelibrary.Q;
import com.qiangxi.checkupdatelibrary.callback.DownloadCallback;
import com.qiangxi.checkupdatelibrary.callback.StringCallback;
import com.qiangxi.checkupdatelibrary.imageloader.ImageLoader;
import java.io.File;
import net.itgoo.component.general.R;
import net.itgoo.component.view.widget.activity.ActivityStackUtils;
import org.json.JSONObject;
public class GeneralAppVersionCheck implements StringCallback, DownloadCallback, ImageLoader {
private static final String CHECK_VERSION_URL = "http://www.tssx.site/app/android/android_update.json";
private static final String TAG = "net.itgoo.component.general.vendor.version.GeneralAppVersionCheck";
private static GeneralAppVersionCheck instance;
private Context mContext;
private boolean mShowNoVersionTip = false;
@Override
public void checkUpdateFailure(Throwable t) {
}
@Override
public void checkUpdateFinish() {
}
@Override
public void checkUpdateStart() {
}
@Override
public void downloadProgress(long currentLength, long totalLength) {
}
@Override
public void downloadSuccess(File apk) {
}
@Override
public void loadImage(ImageView view, String imageUrl) {
}
public static synchronized GeneralAppVersionCheck getInstance() {
GeneralAppVersionCheck generalAppVersionCheck;
synchronized (GeneralAppVersionCheck.class) {
if (instance == null) {
instance = new GeneralAppVersionCheck();
}
generalAppVersionCheck = instance;
}
return generalAppVersionCheck;
}
public void checkVersion(Context context, final boolean showNoVersionTip) {
this.mContext = context;
this.mShowNoVersionTip = showNoVersionTip;
Q.get(CHECK_VERSION_URL, null).callback(this).execute();
}
private int getVersionCode(Context context) {
try {
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return -1;
}
}
public int getAppIconId(Context context) {
try {
return context.getPackageManager().getApplicationInfo(context.getPackageName(), 0).icon;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return 0;
}
}
@Override
public void checkUpdateSuccess(String json) {
CheckUpdateOption checkUpdateOption;
try {
JSONObject jSONObject = new JSONObject(json);
CheckUpdateOption.Builder appName = new CheckUpdateOption.Builder().setAppName(jSONObject.getString("name"));
CheckUpdateOption.Builder filePath = appName.setFileName(jSONObject.getString("name") + jSONObject.getString("version") + ".apk").setFilePath(this.mContext.getExternalCacheDir().getAbsolutePath());
boolean z = true;
if (jSONObject.getInt("force") != 1) {
z = false;
}
checkUpdateOption = filePath.setIsForceUpdate(z).setNewAppSize((float) jSONObject.getDouble("size")).setNewAppUpdateDesc(jSONObject.getString("content")).setNewAppUrl(jSONObject.getString(PushConstants.WEB_URL)).setNewAppVersionName(jSONObject.getString("version")).setNewAppVersionCode(jSONObject.getInt("code")).setNotificationSuccessContent(this.mContext.getString(R.string.general_check_version_download_success)).setNotificationFailureContent(this.mContext.getString(R.string.general_check_version_download_failure)).setNotificationIconResId(getAppIconId(this.mContext)).setNewAppReleaseTime(jSONObject.getString("time")).build();
} catch (Exception e) {
e.printStackTrace();
checkUpdateOption = null;
}
if (checkUpdateOption != null) {
if (checkUpdateOption.getNewAppVersionCode() > getVersionCode(this.mContext)) {
Activity topActivity = ActivityStackUtils.INSTANCE.getTopActivity();
if (topActivity instanceof FragmentActivity) {
Q.show((FragmentActivity) topActivity, checkUpdateOption, this);
}
} else if (this.mShowNoVersionTip) {
Toast.makeText(this.mContext, R.string.general_version_software_is_last_version, 0).show();
}
}
}
}