Replace switches with too few cases with ifs
This commit is contained in:
parent
634322af33
commit
df8a083ec7
|
@ -61,11 +61,8 @@ public final class ResponseList$$JsonObjectMapper<T> extends JsonMapper<Response
|
|||
|
||||
@Override
|
||||
public void parseField(ResponseList<T> instance, String fieldName, JsonParser jsonParser) throws IOException {
|
||||
switch (fieldName) {
|
||||
case "results": {
|
||||
if ("results".equals(fieldName)) {
|
||||
instance.addAll(m84ClassJsonMapper.parseList(jsonParser));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,11 +35,9 @@ import java.io.IOException;
|
|||
public abstract class ConversationExtras implements Parcelable {
|
||||
public static ConversationExtras parse(@NonNull final String extrasType, @Nullable final String json) throws IOException {
|
||||
if (json == null) return null;
|
||||
switch (extrasType) {
|
||||
case ExtrasType.TWITTER_OFFICIAL: {
|
||||
if (ExtrasType.TWITTER_OFFICIAL.equals(extrasType)) {
|
||||
return LoganSquare.parse(json, TwitterOfficialConversationExtras.class);
|
||||
}
|
||||
}
|
||||
return LoganSquare.parse(json, DefaultConversationExtras.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,12 +66,9 @@ public final class DataExportImportTypeSelectorDialogFragment extends BaseDialog
|
|||
|
||||
@Override
|
||||
public final void onClick(final DialogInterface dialog, final int which) {
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_POSITIVE: {
|
||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||
final int flags = getCheckedFlags();
|
||||
onPositiveButtonClicked(flags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,13 +66,11 @@ public class KeyboardShortcutsFragment extends BasePreferenceFragment implements
|
|||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.reset: {
|
||||
if (item.getItemId() == R.id.reset) {
|
||||
final DialogFragment f = new ResetKeyboardShortcutConfirmDialogFragment();
|
||||
f.show(getFragmentManager(), "reset_keyboard_shortcut_confirm");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
@ -132,11 +130,8 @@ public class KeyboardShortcutsFragment extends BasePreferenceFragment implements
|
|||
implements OnClickListener {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_POSITIVE: {
|
||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||
keyboardShortcutsHandler.reset();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -112,14 +112,12 @@ public class RecyclerViewNavigationHelper implements KeyboardShortcutCallback {
|
|||
public boolean handleKeyboardShortcutSingle(@NonNull KeyboardShortcutsHandler handler, int keyCode, @NonNull KeyEvent event, int metaState) {
|
||||
final String action = handler.getKeyAction(CONTEXT_TAG_NAVIGATION, keyCode, event, metaState);
|
||||
if (action == null) return false;
|
||||
switch (action) {
|
||||
case ACTION_NAVIGATION_TOP: {
|
||||
if (ACTION_NAVIGATION_TOP.equals(action)) {
|
||||
if (iface != null) {
|
||||
iface.scrollToStart();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,12 +15,7 @@ public class ImgurProvider implements Provider {
|
|||
public boolean supports(@NonNull String link) {
|
||||
final String authority = UriUtils.getAuthority(link);
|
||||
if (authority == null) return false;
|
||||
switch (authority) {
|
||||
case "i.imgur.com":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return "i.imgur.com".equals(authority);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -28,14 +23,12 @@ public class ImgurProvider implements Provider {
|
|||
public ParcelableMedia from(@NonNull String url) {
|
||||
final String authority = UriUtils.getAuthority(url);
|
||||
if (authority == null) return null;
|
||||
switch (authority) {
|
||||
case "i.imgur.com": {
|
||||
if ("i.imgur.com".equals(authority)) {
|
||||
final String path = UriUtils.getPath(url);
|
||||
if (path == null) return null;
|
||||
ParcelableMedia media = new ParcelableMedia();
|
||||
media.url = url;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue