mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-22 05:45:04 +00:00
[#36] Price gold centered and samll refactorings
This commit is contained in:
parent
005a2ac66c
commit
c84e6f2fa2
1 changed files with 36 additions and 33 deletions
|
|
@ -485,38 +485,41 @@ public class HabitItemRecyclerViewAdapter<THabitItem extends Task>
|
||||||
if (v == binding.btnReward || v == binding.imageView3 || v == binding.gearElementsLayout) {
|
if (v == binding.btnReward || v == binding.imageView3 || v == binding.gearElementsLayout) {
|
||||||
LinearLayout contentViewForDialog = createContentViewForDialog();
|
LinearLayout contentViewForDialog = createContentViewForDialog();
|
||||||
|
|
||||||
final MaterialDialog dialog = new MaterialDialog.Builder(context)
|
MaterialDialog dialog = createGearDialog(event, contentViewForDialog);
|
||||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
|
||||||
@Override
|
|
||||||
public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
|
|
||||||
event.Reward = Item;
|
|
||||||
EventBus.getDefault().post(event);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.positiveColor(context.getResources().getColor(R.color.brand_200))
|
|
||||||
.positiveText("Buy")
|
|
||||||
.title(binding.getReward().getText())
|
|
||||||
.customView(contentViewForDialog, true)
|
|
||||||
.negativeText("Dismiss")
|
|
||||||
.onNegative(new MaterialDialog.SingleButtonCallback() {
|
|
||||||
@Override
|
|
||||||
public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
|
|
||||||
materialDialog.dismiss();
|
|
||||||
}
|
|
||||||
}).build();
|
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
} else super.onClick(v);
|
} else super.onClick(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private MaterialDialog createGearDialog(final BuyRewardTappedEvent event, LinearLayout contentViewForDialog) {
|
||||||
|
return new MaterialDialog.Builder(context)
|
||||||
|
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||||
|
@Override
|
||||||
|
public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
|
||||||
|
event.Reward = Item;
|
||||||
|
EventBus.getDefault().post(event);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.positiveColor(context.getResources().getColor(R.color.brand_200))
|
||||||
|
.positiveText("Buy")
|
||||||
|
.title(binding.getReward().getText())
|
||||||
|
.customView(contentViewForDialog, true)
|
||||||
|
.negativeText("Dismiss")
|
||||||
|
.onNegative(new MaterialDialog.SingleButtonCallback() {
|
||||||
|
@Override
|
||||||
|
public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
|
||||||
|
materialDialog.dismiss();
|
||||||
|
}
|
||||||
|
}).build();
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private LinearLayout createContentViewForDialog() {
|
private LinearLayout createContentViewForDialog() {
|
||||||
String price = String.format("%.0f", binding.getReward().value);
|
String price = String.format("%.0f", binding.getReward().value);
|
||||||
String content = binding.getReward().getNotes();
|
String content = binding.getReward().getNotes();
|
||||||
|
|
||||||
LinearLayout l = new LinearLayout(context);
|
LinearLayout contentViewLayout = new LinearLayout(context);
|
||||||
l.setOrientation(LinearLayout.VERTICAL);
|
contentViewLayout.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
|
||||||
ImageView imageView = new ImageView(context);
|
ImageView imageView = new ImageView(context);
|
||||||
imageView.setMinimumWidth(200);
|
imageView.setMinimumWidth(200);
|
||||||
|
|
@ -524,11 +527,11 @@ public class HabitItemRecyclerViewAdapter<THabitItem extends Task>
|
||||||
|
|
||||||
DataBindingUtils.loadImage(imageView, "shop_" + binding.getReward().getId());
|
DataBindingUtils.loadImage(imageView, "shop_" + binding.getReward().getId());
|
||||||
|
|
||||||
TextView t = new TextView(context);
|
TextView contentTextView = new TextView(context, null);
|
||||||
t.setText(content);
|
contentTextView.setText(content);
|
||||||
|
|
||||||
LinearLayout bottomLayout = new LinearLayout(context);
|
LinearLayout goldPriceLayout = new LinearLayout(context);
|
||||||
bottomLayout.setOrientation(LinearLayout.HORIZONTAL);
|
goldPriceLayout.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
|
|
||||||
TextView priceTextView = new TextView(context);
|
TextView priceTextView = new TextView(context);
|
||||||
priceTextView.setText(price);
|
priceTextView.setText(price);
|
||||||
|
|
@ -539,16 +542,16 @@ public class HabitItemRecyclerViewAdapter<THabitItem extends Task>
|
||||||
gold.setMinimumWidth(50);
|
gold.setMinimumWidth(50);
|
||||||
gold.setPadding(0, 0, 20, 0);
|
gold.setPadding(0, 0, 20, 0);
|
||||||
|
|
||||||
bottomLayout.addView(gold);
|
goldPriceLayout.addView(gold);
|
||||||
bottomLayout.addView(priceTextView);
|
goldPriceLayout.addView(priceTextView);
|
||||||
bottomLayout.setGravity(Gravity.RIGHT);
|
goldPriceLayout.setGravity(Gravity.CENTER);
|
||||||
|
|
||||||
if(imageView.getDrawable()!= null){
|
if(imageView.getDrawable()!= null){
|
||||||
l.addView(imageView);
|
contentViewLayout.addView(imageView);
|
||||||
}
|
}
|
||||||
l.addView(t);
|
contentViewLayout.addView(goldPriceLayout);
|
||||||
l.addView(bottomLayout);
|
contentViewLayout.addView(contentTextView);
|
||||||
return l;
|
return contentViewLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue