diff options
author | stefan-niedermann <info@niedermann.it> | 2019-10-19 16:27:25 +0300 |
---|---|---|
committer | stefan-niedermann <info@niedermann.it> | 2019-10-19 16:27:25 +0300 |
commit | 2f71fc97bf8f42b53ef53672c55f7cc3d6704820 (patch) | |
tree | ae9f362ee5e94d05239978725c1405c57a4d6b45 | |
parent | f70a606b2ef0ba62cdf8baee132649f1ce7a1356 (diff) |
Move scrollToRefresh to MainActivity
4 files changed, 74 insertions, 74 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java index 51c5e2535..bd90ba508 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java @@ -16,6 +16,7 @@ import androidx.appcompat.widget.PopupMenu; import androidx.core.view.GravityCompat; import androidx.lifecycle.LiveData; import androidx.lifecycle.Observer; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.viewpager.widget.ViewPager; import com.google.android.material.floatingactionbutton.FloatingActionButton; @@ -33,6 +34,7 @@ import butterknife.ButterKnife; import it.niedermann.nextcloud.deck.Application; import it.niedermann.nextcloud.deck.DeckLog; import it.niedermann.nextcloud.deck.R; +import it.niedermann.nextcloud.deck.api.IResponseCallback; import it.niedermann.nextcloud.deck.model.Account; import it.niedermann.nextcloud.deck.model.Board; import it.niedermann.nextcloud.deck.model.Stack; @@ -58,6 +60,9 @@ import static it.niedermann.nextcloud.deck.ui.stack.EditStackDialogFragment.NO_S public class MainActivity extends DrawerActivity { + + @BindView(R.id.swipe_refresh_layout) + SwipeRefreshLayout swipeRefreshLayout; @BindView(R.id.fab) FloatingActionButton fab; @BindView(R.id.navigationView) @@ -166,6 +171,19 @@ public class MainActivity extends DrawerActivity { } }); + + swipeRefreshLayout.setOnRefreshListener(() -> syncManager.synchronize(new IResponseCallback<Boolean>(account) { + @Override + public void onResponse(Boolean response) { + runOnUiThread(() -> swipeRefreshLayout.setRefreshing(false)); + } + + @Override + public void onError(Throwable throwable) { + runOnUiThread(() -> swipeRefreshLayout.setRefreshing(false)); + DeckLog.logError(throwable); + } + })); } public void onCreateStack(String stackName) { diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/StackFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/StackFragment.java index e351f46fa..566f8a995 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/StackFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/StackFragment.java @@ -12,7 +12,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import java.util.List; import java.util.Objects; @@ -21,7 +20,6 @@ import butterknife.BindView; import butterknife.ButterKnife; import it.niedermann.nextcloud.deck.DeckLog; import it.niedermann.nextcloud.deck.R; -import it.niedermann.nextcloud.deck.api.IResponseCallback; import it.niedermann.nextcloud.deck.model.Account; import it.niedermann.nextcloud.deck.model.full.FullCard; import it.niedermann.nextcloud.deck.model.full.FullStack; @@ -45,8 +43,6 @@ public class StackFragment extends Fragment { private long boardId; private Account account; - @BindView(R.id.swipe_refresh_layout) - SwipeRefreshLayout swipeRefreshLayout; @BindView(R.id.recycler_view) RecyclerView recyclerView; @BindView(R.id.no_cards) @@ -101,19 +97,6 @@ public class StackFragment extends Fragment { }); } - swipeRefreshLayout.setOnRefreshListener(() -> syncManager.synchronize(new IResponseCallback<Boolean>(account) { - @Override - public void onResponse(Boolean response) { - activity.runOnUiThread(() -> swipeRefreshLayout.setRefreshing(false)); - } - - @Override - public void onError(Throwable throwable) { - activity.runOnUiThread(() -> swipeRefreshLayout.setRefreshing(false)); - DeckLog.logError(throwable); - } - })); - refreshView(); return view; } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 005a6525c..087b3c9bd 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -52,10 +52,21 @@ android:text="@string/add_a_new_column_using_the_three_dots_menu" /> </RelativeLayout> - <androidx.viewpager.widget.ViewPager - android:id="@+id/viewPager" + + <androidx.swiperefreshlayout.widget.SwipeRefreshLayout + android:id="@+id/swipe_refresh_layout" android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_height="wrap_content" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintBottom_toBottomOf="parent"> + + <androidx.viewpager.widget.ViewPager + android:id="@+id/viewPager" + android:layout_width="match_parent" + android:layout_height="match_parent" /> + </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </androidx.constraintlayout.widget.ConstraintLayout> <com.google.android.material.appbar.AppBarLayout diff --git a/app/src/main/res/layout/fragment_stack.xml b/app/src/main/res/layout/fragment_stack.xml index bb306706a..d1ffd2025 100644 --- a/app/src/main/res/layout/fragment_stack.xml +++ b/app/src/main/res/layout/fragment_stack.xml @@ -1,67 +1,55 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" - android:layout_width="match_parent" - android:layout_height="match_parent" xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="wrap_content" android:orientation="vertical"> - <androidx.swiperefreshlayout.widget.SwipeRefreshLayout - android:id="@+id/swipe_refresh_layout" + <RelativeLayout + android:id="@+id/no_cards" android:layout_width="match_parent" - android:layout_height="wrap_content"> + android:layout_height="match_parent" + android:visibility="gone"> - <LinearLayout + <ImageView android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical"> - - <RelativeLayout - android:id="@+id/no_cards" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:visibility="gone"> - - <ImageView - android:layout_width="match_parent" - android:layout_height="180dp" - android:layout_above="@+id/no_cards_text" - android:layout_gravity="center" - android:layout_marginBottom="-40dp" - android:contentDescription="@null" - android:tint="@color/fg_secondary" - app:srcCompat="@drawable/ic_launcher_foreground" /> + android:layout_height="180dp" + android:layout_above="@+id/no_cards_text" + android:layout_gravity="center" + android:layout_marginBottom="-40dp" + android:contentDescription="@null" + android:tint="@color/fg_secondary" + app:srcCompat="@drawable/ic_launcher_foreground" /> - <TextView - android:id="@+id/no_cards_text" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_centerVertical="true" - android:gravity="center" - android:paddingBottom="16dp" - android:text="@string/no_cards" - android:textAlignment="center" - android:textSize="@dimen/empty_content_font_size" /> + <TextView + android:id="@+id/no_cards_text" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_centerVertical="true" + android:gravity="center" + android:paddingBottom="16dp" + android:text="@string/no_cards" + android:textAlignment="center" + android:textSize="@dimen/empty_content_font_size" /> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_below="@id/no_cards_text" - android:layout_centerHorizontal="true" - android:text="@string/add_a_new_card_using_the_button" /> - </RelativeLayout> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/no_cards_text" + android:layout_centerHorizontal="true" + android:text="@string/add_a_new_card_using_the_button" /> + </RelativeLayout> - <androidx.recyclerview.widget.RecyclerView - android:id="@+id/recycler_view" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:clipToPadding="false" - android:paddingTop="@dimen/standard_half_padding" - android:paddingBottom="@dimen/standard_half_padding" - android:scrollbarStyle="outsideOverlay" - android:scrollbars="vertical" - app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" - tools:listitem="@layout/item_card" /> - </LinearLayout> - </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> + <androidx.recyclerview.widget.RecyclerView + android:id="@+id/recycler_view" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:clipToPadding="false" + android:paddingTop="@dimen/standard_half_padding" + android:paddingBottom="@dimen/standard_half_padding" + android:scrollbarStyle="outsideOverlay" + android:scrollbars="vertical" + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" + tools:listitem="@layout/item_card" /> </LinearLayout>
\ No newline at end of file |