Simplify a few elses
Mostly just dropping them after returns.
This commit is contained in:
parent
603a5b25e4
commit
8d4e785185
@ -150,11 +150,10 @@ public class PrivilegedInstaller extends Installer {
|
||||
}
|
||||
|
||||
boolean hasPermissions = returnBundle.getBoolean("has_permissions", false);
|
||||
if (hasPermissions) {
|
||||
return IS_EXTENSION_INSTALLED_YES;
|
||||
} else {
|
||||
if (!hasPermissions) {
|
||||
return IS_EXTENSION_INSTALLED_PERMISSIONS_PROBLEM;
|
||||
}
|
||||
return IS_EXTENSION_INSTALLED_YES;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,13 +34,12 @@ public final class BluetoothSwap extends SwapType {
|
||||
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (adapter == null) {
|
||||
return new NoBluetoothType(context);
|
||||
} else {
|
||||
}
|
||||
if (mInstance == null)
|
||||
mInstance = new BluetoothSwap(context, adapter);
|
||||
|
||||
return mInstance;
|
||||
}
|
||||
}
|
||||
|
||||
private BluetoothSwap(@NonNull Context context, @NonNull BluetoothAdapter adapter) {
|
||||
super(context);
|
||||
|
@ -345,9 +345,8 @@ public class AsyncDownloaderFromAndroid implements AsyncDownloader {
|
||||
|
||||
if (status == DownloadManager.STATUS_SUCCESSFUL) {
|
||||
return 0; // Download is valid, celebrate
|
||||
} else {
|
||||
return c.getInt(c.getColumnIndex(DownloadManager.COLUMN_REASON));
|
||||
}
|
||||
return c.getInt(c.getColumnIndex(DownloadManager.COLUMN_REASON));
|
||||
}
|
||||
} finally {
|
||||
c.close();
|
||||
|
@ -41,11 +41,11 @@ public class DownloaderFactory {
|
||||
if (isBluetoothAddress(url)) {
|
||||
String macAddress = url.getHost().replace("-", ":");
|
||||
return new BluetoothDownloader(context, macAddress, url, destFile);
|
||||
} else if (isOnionAddress(url)) {
|
||||
return new TorHttpDownloader(context, url, destFile);
|
||||
} else {
|
||||
return new HttpDownloader(context, url, destFile);
|
||||
}
|
||||
if (isOnionAddress(url)) {
|
||||
return new TorHttpDownloader(context, url, destFile);
|
||||
}
|
||||
return new HttpDownloader(context, url, destFile);
|
||||
}
|
||||
|
||||
private static boolean isBluetoothAddress(URL url) {
|
||||
@ -60,9 +60,8 @@ public class DownloaderFactory {
|
||||
throws IOException {
|
||||
if (canUseDownloadManager(url)) {
|
||||
return new AsyncDownloaderFromAndroid(context, listener, title, id, url.toString(), destFile);
|
||||
} else {
|
||||
return new AsyncDownloadWrapper(create(context, url, destFile), listener);
|
||||
}
|
||||
return new AsyncDownloadWrapper(create(context, url, destFile), listener);
|
||||
}
|
||||
|
||||
static boolean isOnionAddress(URL url) {
|
||||
|
@ -221,14 +221,13 @@ public class WifiStateChangeService extends Service {
|
||||
private String formatIpAddress(int ipAddress) {
|
||||
if (ipAddress == 0) {
|
||||
return null;
|
||||
} else {
|
||||
}
|
||||
return String.format(Locale.ENGLISH, "%d.%d.%d.%d",
|
||||
ipAddress & 0xff,
|
||||
ipAddress >> 8 & 0xff,
|
||||
ipAddress >> 16 & 0xff,
|
||||
ipAddress >> 24 & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
private String printWifiState(int wifiState) {
|
||||
switch (wifiState) {
|
||||
|
@ -234,14 +234,12 @@ public class BluetoothServer extends Thread {
|
||||
if (f.canRead()) {
|
||||
// No index file, list the directory if it is readable
|
||||
return createResponse(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_HTML, "");
|
||||
} else {
|
||||
}
|
||||
return createResponse(NanoHTTPD.Response.Status.FORBIDDEN, NanoHTTPD.MIME_PLAINTEXT,
|
||||
"FORBIDDEN: No directory listing.");
|
||||
}
|
||||
} else {
|
||||
return respond(headers, uri + indexFile);
|
||||
}
|
||||
}
|
||||
|
||||
Response response = serveFile(uri, headers, f, getMimeTypeForFile(uri));
|
||||
return response != null ? response :
|
||||
|
@ -75,13 +75,11 @@ public final class Request {
|
||||
if (method.equals(Methods.HEAD)) {
|
||||
Utils.debugLog(TAG, "Request was a " + Methods.HEAD + " request, not including anything other than headers and status...");
|
||||
return new Response(responseCode, headers);
|
||||
} else {
|
||||
}
|
||||
Utils.debugLog(TAG, "Request was a " + Methods.GET + " request, so including content stream in response...");
|
||||
return new Response(responseCode, headers, connection.getInputStream());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function used by listenForRequest().
|
||||
* The reason it is here is because the listenForRequest() is a static function, which would
|
||||
|
@ -49,11 +49,11 @@ abstract class InstallExtension {
|
||||
public static InstallExtension create(final Context context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
return new LollipopImpl(context);
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
return new KitKatToLollipopImpl(context);
|
||||
} else {
|
||||
return new PreKitKatImpl(context);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
return new KitKatToLollipopImpl(context);
|
||||
}
|
||||
return new PreKitKatImpl(context);
|
||||
}
|
||||
|
||||
final void runInstall(String apkPath) {
|
||||
|
@ -101,7 +101,7 @@ public class AppSecurityPermissions {
|
||||
if (icon != 0) {
|
||||
// return loadUnbadgedIcon(pm);
|
||||
return loadIcon(pm);
|
||||
} else {
|
||||
}
|
||||
ApplicationInfo appInfo;
|
||||
try {
|
||||
appInfo = pm.getApplicationInfo(packageName, 0);
|
||||
@ -110,7 +110,6 @@ public class AppSecurityPermissions {
|
||||
} catch (NameNotFoundException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -28,14 +28,13 @@ public abstract class ThemeableListFragment extends ListFragment {
|
||||
private View headerView;
|
||||
|
||||
private View getHeaderView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (getHeaderLayout() > 0) {
|
||||
if (getHeaderLayout() == 0) {
|
||||
return null;
|
||||
}
|
||||
if (headerView == null) {
|
||||
headerView = inflater.inflate(getHeaderLayout(), null, false);
|
||||
}
|
||||
return headerView;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private LayoutInflater getThemedInflater(Context context) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user