summaryrefslogtreecommitdiffstats
path: root/src/ryuslash/org/dvdroid/AddDVDActivity.java
blob: f6612f7b6d1fb4966329d6fe6b5b2fb1c7eca02f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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();
    }
}