aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/ml')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java43
3 files changed, 42 insertions, 23 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
index 42824df6..4b38e45b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
@@ -4,6 +4,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
@@ -32,6 +33,10 @@ import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
import com.livefront.bridge.Bridge;
+import com.r0adkll.slidr.Slidr;
+import com.r0adkll.slidr.model.SlidrConfig;
+import com.r0adkll.slidr.model.SlidrListener;
+import com.r0adkll.slidr.model.SlidrPosition;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -71,11 +76,11 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.ReadMessage;
import ml.docilealligator.infinityforreddit.RedditAPI;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
-import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
import ml.docilealligator.infinityforreddit.SaveThing;
-import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.SortType;
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
+import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@@ -181,6 +186,17 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
EventBus.getDefault().register(this);
+ SlidrConfig config = new SlidrConfig.Builder()
+ .sensitivity(1f)
+ .scrimColor(Color.BLACK)
+ .scrimStartAlpha(0.8f)
+ .scrimEndAlpha(0f)
+ .velocityThreshold(2400)
+ .distanceThreshold(0.25f)
+ .build();
+
+ Slidr.attach(this);
+
Resources resources = getResources();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
index 4c50c45c..5a8cbaff 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
@@ -58,13 +58,13 @@ import ml.docilealligator.infinityforreddit.PostDataSource;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.ReadMessage;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
-import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.SortType;
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditDao;
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditViewModel;
import ml.docilealligator.infinityforreddit.SubredditSubscription;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
index 214f77cb..eba9f607 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
@@ -32,10 +32,10 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScroller;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
-import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -62,8 +62,8 @@ import ml.docilealligator.infinityforreddit.PostDataSource;
import ml.docilealligator.infinityforreddit.PostViewModel;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
-import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.SortType;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
@@ -84,10 +84,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
private static final String RECYCLER_VIEW_POSITION_STATE = "RVPS";
+ @BindView(R.id.swipe_refresh_layout_post_fragment)
+ SwipeRefreshLayout mSwipeRefreshLayout;
@BindView(R.id.recycler_view_post_fragment)
RecyclerView mPostRecyclerView;
- @BindView(R.id.progress_bar_post_fragment)
- CircleProgressBar mProgressBar;
@BindView(R.id.fetch_post_info_linear_layout_post_fragment)
LinearLayout mFetchPostInfoLinearLayout;
@BindView(R.id.fetch_post_info_image_view_post_fragment)
@@ -131,6 +131,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
if (mPostRecyclerView.getAdapter() != null) {
((PostRecyclerViewAdapter) mPostRecyclerView.getAdapter()).setCanStartActivity(true);
}
+ if (isInLazyMode && isLazyModePaused) {
+ resumeLazyMode(false);
+ }
}
@Override
@@ -226,6 +229,12 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
};
+ mSwipeRefreshLayout.setOnRefreshListener(() -> {
+ mPostViewModel.refresh();
+ });
+
+ mSwipeRefreshLayout.setColorSchemeResources(R.color.colorAccent);
+
if (savedInstanceState != null) {
int recyclerViewPosition = savedInstanceState.getInt(RECYCLER_VIEW_POSITION_STATE);
if (recyclerViewPosition > 0) {
@@ -465,11 +474,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mPostRecyclerView.setAdapter(mAdapter);
mPostViewModel = new ViewModelProvider(this, factory).get(PostViewModel.class);
- mPostViewModel.getPosts().observe(this, posts -> mAdapter.submitList(posts));
+ mPostViewModel.getPosts().observe(this, posts -> {
+ mAdapter.submitList(posts);
+ });
mPostViewModel.hasPost().observe(this, hasPost -> {
this.hasPost = hasPost;
- mProgressBar.setVisibility(View.GONE);
+ mSwipeRefreshLayout.setRefreshing(false);
if (hasPost) {
mFetchPostInfoLinearLayout.setVisibility(View.GONE);
} else {
@@ -485,13 +496,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mPostViewModel.getInitialLoadingState().observe(this, networkState -> {
if (networkState.getStatus().equals(NetworkState.Status.SUCCESS)) {
- mProgressBar.setVisibility(View.GONE);
+ mSwipeRefreshLayout.setRefreshing(false);
} else if (networkState.getStatus().equals(NetworkState.Status.FAILED)) {
- mProgressBar.setVisibility(View.GONE);
+ mSwipeRefreshLayout.setRefreshing(false);
mFetchPostInfoLinearLayout.setOnClickListener(view -> refresh());
showErrorView(R.string.load_posts_error);
} else {
- mProgressBar.setVisibility(View.VISIBLE);
+ mSwipeRefreshLayout.setRefreshing(true);
}
});
@@ -541,7 +552,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
private void showErrorView(int stringResId) {
if (activity != null && isAdded()) {
- mProgressBar.setVisibility(View.GONE);
+ mSwipeRefreshLayout.setRefreshing(false);
mFetchPostInfoLinearLayout.setVisibility(View.VISIBLE);
mFetchPostInfoTextView.setText(stringResId);
mGlide.load(R.drawable.error_image).into(mFetchPostInfoImageView);
@@ -689,16 +700,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
@Override
- public void onStart() {
- super.onStart();
- if (isInLazyMode && isLazyModePaused) {
- resumeLazyMode(false);
- }
- }
-
- @Override
- public void onStop() {
- super.onStop();
+ public void onPause() {
+ super.onPause();
if (isInLazyMode) {
pauseLazyMode(false);
}