Browse Source

- replaced the navigation drawer filter with an ugly spinner

- filters work again
pull/526/head
Twig N 5 years ago
parent
commit
ff3a289914
  1. 70
      app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssFragment.java
  2. 42
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedsActivity.java
  3. 20
      app/src/main/res/layout/fragment_remoterss.xml

70
app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssFragment.java

@ -18,32 +18,23 @@ package org.transdroid.core.gui.remoterss;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.ActionMenuView;
import android.view.View; import android.view.View;
import android.widget.ListView; import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import com.nispok.snackbar.Snackbar;
import com.nispok.snackbar.SnackbarManager;
import com.nispok.snackbar.enums.SnackbarType;
import org.androidannotations.annotations.AfterViews; import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.Bean; import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EFragment; import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.ItemClick; import org.androidannotations.annotations.ItemClick;
import org.androidannotations.annotations.UiThread; import org.androidannotations.annotations.ItemSelect;
import org.androidannotations.annotations.ViewById; import org.androidannotations.annotations.ViewById;
import org.transdroid.R; import org.transdroid.R;
import org.transdroid.core.gui.lists.LocalTorrent; import org.transdroid.core.gui.lists.SimpleListItemAdapter;
import org.transdroid.core.gui.log.Log; import org.transdroid.core.gui.log.Log;
import org.transdroid.core.gui.navigation.RefreshableActivity; import org.transdroid.core.gui.remoterss.data.RemoteRssChannel;
import org.transdroid.core.gui.remoterss.data.RemoteRssItem; import org.transdroid.core.gui.remoterss.data.RemoteRssItem;
import org.transdroid.core.gui.remoterss.data.RemoteRssSupplier;
import org.transdroid.core.gui.rss.RssfeedsActivity; import org.transdroid.core.gui.rss.RssfeedsActivity;
import org.transdroid.daemon.DaemonException;
import org.transdroid.daemon.task.DaemonTaskSuccessResult;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -64,8 +55,8 @@ public class RemoteRssFragment extends Fragment {
// Views // Views
@ViewById @ViewById
protected View detailsContainer; protected View detailsContainer;
@ViewById(R.id.contextual_menu) @ViewById
protected ActionMenuView contextualMenu; protected Spinner remoterssFilter;
@ViewById @ViewById
protected ListView torrentsList; protected ListView torrentsList;
@ViewById @ViewById
@ -75,20 +66,9 @@ public class RemoteRssFragment extends Fragment {
@AfterViews @AfterViews
protected void init() { protected void init() {
// Inject menu options in the actions toolbar // Inject menu options in the actions toolbar
setHasOptionsMenu(true); setHasOptionsMenu(true);
// // On large screens where this fragment is shown next to the torrents list, we show a continues grey vertical
// // line to separate the lists visually
// if (!NavigationHelper_.getInstance_(getActivity()).isSmallScreen()) {
// if (SystemSettings_.getInstance_(getActivity()).useDarkTheme()) {
// detailsContainer.setBackgroundResource(R.drawable.details_list_background_dark);
// } else {
// detailsContainer.setBackgroundResource(R.drawable.details_list_background_light);
// }
// }
// Set up details adapter // Set up details adapter
adapter = new RemoteRssItemsAdapter(getActivity()); adapter = new RemoteRssItemsAdapter(getActivity());
torrentsList.setAdapter(adapter); torrentsList.setAdapter(adapter);
@ -120,44 +100,22 @@ public class RemoteRssFragment extends Fragment {
} }
} }
public void updateChannelFilters(List<RemoteRssChannel> feedLabels) {
remoterssFilter.setAdapter(new SimpleListItemAdapter(this.getContext(), feedLabels));
}
/** /**
* When the user clicks on an item, prepare to download it. * When the user clicks on an item, prepare to download it.
*/ */
@ItemClick(resName = "torrents_list") @ItemClick(resName = "torrents_list")
protected void detailsListClicked(int position) { protected void detailsListClicked(int position) {
RemoteRssItem item = (RemoteRssItem) adapter.getItem(position); RemoteRssItem item = (RemoteRssItem) adapter.getItem(position);
// downloadRemoteRssItem(item);
((RssfeedsActivity) getActivity()).downloadRemoteRssItem(item); ((RssfeedsActivity) getActivity()).downloadRemoteRssItem(item);
} }
// /** @ItemSelect(R.id.remoterss_filter)
// * Download the item in a background thread and display success/fail accordingly. protected void onFeedSelected(boolean selected, int position) {
// */ ((RssfeedsActivity) getActivity()).onFeedSelected(position);
// @Background }
// protected void downloadRemoteRssItem(RemoteRssItem item) {
// final RemoteRssActivity activity = (RemoteRssActivity) getActivity();
// final RemoteRssSupplier supplier = (RemoteRssSupplier) activity.getCurrentConnection();
//
// try {
// supplier.downloadRemoteRssItem(log, item, activity.getChannel(item.getSourceName()));
// onTaskSucceeded(null, getString(R.string.result_added, item.getTitle()));
// } catch (DaemonException e) {
// onTaskFailed(getString(LocalTorrent.getResourceForDaemonException(e)));
// }
// }
//
// @UiThread
// protected void onTaskSucceeded(DaemonTaskSuccessResult result, String successMessage) {
// SnackbarManager.show(Snackbar.with(getActivity()).text(successMessage));
// }
//
// @UiThread
// protected void onTaskFailed(String message) {
// SnackbarManager.show(Snackbar.with(getActivity())
// .text(message)
// .colorResource(R.color.red)
// .type(SnackbarType.MULTI_LINE)
// );
// }
} }

