Java 8 migration aid
This commit is contained in:
parent
67b0af9cb4
commit
5bc9d6770e
|
@ -20,7 +20,6 @@ package org.mariotaku.twidere.model;
|
|||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.LongDef;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -52,13 +51,7 @@ import java.util.Comparator;
|
|||
@ParcelablePlease
|
||||
public class ParcelableStatus implements Parcelable, Comparable<ParcelableStatus>, Cloneable {
|
||||
|
||||
public static final Comparator<ParcelableStatus> REVERSE_COMPARATOR = new Comparator<ParcelableStatus>() {
|
||||
|
||||
@Override
|
||||
public int compare(final ParcelableStatus object1, final ParcelableStatus object2) {
|
||||
return object2.compareTo(object1);
|
||||
}
|
||||
};
|
||||
public static final Comparator<ParcelableStatus> REVERSE_COMPARATOR = (object1, object2) -> object2.compareTo(object1);
|
||||
public static final Creator<ParcelableStatus> CREATOR = new Creator<ParcelableStatus>() {
|
||||
@Override
|
||||
public ParcelableStatus createFromParcel(Parcel source) {
|
||||
|
|
|
@ -84,12 +84,9 @@ public class ExtendedDividerItemDecoration extends RecyclerView.ItemDecoration {
|
|||
}
|
||||
|
||||
public void setPadding(final int left, final int top, final int right, final int bottom) {
|
||||
mPadding = new Padding() {
|
||||
@Override
|
||||
public boolean get(int position, Rect rect) {
|
||||
mPadding = (position, rect) -> {
|
||||
rect.set(left, top, right, bottom);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -118,14 +118,11 @@ public class FileSelectorDialogFragment extends BaseDialogFragment implements Lo
|
|||
builder.setPositiveButton(android.R.string.ok, this);
|
||||
}
|
||||
final AlertDialog dialog = builder.create();
|
||||
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
@Override
|
||||
public void onShow(final DialogInterface dialog) {
|
||||
final AlertDialog alertDialog = (AlertDialog) dialog;
|
||||
dialog.setOnShowListener(dialog1 -> {
|
||||
final AlertDialog alertDialog = (AlertDialog) dialog1;
|
||||
DialogExtensionsKt.applyTheme(alertDialog);
|
||||
final ListView listView = alertDialog.getListView();
|
||||
listView.setOnItemClickListener(FileSelectorDialogFragment.this);
|
||||
}
|
||||
});
|
||||
return dialog;
|
||||
}
|
||||
|
@ -268,12 +265,9 @@ public class FileSelectorDialogFragment extends BaseDialogFragment implements Lo
|
|||
private final String[] extensions;
|
||||
private final Pattern extensions_regex;
|
||||
|
||||
private static final Comparator<File> NAME_COMPARATOR = new Comparator<File>() {
|
||||
@Override
|
||||
public int compare(final File file1, final File file2) {
|
||||
private static final Comparator<File> NAME_COMPARATOR = (file1, file2) -> {
|
||||
final Locale loc = Locale.getDefault();
|
||||
return file1.getName().toLowerCase(loc).compareTo(file2.getName().toLowerCase(loc));
|
||||
}
|
||||
};
|
||||
|
||||
public FilesLoader(final Context context, final File path, final String[] extensions) {
|
||||
|
|
|
@ -24,7 +24,6 @@ import android.content.Context;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -88,12 +87,7 @@ public class KeyboardShortcutsFragment extends BasePreferenceFragment implements
|
|||
mAction = action;
|
||||
setPersistent(false);
|
||||
setTitle(KeyboardShortcutsHandler.getActionLabel(context, action));
|
||||
mPreferencesChangeListener = new OnSharedPreferenceChangeListener() {
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
||||
updateSummary();
|
||||
}
|
||||
};
|
||||
mPreferencesChangeListener = (preferences, key) -> updateSummary();
|
||||
updateSummary();
|
||||
}
|
||||
|
||||
|
@ -143,12 +137,7 @@ public class KeyboardShortcutsFragment extends BasePreferenceFragment implements
|
|||
builder.setPositiveButton(android.R.string.ok, this);
|
||||
builder.setNegativeButton(android.R.string.cancel, this);
|
||||
final AlertDialog dialog = builder.create();
|
||||
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
@Override
|
||||
public void onShow(final DialogInterface dialog) {
|
||||
DialogExtensionsKt.applyTheme((AlertDialog) dialog);
|
||||
}
|
||||
});
|
||||
dialog.setOnShowListener(dialog1 -> DialogExtensionsKt.applyTheme((AlertDialog) dialog1));
|
||||
return dialog;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,8 +47,7 @@ public class ThemedListPreferenceDialogFragmentCompat extends ThemedPreferenceDi
|
|||
}
|
||||
mClickedDialogEntryIndex = preference.findIndexOfValue(preference.getValue());
|
||||
builder.setSingleChoiceItems(entries, mClickedDialogEntryIndex,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
(dialog, which) -> {
|
||||
mClickedDialogEntryIndex = which;
|
||||
/*
|
||||
* Clicking on an item simulates the positive button
|
||||
|
@ -57,7 +56,6 @@ public class ThemedListPreferenceDialogFragmentCompat extends ThemedPreferenceDi
|
|||
ThemedListPreferenceDialogFragmentCompat.this.onClick(dialog,
|
||||
DialogInterface.BUTTON_POSITIVE);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
/*
|
||||
* The typical interaction for list-based dialogs is to have
|
||||
|
|
|
@ -100,12 +100,7 @@ abstract class MultiSelectListPreference extends DialogPreference implements IDi
|
|||
builder.setNegativeButton(android.R.string.cancel, null);
|
||||
builder.setMultiChoiceItems(mNames, mValues, this);
|
||||
final AlertDialog dialog = builder.create();
|
||||
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
@Override
|
||||
public void onShow(final DialogInterface dialog) {
|
||||
DialogExtensionsKt.applyTheme((AlertDialog) dialog);
|
||||
}
|
||||
});
|
||||
dialog.setOnShowListener(dialog1 -> DialogExtensionsKt.applyTheme((AlertDialog) dialog1));
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.mariotaku.twidere.preference;
|
|||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -78,19 +77,9 @@ public class SettingsImportExportPreference extends DialogPreference implements
|
|||
entries[1] = context.getString(R.string.export_settings);
|
||||
values[0] = new Intent(context, DataImportActivity.class);
|
||||
values[1] = new Intent(context, DataExportActivity.class);
|
||||
builder.setItems(entries, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
startActivity(values[which]);
|
||||
}
|
||||
});
|
||||
builder.setItems(entries, (dialog, which) -> startActivity(values[which]));
|
||||
final AlertDialog dialog = builder.create();
|
||||
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
@Override
|
||||
public void onShow(final DialogInterface dialog) {
|
||||
DialogExtensionsKt.applyTheme((AlertDialog) dialog);
|
||||
}
|
||||
});
|
||||
dialog.setOnShowListener(dialog1 -> DialogExtensionsKt.applyTheme((AlertDialog) dialog1));
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@ package org.mariotaku.twidere.preference;
|
|||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
|
@ -17,7 +15,6 @@ import android.util.AttributeSet;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
|
@ -160,20 +157,15 @@ public class ThemeBackgroundPreference extends DialogPreference implements Const
|
|||
final SharedPreferences preferences = preference.getSharedPreferences();
|
||||
preference.setValue(preference.getPersistedString(null));
|
||||
builder.setTitle(preference.getDialogTitle());
|
||||
builder.setSingleChoiceItems(preference.mBackgroundEntries, preference.getValueIndex(), new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
builder.setSingleChoiceItems(preference.mBackgroundEntries, preference.getValueIndex(), (dialog, which) -> {
|
||||
preference.setSelectedOption(which);
|
||||
updateAlphaVisibility();
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(android.R.string.ok, this);
|
||||
builder.setNegativeButton(android.R.string.cancel, this);
|
||||
final Dialog dialog = builder.create();
|
||||
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
@Override
|
||||
public void onShow(DialogInterface dialog) {
|
||||
final AlertDialog alertDialog = (AlertDialog) dialog;
|
||||
dialog.setOnShowListener(dialog1 -> {
|
||||
final AlertDialog alertDialog = (AlertDialog) dialog1;
|
||||
DialogExtensionsKt.applyTheme(alertDialog);
|
||||
if (preferences != null) {
|
||||
final LayoutInflater inflater = alertDialog.getLayoutInflater();
|
||||
|
@ -187,16 +179,12 @@ public class ThemeBackgroundPreference extends DialogPreference implements Const
|
|||
mAlphaSlider = view.findViewById(R.id.alpha_slider);
|
||||
mAlphaSlider.setMax(MAX_ALPHA - MIN_ALPHA);
|
||||
mAlphaSlider.setProgress(preferences.getInt(KEY_THEME_BACKGROUND_ALPHA, DEFAULT_THEME_BACKGROUND_ALPHA) - MIN_ALPHA);
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
listView.setOnItemClickListener((parent, view1, position, id) -> {
|
||||
preference.setSelectedOption(position);
|
||||
updateAlphaVisibility();
|
||||
}
|
||||
});
|
||||
updateAlphaVisibility();
|
||||
}
|
||||
}
|
||||
});
|
||||
return dialog;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import androidx.annotation.Nullable;
|
|||
import org.mariotaku.twidere.constant.IntentConstants;
|
||||
import org.mariotaku.twidere.util.ServiceUtils.ServiceToken;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
|
@ -73,12 +72,7 @@ public abstract class AbsServiceInterface<I extends IInterface> implements IInte
|
|||
final Intent intent = new Intent(IntentConstants.INTENT_ACTION_EXTENSION_SHORTEN_STATUS);
|
||||
final ComponentName component = ComponentName.unflattenFromString(mShortenerName);
|
||||
intent.setComponent(component);
|
||||
final FutureTask<Boolean> futureTask = new FutureTask<>(new Callable<Boolean>() {
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
return mIInterface != null;
|
||||
}
|
||||
});
|
||||
final FutureTask<Boolean> futureTask = new FutureTask<>(() -> mIInterface != null);
|
||||
mToken = ServiceUtils.bindToService(mContext, intent, new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(final ComponentName name, final IBinder obj) {
|
||||
|
@ -112,7 +106,6 @@ public abstract class AbsServiceInterface<I extends IInterface> implements IInte
|
|||
}
|
||||
|
||||
public interface CheckServiceAction {
|
||||
@SuppressWarnings("RedundantThrows")
|
||||
void check(@Nullable Bundle metaData) throws CheckServiceException;
|
||||
}
|
||||
|
||||
|
|
|
@ -391,12 +391,9 @@ public class SwipeDismissListViewTouchListener implements View.OnTouchListener {
|
|||
}
|
||||
});
|
||||
|
||||
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator valueAnimator) {
|
||||
animator.addUpdateListener(valueAnimator -> {
|
||||
lp.height = (Integer) valueAnimator.getAnimatedValue();
|
||||
dismissView.setLayoutParams(lp);
|
||||
}
|
||||
});
|
||||
|
||||
mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView));
|
||||
|
|
Loading…
Reference in New Issue