Make main actions more robust

This commit is contained in:
Mr. Dragon
2018-02-18 11:47:51 +05:30
parent 44c8819c67
commit ecaaeff539
6 changed files with 7 additions and 9 deletions

View File

@@ -86,7 +86,6 @@ public class DetailsDownloadReceiver extends DownloadReceiver {
buttonCancel.setVisibility(View.GONE);
}
Button buttonDownload = (Button) activityRef.get().findViewById(R.id.download);
buttonDownload.setText(R.string.details_download);
buttonDownload.setEnabled(true);
}
}

View File

@@ -38,6 +38,7 @@ public class UpdatableAppsActivity extends AppListActivity {
task.setRespectUpdateBlacklist(true);
task.setIncludeSystemApps(true);
task.execute();
loadApps();
}
@Override

View File

@@ -32,7 +32,6 @@ public class ButtonCancel extends Button {
activity.startService(intentCancel);
button.setVisibility(View.GONE);
android.widget.Button buttonDownload = (android.widget.Button) activity.findViewById(R.id.download);
buttonDownload.setText(R.string.details_download);
buttonDownload.setVisibility(View.VISIBLE);
buttonDownload.setEnabled(true);
}

View File

@@ -88,7 +88,6 @@ public class ButtonDownload extends Button {
if (Paths.getApkPath(activity, app.getPackageName(), app.getVersionCode()).exists()
&& !state.isEverythingSuccessful()
) {
disable(R.string.details_downloading);
NumberProgressBar progressBar = (NumberProgressBar) activity.findViewById(R.id.download_progress);
if (null != progressBar) {
new DownloadProgressBarUpdater(app.getPackageName(), progressBar).execute(PurchaseTask.UPDATE_INTERVAL);
@@ -147,10 +146,10 @@ public class ButtonDownload extends Button {
static class LocalPurchaseTask extends PurchaseTask {
private ButtonDownload fragment;
private ButtonDownload buttonDownload;
public LocalPurchaseTask setFragment(ButtonDownload fragment) {
this.fragment = fragment;
this.buttonDownload = fragment;
return this;
}
@@ -163,21 +162,20 @@ public class ButtonDownload extends Button {
task.setErrorView(errorView);
task.setContext(context);
task.setProgressIndicator(progressIndicator);
task.setFragment(fragment);
task.setFragment(buttonDownload);
return task;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
fragment.disable(R.string.details_downloading);
}
@Override
protected void onPostExecute(AndroidAppDeliveryData deliveryData) {
super.onPostExecute(deliveryData);
if (!success()) {
fragment.draw();
buttonDownload.draw();
if (null != getRestrictionString()) {
ContextUtil.toastLong(context, getRestrictionString());
Log.i(getClass().getSimpleName(), "No download link returned, app restriction is " + app.getRestriction());

View File

@@ -112,6 +112,7 @@
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:weightSum="3"
android:gravity="end"
android:orientation="horizontal">

View File

@@ -11,7 +11,7 @@
<string name="list_incompatible">incompatible</string>
<string name="list_check_updates">Check update</string>
<string name="list_check_updates_txt">My apps and games</string>
<string name="list_update_all">Update now</string>
<string name="list_update_all">Update All</string>
<string name="list_update_all_txt">Update(s) available</string>
<string name="list_updating">Updating…</string>
<string name="list_app_has_ads">has ads</string>