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;
@Setter
private CreateSupportListener listener;
@Setter
private Claim claim;
private final CreateSupportListener listener;
private final Claim claim;
public static CreateSupportDialogFragment newInstance() {
return new CreateSupportDialogFragment();
private CreateSupportDialogFragment(Claim claim, CreateSupportListener listener) {
super();
this.claim = claim;
this.listener = listener;
}
public static CreateSupportDialogFragment newInstance(Claim claim, CreateSupportListener listener) {
return new CreateSupportDialogFragment(claim, listener);
}
private void disableControls() {

View file

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

View file

@ -185,19 +185,14 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
}
if (claim != null) {
CreateSupportDialogFragment dialog = CreateSupportDialogFragment.newInstance();
dialog.setClaim(claim);
dialog.setListener(new CreateSupportDialogFragment.CreateSupportListener() {
@Override
public void onSupportCreated(BigDecimal amount, boolean isTip) {
CreateSupportDialogFragment dialog = CreateSupportDialogFragment.newInstance(claim, (amount, isTip) -> {
double sentAmount = amount.doubleValue();
View view = getView();
if (view != null) {
View view1 = getView();
if (view1 != null) {
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();
}
Snackbar.make(view1, message, Snackbar.LENGTH_LONG).show();
}
});
Context context = getContext();

View file

@ -1007,17 +1007,12 @@ public class FileViewFragment extends BaseFragment implements
}
if (claim != null) {
CreateSupportDialogFragment dialog = CreateSupportDialogFragment.newInstance();
dialog.setClaim(claim);
dialog.setListener(new CreateSupportDialogFragment.CreateSupportListener() {
@Override
public void onSupportCreated(BigDecimal amount, boolean isTip) {
CreateSupportDialogFragment dialog = CreateSupportDialogFragment.newInstance(claim, (amount, isTip) -> {
double sentAmount = amount.doubleValue();
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();
if (context instanceof MainActivity) {
@ -1036,16 +1031,11 @@ public class FileViewFragment extends BaseFragment implements
}
if (claim != null) {
RepostClaimDialogFragment dialog = RepostClaimDialogFragment.newInstance();
dialog.setClaim(claim);
dialog.setListener(new RepostClaimDialogFragment.RepostClaimListener() {
@Override
public void onClaimReposted(Claim claim) {
RepostClaimDialogFragment dialog = RepostClaimDialogFragment.newInstance(claim, claim -> {
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).showMessage(R.string.content_successfully_reposted);
}
}
});
Context context = getContext();
if (context instanceof MainActivity) {