From c16a0149fafd9a32a568ccd57bb6d514937a5ea2 Mon Sep 17 00:00:00 2001 From: twig Date: Fri, 3 Jun 2016 07:54:12 +1000 Subject: [PATCH] - now shows the current filter on remote rss feeds in toolbar subtitle - scroll to top after setting new remote rss items - format the item timestamp --- .../core/gui/remoterss/RemoteRssActivity.java | 11 ++++++++--- .../core/gui/remoterss/RemoteRssFragment.java | 1 + .../core/gui/remoterss/RemoteRssItemView.java | 13 +++++++++---- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssActivity.java b/app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssActivity.java index a8f1af53..3a5dee71 100644 --- a/app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssActivity.java @@ -119,11 +119,11 @@ public class RemoteRssActivity extends AppCompatActivity { ServerSetting lastUsed = applicationSettings.getLastUsedServer(); currentConnection = lastUsed.createServerAdapter(connectivityHelper.getConnectedNetworkName(), this); - // Show all items - showRecentItems(); - // Fill in the filter list showChannelFilters(); + + // Show all items + showRecentItems(); } @@ -172,6 +172,8 @@ public class RemoteRssActivity extends AppCompatActivity { } fragmentRemoteRss.updateTorrentFiles(recentItems); + RemoteRssChannel channel = (RemoteRssChannel) drawerList.getAdapter().getItem(0); + getSupportActionBar().setSubtitle(channel.getName()); } protected void showChannelFilters() { @@ -200,6 +202,9 @@ public class RemoteRssActivity extends AppCompatActivity { fragmentRemoteRss.updateTorrentFiles(feeds.get(position -1).getItems()); } + RemoteRssChannel channel = (RemoteRssChannel) drawerList.getAdapter().getItem(position); + getSupportActionBar().setSubtitle(channel.getName()); + drawerLayout.closeDrawers(); } diff --git a/app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssFragment.java b/app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssFragment.java index 303bc027..11948296 100644 --- a/app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssFragment.java +++ b/app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssFragment.java @@ -110,6 +110,7 @@ public class RemoteRssFragment extends Fragment { public void updateTorrentFiles(List remoteRssFiles) { torrentFiles = new ArrayList<>(remoteRssFiles); adapter.updateFiles(torrentFiles); + torrentsList.smoothScrollToPosition(0); } @ItemClick(resName = "torrents_list") diff --git a/app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssItemView.java b/app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssItemView.java index b9be7e5c..ff4e09fe 100644 --- a/app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssItemView.java +++ b/app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssItemView.java @@ -17,6 +17,7 @@ package org.transdroid.core.gui.remoterss; import android.content.Context; +import android.text.format.DateFormat; import android.widget.LinearLayout; import android.widget.TextView; @@ -41,10 +42,14 @@ public class RemoteRssItemView extends LinearLayout { super(context); } - public void bind(RemoteRssItem file) { - nameText.setText(file.getName()); - dateText.setText(String.valueOf(file.getTimestamp())); - labelText.setText(file.getSourceName()); + public void bind(RemoteRssItem item) { + labelText.setText(item.getSourceName()); + nameText.setText(item.getName()); + dateText.setText( + DateFormat.getDateFormat(getContext()).format(item.getTimestamp()) + + " " + + DateFormat.getTimeFormat(getContext()).format(item.getTimestamp()) + ); } }