Simplify some ifs

Sometimes joining them, removing unnecessary checks and removing
unnecessary levels of indentation.
This commit is contained in:
Daniel Martí 2016-01-03 19:08:52 +01:00
parent 8e193cecff
commit ea3c95832e
3 changed files with 19 additions and 22 deletions

View File

@ -185,8 +185,7 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
return getString(R.string.app_not_installed);
}
// Definitely installed this version.
if (app.installedSig != null && apk.sig != null
&& apk.sig.equals(app.installedSig)) {
if (apk.sig != null && apk.sig.equals(app.installedSig)) {
return getString(R.string.app_installed);
}
// Installed the same version, but from someplace else.
@ -561,11 +560,9 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
@Override
protected void onDestroy() {
if (downloadHandler != null) {
if (!inProcessOfChangingConfiguration) {
downloadHandler.cancel(false);
cleanUpFinishedDownload();
}
if (downloadHandler != null && !inProcessOfChangingConfiguration) {
downloadHandler.cancel(false);
cleanUpFinishedDownload();
}
inProcessOfChangingConfiguration = false;
super.onDestroy();
@ -1600,12 +1597,10 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
public void onClick(View v) {
App app = getApp();
AppDetails activity = (AppDetails) getActivity();
if (updateWanted) {
if (app.suggestedVercode > 0) {
final Apk apkToInstall = ApkProvider.Helper.find(activity, app.packageName, app.suggestedVercode);
activity.install(apkToInstall);
return;
}
if (updateWanted && app.suggestedVercode > 0) {
Apk apkToInstall = ApkProvider.Helper.find(activity, app.packageName, app.suggestedVercode);
activity.install(apkToInstall);
return;
}
if (installed) {
// If installed

View File

@ -29,10 +29,9 @@ public class AppFilter {
return false;
}
if (!Preferences.get().filterAppsRequiringRoot()) {
if (app.requirements.contains("root")) {
return true;
}
if (!Preferences.get().filterAppsRequiringRoot() &&
app.requirements.contains("root")) {
return true;
}
return false;

View File

@ -662,11 +662,14 @@ public final class Utils {
}
for (File f : files) {
if ((startsWith != null && f.getName().startsWith(startsWith))
|| (endsWith != null && f.getName().endsWith(endsWith))) {
if (!f.delete()) {
Log.w(TAG, "Couldn't delete cache file " + f);
}
if (startsWith != null && f.getName().startsWith(startsWith)) {
continue;
}
if (endsWith != null && f.getName().endsWith(endsWith)) {
continue;
}
if (!f.delete()) {
Log.w(TAG, "Couldn't delete cache file " + f);
}
}
}