mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 20:57:25 +01:00
Swipe down to refresh is available in other activities.
This commit is contained in:
parent
47b57fd50f
commit
ca81ec49cf
@ -5,6 +5,7 @@ import android.content.res.Configuration;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -22,12 +23,12 @@ import androidx.lifecycle.ViewModelProvider;
|
|||||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.RequestManager;
|
import com.bumptech.glide.RequestManager;
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||||
import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar;
|
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
@ -65,10 +66,10 @@ public class ViewMessageActivity extends BaseActivity {
|
|||||||
AppBarLayout appBarLayout;
|
AppBarLayout appBarLayout;
|
||||||
@BindView(R.id.toolbar_view_message_activity)
|
@BindView(R.id.toolbar_view_message_activity)
|
||||||
Toolbar toolbar;
|
Toolbar toolbar;
|
||||||
@BindView(R.id.progress_bar_view_message_activity)
|
@BindView(R.id.swipe_refresh_layout_view_message_activity)
|
||||||
CircleProgressBar mProgressBar;
|
SwipeRefreshLayout mSwipeRefreshLayout;
|
||||||
@BindView(R.id.recycler_view_view_message_activity)
|
@BindView(R.id.recycler_view_view_message_activity)
|
||||||
RecyclerView recyclerView;
|
RecyclerView mRecyclerView;
|
||||||
@BindView(R.id.fetch_messages_info_linear_layout_view_message_activity)
|
@BindView(R.id.fetch_messages_info_linear_layout_view_message_activity)
|
||||||
LinearLayout mFetchMessageInfoLinearLayout;
|
LinearLayout mFetchMessageInfoLinearLayout;
|
||||||
@BindView(R.id.fetch_messages_info_image_view_view_message_activity)
|
@BindView(R.id.fetch_messages_info_image_view_view_message_activity)
|
||||||
@ -146,7 +147,7 @@ public class ViewMessageActivity extends BaseActivity {
|
|||||||
|
|
||||||
int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
|
int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
|
||||||
if (navBarResourceId > 0) {
|
if (navBarResourceId > 0) {
|
||||||
recyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
|
mRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,10 +212,10 @@ public class ViewMessageActivity extends BaseActivity {
|
|||||||
mAdapter = new MessageRecyclerViewAdapter(this, mOauthRetrofit, mAccessToken,
|
mAdapter = new MessageRecyclerViewAdapter(this, mOauthRetrofit, mAccessToken,
|
||||||
() -> mMessageViewModel.retryLoadingMore());
|
() -> mMessageViewModel.retryLoadingMore());
|
||||||
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
||||||
recyclerView.setLayoutManager(layoutManager);
|
mRecyclerView.setLayoutManager(layoutManager);
|
||||||
recyclerView.setAdapter(mAdapter);
|
mRecyclerView.setAdapter(mAdapter);
|
||||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this, layoutManager.getOrientation());
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this, layoutManager.getOrientation());
|
||||||
recyclerView.addItemDecoration(dividerItemDecoration);
|
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||||
|
|
||||||
MessageViewModel.Factory factory = new MessageViewModel.Factory(mOauthRetrofit,
|
MessageViewModel.Factory factory = new MessageViewModel.Factory(mOauthRetrofit,
|
||||||
getResources().getConfiguration().locale, mAccessToken, FetchMessages.WHERE_INBOX);
|
getResources().getConfiguration().locale, mAccessToken, FetchMessages.WHERE_INBOX);
|
||||||
@ -222,7 +223,7 @@ public class ViewMessageActivity extends BaseActivity {
|
|||||||
mMessageViewModel.getMessages().observe(this, messages -> mAdapter.submitList(messages));
|
mMessageViewModel.getMessages().observe(this, messages -> mAdapter.submitList(messages));
|
||||||
|
|
||||||
mMessageViewModel.hasMessage().observe(this, hasMessage -> {
|
mMessageViewModel.hasMessage().observe(this, hasMessage -> {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
if (hasMessage) {
|
if (hasMessage) {
|
||||||
mFetchMessageInfoLinearLayout.setVisibility(View.GONE);
|
mFetchMessageInfoLinearLayout.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
@ -235,9 +236,9 @@ public class ViewMessageActivity extends BaseActivity {
|
|||||||
|
|
||||||
mMessageViewModel.getInitialLoadingState().observe(this, networkState -> {
|
mMessageViewModel.getInitialLoadingState().observe(this, networkState -> {
|
||||||
if (networkState.getStatus().equals(NetworkState.Status.SUCCESS)) {
|
if (networkState.getStatus().equals(NetworkState.Status.SUCCESS)) {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
} else if (networkState.getStatus().equals(NetworkState.Status.FAILED)) {
|
} else if (networkState.getStatus().equals(NetworkState.Status.FAILED)) {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
mFetchMessageInfoLinearLayout.setOnClickListener(view -> {
|
mFetchMessageInfoLinearLayout.setOnClickListener(view -> {
|
||||||
mFetchMessageInfoLinearLayout.setVisibility(View.GONE);
|
mFetchMessageInfoLinearLayout.setVisibility(View.GONE);
|
||||||
mMessageViewModel.refresh();
|
mMessageViewModel.refresh();
|
||||||
@ -245,17 +246,24 @@ public class ViewMessageActivity extends BaseActivity {
|
|||||||
});
|
});
|
||||||
showErrorView(R.string.load_messages_failed);
|
showErrorView(R.string.load_messages_failed);
|
||||||
} else {
|
} else {
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
mSwipeRefreshLayout.setRefreshing(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mMessageViewModel.getPaginationNetworkState().observe(this, networkState -> {
|
mMessageViewModel.getPaginationNetworkState().observe(this, networkState -> {
|
||||||
mAdapter.setNetworkState(networkState);
|
mAdapter.setNetworkState(networkState);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mSwipeRefreshLayout.setOnRefreshListener(this::onRefresh);
|
||||||
|
|
||||||
|
TypedValue typedValue = new TypedValue();
|
||||||
|
getTheme().resolveAttribute(R.attr.cardViewBackgroundColor, typedValue, true);
|
||||||
|
mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(typedValue.data);
|
||||||
|
mSwipeRefreshLayout.setColorSchemeResources(R.color.colorAccent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showErrorView(int stringResId) {
|
private void showErrorView(int stringResId) {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
mFetchMessageInfoLinearLayout.setVisibility(View.VISIBLE);
|
mFetchMessageInfoLinearLayout.setVisibility(View.VISIBLE);
|
||||||
mFetchMessageInfoTextView.setText(stringResId);
|
mFetchMessageInfoTextView.setText(stringResId);
|
||||||
mGlide.load(R.drawable.error_image).into(mFetchMessageInfoImageView);
|
mGlide.load(R.drawable.error_image).into(mFetchMessageInfoImageView);
|
||||||
@ -300,4 +308,8 @@ public class ViewMessageActivity extends BaseActivity {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onRefresh() {
|
||||||
|
mMessageViewModel.refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import android.content.res.Configuration;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@ -15,7 +16,6 @@ import android.view.Window;
|
|||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -26,6 +26,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.LinearSmoothScroller;
|
import androidx.recyclerview.widget.LinearSmoothScroller;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.RequestManager;
|
import com.bumptech.glide.RequestManager;
|
||||||
@ -135,8 +136,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
AppBarLayout appBarLayout;
|
AppBarLayout appBarLayout;
|
||||||
@BindView(R.id.toolbar_view_post_detail_activity)
|
@BindView(R.id.toolbar_view_post_detail_activity)
|
||||||
Toolbar toolbar;
|
Toolbar toolbar;
|
||||||
@BindView(R.id.progress_bar_view_post_detail_activity)
|
@BindView(R.id.swipe_refresh_layout_view_post_detail_activity)
|
||||||
ProgressBar mProgressBar;
|
SwipeRefreshLayout mSwipeRefreshLayout;
|
||||||
@BindView(R.id.recycler_view_view_post_detail)
|
@BindView(R.id.recycler_view_view_post_detail)
|
||||||
RecyclerView mRecyclerView;
|
RecyclerView mRecyclerView;
|
||||||
@BindView(R.id.fetch_post_info_linear_layout_view_post_detail_activity)
|
@BindView(R.id.fetch_post_info_linear_layout_view_post_detail_activity)
|
||||||
@ -311,6 +312,13 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mSwipeRefreshLayout.setOnRefreshListener(() -> refresh(true, true));
|
||||||
|
|
||||||
|
TypedValue typedValue = new TypedValue();
|
||||||
|
getTheme().resolveAttribute(R.attr.cardViewBackgroundColor, typedValue, true);
|
||||||
|
mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(typedValue.data);
|
||||||
|
mSwipeRefreshLayout.setColorSchemeResources(R.color.colorAccent);
|
||||||
|
|
||||||
mSmoothScroller = new LinearSmoothScroller(this) {
|
mSmoothScroller = new LinearSmoothScroller(this) {
|
||||||
@Override
|
@Override
|
||||||
protected int getVerticalSnapPreference() {
|
protected int getVerticalSnapPreference() {
|
||||||
@ -510,7 +518,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
|
|
||||||
private void fetchPostAndCommentsById(String subredditId) {
|
private void fetchPostAndCommentsById(String subredditId) {
|
||||||
mFetchPostInfoLinearLayout.setVisibility(View.GONE);
|
mFetchPostInfoLinearLayout.setVisibility(View.GONE);
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
mSwipeRefreshLayout.setRefreshing(true);
|
||||||
mGlide.clear(mFetchPostInfoImageView);
|
mGlide.clear(mFetchPostInfoImageView);
|
||||||
|
|
||||||
String sortType = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, SortType.Type.BEST.value).toLowerCase();
|
String sortType = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, SortType.Type.BEST.value).toLowerCase();
|
||||||
@ -537,7 +545,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
postAndComments.enqueue(new Callback<String>() {
|
postAndComments.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
|
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
ParsePost.parsePost(response.body(), mLocale, new ParsePost.ParsePostListener() {
|
ParsePost.parsePost(response.body(), mLocale, new ParsePost.ParsePostListener() {
|
||||||
@ -860,6 +868,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
|
|
||||||
mMenu.findItem(R.id.action_view_crosspost_parent_view_post_detail_activity).setVisible(mPost.getCrosspostParentId() != null);
|
mMenu.findItem(R.id.action_view_crosspost_parent_view_post_detail_activity).setVisible(mPost.getCrosspostParentId() != null);
|
||||||
}
|
}
|
||||||
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -873,7 +882,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showErrorView(String subredditId) {
|
private void showErrorView(String subredditId) {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
mFetchPostInfoLinearLayout.setVisibility(View.VISIBLE);
|
mFetchPostInfoLinearLayout.setVisibility(View.VISIBLE);
|
||||||
mFetchPostInfoLinearLayout.setOnClickListener(view -> fetchPostAndCommentsById(subredditId));
|
mFetchPostInfoLinearLayout.setOnClickListener(view -> fetchPostAndCommentsById(subredditId));
|
||||||
mFetchPostInfoTextView.setText(R.string.load_post_error);
|
mFetchPostInfoTextView.setText(R.string.load_post_error);
|
||||||
|
@ -8,6 +8,7 @@ import android.content.res.Configuration;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -21,10 +22,10 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.RequestManager;
|
import com.bumptech.glide.RequestManager;
|
||||||
import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
@ -39,8 +40,8 @@ import ml.docilealligator.infinityforreddit.Infinity;
|
|||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
|
|
||||||
@ -59,10 +60,10 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
|||||||
|
|
||||||
@BindView(R.id.coordinator_layout_comments_listing_fragment)
|
@BindView(R.id.coordinator_layout_comments_listing_fragment)
|
||||||
CoordinatorLayout mCoordinatorLayout;
|
CoordinatorLayout mCoordinatorLayout;
|
||||||
|
@BindView(R.id.swipe_refresh_layout_view_comments_listing_fragment)
|
||||||
|
SwipeRefreshLayout mSwipeRefreshLayout;
|
||||||
@BindView(R.id.recycler_view_comments_listing_fragment)
|
@BindView(R.id.recycler_view_comments_listing_fragment)
|
||||||
RecyclerView mCommentRecyclerView;
|
RecyclerView mCommentRecyclerView;
|
||||||
@BindView(R.id.progress_bar_comments_listing_fragment)
|
|
||||||
CircleProgressBar mProgressBar;
|
|
||||||
@BindView(R.id.fetch_comments_info_linear_layout_comments_listing_fragment)
|
@BindView(R.id.fetch_comments_info_linear_layout_comments_listing_fragment)
|
||||||
LinearLayout mFetchCommentInfoLinearLayout;
|
LinearLayout mFetchCommentInfoLinearLayout;
|
||||||
@BindView(R.id.fetch_comments_info_image_view_comments_listing_fragment)
|
@BindView(R.id.fetch_comments_info_image_view_comments_listing_fragment)
|
||||||
@ -179,7 +180,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
|||||||
mCommentViewModel.getComments().observe(this, comments -> mAdapter.submitList(comments));
|
mCommentViewModel.getComments().observe(this, comments -> mAdapter.submitList(comments));
|
||||||
|
|
||||||
mCommentViewModel.hasComment().observe(this, hasComment -> {
|
mCommentViewModel.hasComment().observe(this, hasComment -> {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
if (hasComment) {
|
if (hasComment) {
|
||||||
mFetchCommentInfoLinearLayout.setVisibility(View.GONE);
|
mFetchCommentInfoLinearLayout.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
@ -192,17 +193,24 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
|||||||
|
|
||||||
mCommentViewModel.getInitialLoadingState().observe(this, networkState -> {
|
mCommentViewModel.getInitialLoadingState().observe(this, networkState -> {
|
||||||
if (networkState.getStatus().equals(NetworkState.Status.SUCCESS)) {
|
if (networkState.getStatus().equals(NetworkState.Status.SUCCESS)) {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
} else if (networkState.getStatus().equals(NetworkState.Status.FAILED)) {
|
} else if (networkState.getStatus().equals(NetworkState.Status.FAILED)) {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
mFetchCommentInfoLinearLayout.setOnClickListener(view -> refresh());
|
mFetchCommentInfoLinearLayout.setOnClickListener(view -> refresh());
|
||||||
showErrorView(R.string.load_comments_failed);
|
showErrorView(R.string.load_comments_failed);
|
||||||
} else {
|
} else {
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
mSwipeRefreshLayout.setRefreshing(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mCommentViewModel.getPaginationNetworkState().observe(this, networkState -> mAdapter.setNetworkState(networkState));
|
mCommentViewModel.getPaginationNetworkState().observe(this, networkState -> mAdapter.setNetworkState(networkState));
|
||||||
|
|
||||||
|
mSwipeRefreshLayout.setOnRefreshListener(() -> mCommentViewModel.refresh());
|
||||||
|
|
||||||
|
TypedValue typedValue = new TypedValue();
|
||||||
|
mActivity.getTheme().resolveAttribute(R.attr.cardViewBackgroundColor, typedValue, true);
|
||||||
|
mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(typedValue.data);
|
||||||
|
mSwipeRefreshLayout.setColorSchemeResources(R.color.colorAccent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeSortType(SortType sortType) {
|
public void changeSortType(SortType sortType) {
|
||||||
@ -231,7 +239,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
|||||||
|
|
||||||
private void showErrorView(int stringResId) {
|
private void showErrorView(int stringResId) {
|
||||||
if (mActivity != null && isAdded()) {
|
if (mActivity != null && isAdded()) {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
mFetchCommentInfoLinearLayout.setVisibility(View.VISIBLE);
|
mFetchCommentInfoLinearLayout.setVisibility(View.VISIBLE);
|
||||||
mFetchCommentInfoTextView.setText(stringResId);
|
mFetchCommentInfoTextView.setText(stringResId);
|
||||||
mGlide.load(R.drawable.error_image).into(mFetchCommentInfoImageView);
|
mGlide.load(R.drawable.error_image).into(mFetchCommentInfoImageView);
|
||||||
|
@ -12,6 +12,7 @@ import android.os.Build;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -25,6 +26,7 @@ import android.widget.Toast;
|
|||||||
import androidx.annotation.DimenRes;
|
import androidx.annotation.DimenRes;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.paging.PagedList;
|
import androidx.paging.PagedList;
|
||||||
@ -233,6 +235,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
mPostViewModel.refresh();
|
mPostViewModel.refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
TypedValue typedValue = new TypedValue();
|
||||||
|
activity.getTheme().resolveAttribute(R.attr.cardViewBackgroundColor, typedValue, true);
|
||||||
|
mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(typedValue.data);
|
||||||
mSwipeRefreshLayout.setColorSchemeResources(R.color.colorAccent);
|
mSwipeRefreshLayout.setColorSchemeResources(R.color.colorAccent);
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
|
@ -2,12 +2,14 @@ package ml.docilealligator.infinityforreddit.Fragment;
|
|||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -21,9 +23,9 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
@ -38,9 +40,9 @@ import ml.docilealligator.infinityforreddit.Infinity;
|
|||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import ml.docilealligator.infinityforreddit.SubredditListingViewModel;
|
import ml.docilealligator.infinityforreddit.SubredditListingViewModel;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
|
|
||||||
@ -58,8 +60,8 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
CoordinatorLayout mCoordinatorLayout;
|
CoordinatorLayout mCoordinatorLayout;
|
||||||
@BindView(R.id.recycler_view_subreddit_listing_fragment)
|
@BindView(R.id.recycler_view_subreddit_listing_fragment)
|
||||||
RecyclerView mSubredditListingRecyclerView;
|
RecyclerView mSubredditListingRecyclerView;
|
||||||
@BindView(R.id.progress_bar_subreddit_listing_fragment)
|
@BindView(R.id.swipe_refresh_layout_subreddit_listing_fragment)
|
||||||
CircleProgressBar mProgressBar;
|
SwipeRefreshLayout mSwipeRefreshLayout;
|
||||||
@BindView(R.id.fetch_subreddit_listing_info_linear_layout_subreddit_listing_fragment)
|
@BindView(R.id.fetch_subreddit_listing_info_linear_layout_subreddit_listing_fragment)
|
||||||
LinearLayout mFetchSubredditListingInfoLinearLayout;
|
LinearLayout mFetchSubredditListingInfoLinearLayout;
|
||||||
@BindView(R.id.fetch_subreddit_listing_info_image_view_subreddit_listing_fragment)
|
@BindView(R.id.fetch_subreddit_listing_info_image_view_subreddit_listing_fragment)
|
||||||
@ -79,6 +81,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
private LinearLayoutManager mLinearLayoutManager;
|
private LinearLayoutManager mLinearLayoutManager;
|
||||||
private SubredditListingRecyclerViewAdapter mAdapter;
|
private SubredditListingRecyclerViewAdapter mAdapter;
|
||||||
|
private Activity mActivity;
|
||||||
|
|
||||||
public SubredditListingFragment() {
|
public SubredditListingFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
@ -91,9 +94,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View rootView = inflater.inflate(R.layout.fragment_subreddit_listing, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_subreddit_listing, container, false);
|
||||||
|
|
||||||
Activity activity = getActivity();
|
((Infinity) mActivity.getApplication()).getAppComponent().inject(this);
|
||||||
|
|
||||||
((Infinity) activity.getApplication()).getAppComponent().inject(this);
|
|
||||||
|
|
||||||
ButterKnife.bind(this, rootView);
|
ButterKnife.bind(this, rootView);
|
||||||
|
|
||||||
@ -119,7 +120,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
String sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_SUBREDDIT, SortType.Type.RELEVANCE.value);
|
String sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_SUBREDDIT, SortType.Type.RELEVANCE.value);
|
||||||
SortType sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase()));
|
SortType sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase()));
|
||||||
|
|
||||||
mAdapter = new SubredditListingRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit,
|
mAdapter = new SubredditListingRecyclerViewAdapter(mActivity, mOauthRetrofit, mRetrofit,
|
||||||
accessToken, accountName, mRedditDataRoomDatabase,
|
accessToken, accountName, mRedditDataRoomDatabase,
|
||||||
new SubredditListingRecyclerViewAdapter.Callback() {
|
new SubredditListingRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
@ -130,11 +131,11 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
@Override
|
@Override
|
||||||
public void subredditSelected(String subredditName, String iconUrl) {
|
public void subredditSelected(String subredditName, String iconUrl) {
|
||||||
if (isPosting) {
|
if (isPosting) {
|
||||||
((SearchSubredditsResultActivity) activity).getSelectedSubreddit(subredditName, iconUrl);
|
((SearchSubredditsResultActivity) mActivity).getSelectedSubreddit(subredditName, iconUrl);
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(activity, ViewSubredditDetailActivity.class);
|
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
|
||||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, subredditName);
|
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, subredditName);
|
||||||
activity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -146,7 +147,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
mSubredditListingViewModel.getSubreddits().observe(this, subredditData -> mAdapter.submitList(subredditData));
|
mSubredditListingViewModel.getSubreddits().observe(this, subredditData -> mAdapter.submitList(subredditData));
|
||||||
|
|
||||||
mSubredditListingViewModel.hasSubredditLiveData().observe(this, hasSubreddit -> {
|
mSubredditListingViewModel.hasSubredditLiveData().observe(this, hasSubreddit -> {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
if (hasSubreddit) {
|
if (hasSubreddit) {
|
||||||
mFetchSubredditListingInfoLinearLayout.setVisibility(View.GONE);
|
mFetchSubredditListingInfoLinearLayout.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
@ -159,13 +160,13 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
|
|
||||||
mSubredditListingViewModel.getInitialLoadingState().observe(this, networkState -> {
|
mSubredditListingViewModel.getInitialLoadingState().observe(this, networkState -> {
|
||||||
if (networkState.getStatus().equals(NetworkState.Status.SUCCESS)) {
|
if (networkState.getStatus().equals(NetworkState.Status.SUCCESS)) {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
} else if (networkState.getStatus().equals(NetworkState.Status.FAILED)) {
|
} else if (networkState.getStatus().equals(NetworkState.Status.FAILED)) {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
mFetchSubredditListingInfoLinearLayout.setOnClickListener(view -> refresh());
|
mFetchSubredditListingInfoLinearLayout.setOnClickListener(view -> refresh());
|
||||||
showErrorView(R.string.search_subreddits_error);
|
showErrorView(R.string.search_subreddits_error);
|
||||||
} else {
|
} else {
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
mSwipeRefreshLayout.setRefreshing(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -173,12 +174,25 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
mAdapter.setNetworkState(networkState);
|
mAdapter.setNetworkState(networkState);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mSwipeRefreshLayout.setOnRefreshListener(() -> mSubredditListingViewModel.refresh());
|
||||||
|
|
||||||
|
TypedValue typedValue = new TypedValue();
|
||||||
|
mActivity.getTheme().resolveAttribute(R.attr.cardViewBackgroundColor, typedValue, true);
|
||||||
|
mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(typedValue.data);
|
||||||
|
mSwipeRefreshLayout.setColorSchemeResources(R.color.colorAccent);
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(@NonNull Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
mActivity = (Activity) context;
|
||||||
|
}
|
||||||
|
|
||||||
private void showErrorView(int stringResId) {
|
private void showErrorView(int stringResId) {
|
||||||
if (getActivity() != null && isAdded()) {
|
if (getActivity() != null && isAdded()) {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
mFetchSubredditListingInfoLinearLayout.setVisibility(View.VISIBLE);
|
mFetchSubredditListingInfoLinearLayout.setVisibility(View.VISIBLE);
|
||||||
mFetchSubredditListingInfoTextView.setText(stringResId);
|
mFetchSubredditListingInfoTextView.setText(stringResId);
|
||||||
Glide.with(this).load(R.drawable.error_image).into(mFetchSubredditListingInfoImageView);
|
Glide.with(this).load(R.drawable.error_image).into(mFetchSubredditListingInfoImageView);
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package ml.docilealligator.infinityforreddit.Fragment;
|
package ml.docilealligator.infinityforreddit.Fragment;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -13,14 +16,15 @@ import android.widget.ImageView;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
@ -33,9 +37,9 @@ import ml.docilealligator.infinityforreddit.Infinity;
|
|||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import ml.docilealligator.infinityforreddit.UserListingViewModel;
|
import ml.docilealligator.infinityforreddit.UserListingViewModel;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
|
|
||||||
@ -52,8 +56,8 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
|
|||||||
CoordinatorLayout mCoordinatorLayout;
|
CoordinatorLayout mCoordinatorLayout;
|
||||||
@BindView(R.id.recycler_view_user_listing_fragment)
|
@BindView(R.id.recycler_view_user_listing_fragment)
|
||||||
RecyclerView mUserListingRecyclerView;
|
RecyclerView mUserListingRecyclerView;
|
||||||
@BindView(R.id.progress_bar_user_listing_fragment)
|
@BindView(R.id.swipe_refresh_layout_user_listing_fragment)
|
||||||
CircleProgressBar mProgressBar;
|
SwipeRefreshLayout mSwipeRefreshLayout;
|
||||||
@BindView(R.id.fetch_user_listing_info_linear_layout_user_listing_fragment)
|
@BindView(R.id.fetch_user_listing_info_linear_layout_user_listing_fragment)
|
||||||
LinearLayout mFetchUserListingInfoLinearLayout;
|
LinearLayout mFetchUserListingInfoLinearLayout;
|
||||||
@BindView(R.id.fetch_user_listing_info_image_view_user_listing_fragment)
|
@BindView(R.id.fetch_user_listing_info_image_view_user_listing_fragment)
|
||||||
@ -74,6 +78,7 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
|
|||||||
private LinearLayoutManager mLinearLayoutManager;
|
private LinearLayoutManager mLinearLayoutManager;
|
||||||
private String mQuery;
|
private String mQuery;
|
||||||
private UserListingRecyclerViewAdapter mAdapter;
|
private UserListingRecyclerViewAdapter mAdapter;
|
||||||
|
private Activity mActivity;
|
||||||
|
|
||||||
public UserListingFragment() {
|
public UserListingFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
@ -86,7 +91,7 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
|
|||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View rootView = inflater.inflate(R.layout.fragment_user_listing, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_user_listing, container, false);
|
||||||
|
|
||||||
((Infinity) getActivity().getApplication()).getAppComponent().inject(this);
|
((Infinity) mActivity.getApplication()).getAppComponent().inject(this);
|
||||||
|
|
||||||
ButterKnife.bind(this, rootView);
|
ButterKnife.bind(this, rootView);
|
||||||
|
|
||||||
@ -122,7 +127,7 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
|
|||||||
mUserListingViewModel.getUsers().observe(this, UserData -> mAdapter.submitList(UserData));
|
mUserListingViewModel.getUsers().observe(this, UserData -> mAdapter.submitList(UserData));
|
||||||
|
|
||||||
mUserListingViewModel.hasUser().observe(this, hasUser -> {
|
mUserListingViewModel.hasUser().observe(this, hasUser -> {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
if (hasUser) {
|
if (hasUser) {
|
||||||
mFetchUserListingInfoLinearLayout.setVisibility(View.GONE);
|
mFetchUserListingInfoLinearLayout.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
@ -135,13 +140,13 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
|
|||||||
|
|
||||||
mUserListingViewModel.getInitialLoadingState().observe(this, networkState -> {
|
mUserListingViewModel.getInitialLoadingState().observe(this, networkState -> {
|
||||||
if (networkState.getStatus().equals(NetworkState.Status.SUCCESS)) {
|
if (networkState.getStatus().equals(NetworkState.Status.SUCCESS)) {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
} else if (networkState.getStatus().equals(NetworkState.Status.FAILED)) {
|
} else if (networkState.getStatus().equals(NetworkState.Status.FAILED)) {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
mFetchUserListingInfoLinearLayout.setOnClickListener(view -> refresh());
|
mFetchUserListingInfoLinearLayout.setOnClickListener(view -> refresh());
|
||||||
showErrorView(R.string.search_users_error);
|
showErrorView(R.string.search_users_error);
|
||||||
} else {
|
} else {
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
mSwipeRefreshLayout.setRefreshing(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -149,12 +154,25 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
|
|||||||
mAdapter.setNetworkState(networkState);
|
mAdapter.setNetworkState(networkState);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mSwipeRefreshLayout.setOnRefreshListener(() -> mUserListingViewModel.refresh());
|
||||||
|
|
||||||
|
TypedValue typedValue = new TypedValue();
|
||||||
|
mActivity.getTheme().resolveAttribute(R.attr.cardViewBackgroundColor, typedValue, true);
|
||||||
|
mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(typedValue.data);
|
||||||
|
mSwipeRefreshLayout.setColorSchemeResources(R.color.colorAccent);
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(@NonNull Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
mActivity = (Activity) context;
|
||||||
|
}
|
||||||
|
|
||||||
private void showErrorView(int stringResId) {
|
private void showErrorView(int stringResId) {
|
||||||
if (getActivity() != null && isAdded()) {
|
if (getActivity() != null && isAdded()) {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
mFetchUserListingInfoLinearLayout.setVisibility(View.VISIBLE);
|
mFetchUserListingInfoLinearLayout.setVisibility(View.VISIBLE);
|
||||||
mFetchUserListingInfoTextView.setText(stringResId);
|
mFetchUserListingInfoTextView.setText(stringResId);
|
||||||
Glide.with(this).load(R.drawable.error_image).into(mFetchUserListingInfoImageView);
|
Glide.with(this).load(R.drawable.error_image).into(mFetchUserListingInfoImageView);
|
||||||
|
@ -38,22 +38,19 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" >
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" >
|
||||||
|
|
||||||
<com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/progress_bar_view_message_activity"
|
android:id="@+id/swipe_refresh_layout_view_message_activity"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
app:mlpb_progress_stoke_width="3dp"
|
|
||||||
app:mlpb_progress_color="@color/colorAccent"
|
|
||||||
app:mlpb_background_color="?attr/circularProgressBarBackground" />
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/recycler_view_view_message_activity"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipToPadding="false"/>
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/recycler_view_view_message_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:clipToPadding="false"/>
|
||||||
|
|
||||||
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/fetch_messages_info_linear_layout_view_message_activity"
|
android:id="@+id/fetch_messages_info_linear_layout_view_message_activity"
|
||||||
|
@ -33,19 +33,19 @@
|
|||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<ProgressBar
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/progress_bar_view_post_detail_activity"
|
android:id="@+id/swipe_refresh_layout_view_post_detail_activity"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/recycler_view_view_post_detail"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:clipToPadding="false"
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/recycler_view_view_post_detail"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clipToPadding="false" />
|
||||||
|
|
||||||
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/fetch_post_info_linear_layout_view_post_detail_activity"
|
android:id="@+id/fetch_post_info_linear_layout_view_post_detail_activity"
|
||||||
|
@ -7,22 +7,18 @@
|
|||||||
android:id="@+id/coordinator_layout_comments_listing_fragment"
|
android:id="@+id/coordinator_layout_comments_listing_fragment"
|
||||||
tools:application="ml.docilealligator.infinityforreddit.Fragment.CommentsListingFragment">
|
tools:application="ml.docilealligator.infinityforreddit.Fragment.CommentsListingFragment">
|
||||||
|
|
||||||
<com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/progress_bar_comments_listing_fragment"
|
android:id="@+id/swipe_refresh_layout_view_comments_listing_fragment"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
app:mlpb_progress_stoke_width="3dp"
|
|
||||||
app:mlpb_progress_color="@color/colorAccent"
|
|
||||||
app:mlpb_background_color="?attr/circularProgressBarBackground"
|
|
||||||
android:layout_gravity="center_horizontal"/>
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/recycler_view_comments_listing_fragment"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:clipToPadding="false" />
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/recycler_view_comments_listing_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:clipToPadding="false" />
|
||||||
|
|
||||||
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/fetch_comments_info_linear_layout_comments_listing_fragment"
|
android:id="@+id/fetch_comments_info_linear_layout_comments_listing_fragment"
|
||||||
|
@ -8,8 +8,7 @@
|
|||||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/swipe_refresh_layout_post_fragment"
|
android:id="@+id/swipe_refresh_layout_post_fragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:background="@color/backgroundColor">
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/recycler_view_post_fragment"
|
android:id="@+id/recycler_view_post_fragment"
|
||||||
|
@ -7,22 +7,18 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
tools:application=".SubredditListingFragment">
|
tools:application=".SubredditListingFragment">
|
||||||
|
|
||||||
<com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/progress_bar_subreddit_listing_fragment"
|
android:id="@+id/swipe_refresh_layout_subreddit_listing_fragment"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
app:mlpb_progress_stoke_width="3dp"
|
|
||||||
app:mlpb_progress_color="@color/colorAccent"
|
|
||||||
app:mlpb_background_color="?attr/circularProgressBarBackground"
|
|
||||||
android:layout_gravity="center_horizontal"/>
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/recycler_view_subreddit_listing_fragment"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:clipToPadding="false" />
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/recycler_view_subreddit_listing_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:clipToPadding="false" />
|
||||||
|
|
||||||
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/fetch_subreddit_listing_info_linear_layout_subreddit_listing_fragment"
|
android:id="@+id/fetch_subreddit_listing_info_linear_layout_subreddit_listing_fragment"
|
||||||
|
@ -7,22 +7,18 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
tools:application=".UserListingFragment">
|
tools:application=".UserListingFragment">
|
||||||
|
|
||||||
<com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/progress_bar_user_listing_fragment"
|
android:id="@+id/swipe_refresh_layout_user_listing_fragment"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
app:mlpb_progress_stoke_width="3dp"
|
|
||||||
app:mlpb_progress_color="@color/colorAccent"
|
|
||||||
app:mlpb_background_color="?attr/circularProgressBarBackground"
|
|
||||||
android:layout_gravity="center_horizontal"/>
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/recycler_view_user_listing_fragment"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:clipToPadding="false" />
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/recycler_view_user_listing_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:clipToPadding="false" />
|
||||||
|
|
||||||
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/fetch_user_listing_info_linear_layout_user_listing_fragment"
|
android:id="@+id/fetch_user_listing_info_linear_layout_user_listing_fragment"
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
app:cardBackgroundColor="?attr/cardViewBackgroundColor"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
Loading…
Reference in New Issue
Block a user