From c5470a329c2f04ce48058de460fdb79deb91b8cf Mon Sep 17 00:00:00 2001 From: lado Date: Wed, 3 Apr 2013 11:28:10 +0200 Subject: Feature #1321 --- .../vdrmanager/data/RecordingListItem.java | 2 + .../vdrmanager/gui/BaseEventAdapter.java | 2 + .../vdrmanager/gui/RecordingAdapter.java | 9 ++-- .../vdrmanager/gui/RecordingListActivity.java | 50 +++++++++++++--------- 4 files changed, 40 insertions(+), 23 deletions(-) (limited to 'vdrmanager/src') diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/RecordingListItem.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/RecordingListItem.java index b3137e3..486b1a3 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/RecordingListItem.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/RecordingListItem.java @@ -5,6 +5,8 @@ public class RecordingListItem extends EventListItem { public String folder; + public Integer count = 0; + public RecordingListItem(Recording rec) { super(rec); } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventAdapter.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventAdapter.java index 82ac575..2f5dce5 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventAdapter.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventAdapter.java @@ -166,6 +166,8 @@ abstract class BaseEventAdapter extends ArrayAdapter Recording r = (Recording) item.getEvent(); if (r.getTimerStopTime() != null) { itemHolder.state.setImageResource(R.drawable.timer_recording); + } else { + itemHolder.state.setImageResource(R.drawable.timer_none); } } else if (item.getEvent() instanceof Timerable == true) { TimerMatch match = ((Timerable) item.getEvent()).getTimerMatch(); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingAdapter.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingAdapter.java index bbc784c..ff69795 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingAdapter.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingAdapter.java @@ -57,12 +57,14 @@ class RecordingAdapter extends BaseEventAdapter { class EventListItemFolderHolder { public TextView folder; + public TextView count; } protected EventListItemFolderHolder getFolderViewHolder(EventListItem item, View view) { EventListItemFolderHolder itemHolder = new EventListItemFolderHolder(); itemHolder.folder = (TextView) view.findViewById(R.id.header_item); + itemHolder.count = (TextView) view.findViewById(R.id.count); return itemHolder; } @@ -78,16 +80,17 @@ class RecordingAdapter extends BaseEventAdapter { return super.getView(position, convertView, parent); } - Object holder = null; + EventListItemFolderHolder holder = null; if (convertView == null || (convertView != null && convertView.getTag() instanceof EventListItemFolderHolder) == false) { convertView = inflater.inflate(R.layout.folder_item, null); holder = getFolderViewHolder(item, convertView); convertView.setTag(holder); } else { - holder = convertView.getTag(); + holder = (EventListItemFolderHolder) convertView.getTag(); } - ((EventListItemFolderHolder) holder).folder.setText(item.folder); + holder.folder.setText(item.folder); + holder.count.setText(String.valueOf(item.count)); return convertView; } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java index d3cb81a..c19e7ae 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java @@ -3,6 +3,7 @@ package de.bjusystems.vdrmanager.gui; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Set; @@ -26,7 +27,6 @@ import de.bjusystems.vdrmanager.data.EventListItem; import de.bjusystems.vdrmanager.data.Preferences; import de.bjusystems.vdrmanager.data.Recording; import de.bjusystems.vdrmanager.data.RecordingListItem; -import de.bjusystems.vdrmanager.data.Recording.Folder; import de.bjusystems.vdrmanager.tasks.DeleteRecordingTask; import de.bjusystems.vdrmanager.utils.date.DateFormatter; import de.bjusystems.vdrmanager.utils.svdrp.RecordingClient; @@ -68,7 +68,6 @@ public class RecordingListActivity extends BaseEventListActivity protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - adapter = new RecordingAdapter(this); // attach adapter to ListView @@ -138,10 +137,11 @@ public class RecordingListActivity extends BaseEventListActivity final RecordingListItem item = (RecordingListItem) adapter .getItem(position); if (item.isFolder()) { - if(currentFolder.equals(Recording.ROOT_FOLDER)){ + if (currentFolder.equals(Recording.ROOT_FOLDER)) { currentFolder = item.folder; } else { - currentFolder = currentFolder + Recording.FOLDERDELIMCHAR + item.folder; + currentFolder = currentFolder + Recording.FOLDERDELIMCHAR + + item.folder; } stack.push(currentFolder); fillAdapter(); @@ -315,6 +315,11 @@ public class RecordingListActivity extends BaseEventListActivity for (String f : folders) { RecordingListItem recordingListItem = new RecordingListItem(f); recordingListItem.folder = f; + String sf = currentFolder.length() > 0 ? currentFolder + Recording.FOLDERDELIMCHAR + f : f; + List list2 = CACHE.get(sf); + if (list2 != null) { + recordingListItem.count = list2.size(); + } adapter.add(recordingListItem); } } @@ -358,34 +363,39 @@ public class RecordingListActivity extends BaseEventListActivity String[] split = folder.split(Recording.FOLDERDELIMCHAR); String key = null; String value = null; - if(split.length == 1){ - key = Recording.ROOT_FOLDER ; + if (split.length == 1) { + key = Recording.ROOT_FOLDER; value = split[0]; } else { value = split[split.length - 1]; - //StringBuilder sb = new StringBuilder(); - //String sep = ""; - //for(int i = 0; i < split.length - 1; ++i){ - //sb.append(sep).append(split[i]); - //sep = Recording.FOLDERDELIMCHAR; - //} - key = folder.subSequence(0, folder.length() - (value.length()+1) ).toString(); + // StringBuilder sb = new StringBuilder(); + // String sep = ""; + // for(int i = 0; i < split.length - 1; ++i){ + // sb.append(sep).append(split[i]); + // sep = Recording.FOLDERDELIMCHAR; + // } + key = folder.subSequence(0, + folder.length() - (value.length() + 1)).toString(); } Set list = FOLDERS.get(key); - if(list == null){ - list = new TreeSet(); + if (list == null) { + list = new TreeSet(new Comparator() { + @Override + public int compare(String lhs, String rhs) { + return lhs.compareToIgnoreCase(rhs); + } + }); FOLDERS.put(key, list); } list.add(value); - //a b - //a - //c - //a~b > k - + // a b + // a + // c + // a~b > k } List list = CACHE.get(folder); -- cgit v1.2.3