Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SnoopyCodeX committed Apr 24, 2020
1 parent 1791be1 commit f3a4106
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected void onCreate(Bundle savedInstanceState)
setContentView(R.layout.main);

UpdateChecker.getInstance(this)
.setUpdateLogsUrl("https://pastebin.com/raw/SFpLs0De")
.setUpdateLogsUrl("https://pastebin.com/raw/e3q1h4iQ")
.shouldAutoRun(true)
.shouldAutoInstall(true)
.setJsonReader(new MyCustomJsonReader())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ private static class TaskUpdateChecker extends AsyncTask<String, Void, NewUpdate
private static final int READ_TIMEOUT = 3000;

private ProgressDialog dlg;
private String errMsg;

@Override
protected void onPreExecute()
Expand All @@ -246,7 +247,7 @@ protected NewUpdateInfo doInBackground(String... params)
NewUpdateInfo info = null;

try {
String str_url = sanitizeUrl(params[0]);
String str_url = params[0];
URL url = new URL(str_url);

HttpURLConnection conn = (HttpURLConnection) url.openConnection();
Expand Down Expand Up @@ -274,6 +275,7 @@ protected NewUpdateInfo doInBackground(String... params)
conn.disconnect();
} catch(Exception e) {
e.printStackTrace();
errMsg += e.getMessage();
}

return info;
Expand All @@ -288,30 +290,16 @@ protected void onPostExecute(NewUpdateInfo result)
if(dlg != null)
dlg.dismiss();

if(listener != null)
if(listener != null && errMsg == null)
if(ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0).versionCode < result.app_version)
listener.onUpdateDetected(result, autoInstall);
else
Toast.makeText(ctx, errMsg, Toast.LENGTH_LONG).show();
} catch(Exception e) {
e.printStackTrace();
Toast.makeText(ctx, e.getMessage(), Toast.LENGTH_LONG).show();
}
}

private String sanitizeUrl(String url)
{
String sanitized = url;

if(url.contains("//"))
{
String[] params = url.split("//");
if(!params[0].equals("http:") || !params[0].equals("https:"))
sanitized = "https://" + url;
}
else
sanitized = "https://" + url;

return sanitized;
}
}

private static final class TaskDownloadUpdate extends AsyncTask<String, Void, File>
Expand Down

0 comments on commit f3a4106

Please sign in to comment.