Long press a multireddit in the list to show some options. Fix some UI issues.

This commit is contained in:
Alex Ning 2020-04-05 16:21:47 +08:00
parent 28b9eb37da
commit 7a429f902d
20 changed files with 328 additions and 114 deletions

View File

@ -33,7 +33,7 @@
android:name=".Activity.ThemePreviewActivity"
android:label="@string/theme_preview_activity_label"
android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" />
android:theme="@style/AppTheme.NoActionBarWithTranslucentWindow" />
<activity
android:name=".Activity.CustomThemeListingActivity"
android:label="@string/custom_theme_listing_activity_label"

View File

@ -103,6 +103,16 @@ public class CustomThemeListingActivity extends BaseActivity implements
CustomThemeWrapper.getPredefinedThemes(this));
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
if (dy > 0) {
fab.hide();
} else if (dy < 0) {
fab.show();
}
}
});
customThemeViewModel = new ViewModelProvider(this,
new CustomThemeViewModel.Factory(redditDataRoomDatabase))

View File

@ -71,72 +71,76 @@ public class LinkResolverActivity extends AppCompatActivity {
String messageFullname = getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME);
String newAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
if (path.matches(POST_PATTERN)) {
List<String> segments = uri.getPathSegments();
int commentsIndex = segments.lastIndexOf("comments");
if (commentsIndex >= 0 && commentsIndex < segments.size() - 1) {
String authority = uri.getAuthority();
if (authority != null && (authority.contains("reddit.com") || authority.contains("redd.it") || authority.contains("reddit.app"))) {
if (path.matches(POST_PATTERN)) {
List<String> segments = uri.getPathSegments();
int commentsIndex = segments.lastIndexOf("comments");
if (commentsIndex >= 0 && commentsIndex < segments.size() - 1) {
Intent intent = new Intent(this, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, segments.get(commentsIndex + 1));
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
} else {
deepLinkError(uri);
}
} else if (path.matches(COMMENT_PATTERN)) {
List<String> segments = uri.getPathSegments();
int commentsIndex = segments.lastIndexOf("comments");
if (commentsIndex >= 0 && commentsIndex < segments.size() - 1) {
Intent intent = new Intent(this, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, segments.get(commentsIndex + 1));
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, segments.get(segments.size() - 1));
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
} else {
deepLinkError(uri);
}
} else if (path.matches(SUBREDDIT_PATTERN)) {
String subredditName = path.substring(3);
if (subredditName.equals("popular") || subredditName.equals("all")) {
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra(MainActivity.EXTRA_POST_TYPE, subredditName);
intent.putExtra(MainActivity.EXTRA_MESSSAGE_FULLNAME, messageFullname);
intent.putExtra(MainActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
} else {
Intent intent = new Intent(this, ViewSubredditDetailActivity.class);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, path.substring(3));
intent.putExtra(ViewSubredditDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
}
} else if (path.matches(USER_PATTERN_1)) {
Intent intent = new Intent(this, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, path.substring(6));
intent.putExtra(ViewUserDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewUserDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
} else if (path.matches(USER_PATTERN_2)) {
Intent intent = new Intent(this, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, path.substring(3));
intent.putExtra(ViewUserDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewUserDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
} else if (path.matches(SIDEBAR_PATTERN)) {
Intent intent = new Intent(this, ViewSidebarActivity.class);
intent.putExtra(ViewSidebarActivity.EXTRA_SUBREDDIT_NAME, path.substring(3, path.length() - 14));
startActivity(intent);
} else if (path.matches(MULTIREDDIT_PATTERN)) {
Intent intent = new Intent(this, ViewMultiRedditDetailActivity.class);
intent.putExtra(ViewMultiRedditDetailActivity.EXTRA_MULTIREDDIT_PATH, path);
startActivity(intent);
} else if (path.matches(REDD_IT_POST_PATTERN)) {
Intent intent = new Intent(this, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, segments.get(commentsIndex + 1));
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, path.substring(1));
startActivity(intent);
} else {
deepLinkError(uri);
}
} else if (path.matches(COMMENT_PATTERN)) {
List<String> segments = uri.getPathSegments();
int commentsIndex = segments.lastIndexOf("comments");
if (commentsIndex >= 0 && commentsIndex < segments.size() - 1) {
Intent intent = new Intent(this, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, segments.get(commentsIndex + 1));
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, segments.get(segments.size() - 1));
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
} else {
deepLinkError(uri);
}
} else if (path.matches(SUBREDDIT_PATTERN)) {
String subredditName = path.substring(3);
if (subredditName.equals("popular") || subredditName.equals("all")) {
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra(MainActivity.EXTRA_POST_TYPE, subredditName);
intent.putExtra(MainActivity.EXTRA_MESSSAGE_FULLNAME, messageFullname);
intent.putExtra(MainActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
} else {
Intent intent = new Intent(this, ViewSubredditDetailActivity.class);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, path.substring(3));
intent.putExtra(ViewSubredditDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
}
} else if (path.matches(USER_PATTERN_1)) {
Intent intent = new Intent(this, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, path.substring(6));
intent.putExtra(ViewUserDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewUserDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
} else if (path.matches(USER_PATTERN_2)) {
Intent intent = new Intent(this, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, path.substring(3));
intent.putExtra(ViewUserDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewUserDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
} else if (path.matches(SIDEBAR_PATTERN)) {
Intent intent = new Intent(this, ViewSidebarActivity.class);
intent.putExtra(ViewSidebarActivity.EXTRA_SUBREDDIT_NAME, path.substring(3, path.length() - 14));
startActivity(intent);
} else if (path.matches(MULTIREDDIT_PATTERN)) {
Intent intent = new Intent(this, ViewMultiRedditDetailActivity.class);
intent.putExtra(ViewMultiRedditDetailActivity.EXTRA_MULTIREDDIT_PATH, path);
startActivity(intent);
} else if (path.matches(REDD_IT_POST_PATTERN)) {
Intent intent = new Intent(this, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, path.substring(1));
startActivity(intent);
}
else {
} else {
deepLinkError(uri);
}
}

View File

@ -24,8 +24,11 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import org.greenrobot.eventbus.Subscribe;
import java.util.ArrayList;
import javax.inject.Inject;
@ -37,7 +40,9 @@ import ml.docilealligator.infinityforreddit.Adapter.MultiRedditListingRecyclerVi
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.InsertMultiRedditAsyncTask;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.RefreshMultiRedditsEvent;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.MultiReddit.DeleteMultiReddit;
import ml.docilealligator.infinityforreddit.MultiReddit.FetchMyMultiReddits;
import ml.docilealligator.infinityforreddit.MultiReddit.MultiReddit;
import ml.docilealligator.infinityforreddit.MultiReddit.MultiRedditViewModel;
@ -260,4 +265,33 @@ public class MultiRedditListingActivity extends BaseActivity {
mErrorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
applyFABTheme(fab);
}
public void deleteMultiReddit(MultiReddit multiReddit) {
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.delete)
.setMessage(R.string.delete_multi_reddit_dialog_message)
.setPositiveButton(R.string.delete, (dialogInterface, i)
-> DeleteMultiReddit.deleteMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase,
mAccessToken, mAccountName, multiReddit.getPath(), new DeleteMultiReddit.DeleteMultiRedditListener() {
@Override
public void success() {
Toast.makeText(MultiRedditListingActivity.this,
R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show();
loadMultiReddits();
}
@Override
public void failed() {
Toast.makeText(MultiRedditListingActivity.this,
R.string.delete_multi_reddit_failed, Toast.LENGTH_SHORT).show();
}
}))
.setNegativeButton(R.string.cancel, null)
.show();
}
@Subscribe
public void onRefreshMultiRedditsEvent(RefreshMultiRedditsEvent event) {
loadMultiReddits();
}
}

View File

@ -75,6 +75,17 @@ public class SelectedSubredditsActivity extends BaseActivity {
adapter = new SelectedSubredditsRecyclerViewAdapter(mCustomThemeWrapper, subreddits);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(adapter);
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (dy > 0) {
fab.hide();
} else {
fab.show();
}
}
});
fab.setOnClickListener(view -> {
Intent intent = new Intent(this, SubredditMultiselectionActivity.class);

View File

@ -19,6 +19,8 @@ import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import org.greenrobot.eventbus.EventBus;
import javax.inject.Inject;
import javax.inject.Named;
@ -26,6 +28,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.RefreshMultiRedditsEvent;
import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
import ml.docilealligator.infinityforreddit.Fragment.PostLayoutBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Fragment.SortTimeBottomSheetFragment;
@ -33,7 +36,6 @@ import ml.docilealligator.infinityforreddit.Fragment.SortTypeBottomSheetFragment
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.MultiReddit.DeleteMultiReddit;
import ml.docilealligator.infinityforreddit.MultiReddit.EditMultiReddit;
import ml.docilealligator.infinityforreddit.MultiReddit.MultiReddit;
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
import ml.docilealligator.infinityforreddit.R;
@ -259,23 +261,22 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
.setTitle(R.string.delete)
.setMessage(R.string.delete_multi_reddit_dialog_message)
.setPositiveButton(R.string.delete, (dialogInterface, i)
-> {
DeleteMultiReddit.deleteMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase,
mAccessToken, mAccountName, multiPath, new DeleteMultiReddit.DeleteMultiRedditListener() {
@Override
public void success() {
Toast.makeText(ViewMultiRedditDetailActivity.this,
R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show();
finish();
}
-> DeleteMultiReddit.deleteMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase,
mAccessToken, mAccountName, multiPath, new DeleteMultiReddit.DeleteMultiRedditListener() {
@Override
public void success() {
Toast.makeText(ViewMultiRedditDetailActivity.this,
R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new RefreshMultiRedditsEvent());
finish();
}
@Override
public void failed() {
Toast.makeText(ViewMultiRedditDetailActivity.this,
R.string.delete_multi_reddit_failed, Toast.LENGTH_SHORT).show();
}
});
})
@Override
public void failed() {
Toast.makeText(ViewMultiRedditDetailActivity.this,
R.string.delete_multi_reddit_failed, Toast.LENGTH_SHORT).show();
}
}))
.setNegativeButton(R.string.cancel, null)
.show();
return true;

