code cleanup, make newInstance use final variables for listener and claim
This commit is contained in:
parent
c95f25b584
commit
b9251c2036
4 changed files with 38 additions and 45 deletions
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
double sentAmount = amount.doubleValue();
|
||||
View view = getView();
|
||||
if (view != 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();
|
||||
}
|
||||
CreateSupportDialogFragment dialog = CreateSupportDialogFragment.newInstance(claim, (amount, isTip) -> {
|
||||
double sentAmount = amount.doubleValue();
|
||||
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(view1, message, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
Context context = getContext();
|
||||
|
|
|
@ -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) {
|
||||
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();
|
||||
}
|
||||
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,15 +1031,10 @@ 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) {
|
||||
Context context = getContext();
|
||||
if (context instanceof MainActivity) {
|
||||
((MainActivity) context).showMessage(R.string.content_successfully_reposted);
|
||||
}
|
||||
RepostClaimDialogFragment dialog = RepostClaimDialogFragment.newInstance(claim, claim -> {
|
||||
Context context = getContext();
|
||||
if (context instanceof MainActivity) {
|
||||
((MainActivity) context).showMessage(R.string.content_successfully_reposted);
|
||||
}
|
||||
});
|
||||
Context context = getContext();
|
||||
|
|
Loading…
Reference in a new issue