From 42c6698732fa076383460825a1846a73f8b75f90 Mon Sep 17 00:00:00 2001 From: Sanjiv Jha Date: Sat, 9 Jan 2016 16:39:31 +0530 Subject: [PATCH] ProgressBar must stop incase of network failure in videolist & detail page --- .../java/org/schabi/newpipe/VideoItemDetailFragment.java | 6 +++++- .../main/java/org/schabi/newpipe/VideoItemListFragment.java | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java b/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java index 03ec4e5aa..77c1d5b78 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java @@ -75,6 +75,7 @@ public class VideoItemDetailFragment extends Fragment { private AppCompatActivity activity; private ActionBarHandler actionBarHandler; + private ProgressBar progressBar; private int streamingServiceId = -1; @@ -86,6 +87,7 @@ public class VideoItemDetailFragment extends Fragment { private FloatingActionButton playVideoButton; private final Point initialThumbnailPos = new Point(0, 0); + public interface OnInvokeCreateOptionsMenuListener { void createOptionsMenu(); } @@ -132,6 +134,7 @@ public class VideoItemDetailFragment extends Fragment { } } } catch (Exception e) { + progressBar.setVisibility(View.GONE); e.printStackTrace(); } @@ -207,7 +210,6 @@ public class VideoItemDetailFragment extends Fragment { new VideoInfoItemViewCreator(LayoutInflater.from(getActivity())); RelativeLayout textContentLayout = (RelativeLayout) activity.findViewById(R.id.detailTextContentLayout); - ProgressBar progressBar = (ProgressBar) activity.findViewById(R.id.detailProgressBar); TextView videoTitleView = (TextView) activity.findViewById(R.id.detailVideoTitleView); TextView uploaderView = (TextView) activity.findViewById(R.id.detailUploaderView); TextView viewCountView = (TextView) activity.findViewById(R.id.detailViewCountView); @@ -353,6 +355,8 @@ public class VideoItemDetailFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_videoitem_detail, container, false); + progressBar = (ProgressBar) rootView.findViewById(R.id.detailProgressBar); + actionBarHandler = new ActionBarHandler(activity); actionBarHandler.setupNavMenu(activity); if(onInvokeCreateOptionsMenuListener != null) { diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java b/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java index bea1c6111..16953df1d 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java @@ -109,15 +109,18 @@ public class VideoItemListFragment extends ListFragment { String searchLanguage = sp.getString(searchLanguageKey, getString(R.string.default_language_value)); SearchEngine.Result result = engine.search(query, page, searchLanguage); + Log.i(TAG, "language code passed:\""+searchLanguage+"\""); if(runs) { h.post(new ResultRunnable(result, requestId)); } } catch(Exception e) { e.printStackTrace(); + h.post(new Runnable() { @Override public void run() { + setListShown(true); Toast.makeText(getActivity(), getString(R.string.network_error), Toast.LENGTH_SHORT).show(); }