Make checking app availability after external changes a little bit safer
This commit is contained in:
parent
6345195d41
commit
37b310575a
@ -109,8 +109,8 @@ public class AppDetails2 extends AppCompatActivity
|
|||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
supportPostponeEnterTransition();
|
supportPostponeEnterTransition();
|
||||||
|
|
||||||
resetCurrentApp(getPackageNameFromIntent(getIntent()));
|
String packageName = getPackageNameFromIntent(getIntent());
|
||||||
if (app == null) {
|
if (!resetCurrentApp(packageName)) {
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -662,10 +662,12 @@ public class AppDetails2 extends AppCompatActivity
|
|||||||
* removed while F-Droid was in the background.
|
* removed while F-Droid was in the background.
|
||||||
* <p>
|
* <p>
|
||||||
* Shows a {@link Toast} if no {@link App} was found matching {@code packageName}.
|
* Shows a {@link Toast} if no {@link App} was found matching {@code packageName}.
|
||||||
|
*
|
||||||
|
* @return whether the {@link App} for a given {@code packageName} is still available
|
||||||
*/
|
*/
|
||||||
private void resetCurrentApp(String packageName) {
|
private boolean resetCurrentApp(String packageName) {
|
||||||
if (TextUtils.isEmpty(packageName)) {
|
if (TextUtils.isEmpty(packageName)) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
app = AppProvider.Helper.findHighestPriorityMetadata(getContentResolver(), packageName);
|
app = AppProvider.Helper.findHighestPriorityMetadata(getContentResolver(), packageName);
|
||||||
|
|
||||||
@ -678,15 +680,18 @@ public class AppDetails2 extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
if (app == null) {
|
if (app == null) {
|
||||||
Toast.makeText(this, R.string.no_such_app, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, R.string.no_such_app, Toast.LENGTH_LONG).show();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onAppChanged() {
|
private void onAppChanged() {
|
||||||
recyclerView.post(new Runnable() {
|
recyclerView.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
resetCurrentApp(app.packageName);
|
String packageName = app != null ? app.packageName : null;
|
||||||
if (app == null) {
|
if (!resetCurrentApp(packageName)) {
|
||||||
AppDetails2.this.finish();
|
AppDetails2.this.finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user