Merge pull request #3287 from ByteHamster/add-feed-page-redesign
Added error message, do not jump after loading completed
This commit is contained in:
commit
22ac88e2df
|
@ -32,6 +32,10 @@ public class PodcastSearchResult {
|
||||||
this.feedUrl = feedUrl;
|
this.feedUrl = feedUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PodcastSearchResult dummy() {
|
||||||
|
return new PodcastSearchResult("", "", "");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a Podcast instance from a iTunes search result
|
* Constructs a Podcast instance from a iTunes search result
|
||||||
*
|
*
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.GridView;
|
import android.widget.GridView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.activity.MainActivity;
|
import de.danoeh.antennapod.activity.MainActivity;
|
||||||
|
@ -19,6 +20,9 @@ import de.danoeh.antennapod.discovery.ItunesTopListLoader;
|
||||||
import de.danoeh.antennapod.discovery.PodcastSearchResult;
|
import de.danoeh.antennapod.discovery.PodcastSearchResult;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.OnItemClickListener {
|
public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.OnItemClickListener {
|
||||||
private static final String TAG = "FeedDiscoveryFragment";
|
private static final String TAG = "FeedDiscoveryFragment";
|
||||||
|
@ -27,6 +31,7 @@ public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.
|
||||||
private Disposable disposable;
|
private Disposable disposable;
|
||||||
private FeedDiscoverAdapter adapter;
|
private FeedDiscoverAdapter adapter;
|
||||||
private GridView subscriptionGridLayout;
|
private GridView subscriptionGridLayout;
|
||||||
|
private TextView errorTextView;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
@ -35,13 +40,23 @@ public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.
|
||||||
View discoverMore = root.findViewById(R.id.discover_more);
|
View discoverMore = root.findViewById(R.id.discover_more);
|
||||||
discoverMore.setOnClickListener(v ->
|
discoverMore.setOnClickListener(v ->
|
||||||
((MainActivity) getActivity()).loadChildFragment(new ItunesSearchFragment()));
|
((MainActivity) getActivity()).loadChildFragment(new ItunesSearchFragment()));
|
||||||
subscriptionGridLayout = root.findViewById(R.id.discover_grid);
|
|
||||||
|
|
||||||
|
subscriptionGridLayout = root.findViewById(R.id.discover_grid);
|
||||||
progressBar = root.findViewById(R.id.discover_progress_bar);
|
progressBar = root.findViewById(R.id.discover_progress_bar);
|
||||||
|
errorTextView = root.findViewById(R.id.discover_error);
|
||||||
|
|
||||||
adapter = new FeedDiscoverAdapter((MainActivity) getActivity());
|
adapter = new FeedDiscoverAdapter((MainActivity) getActivity());
|
||||||
subscriptionGridLayout.setAdapter(adapter);
|
subscriptionGridLayout.setAdapter(adapter);
|
||||||
subscriptionGridLayout.setOnItemClickListener(this);
|
subscriptionGridLayout.setOnItemClickListener(this);
|
||||||
|
|
||||||
|
// Fill with dummy elements to have a fixed height and
|
||||||
|
// prevent the UI elements below from jumping on slow connections
|
||||||
|
List<PodcastSearchResult> dummies = new ArrayList<>();
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
dummies.add(PodcastSearchResult.dummy());
|
||||||
|
}
|
||||||
|
adapter.updateData(dummies);
|
||||||
|
|
||||||
loadToplist();
|
loadToplist();
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
|
@ -57,18 +72,22 @@ public class QuickFeedDiscoveryFragment extends Fragment implements AdapterView.
|
||||||
|
|
||||||
private void loadToplist() {
|
private void loadToplist() {
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
subscriptionGridLayout.setVisibility(View.GONE);
|
subscriptionGridLayout.setVisibility(View.INVISIBLE);
|
||||||
|
errorTextView.setVisibility(View.GONE);
|
||||||
|
|
||||||
ItunesTopListLoader loader = new ItunesTopListLoader(getContext());
|
ItunesTopListLoader loader = new ItunesTopListLoader(getContext());
|
||||||
disposable = loader.loadToplist(8)
|
disposable = loader.loadToplist(8)
|
||||||
.subscribe(podcasts -> {
|
.subscribe(podcasts -> {
|
||||||
|
errorTextView.setVisibility(View.GONE);
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
subscriptionGridLayout.setVisibility(View.VISIBLE);
|
subscriptionGridLayout.setVisibility(View.VISIBLE);
|
||||||
adapter.updateData(podcasts);
|
adapter.updateData(podcasts);
|
||||||
}, error -> {
|
}, error -> {
|
||||||
Log.e(TAG, Log.getStackTraceString(error));
|
Log.e(TAG, Log.getStackTraceString(error));
|
||||||
|
errorTextView.setText(error.getLocalizedMessage());
|
||||||
|
errorTextView.setVisibility(View.VISIBLE);
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
subscriptionGridLayout.setVisibility(View.VISIBLE);
|
subscriptionGridLayout.setVisibility(View.INVISIBLE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,9 @@
|
||||||
android:textColor="@color/antennapod_blue"/>
|
android:textColor="@color/antennapod_blue"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<de.danoeh.antennapod.view.WrappingGridView
|
<de.danoeh.antennapod.view.WrappingGridView
|
||||||
android:id="@+id/discover_grid"
|
android:id="@+id/discover_grid"
|
||||||
|
@ -53,6 +56,7 @@
|
||||||
android:verticalSpacing="4dp"
|
android:verticalSpacing="4dp"
|
||||||
android:scrollbars="none"
|
android:scrollbars="none"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
android:layout_gravity="center_horizontal"/>
|
android:layout_gravity="center_horizontal"/>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
|
@ -61,8 +65,18 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
android:layout_marginTop="30dp"/>
|
android:layout_marginTop="30dp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/discover_error"
|
||||||
|
android:textColor="@color/md_edittext_error"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</android.support.v7.widget.CardView>
|
||||||
|
|
Loading…
Reference in New Issue