diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 9b0638a..4c34e76 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -11,5 +11,6 @@
+
diff --git a/res/layout/add.xml b/res/layout/add.xml
new file mode 100644
index 0000000..22430f3
--- /dev/null
+++ b/res/layout/add.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/res/layout/main.xml b/res/layout/main.xml
index f109163..925b362 100644
--- a/res/layout/main.xml
+++ b/res/layout/main.xml
@@ -3,23 +3,12 @@
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
-
-
-
-
+
DVDroid
- Enter A DVD title
+ Title...
+ On wishlist
+ Watched
Add
+ Save
diff --git a/src/ryuslash/org/dvdroid/AddDVDActivity.java b/src/ryuslash/org/dvdroid/AddDVDActivity.java
new file mode 100644
index 0000000..f6612f7
--- /dev/null
+++ b/src/ryuslash/org/dvdroid/AddDVDActivity.java
@@ -0,0 +1,59 @@
+package ryuslash.org.dvdroid;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.CheckBox;
+import android.widget.EditText;
+
+public class AddDVDActivity extends Activity
+{
+ private DVDDataSource datasource;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.add);
+
+ datasource = new DVDDataSource(this);
+ datasource.open();
+ }
+
+ public void saveDVD(View view)
+ {
+ EditText name_entry = (EditText)findViewById(R.id.name_entry);
+ CheckBox watched_entry =
+ (CheckBox)findViewById(R.id.watched_entry);
+ CheckBox wishlist_entry =
+ (CheckBox)findViewById(R.id.wishlist_entry);
+
+ datasource.createDVD(name_entry.getText().toString(),
+ watched_entry.isChecked() ? 1 : 0,
+ wishlist_entry.isChecked() ? 1 : 0);
+
+ finish();
+ }
+
+ @Override
+ protected void onResume()
+ {
+ datasource.open();
+ super.onResume();
+ }
+
+ @Override
+ protected void onPause()
+ {
+ datasource.close();
+ super.onPause();
+ }
+
+ @Override
+ protected void onDestroy()
+ {
+ datasource.close();
+ super.onDestroy();
+ }
+}
diff --git a/src/ryuslash/org/dvdroid/DVDDataSource.java b/src/ryuslash/org/dvdroid/DVDDataSource.java
index 428ecc4..6658c8d 100644
--- a/src/ryuslash/org/dvdroid/DVDDataSource.java
+++ b/src/ryuslash/org/dvdroid/DVDDataSource.java
@@ -33,13 +33,13 @@ public class DVDDataSource
dbHelper.close();
}
- public DVD createDVD(String title)
+ public DVD createDVD(String title, int watched, int wishlist)
{
ContentValues values = new ContentValues();
values.put(SQLiteHelper.COLUMN_TITLE, title);
- values.put(SQLiteHelper.COLUMN_WATCHED, 0);
- values.put(SQLiteHelper.COLUMN_WISHLIST, 1);
+ values.put(SQLiteHelper.COLUMN_WATCHED, watched);
+ values.put(SQLiteHelper.COLUMN_WISHLIST, wishlist);
long insertId = database.insert(SQLiteHelper.TABLE_DVD, null,
values);
diff --git a/src/ryuslash/org/dvdroid/DVDroidActivity.java b/src/ryuslash/org/dvdroid/DVDroidActivity.java
index 20c1ad0..5a46286 100644
--- a/src/ryuslash/org/dvdroid/DVDroidActivity.java
+++ b/src/ryuslash/org/dvdroid/DVDroidActivity.java
@@ -4,6 +4,7 @@ import java.util.List;
import android.app.ListActivity;
import android.content.Context;
+import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
@@ -35,17 +36,10 @@ public class DVDroidActivity extends ListActivity
public void addDVD(View view)
{
- ArrayAdapter adapter = (ArrayAdapter)getListAdapter();
- EditText editText = (EditText)findViewById(R.id.name_entry);
- DVD dvd = datasource.createDVD(editText.getText().toString());
- int duration = Toast.LENGTH_SHORT;
- Toast toast = Toast.makeText(this, "Added " + editText.getText(),
- duration);
+ Intent intent = new Intent(this, AddDVDActivity.class);
- editText.setText("");
- adapter.add(dvd);
- adapter.notifyDataSetChanged();
- toast.show();
+ datasource.close();
+ startActivityForResult(intent, 1);
}
@Override
@@ -61,4 +55,20 @@ public class DVDroidActivity extends ListActivity
datasource.close();
super.onPause();
}
+
+ @Override
+ protected void onActivityResult(int requestCode,
+ int resultCode,
+ Intent data)
+ {
+ super.onActivityResult(requestCode, resultCode, data);
+ datasource.open();
+
+ ArrayAdapter adapter = (ArrayAdapter)getListAdapter();
+ List dvds = datasource.getWishlist();
+
+ adapter.clear();
+ adapter.addAll(dvds);
+ adapter.notifyDataSetChanged();
+ }
}