View File

@ -101,6 +101,10 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
customThemeOptionsBottomSheetFragment.setArguments(bundle);
customThemeOptionsBottomSheetFragment.show(activity.getSupportFragmentManager(), customThemeOptionsBottomSheetFragment.getTag());
});
((UserCustomThemeViewHolder) holder).itemView.setOnLongClickListener(view -> {
((UserCustomThemeViewHolder) holder).itemView.performClick();
return true;
});
} else if (holder instanceof PreDefinedThemeDividerViewHolder) {
((TextView) ((PreDefinedThemeDividerViewHolder) holder).itemView).setText(R.string.predefined_themes);
} else if (holder instanceof UserThemeDividerViewHolder) {
@ -127,7 +131,7 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
@BindView(R.id.add_image_view_item_predefined_custom_theme)
ImageView createThemeImageView;
public PredefinedCustomThemeViewHolder(@NonNull View itemView) {
PredefinedCustomThemeViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
@ -144,7 +148,7 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
@BindView(R.id.share_image_view_item_user_custom_theme)
ImageView shareImageView;
public UserCustomThemeViewHolder(@NonNull View itemView) {
UserCustomThemeViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
@ -152,14 +156,14 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
class PreDefinedThemeDividerViewHolder extends RecyclerView.ViewHolder {
public PreDefinedThemeDividerViewHolder(@NonNull View itemView) {
PreDefinedThemeDividerViewHolder(@NonNull View itemView) {
super(itemView);
}
}
class UserThemeDividerViewHolder extends RecyclerView.ViewHolder {
public UserThemeDividerViewHolder(@NonNull View itemView) {
UserThemeDividerViewHolder(@NonNull View itemView) {
super(itemView);
}
}

View File

@ -54,7 +54,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
mOauthRetrofit = oauthRetrofit;
mRedditDataRoomDatabase = redditDataRoomDatabase;
mAccessToken = accessToken;
glide = Glide.with(context.getApplicationContext());
glide = Glide.with(context);
mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor();
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
}

View File

@ -1,7 +1,7 @@
package ml.docilealligator.infinityforreddit.Adapter;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -10,6 +10,7 @@ import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
@ -23,6 +24,7 @@ import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.Activity.ViewMultiRedditDetailActivity;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Fragment.MultiRedditOptionsBottomSheetFragment;
import ml.docilealligator.infinityforreddit.MultiReddit.FavoriteMultiReddit;
import ml.docilealligator.infinityforreddit.MultiReddit.MultiReddit;
import ml.docilealligator.infinityforreddit.R;
@ -37,7 +39,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
private static final int VIEW_TYPE_MULTI_REDDIT_DIVIDER = 2;
private static final int VIEW_TYPE_MULTI_REDDIT = 3;
private Context mContext;
private AppCompatActivity mActivity;
private Retrofit mOauthRetrofit;
private RedditDataRoomDatabase mRedditDataRoomDatabase;
private RequestManager mGlide;
@ -49,12 +51,12 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
private int mPrimaryTextColor;
private int mSecondaryTextColor;
public MultiRedditListingRecyclerViewAdapter(Context context, Retrofit oauthRetrofit,
public MultiRedditListingRecyclerViewAdapter(AppCompatActivity activity, Retrofit oauthRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase,
CustomThemeWrapper customThemeWrapper,
String accessToken, String accountName) {
mContext = context;
mGlide = Glide.with(context.getApplicationContext());
mActivity = activity;
mGlide = Glide.with(activity);
mOauthRetrofit = oauthRetrofit;
mRedditDataRoomDatabase = redditDataRoomDatabase;
mAccessToken = accessToken;
@ -135,7 +137,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
@Override
public void failed() {
Toast.makeText(mContext, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show();
int position = holder.getAdapterPosition() - offset;
if(position >= 0 && mMultiReddits.size() > position) {
mMultiReddits.get(position).setFavorite(true);
@ -161,7 +163,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
@Override
public void failed() {
Toast.makeText(mContext, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show();
int position = holder.getAdapterPosition() - offset;
if(position >= 0 && mMultiReddits.size() > position) {
mMultiReddits.get(position).setFavorite(false);
@ -173,9 +175,14 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
}
});
holder.itemView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, ViewMultiRedditDetailActivity.class);
Intent intent = new Intent(mActivity, ViewMultiRedditDetailActivity.class);
intent.putExtra(ViewMultiRedditDetailActivity.EXTRA_MULTIREDDIT_DATA, multiReddit);
mContext.startActivity(intent);
mActivity.startActivity(intent);
});
holder.itemView.setOnLongClickListener(view -> {
showOptionsBottomSheetFragment(multiReddit);
return true;
});
if (iconUrl != null && !iconUrl.equals("")) {
@ -218,7 +225,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
@Override
public void failed() {
Toast.makeText(mContext, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show();
int position = holder.getAdapterPosition() - 1;
if(position >= 0 && mFavoriteMultiReddits.size() > position) {
mFavoriteMultiReddits.get(position).setFavorite(true);
@ -244,7 +251,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
@Override
public void failed() {
Toast.makeText(mContext, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show();
Toast.makeText(mActivity, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show();
int position = holder.getAdapterPosition() - 1;
if(position >= 0 && mFavoriteMultiReddits.size() > position) {
mFavoriteMultiReddits.get(position).setFavorite(false);
@ -256,9 +263,14 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
}
});
holder.itemView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, ViewMultiRedditDetailActivity.class);
Intent intent = new Intent(mActivity, ViewMultiRedditDetailActivity.class);
intent.putExtra(ViewMultiRedditDetailActivity.EXTRA_MULTIREDDIT_DATA, multiReddit);
mContext.startActivity(intent);
mActivity.startActivity(intent);
});
holder.itemView.setOnLongClickListener(view -> {
showOptionsBottomSheetFragment(multiReddit);
return true;
});
if (iconUrl != null && !iconUrl.equals("")) {
@ -298,6 +310,14 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
}
}
private void showOptionsBottomSheetFragment(MultiReddit multiReddit) {
MultiRedditOptionsBottomSheetFragment fragment = new MultiRedditOptionsBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putParcelable(MultiRedditOptionsBottomSheetFragment.EXTRA_MULTI_REDDIT, multiReddit);
fragment.setArguments(bundle);
fragment.show(mActivity.getSupportFragmentManager(), fragment.getTag());
}
public void setMultiReddits(List<MultiReddit> multiReddits) {
mMultiReddits = multiReddits;
notifyDataSetChanged();

View File

@ -198,7 +198,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
DrawableCompat.setTint(mCommentIcon, mPostIconAndInfoColor);
}
mScale = activity.getResources().getDisplayMetrics().density;
mGlide = Glide.with(mActivity.getApplicationContext());
mGlide = Glide.with(mActivity);
mRedditDataRoomDatabase = redditDataRoomDatabase;
mUserDao = redditDataRoomDatabase.userDao();
mCallback = callback;

View File

@ -80,7 +80,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
this.accountName = accountName;
this.redditDataRoomDatabase = redditDataRoomDatabase;
this.callback = callback;
glide = Glide.with(context.getApplicationContext());
glide = Glide.with(context);
colorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
primaryTextColor = customThemeWrapper.getPrimaryTextColor();
secondaryTextColor = customThemeWrapper.getSecondaryTextColor();

View File

@ -57,7 +57,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
CustomThemeWrapper customThemeWrapper,
String accessToken) {
mContext = context;
glide = Glide.with(context.getApplicationContext());
glide = Glide.with(context);
mOauthRetrofit = oauthRetrofit;
mRedditDataRoomDatabase = redditDataRoomDatabase;
this.accessToken = accessToken;

View File

@ -81,7 +81,7 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
this.accountName = accountName;
this.subscribedUserDao = subscribedUserDao;
this.retryLoadingMoreCallback = retryLoadingMoreCallback;
glide = Glide.with(context.getApplicationContext());
glide = Glide.with(context);
primaryTextColor = customThemeWrapper.getPrimaryTextColor();
buttonTextColor = customThemeWrapper.getButtonTextColor();
colorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();

View File

@ -641,7 +641,7 @@ public class CustomThemeWrapper {
return customTheme;
}
public static CustomTheme getWhite(Context context) {
private static CustomTheme getWhite(Context context) {
CustomTheme customTheme = new CustomTheme(context.getString(R.string.theme_name_white));
customTheme.isLightTheme = true;
customTheme.isDarkTheme = false;
@ -715,7 +715,7 @@ public class CustomThemeWrapper {
return customTheme;
}
public static CustomTheme getWhiteDark(Context context) {
private static CustomTheme getWhiteDark(Context context) {
CustomTheme customTheme = new CustomTheme(context.getString(R.string.theme_name_white_dark));
customTheme.isLightTheme = false;
customTheme.isDarkTheme = true;
@ -789,7 +789,7 @@ public class CustomThemeWrapper {
return customTheme;
}
public static CustomTheme getWhiteAmoled(Context context) {
private static CustomTheme getWhiteAmoled(Context context) {
CustomTheme customTheme = new CustomTheme(context.getString(R.string.theme_name_white_amoled));
customTheme.isLightTheme = false;
customTheme.isDarkTheme = false;
@ -863,7 +863,7 @@ public class CustomThemeWrapper {
return customTheme;
}
public static CustomTheme getRed(Context context) {
private static CustomTheme getRed(Context context) {
CustomTheme customTheme = new CustomTheme(context.getString(R.string.theme_name_red));
customTheme.isLightTheme = true;
customTheme.isDarkTheme = false;
@ -937,7 +937,7 @@ public class CustomThemeWrapper {
return customTheme;
}
public static CustomTheme getRedDark(Context context) {
private static CustomTheme getRedDark(Context context) {
CustomTheme customTheme = new CustomTheme(context.getString(R.string.theme_name_red_dark));
customTheme.isLightTheme = false;
customTheme.isDarkTheme = true;
@ -1011,7 +1011,7 @@ public class CustomThemeWrapper {
return customTheme;
}
public static CustomTheme getRedAmoled(Context context) {
private static CustomTheme getRedAmoled(Context context) {
CustomTheme customTheme = new CustomTheme(context.getString(R.string.theme_name_red_amoled));
customTheme.isLightTheme = false;
customTheme.isDarkTheme = false;
@ -1085,7 +1085,7 @@ public class CustomThemeWrapper {
return customTheme;
}
public static CustomTheme getDracula(Context context) {
private static CustomTheme getDracula(Context context) {
CustomTheme customTheme = new CustomTheme(context.getString(R.string.theme_name_dracula));
customTheme.isLightTheme = true;
customTheme.isDarkTheme = true;
@ -1159,7 +1159,7 @@ public class CustomThemeWrapper {
return customTheme;
}
public static CustomTheme getCalmPastel(Context context) {
private static CustomTheme getCalmPastel(Context context) {
CustomTheme customTheme = new CustomTheme(context.getString(R.string.theme_name_calm_pastel));
customTheme.isLightTheme = true;
customTheme.isDarkTheme = false;
@ -1177,7 +1177,7 @@ public class CustomThemeWrapper {
customTheme.backgroundColor = Color.parseColor("#DAD0DE");
customTheme.cardViewBackgroundColor = Color.parseColor("#C0F0F4");
customTheme.commentBackgroundColor = Color.parseColor("#C0F0F4");
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#C0F0F4");
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#D48AE0");
customTheme.primaryIconColor = Color.parseColor("#000000");
customTheme.postIconAndInfoColor = Color.parseColor("#000000");
customTheme.commentIconAndInfoColor = Color.parseColor("#000000");
@ -1226,9 +1226,9 @@ public class CustomThemeWrapper {
customTheme.fabIconColor = Color.parseColor("#000000");
customTheme.chipTextColor = Color.parseColor("#FFFFFF");
customTheme.navBarColor = Color.parseColor("#D48AE0");
customTheme.isLightStatusBar = false;
customTheme.isLightStatusBar = true;
customTheme.isLightNavBar = true;
customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = true;
customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = false;
return customTheme;
}

View File

@ -0,0 +1,4 @@
package ml.docilealligator.infinityforreddit.Event;
public class RefreshMultiRedditsEvent {
}

View File

@ -0,0 +1,70 @@
package ml.docilealligator.infinityforreddit.Fragment;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Activity.EditMultiRedditActivity;
import ml.docilealligator.infinityforreddit.Activity.MultiRedditListingActivity;
import ml.docilealligator.infinityforreddit.MultiReddit.MultiReddit;
import ml.docilealligator.infinityforreddit.R;
/**
* A simple {@link Fragment} subclass.
*/
public class MultiRedditOptionsBottomSheetFragment extends RoundedBottomSheetDialogFragment {
public static final String EXTRA_MULTI_REDDIT = "EMR";
@BindView(R.id.edit_multi_reddit_text_view_multi_reddit_options_bottom_sheet_fragment)
TextView editMultiRedditTextView;
@BindView(R.id.delete_multi_reddit_text_view_multi_reddit_options_bottom_sheet_fragment)
TextView deleteMultiRedditTextView;
private MultiRedditListingActivity multiRedditListingActivity;
public MultiRedditOptionsBottomSheetFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_multi_reddit_options_bottom_sheet, container, false);
ButterKnife.bind(this, rootView);
MultiReddit multiReddit = getArguments().getParcelable(EXTRA_MULTI_REDDIT);
editMultiRedditTextView.setOnClickListener(view -> {
Intent editIntent = new Intent(multiRedditListingActivity, EditMultiRedditActivity.class);
editIntent.putExtra(EditMultiRedditActivity.EXTRA_MULTI_REDDIT, multiReddit);
startActivity(editIntent);
dismiss();
});
deleteMultiRedditTextView.setOnClickListener(view -> {
multiRedditListingActivity.deleteMultiReddit(multiReddit);
dismiss();
});
return rootView;
}
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
multiRedditListingActivity = (MultiRedditListingActivity) context;
}
}

View File

@ -44,6 +44,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:layout_gravity="bottom|end" />
android:layout_gravity="bottom|end"
android:src="@drawable/ic_add_24dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:overScrollMode="never">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/edit_multi_reddit_text_view_multi_reddit_options_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:text="@string/edit_multi_reddit"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:drawableStart="@drawable/ic_edit_24dp"
android:drawablePadding="48dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" />
<TextView
android:id="@+id/delete_multi_reddit_text_view_multi_reddit_options_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:text="@string/delete_multi_reddit"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:drawableStart="@drawable/ic_delete_24dp"
android:drawablePadding="48dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -4,7 +4,7 @@
<item
android:id="@+id/action_preview_customize_theme_activity"
android:orderInCategory="1"
android:title="@string/action_save"
android:title="@string/action_preview"
android:icon="@drawable/ic_preview_24dp"
app:showAsAction="ifRoom" />

View File

@ -56,6 +56,7 @@
<string name="action_edit_multi_reddit">Edit MultiReddit</string>
<string name="action_delete_multi_reddit">Delete Multireddit</string>
<string name="action_share">Share</string>
<string name="action_preview">Preview</string>
<string name="parse_json_response_error">Error occurred when parsing the JSON response</string>
<string name="retrieve_token_error">Error Retrieving the token</string>
@ -683,4 +684,7 @@
<string name="author_flair_preview">Author Flair</string>
<string name="comment_content_preview">I got my girlfriend a “Get better soon” card.\nShe\'s not ill or anything, but she could definitely get better.</string>
<string name="edit_multi_reddit">Edit Multireddit</string>
<string name="delete_multi_reddit">Delete Multireddit</string>
</resources>