diff options
Diffstat (limited to 'vdrmanager')
8 files changed, 89 insertions, 64 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java index 569f59e..de3d42e 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java @@ -12,14 +12,12 @@ import android.view.View.OnClickListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; -import android.widget.TextView; import android.widget.ViewFlipper; import com.actionbarsherlock.app.ActionBar.OnNavigationListener; import de.bjusystems.vdrmanager.R; import de.bjusystems.vdrmanager.app.VdrManagerApp; -import de.bjusystems.vdrmanager.data.Cache; import de.bjusystems.vdrmanager.data.Channel; import de.bjusystems.vdrmanager.data.Preferences; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncTask; @@ -32,7 +30,7 @@ import de.bjusystems.vdrmanager.utils.svdrp.SvdrpListener; public abstract class BaseActivity<Result, T extends ListView> extends ICSBaseActivity implements OnClickListener, SvdrpListener, - SvdrpExceptionListener, SvdrpFinishedListener<Result>, Cache { + SvdrpExceptionListener, SvdrpFinishedListener<Result> { public static final String TAG = BaseActivity.class.getName(); @@ -209,8 +207,6 @@ public abstract class BaseActivity<Result, T extends ListView> extends progress = new ProgressDialog(this); - getApp().addActivityToFinish(this); - initActionBar(); initListNavigation(); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BasePreferencesActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BasePreferencesActivity.java index eedb3f9..168eef3 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BasePreferencesActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BasePreferencesActivity.java @@ -68,7 +68,7 @@ public abstract class BasePreferencesActivity extends PreferenceActivity { return false; } - protected void setSummary(CharSequence text, DialogPreference ep){ + protected void setSummary(CharSequence text, Preference ep){ CharSequence sm = ep.getSummary(); String sum; if (sm != null) { diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java index 42d995d..2a3b03d 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java @@ -10,6 +10,7 @@ import android.view.View.OnClickListener; import android.widget.AdapterView; import de.bjusystems.vdrmanager.R; import de.bjusystems.vdrmanager.app.Intents; +import de.bjusystems.vdrmanager.data.CACHE; import de.bjusystems.vdrmanager.data.Event; import de.bjusystems.vdrmanager.data.EventListItem; import de.bjusystems.vdrmanager.data.Timer; @@ -189,10 +190,14 @@ public abstract class BaseTimerEditActivity<T extends Event> extends */ protected void timerModified(final Timer timer) { backupViewSelection(); + if(timer != null && timer.getChannelId()!=null){ + CACHE.CACHE.remove(timer.getChannelId()); + } // say(R.string.update_will_start_in); // Runnable task = new Runnable() { // public void run() { refresh(); + // } // }; // worker.schedule(task, 1000, TimeUnit.MILLISECONDS); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java index d3b9e57..990488d 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java @@ -604,10 +604,4 @@ public class ChannelListActivity extends protected int getListNavigationIndex() { return LIST_NAVIGATION_CHANNELS; } - - @Override - public void clearCache() { - ChannelClient.clearCache(); - } - }
\ No newline at end of file diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java index 3256343..c67e4dc 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java @@ -23,6 +23,7 @@ import android.widget.TextView; import android.widget.Toast; import de.bjusystems.vdrmanager.R; import de.bjusystems.vdrmanager.app.VdrManagerApp; +import de.bjusystems.vdrmanager.data.CACHE; import de.bjusystems.vdrmanager.data.Channel; import de.bjusystems.vdrmanager.data.Epg; import de.bjusystems.vdrmanager.data.Event; @@ -59,10 +60,6 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements // protected static ArrayList<Epg> CACHE = new ArrayList<Epg>(); - private static WeakHashMap<String, ArrayList<Epg>> CACHE = new WeakHashMap<String, ArrayList<Epg>>(); - - private static WeakHashMap<String, Date> NEXT_REFRESH = new WeakHashMap<String, Date>(); - private TextView audio; private View channelInfo; @@ -201,23 +198,23 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements public void clearCache() { getCache().clear(); - CACHE.remove(currentChannel.getId()); - NEXT_REFRESH.remove(currentChannel.getId()); + CACHE.CACHE.remove(currentChannel.getId()); + CACHE.NEXT_REFRESH.remove(currentChannel.getId()); } private boolean useCache() { - if(currentChannel == null){ + if (currentChannel == null) { return false; } - ArrayList<Epg> cachedChannel = CACHE.get(currentChannel.getId()) ; + ArrayList<Epg> cachedChannel = CACHE.CACHE.get(currentChannel.getId()); if (cachedChannel == null) { return false; } - Date nextForceCache = NEXT_REFRESH.get(currentChannel.getId()); + Date nextForceCache = CACHE.NEXT_REFRESH.get(currentChannel.getId()); if (nextForceCache == null) { return false; @@ -274,18 +271,10 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements task.run(); } - @Override - protected void timerModified(Timer timer) { - if(timer != null){ - CACHE.remove(timer.getChannelId()); - } - super.timerModified(timer); - } - private static final ArrayList<Epg> EMPTY = new ArrayList<Epg>(0); private ArrayList<Epg> getCache() { - ArrayList<Epg> arrayList = CACHE.get(currentChannel.getId()); + ArrayList<Epg> arrayList = CACHE.CACHE.get(currentChannel.getId()); if (arrayList == null) { return EMPTY; } @@ -297,8 +286,7 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements adapter.clear(); - - ArrayList<Epg> cache = getCache(); + ArrayList<Epg> cache = getCache(); if (cache.isEmpty()) { return; @@ -342,8 +330,7 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements Date now = new Date(); - - NEXT_REFRESH.put(currentChannel.getId(), FUTURE); + CACHE.NEXT_REFRESH.put(currentChannel.getId(), FUTURE); Date nextForceCache = FUTURE; @@ -366,8 +353,8 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements } } - NEXT_REFRESH.put(currentChannel.getId(), nextForceCache); - CACHE.put(currentChannel.getId(), cache); + CACHE.NEXT_REFRESH.put(currentChannel.getId(), nextForceCache); + CACHE.CACHE.put(currentChannel.getId(), cache); fillAdapter(); listView.setSelectionAfterHeaderView(); @@ -479,9 +466,4 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements return super.onOptionsItemSelected(item); } - // @Override - // protected void timerModified() { - // cachedChannel = null; - // } - } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/PreferencesActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/PreferencesActivity.java index 9555e8a..e8ae690 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/PreferencesActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/PreferencesActivity.java @@ -17,7 +17,7 @@ import de.bjusystems.vdrmanager.data.Preferences; public class PreferencesActivity extends BasePreferencesActivity implements OnSharedPreferenceChangeListener, OnPreferenceChangeListener, OnPreferenceClickListener { -// +// // Preference somePreference = findPreference(SOME_PREFERENCE_KEY); // PreferenceScreen preferenceScreen = getPreferenceScreen(); // preferenceScreen.removePreference(somePreference); @@ -35,7 +35,7 @@ public class PreferencesActivity extends BasePreferencesActivity implements Preferences.getPreferenceFile(this)); this.addPreferencesFromResource(R.xml.preferences); - + Preference backupPreference = findPreference(getString(R.string.settings_backup_key)); backupPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override @@ -46,7 +46,7 @@ public class PreferencesActivity extends BasePreferencesActivity implements return true; } }); - + updateChildPreferences(); } @@ -82,27 +82,25 @@ public class PreferencesActivity extends BasePreferencesActivity implements updateSummary(p); } - + } @Override public void onBackPressed() { - - //Preferences.getSharedPreferences(this) //.registerOnSharedPreferenceChangeListener(this); // finish this activity - final VdrManagerApp app = (VdrManagerApp) getApplication(); - app.addActivityToFinish(this); - app.finishActivities(); - //Preferences.init(this); // restart main activity because // the buttons needs refreshing - final Intent intent = new Intent(); - intent.setClass(this, VdrManagerActivity.class); + Intent intent = new Intent(this, VdrManagerActivity.class); + int flags = Intent.FLAG_ACTIVITY_NEW_TASK + | Intent.FLAG_ACTIVITY_SINGLE_TOP + | Intent.FLAG_ACTIVITY_CLEAR_TOP; + intent.setFlags(flags); startActivity(intent); + finish(); } public void onSharedPreferenceChanged(SharedPreferences arg0, String key) { @@ -142,5 +140,5 @@ public class PreferencesActivity extends BasePreferencesActivity implements return true; } - + } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java index 678a54e..7c5da2c 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java @@ -126,14 +126,13 @@ public class VdrManagerActivity extends SherlockActivity implements switch (item.getItemId()) { case R.id.main_menu_preferences: { - // remember activity for finishing - final VdrManagerApp app = (VdrManagerApp) getApplication(); - app.clearActivitiesToFinish(); - app.addActivityToFinish(this); - - Intent intent = new Intent(); - intent.setClass(this, PreferencesActivity.class); + Intent intent = new Intent(this, PreferencesActivity.class); + int flags = Intent.FLAG_ACTIVITY_NEW_TASK + | Intent.FLAG_ACTIVITY_SINGLE_TOP + | Intent.FLAG_ACTIVITY_CLEAR_TOP; + intent.setFlags(flags); startActivity(intent); + finish(); break; } case R.id.main_menu_info: { @@ -195,8 +194,6 @@ public class VdrManagerActivity extends SherlockActivity implements R.string.main_menu_switched_to, vdr.getName()), Toast.LENGTH_SHORT).show(); - ((VdrManagerApp) getApplication()) - .finishActivities(); Intent intent = getIntent(); overridePendingTransition(0, 0); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrPreferencesActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrPreferencesActivity.java index d3ec64c..c166333 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrPreferencesActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrPreferencesActivity.java @@ -7,13 +7,18 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; +import android.app.Activity; import android.app.ProgressDialog; +import android.content.Intent; import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Bundle; import android.preference.Preference; +import android.preference.Preference.OnPreferenceClickListener; import android.view.View; import de.bjusystems.vdrmanager.R; +import de.bjusystems.vdrmanager.ZonePicker; import de.bjusystems.vdrmanager.app.Intents; import de.bjusystems.vdrmanager.data.MacFetchEditTextPreference; import de.bjusystems.vdrmanager.data.Preferences; @@ -23,7 +28,9 @@ import de.bjusystems.vdrmanager.data.db.DBAccess; import de.bjusystems.vdrmanager.tasks.VoidAsyncTask; public class VdrPreferencesActivity extends BasePreferencesActivity implements - OnSharedPreferenceChangeListener { + OnSharedPreferenceChangeListener, OnPreferenceClickListener { + + public static final int REQUEST_CODE_PICK_A_TIME_ZONE = 1; Vdr vdr; @@ -41,6 +48,19 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements return super.findPreference(key); } + + @Override + protected void updateSummary(Preference ep) { + if(ep.getKey().equals("key_timezone")) { + String text = vdr.getServerTimeZone(); + if (text == null) { + return; + } + setSummary(text, ep); + return; + } + super.updateSummary(ep); + } private void initVDRInstance() { id = getIntent().getIntExtra(Intents.VDR_ID, -1); if (id == -1) {// new vdr @@ -207,6 +227,9 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements }); updateChildPreferences(); + + findPreference(getString(R.string.timezone_key)).setOnPreferenceClickListener(this); + } public void onSharedPreferenceChanged(SharedPreferences arg0, String key) { @@ -338,4 +361,34 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements super.onBackPressed(); } + @Override + public boolean onPreferenceClick(Preference preference) { + + String timezone = vdr.getServerTimeZone(); + + Intent intent = new Intent(this, ZonePicker.class); + intent.putExtra("current_tz", timezone); + startActivityForResult(intent, REQUEST_CODE_PICK_A_TIME_ZONE); + return true; + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if(resultCode != Activity.RESULT_OK){ + super.onActivityResult(requestCode, resultCode, data); + return; + } + + if(requestCode == REQUEST_CODE_PICK_A_TIME_ZONE){ + String ntz = data.getStringExtra("new_tz"); + if(ntz != null){ + vdr.setServerTimeZone(ntz); + Editor editor = findPreference("key_timezone").getEditor(); + editor.putString("key_timezone", ntz); + editor.commit(); + //setSummary(ntz, ); + } + } + } + } |