42
app/src/main/java/org/transdroid/core/gui/rss/RssfeedsActivity.java

@ -21,6 +21,7 @@ import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcel;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout; import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
@ -324,16 +325,10 @@ public class RssfeedsActivity extends AppCompatActivity {
return; return;
} }
// if (feeds != null) {
// Called from a configuration change. No need to load anything from server
// showChannelFilters();
fragmentRemoteFeeds.updateRemoteItems( fragmentRemoteFeeds.updateRemoteItems(
// selectedFilter == 0 ? recentItems : feeds.get(selectedFilter).getItems(), selectedFilter == 0 ? recentItems : feeds.get(selectedFilter -1).getItems(),
recentItems,
false /* allow android to restore scroll position */ ); false /* allow android to restore scroll position */ );
// } else { showRemoteChannelFilters();
// loadFeeds();
// }
} }
@UiThread @UiThread
@ -345,17 +340,19 @@ public class RssfeedsActivity extends AppCompatActivity {
} }
// @ItemClick(R.id.drawer_list) public void onFeedSelected(int position) {
protected void onFeedSelected(int position) {
selectedFilter = position; selectedFilter = position;
RemoteRssChannel channel = feeds.get(position);
fragmentRemoteFeeds.updateRemoteItems(position == 0 ? recentItems : channel.getItems(), true); if (position == 0) {
fragmentRemoteFeeds.updateRemoteItems(recentItems, true);
}
else {
RemoteRssChannel channel = feeds.get(selectedFilter -1);
fragmentRemoteFeeds.updateRemoteItems(channel.getItems(), true);
}
// RemoteRssChannel channel = (RemoteRssChannel) drawerList.getAdapter().getItem(position); // RemoteRssChannel channel = (RemoteRssChannel) drawerList.getAdapter().getItem(position);
// getSupportActionBar().setSubtitle(channel.getName()); // getSupportActionBar().setSubtitle(channel.getName());
// drawerLayout.closeDrawers();
} }
/** /**
@ -387,4 +384,21 @@ public class RssfeedsActivity extends AppCompatActivity {
.type(SnackbarType.MULTI_LINE) .type(SnackbarType.MULTI_LINE)
); );
} }
private void showRemoteChannelFilters() {
List<RemoteRssChannel> feedLabels = new ArrayList<>(feeds.size() +1);
feedLabels.add(new RemoteRssChannel() {
@Override
public String getName() {
return getString(R.string.remoterss_filter_allrecent);
}
@Override
public void writeToParcel(Parcel dest, int flags) {
}
});
feedLabels.addAll(feeds);
fragmentRemoteFeeds.updateChannelFilters(feedLabels);
}
} }

20
app/src/main/res/layout/fragment_remoterss.xml

@ -15,10 +15,18 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
--> -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout
xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"> android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Spinner
android:id="@+id/remoterss_filter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:spinnerMode="dialog" />
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -33,5 +41,5 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:clipToPadding="false" android:clipToPadding="false"
tools:listitem="@layout/list_item_remoterssitem" tools:listitem="@layout/list_item_remoterssitem"
tools:visibility="visible"/> tools:visibility="visible" />
</FrameLayout> </LinearLayout>

Loading…
Cancel
Save