Commit 1de320b7 authored by Kevin Whitaker's avatar Kevin Whitaker

Implement last character details screen. Also, rip out built-in dialog support...

Implement last character details screen. Also, rip out built-in dialog support for a library that makes consistent material look across platforms.
parent 91615dbd
......@@ -6,13 +6,6 @@
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
<option name="mavenHome" value="Bundled (Maven 3)" />
</MavenGeneralSettings>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
......@@ -29,19 +22,4 @@
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
\ No newline at end of file
......@@ -85,13 +85,16 @@
</content>
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="alertdialogpro-core-0.2.2" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.0.0" level="project" />
<orderEntry type="library" exported="" name="android-holo-graph-0.1.0" level="project" />
<orderEntry type="library" exported="" name="calligraphy-2.0.2" level="project" />
<orderEntry type="library" exported="" name="realm-android-0.80.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.0.0" level="project" />
<orderEntry type="library" exported="" name="alertdialogpro-theme-material-0.2.2" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.0.0" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-21.0.3" level="project" />
</component>
</module>
\ No newline at end of file
......@@ -44,4 +44,5 @@ dependencies {
compile 'com.android.support:recyclerview-v7:21.0.+'
compile 'com.android.support:cardview-v7:21.0.+'
compile 'org.quanqi:android-holo-graph:0.1.0'
compile 'com.github.fengdai:alertdialogpro-theme-material:0.2.2'
}
......@@ -26,8 +26,9 @@
android:value="com.eyecreate.miceandmystics.miceandmystics.CampaignActivity" />
</activity>
<activity
android:name=".PlayerManagerActivity">
</activity>
android:name=".PlayerManagerActivity"/>
<activity
android:name=".CharacterDetailsActivity"/>
</application>
</manifest>
......@@ -3,7 +3,6 @@ package com.eyecreate.miceandmystics.miceandmystics;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.*;
......@@ -11,6 +10,7 @@ import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import com.alertdialogpro.AlertDialogPro;
import com.eyecreate.miceandmystics.miceandmystics.adapters.CampaignAdapter;
import com.eyecreate.miceandmystics.miceandmystics.model.Enums.CampaignType;
......@@ -56,7 +56,7 @@ public class CampaignActivity extends RecyclerViewActivity {
final Spinner typeSpinner = ((Spinner)dialogView.findViewById(R.id.campaign_type));
typeSpinner.setAdapter(new ArrayAdapter<CampaignType>(this, R.layout.simple_spinner_item, CampaignType.values()));
typeSpinner.setSelection(0);
AlertDialog addDialog = new AlertDialog.Builder(this,R.style.dialogTheme)
AlertDialog addDialog = new AlertDialogPro.Builder(this,R.style.dialogTheme)
.setMessage("Please give your new campaign a unique name:")
.setView(dialogView)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
......
......@@ -12,6 +12,7 @@ import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import com.alertdialogpro.AlertDialogPro;
import com.eyecreate.miceandmystics.miceandmystics.adapters.CampaignDetailsAdapter;
import com.eyecreate.miceandmystics.miceandmystics.model.Achievement;
import com.eyecreate.miceandmystics.miceandmystics.model.Campaign;
......@@ -80,7 +81,7 @@ public class CampaignDetailsActivity extends RecyclerViewActivity {
LayoutInflater inflator = (LayoutInflater)(new ContextThemeWrapper(ctx, R.style.dialogTheme)).getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View dialogView = inflator.inflate(R.layout.dialog_new_player, null, false);
final EditText playerEdit = ((EditText)dialogView.findViewById(R.id.player_name));
AlertDialog addDialog = new AlertDialog.Builder(ctx,R.style.dialogTheme)
AlertDialog addDialog = new AlertDialogPro.Builder(ctx,R.style.dialogTheme)
.setMessage("Please name the new player:")
.setView(dialogView)
.setPositiveButton("Create", new DialogInterface.OnClickListener() {
......@@ -116,7 +117,7 @@ public class CampaignDetailsActivity extends RecyclerViewActivity {
final Spinner achievementSpinner = ((Spinner)dialogView.findViewById(R.id.achievement_name));
achievementSpinner.setAdapter(new ArrayAdapter<com.eyecreate.miceandmystics.miceandmystics.model.Enums.Achievement>(this, R.layout.simple_spinner_item, com.eyecreate.miceandmystics.miceandmystics.model.Enums.Achievement.values()));
achievementSpinner.setSelection(0);
AlertDialog addDialog = new AlertDialog.Builder(this,R.style.dialogTheme)
AlertDialog addDialog = new AlertDialogPro.Builder(this,R.style.dialogTheme)
.setMessage("Please select the achievement to add to party:")
.setView(dialogView)
.setPositiveButton("Add", new DialogInterface.OnClickListener() {
......@@ -150,7 +151,7 @@ public class CampaignDetailsActivity extends RecyclerViewActivity {
RealmResults<Player> players = MiceAndMysticsApplication.getRealmInstance().where(Player.class).findAll();
playerSpinner.setAdapter(new ArrayAdapter<String>(this, R.layout.simple_spinner_item, Player.convertPlayerListToStringArray(players.subList(0,players.size()))));
playerSpinner.setSelection(0);
AlertDialog addDialog = new AlertDialog.Builder(this,R.style.dialogTheme)
AlertDialog addDialog = new AlertDialogPro.Builder(this,R.style.dialogTheme)
.setMessage("Please select your character and controlling player:")
.setView(dialogView)
.setPositiveButton("Create", new DialogInterface.OnClickListener() {
......
package com.eyecreate.miceandmystics.miceandmystics;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.*;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import com.alertdialogpro.AlertDialogPro;
import com.eyecreate.miceandmystics.miceandmystics.adapters.CharacterDetailsAdapter;
import com.eyecreate.miceandmystics.miceandmystics.model.Character;
import com.eyecreate.miceandmystics.miceandmystics.model.Enums.Abilities;
import com.eyecreate.miceandmystics.miceandmystics.model.Enums.CharacterNames;
import io.realm.RealmResults;
public class CharacterDetailsActivity extends RecyclerViewActivity {
Character currentCharacter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Character Details");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if(getIntent().hasExtra("characterId")) {
currentCharacter = MiceAndMysticsApplication.getRealmInstance().where(Character.class).equalTo("uuid",getIntent().getStringExtra("characterId")).findFirst();
} else if(savedInstanceState.containsKey("characterId")) {
currentCharacter = MiceAndMysticsApplication.getRealmInstance().where(Character.class).equalTo("uuid",savedInstanceState.getString("characterId")).findFirst();
}
setLayoutManager(new LinearLayoutManager(this));
setAdapter(new CharacterDetailsAdapter(currentCharacter));
}
@Override
public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) {
super.onSaveInstanceState(outState, outPersistentState);
outState.putString("characterId", currentCharacter.getUuid());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_character_details, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if(id == R.id.action_add_ability) {
newAbilityDialog();
return true;
} else if(id == R.id.action_add_item) {
newItemDialog();
return true;
} else if (id == android.R.id.home) {
finish();
}
return super.onOptionsItemSelected(item);
}
public void newAbilityDialog() {
LayoutInflater inflator = (LayoutInflater)(new ContextThemeWrapper(this, R.style.dialogTheme)).getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View dialogView = inflator.inflate(R.layout.dialog_new_ability, null, false);
final Spinner abilitySpinner = ((Spinner)dialogView.findViewById(R.id.ability_name));
abilitySpinner.setAdapter(new ArrayAdapter<Abilities>(this, R.layout.simple_spinner_item, Abilities.getMatchingCharacterAbilities(CharacterNames.valueOf(currentCharacter.getCharacterName()).characterTypes())));
abilitySpinner.setSelection(0);
AlertDialog addDialog = new AlertDialogPro.Builder(this,R.style.dialogTheme)
.setMessage("Please select the ability to be added:")
.setView(dialogView)
.setPositiveButton("Add", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
RealmResults<Character> duplicates = MiceAndMysticsApplication.getRealmInstance().where(Character.class).equalTo("abilities.abilityName",abilitySpinner.getSelectedItem().toString()).equalTo("uuid",currentCharacter.getUuid()).findAll();
if(duplicates.size()==0) {
((CharacterDetailsAdapter) getAdapter()).addAbility((Abilities) abilitySpinner.getSelectedItem());
} else {
Toast.makeText(CharacterDetailsActivity.this,"That ability is already on this character.",Toast.LENGTH_LONG).show();
}
}
})
.create();
addDialog.show();
}
public void newItemDialog() {
LayoutInflater inflator = (LayoutInflater)(new ContextThemeWrapper(this, R.style.dialogTheme)).getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View dialogView = inflator.inflate(R.layout.dialog_new_item, null, false);
final EditText itemEdit = ((EditText)dialogView.findViewById(R.id.item_name));
AlertDialog addDialog = new AlertDialogPro.Builder(this,R.style.dialogTheme)
.setMessage("Please name the item to mark as held:")
.setView(dialogView)
.setPositiveButton("Add", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (itemEdit.getText().length() > 0) {
((CharacterDetailsAdapter) getAdapter()).addItem(itemEdit.getText().toString());
} else if (itemEdit.getText().length() == 0) {
Toast.makeText(CharacterDetailsActivity.this, "Can not have a blank item name!", Toast.LENGTH_LONG).show();
}
}
})
.create();
addDialog.show();
}
}
package com.eyecreate.miceandmystics.miceandmystics.adapters;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.eyecreate.miceandmystics.miceandmystics.MiceAndMysticsApplication;
import com.eyecreate.miceandmystics.miceandmystics.R;
import com.eyecreate.miceandmystics.miceandmystics.model.Ability;
import com.eyecreate.miceandmystics.miceandmystics.model.BackpackItem;
import com.eyecreate.miceandmystics.miceandmystics.model.Character;
import com.eyecreate.miceandmystics.miceandmystics.model.Enums.Abilities;
import com.eyecreate.miceandmystics.miceandmystics.viewholders.CharacterAbilityHeaderViewHolder;
import com.eyecreate.miceandmystics.miceandmystics.viewholders.CharacterAbilityViewHolder;
import com.eyecreate.miceandmystics.miceandmystics.viewholders.CharacterItemViewHolder;
import com.eyecreate.miceandmystics.miceandmystics.viewholders.CharacterItemsHeaderViewHolder;
import java.util.UUID;
public class CharacterDetailsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
Character currentCharacter;
LayoutInflater inflater;
public CharacterDetailsAdapter(Character currentCharacter) {
this.currentCharacter = currentCharacter;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if(inflater == null) inflater = (LayoutInflater)parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if(viewType == R.id.characterDeatilAbilityHeader) {
return new CharacterAbilityHeaderViewHolder(inflater.inflate(R.layout.item_character_ability_header,parent,false));
} else if(viewType == R.id.characterDetailAbility) {
return new CharacterAbilityViewHolder(inflater.inflate(R.layout.item_character_ability,parent,false),this);
} else if(viewType == R.id.characterDetailItemHeader) {
return new CharacterItemsHeaderViewHolder(inflater.inflate(R.layout.item_character_items_header,parent,false));
} else {
return new CharacterItemViewHolder(inflater.inflate(R.layout.item_character_item,parent,false),this);
}
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if(holder instanceof CharacterAbilityHeaderViewHolder) {
((CharacterAbilityHeaderViewHolder) holder).bindHolder(currentCharacter);
} else if(holder instanceof CharacterAbilityViewHolder) {
((CharacterAbilityViewHolder)holder).bindHolder(currentCharacter.getAbilities().get(position-1));
} else if(holder instanceof CharacterItemViewHolder) {
((CharacterItemViewHolder) holder).bindModel(currentCharacter.getStoredItems().get(position-2-currentCharacter.getAbilities().size()));
}
}
@Override
public int getItemCount() {
return currentCharacter.getAbilities().size()+1+currentCharacter.getStoredItems().size()+1; //The plus ones represent headers
}
@Override
public int getItemViewType(int position) {
if(position == 0) {
return R.id.characterDeatilAbilityHeader;
} else if(position < currentCharacter.getAbilities().size()+1) {
return R.id.characterDetailAbility;
} else if (position == currentCharacter.getAbilities().size()+1) {
return R.id.characterDetailItemHeader;
} else {
return R.id.characterDetailItem;
}
}
public void addAbility(Abilities ability) {
MiceAndMysticsApplication.getRealmInstance().beginTransaction();
Ability realmAbility = MiceAndMysticsApplication.getRealmInstance().createObject(Ability.class);
realmAbility.setUuid(UUID.randomUUID().toString());
realmAbility.setAbilityName(ability.displayName());
currentCharacter.getAbilities().add(realmAbility);
MiceAndMysticsApplication.getRealmInstance().commitTransaction();
notifyDataSetChanged();
}
public void addItem(String itemName) {
MiceAndMysticsApplication.getRealmInstance().beginTransaction();
BackpackItem item = MiceAndMysticsApplication.getRealmInstance().createObject(BackpackItem.class);
item.setUuid(UUID.randomUUID().toString());
item.setItemName(itemName);
currentCharacter.getStoredItems().add(item);
MiceAndMysticsApplication.getRealmInstance().commitTransaction();
notifyDataSetChanged();
}
public void removeItem(String itemUuid) {
BackpackItem item = MiceAndMysticsApplication.getRealmInstance().where(BackpackItem.class).equalTo("uuid",itemUuid).findFirst();
MiceAndMysticsApplication.getRealmInstance().beginTransaction();
item.removeFromRealm();
MiceAndMysticsApplication.getRealmInstance().commitTransaction();
notifyDataSetChanged();
}
public void removeAbility(String abilityUuid) {
Ability ability = MiceAndMysticsApplication.getRealmInstance().where(Ability.class).equalTo("uuid",abilityUuid).findFirst();
MiceAndMysticsApplication.getRealmInstance().beginTransaction();
ability.removeFromRealm();
MiceAndMysticsApplication.getRealmInstance().commitTransaction();
notifyDataSetChanged();
}
}
......@@ -6,6 +6,7 @@ import android.content.DialogInterface;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.alertdialogpro.AlertDialogPro;
import com.eyecreate.miceandmystics.miceandmystics.MiceAndMysticsApplication;
import com.eyecreate.miceandmystics.miceandmystics.R;
import com.eyecreate.miceandmystics.miceandmystics.model.*;
......@@ -45,7 +46,7 @@ public class PlayerManagerAdapter extends RecyclerView.Adapter<PlayerViewHolder>
final RealmResults<Character> playerCharacters = MiceAndMysticsApplication.getRealmInstance().where(com.eyecreate.miceandmystics.miceandmystics.model.Character.class)
.equalTo("controllingPlayer.playerName", playerName).findAll();
if(playerCharacters.size()>0) {
AlertDialog removeDialog = new AlertDialog.Builder(ctx,R.style.dialogTheme)
AlertDialog removeDialog = new AlertDialogPro.Builder(ctx,R.style.dialogTheme)
.setMessage("Removing player "+playerName+" must first remove all characters owned by player. Do you want to continue still?")
.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
......@@ -68,7 +69,7 @@ public class PlayerManagerAdapter extends RecyclerView.Adapter<PlayerViewHolder>
.create();
removeDialog.show();
} else {
AlertDialog removeDialog = new AlertDialog.Builder(ctx, R.style.dialogTheme)
AlertDialog removeDialog = new AlertDialogPro.Builder(ctx, R.style.dialogTheme)
.setMessage("Do you want to remove player: " + playerName + "?")
.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
......
package com.eyecreate.miceandmystics.miceandmystics.model.Enums;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public enum Abilities {
......@@ -52,6 +54,16 @@ public enum Abilities {
return false;
}
public static Abilities[] getMatchingCharacterAbilities(CharacterType[] matchingTypes) {
List<Abilities> matchingList = new ArrayList<Abilities>();
for(Abilities ability:Abilities.values()) {
if(ability.doesApply(matchingTypes)) {
matchingList.add(ability);
}
}
return matchingList.toArray(new Abilities[matchingList.size()]);
}
public String displayName() { return displayName; }
@Override public String toString() { return displayName; }
......
......@@ -2,10 +2,13 @@ package com.eyecreate.miceandmystics.miceandmystics.viewholders;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.alertdialogpro.AlertDialogPro;
import com.eyecreate.miceandmystics.miceandmystics.CharacterDetailsActivity;
import com.eyecreate.miceandmystics.miceandmystics.R;
import com.eyecreate.miceandmystics.miceandmystics.adapters.CampaignDetailsAdapter;
import com.eyecreate.miceandmystics.miceandmystics.model.Character;
......@@ -37,12 +40,14 @@ public class CampaignDetailsViewHolder extends RecyclerView.ViewHolder implement
@Override
public void onClick(View view) {
//TODO:implement character edit screen.
Intent editCharacter = new Intent(view.getContext(), CharacterDetailsActivity.class);
editCharacter.putExtra("characterId",boundCharacter.getUuid());
view.getContext().startActivity(editCharacter);
}
@Override
public boolean onLongClick(View view) {
AlertDialog removeDialog = new AlertDialog.Builder(view.getContext(),R.style.dialogTheme)
AlertDialog removeDialog = new AlertDialogPro.Builder(view.getContext(),R.style.dialogTheme)
.setMessage("Do you want to remove character: "+characterName.getText()+"?")
.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
......
......@@ -9,6 +9,7 @@ import android.support.v7.widget.RecyclerView;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
import com.alertdialogpro.AlertDialogPro;
import com.echo.holographlibrary.PieGraph;
import com.echo.holographlibrary.PieSlice;
import com.eyecreate.miceandmystics.miceandmystics.CampaignDetailsActivity;
......@@ -74,7 +75,7 @@ public class CampaignViewHolder extends RecyclerView.ViewHolder implements View.
@Override
public boolean onLongClick(View view) {
AlertDialog removeDialog = new AlertDialog.Builder(view.getContext(),R.style.dialogTheme)
AlertDialog removeDialog = new AlertDialogPro.Builder(view.getContext(),R.style.dialogTheme)
.setMessage("Do you want to remove campaign: "+campaignName.getText()+"?")
.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
......
package com.eyecreate.miceandmystics.miceandmystics.viewholders;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import com.eyecreate.miceandmystics.miceandmystics.R;
import com.eyecreate.miceandmystics.miceandmystics.model.Character;
public class CharacterAbilityHeaderViewHolder extends RecyclerView.ViewHolder {
TextView characterName;
public CharacterAbilityHeaderViewHolder(View itemView) {
super(itemView);
characterName = (TextView) itemView.findViewById(R.id.character_name);
}
public void bindHolder(Character currentCharacter) {
characterName.setText(currentCharacter.getCharacterName());
}
}
package com.eyecreate.miceandmystics.miceandmystics.viewholders;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import com.alertdialogpro.AlertDialogPro;
import com.eyecreate.miceandmystics.miceandmystics.R;
import com.eyecreate.miceandmystics.miceandmystics.adapters.CharacterDetailsAdapter;
import com.eyecreate.miceandmystics.miceandmystics.model.Ability;
public class CharacterAbilityViewHolder extends RecyclerView.ViewHolder implements View.OnLongClickListener {
CharacterDetailsAdapter adapter;
TextView abilityName;
String uuid;
public CharacterAbilityViewHolder(View itemView,CharacterDetailsAdapter adapter) {
super(itemView);
this.adapter = adapter;
abilityName = (TextView) itemView.findViewById(R.id.ability_name);
itemView.setOnLongClickListener(this);
}
public void bindHolder(Ability ability) {
abilityName.setText(ability.getAbilityName());
uuid = ability.getUuid();
}
@Override
public boolean onLongClick(View view) {
AlertDialog removeDialog = new AlertDialogPro.Builder(view.getContext(),R.style.dialogTheme)
.setMessage("Do you want to remove ability: "+abilityName.getText()+"?")
.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
})
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
adapter.removeAbility(uuid);
}
})
.create();
removeDialog.show();
return true;
}
}
package com.eyecreate.miceandmystics.miceandmystics.viewholders;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import com.alertdialogpro.AlertDialogPro;
import com.eyecreate.miceandmystics.miceandmystics.R;
import com.eyecreate.miceandmystics.miceandmystics.adapters.CharacterDetailsAdapter;
import com.eyecreate.miceandmystics.miceandmystics.model.BackpackItem;
public class CharacterItemViewHolder extends RecyclerView.ViewHolder implements View.OnLongClickListener {
CharacterDetailsAdapter adapter;
TextView itemName;
String uuid;
public CharacterItemViewHolder(View itemView,CharacterDetailsAdapter adapter) {
super(itemView);
this.adapter = adapter;
itemName = (TextView) itemView.findViewById(R.id.item_name);
itemView.setOnLongClickListener(this);
}
public void bindModel(BackpackItem item) {
itemName.setText(item.getItemName());
uuid = item.getUuid();
}
@Override
public boolean onLongClick(View view) {
AlertDialog removeDialog = new AlertDialogPro.Builder(view.getContext(),R.style.dialogTheme)
.setMessage("Do you want to remove item: "+itemName.getText()+"?")
.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
})
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
adapter.removeItem(uuid);
}
})
.create();
removeDialog.show();
return true;
}
}
package com.eyecreate.miceandmystics.miceandmystics.viewholders;
import android.support.v7.widget.RecyclerView;
import android.view.View;
public class CharacterItemsHeaderViewHolder extends RecyclerView.ViewHolder {
public CharacterItemsHeaderViewHolder(View itemView) {
super(itemView);
}
}
......@@ -6,6 +6,7 @@ import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.alertdialogpro.AlertDialogPro;
import com.eyecreate.miceandmystics.miceandmystics.R;
import com.eyecreate.miceandmystics.miceandmystics.adapters.CampaignDetailsAdapter;
import com.eyecreate.miceandmystics.miceandmystics.model.Achievement;
......@@ -33,7 +34,7 @@ public class PartyAchievementViewHolder extends RecyclerView.ViewHolder implemen
@Override
public boolean onLongClick(View view) {
AlertDialog removeDialog = new AlertDialog.Builder(view.getContext(),R.style.dialogTheme)
AlertDialog removeDialog = new AlertDialogPro.Builder(view.getContext(),R.style.dialogTheme)
.setMessage("Do you want to remove achievement: "+achievementName.getText()+"?")
.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:padding="12dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/ability_name"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:padding="12dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/item_name"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"