fix equipping pets and mounts

This commit is contained in:
Phillip Thelen 2016-04-07 20:31:10 +02:00
parent 318614ac02
commit 6dc5399b8c
2 changed files with 18 additions and 20 deletions

View file

@ -120,14 +120,12 @@ public class MountDetailRecyclerAdapter extends RecyclerView.Adapter<MountDetail
}
BottomSheetMenu menu = new BottomSheetMenu(context);
menu.addMenuItem(new BottomSheetMenuItem(resources.getString(R.string.use_animal)));
menu.setSelectionRunnable(new BottomSheetMenuSelectionRunnable() {
@Override
public void selectedItemAt(Integer index) {
if (index == 0) {
EquipCommand event = new EquipCommand();
event.type = "mount";
event.key = animal.getKey();
}
menu.setSelectionRunnable(index -> {
if (index == 0) {
EquipCommand event = new EquipCommand();
event.type = "mount";
event.key = animal.getKey();
EventBus.getDefault().post(event);
}
});
menu.show();

View file

@ -4,6 +4,7 @@ import android.content.Context;
import android.content.res.Resources;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -148,18 +149,17 @@ public class PetDetailRecyclerAdapter extends RecyclerView.Adapter<PetDetailRecy
if (!this.isMountOwned()) {
menu.addMenuItem(new BottomSheetMenuItem(resources.getString(R.string.feed)));
}
menu.setSelectionRunnable(new BottomSheetMenuSelectionRunnable() {
@Override
public void selectedItemAt(Integer index) {
if (index == 0) {
EquipCommand event = new EquipCommand();
event.type = "pet";
event.key = animal.getKey();
} else if (index == 1) {
FeedCommand event = new FeedCommand();
event.usingPet = animal;
EventBus.getDefault().post(event);
}
menu.setSelectionRunnable(index -> {
Log.e("EEEEEEE", index.toString());
if (index == 0) {
EquipCommand event = new EquipCommand();
event.type = "pet";
event.key = animal.getKey();
EventBus.getDefault().post(event);
} else if (index == 1) {
FeedCommand event = new FeedCommand();
event.usingPet = animal;
EventBus.getDefault().post(event);
}
});
menu.show();