From 5664acee87aa98b09130c70eaf480c11d64ce142 Mon Sep 17 00:00:00 2001 From: lado Date: Sun, 3 Nov 2013 23:01:18 +0100 Subject: fix recordings --- .../vdrmanager/gui/EpgDetailsActivity.java | 9 +-- .../vdrmanager/gui/RecordingListActivity.java | 76 ++++++++++++++++------ 2 files changed, 58 insertions(+), 27 deletions(-) (limited to 'vdrmanager') diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java index f66778a..beaf30d 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java @@ -531,16 +531,10 @@ public class EpgDetailsActivity extends ICSBaseActivity implements new AlertDialog.Builder(this) .setAdapter(ada, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { - final Timer t; - if (timer == null) { - t = timerable.createTimer(); - } else { - t = timer; - } - getApp().setCurrentTimer(t); Wrapper w = ada.getItem(which); switch (w.id) { case R.string.epg_item_menu_timer_add: { + getApp().setCurrentTimer(timerable.createTimer()); final Intent intent = new Intent(); intent.setClass(EpgDetailsActivity.this, TimerDetailsActivity.class); @@ -552,6 +546,7 @@ public class EpgDetailsActivity extends ICSBaseActivity implements break; } case R.string.epg_item_menu_timer_modify: { + getApp().setCurrentTimer(timer); final Intent intent = new Intent(); intent.setClass(EpgDetailsActivity.this, TimerDetailsActivity.class); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java index 7f38854..f137fde 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Comparator; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -31,7 +32,6 @@ import de.bjusystems.vdrmanager.data.Preferences; import de.bjusystems.vdrmanager.data.Recording; import de.bjusystems.vdrmanager.data.RecordingListItem; import de.bjusystems.vdrmanager.tasks.DeleteRecordingTask; -import de.bjusystems.vdrmanager.tasks.VoidAsyncTask; import de.bjusystems.vdrmanager.utils.date.DateFormatter; import de.bjusystems.vdrmanager.utils.svdrp.RecordingClient; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncTask; @@ -179,10 +179,9 @@ public class RecordingListActivity extends BaseEventListActivity } } - private void updateCurrentFolderInfo() { + private void updateCurrentFolderInfo( int size) { folderInfo.setText("/" + currentFolder.replaceAll("~", "/")); - final List list = CACHE.get(currentFolder); - currentCount.setText(String.valueOf(list.size())); + currentCount.setText(String.valueOf(size)); } /* @@ -208,7 +207,7 @@ public class RecordingListActivity extends BaseEventListActivity @Override protected void prepareDetailsViewData(final EventListItem event) { getApp().setCurrentEvent(event.getEvent()); - getApp().setCurrentEpgList(CACHE.get(currentFolder)); + getApp().setCurrentEpgList(CACHEget(currentFolder)); } @Override @@ -323,11 +322,11 @@ public class RecordingListActivity extends BaseEventListActivity /* */ switch (sortBy) { case MENU_GROUP_DEFAULT: { - sortItemsByTime(CACHE.get(currentFolder), true); + sortItemsByTime(CACHEget(currentFolder), true); break; } case MENU_GROUP_ALPHABET: { - Collections.sort(CACHE.get(currentFolder), new TitleComparator()); + Collections.sort(CACHEget(currentFolder), new TitleComparator()); break; } // case MENU_GROUP_CHANNEL: { @@ -336,16 +335,40 @@ public class RecordingListActivity extends BaseEventListActivity } } + private List CACHEget(String currentFolder) { + List list = CACHE.get(currentFolder); + if (list != null) { + return list; + } + return EMPTY; + } + + private int getCountInFolder(String base, String folder) { + + if (base.equals(Recording.ROOT_FOLDER) == false) { + folder = base + Recording.FOLDERDELIMCHAR + folder; + } + int count = CACHEget(folder).size(); + + Set set = FOLDERS.get(folder); + + if (set == null) { + return count; + } + + for (String f : set) { + count += getCountInFolder(folder, f); + } + + return count; + } + @Override protected void fillAdapter() { adapter.clear(); - final List list = CACHE.get(currentFolder); - if (list == null || list.isEmpty()) { - return; - } + List list = CACHEget(currentFolder); - updateCurrentFolderInfo(); sort(); @@ -353,22 +376,26 @@ public class RecordingListActivity extends BaseEventListActivity int day = -1; final Set folders = FOLDERS.get(currentFolder); + int currenFolderSum = 0; if (folders != null) { for (final String f : folders) { final RecordingListItem recordingListItem = new RecordingListItem( f); recordingListItem.folder = f; - final String sf = currentFolder.length() > 0 ? currentFolder - + Recording.FOLDERDELIMCHAR + f : f; - final List list2 = CACHE.get(sf); - if (list2 != null) { - recordingListItem.count = list2.size(); - } + // final String sf = currentFolder.length() > 0 ? currentFolder + // + Recording.FOLDERDELIMCHAR + f : f; + // final List list2 = CACHE.get(sf); + // if (list2 != null) { + recordingListItem.count = getCountInFolder(currentFolder, f); + currenFolderSum += recordingListItem.count; + // } adapter.add(recordingListItem); } } - for (final Event rec : CACHE.get(currentFolder)) { + updateCurrentFolderInfo(list.size() + currenFolderSum); + + for (final Event rec : CACHEget(currentFolder)) { cal.setTime(rec.getStart()); final int eday = cal.get(Calendar.DAY_OF_YEAR); if (eday != day) { @@ -436,6 +463,15 @@ public class RecordingListActivity extends BaseEventListActivity list.add(value); + if (key.equals(Recording.ROOT_FOLDER) == false) { + Set set = FOLDERS.get(Recording.ROOT_FOLDER); + if (set == null) { + set = new HashSet(); + FOLDERS.put(key, set); + } + set.add(key); + } + // a b // a // c @@ -498,7 +534,7 @@ public class RecordingListActivity extends BaseEventListActivity String[] split = meta.split(":"); if (split.length != 3) { - Log.w(TAG, "Recoring list meta ist wrong"); + Log.w(TAG, "Recoring list meta is wrong"); return; } -- cgit v1.2.3