Added toolbar to online search fragments
This commit is contained in:
parent
78b26fefb5
commit
be22ad1682
@ -2,6 +2,7 @@ package de.danoeh.antennapod.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.core.view.MenuItemCompat;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
@ -66,6 +67,7 @@ public class CombinedSearchFragment extends Fragment {
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View root = inflater.inflate(R.layout.fragment_itunes_search, container, false);
|
||||
((AppCompatActivity) getActivity()).setSupportActionBar(root.findViewById(R.id.toolbar));
|
||||
gridView = root.findViewById(R.id.gridView);
|
||||
adapter = new ItunesAdapter(getActivity(), new ArrayList<>());
|
||||
gridView.setAdapter(adapter);
|
||||
|
@ -2,6 +2,7 @@ package de.danoeh.antennapod.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.core.view.MenuItemCompat;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
@ -65,6 +66,7 @@ public class FyydSearchFragment extends Fragment {
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View root = inflater.inflate(R.layout.fragment_itunes_search, container, false);
|
||||
((AppCompatActivity) getActivity()).setSupportActionBar(root.findViewById(R.id.toolbar));
|
||||
gridView = root.findViewById(R.id.gridView);
|
||||
adapter = new ItunesAdapter(getActivity(), new ArrayList<>());
|
||||
gridView.setAdapter(adapter);
|
||||
|
@ -3,6 +3,7 @@ package de.danoeh.antennapod.fragment;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.core.view.MenuItemCompat;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
@ -93,6 +94,7 @@ public class ItunesSearchFragment extends Fragment {
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View root = inflater.inflate(R.layout.fragment_itunes_search, container, false);
|
||||
((AppCompatActivity) getActivity()).setSupportActionBar(root.findViewById(R.id.toolbar));
|
||||
gridView = root.findViewById(R.id.gridView);
|
||||
adapter = new ItunesAdapter(getActivity(), new ArrayList<>());
|
||||
gridView.setAdapter(adapter);
|
||||
@ -172,7 +174,7 @@ public class ItunesSearchFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||
if(searchResults != null) {
|
||||
if (searchResults != null) {
|
||||
searchResults = null;
|
||||
updateData(topList);
|
||||
}
|
||||
|
@ -1,18 +1,17 @@
|
||||
package de.danoeh.antennapod.fragment.gpodnet;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import de.danoeh.antennapod.R;
|
||||
|
||||
/**
|
||||
@ -20,49 +19,25 @@ import de.danoeh.antennapod.R;
|
||||
*/
|
||||
public class GpodnetMainFragment extends Fragment {
|
||||
|
||||
private static final String TAG = "GpodnetMainFragment";
|
||||
|
||||
private static final String PREF_LAST_TAB_POSITION = "tab_position";
|
||||
private TabLayout tabLayout;
|
||||
private ViewPager viewPager;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
View root = inflater.inflate(R.layout.pager_fragment, container, false);
|
||||
Toolbar toolbar = root.findViewById(R.id.toolbar);
|
||||
toolbar.setTitle(R.string.gpodnet_main_label);
|
||||
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
|
||||
|
||||
viewPager = root.findViewById(R.id.viewpager);
|
||||
ViewPager viewPager = root.findViewById(R.id.viewpager);
|
||||
GpodnetPagerAdapter pagerAdapter = new GpodnetPagerAdapter(getChildFragmentManager(), getResources());
|
||||
viewPager.setAdapter(pagerAdapter);
|
||||
|
||||
// Give the TabLayout the ViewPager
|
||||
tabLayout = root.findViewById(R.id.sliding_tabs);
|
||||
TabLayout tabLayout = root.findViewById(R.id.sliding_tabs);
|
||||
tabLayout.setupWithViewPager(viewPager);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
// save our tab selection
|
||||
SharedPreferences prefs = getActivity().getSharedPreferences(TAG, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putInt(PREF_LAST_TAB_POSITION, tabLayout.getSelectedTabPosition());
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
// restore our last position
|
||||
SharedPreferences prefs = getActivity().getSharedPreferences(TAG, Context.MODE_PRIVATE);
|
||||
int lastPosition = prefs.getInt(PREF_LAST_TAB_POSITION, 0);
|
||||
viewPager.setCurrentItem(lastPosition);
|
||||
}
|
||||
|
||||
public class GpodnetPagerAdapter extends FragmentPagerAdapter {
|
||||
|
||||
|
||||
@ -80,13 +55,19 @@ public class GpodnetMainFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int i) {
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putBoolean(PodcastListFragment.ARGUMENT_HIDE_TOOLBAR, true);
|
||||
switch (i) {
|
||||
case POS_TAGS:
|
||||
return new TagListFragment();
|
||||
case POS_TOPLIST:
|
||||
return new PodcastTopListFragment();
|
||||
PodcastListFragment topListFragment = new PodcastTopListFragment();
|
||||
topListFragment.setArguments(arguments);
|
||||
return topListFragment;
|
||||
case POS_SUGGESTIONS:
|
||||
return new SuggestionListFragment();
|
||||
PodcastListFragment suggestionsFragment = new SuggestionListFragment();
|
||||
suggestionsFragment.setArguments(arguments);
|
||||
return suggestionsFragment;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.core.view.MenuItemCompat;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
@ -34,7 +36,7 @@ import de.danoeh.antennapod.menuhandler.MenuItemUtils;
|
||||
* Displays a list of GPodnetPodcast-Objects in a GridView
|
||||
*/
|
||||
public abstract class PodcastListFragment extends Fragment {
|
||||
|
||||
public static final String ARGUMENT_HIDE_TOOLBAR = "hideToolbar";
|
||||
private static final String TAG = "PodcastListFragment";
|
||||
|
||||
private GridView gridView;
|
||||
@ -76,6 +78,13 @@ public abstract class PodcastListFragment extends Fragment {
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View root = inflater.inflate(R.layout.gpodnet_podcast_list, container, false);
|
||||
Toolbar toolbar = root.findViewById(R.id.toolbar);
|
||||
if (getArguments() == null || !getArguments().getBoolean(ARGUMENT_HIDE_TOOLBAR, false)) {
|
||||
toolbar.setTitle(R.string.gpodnet_main_label);
|
||||
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
|
||||
} else {
|
||||
toolbar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
gridView = root.findViewById(R.id.gridView);
|
||||
progressBar = root.findViewById(R.id.progressBar);
|
||||
|
@ -24,8 +24,6 @@ import de.danoeh.antennapod.core.gpoddernet.model.GpodnetTag;
|
||||
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
|
||||
|
||||
public class TagListFragment extends ListFragment {
|
||||
|
||||
private static final String TAG = "TagListFragment";
|
||||
private static final int COUNT = 50;
|
||||
|
||||
@Override
|
||||
@ -72,12 +70,6 @@ public class TagListFragment extends ListFragment {
|
||||
startLoadTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
((MainActivity) getActivity()).getSupportActionBar().setTitle(R.string.add_feed_label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
@ -1,10 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
android:theme="?attr/actionBarTheme"
|
||||
app:navigationIcon="?homeAsUpIndicator"
|
||||
android:id="@+id/toolbar"/>
|
||||
|
||||
<GridView
|
||||
android:id="@+id/gridView"
|
||||
android:layout_width="match_parent"
|
||||
@ -18,6 +27,7 @@
|
||||
android:paddingTop="@dimen/list_vertical_padding"
|
||||
android:stretchMode="columnWidth"
|
||||
android:verticalSpacing="8dp"
|
||||
android:layout_below="@id/toolbar"
|
||||
tools:listitem="@layout/gpodnet_podcast_listitem" />
|
||||
|
||||
<ProgressBar
|
||||
|
@ -11,6 +11,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
android:theme="?attr/actionBarTheme"
|
||||
app:navigationIcon="?homeAsUpIndicator"
|
||||
android:id="@+id/toolbar"/>
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
|
Loading…
x
Reference in New Issue
Block a user