mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 15:23:00 +00:00 
			
		
		
		
	Merge pull request #118 from joshsoftware/master
Adding the loading screen when user scroll through videoList.
This commit is contained in:
		| @@ -20,6 +20,9 @@ Project status: | |||||||
| [<img src="screenshots/screenshot_5.png" width=150>](screenshots/screenshot_5.png) | [<img src="screenshots/screenshot_5.png" width=150>](screenshots/screenshot_5.png) | ||||||
| [<img src="screenshots/screenshot_6.png" width=250>](screenshots/screenshot_6.png) | [<img src="screenshots/screenshot_6.png" width=250>](screenshots/screenshot_6.png) | ||||||
|  |  | ||||||
|  | [](assets/screenshot_1.png) | ||||||
|  | [](assets/screenshot_2.png) | ||||||
|  |  | ||||||
| ## Description | ## Description | ||||||
|  |  | ||||||
| NewPipe does not use any Google framework libraries, or the YouTube API. It only parses the website in order to gain the information it needs. Therefore this app can be used on devices without Google Services installed. Also, you don't need a YouTube account to use NewPipe, and it's FLOSS. | NewPipe does not use any Google framework libraries, or the YouTube API. It only parses the website in order to gain the information it needs. Therefore this app can be used on devices without Google Services installed. Also, you don't need a YouTube account to use NewPipe, and it's FLOSS. | ||||||
|   | |||||||
| @@ -9,6 +9,7 @@ import android.os.Handler; | |||||||
| import android.preference.PreferenceManager; | import android.preference.PreferenceManager; | ||||||
| import android.support.v4.app.ListFragment; | import android.support.v4.app.ListFragment; | ||||||
| import android.util.Log; | import android.util.Log; | ||||||
|  | import android.view.LayoutInflater; | ||||||
| import android.view.View; | import android.view.View; | ||||||
| import android.widget.AbsListView; | import android.widget.AbsListView; | ||||||
| import android.widget.ListView; | import android.widget.ListView; | ||||||
| @@ -63,6 +64,8 @@ public class VideoItemListFragment extends ListFragment { | |||||||
|     private int currentRequestId = -1; |     private int currentRequestId = -1; | ||||||
|     private ListView list; |     private ListView list; | ||||||
|  |  | ||||||
|  |     private View footer; | ||||||
|  |  | ||||||
|     private class ResultRunnable implements Runnable { |     private class ResultRunnable implements Runnable { | ||||||
|         private final SearchEngine.Result result; |         private final SearchEngine.Result result; | ||||||
|         private final int requestId; |         private final int requestId; | ||||||
| @@ -112,6 +115,16 @@ public class VideoItemListFragment extends ListFragment { | |||||||
|                     } |                     } | ||||||
|                 }); |                 }); | ||||||
|             } |             } | ||||||
|  |             getActivity().runOnUiThread(new Runnable() { | ||||||
|  |                                             @Override | ||||||
|  |  | ||||||
|  |                                             public void run() { | ||||||
|  |                                                 getListView().removeFooterView(footer); | ||||||
|  |                                             } | ||||||
|  |                                         } | ||||||
|  |  | ||||||
|  |             ); | ||||||
|  |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -283,6 +296,9 @@ public class VideoItemListFragment extends ListFragment { | |||||||
|         super.onViewCreated(view, savedInstanceState); |         super.onViewCreated(view, savedInstanceState); | ||||||
|         list = getListView(); |         list = getListView(); | ||||||
|         videoListAdapter = new VideoListAdapter(getActivity(), this); |         videoListAdapter = new VideoListAdapter(getActivity(), this); | ||||||
|  |         footer = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.paginate_footer, null, false); | ||||||
|  |  | ||||||
|  |  | ||||||
|         setListAdapter(videoListAdapter); |         setListAdapter(videoListAdapter); | ||||||
|  |  | ||||||
|         // Restore the previously serialized activated item position. |         // Restore the previously serialized activated item position. | ||||||
| @@ -292,6 +308,7 @@ public class VideoItemListFragment extends ListFragment { | |||||||
|             setActivatedPosition(savedInstanceState.getInt(STATE_ACTIVATED_POSITION)); |             setActivatedPosition(savedInstanceState.getInt(STATE_ACTIVATED_POSITION)); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|         getListView().setOnScrollListener(new AbsListView.OnScrollListener() { |         getListView().setOnScrollListener(new AbsListView.OnScrollListener() { | ||||||
|             long lastScrollDate = 0; |             long lastScrollDate = 0; | ||||||
|  |  | ||||||
| @@ -308,6 +325,7 @@ public class VideoItemListFragment extends ListFragment { | |||||||
|                     long time = System.currentTimeMillis(); |                     long time = System.currentTimeMillis(); | ||||||
|                     if ((time - lastScrollDate) > 200) { |                     if ((time - lastScrollDate) > 200) { | ||||||
|                         lastScrollDate = time; |                         lastScrollDate = time; | ||||||
|  |                         getListView().addFooterView(footer); | ||||||
|                         nextPage(); |                         nextPage(); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|   | |||||||
							
								
								
									
										20
									
								
								app/src/main/res/layout/paginate_footer.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								app/src/main/res/layout/paginate_footer.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | |||||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||||
|  | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|  |     android:layout_width="match_parent" | ||||||
|  |     android:layout_height="match_parent" | ||||||
|  |     android:gravity="center_horizontal" | ||||||
|  |     android:orientation="vertical"> | ||||||
|  |  | ||||||
|  |     <TextView | ||||||
|  |         android:layout_width="wrap_content" | ||||||
|  |         android:layout_height="wrap_content" | ||||||
|  |         android:text="Loading" | ||||||
|  |         android:textAppearance="?android:attr/textAppearanceMedium" /> | ||||||
|  |  | ||||||
|  |     <ProgressBar | ||||||
|  |         android:id="@+id/paginate_progress_bar" | ||||||
|  |         android:layout_width="wrap_content" | ||||||
|  |         android:layout_height="wrap_content" | ||||||
|  |         android:layout_marginRight="10dp" /> | ||||||
|  |  | ||||||
|  | </LinearLayout> | ||||||
		Reference in New Issue
	
	Block a user
	 Christian Schabesberger
					Christian Schabesberger