mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-19 04:09:03 +00:00
remove MaterialDialogs as dependency
This commit is contained in:
parent
93853b4ee0
commit
e55455e4d0
4 changed files with 65 additions and 91 deletions
|
|
@ -93,9 +93,6 @@ dependencies {
|
|||
transitive = true
|
||||
}
|
||||
|
||||
//Material Dialogs
|
||||
compile('com.github.afollestad.material-dialogs:core:0.8.5.6@aar')
|
||||
|
||||
compile 'fr.avianey.com.viewpagerindicator:library:2.4.1@aar'
|
||||
|
||||
compile 'com.amplitude:android-sdk:2.5.0'
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import android.widget.FrameLayout;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.amplitude.api.Amplitude;
|
||||
import com.habitrpg.android.habitica.APIHelper;
|
||||
import com.habitrpg.android.habitica.HabiticaApplication;
|
||||
|
|
@ -139,7 +138,7 @@ public class MainActivity extends BaseActivity implements HabitRPGUserCallback.O
|
|||
private BaseMainFragment activeFragment;
|
||||
private AvatarWithBarsViewModel avatarInHeader;
|
||||
private APIHelper mAPIHelper;
|
||||
private MaterialDialog faintDialog;
|
||||
private AlertDialog faintDialog;
|
||||
|
||||
private UserPicture sideUserPicture;
|
||||
private UserPicture dialogUserPicture;
|
||||
|
|
@ -708,13 +707,14 @@ public class MainActivity extends BaseActivity implements HabitRPGUserCallback.O
|
|||
this.mAPIHelper.apiService.hatchPet(event.usingEgg.getKey(), event.usingHatchingPotion.getKey(), new ItemsCallback(new HabitRPGUserCallback.OnUserReceived() {
|
||||
@Override
|
||||
public void onUserReceived(HabitRPGUser user) {
|
||||
ImageView petImageView = (ImageView)getLayoutInflater().inflate(R.layout.pet_imageview, null);
|
||||
FrameLayout petWrapper = (FrameLayout) getLayoutInflater().inflate(R.layout.pet_imageview, null);
|
||||
ImageView petImageView = (ImageView)petWrapper.findViewById(R.id.pet_imageview);
|
||||
|
||||
DataBindingUtils.loadImage(petImageView, "Pet-" + event.usingEgg.getKey() + "-" + event.usingHatchingPotion.getKey());
|
||||
|
||||
AlertDialog dialog = new AlertDialog.Builder(MainActivity.this)
|
||||
.setTitle(getString(R.string.hatched_pet_title, event.usingHatchingPotion.getText(), event.usingEgg.getText()))
|
||||
.setView(petImageView)
|
||||
.setView(petWrapper)
|
||||
.setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
|
@ -842,27 +842,8 @@ public class MainActivity extends BaseActivity implements HabitRPGUserCallback.O
|
|||
}
|
||||
|
||||
if (this.faintDialog == null) {
|
||||
this.faintDialog = new MaterialDialog.Builder(this)
|
||||
.title(R.string.faint_header)
|
||||
.customView(R.layout.dialog_faint, true)
|
||||
.positiveText(R.string.faint_button)
|
||||
.positiveColorRes(R.color.worse_100)
|
||||
.dismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
faintDialog = null;
|
||||
mAPIHelper.reviveUser(new HabitRPGUserCallback(MainActivity.this));
|
||||
}
|
||||
})
|
||||
.cancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
faintDialog = null;
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
||||
View customView = this.faintDialog.getCustomView();
|
||||
View customView = getLayoutInflater().inflate(R.layout.dialog_faint, null);
|
||||
if (customView != null) {
|
||||
View hpBarView = customView.findViewById(R.id.hpBar);
|
||||
|
||||
|
|
@ -875,6 +856,20 @@ public class MainActivity extends BaseActivity implements HabitRPGUserCallback.O
|
|||
this.dialogUserPicture.setPictureOn(avatarView);
|
||||
}
|
||||
|
||||
this.faintDialog = new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.faint_header)
|
||||
.setView(customView)
|
||||
.setPositiveButton(R.string.faint_button, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
faintDialog = null;
|
||||
mAPIHelper.reviveUser(new HabitRPGUserCallback(MainActivity.this));
|
||||
}
|
||||
})
|
||||
.create();
|
||||
|
||||
|
||||
|
||||
this.faintDialog.show();
|
||||
}
|
||||
}
|
||||
|
|
@ -887,14 +882,7 @@ public class MainActivity extends BaseActivity implements HabitRPGUserCallback.O
|
|||
}
|
||||
}
|
||||
|
||||
MaterialDialog dialog = new MaterialDialog.Builder(this)
|
||||
.title(R.string.levelup_header)
|
||||
.customView(R.layout.dialog_levelup, true)
|
||||
.positiveText(R.string.levelup_button)
|
||||
.positiveColorRes(R.color.brand_100)
|
||||
.build();
|
||||
|
||||
View customView = dialog.getCustomView();
|
||||
View customView = getLayoutInflater().inflate(R.layout.dialog_levelup, null);
|
||||
if (customView != null) {
|
||||
TextView detailView = (TextView) customView.findViewById(R.id.levelupDetail);
|
||||
detailView.setText(this.getString(R.string.levelup_detail, level));
|
||||
|
|
@ -903,6 +891,12 @@ public class MainActivity extends BaseActivity implements HabitRPGUserCallback.O
|
|||
this.dialogUserPicture.setPictureOn(avatarView);
|
||||
}
|
||||
|
||||
AlertDialog dialog = new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.levelup_header)
|
||||
.setView(customView)
|
||||
.setPositiveButton(R.string.levelup_button, null)
|
||||
.create();
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.habitrpg.android.habitica.ui.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
|
|
@ -12,9 +14,6 @@ import android.widget.LinearLayout;
|
|||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.afollestad.materialdialogs.GravityEnum;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.events.commands.OpenMenuItemCommand;
|
||||
import com.habitrpg.android.habitica.events.commands.UnlockPathCommand;
|
||||
|
|
@ -34,9 +33,6 @@ import java.util.Map;
|
|||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* Created by viirus on 13/01/16.
|
||||
*/
|
||||
public class CustomizationRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private List<Object> customizationList;
|
||||
|
|
@ -182,34 +178,30 @@ public class CustomizationRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
|||
TextView priceLabel = (TextView) dialogContent.findViewById(R.id.priceLabel);
|
||||
priceLabel.setText(String.valueOf(customization.getPrice()));
|
||||
|
||||
MaterialDialog dialog = new MaterialDialog.Builder(context)
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
AlertDialog dialog = new AlertDialog.Builder(context)
|
||||
.setPositiveButton(R.string.purchase_button, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
|
||||
if (customization.getPrice() > gemBalance) {
|
||||
OpenMenuItemCommand event = new OpenMenuItemCommand();
|
||||
event.identifier = MainDrawerBuilder.SIDEBAR_PURCHASE;
|
||||
EventBus.getDefault().post(event);
|
||||
return;
|
||||
}
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (customization.getPrice() > gemBalance) {
|
||||
OpenMenuItemCommand event = new OpenMenuItemCommand();
|
||||
event.identifier = MainDrawerBuilder.SIDEBAR_PURCHASE;
|
||||
EventBus.getDefault().post(event);
|
||||
return;
|
||||
}
|
||||
UnlockPathCommand event = new UnlockPathCommand();
|
||||
event.path = customization.getPath();
|
||||
event.balanceDiff = customization.getPrice() / 4;
|
||||
EventBus.getDefault().post(event);
|
||||
}
|
||||
})
|
||||
.contentGravity(GravityEnum.CENTER)
|
||||
.positiveColor(context.getResources().getColor(R.color.brand_200))
|
||||
.positiveText(R.string.purchase_button)
|
||||
.title(context.getString(R.string.purchase_customization))
|
||||
.customView(dialogContent, true)
|
||||
.negativeText(R.string.reward_dialog_dismiss)
|
||||
.onNegative(new MaterialDialog.SingleButtonCallback() {
|
||||
.setTitle(context.getString(R.string.purchase_customization))
|
||||
.setView(dialogContent)
|
||||
.setNegativeButton(R.string.reward_dialog_dismiss, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
|
||||
materialDialog.dismiss();
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
}).build();
|
||||
}).create();
|
||||
dialog.show();
|
||||
return;
|
||||
}
|
||||
|
|
@ -268,10 +260,10 @@ public class CustomizationRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
|||
TextView priceLabel = (TextView) dialogContent.findViewById(R.id.priceLabel);
|
||||
priceLabel.setText(String.valueOf(set.price));
|
||||
|
||||
MaterialDialog dialog = new MaterialDialog.Builder(context)
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
AlertDialog dialog = new AlertDialog.Builder(context)
|
||||
.setPositiveButton(R.string.purchase_button, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (set.price > gemBalance) {
|
||||
OpenMenuItemCommand event = new OpenMenuItemCommand();
|
||||
event.identifier = MainDrawerBuilder.SIDEBAR_PURCHASE;
|
||||
|
|
@ -293,18 +285,14 @@ public class CustomizationRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
|||
EventBus.getDefault().post(event);
|
||||
}
|
||||
})
|
||||
.contentGravity(GravityEnum.CENTER)
|
||||
.positiveColor(context.getResources().getColor(R.color.brand_200))
|
||||
.positiveText(R.string.purchase_button)
|
||||
.title(context.getString(R.string.purchase_set_title, set.text))
|
||||
.customView(dialogContent, true)
|
||||
.negativeText(R.string.reward_dialog_dismiss)
|
||||
.onNegative(new MaterialDialog.SingleButtonCallback() {
|
||||
.setTitle(context.getString(R.string.purchase_set_title, set.text))
|
||||
.setView(dialogContent)
|
||||
.setNegativeButton(R.string.reward_dialog_dismiss, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
|
||||
materialDialog.dismiss();
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
}).build();
|
||||
}).create();
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,14 @@ package com.habitrpg.android.habitica.ui.adapter.tasks;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.databinding.DataBindingUtil;
|
||||
import android.databinding.ObservableArrayList;
|
||||
import android.graphics.Rect;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
|
|
@ -28,9 +30,6 @@ import android.widget.LinearLayout;
|
|||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.afollestad.materialdialogs.GravityEnum;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.github.data5tream.emojilib.EmojiTextView;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.databinding.DailyItemCardBinding;
|
||||
|
|
@ -566,7 +565,7 @@ public class HabitItemRecyclerViewAdapter<THabitItem extends Task>
|
|||
} else {
|
||||
if(Item.specialTag != null && Item.specialTag.equals("item")) {
|
||||
LinearLayout contentViewForDialog = createContentViewForGearDialog();
|
||||
MaterialDialog dialog = createGearDialog(contentViewForDialog);
|
||||
AlertDialog dialog = createGearDialog(contentViewForDialog);
|
||||
dialog.show();
|
||||
} else {
|
||||
TaskTappedEvent event = new TaskTappedEvent();
|
||||
|
|
@ -577,28 +576,24 @@ public class HabitItemRecyclerViewAdapter<THabitItem extends Task>
|
|||
}
|
||||
}
|
||||
|
||||
private MaterialDialog createGearDialog(LinearLayout contentViewForDialog) {
|
||||
return new MaterialDialog.Builder(context)
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
private AlertDialog createGearDialog(LinearLayout contentViewForDialog) {
|
||||
return new AlertDialog.Builder(context)
|
||||
.setPositiveButton(R.string.reward_dialog_buy, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
BuyRewardCommand event = new BuyRewardCommand();
|
||||
event.Reward = Item;
|
||||
EventBus.getDefault().post(event);
|
||||
}
|
||||
})
|
||||
.contentGravity(GravityEnum.CENTER)
|
||||
.positiveColor(ContextCompat.getColor(context, R.color.brand_200))
|
||||
.positiveText(R.string.reward_dialog_buy)
|
||||
.title(binding.getReward().getText())
|
||||
.customView(contentViewForDialog, true)
|
||||
.negativeText(R.string.reward_dialog_dismiss)
|
||||
.onNegative(new MaterialDialog.SingleButtonCallback() {
|
||||
.setTitle(binding.getReward().getText())
|
||||
.setView(contentViewForDialog)
|
||||
.setNegativeButton(R.string.reward_dialog_dismiss, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
|
||||
materialDialog.dismiss();
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
}).build();
|
||||
}).create();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
|||
Loading…
Reference in a new issue