Simplify some bits of code
* Don't call getIntent() multiple times * Drop else after return * Don't do "if (!cond) foo else bar"
This commit is contained in:
parent
fd8355e872
commit
7cfc2ea004
@ -362,14 +362,13 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
* never happen as AppDetails is only to be called by the FDroid activity
|
||||
* and not externally.
|
||||
*/
|
||||
private String getAppIdFromIntent() {
|
||||
Intent i = getIntent();
|
||||
if (!i.hasExtra(EXTRA_APPID)) {
|
||||
private String getAppIdFromIntent(Intent intent) {
|
||||
if (!intent.hasExtra(EXTRA_APPID)) {
|
||||
Log.e(TAG, "No application ID found in the intent!");
|
||||
return null;
|
||||
}
|
||||
|
||||
return i.getStringExtra(EXTRA_APPID);
|
||||
return intent.getStringExtra(EXTRA_APPID);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -384,8 +383,9 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
// compat implementation is assigned in the ActionBarActivity base class.
|
||||
supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||
|
||||
if (getIntent().hasExtra(EXTRA_FROM)) {
|
||||
setTitle(getIntent().getStringExtra(EXTRA_FROM));
|
||||
Intent intent = getIntent();
|
||||
if (intent.hasExtra(EXTRA_FROM)) {
|
||||
setTitle(intent.getStringExtra(EXTRA_FROM));
|
||||
}
|
||||
|
||||
mPm = getPackageManager();
|
||||
@ -403,7 +403,7 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
app = previousData.app;
|
||||
setApp(app);
|
||||
} else {
|
||||
if (!reset(getAppIdFromIntent())) {
|
||||
if (!reset(getAppIdFromIntent(intent))) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
@ -288,10 +288,10 @@ public class FDroidApp extends Application {
|
||||
private BluetoothAdapter getBluetoothAdapter() {
|
||||
// to use the new, recommended way of getting the adapter
|
||||
// http://developer.android.com/reference/android/bluetooth/BluetoothAdapter.html
|
||||
if (Build.VERSION.SDK_INT < 18)
|
||||
if (Build.VERSION.SDK_INT < 18) {
|
||||
return BluetoothAdapter.getDefaultAdapter();
|
||||
else
|
||||
return ((BluetoothManager) getSystemService(BLUETOOTH_SERVICE)).getAdapter();
|
||||
}
|
||||
return ((BluetoothManager) getSystemService(BLUETOOTH_SERVICE)).getAdapter();
|
||||
}
|
||||
|
||||
public void sendViaBluetooth(Activity activity, int resultCode, String packageName) {
|
||||
@ -327,13 +327,13 @@ public class FDroidApp extends Application {
|
||||
found = false;
|
||||
}
|
||||
if (sendBt != null) {
|
||||
if (!found) {
|
||||
if (found) {
|
||||
sendBt.setClassName(bluetoothPackageName, className);
|
||||
activity.startActivity(sendBt);
|
||||
} else {
|
||||
Toast.makeText(this, R.string.bluetooth_activity_not_found,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
activity.startActivity(Intent.createChooser(sendBt, getString(R.string.choose_bt_send)));
|
||||
} else {
|
||||
sendBt.setClassName(bluetoothPackageName, className);
|
||||
activity.startActivity(sendBt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user