From 22805607a538bd4df422242e2725c1c02807dd8a Mon Sep 17 00:00:00 2001 From: lado Date: Tue, 1 Nov 2011 16:07:12 +0100 Subject: big refactoring --- .../src/de/bjusystems/vdrmanager/app/Intents.java | 5 +- .../bjusystems/vdrmanager/app/VdrManagerApp.java | 2 - .../de/bjusystems/vdrmanager/data/BaseEvent.java | 104 ------ .../src/de/bjusystems/vdrmanager/data/Epg.java | 2 +- .../vdrmanager/data/EpgSearchParams.java | 4 +- .../vdrmanager/data/EpgSearchTimeValue.java | 7 + .../vdrmanager/data/EpgSearchTimeValues.java | 6 +- .../src/de/bjusystems/vdrmanager/data/Event.java | 110 ++++++- .../bjusystems/vdrmanager/data/EventListItem.java | 2 +- .../de/bjusystems/vdrmanager/data/Recording.java | 2 +- .../src/de/bjusystems/vdrmanager/data/Timer.java | 2 +- .../de/bjusystems/vdrmanager/gui/BaseActivity.java | 144 +++++++-- .../vdrmanager/gui/BaseEventListActivity.java | 79 ++--- .../vdrmanager/gui/BaseTimerEditActivity.java | 287 +++-------------- .../vdrmanager/gui/ChannelListActivity.java | 174 +++------- .../vdrmanager/gui/EpgDetailsActivity.java | 349 ++++++++++++++++----- .../vdrmanager/gui/EpgSearchListActivity.java | 5 + .../vdrmanager/gui/EventEpgListActivity.java | 136 +++++++- .../vdrmanager/gui/RecordingListActivity.java | 9 +- .../vdrmanager/gui/SvdrpProgressDialog.java | 18 +- .../vdrmanager/gui/TimeEpgListActivity.java | 105 ++++++- .../vdrmanager/gui/TimerDetailsActivity.java | 242 +++++++------- .../vdrmanager/gui/TimerListActivity.java | 11 +- .../vdrmanager/gui/VdrManagerActivity.java | 32 +- .../vdrmanager/utils/svdrp/ChannelClient.java | 66 ++-- .../vdrmanager/utils/svdrp/EpgClient.java | 3 +- .../vdrmanager/utils/svdrp/SvdrpClient.java | 69 +++- 27 files changed, 1108 insertions(+), 867 deletions(-) delete mode 100644 vdrmanager/src/de/bjusystems/vdrmanager/data/BaseEvent.java (limited to 'vdrmanager/src') diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/app/Intents.java b/vdrmanager/src/de/bjusystems/vdrmanager/app/Intents.java index dc71105..853f772 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/app/Intents.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/app/Intents.java @@ -2,7 +2,10 @@ package de.bjusystems.vdrmanager.app; public interface Intents { - public static final String CURRENT_CHANNEL = "CURRENT_CHANNEL"; + //public static final String CURRENT_CHANNEL = "CURRENT_CHANNEL"; public static final String HIGHLIGHT = "HIGHLIGHT"; + public static final String TIMER_OP = "TIMER_OP"; + public static final int EDIT_TIMER = 0; + public static final int ADD_TIMER = 1; } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java b/vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java index 7be0259..c4dc2a4 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java @@ -60,7 +60,6 @@ public class VdrManagerApp extends Application { } public void setCurrentEvent(final Event currentEvent) { - clear(); this.currentEvent = currentEvent; //if (currentEvent.getTimer() != null) { //this.currentTimer = currentEvent.getTimer(); @@ -74,7 +73,6 @@ public class VdrManagerApp extends Application { } public void setCurrentTimer(final Timer currentTimer) { - clear(); this.currentTimer = currentTimer; } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/BaseEvent.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/BaseEvent.java deleted file mode 100644 index b044b1a..0000000 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/BaseEvent.java +++ /dev/null @@ -1,104 +0,0 @@ -package de.bjusystems.vdrmanager.data; - -import java.util.Date; - -import android.text.TextUtils; - -public abstract class BaseEvent implements Event { - - protected String channelNumber; - protected String channelName; - protected String title; - protected String shortText; - protected String description; - protected Date start; - protected Date stop; - - public BaseEvent(){ - - } - - public Timer createTimer() { - return new Timer(this); - } - - public TimerState getTimerState() { - return TimerState.None; - } - - public void setChannelNumber(String channelNumber) { - this.channelNumber = channelNumber; - } - - public void setChannelName(String channelName) { - this.channelName = channelName; - } - - public void setTitle(String title) { - this.title = title; - } - - public void setShortText(String shortText) { - this.shortText = shortText; - } - - public void setDescription(String description) { - this.description = description; - } - - public void setStart(Date start) { - this.start = start; - } - - public void setStop(Date stop) { - this.stop = stop; - } - - public BaseEvent(Event event) { - channelNumber = event.getChannelNumber(); - channelName = event.getChannelName(); - title = event.getTitle(); - shortText = event.getShortText(); - description = event.getDescription(); - start = event.getStart(); - stop = event.getStop(); - } - - public String getChannelNumber() { - return channelNumber; - } - - public String getChannelName() { - return channelName; - } - - public String getTitle() { - return title; - } - - public String getShortText() { - if (TextUtils.isEmpty(shortText) == false) { - return shortText; - } - if (TextUtils.isEmpty(description) == false) { - if (description.length() < 30) { - return description; - } - return TextUtils.substring(description, 0, 30) + "…"; - } - return shortText; - } - - public String getDescription() { - return description; - } - - public Date getStart() { - return start; - } - - public Date getStop() { - return stop; - } - -} diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Epg.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Epg.java index f9ca15a..721e839 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Epg.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Epg.java @@ -12,7 +12,7 @@ import static de.bjusystems.vdrmanager.gui.Utils.mapSpecialChars; * Class for EPG events * @author bju */ -public class Epg extends BaseEvent { +public class Epg extends Event { private Timer timer; diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/EpgSearchParams.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/EpgSearchParams.java index 62ca4e2..fbcac24 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/EpgSearchParams.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/EpgSearchParams.java @@ -2,6 +2,8 @@ package de.bjusystems.vdrmanager.data; import java.util.Date; +import de.bjusystems.vdrmanager.gui.Utils; + /** * Class for EPG events * @author bju @@ -38,6 +40,6 @@ public class EpgSearchParams { this.end = end; } public String toCommandLine() { - return title; + return Utils.unMapSpecialChars(title); } } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/EpgSearchTimeValue.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/EpgSearchTimeValue.java index 281b020..8ba9b5e 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/EpgSearchTimeValue.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/EpgSearchTimeValue.java @@ -18,13 +18,20 @@ public class EpgSearchTimeValue { this.text = ""; } + public String getText(){ + return text; + } + public String getValue() { switch (index) { + case -1: + return "adhoc"; case 0: return "now"; case 1: return "next"; default: + final String[] values = text.split(":"); final Calendar cal = new GregorianCalendar(); cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(values[0])); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/EpgSearchTimeValues.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/EpgSearchTimeValues.java index 6fba7ba..19878f3 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/EpgSearchTimeValues.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/EpgSearchTimeValues.java @@ -13,7 +13,6 @@ public class EpgSearchTimeValues { private final Context context; public EpgSearchTimeValues(final Context context) { - this.context = context; } @@ -38,9 +37,14 @@ public class EpgSearchTimeValues { } } + values.add(new EpgSearchTimeValue(-1, context.getString(R.string.epg_list_time_adhoc))); return values; } + public void append(EpgSearchTimeValue est){ + values.add(values.size() - 1, est); + } + public void saveValues(final List values) { // get old values diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Event.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Event.java index 8bf9270..0348441 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Event.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Event.java @@ -2,7 +2,106 @@ package de.bjusystems.vdrmanager.data; import java.util.Date; -public interface Event { +import android.text.TextUtils; + +public abstract class Event { + + protected String channelNumber; + protected String channelName; + protected String title; + protected String shortText; + protected String description; + protected Date start; + protected Date stop; + + public Event(){ + + } + + public Timer createTimer() { + return new Timer(this); + } + + public TimerState getTimerState() { + return TimerState.None; + } + + public void setChannelNumber(String channelNumber) { + this.channelNumber = channelNumber; + } + + public void setChannelName(String channelName) { + this.channelName = channelName; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setShortText(String shortText) { + this.shortText = shortText; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setStart(Date start) { + this.start = start; + } + + public void setStop(Date stop) { + this.stop = stop; + } + + public Event(Event event) { + channelNumber = event.getChannelNumber(); + channelName = event.getChannelName(); + title = event.getTitle(); + shortText = event.getShortText(); + description = event.getDescription(); + start = event.getStart(); + stop = event.getStop(); + } + + public String getChannelNumber() { + return channelNumber; + } + + public String getChannelName() { + return channelName; + } + + public String getTitle() { + return title; + } + + public String getShortText() { + if (TextUtils.isEmpty(shortText) == false) { + return shortText; + } + if (TextUtils.isEmpty(description) == false) { + if (description.length() < 30) { + return description; + } + return TextUtils.substring(description, 0, 30) + "…"; + } + return shortText; + } + + public String getDescription() { + return description; + } + + public Date getStart() { + return start; + } + + public Date getStop() { + return stop; + } + + public enum TimerState { None, @@ -13,12 +112,5 @@ public interface Event { ; } - String getChannelNumber(); - String getChannelName(); - String getTitle(); - String getDescription(); - String getShortText(); - Date getStart(); - Date getStop(); - TimerState getTimerState(); + } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/EventListItem.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/EventListItem.java index 1f1fd8f..e37aa3c 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/EventListItem.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/EventListItem.java @@ -8,7 +8,7 @@ import de.bjusystems.vdrmanager.gui.Utils; * TODO auf Event Interface umstellen und die Aufrufen an event * delegieren. Das hier ist nicht gut. */ -public class EventListItem extends BaseEvent { +public class EventListItem extends Event { Event event; diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Recording.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Recording.java index 378ec00..8209004 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Recording.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Recording.java @@ -8,7 +8,7 @@ import de.bjusystems.vdrmanager.app.C; import static de.bjusystems.vdrmanager.gui.Utils.mapSpecialChars; -public class Recording extends BaseEvent{ +public class Recording extends Event{ public Recording(String line) { final String[] words = StringUtils.splitPreserveAllTokens(line, C.DATA_SEPARATOR); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Timer.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Timer.java index fb79fde..7765a36 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Timer.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Timer.java @@ -15,7 +15,7 @@ import de.bjusystems.vdrmanager.utils.svdrp.SetTimerClient.TimerOperation; * * @author bju */ -public class Timer extends BaseEvent { +public class Timer extends Event { private static final int ENABLED = 1; private static final int INSTANT = 2; diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java index 5e2e49c..f4633b5 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java @@ -2,6 +2,8 @@ package de.bjusystems.vdrmanager.gui; import android.app.Activity; import android.app.AlertDialog; +import android.content.Context; +import android.net.ConnectivityManager; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -13,51 +15,46 @@ import android.widget.ViewFlipper; import de.bjusystems.vdrmanager.R; import de.bjusystems.vdrmanager.app.VdrManagerApp; import de.bjusystems.vdrmanager.data.Channel; +import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncListener; +import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException; -public abstract class BaseActivity extends Activity - implements OnClickListener { +public abstract class BaseActivity extends Activity + implements OnClickListener, SvdrpAsyncListener { + + public static final String TAG = BaseActivity.class.getName(); public static final int MENU_GROUP_REFRESH = 99; public static final int MENU_REFRESH = 99; protected T listView; - + protected ViewFlipper flipper; + private Button retry; + protected SvdrpProgressDialog progress; + abstract protected int getMainLayout(); - public void svdrpException(final SvdrpException exception) { - // Log.w(TAG, exception); - alert(getString(R.string.vdr_error_text, exception.getMessage())); - } - + protected void switchNoConnection() { - View view = findViewById(R.id.main_content); - if (view != null) { - view.setVisibility(View.GONE); + if (flipper == null) { + return; } - view = findViewById(R.id.no_connection_layout); - if (view != null) { - view.setVisibility(View.VISIBLE); - } - Button b = (Button) findViewById(R.id.retry_button); - b.setOnClickListener(this); + flipper.setDisplayedChild(1); + } + + protected void initFlipper() { + this.flipper = (ViewFlipper) findViewById(R.id.flipper); + retry = (Button) findViewById(R.id.retry_button); + retry.setOnClickListener(this); } public void onClick(View v) { if (v.getId() == R.id.retry_button) { - View view = findViewById(R.id.no_connection_layout); - if (view != null) { - view.setVisibility(View.GONE); - } - view = findViewById(R.id.main_content); - if (view != null) { - view.setVisibility(View.VISIBLE); - } retry(); } } @@ -83,7 +80,7 @@ public abstract class BaseActivity extends Activity public boolean onCreateOptionsMenu(final Menu menu) { MenuItem item; item = menu.add(MENU_GROUP_REFRESH, MENU_REFRESH, 0, R.string.refresh); - item.setIcon(android.R.drawable.ic_menu_rotate); + item.setIcon(R.drawable.ic_menu_refresh); item.setAlphabeticShortcut('r'); return true; } @@ -104,7 +101,7 @@ public abstract class BaseActivity extends Activity } } - protected void setAsCurrent(Channel channel) { + protected void setCurrent(Channel channel) { getApp().setCurrentChannel(channel); } @@ -127,6 +124,26 @@ public abstract class BaseActivity extends Activity Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); } + protected boolean noConnection(SvdrpEvent event) { + switch (event) { + case CONNECT_ERROR: + say(R.string.progress_connect_error); + switchNoConnection(); + break; + case FINISHED_ABNORMALY: + alert(R.string.progress_connect_finished_abnormal); + switchNoConnection(); + break; + case LOGIN_ERROR: + say(R.string.progress_login_error); + switchNoConnection(); + break; + default: + return false; + } + return true; + } + protected void alert(String msg) { new AlertDialog.Builder(this)// .setMessage(msg)// @@ -152,4 +169,77 @@ public abstract class BaseActivity extends Activity int index; int top; + protected boolean checkInternetConnection() { + ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); + // test for connection + if (cm.getActiveNetworkInfo() != null + && cm.getActiveNetworkInfo().isAvailable() + && cm.getActiveNetworkInfo().isConnected()) { + return true; + } + return false; + } + + public void svdrpEvent(final SvdrpEvent event, final Result result) { + + switch (event) { + + case ABORTED: + alert(R.string.aborted); + break; + case ERROR: + alert(R.string.epg_client_errors); + // say(R.string.epg_client_errors); + // dismiss(progress); + break; + case CONNECTING: + break; + case CONNECTED: + connected(); + break; + case CONNECT_ERROR: + case FINISHED_ABNORMALY: + case LOGIN_ERROR: + noConnection(event); + break; + case CACHE_HIT: + cacheHit(); + return; + case FINISHED_SUCCESS: + if (finishedSuccess() == false) { + say(R.string.epg_no_items); + } else { + restoreViewSelection(); + } + break; + case RESULT_RECEIVED: + resultReceived(result); + break; + } + } + + protected void cacheHit() { + + } + + /** + * @return false, if no results found + */ + protected abstract boolean finishedSuccess(); + + /** + * @param result + */ + protected abstract void resultReceived(Result result); + + protected void connected() { + + } + + public void svdrpException(final SvdrpException exception) { + progress.svdrpException(exception); + // Log.w(TAG, exception); + alert(getString(R.string.vdr_error_text, exception.getMessage())); + } + } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java index 7174803..f802b81 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java @@ -29,17 +29,14 @@ import de.bjusystems.vdrmanager.data.Event; import de.bjusystems.vdrmanager.data.EventListItem; import de.bjusystems.vdrmanager.gui.SimpleGestureFilter.SimpleGestureListener; import de.bjusystems.vdrmanager.utils.svdrp.EpgClient; -import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncListener; -import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException; /** * @author lado * */ -public abstract class BaseEventListActivity extends - BaseActivity implements OnItemClickListener, - SvdrpAsyncListener, SimpleGestureListener { +public abstract class BaseEventListActivity extends BaseActivity implements OnItemClickListener, + SimpleGestureListener { public static final String TAG = BaseEventListActivity.class.getName(); @@ -56,6 +53,7 @@ public abstract class BaseEventListActivity extends protected String highlight = null; protected static final Date FUTURE = new Date(Long.MAX_VALUE); + // private static final Date BEGIN = new Date(0); @@ -70,14 +68,17 @@ public abstract class BaseEventListActivity extends super.onCreate(savedInstanceState); // Attach view setContentView(getMainLayout()); - detector = new SimpleGestureFilter(this, this); setTitle(getWindowTitle()); + initFlipper(); + detector = new SimpleGestureFilter(this, this); + initChannel(); } private void initChannel() { - currentChannel = getIntent() - .getParcelableExtra(Intents.CURRENT_CHANNEL); + currentChannel = getApp().getCurrentChannel(); + //currentChannel = getIntent() + // .getParcelableExtra(Intents.CURRENT_CHANNEL); } private boolean refreshViewOnResume = false; @@ -153,10 +154,10 @@ public abstract class BaseEventListActivity extends Intent intent; switch (item.getItemId()) { - case R.id.epg_menu_search: +// case R.id.epg_menu_search: // startSearchManager(); - super.onSearchRequested(); - break; + // super.onSearchRequested(); + // break; case R.id.epg_menu_times: intent = new Intent(); intent.setClass(this, EpgSearchTimesListActivity.class); @@ -205,11 +206,6 @@ public abstract class BaseEventListActivity extends // find and remember item final EventListItem item = adapter.getItem(position); - if (item.isHeader()) { - return; - } - - // prepare timer if we want to program prepareTimer(item); // show details @@ -236,50 +232,19 @@ public abstract class BaseEventListActivity extends // } } - public void svdrpEvent(final SvdrpEvent event, final T result) { - - switch (event) { - case ABORTED: - alert(R.string.aborted); - break; - case ERROR: - alert(R.string.epg_client_errors); - // say(R.string.epg_client_errors); - // dismiss(progress); - break; - // case CONNECTING: - // break; - case CONNECTED: - results.clear(); - break; - case CONNECT_ERROR: - say(R.string.progress_connect_error); - switchNoConnection(); - break; - case FINISHED_ABNORMALY: - alert(R.string.progress_connect_finished_abnormal); - switchNoConnection(); - break; - case LOGIN_ERROR: - switchNoConnection(); - break; - case FINISHED_SUCCESS: - if (finishedSuccess() == false) { - say(R.string.epg_no_items); - } else { - restoreViewSelection(); - } - break; - case RESULT_RECEIVED: - resultReceived(result); - break; - } - } protected void resultReceived(Event result) { results.add(result); } + @Override + protected void connected() { + if(flipper != null){ + flipper.setDisplayedChild(0); + } + results.clear(); + } + @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); @@ -305,10 +270,6 @@ public abstract class BaseEventListActivity extends dialog.dismiss(); } - /** - * @return false, if no results found - */ - protected abstract boolean finishedSuccess(); public boolean onSearchRequested() { InputMethodManager inputMgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java index 55cc468..c9aec1d 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java @@ -1,14 +1,7 @@ package de.bjusystems.vdrmanager.gui; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; - -import android.app.AlertDialog; -import android.app.DatePickerDialog; -import android.app.DatePickerDialog.OnDateSetListener; -import android.app.TimePickerDialog; -import android.app.TimePickerDialog.OnTimeSetListener; +import android.app.Activity; +import android.content.Intent; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; import android.view.MenuInflater; @@ -16,77 +9,20 @@ import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; -import android.widget.Button; -import android.widget.DatePicker; -import android.widget.TextView; -import android.widget.TimePicker; import de.bjusystems.vdrmanager.R; +import de.bjusystems.vdrmanager.app.Intents; import de.bjusystems.vdrmanager.data.Event; import de.bjusystems.vdrmanager.data.EventFormatter; import de.bjusystems.vdrmanager.data.EventListItem; import de.bjusystems.vdrmanager.data.Timer; -import de.bjusystems.vdrmanager.tasks.CreateTimerTask; import de.bjusystems.vdrmanager.tasks.DeleteTimerTask; -import de.bjusystems.vdrmanager.tasks.ModifyTimerTask; import de.bjusystems.vdrmanager.tasks.ToggleTimerTask; -import de.bjusystems.vdrmanager.utils.svdrp.SetTimerClient.TimerOperation; +import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent; public abstract class BaseTimerEditActivity extends - BaseEventListActivity implements OnClickListener, OnDateSetListener, - OnTimeSetListener // SvdrpAsyncListener, + BaseEventListActivity implements OnClickListener // SvdrpAsyncListener, { - public class EditTimerViewHolder { - View view; - TextView title; - TextView channel; - TextView dateField; - TextView startField; - TextView endField; - Button saveButton; - Button modifyButton; - } - - EditTimerViewHolder tView = null; - AlertDialog tDialog = null; - - boolean editStart; - - // SetTimerClient setTimerClient; - - Timer timer; - - private void updateDisplay(TimerOperation op) { - updateDisplay(); - switch (op) { - case CREATE: - tView.modifyButton.setVisibility(View.GONE); - tView.saveButton.setVisibility(View.VISIBLE); - tView.saveButton.setText(R.string.timer_details_create_title); - break; - case MODIFY: - tView.saveButton.setVisibility(View.GONE); - tView.modifyButton.setVisibility(View.VISIBLE); - tView.saveButton.setText(R.string.timer_details_save_title); - break; - } - - } - - private void updateDisplay() { - EventFormatter f = new EventFormatter(timer,true); - tView.channel.setText(timer.getChannelNumber() + " " - + timer.getChannelName()); - tView.title.setText(f.getTitle()); - tView.dateField.setText(f.getDate()); - tView.startField.setText(f.getTime()); - tView.endField.setText(f.getStop()); - } - - protected Timer getTimer(EventListItem item) { - return item.getEpg().getTimer(); - } - /* * (non-Javadoc) * @@ -94,63 +30,41 @@ public abstract class BaseTimerEditActivity extends */ @Override public boolean onContextItemSelected(final MenuItem item) { - + // final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item .getMenuInfo(); final EventListItem event = adapter.getItem(info.position); - - if (tView == null) { - tView = new EditTimerViewHolder(); - View view = getLayoutInflater() - .inflate(R.layout.timer_detail, null); - tView.view = view; - tView.title = (TextView) view.findViewById(R.id.timer_detail_title); - tView.channel = (TextView) view - .findViewById(R.id.timer_detail_channel); - tView.dateField = (TextView) view - .findViewById(R.id.timer_detail_day); - tView.startField = (TextView) view - .findViewById(R.id.timer_detail_start); - tView.endField = (TextView) view - .findViewById(R.id.timer_detail_end); - tView.saveButton = (Button) view - .findViewById(R.id.timer_details_save); - tView.modifyButton = (Button) view - .findViewById(R.id.timer_details_modify); - - view.findViewById(R.id.timer_details_cancel).setOnClickListener( - this); - tView.dateField.setOnClickListener(this); - tView.startField.setOnClickListener(this); - tView.endField.setOnClickListener(this); - tView.saveButton.setOnClickListener(this); - tView.modifyButton.setOnClickListener(this); - - tDialog = new AlertDialog.Builder(this) - - .setView(view).create(); - } - + getApp().setCurrentEvent(event.getEvent()); switch (item.getItemId()) { - case R.id.epg_item_menu_timer_add: - timer = event.createTimer(); - updateDisplay(TimerOperation.CREATE); - tDialog.show(); + case R.id.epg_item_menu_timer_add: { + getApp().setCurrentTimer(event.createTimer()); + // updateDisplay(TimerOperation.CREATE); + // tDialog.show(); + final Intent intent = new Intent(); + intent.setClass(this, TimerDetailsActivity.class); + intent.putExtra(Intents.TIMER_OP, Intents.ADD_TIMER); + startActivityForResult(intent, + TimerDetailsActivity.REQUEST_CODE_TIMER_EDIT); + } break; case R.id.epg_item_menu_timer_modify: { - timer = getTimer(event); - updateDisplay(TimerOperation.MODIFY); - tDialog.show(); - // final Intent intent = new Intent(); - // intent.setClass(this, TimerDetailsActivity.class); - // startActivityForResult(intent, REQUEST_CODE_TIMED_EDIT); + getApp().setCurrentTimer(getTimer(event)); + // updateDisplay(TimerOperation.MODIFY); + // tDialog.show(); + final Intent intent = new Intent(); + intent.setClass(this, TimerDetailsActivity.class); + intent.putExtra(Intents.TIMER_OP, Intents.EDIT_TIMER); + startActivityForResult(intent, + TimerDetailsActivity.REQUEST_CODE_TIMER_EDIT); break; } case R.id.epg_item_menu_timer_delete: { + backupViewSelection(); deleteTimer(getTimer(event)); break; } case R.id.epg_item_menu_timer_toggle: { + backupViewSelection(); toggleTimer(getTimer(event)); break; } @@ -200,155 +114,50 @@ public abstract class BaseTimerEditActivity extends } - protected void toggleTimer(Timer timer) { - final ToggleTimerTask task = new ToggleTimerTask(this, timer) { - @Override - public void finished() { - refresh(); - } - }; - task.start(); - } - - public void onClick(final View view) { - switch (view.getId()) { - case R.id.timer_detail_day: { - final Calendar cal = new GregorianCalendar(); - cal.setTime(timer.getStart()); - final DatePickerDialog dialog = new DatePickerDialog(this, this, - cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), - cal.get(Calendar.DAY_OF_MONTH)); - dialog.show(); - break; - } - case R.id.timer_detail_start: { - final Calendar cal = new GregorianCalendar(); - cal.setTime(timer.getStart()); - editStart = true; - final TimePickerDialog dialog = new TimePickerDialog(this, this, - cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), - true); - dialog.show(); - break; - } - case R.id.timer_detail_end: { - final Calendar cal = new GregorianCalendar(); - cal.setTime(timer.getStop()); - editStart = false; - final TimePickerDialog dialog = new TimePickerDialog(this, this, - cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), - true); - dialog.show(); - break; - } - case R.id.timer_details_cancel: { - tDialog.dismiss(); - break; - } - case R.id.timer_details_modify: - modifyTimer(timer); - tDialog.dismiss(); - say(R.string.done); - break; - - case R.id.timer_details_save: { - createTimer(timer); - tDialog.dismiss(); - say(R.string.done); - break; - } - - default: - super.onClick(view); - } + protected Timer getTimer(EventListItem item) { + return item.getEpg().getTimer(); } - private void modifyTimer(Timer timer) { - backupViewSelection(); - final ModifyTimerTask task = new ModifyTimerTask(this, timer) { + protected void toggleTimer(Timer timer) { + final ToggleTimerTask task = new ToggleTimerTask(this, timer) { @Override - public void finished() { + public void finished(SvdrpEvent event) { refresh(); - //say(R.string.done); + restoreViewSelection(); } }; task.start(); } protected void deleteTimer(final Timer timer) { - backupViewSelection(); + //backupViewSelection(); final DeleteTimerTask task = new DeleteTimerTask(this, timer) { @Override - public void finished() { + public void finished(SvdrpEvent event) { refresh(); restoreViewSelection(); - //say(R.string.done); } }; task.start(); } - - private void createTimer(Timer timer) { + + protected void timerModified(){ backupViewSelection(); - final CreateTimerTask task = new CreateTimerTask(this, timer) { - @Override - public void finished() { - refresh(); - //say(R.string.done); - } - }; - task.start(); - } - - public void onTimeSet(final TimePicker view, final int hourOfDay, - final int minute) { - if (editStart) { - timer.setStart(calculateTime(timer.getStart(), hourOfDay, minute, - null)); - } else { - timer.setStop(calculateTime(timer.getStop(), hourOfDay, minute, - timer.getStart())); - } - updateDisplay(); - } - - public void onDateSet(final DatePicker view, final int year, - final int monthOfYear, final int dayOfMonth) { - timer.setStart(calculateDate(timer.getStart(), year, monthOfYear, - dayOfMonth)); - updateDisplay(); - } - - private Date calculateDate(final Date oldDate, final int year, - final int monthOfYear, final int dayOfMonth) { - - final Calendar cal = new GregorianCalendar(); - cal.setTime(oldDate); - cal.set(Calendar.YEAR, year); - cal.set(Calendar.MONTH, monthOfYear); - cal.set(Calendar.DAY_OF_MONTH, dayOfMonth); - - return cal.getTime(); + refresh(); } + - private Date calculateTime(final Date oldTime, final int hourOfDay, - final int minute, final Date startTime) { - - // set hour and minute - final Calendar cal = new GregorianCalendar(); - cal.setTime(oldTime); - cal.set(Calendar.HOUR_OF_DAY, hourOfDay); - cal.set(Calendar.MINUTE, minute); + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); - // go to the next day if end time before start time - if (startTime != null) { - if (cal.getTime().before(startTime)) { - cal.add(Calendar.DAY_OF_MONTH, 1); - } + if (resultCode != Activity.RESULT_OK) { + return; } - - return cal.getTime(); - + if(requestCode == TimerDetailsActivity.REQUEST_CODE_TIMER_EDIT){ + timerModified(); + } +// refresh(); } } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java index 1c2c4ff..510e1de 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java @@ -8,7 +8,6 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; -import android.util.Log; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; import android.view.Menu; @@ -21,81 +20,53 @@ import android.widget.ExpandableListView.ExpandableListContextMenuInfo; import android.widget.ExpandableListView.OnChildClickListener; import android.widget.ExpandableListView.OnGroupClickListener; import de.bjusystems.vdrmanager.R; -import de.bjusystems.vdrmanager.app.Intents; import de.bjusystems.vdrmanager.data.Channel; import de.bjusystems.vdrmanager.data.Preferences; import de.bjusystems.vdrmanager.utils.svdrp.ChannelClient; -import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncListener; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncTask; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpClient; -import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent; -import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException; /** * This class is used for showing what's current running on all channels * * @author bju */ -public class ChannelListActivity extends BaseActivity implements - OnChildClickListener, OnGroupClickListener, SvdrpAsyncListener { +public class ChannelListActivity extends BaseActivity + implements OnChildClickListener, OnGroupClickListener +{ private static final String TAG = ChannelListActivity.class.getName(); + ChannelClient channelClient; - + ChannelAdapter adapter; - + Preferences prefs; - + public static final int MENU_GROUP = 0; public static final int MENU_PROVIDER = 1; public static final int MENU_NAME = 2; private int groupBy = MENU_GROUP; - final static ArrayList ALL_CHANNELS_GROUP = new ArrayList( - 1); - - //ExpandableListView listView; + final static ArrayList ALL_CHANNELS_GROUP = new ArrayList(1); - // @Override - // public boolean onKeyLongPress(int keyCode, KeyEvent event) { - // // TODO Auto-generated method stub - // return super.onKeyLongPress(keyCode, event); - // } - // - // @Override - // public boolean onKeyDown(int keyCode, KeyEvent event) { - // // TODO Auto-generated method stub - // return super.onKeyDown(keyCode, event); - // } - - // @Override - // public boolean onKeyUp(int keyCode, KeyEvent event) { - // // TODO Auto-generated method stub - // return super.onKeyUp(keyCode, event); - // } - // - @Override protected void onResume() { super.onResume(); } - + @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); - // Attach view setContentView(getMainLayout()); setTitle(R.string.action_menu_channels); + initFlipper(); adapter = new ChannelAdapter(this); - // Create adapter for ListView - listView = (ExpandableListView) findViewById(R.id.channel_list); - // listView.setOnItemClickListener(this); listView.setOnChildClickListener(this); listView.setTextFilterEnabled(true); listView.setFastScrollEnabled(true); @@ -119,6 +90,11 @@ public class ChannelListActivity extends BaseActivity implem private void startChannelQuery(boolean useCache) { + if (checkInternetConnection() == false) { + switchNoConnection(); + return; + } + // get channel task channelClient = new ChannelClient(useCache); @@ -140,10 +116,10 @@ public class ChannelListActivity extends BaseActivity implem private void fillAdapter() { switch (groupBy) { case MENU_GROUP: - ArrayList cgs = channelClient.getChannelGroups(); - adapter.fill(cgs, channelClient.getGroupChannels(), groupBy); - if(cgs.size() == 1){ - listView.expandGroup(0); + ArrayList cgs = ChannelClient.getChannelGroups(); + adapter.fill(cgs, ChannelClient.getGroupChannels(), groupBy); + if (cgs.size() == 1) { + listView.expandGroup(0); } updateWindowTitle( getString(R.string.action_menu_channels), @@ -151,11 +127,10 @@ public class ChannelListActivity extends BaseActivity implem getString(R.string.groupby_group))); break; case MENU_PROVIDER: - ArrayList gs = new ArrayList(channelClient + ArrayList gs = new ArrayList(ChannelClient .getProviderChannels().keySet()); - adapter.fill(gs, channelClient - .getProviderChannels(), groupBy); - if(gs.size() == 1){ + adapter.fill(gs, ChannelClient.getProviderChannels(), groupBy); + if (gs.size() == 1) { listView.expandGroup(0); } updateWindowTitle( @@ -171,7 +146,7 @@ public class ChannelListActivity extends BaseActivity implem HashMap> channels = new HashMap>( 1); channels.put(getString(R.string.groupby_name_all_channels_group), - channelClient.getChannels()); + ChannelClient.getChannels()); adapter.fill(ALL_CHANNELS_GROUP, channels, groupBy); listView.expandGroup(0); @@ -181,54 +156,12 @@ public class ChannelListActivity extends BaseActivity implem } } - public void svdrpEvent(final SvdrpEvent event, final Channel result) { - switch (event) { - case ABORTED: - say(R.string.aborted); - break; - case ERROR: - say(R.string.epg_client_errors); - break; - case CONNECTING: - break; - case CONNECT_ERROR: - say(R.string.progress_connect_error); - switchNoConnection(); - break; - case FINISHED_ABNORMALY: - say(R.string.progress_connect_finished_abnormal); - switchNoConnection(); - break; - case LOGIN_ERROR: - switchNoConnection(); - break; - case CACHE_HIT: - say(R.string.progress_cache_hit); - fillAdapter(); - restoreViewSelection(); - break; - case FINISHED_SUCCESS: - fillAdapter(); - restoreViewSelection(); - break; - - } - } - - public void svdrpException(final SvdrpException exception) { - progress.svdrpException(exception); - Log.w(TAG, exception); - alert(getString(R.string.vdr_error_text, exception.getMessage())); - } - - public boolean onPrepareOptionsMenu(Menu menu) { - + return super.onPrepareOptionsMenu(menu); } - @Override public final boolean onCreateOptionsMenu(final Menu menu) { super.onCreateOptionsMenu(menu); @@ -237,17 +170,6 @@ public class ChannelListActivity extends BaseActivity implem item = menu.add(MENU_GROUP, MENU_GROUP, 0, R.string.menu_groupby); item.setIcon(android.R.drawable.ic_menu_sort_alphabetically); item.setAlphabeticShortcut('g'); - - // item = menu.add(MENU_GROUP_PROVIDER, MENU_PROVIDER, 0, - // R.string.groupby_provider); - // item.setIcon(android.R.drawable.ic_menu_sort_alphabetically); - // item.setAlphabeticShortcut('p'); - - // item = menu.add(MENU_GROUP_NAME, MENU_NAME, 0, - // R.string.groupby_name); - // item.setIcon(android.R.drawable.ic_menu_sort_alphabetically); - // item.setAlphabeticShortcut('n'); - return true; } @@ -359,29 +281,6 @@ public class ChannelListActivity extends BaseActivity implem } - // @Override - // public boolean onContextItemSelected(final MenuItem item) { - // - // final AdapterView.AdapterContextMenuInfo info = - // (AdapterView.AdapterContextMenuInfo) item - // .getMenuInfo(); - // // final Channel channel = adapter.getItem(info.position); - // // if(channel.isGroupSeparator()){ - // // - // // } - // - // switch (item.getItemId()) { - // case R.id.channel_item_menu_epg: - // //onItemClick(null, null, info.position, 0); - // break; - // case R.id.channel_item_menu_stream: - // // show live stream - // // Utils.stream(this, channel); - // break; - // } - // - // return true; - // } @Override public boolean onSearchRequested() { @@ -390,11 +289,6 @@ public class ChannelListActivity extends BaseActivity implem return true; } - @Override - public void onBackPressed() { - super.onBackPressed(); - } - public boolean onGroupClick(ExpandableListView arg0, View arg1, int arg2, long arg3) { return true; @@ -408,7 +302,8 @@ public class ChannelListActivity extends BaseActivity implem // show details final Intent intent = new Intent(); - intent.putExtra(Intents.CURRENT_CHANNEL, channel); + getApp().setCurrentChannel(channel); + //intent.putExtra(Intents.CURRENT_CHANNEL, channel); intent.setClass(this, EventEpgListActivity.class); startActivity(intent); } @@ -437,4 +332,21 @@ public class ChannelListActivity extends BaseActivity implem return R.layout.channel_list; } + @Override + protected boolean finishedSuccess() { + fillAdapter(); + restoreViewSelection(); + return ChannelClient.getChannels().isEmpty() == false; + } + + @Override + protected void resultReceived(Channel result) { + + } + + protected void cacheHit() { + fillAdapter(); + restoreViewSelection(); + } + } \ No newline at end of file diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java index 40d54fe..2e3dd4e 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java @@ -4,18 +4,18 @@ import java.util.ArrayList; import java.util.List; import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; -import android.os.AsyncTask; import android.os.Bundle; -import android.view.ContextMenu; import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; -import android.view.ContextMenu.ContextMenuInfo; import android.view.View.OnClickListener; -import android.widget.AdapterView; +import android.view.Window; +import android.widget.ArrayAdapter; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ProgressBar; @@ -24,17 +24,19 @@ import android.widget.Toast; import de.bjusystems.vdrmanager.R; import de.bjusystems.vdrmanager.app.Intents; import de.bjusystems.vdrmanager.app.VdrManagerApp; -import de.bjusystems.vdrmanager.data.Channel; import de.bjusystems.vdrmanager.data.Epg; import de.bjusystems.vdrmanager.data.Event; +import de.bjusystems.vdrmanager.data.Event.TimerState; import de.bjusystems.vdrmanager.data.EventFormatter; -import de.bjusystems.vdrmanager.data.EventListItem; import de.bjusystems.vdrmanager.data.Preferences; +import de.bjusystems.vdrmanager.data.Recording; import de.bjusystems.vdrmanager.data.Timer; import de.bjusystems.vdrmanager.gui.SimpleGestureFilter.SimpleGestureListener; -import de.bjusystems.vdrmanager.utils.date.DateFormatter; -import de.bjusystems.vdrmanager.utils.svdrp.EpgClient; -import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException; +import de.bjusystems.vdrmanager.tasks.DeleteTimerTask; +import de.bjusystems.vdrmanager.tasks.ModifyTimerTask; +import de.bjusystems.vdrmanager.tasks.ToggleTimerTask; +import de.bjusystems.vdrmanager.tasks.VoidAsyncTask; +import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent; /** * This class is used for showing what's current running on all channels @@ -56,12 +58,16 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, Event cEvent; + ImageView state; + @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); + requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); + Intent i = getIntent(); - + highlight = i.getStringExtra(Intents.HIGHLIGHT); // Attach view @@ -69,23 +75,42 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, detector = new SimpleGestureFilter(this, this); - // event_left = (ImageButton) findViewById(R.id.epg_event_left); - // event_right = (ImageButton) findViewById(R.id.epg_event_right); + event_left = (ImageButton) findViewById(R.id.epg_event_left); + event_right = (ImageButton) findViewById(R.id.epg_event_right); + state = (ImageView) findViewById(R.id.epg_timer_state); - // current event - final VdrManagerApp app = (VdrManagerApp) getApplication(); - epgs = app.getCurrentEpgList(); - Event epg = app.getCurrentEvent(); + new VoidAsyncTask() { + + private Event epg; - counter = 0; - for (Event e : epgs) { - if (epg == e) { - break; + @Override + protected void onPreExecute() { + setProgressBarIndeterminateVisibility(true); } - counter++; - } - publishEPG(epg); + @Override + protected Void doInBackground(Void... params) { + // current event + final VdrManagerApp app = (VdrManagerApp) getApplication(); + epgs = app.getCurrentEpgList(); + epg = app.getCurrentEvent(); + + counter = 0; + for (Event e : epgs) { + if (epg == e) { + break; + } + counter++; + } + return (Void) null; + } + + @Override + protected void onPostExecute(Void result) { + publishEPG(epg); + } + }.execute((Void) null); + } private void setState(ImageView view, int res) { @@ -93,7 +118,13 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, view.setImageResource(res); } - public void publishEPG(Event event) { + public void publishEPG(final Event event) { + setProgressBarIndeterminateVisibility(true); + publishEPGImpl(event); + setProgressBarIndeterminateVisibility(false); + } + + public void publishEPGImpl(Event event) { cEvent = event; @@ -118,7 +149,7 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, .getChannelName()); // ((TextView) findViewById(R.id.epg_detail_date)).setText(formatter // .getLongDate()); - ImageView state = (ImageView) findViewById(R.id.epg_timer_state); + switch (event.getTimerState()) { case Active: @@ -130,6 +161,8 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, case Recording: setState(state, R.drawable.timer_recording); break; + default: + setState(state, R.drawable.timer_none); } final TextView shortText = (TextView) findViewById(R.id.epg_detail_shorttext); @@ -177,8 +210,8 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, b.setVisibility(View.VISIBLE); setThisAsOnClickListener(b); } - // setThisAsOnClickListener(R.id.epg_event_left); - // setThisAsOnClickListener(R.id.epg_event_right); + setThisAsOnClickListener(R.id.epg_event_left); + setThisAsOnClickListener(R.id.epg_event_right); // set button text if (event instanceof Timer) { @@ -203,8 +236,6 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, protected void onResume() { super.onResume(); // TODO Check here whether the config has changed for imdb - // TODO check here if we are still live ? - } @Override @@ -212,14 +243,107 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, super.onPause(); } + class Wrapper { + public int id; + public String value; + + public Wrapper(int id) { + this.id = id; + this.value = getString(id); + } + + public String toString() { + return value; + } + } + + public Timer getTimer(Event event) { + if (event instanceof Timer) { + return (Timer) event; + } + if (event instanceof Epg) { + return ((Epg) event).getTimer(); + } + return null; + } + + protected VdrManagerApp getApp() { + final VdrManagerApp app = (VdrManagerApp) getApplication(); + return app; + } + public void onClick(final View v) { switch (v.getId()) { case R.id.epg_event_livetv: Utils.stream(this, cEvent.getChannelNumber()); break; case R.id.epg_event_create_timer: - Toast.makeText(this, "Soon we get here the timer menu", - Toast.LENGTH_SHORT).show(); + final ArrayAdapter ada = new ArrayAdapter(this, + R.layout.timer_operation_list_item); + final Timer timer = getTimer(cEvent); + // remove unneeded menu items + if (timer != null) { + ada.add(new Wrapper(R.string.epg_item_menu_timer_modify)); + ada.add(new Wrapper(R.string.epg_item_menu_timer_delete)); + if (timer.isEnabled()) { + ada.add(new Wrapper(R.string.epg_item_menu_timer_disable)); + } else { + ada.add(new Wrapper(R.string.epg_item_menu_timer_enable)); + } + } else if (cEvent instanceof Recording) { + ada.add(new Wrapper(R.string.epg_item_menu_timer_delete)); + + } else { + ada.add(new Wrapper(R.string.epg_item_menu_timer_add)); + } + new AlertDialog.Builder(this) + .setAdapter(ada, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + final Timer t; + if (timer == null) { + t = cEvent.createTimer(); + } else { + t = timer; + } + getApp().setCurrentTimer(t); + Wrapper w = ada.getItem(which); + switch (w.id) { + case R.string.epg_item_menu_timer_add: { + final Intent intent = new Intent(); + intent.setClass(EpgDetailsActivity.this, + TimerDetailsActivity.class); + intent.putExtra(Intents.TIMER_OP, + Intents.ADD_TIMER); + startActivityForResult( + intent, + TimerDetailsActivity.REQUEST_CODE_TIMER_ADD); + break; + } + case R.string.epg_item_menu_timer_modify: { + final Intent intent = new Intent(); + intent.setClass(EpgDetailsActivity.this, + TimerDetailsActivity.class); + intent.putExtra(Intents.TIMER_OP, + Intents.EDIT_TIMER); + startActivityForResult( + intent, + TimerDetailsActivity.REQUEST_CODE_TIMER_EDIT); + break; + } + case R.string.epg_item_menu_timer_delete: { + deleteTimer(timer); + break; + } + case R.string.epg_item_menu_timer_enable: + case R.string.epg_item_menu_timer_disable: { + toggleTimer(timer); + break; + } + } + } + }).create()// + .show();// + break; case R.id.epg_event_imdb: final TextView title = (TextView) findViewById(R.id.epg_detail_title); @@ -230,12 +354,43 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, i.setData(Uri.parse(url)); startActivity(i); break; -// case R.id.epg_event_share: -// shareEvent(cEvent); -// break; + case R.id.epg_event_left: + prevEPG(); + break; + case R.id.epg_event_right: + nextEPG(); + break; + // case R.id.epg_event_share: + // shareEvent(cEvent); + // break; } } + protected void toggleTimer(final Timer timer) { + final ToggleTimerTask task = new ToggleTimerTask(this, timer) { + @Override + public void finished(SvdrpEvent event) { + if (event == SvdrpEvent.FINISHED_SUCCESS) { + TimerState state = timer.getTimerState(); + int res = -1; + if (state == TimerState.Active) { + res = R.drawable.timer_inactive; + } else if (state == TimerState.Inactive) { + res = R.drawable.timer_active; + } + if (res != -1) { + setState( + (ImageView) findViewById(R.id.epg_timer_state), + res); + } + } + } + }; + task.start(); + } + + // EditTimerViewHolder tView = null; + public void onSwipe(int direction) { switch (direction) { case SimpleGestureFilter.SWIPE_RIGHT: @@ -250,66 +405,56 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, private void prevEPG() { Event epg; if (counter == 0) { - epg = epgs.get(0); - } else { - epg = epgs.get(--counter); + say(R.string.navigae_at_the_start); + return; } - + epg = epgs.get(--counter); publishEPG(epg); - } List epgs = new ArrayList(); - - int counter = 0; -/* - public void initEPGs() { - - if (epgs != null) { - return; - } - epgs = new ArrayList(); - - final VdrManagerApp app = (VdrManagerApp) getApplication(); - final Event event = app.getCurrentEvent(); - EpgClient c = new EpgClient(new Channel() { - @Override - public String getName() { - return event.getChannelName(); - } - @Override - public int getNumber() { - return Integer.valueOf(event.getChannelNumber()); - } - }); - - try { - c.run(); - } catch (SvdrpException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - List e = c.getResults(); - if (e == null || e.isEmpty()) { - return; - } + int counter = 0; - epgs.addAll(e); - Event fe = epgs.get(0); - if (event.getStart().equals(fe.getStart()) == false) { - epgs.set(0, event); - ; - } - } -*/ + /* + * public void initEPGs() { + * + * if (epgs != null) { return; } epgs = new ArrayList(); + * + * final VdrManagerApp app = (VdrManagerApp) getApplication(); final Event + * event = app.getCurrentEvent(); EpgClient c = new EpgClient(new Channel() + * { + * + * @Override public String getName() { return event.getChannelName(); } + * + * @Override public int getNumber() { return + * Integer.valueOf(event.getChannelNumber()); } }); + * + * try { c.run(); } catch (SvdrpException e) { // TODO Auto-generated catch + * block e.printStackTrace(); } + * + * List e = c.getResults(); if (e == null || e.isEmpty()) { return; } + * + * epgs.addAll(e); Event fe = epgs.get(0); if + * (event.getStart().equals(fe.getStart()) == false) { epgs.set(0, event); ; + * } } + */ private void nextEPG() { if (counter < epgs.size() - 1) { counter++; + Event epg = epgs.get(counter); + publishEPG(epg); + } else { + say(R.string.navigae_at_the_end); } - Event epg = epgs.get(counter); - publishEPG(epg); + } + + protected void say(int res) { + Toast.makeText(this, res, Toast.LENGTH_SHORT).show(); + } + + protected void say(String msg) { + Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); } public void onDoubleTap() { @@ -337,7 +482,7 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, private void shareEvent(Event event) { Utils.shareEvent(this, event); } - + @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == MENU_SHARE) { @@ -346,4 +491,40 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, } return super.onOptionsItemSelected(item); } + + protected void modifyTimer(Timer timer) { + final ModifyTimerTask task = new ModifyTimerTask(this, timer) { + @Override + public void finished(SvdrpEvent event) { + + } + }; + task.start(); + } + + protected void deleteTimer(final Timer timer) { + final DeleteTimerTask task = new DeleteTimerTask(this, timer) { + @Override + public void finished(SvdrpEvent event) { + if (event == SvdrpEvent.FINISHED_SUCCESS) { + setState((ImageView) findViewById(R.id.epg_timer_state), + R.drawable.timer_none); + } + } + }; + task.start(); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if(resultCode != RESULT_OK){ + return; + } + if(requestCode == TimerDetailsActivity.REQUEST_CODE_TIMER_ADD){ + setState(state, Utils.isLive(getApp().getCurrentEvent()) ? R.drawable.timer_recording : R.drawable.timer_active); + } else if( requestCode == TimerDetailsActivity.REQUEST_CODE_TIMER_EDIT){ + //?? + } + } + } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java index 3ff0df2..b79e084 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java @@ -83,6 +83,11 @@ public class EpgSearchListActivity extends BaseTimerEditActivity implements private void startEpgQuery() { + if (checkInternetConnection() == false) { + switchNoConnection(); + return; + } + EpgSearchParams sp = new EpgSearchParams(); sp.setTitle(highlight); setTitle(getString(R.string.epg_by_search_param, highlight)); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java index 257eea5..7841f20 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java @@ -2,9 +2,12 @@ package de.bjusystems.vdrmanager.gui; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collections; +import java.util.Comparator; import java.util.Date; import java.util.List; +import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; @@ -25,6 +28,9 @@ import de.bjusystems.vdrmanager.utils.svdrp.ChannelClient; import de.bjusystems.vdrmanager.utils.svdrp.EpgClient; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncTask; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpClient; +import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent; +import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException; +import de.bjusystems.vdrmanager.utils.svdrp.SvdrpListener; /** * This class is used for showing what's current running on all channels @@ -42,15 +48,15 @@ public class EventEpgListActivity extends BaseTimerEditActivity implements Spinner channelSpinner; + View switcher; + ArrayAdapter channelSpinnerAdapter; @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - - // get state - final List channels = ChannelClient.getChannels(); - + // + // // create adapter for channel spinner channelSpinnerAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item); @@ -58,18 +64,19 @@ public class EventEpgListActivity extends BaseTimerEditActivity implements .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); channelSpinner = (Spinner) findViewById(R.id.epg_list_channel_spinner); channelSpinner.setAdapter(channelSpinnerAdapter); + switcher = findViewById(R.id.switch_epg_view); + switcher.setOnClickListener(this); // add channel values // boolean useChannelNumber = Preferences.get().isShowChannelNumbers(); - for (final Channel c : channels) { - channelSpinnerAdapter.add(c); - } + // show needed items adapter = new ChannelEventAdapter(this); - channelSpinner.setOnItemSelectedListener(this); - channelSpinner.setSelection(currentChannel.getNumber() - 1); + // if (currentChannel != null) { + + // } // startChannelEpgQuery(channel); // findViewById(R.id.timer_item_channel).setVisibility(View.GONE); // break; @@ -77,15 +84,28 @@ public class EventEpgListActivity extends BaseTimerEditActivity implements // Create adapter for EPG list listView = (ListView) findViewById(R.id.whatson_list); listView.setAdapter(adapter); - //listView.setFastScrollEnabled(true); + // listView.setFastScrollEnabled(true); listView.setTextFilterEnabled(true); registerForContextMenu(listView); // register EPG item click listView.setOnItemClickListener(this); + } + // private void ensureChannelList() { + + @Override + protected void onPause() { + super.onPause(); } + @Override + protected void onResume() { + super.onResume(); + backupViewSelection(); + startEpgQuery(); + channelSpinner.setOnItemSelectedListener(this); + } public void onItemSelected(final AdapterView parent, final View view, final int position, final long id) { @@ -93,12 +113,37 @@ public class EventEpgListActivity extends BaseTimerEditActivity implements // get spinner value final Channel channel = (Channel) channelSpinner.getSelectedItem(); currentChannel = channel; + getApp().setCurrentChannel(currentChannel); // setAsCurrent(channel); // update search startEpgQuery(); } + // class LoadChannelsTask extends AsyncProgressTask { + // + // boolean f; + // Channel c; + // + // public LoadChannelsTask(Channel channel, boolean force, + // Activity activity, ChannelClient client) { + // super(activity, client); + // this.f = force; + // this.c = channel; + // } + // + // @Override + // public void finished(SvdrpEvent event) { + // if (noConnection(event)) { + // return; + // } + // ArrayList channels = ChannelClient.getChannels(); + // for (final Channel c : channels) { + // channelSpinnerAdapter.add(c); + // } + // } + // } + public void onNothingSelected(final AdapterView arg0) { // startTimeEpgQuery(((EpgTimeSpinnerValue)timeSpinner.getAdapter().getItem(0)).getValue()); } @@ -134,13 +179,49 @@ public class EventEpgListActivity extends BaseTimerEditActivity implements startEpgQuery(false); } + @Override + public void onClick(View view) { + if (view == switcher) { + final Intent intent = new Intent(); + intent.setClass(this, TimeEpgListActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT + | Intent.FLAG_ACTIVITY_SINGLE_TOP); + startActivity(intent); + } else { + super.onClick(view); + } + } + private void startEpgQuery(Channel channel, boolean force) { + try { + ChannelClient client = new ChannelClient(); + client.addSvdrpListener(new SvdrpListener() { + public void svdrpEvent(SvdrpEvent event, Channel result) { + if (event == SvdrpEvent.CACHE_HIT + || event == SvdrpEvent.FINISHED_SUCCESS) { + ArrayList channels = ChannelClient + .getChannels(); + for (final Channel c : channels) { + channelSpinnerAdapter.add(c); + } + } + noConnection(event); + } + }); + client.run(); + } catch (SvdrpException ex) { + svdrpException(ex); + } + startEpgQueryImpl(channel, force); + } + + private void startEpgQueryImpl(Channel channel, boolean force) { if (useCache(channel) && !force) { Calendar cal = Calendar.getInstance(); int day = -1; for (Event i : CACHE) { - Epg e = (Epg)i; + Epg e = (Epg) i; cal.setTime(e.getStart()); int eday = cal.get(Calendar.DAY_OF_YEAR); if (eday != day) { @@ -153,9 +234,15 @@ public class EventEpgListActivity extends BaseTimerEditActivity implements return; } + if (checkInternetConnection() == false) { + switchNoConnection(); + return; + } + clearCache(); epgClient = new EpgClient(channel); + epgClient.setResultInfoEnabled(true); // remove old listeners // epgClient.clearSvdrpListener(); @@ -170,7 +257,6 @@ public class EventEpgListActivity extends BaseTimerEditActivity implements task.addListener(progress); task.addListener(this); - // start task task.run(); } @@ -189,7 +275,8 @@ public class EventEpgListActivity extends BaseTimerEditActivity implements nextForceCache = FUTURE; Calendar cal = Calendar.getInstance(); int day = -1; - for (Epg e : epgClient.getResults()) { + sortItemsByTime(results); + for (Event e : results) { CACHE.add(e); cal.setTime(e.getStart()); int eday = cal.get(Calendar.DAY_OF_YEAR); @@ -198,13 +285,13 @@ public class EventEpgListActivity extends BaseTimerEditActivity implements adapter.add(new EventListItem(new DateFormatter(cal) .getDailyHeader())); } - adapter.add(new EventListItem(e)); + adapter.add(new EventListItem((Epg) e)); if (e.getStop().before(nextForceCache) && e.getStop().after(now)) { nextForceCache = e.getStop(); } } cachedChannel = currentChannel; - //listView.setSelectionAfterHeaderView(); + // listView.setSelectionAfterHeaderView(); dismiss(progress); return CACHE.isEmpty() == false; } @@ -227,7 +314,7 @@ public class EventEpgListActivity extends BaseTimerEditActivity implements @Override protected void retry() { - startEpgQuery(currentChannel, true); + refresh(); } @Override @@ -265,4 +352,21 @@ public class EventEpgListActivity extends BaseTimerEditActivity implements break; } } + + protected void sortItemsByChannel(List result) { + final Comparator comparator = new Comparator() { + + public int compare(final Event item1, final Event item2) { + return Integer.valueOf(item1.getChannelNumber()).compareTo( + Integer.valueOf(item2.getChannelNumber())); + } + }; + Collections.sort(result, comparator); + } + + @Override + protected void timerModified() { + cachedChannel = null; + } + } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java index b13d3ae..c38a20d 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java @@ -21,6 +21,7 @@ import de.bjusystems.vdrmanager.utils.svdrp.RecordingClient; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncListener; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncTask; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpClient; +import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent; /** * This class is used for showing what's current running on all channels @@ -94,7 +95,7 @@ public class RecordingListActivity extends BaseEventListActivity case R.id.recording_item_menu_delete: { DeleteRecordingTask drt = new DeleteRecordingTask(this, rec) { @Override - public void finished() { + public void finished(SvdrpEvent event) { dismiss(progress); refresh(); } @@ -114,6 +115,12 @@ public class RecordingListActivity extends BaseEventListActivity } private void startRecordingQuery() { + + + if (checkInternetConnection() == false) { + switchNoConnection(); + return; + } // get timer client recordingClient = new RecordingClient(); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java index f3468f8..4e34590 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java @@ -2,6 +2,7 @@ package de.bjusystems.vdrmanager.gui; import android.app.Activity; import android.app.ProgressDialog; +import android.content.DialogInterface; import de.bjusystems.vdrmanager.R; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncListener; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpClient; @@ -9,7 +10,7 @@ import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException; public class SvdrpProgressDialog extends ProgressDialog implements - SvdrpAsyncListener { + SvdrpAsyncListener, DialogInterface.OnCancelListener { ProgressDialog progress; Activity activity; SvdrpClient client; @@ -20,6 +21,8 @@ public class SvdrpProgressDialog extends ProgressDialog implements this.activity = activity; this.client = client; progress = new ProgressDialog(activity); + progress.setOnCancelListener(this); + progress.setCancelable(false); } public void svdrpEvent(final SvdrpEvent event) { @@ -69,8 +72,19 @@ public class SvdrpProgressDialog extends ProgressDialog implements progress.setMessage(activity.getString(resId, args)); } } - + + private void abort() { + if (client.isConnected()) { + client.abort(); + dismiss(); + } + } + public void dismiss() { progress.dismiss(); } + + public void onCancel(DialogInterface dialog) { + abort(); + } } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java index dfa7e6c..6a12b0d 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java @@ -1,10 +1,15 @@ package de.bjusystems.vdrmanager.gui; import java.util.ArrayList; +import java.util.Calendar; import java.util.Date; +import java.util.List; +import java.util.TimeZone; +import android.app.TimePickerDialog; +import android.app.TimePickerDialog.OnTimeSetListener; +import android.content.Intent; import android.os.Bundle; -import android.view.LayoutInflater; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; @@ -12,8 +17,7 @@ import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Spinner; -import android.widget.TextView; -import android.widget.Toast; +import android.widget.TimePicker; import de.bjusystems.vdrmanager.R; import de.bjusystems.vdrmanager.app.VdrManagerApp; import de.bjusystems.vdrmanager.data.Epg; @@ -21,6 +25,7 @@ import de.bjusystems.vdrmanager.data.EpgSearchTimeValue; import de.bjusystems.vdrmanager.data.EpgSearchTimeValues; import de.bjusystems.vdrmanager.data.Event; import de.bjusystems.vdrmanager.data.EventListItem; +import de.bjusystems.vdrmanager.data.Preferences; import de.bjusystems.vdrmanager.utils.date.DateFormatter; import de.bjusystems.vdrmanager.utils.svdrp.EpgClient; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncTask; @@ -32,9 +37,13 @@ import de.bjusystems.vdrmanager.utils.svdrp.SvdrpClient; * @author bju */ public class TimeEpgListActivity extends BaseTimerEditActivity implements - OnItemClickListener, OnItemSelectedListener { + OnItemClickListener, OnItemSelectedListener, OnTimeSetListener { - Spinner timeSpinner; + protected Spinner timeSpinner; + + protected View switcher; + + protected View clock; ArrayAdapter timeSpinnerAdapter; @@ -44,6 +53,8 @@ public class TimeEpgListActivity extends BaseTimerEditActivity implements private static String cachedTime = null; + int selectedIndex = 0; + @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -56,13 +67,18 @@ public class TimeEpgListActivity extends BaseTimerEditActivity implements timeSpinner = (Spinner) findViewById(R.id.epg_list_time_spinner); timeSpinner.setAdapter(timeSpinnerAdapter); - fillTimeSpinnerValues(); + switcher = findViewById(R.id.switch_epg_view); + switcher.setOnClickListener(this); + + clock = findViewById(R.id.epg_list_times); + clock.setOnClickListener(this); // update gui adapter = new TimeEventAdapter(this); // searchLabel.setVisibility(View.GONE); timeSpinner.setOnItemSelectedListener(this); - timeSpinner.setSelection(0); + + fillTimeSpinnerValues(); // Create adapter for EPG list listView = (ListView) findViewById(R.id.whatson_list); @@ -77,8 +93,6 @@ public class TimeEpgListActivity extends BaseTimerEditActivity implements } - - private void fillTimeSpinnerValues() { final EpgSearchTimeValues values = new EpgSearchTimeValues(this); timeSpinnerAdapter.clear(); @@ -87,6 +101,10 @@ public class TimeEpgListActivity extends BaseTimerEditActivity implements } } + @Override + protected void onResume() { + super.onResume(); + } @Override protected void onPause() { @@ -94,6 +112,49 @@ public class TimeEpgListActivity extends BaseTimerEditActivity implements } + @Override + public void onClick(View view) { + if (view == switcher) { + final Intent intent = new Intent(); + intent.setClass(this, EventEpgListActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT + | Intent.FLAG_ACTIVITY_SINGLE_TOP); + startActivity(intent); + } else if (view == clock) { + Intent intent = new Intent(); + intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT + | Intent.FLAG_ACTIVITY_SINGLE_TOP); + intent.setClass(this, EpgSearchTimesListActivity.class); + startActivity(intent); + } else { + super.onClick(view); + } + } + + public void onTimeSet(final TimePicker view, final int hourOfDay, + final int minute) { + String tm = String.format("%02d:%02d", hourOfDay, minute); + + // timeSpinnerAdapter.add(time); + final EpgSearchTimeValues values = new EpgSearchTimeValues(this); + List vs = values.getValues(); + final EpgSearchTimeValue time = new EpgSearchTimeValue(3, tm); + vs.add(vs.size() - 1, time); + timeSpinnerAdapter.clear(); + int select = -1; + int counter = 0; + for (final EpgSearchTimeValue value : vs) { + timeSpinnerAdapter.add(value); + if (select == -1 && value.getText().equals(tm)) { + select = counter; + } + counter++; + } + timeSpinner.setSelection(select); + setTitle(getString(R.string.epg_by_time_args, tm)); + // update search + startEpgQuery(time.getValue(), false); + } public void onItemSelected(final AdapterView parent, final View view, final int position, final long id) { @@ -101,9 +162,19 @@ public class TimeEpgListActivity extends BaseTimerEditActivity implements // get spinner value final EpgSearchTimeValue selection = (EpgSearchTimeValue) timeSpinner .getSelectedItem(); - // update search - startEpgQuery(selection.getValue(), false); + if (selection.getValue().equals("adhoc")) { + final Calendar cal = Calendar.getInstance(TimeZone.getDefault()); + // show time selection + final TimePickerDialog dialog = new TimePickerDialog(this, this, + cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), + Preferences.get().isUse24hFormat()); + dialog.show(); + } else { + // update search + setTitle(getString(R.string.epg_by_time_args, selection.getText())); + startEpgQuery(selection.getValue(), false); + } } public void onNothingSelected(final AdapterView arg0) { @@ -151,6 +222,11 @@ public class TimeEpgListActivity extends BaseTimerEditActivity implements return; } + if (checkInternetConnection() == false) { + switchNoConnection(); + return; + } + clearCache(); epgClient = new EpgClient(time); @@ -236,8 +312,7 @@ public class TimeEpgListActivity extends BaseTimerEditActivity implements private void nextEvent() { int pos = timeSpinner.getSelectedItemPosition(); if (pos + 1 >= timeSpinnerAdapter.getCount()) { - Toast.makeText(this, R.string.navigae_at_the_end, - Toast.LENGTH_SHORT).show(); + say(R.string.navigae_at_the_end); return; } timeSpinner.setSelection(pos + 1, true); @@ -246,8 +321,7 @@ public class TimeEpgListActivity extends BaseTimerEditActivity implements private void prevEvent() { int pos = timeSpinner.getSelectedItemPosition(); if (pos <= 0) { - Toast.makeText(this, R.string.navigae_at_the_start, - Toast.LENGTH_SHORT).show(); + say(R.string.navigae_at_the_start); return; } timeSpinner.setSelection(pos - 1, true); @@ -264,4 +338,5 @@ public class TimeEpgListActivity extends BaseTimerEditActivity implements break; } } + } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerDetailsActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerDetailsActivity.java index 5a79c30..696da9e 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerDetailsActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerDetailsActivity.java @@ -16,71 +16,123 @@ import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; import android.widget.TimePicker; +import android.widget.Toast; import de.bjusystems.vdrmanager.R; +import de.bjusystems.vdrmanager.app.Intents; import de.bjusystems.vdrmanager.app.VdrManagerApp; -import de.bjusystems.vdrmanager.data.Preferences; +import de.bjusystems.vdrmanager.data.EventFormatter; import de.bjusystems.vdrmanager.data.Timer; -import de.bjusystems.vdrmanager.utils.date.DateFormatter; -import de.bjusystems.vdrmanager.utils.svdrp.SetTimerClient; -import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncListener; -import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncTask; -import de.bjusystems.vdrmanager.utils.svdrp.SvdrpClient; +import de.bjusystems.vdrmanager.tasks.CreateTimerTask; +import de.bjusystems.vdrmanager.tasks.ModifyTimerTask; +import de.bjusystems.vdrmanager.utils.svdrp.SetTimerClient.TimerOperation; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent; -import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException; -/** - * This class is used for showing what's current running on all channels - * - * @author bju - */ public class TimerDetailsActivity extends Activity implements OnClickListener, - OnDateSetListener, OnTimeSetListener, SvdrpAsyncListener { + OnDateSetListener, OnTimeSetListener { - Preferences prefs; - TextView dateField; - TextView startField; - TextView endField; - boolean editStart; - Timer timer; - SvdrpProgressDialog progress; - SetTimerClient setTimerClient; + public static final int REQUEST_CODE_TIMER_EDIT = 84; + + public static final int REQUEST_CODE_TIMER_ADD = 85; @Override - protected void onCreate(final Bundle savedInstanceState) { + protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // Attach view - setContentView(R.layout.timer_detail); + View view = getLayoutInflater().inflate(R.layout.timer_detail, null); + tView = new EditTimerViewHolder(); + tView.view = view; + tView.title = (TextView) view.findViewById(R.id.timer_detail_title); + tView.channel = (TextView) view.findViewById(R.id.timer_detail_channel); + tView.dateField = (TextView) view.findViewById(R.id.timer_detail_day); + tView.startField = (TextView) view + .findViewById(R.id.timer_detail_start); + tView.endField = (TextView) view.findViewById(R.id.timer_detail_end); + tView.saveButton = (Button) view.findViewById(R.id.timer_details_save); + tView.modifyButton = (Button) view + .findViewById(R.id.timer_details_modify); + + view.findViewById(R.id.timer_details_cancel).setOnClickListener(this); + tView.dateField.setOnClickListener(this); + tView.startField.setOnClickListener(this); + tView.endField.setOnClickListener(this); + tView.saveButton.setOnClickListener(this); + tView.modifyButton.setOnClickListener(this); + setContentView(view); + timer = getApp().getCurrentTimer(); + int op = getIntent().getExtras().getInt(Intents.TIMER_OP); + switch (op) { + case Intents.ADD_TIMER: + setTitle(R.string.timer_details_add_title); + add(); + break; + case Intents.EDIT_TIMER: + setTitle(R.string.timer_details_modify_title); + modify(); + break; - // timer - timer = ((VdrManagerApp) getApplication()).getCurrentTimer(); + default: + finish(); + } - // update display - updateDisplay(); + } - // register buttons - final Button saveButton = (Button) findViewById(R.id.timer_details_save); - saveButton.setOnClickListener(this); - if (timer.getNumber() > 0) { - saveButton.setText(R.string.timer_details_save_title); - } else { - saveButton.setText(R.string.timer_details_create_title); + public class EditTimerViewHolder { + View view; + TextView title; + TextView channel; + TextView dateField; + TextView startField; + TextView endField; + Button saveButton; + Button modifyButton; + } + + EditTimerViewHolder tView = null; + + boolean editStart; + + // SetTimerClient setTimerClient; + + Timer timer; + + private void updateDisplay(TimerOperation op) { + updateDisplay(); + switch (op) { + case CREATE: + tView.modifyButton.setVisibility(View.GONE); + tView.saveButton.setVisibility(View.VISIBLE); + tView.saveButton.setText(R.string.timer_details_create_title); + break; + case MODIFY: + tView.saveButton.setVisibility(View.GONE); + tView.modifyButton.setVisibility(View.VISIBLE); + tView.saveButton.setText(R.string.timer_details_save_title); + break; } - // register text fields for editing - dateField.setOnClickListener(this); - startField.setOnClickListener(this); - endField.setOnClickListener(this); } - @Override - protected void onResume() { - super.onResume(); + private void updateDisplay() { + EventFormatter f = new EventFormatter(timer, true); + tView.channel.setText(timer.getChannelNumber() + " " + + timer.getChannelName()); + tView.title.setText(f.getTitle()); + tView.dateField.setText(f.getDate()); + tView.startField.setText(f.getTime()); + tView.endField.setText(f.getStop()); } - @Override - protected void onPause() { - super.onPause(); + protected VdrManagerApp getApp() { + final VdrManagerApp app = (VdrManagerApp) getApplication(); + return app; + } + + public void add() { + updateDisplay(TimerOperation.CREATE); + } + + public void modify() { + updateDisplay(TimerOperation.MODIFY); } public void onClick(final View view) { @@ -114,30 +166,29 @@ public class TimerDetailsActivity extends Activity implements OnClickListener, dialog.show(); break; } - case R.id.timer_details_save: { - // collect values - timer.setTitle(((TextView) findViewById(R.id.timer_detail_title)) - .getText().toString()); - - // create client for saving the timer - //setTimerClient = new SetTimerClient(timer, false); - - // create backgound task - final SvdrpAsyncTask> task = new SvdrpAsyncTask>( - setTimerClient); - - // create progress - progress = new SvdrpProgressDialog(this, setTimerClient); - - // attach listener - task.addListener(this); + case R.id.timer_details_cancel: { + finishActivity(REQUEST_CODE_TIMER_EDIT); + finish(); + break; + } + case R.id.timer_details_modify: + modifyTimer(timer); + say(R.string.done); + break; - // start task - task.run(); + case R.id.timer_details_save: { + createTimer(timer); + say(R.string.done); + break; } + } } + protected void say(int res) { + Toast.makeText(this, res, Toast.LENGTH_SHORT).show(); + } + public void onTimeSet(final TimePicker view, final int hourOfDay, final int minute) { if (editStart) { @@ -189,54 +240,29 @@ public class TimerDetailsActivity extends Activity implements OnClickListener, } - private void updateDisplay() { - - ((TextView) findViewById(R.id.timer_detail_title)).setText(timer - .getTitle()); - ((TextView) findViewById(R.id.timer_detail_channel)).setText(timer - .getChannelName()); - dateField = (TextView) findViewById(R.id.timer_detail_day); - final DateFormatter dateFormatter = new DateFormatter(timer.getStart()); - dateField.setText(dateFormatter.getDateString()); - startField = (TextView) findViewById(R.id.timer_detail_start); - startField.setText(dateFormatter.getTimeString()); - endField = (TextView) findViewById(R.id.timer_detail_end); - endField.setText(new DateFormatter(timer.getStop()).getTimeString()); - - final Button button = (Button) findViewById(R.id.timer_details_save); - if (timer.getNumber() > 0) { - // existing timer - button.setText(R.string.timer_details_save_title); - } else { - // new timer - button.setText(R.string.timer_details_create_title); - } + private void createTimer(Timer timer) { + final CreateTimerTask task = new CreateTimerTask(this, timer) { + @Override + public void finished(SvdrpEvent event) { + done(); + } + }; + task.start(); } - public void svdrpEvent(final SvdrpEvent event, final Timer result) { - - progress.svdrpEvent(event); + public void done() { + setResult(RESULT_OK); + finish(); + } - switch (event) { - case FINISHED_ABNORMALY: - finish(); - if(progress != null) { - progress.dismiss(); - progress = null; + private void modifyTimer(Timer timer) { + final ModifyTimerTask task = new ModifyTimerTask(this, timer) { + @Override + public void finished(SvdrpEvent event) { + done(); } - break; - case FINISHED_SUCCESS: - if(progress != null){ - progress.dismiss(); - progress = null; - } - setResult(Activity.RESULT_OK); - finish(); - break; - } + }; + task.start(); } - public void svdrpException(final SvdrpException exception) { - progress.svdrpException(exception); - } } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerListActivity.java index 7c3c77b..8d8d3a3 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerListActivity.java @@ -32,7 +32,7 @@ public class TimerListActivity extends BaseTimerEditActivity implements protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Attach view - setContentView(getMainLayout()); +// setContentView(getMainLayout()); // create an adapter adapter = new TimeEventAdapter(this); @@ -57,15 +57,16 @@ public class TimerListActivity extends BaseTimerEditActivity implements @Override protected void onPause() { super.onPause(); - if (timerClient != null) { - timerClient.abort(); - } - dismiss(progress); } private void startTimerQuery() { + if (checkInternetConnection() == false) { + switchNoConnection(); + return; + } + // get timer client timerClient = new TimerClient(); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java index 983fb28..d3fbcb6 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrManagerActivity.java @@ -15,7 +15,6 @@ import de.bjusystems.vdrmanager.utils.wakeup.AsyncWakeupTask; public class VdrManagerActivity extends Activity implements OnClickListener { - @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -23,15 +22,15 @@ public class VdrManagerActivity extends Activity implements OnClickListener { // attach view setContentView(R.layout.vdrmanager); - //Preferences.loadPreferences(this); + // 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){ + + if (Preferences.get().isWakeupEnabled() == false) { findViewById(R.id.action_menu_wakeup).setVisibility(View.GONE); } else { findViewById(R.id.action_menu_wakeup).setOnClickListener(this); @@ -49,21 +48,26 @@ public class VdrManagerActivity extends Activity implements OnClickListener { 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: + 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 intent = new Intent(); intent.setClass(this, PreferencesActivity.class); startActivity(intent); break; + } + case R.id.main_menu_info: { + About.show(this); + break; + } case R.id.main_menu_exit: finish(); break; @@ -73,11 +77,11 @@ public class VdrManagerActivity extends Activity implements OnClickListener { @Override public void onBackPressed() { - if(Preferences.get().isQuiteOnBackButton()){ + if (Preferences.get().isQuiteOnBackButton()) { super.onBackPressed(); } } - + public void startActivity(Class clazz) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClass(this, clazz); @@ -110,12 +114,12 @@ public class VdrManagerActivity extends Activity implements OnClickListener { } } - + @Override public boolean onSearchRequested() { - Bundle appData = new Bundle(); - //appData.putBoolean(SearchableActivity.JARGON, true); - startSearch(null, false, appData, false); - return true; + Bundle appData = new Bundle(); + // appData.putBoolean(SearchableActivity.JARGON, true); + startSearch(null, false, appData, false); + return true; } } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/ChannelClient.java b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/ChannelClient.java index 5ec1a6a..41ca798 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/ChannelClient.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/ChannelClient.java @@ -3,7 +3,6 @@ package de.bjusystems.vdrmanager.utils.svdrp; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; -import java.util.List; import java.util.TreeMap; import de.bjusystems.vdrmanager.R; @@ -27,18 +26,18 @@ public class ChannelClient extends SvdrpClient implements private static ArrayList channels = new ArrayList(); - private static boolean inited = false; + private static boolean inited = false; - - public ChannelClient(boolean useCache){ + public ChannelClient(boolean useCache) { super(); - if(useCache == false){ + if (useCache == false) { clearCache(); } + setResultInfoEnabled(true); addSvdrpListener(this); } - - private void clearCache(){ + + private void clearCache() { channelGroups.clear(); groupChannels.clear(); providerChannels.clear(); @@ -46,9 +45,8 @@ public class ChannelClient extends SvdrpClient implements inited = false; } - public static ArrayList getChannelGroups() { - return channelGroups; + return channelGroups; } public static HashMap> getGroupChannels() { @@ -103,37 +101,33 @@ public class ChannelClient extends SvdrpClient implements return R.string.progress_channels_loading; } - private synchronized void initChannels(List results) { - if(inited){ - return; - } - ArrayList currentChannels = null; - for (Channel c : results) { - if (c.isGroupSeparator()) { - channelGroups.add(c.getName()); - currentChannels = new ArrayList(); - groupChannels.put(c.getName(), currentChannels); - } else { - channels.add(c); - currentChannels.add(c); - String provider = c.getProvider(); - ArrayList channels = providerChannels.get(provider); - if (channels == null) { - channels = new ArrayList(); - providerChannels.put(provider, channels); - } - channels.add(c); + ArrayList currentChannels = null; + + private void received(Channel c) { + if (c.isGroupSeparator()) { + channelGroups.add(c.getName()); + currentChannels = new ArrayList(); + groupChannels.put(c.getName(), currentChannels); + } else { + channels.add(c); + currentChannels.add(c); + String provider = c.getProvider(); + ArrayList channels = providerChannels.get(provider); + if (channels == null) { + channels = new ArrayList(); + providerChannels.put(provider, channels); } + channels.add(c); } - inited = true; } - public void svdrpEvent(SvdrpEvent event, Channel result) { - if(event != SvdrpEvent.FINISHED_SUCCESS){ + public void svdrpEvent(SvdrpEvent event, Channel c) { + if (event == SvdrpEvent.RESULT_RECEIVED) { + received(c); return; } - initChannels(getResults()); - getResults().clear(); + if(event == SvdrpEvent.FINISHED_SUCCESS){ + inited = true; + } } - -} \ No newline at end of file +} diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/EpgClient.java b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/EpgClient.java index df30055..3d1e73f 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/EpgClient.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/EpgClient.java @@ -1,5 +1,6 @@ package de.bjusystems.vdrmanager.utils.svdrp; +import android.text.TextUtils; import de.bjusystems.vdrmanager.R; import de.bjusystems.vdrmanager.data.Channel; import de.bjusystems.vdrmanager.data.Epg; @@ -67,7 +68,7 @@ public class EpgClient extends SvdrpClient { } else if (channel != null) { runCommand(String.format("cevents %s", channel.getNumber())); } else if (search != null) { - runCommand(String.format("search %s %s", Preferences.getPreferences().getChannels(), search.toCommandLine())); + runCommand(String.format("search %s:%s", Preferences.get().getChannels(), search.toCommandLine())); } } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java index 35016b1..6849e90 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java @@ -41,6 +41,13 @@ public abstract class SvdrpClient { private boolean resultInfoEnabled = false; private Timer watchDog = new Timer(); + + public boolean isConnected(){ + if(socket == null){ + return false; + } + return socket.isConnected(); + } /** * Parse received answer line @@ -97,6 +104,23 @@ public abstract class SvdrpClient { */ public void abort() { abort = true; + try { + if (socket != null) { + if (socket.isConnected()) { + socket.shutdownInput(); + socket.shutdownOutput(); + socket.close(); + } else { + if(st != null){ + st.interrupt(); + } + socket.close(); + } + } + } catch (Exception ex) { + Log.w(TAG, ex); + } + } /** @@ -108,6 +132,8 @@ public abstract class SvdrpClient { return results; } + private Thread st; + /** * Connect to SVDRP * @@ -122,15 +148,45 @@ public abstract class SvdrpClient { */ protected boolean connect() throws IOException { - Preferences prefs = Preferences.get(); + final Preferences prefs = Preferences.get(); try { // connect - //TODO prefs informListener(SvdrpEvent.CONNECTING, null); socket = new Socket(); - socket.connect(new InetSocketAddress(prefs.getSvdrpHost(), prefs.getSvdrpPort()), 10 * 1000);//8 secs for connect - socket.setSoTimeout(15 * 1000);//15 sec for each read - final long delay = C.ONE_MINUTE_IN_MILLIS * 3; //in 3 minutes we abort the communication + //st = new Thread(){ +// @Override +// public void run() { +// try{ + socket.connect( + new InetSocketAddress(prefs.getSvdrpHost(), prefs + .getSvdrpPort()), + prefs.getConnectionTimeout() * 1000);// 8 secs for connect +// }catch(IOException iox){ +// throw new RuntimeException(); +// } +// } +// +// }; + +// st.start(); +// +// try { +// st.join(); +// } catch (InterruptedException e) { +// Thread.currentThread().interrupt(); +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// + socket.setSoTimeout(prefs.getReadTimeout() * 1000);// 15 sec for + // each read + final long delay = C.ONE_MINUTE_IN_MILLIS * prefs.getTimeout() * 60; // in + // 3 + // minutes + // we + // abort + // the + // communication watchDog.schedule(new TimerTask() { @Override public void run() { @@ -139,7 +195,7 @@ public abstract class SvdrpClient { } }, delay); informListener(SvdrpEvent.CONNECTED, null); - } catch (final IOException e) { + } catch (final Exception e) { Log.w(TAG, e); informListener(SvdrpEvent.CONNECT_ERROR, null); return false; @@ -159,7 +215,6 @@ public abstract class SvdrpClient { } else { informListener(SvdrpEvent.LOGGED_IN, null); } - return true; } -- cgit v1.2.3