fix search fragment progressbar
This commit is contained in:
parent
5d06e8310d
commit
7bea94144e
2 changed files with 58 additions and 45 deletions
|
@ -15,6 +15,7 @@ import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.schabi.newpipe.ErrorActivity;
|
import org.schabi.newpipe.ErrorActivity;
|
||||||
|
@ -84,6 +85,7 @@ public class SearchInfoItemFragment extends Fragment {
|
||||||
private String searchQuery = "";
|
private String searchQuery = "";
|
||||||
private boolean isLoading = false;
|
private boolean isLoading = false;
|
||||||
|
|
||||||
|
private ProgressBar loadingIndicator = null;
|
||||||
private SearchView searchView = null;
|
private SearchView searchView = null;
|
||||||
private int pageNumber = 0;
|
private int pageNumber = 0;
|
||||||
private SuggestionListAdapter suggestionListAdapter = null;
|
private SuggestionListAdapter suggestionListAdapter = null;
|
||||||
|
@ -135,6 +137,7 @@ public class SearchInfoItemFragment extends Fragment {
|
||||||
public void onResult(SearchResult result) {
|
public void onResult(SearchResult result) {
|
||||||
infoListAdapter.addStreamItemList(result.resultList);
|
infoListAdapter.addStreamItemList(result.resultList);
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
loadingIndicator.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -143,6 +146,7 @@ public class SearchInfoItemFragment extends Fragment {
|
||||||
Toast.makeText(getActivity(), getString(stringResource),
|
Toast.makeText(getActivity(), getString(stringResource),
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
loadingIndicator.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -151,6 +155,7 @@ public class SearchInfoItemFragment extends Fragment {
|
||||||
Toast.makeText(getActivity(), message,
|
Toast.makeText(getActivity(), message,
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
loadingIndicator.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -160,10 +165,9 @@ public class SearchInfoItemFragment extends Fragment {
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_searchinfoitem, container, false);
|
View view = inflater.inflate(R.layout.fragment_searchinfoitem, container, false);
|
||||||
|
|
||||||
// Set the adapter
|
|
||||||
if (view instanceof RecyclerView) {
|
|
||||||
Context context = view.getContext();
|
Context context = view.getContext();
|
||||||
recyclerView = (RecyclerView) view;
|
loadingIndicator = (ProgressBar) view.findViewById(R.id.progressBar);
|
||||||
|
recyclerView = (RecyclerView) view.findViewById(R.id.list);
|
||||||
streamInfoListLayoutManager = new LinearLayoutManager(context);
|
streamInfoListLayoutManager = new LinearLayoutManager(context);
|
||||||
recyclerView.setLayoutManager(streamInfoListLayoutManager);
|
recyclerView.setLayoutManager(streamInfoListLayoutManager);
|
||||||
|
|
||||||
|
@ -180,7 +184,6 @@ public class SearchInfoItemFragment extends Fragment {
|
||||||
});
|
});
|
||||||
recyclerView.setAdapter(infoListAdapter);
|
recyclerView.setAdapter(infoListAdapter);
|
||||||
|
|
||||||
|
|
||||||
recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
|
recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||||
|
@ -200,7 +203,6 @@ public class SearchInfoItemFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -245,6 +247,7 @@ public class SearchInfoItemFragment extends Fragment {
|
||||||
infoListAdapter.clearSteamItemList();
|
infoListAdapter.clearSteamItemList();
|
||||||
pageNumber = 0;
|
pageNumber = 0;
|
||||||
search(query, pageNumber);
|
search(query, pageNumber);
|
||||||
|
loadingIndicator.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void search(String query, int page) {
|
private void search(String query, int page) {
|
||||||
|
|
|
@ -1,14 +1,24 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/list"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:name="org.schabi.newpipe.SearchInfoItemFragment"
|
android:name="org.schabi.newpipe.SearchInfoItemFragment"
|
||||||
|
tools:context=".search_fragment.SearchInfoItemFragment">
|
||||||
|
|
||||||
|
<android.support.v7.widget.RecyclerView
|
||||||
|
android:id="@+id/list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
app:layoutManager="LinearLayoutManager"
|
app:layoutManager="LinearLayoutManager"
|
||||||
tools:context=".search_fragment.SearchInfoItemFragment"
|
|
||||||
tools:listitem="@layout/video_item"
|
tools:listitem="@layout/video_item"
|
||||||
android:scrollbars="vertical"/>
|
android:scrollbars="vertical"/>
|
||||||
|
|
||||||
|
<ProgressBar android:id="@+id/progressBar"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:indeterminate="true"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
Loading…
Reference in a new issue