summaryrefslogtreecommitdiff
path: root/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java
blob: bc55f3c55bc380b10855202d4947211a217dbfe2 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package de.bjusystems.vdrmanager.gui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.app.VdrManagerApp;
import de.bjusystems.vdrmanager.data.Preferences;
import de.bjusystems.vdrmanager.utils.wakeup.AsyncWakeupTask;

public class VdrManagerActivity extends Activity implements OnClickListener {

	
	@Override
	protected void onCreate(final Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// attach view
		setContentView(R.layout.vdrmanager);

		Preferences.loadPreferences(this);

		findViewById(R.id.action_menu_channels).setOnClickListener(this);
		findViewById(R.id.action_menu_recordings).setOnClickListener(this);
		findViewById(R.id.action_menu_timers).setOnClickListener(this);
		findViewById(R.id.action_menu_epg).setOnClickListener(this);
		findViewById(R.id.action_menu_search).setOnClickListener(this);
		
		if(Preferences.get().isWakeupEnabled() == false){
			findViewById(R.id.action_menu_wakeup).setVisibility(View.GONE);
		} else {
			findViewById(R.id.action_menu_wakeup).setOnClickListener(this);
		}

		// add and register buttons
		// createButtons();
	}

	@Override
	public boolean onCreateOptionsMenu(final Menu menu) {
		super.onCreateOptionsMenu(menu);

		final MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.main_menu, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(final MenuItem item) {

		switch (item.getItemId()) {
		case R.id.main_menu_preferences:
			// remember activity for finishing
			final VdrManagerApp app = (VdrManagerApp) getApplication();
			app.clearActivitiesToFinish();
			app.addActivityToFinish(this);

			final Intent intent = new Intent();
			intent.setClass(this, PreferencesActivity.class);
			startActivity(intent);
			break;
		case R.id.main_menu_exit:
			finish();
			break;
		}
		return true;
	}

	@Override
	public void onBackPressed() {
	}
	
	public void startActivity(Class<?> clazz) {
		Intent intent = new Intent(Intent.ACTION_VIEW);
		intent.setClass(this, clazz);
		startActivity(intent);
	}

	public void onClick(View v) {
		int id = v.getId();

		switch (id) {
		case R.id.action_menu_channels:
			startActivity(ChannelListActivity.class);
			break;
		case R.id.action_menu_recordings:
			startActivity(RecordingListActivity.class);
			break;
		case R.id.action_menu_timers:
			startActivity(TimerListActivity.class);
			break;
		case R.id.action_menu_epg:
			startActivity(TimeEpgListActivity.class);
			break;
		case R.id.action_menu_search:
			startActivity(EpgSearchActivity.class);
			break;
		case R.id.action_menu_wakeup:
			final AsyncWakeupTask wakeupTask = new AsyncWakeupTask(this);
			wakeupTask.execute();
			break;
		}

	}
}