Merge branch 'issue-1079--swipe-to-refresh-updates' into 'master'
Allow swipe-to-refresh on categories and updates tab. Closes #1079 See merge request fdroid/fdroidclient!586
This commit is contained in:
commit
85349fb59b
@ -7,6 +7,7 @@ import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@ -15,6 +16,7 @@ import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.UpdateService;
|
||||
import org.fdroid.fdroid.data.CategoryProvider;
|
||||
import org.fdroid.fdroid.data.Schema;
|
||||
import org.fdroid.fdroid.views.apps.AppListActivity;
|
||||
@ -54,6 +56,16 @@ class CategoriesViewBinder implements LoaderManager.LoaderCallbacks<Cursor> {
|
||||
categoriesList.setLayoutManager(new LinearLayoutManager(activity));
|
||||
categoriesList.setAdapter(categoryAdapter);
|
||||
|
||||
final SwipeRefreshLayout swipeToRefresh =
|
||||
(SwipeRefreshLayout) categoriesView.findViewById(R.id.swipe_to_refresh);
|
||||
swipeToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
swipeToRefresh.setRefreshing(false);
|
||||
UpdateService.updateNow(activity);
|
||||
}
|
||||
});
|
||||
|
||||
FloatingActionButton searchFab = (FloatingActionButton) categoriesView.findViewById(R.id.btn_search);
|
||||
searchFab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.fdroid.fdroid.views.updates;
|
||||
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@ -9,6 +10,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.UpdateService;
|
||||
|
||||
public class UpdatesViewBinder {
|
||||
|
||||
@ -17,7 +19,7 @@ public class UpdatesViewBinder {
|
||||
private final TextView emptyState;
|
||||
private final ImageView emptyImage;
|
||||
|
||||
public UpdatesViewBinder(AppCompatActivity activity, FrameLayout parent) {
|
||||
public UpdatesViewBinder(final AppCompatActivity activity, FrameLayout parent) {
|
||||
View view = activity.getLayoutInflater().inflate(R.layout.main_tab_updates, parent, true);
|
||||
|
||||
adapter = new UpdatesAdapter(activity);
|
||||
@ -30,6 +32,16 @@ public class UpdatesViewBinder {
|
||||
|
||||
emptyState = (TextView) view.findViewById(R.id.empty_state);
|
||||
emptyImage = (ImageView) view.findViewById(R.id.image);
|
||||
|
||||
final SwipeRefreshLayout swipeToRefresh = (SwipeRefreshLayout) view.findViewById(R.id.swipe_to_refresh);
|
||||
swipeToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
swipeToRefresh.setRefreshing(false);
|
||||
UpdateService.updateNow(activity);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void bind() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
@ -7,14 +7,22 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v4.widget.SwipeRefreshLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/swipe_to_refresh">
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<org.fdroid.fdroid.views.BannerUpdatingRepos
|
||||
android:id="@+id/banner_updating_repos"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:layout_editor_absoluteX="8dp" />
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/empty_state"
|
||||
@ -50,3 +58,5 @@
|
||||
android:layout_marginRight="@dimen/fab_margin" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
@ -1,12 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v4.widget.SwipeRefreshLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/swipe_to_refresh">
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/mainTabSwapBackground">
|
||||
|
||||
<org.fdroid.fdroid.views.BannerUpdatingRepos
|
||||
android:id="@+id/banner_updating_repos"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/empty_state"
|
||||
android:layout_width="0dp"
|
||||
@ -14,7 +32,7 @@
|
||||
style="@style/AppListEmptyText"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/banner_updating_repos"
|
||||
android:visibility="gone"
|
||||
android:text="@string/empty_can_update_app_list" />
|
||||
|
||||
@ -39,8 +57,10 @@
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/banner_updating_repos"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:scrollbars="vertical" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
Loading…
x
Reference in New Issue
Block a user