PR cleanup #1164

Merged
akinwale merged 32 commits from pr-1118 into master 2021-03-08 20:15:23 +01:00
4 changed files with 38 additions and 45 deletions
Showing only changes of commit b9251c2036 - Show all commits

View file

@ -61,13 +61,17 @@ public class CreateSupportDialogFragment extends BottomSheetDialogFragment imple
private ProgressBar progressLoadingChannels; private ProgressBar progressLoadingChannels;
@Setter private final CreateSupportListener listener;
private CreateSupportListener listener; private final Claim claim;
@Setter
private Claim claim;
public static CreateSupportDialogFragment newInstance() { private CreateSupportDialogFragment(Claim claim, CreateSupportListener listener) {
return new CreateSupportDialogFragment(); super();
this.claim = claim;
this.listener = listener;
}
public static CreateSupportDialogFragment newInstance(Claim claim, CreateSupportListener listener) {
return new CreateSupportDialogFragment(claim, listener);
} }
private void disableControls() { private void disableControls() {

View file

@ -57,13 +57,17 @@ public class RepostClaimDialogFragment extends BottomSheetDialogFragment impleme
private TextView linkToggleAdvanced; private TextView linkToggleAdvanced;
private View advancedContainer; private View advancedContainer;
@Setter private final RepostClaimListener listener;
private RepostClaimListener listener; private final Claim claim;
@Setter
private Claim claim;
public static RepostClaimDialogFragment newInstance() { private RepostClaimDialogFragment(Claim claim, RepostClaimListener listener) {
return new RepostClaimDialogFragment(); super();
this.listener = listener;
this.claim = claim;
}
public static RepostClaimDialogFragment newInstance(Claim claim, RepostClaimListener listener) {
return new RepostClaimDialogFragment(claim, listener);
} }
@Override @Override

View file

@ -185,19 +185,14 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
} }
if (claim != null) { if (claim != null) {
CreateSupportDialogFragment dialog = CreateSupportDialogFragment.newInstance(); CreateSupportDialogFragment dialog = CreateSupportDialogFragment.newInstance(claim, (amount, isTip) -> {
dialog.setClaim(claim); double sentAmount = amount.doubleValue();
dialog.setListener(new CreateSupportDialogFragment.CreateSupportListener() { View view1 = getView();
@Override if (view1 != null) {
public void onSupportCreated(BigDecimal amount, boolean isTip) { String message = getResources().getQuantityString(
double sentAmount = amount.doubleValue(); isTip ? R.plurals.you_sent_a_tip : R.plurals.you_sent_a_support, sentAmount == 1.0 ? 1 : 2,
View view = getView(); new DecimalFormat("#,###.##").format(sentAmount));
if (view != null) { Snackbar.make(view1, message, Snackbar.LENGTH_LONG).show();
String message = getResources().getQuantityString(
isTip ? R.plurals.you_sent_a_tip : R.plurals.you_sent_a_support, sentAmount == 1.0 ? 1 : 2,
new DecimalFormat("#,###.##").format(sentAmount));
Snackbar.make(view, message, Snackbar.LENGTH_LONG).show();
}
} }
}); });
Context context = getContext(); Context context = getContext();

View file

@ -1007,17 +1007,12 @@ public class FileViewFragment extends BaseFragment implements
} }
if (claim != null) { if (claim != null) {
CreateSupportDialogFragment dialog = CreateSupportDialogFragment.newInstance(); CreateSupportDialogFragment dialog = CreateSupportDialogFragment.newInstance(claim, (amount, isTip) -> {
dialog.setClaim(claim); double sentAmount = amount.doubleValue();
dialog.setListener(new CreateSupportDialogFragment.CreateSupportListener() { String message = getResources().getQuantityString(
@Override isTip ? R.plurals.you_sent_a_tip : R.plurals.you_sent_a_support, sentAmount == 1.0 ? 1 : 2,
public void onSupportCreated(BigDecimal amount, boolean isTip) { new DecimalFormat("#,###.##").format(sentAmount));
double sentAmount = amount.doubleValue(); Snackbar.make(root.findViewById(R.id.file_view_claim_display_area), message, Snackbar.LENGTH_LONG).show();
String message = getResources().getQuantityString(
isTip ? R.plurals.you_sent_a_tip : R.plurals.you_sent_a_support, sentAmount == 1.0 ? 1 : 2,
new DecimalFormat("#,###.##").format(sentAmount));
Snackbar.make(root.findViewById(R.id.file_view_claim_display_area), message, Snackbar.LENGTH_LONG).show();
}
}); });
Context context = getContext(); Context context = getContext();
if (context instanceof MainActivity) { if (context instanceof MainActivity) {
@ -1036,15 +1031,10 @@ public class FileViewFragment extends BaseFragment implements
} }
if (claim != null) { if (claim != null) {
RepostClaimDialogFragment dialog = RepostClaimDialogFragment.newInstance(); RepostClaimDialogFragment dialog = RepostClaimDialogFragment.newInstance(claim, claim -> {
dialog.setClaim(claim); Context context = getContext();
dialog.setListener(new RepostClaimDialogFragment.RepostClaimListener() { if (context instanceof MainActivity) {
@Override ((MainActivity) context).showMessage(R.string.content_successfully_reposted);
public void onClaimReposted(Claim claim) {
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).showMessage(R.string.content_successfully_reposted);
}
} }
}); });
Context context = getContext(); Context context = getContext();