Commit f0753180 authored by Kevin Whitaker's avatar Kevin Whitaker

Add in campaign type in order to allow expansions easier. Allow campaign...

Add in campaign type in order to allow expansions easier. Allow campaign details page to come up with nothing. Add helper methods to try and convert nice string back to enums. Start working on detail header too.
parent 07b12075
...@@ -4,3 +4,5 @@ ...@@ -4,3 +4,5 @@
/.idea/libraries /.idea/libraries
.DS_Store .DS_Store
/build /build
gradlew.bat
\ No newline at end of file
package com.eyecreate.miceandmystics.miceandmystics; package com.eyecreate.miceandmystics.miceandmystics;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.view.ContextThemeWrapper; import android.view.*;
import android.view.Menu; import android.widget.ArrayAdapter;
import android.view.MenuItem;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Spinner;
import com.eyecreate.miceandmystics.miceandmystics.adapters.CampaignAdapter; import com.eyecreate.miceandmystics.miceandmystics.adapters.CampaignAdapter;
import com.eyecreate.miceandmystics.miceandmystics.model.Enums.CampaignType;
public class CampaignActivity extends RecyclerViewActivity { public class CampaignActivity extends RecyclerViewActivity {
...@@ -40,15 +42,18 @@ public class CampaignActivity extends RecyclerViewActivity { ...@@ -40,15 +42,18 @@ public class CampaignActivity extends RecyclerViewActivity {
//noinspection SimplifiableIfStatement //noinspection SimplifiableIfStatement
if (id == R.id.action_add_campaign) { if (id == R.id.action_add_campaign) {
final EditText newName = new EditText(new ContextThemeWrapper(this,R.style.editTextDialogTheme)); LayoutInflater inflator = (LayoutInflater)(new ContextThemeWrapper(this, R.style.dialogTheme)).getSystemService(Context.LAYOUT_INFLATER_SERVICE);
newName.setTypeface(Typeface.createFromAsset(getAssets(),"ArchitectsDaughter.ttf")); final View dialogView = inflator.inflate(R.layout.dialog_new_campaign, null, false);
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 AlertDialog.Builder(this,R.style.dialogTheme)
.setMessage("Please give your new campaign a unique name:") .setMessage("Please give your new campaign a unique name:")
.setView(newName) .setView(dialogView)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() { .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
((CampaignAdapter) getAdapter()).addItem(newName.getText().toString()); ((CampaignAdapter) getAdapter()).addItem(((EditText) dialogView.findViewById(R.id.campagin_name)).getText().toString(), CampaignType.valueOfDisplayName(typeSpinner.getSelectedItem().toString()));
} }
}) })
.create(); .create();
......
package com.eyecreate.miceandmystics.miceandmystics; package com.eyecreate.miceandmystics.miceandmystics;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import com.eyecreate.miceandmystics.miceandmystics.model.Campaign;
public class CampaignDetailsActivity extends ActionBarActivity { public class CampaignDetailsActivity extends RecyclerViewActivity {
Campaign campaign;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_campaign_details); setTitle(getIntent().getStringExtra("campaignName"));
campaign = MiceAndMysticsApplication.getRealmInstance().where(Campaign.class).equalTo("campaignName",getIntent().getStringExtra("campaignName")).findFirst();
setLayoutManager(new LinearLayoutManager(this));
} }
...@@ -30,7 +35,7 @@ public class CampaignDetailsActivity extends ActionBarActivity { ...@@ -30,7 +35,7 @@ public class CampaignDetailsActivity extends ActionBarActivity {
int id = item.getItemId(); int id = item.getItemId();
//noinspection SimplifiableIfStatement //noinspection SimplifiableIfStatement
if (id == R.id.action_settings) { if (id == R.id.action_add_character) {
return true; return true;
} }
......
...@@ -6,6 +6,7 @@ import android.view.LayoutInflater; ...@@ -6,6 +6,7 @@ import android.view.LayoutInflater;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.eyecreate.miceandmystics.miceandmystics.MiceAndMysticsApplication; import com.eyecreate.miceandmystics.miceandmystics.MiceAndMysticsApplication;
import com.eyecreate.miceandmystics.miceandmystics.R; import com.eyecreate.miceandmystics.miceandmystics.R;
import com.eyecreate.miceandmystics.miceandmystics.model.Enums.CampaignType;
import com.eyecreate.miceandmystics.miceandmystics.viewholders.Campaign; import com.eyecreate.miceandmystics.miceandmystics.viewholders.Campaign;
import io.realm.RealmResults; import io.realm.RealmResults;
...@@ -33,10 +34,11 @@ public class CampaignAdapter extends RecyclerView.Adapter<Campaign> { ...@@ -33,10 +34,11 @@ public class CampaignAdapter extends RecyclerView.Adapter<Campaign> {
notifyDataSetChanged(); notifyDataSetChanged();
} }
public void addItem(String campaignName) { public void addItem(String campaignName,CampaignType type) {
MiceAndMysticsApplication.getRealmInstance().beginTransaction(); MiceAndMysticsApplication.getRealmInstance().beginTransaction();
com.eyecreate.miceandmystics.miceandmystics.model.Campaign campaign = new com.eyecreate.miceandmystics.miceandmystics.model.Campaign(); com.eyecreate.miceandmystics.miceandmystics.model.Campaign campaign = new com.eyecreate.miceandmystics.miceandmystics.model.Campaign();
campaign.setCampaignName(campaignName); campaign.setCampaignName(campaignName);
campaign.setCampaignType(type.displayName());
MiceAndMysticsApplication.getRealmInstance().copyToRealm(campaign); MiceAndMysticsApplication.getRealmInstance().copyToRealm(campaign);
MiceAndMysticsApplication.getRealmInstance().commitTransaction(); MiceAndMysticsApplication.getRealmInstance().commitTransaction();
fullRefresh(); fullRefresh();
......
package com.eyecreate.miceandmystics.miceandmystics.adapters;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import com.eyecreate.miceandmystics.miceandmystics.viewholders.CampaignDetails;
public class CampaignDetailsAdapter extends RecyclerView.Adapter<CampaignDetails> {
@Override
public CampaignDetails onCreateViewHolder(ViewGroup parent, int viewType) {
return null;
}
@Override
public void onBindViewHolder(CampaignDetails holder, int position) {
}
@Override
public int getItemCount() {
return 0;
}
}
...@@ -7,6 +7,7 @@ import io.realm.annotations.PrimaryKey; ...@@ -7,6 +7,7 @@ import io.realm.annotations.PrimaryKey;
public class Campaign extends RealmObject { public class Campaign extends RealmObject {
@PrimaryKey @PrimaryKey
private String campaignName; private String campaignName;
private String campaignType;
private RealmList<Character> currentCharacters; private RealmList<Character> currentCharacters;
private RealmList<Achievement> partyStoryAchievements; private RealmList<Achievement> partyStoryAchievements;
...@@ -33,4 +34,12 @@ public class Campaign extends RealmObject { ...@@ -33,4 +34,12 @@ public class Campaign extends RealmObject {
public void setCampaignName(String campaignName) { public void setCampaignName(String campaignName) {
this.campaignName = campaignName; this.campaignName = campaignName;
} }
public String getCampaignType() {
return campaignType;
}
public void setCampaignType(String campaignType) {
this.campaignType = campaignType;
}
} }
...@@ -55,4 +55,5 @@ public enum Abilities { ...@@ -55,4 +55,5 @@ public enum Abilities {
public String displayName() { return displayName; } public String displayName() { return displayName; }
@Override public String toString() { return displayName; } @Override public String toString() { return displayName; }
public Abilities valueOfDisplayName(String valuedDisplayName) {return Abilities.valueOf(valuedDisplayName.replace(" ","_"));}
} }
...@@ -17,4 +17,5 @@ public enum Achievement { ...@@ -17,4 +17,5 @@ public enum Achievement {
public String displayName() { return displayName; } public String displayName() { return displayName; }
@Override public String toString() { return displayName; } @Override public String toString() { return displayName; }
public Achievement valueOfDisplayName(String valuedDisplayName) {return Achievement.valueOf(valuedDisplayName.replace(" ","_").replace("'",""));}
} }
package com.eyecreate.miceandmystics.miceandmystics.model.Enums;
public enum CampaignType {
Sorrow_and_Remembrance("Sorrow and Remembrance");
private String displayName;
CampaignType(String name) {
this.displayName = name;
}
public String displayName() { return displayName; }
@Override public String toString() { return displayName; }
public static CampaignType valueOfDisplayName(String valuedDisplayName) {return CampaignType.valueOf(valuedDisplayName.replace(" ","_"));}
}
...@@ -3,12 +3,14 @@ package com.eyecreate.miceandmystics.miceandmystics.viewholders; ...@@ -3,12 +3,14 @@ package com.eyecreate.miceandmystics.miceandmystics.viewholders;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build; import android.os.Build;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import com.echo.holographlibrary.PieGraph; import com.echo.holographlibrary.PieGraph;
import com.eyecreate.miceandmystics.miceandmystics.CampaignDetailsActivity;
import com.eyecreate.miceandmystics.miceandmystics.R; import com.eyecreate.miceandmystics.miceandmystics.R;
import com.eyecreate.miceandmystics.miceandmystics.adapters.CampaignAdapter; import com.eyecreate.miceandmystics.miceandmystics.adapters.CampaignAdapter;
...@@ -43,7 +45,9 @@ public class Campaign extends RecyclerView.ViewHolder implements View.OnClickLis ...@@ -43,7 +45,9 @@ public class Campaign extends RecyclerView.ViewHolder implements View.OnClickLis
@Override @Override
public void onClick(View view) { public void onClick(View view) {
//TODO:implement next screen Intent openCampaignDetails = new Intent(view.getContext(), CampaignDetailsActivity.class);
openCampaignDetails.putExtra("campaignName",campaignName.getText().toString());
view.getContext().startActivity(openCampaignDetails);
} }
public void bindModel(com.eyecreate.miceandmystics.miceandmystics.model.Campaign campaign) { public void bindModel(com.eyecreate.miceandmystics.miceandmystics.model.Campaign campaign) {
......
package com.eyecreate.miceandmystics.miceandmystics.viewholders;
import android.support.v7.widget.RecyclerView;
import android.view.View;
public class CampaignDetails extends RecyclerView.ViewHolder {
public CampaignDetails(View itemView) {
super(itemView);
}
}
package com.eyecreate.miceandmystics.miceandmystics.viewholders;
public class CampaignHeader {
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.eyecreate.miceandmystics.miceandmystics.CampaignDetailsActivity">
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/campagin_name"/>
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/campaign_type"/>
</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:layout_width="match_parent"
android:layout_height="match_parent">
</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:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/campaign_name"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/campaign_type"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:textAlignment="inherit"/>
\ No newline at end of file
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
tools:context="com.eyecreate.miceandmystics.miceandmystics.CampaignDetailsActivity"> tools:context="com.eyecreate.miceandmystics.miceandmystics.CampaignDetailsActivity">
<item android:id="@+id/action_settings" <item android:id="@+id/action_add_character"
android:title="@string/action_settings" android:title="Add Character"
android:orderInCategory="100" android:icon="@android:drawable/ic_menu_add"
app:showAsAction="never"/> app:showAsAction="always"/>
</menu> </menu>
...@@ -22,9 +22,4 @@ ...@@ -22,9 +22,4 @@
<item name="android:textColorPrimary">@android:color/black</item> <item name="android:textColorPrimary">@android:color/black</item>
</style> </style>
<style name="editTextDialogTheme" parent="Widget.AppCompat.EditText">
<item name="colorAccent">@color/wood_brown</item>
<item name="android:textColorPrimary">@android:color/black</item>
</style>
</resources> </resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment