Fix some lambdas

This commit is contained in:
TacoTheDank 2020-08-27 16:56:41 -04:00 committed by Stypox
parent 6cb16be5df
commit 273c287fbf
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
9 changed files with 23 additions and 51 deletions

View File

@ -492,12 +492,8 @@ public class RouterActivity extends AppCompatActivity {
downloadDialog.setSelectedVideoStream(selectedVideoStreamIndex); downloadDialog.setSelectedVideoStream(selectedVideoStreamIndex);
downloadDialog.show(fm, "downloadDialog"); downloadDialog.show(fm, "downloadDialog");
fm.executePendingTransactions(); fm.executePendingTransactions();
downloadDialog.getDialog().setOnDismissListener(dialog -> { downloadDialog.getDialog().setOnDismissListener(dialog -> finish());
finish(); }, (@NonNull Throwable throwable) -> onError());
});
}, (@NonNull Throwable throwable) -> {
onError();
});
} }
@Override @Override

View File

@ -133,7 +133,7 @@ public abstract class BaseListInfoFragment<I extends ListInfo>
currentInfo = result; currentInfo = result;
currentNextPage = result.getNextPage(); currentNextPage = result.getNextPage();
handleResult(result); handleResult(result);
}, (@NonNull Throwable throwable) -> onError(throwable)); }, this::onError);
} }
/** /**

View File

@ -271,9 +271,8 @@ public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistL
final Builder builder = new AlertDialog.Builder(activity); final Builder builder = new AlertDialog.Builder(activity);
builder.setView(dialogView) builder.setView(dialogView)
.setPositiveButton(R.string.rename_playlist, (dialog, which) -> { .setPositiveButton(R.string.rename_playlist, (dialog, which) ->
changeLocalPlaylistName(selectedItem.uid, editText.getText().toString()); changeLocalPlaylistName(selectedItem.uid, editText.getText().toString()))
})
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.setNeutralButton(R.string.delete, (dialog, which) -> { .setNeutralButton(R.string.delete, (dialog, which) -> {
showDeleteDialog(selectedItem.name, showDeleteDialog(selectedItem.name,

View File

@ -553,9 +553,8 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
.setView(dialogView) .setView(dialogView)
.setCancelable(true) .setCancelable(true)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.rename, (dialogInterface, i) -> { .setPositiveButton(R.string.rename, (dialogInterface, i) ->
changePlaylistName(nameEdit.getText().toString()); changePlaylistName(nameEdit.getText().toString()));
});
dialogBuilder.show(); dialogBuilder.show();
} }

View File

@ -216,18 +216,16 @@ public class ErrorActivity extends AppCompatActivity {
addGuruMeditation(); addGuruMeditation();
currentTimeStamp = getCurrentTimeStamp(); currentTimeStamp = getCurrentTimeStamp();
reportEmailButton.setOnClickListener((View v) -> { reportEmailButton.setOnClickListener((View v) ->
openPrivacyPolicyDialog(this, "EMAIL"); openPrivacyPolicyDialog(this, "EMAIL"));
});
copyButton.setOnClickListener((View v) -> { copyButton.setOnClickListener((View v) -> {
ShareUtils.copyToClipboard(this, buildMarkdown()); ShareUtils.copyToClipboard(this, buildMarkdown());
Toast.makeText(this, R.string.msg_copied, Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.msg_copied, Toast.LENGTH_SHORT).show();
}); });
reportGithubButton.setOnClickListener((View v) -> { reportGithubButton.setOnClickListener((View v) ->
openPrivacyPolicyDialog(this, "GITHUB"); openPrivacyPolicyDialog(this, "GITHUB"));
});
// normal bugreport // normal bugreport
@ -278,10 +276,9 @@ public class ErrorActivity extends AppCompatActivity {
.setTitle(R.string.privacy_policy_title) .setTitle(R.string.privacy_policy_title)
.setMessage(R.string.start_accept_privacy_policy) .setMessage(R.string.start_accept_privacy_policy)
.setCancelable(false) .setCancelable(false)
.setNeutralButton(R.string.read_privacy_policy, (dialog, which) -> { .setNeutralButton(R.string.read_privacy_policy, (dialog, which) ->
ShareUtils.openUrlInBrowser(context, ShareUtils.openUrlInBrowser(context,
context.getString(R.string.privacy_policy_url)); context.getString(R.string.privacy_policy_url)))
})
.setPositiveButton(R.string.accept, (dialog, which) -> { .setPositiveButton(R.string.accept, (dialog, which) -> {
if (action.equals("EMAIL")) { // send on email if (action.equals("EMAIL")) { // send on email
final Intent i = new Intent(Intent.ACTION_SENDTO) final Intent i = new Intent(Intent.ACTION_SENDTO)

View File

@ -213,9 +213,8 @@ public class PeertubeInstanceListFragment extends Fragment {
private void initButton(final View rootView) { private void initButton(final View rootView) {
final FloatingActionButton fab = rootView.findViewById(R.id.addInstanceButton); final FloatingActionButton fab = rootView.findViewById(R.id.addInstanceButton);
fab.setOnClickListener(v -> { fab.setOnClickListener(v ->
showAddItemDialog(requireContext()); showAddItemDialog(requireContext()));
});
} }
private void showAddItemDialog(final Context c) { private void showAddItemDialog(final Context c) {

View File

@ -208,12 +208,7 @@ public class SelectChannelFragment extends DialogFragment {
public void onBindViewHolder(final SelectChannelItemHolder holder, final int position) { public void onBindViewHolder(final SelectChannelItemHolder holder, final int position) {
final SubscriptionEntity entry = subscriptions.get(position); final SubscriptionEntity entry = subscriptions.get(position);
holder.titleView.setText(entry.getName()); holder.titleView.setText(entry.getName());
holder.view.setOnClickListener(new View.OnClickListener() { holder.view.setOnClickListener(view -> clickedItem(position));
@Override
public void onClick(final View view) {
clickedItem(position);
}
});
imageLoader.displayImage(entry.getAvatarUrl(), holder.thumbnailView, imageLoader.displayImage(entry.getAvatarUrl(), holder.thumbnailView,
DISPLAY_IMAGE_OPTIONS); DISPLAY_IMAGE_OPTIONS);
} }

View File

@ -162,13 +162,9 @@ public final class AnimationUtils {
.ofObject(new ArgbEvaluator(), colorStart, colorEnd); .ofObject(new ArgbEvaluator(), colorStart, colorEnd);
viewPropertyAnimator.setInterpolator(new FastOutSlowInInterpolator()); viewPropertyAnimator.setInterpolator(new FastOutSlowInInterpolator());
viewPropertyAnimator.setDuration(duration); viewPropertyAnimator.setDuration(duration);
viewPropertyAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { viewPropertyAnimator.addUpdateListener(animation ->
@Override
public void onAnimationUpdate(final ValueAnimator animation) {
ViewCompat.setBackgroundTintList(view, ViewCompat.setBackgroundTintList(view,
new ColorStateList(empty, new int[]{(int) animation.getAnimatedValue()})); new ColorStateList(empty, new int[]{(int) animation.getAnimatedValue()})));
}
});
viewPropertyAnimator.addListener(new AnimatorListenerAdapter() { viewPropertyAnimator.addListener(new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationEnd(final Animator animation) { public void onAnimationEnd(final Animator animation) {
@ -205,12 +201,8 @@ public final class AnimationUtils {
.ofObject(new ArgbEvaluator(), colorStart, colorEnd); .ofObject(new ArgbEvaluator(), colorStart, colorEnd);
viewPropertyAnimator.setInterpolator(new FastOutSlowInInterpolator()); viewPropertyAnimator.setInterpolator(new FastOutSlowInInterpolator());
viewPropertyAnimator.setDuration(duration); viewPropertyAnimator.setDuration(duration);
viewPropertyAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { viewPropertyAnimator.addUpdateListener(animation ->
@Override view.setTextColor((int) animation.getAnimatedValue()));
public void onAnimationUpdate(final ValueAnimator animation) {
view.setTextColor((int) animation.getAnimatedValue());
}
});
viewPropertyAnimator.addListener(new AnimatorListenerAdapter() { viewPropertyAnimator.addListener(new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationEnd(final Animator animation) { public void onAnimationEnd(final Animator animation) {

View File

@ -36,7 +36,6 @@ import org.schabi.newpipe.MainActivity;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
@ -254,12 +253,8 @@ public final class StateSaver {
return new SavedState(prefixFileName, file.getAbsolutePath()); return new SavedState(prefixFileName, file.getAbsolutePath());
} else { } else {
// Delete any file that contains the prefix // Delete any file that contains the prefix
final File[] files = cacheDir.listFiles(new FilenameFilter() { final File[] files = cacheDir.listFiles((dir, name) ->
@Override name.contains(prefixFileName));
public boolean accept(final File dir, final String name) {
return name.contains(prefixFileName);
}
});
for (final File fileToDelete : files) { for (final File fileToDelete : files) {
fileToDelete.delete(); fileToDelete.delete();
} }