Replace switches with too few cases with ifs

This commit is contained in:
TacoTheDank 2020-05-31 02:24:17 -04:00
parent 634322af33
commit df8a083ec7
6 changed files with 23 additions and 45 deletions

View File

@ -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": {
instance.addAll(m84ClassJsonMapper.parseList(jsonParser));
break;
}
if ("results".equals(fieldName)) {
instance.addAll(m84ClassJsonMapper.parseList(jsonParser));
}
}

View File

@ -35,10 +35,8 @@ 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: {
return LoganSquare.parse(json, TwitterOfficialConversationExtras.class);
}
if (ExtrasType.TWITTER_OFFICIAL.equals(extrasType)) {
return LoganSquare.parse(json, TwitterOfficialConversationExtras.class);
}
return LoganSquare.parse(json, DefaultConversationExtras.class);
}

View File

@ -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: {
final int flags = getCheckedFlags();
onPositiveButtonClicked(flags);
break;
}
if (which == DialogInterface.BUTTON_POSITIVE) {
final int flags = getCheckedFlags();
onPositiveButtonClicked(flags);
}
}

View File

@ -66,12 +66,10 @@ public class KeyboardShortcutsFragment extends BasePreferenceFragment implements
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.reset: {
final DialogFragment f = new ResetKeyboardShortcutConfirmDialogFragment();
f.show(getFragmentManager(), "reset_keyboard_shortcut_confirm");
return true;
}
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: {
keyboardShortcutsHandler.reset();
break;
}
if (which == DialogInterface.BUTTON_POSITIVE) {
keyboardShortcutsHandler.reset();
}
}

View File

@ -112,13 +112,11 @@ 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 (iface != null) {
iface.scrollToStart();
}
return true;
if (ACTION_NAVIGATION_TOP.equals(action)) {
if (iface != null) {
iface.scrollToStart();
}
return true;
}
return false;
}

View File

@ -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,13 +23,11 @@ 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": {
final String path = UriUtils.getPath(url);
if (path == null) return null;
ParcelableMedia media = new ParcelableMedia();
media.url = url;
}
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;
}