mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 19:27:26 +01:00
The new nav bar is now fully functional. Fix wrong icon color in dark theme.
This commit is contained in:
parent
61cc6089fa
commit
9f87139794
@ -66,6 +66,7 @@ import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
|
|||||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||||
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask;
|
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask;
|
||||||
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
|
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
|
||||||
|
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchToAnonymousAccountAsyncTask;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeConfirmToExitEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeConfirmToExitEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeLockBottomAppBarEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeLockBottomAppBarEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
|
||||||
@ -540,6 +541,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_GILDED);
|
intent.putExtra(AccountPostsActivity.EXTRA_USER_WHERE, PostDataSource.USER_WHERE_GILDED);
|
||||||
break;
|
break;
|
||||||
case R.string.light_theme:
|
case R.string.light_theme:
|
||||||
|
mSharedPreferences.edit().putString(SharedPreferencesUtils.THEME_KEY, "0").apply();
|
||||||
|
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
|
||||||
|
getTheme().applyStyle(R.style.Theme_Default, true);
|
||||||
|
break;
|
||||||
|
case R.string.dark_theme:
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.THEME_KEY, "1").apply();
|
mSharedPreferences.edit().putString(SharedPreferencesUtils.THEME_KEY, "1").apply();
|
||||||
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
|
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
|
||||||
if(mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
|
if(mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
|
||||||
@ -548,13 +554,28 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
getTheme().applyStyle(R.style.Theme_Default_NormalDark, true);
|
getTheme().applyStyle(R.style.Theme_Default_NormalDark, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.string.dark_theme:
|
|
||||||
mSharedPreferences.edit().putString(SharedPreferencesUtils.THEME_KEY, "0").apply();
|
|
||||||
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
|
|
||||||
getTheme().applyStyle(R.style.Theme_Default, true);
|
|
||||||
break;
|
|
||||||
case R.string.settings:
|
case R.string.settings:
|
||||||
intent = new Intent(MainActivity.this, SettingsActivity.class);
|
intent = new Intent(MainActivity.this, SettingsActivity.class);
|
||||||
|
break;
|
||||||
|
case R.string.add_account:
|
||||||
|
Intent addAccountIntent = new Intent(MainActivity.this, LoginActivity.class);
|
||||||
|
startActivityForResult(addAccountIntent, LOGIN_ACTIVITY_REQUEST_CODE);
|
||||||
|
break;
|
||||||
|
case R.string.anonymous_account:
|
||||||
|
new SwitchToAnonymousAccountAsyncTask(mRedditDataRoomDatabase, false,
|
||||||
|
() -> {
|
||||||
|
Intent anonymousIntent = new Intent(MainActivity.this, MainActivity.class);
|
||||||
|
startActivity(anonymousIntent);
|
||||||
|
finish();
|
||||||
|
}).execute();
|
||||||
|
break;
|
||||||
|
case R.string.log_out:
|
||||||
|
new SwitchToAnonymousAccountAsyncTask(mRedditDataRoomDatabase, true,
|
||||||
|
() -> {
|
||||||
|
Intent logOutIntent = new Intent(MainActivity.this, MainActivity.class);
|
||||||
|
startActivity(logOutIntent);
|
||||||
|
finish();
|
||||||
|
}).execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
@ -569,6 +590,15 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, subredditName);
|
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, subredditName);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountClick(String accountName) {
|
||||||
|
new SwitchAccountAsyncTask(mRedditDataRoomDatabase, accountName, newAccount -> {
|
||||||
|
Intent intent = new Intent(MainActivity.this, MainActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}).execute();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
navDrawerRecyclerView.setLayoutManager(new LinearLayoutManager(this));
|
navDrawerRecyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||||
navDrawerRecyclerView.setAdapter(adapter);
|
navDrawerRecyclerView.setAdapter(adapter);
|
||||||
|
@ -39,7 +39,7 @@ public class AccountRecyclerViewAdapter extends RecyclerView.Adapter<AccountRecy
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public AccountViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public AccountViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
return new AccountViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_account, parent, false));
|
return new AccountViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_nav_drawer_account, parent, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -63,21 +63,21 @@ public class AccountRecyclerViewAdapter extends RecyclerView.Adapter<AccountRecy
|
|||||||
});
|
});
|
||||||
} else if (position == mAccounts.size()) {
|
} else if (position == mAccounts.size()) {
|
||||||
holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
|
holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
mGlide.load(R.drawable.ic_outline_add_circle_outline_24px)
|
mGlide.load(R.drawable.ic_outline_add_circle_outline_24dp)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
||||||
.into(holder.profileImageGifImageView);
|
.into(holder.profileImageGifImageView);
|
||||||
holder.usernameTextView.setText(R.string.add_account);
|
holder.usernameTextView.setText(R.string.add_account);
|
||||||
holder.itemView.setOnClickListener(view -> mItemSelectedListener.addAccountSelected());
|
holder.itemView.setOnClickListener(view -> mItemSelectedListener.addAccountSelected());
|
||||||
} else if (position == mAccounts.size() + 1) {
|
} else if (position == mAccounts.size() + 1) {
|
||||||
holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
|
holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
mGlide.load(R.drawable.ic_outline_public_24px)
|
mGlide.load(R.drawable.ic_anonymous_24dp)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
||||||
.into(holder.profileImageGifImageView);
|
.into(holder.profileImageGifImageView);
|
||||||
holder.usernameTextView.setText(R.string.anonymous_account);
|
holder.usernameTextView.setText(R.string.anonymous_account);
|
||||||
holder.itemView.setOnClickListener(view -> mItemSelectedListener.anonymousSelected());
|
holder.itemView.setOnClickListener(view -> mItemSelectedListener.anonymousSelected());
|
||||||
} else {
|
} else {
|
||||||
holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
|
holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
mGlide.load(R.drawable.ic_outline_block_24px)
|
mGlide.load(R.drawable.ic_log_out_24dp)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
||||||
.into(holder.profileImageGifImageView);
|
.into(holder.profileImageGifImageView);
|
||||||
holder.usernameTextView.setText(R.string.log_out);
|
holder.usernameTextView.setText(R.string.log_out);
|
||||||
|
@ -28,9 +28,11 @@ import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.Subscrib
|
|||||||
import pl.droidsonroids.gif.GifImageView;
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
|
|
||||||
public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
public interface ItemClickListener {
|
public interface ItemClickListener {
|
||||||
void onMenuClick(int stringId);
|
void onMenuClick(int stringId);
|
||||||
void onSubscribedSubredditClick(String subredditName);
|
void onSubscribedSubredditClick(String subredditName);
|
||||||
|
void onAccountClick(String accountName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int VIEW_TYPE_NAV_HEADER = 0;
|
private static final int VIEW_TYPE_NAV_HEADER = 0;
|
||||||
@ -38,6 +40,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
|
|||||||
private static final int VIEW_TYPE_MENU_ITEM = 2;
|
private static final int VIEW_TYPE_MENU_ITEM = 2;
|
||||||
private static final int VIEW_TYPE_DIVIDER = 3;
|
private static final int VIEW_TYPE_DIVIDER = 3;
|
||||||
private static final int VIEW_TYPE_SUBSCRIBED_SUBREDDIT = 4;
|
private static final int VIEW_TYPE_SUBSCRIBED_SUBREDDIT = 4;
|
||||||
|
private static final int VIEW_TYPE_ACCOUNT = 5;
|
||||||
private static final int CURRENT_MENU_ITEMS = 15;
|
private static final int CURRENT_MENU_ITEMS = 15;
|
||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
@ -68,6 +71,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemViewType(int position) {
|
public int getItemViewType(int position) {
|
||||||
|
if (isInMainPage) {
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
if (position >= 15) {
|
if (position >= 15) {
|
||||||
return VIEW_TYPE_SUBSCRIBED_SUBREDDIT;
|
return VIEW_TYPE_SUBSCRIBED_SUBREDDIT;
|
||||||
@ -87,6 +91,20 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
|
|||||||
return VIEW_TYPE_MENU_ITEM;
|
return VIEW_TYPE_MENU_ITEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (position == 0) {
|
||||||
|
return VIEW_TYPE_NAV_HEADER;
|
||||||
|
}
|
||||||
|
if (accounts != null) {
|
||||||
|
if (position > accounts.size()) {
|
||||||
|
return VIEW_TYPE_MENU_ITEM;
|
||||||
|
} else {
|
||||||
|
return VIEW_TYPE_ACCOUNT;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return VIEW_TYPE_MENU_ITEM;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -105,6 +123,9 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
|
|||||||
case VIEW_TYPE_DIVIDER:
|
case VIEW_TYPE_DIVIDER:
|
||||||
return new DividerViewHolder(LayoutInflater.from(parent.getContext())
|
return new DividerViewHolder(LayoutInflater.from(parent.getContext())
|
||||||
.inflate(R.layout.item_nav_drawer_divider, parent, false));
|
.inflate(R.layout.item_nav_drawer_divider, parent, false));
|
||||||
|
case VIEW_TYPE_ACCOUNT:
|
||||||
|
return new AccountViewHolder(LayoutInflater.from(parent.getContext())
|
||||||
|
.inflate(R.layout.item_nav_drawer_account, parent, false));
|
||||||
default:
|
default:
|
||||||
return new SubscribedThingViewHolder(LayoutInflater.from(parent.getContext())
|
return new SubscribedThingViewHolder(LayoutInflater.from(parent.getContext())
|
||||||
.inflate(R.layout.item_nav_drawer_subscribed_thing, parent, false));
|
.inflate(R.layout.item_nav_drawer_subscribed_thing, parent, false));
|
||||||
@ -135,6 +156,9 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
|
|||||||
} else {
|
} else {
|
||||||
((NavHeaderViewHolder) holder).karmaTextView.setText(R.string.press_here_to_login);
|
((NavHeaderViewHolder) holder).karmaTextView.setText(R.string.press_here_to_login);
|
||||||
((NavHeaderViewHolder) holder).accountNameTextView.setText(R.string.anonymous_account);
|
((NavHeaderViewHolder) holder).accountNameTextView.setText(R.string.anonymous_account);
|
||||||
|
glide.load(R.drawable.subreddit_default_icon)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(144, 0)))
|
||||||
|
.into(((NavHeaderViewHolder) holder).profileImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isInMainPage) {
|
if (isInMainPage) {
|
||||||
@ -145,11 +169,31 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
|
|||||||
|
|
||||||
((NavHeaderViewHolder) holder).itemView.setOnClickListener(view -> {
|
((NavHeaderViewHolder) holder).itemView.setOnClickListener(view -> {
|
||||||
if (isInMainPage) {
|
if (isInMainPage) {
|
||||||
isInMainPage = false;
|
|
||||||
((NavHeaderViewHolder) holder).dropIconImageView.setImageDrawable(resources.getDrawable(R.drawable.ic_baseline_arrow_drop_up_24px));
|
((NavHeaderViewHolder) holder).dropIconImageView.setImageDrawable(resources.getDrawable(R.drawable.ic_baseline_arrow_drop_up_24px));
|
||||||
|
notifyItemRangeRemoved(1, getItemCount() - 1);
|
||||||
|
if (accounts != null) {
|
||||||
|
notifyItemRangeInserted(1, accounts.size() + 3);
|
||||||
|
} else {
|
||||||
|
if (isLoggedIn) {
|
||||||
|
notifyItemRangeInserted(1, 3);
|
||||||
|
} else {
|
||||||
|
notifyItemInserted(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isInMainPage = false;
|
||||||
} else {
|
} else {
|
||||||
isInMainPage = true;
|
|
||||||
((NavHeaderViewHolder) holder).dropIconImageView.setImageDrawable(resources.getDrawable(R.drawable.ic_baseline_arrow_drop_down_24px));
|
((NavHeaderViewHolder) holder).dropIconImageView.setImageDrawable(resources.getDrawable(R.drawable.ic_baseline_arrow_drop_down_24px));
|
||||||
|
notifyItemRangeRemoved(1, getItemCount() - 1);
|
||||||
|
if (isLoggedIn) {
|
||||||
|
if (subscribedSubreddits != null) {
|
||||||
|
notifyItemRangeInserted(1, subscribedSubreddits.size() + CURRENT_MENU_ITEMS - 1);
|
||||||
|
} else {
|
||||||
|
notifyItemRangeInserted(1, CURRENT_MENU_ITEMS - 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
notifyItemRangeInserted(1, 2);
|
||||||
|
}
|
||||||
|
isInMainPage = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (holder instanceof MenuGroupTitleViewHolder) {
|
} else if (holder instanceof MenuGroupTitleViewHolder) {
|
||||||
@ -162,6 +206,8 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
|
|||||||
int stringId = 0;
|
int stringId = 0;
|
||||||
int drawableId = 0;
|
int drawableId = 0;
|
||||||
|
|
||||||
|
if (isInMainPage) {
|
||||||
|
if (isLoggedIn) {
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 2:
|
case 2:
|
||||||
stringId = R.string.profile;
|
stringId = R.string.profile;
|
||||||
@ -211,14 +257,49 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
|
|||||||
case 14:
|
case 14:
|
||||||
stringId = R.string.settings;
|
stringId = R.string.settings;
|
||||||
drawableId = R.drawable.ic_settings_24dp;
|
drawableId = R.drawable.ic_settings_24dp;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch (position) {
|
||||||
|
case 1:
|
||||||
|
if ((resources.getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
|
||||||
|
stringId = R.string.dark_theme;
|
||||||
|
drawableId = R.drawable.ic_dark_theme_24dp;
|
||||||
|
} else {
|
||||||
|
stringId = R.string.light_theme;
|
||||||
|
drawableId = R.drawable.ic_light_theme_24dp;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
stringId = R.string.settings;
|
||||||
|
drawableId = R.drawable.ic_settings_24dp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isLoggedIn) {
|
||||||
|
int offset = accounts == null ? 0 : accounts.size();
|
||||||
|
if (position == offset + 1) {
|
||||||
|
stringId = R.string.add_account;
|
||||||
|
drawableId = R.drawable.ic_outline_add_circle_outline_24dp;
|
||||||
|
} else if (position == offset + 2) {
|
||||||
|
stringId = R.string.anonymous_account;
|
||||||
|
drawableId = R.drawable.ic_anonymous_24dp;
|
||||||
|
} else if (position == offset + 3) {
|
||||||
|
stringId = R.string.log_out;
|
||||||
|
drawableId = R.drawable.ic_log_out_24dp;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
stringId = R.string.add_account;
|
||||||
|
drawableId = R.drawable.ic_outline_add_circle_outline_24dp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stringId != 0) {
|
||||||
((MenuItemViewHolder) holder).menuTextView.setText(stringId);
|
((MenuItemViewHolder) holder).menuTextView.setText(stringId);
|
||||||
((MenuItemViewHolder) holder).menuTextView.setCompoundDrawablesWithIntrinsicBounds(
|
((MenuItemViewHolder) holder).menuTextView.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
drawableId, 0, 0, 0);
|
drawableId, 0, 0, 0);
|
||||||
int finalStringId = stringId;
|
int finalStringId = stringId;
|
||||||
((MenuItemViewHolder) holder).itemView.setOnClickListener(view -> itemClickListener.onMenuClick(finalStringId));
|
((MenuItemViewHolder) holder).itemView.setOnClickListener(view -> itemClickListener.onMenuClick(finalStringId));
|
||||||
|
}
|
||||||
} else if (holder instanceof SubscribedThingViewHolder) {
|
} else if (holder instanceof SubscribedThingViewHolder) {
|
||||||
SubscribedSubredditData subreddit = subscribedSubreddits.get(position - CURRENT_MENU_ITEMS);
|
SubscribedSubredditData subreddit = subscribedSubreddits.get(position - CURRENT_MENU_ITEMS);
|
||||||
String subredditName = subreddit.getName();
|
String subredditName = subreddit.getName();
|
||||||
@ -239,16 +320,43 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
|
|||||||
((SubscribedThingViewHolder) holder).itemView.setOnClickListener(view -> {
|
((SubscribedThingViewHolder) holder).itemView.setOnClickListener(view -> {
|
||||||
itemClickListener.onSubscribedSubredditClick(subredditName);
|
itemClickListener.onSubscribedSubredditClick(subredditName);
|
||||||
});
|
});
|
||||||
|
} else if (holder instanceof AccountViewHolder) {
|
||||||
|
glide.load(accounts.get(position - 1).getProfileImageUrl())
|
||||||
|
.error(glide.load(R.drawable.subreddit_default_icon))
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
||||||
|
.into(((AccountViewHolder) holder).profileImageGifImageView);
|
||||||
|
((AccountViewHolder) holder).usernameTextView.setText(accounts.get(position - 1).getUsername());
|
||||||
|
((AccountViewHolder) holder).itemView.setOnClickListener(view ->
|
||||||
|
itemClickListener.onAccountClick(accounts.get(position - 1).getUsername()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
|
if (isInMainPage) {
|
||||||
|
if (isLoggedIn) {
|
||||||
if (subscribedSubreddits != null) {
|
if (subscribedSubreddits != null) {
|
||||||
return CURRENT_MENU_ITEMS + subscribedSubreddits.size();
|
return CURRENT_MENU_ITEMS + subscribedSubreddits.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
return CURRENT_MENU_ITEMS;
|
return CURRENT_MENU_ITEMS;
|
||||||
|
} else {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isLoggedIn) {
|
||||||
|
if (accounts != null && !accounts.isEmpty()) {
|
||||||
|
return 4 + accounts.size();
|
||||||
|
} else {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (accounts != null && !accounts.isEmpty()) {
|
||||||
|
return 2 + accounts.size();
|
||||||
|
} else {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubscribedSubreddits(List<SubscribedSubredditData> subscribedSubreddits) {
|
public void setSubscribedSubreddits(List<SubscribedSubredditData> subscribedSubreddits) {
|
||||||
@ -315,4 +423,16 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
|
|||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AccountViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
@BindView(R.id.profile_image_item_account)
|
||||||
|
GifImageView profileImageGifImageView;
|
||||||
|
@BindView(R.id.username_text_view_item_account)
|
||||||
|
TextView usernameTextView;
|
||||||
|
|
||||||
|
AccountViewHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
ButterKnife.bind(this, itemView);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Fragment;
|
|||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
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;
|
||||||
@ -78,8 +79,6 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
|
|||||||
|
|
||||||
ButterKnife.bind(this, rootView);
|
ButterKnife.bind(this, rootView);
|
||||||
|
|
||||||
mActivity = getActivity();
|
|
||||||
|
|
||||||
((Infinity) mActivity.getApplication()).getAppComponent().inject(this);
|
((Infinity) mActivity.getApplication()).getAppComponent().inject(this);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||||
@ -153,6 +152,12 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
|
|||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(@NonNull Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
mActivity = (Activity) context;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopRefreshProgressbar() {
|
public void stopRefreshProgressbar() {
|
||||||
mSwipeRefreshLayout.setRefreshing(false);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
|
9
app/src/main/res/drawable-night/ic_anonymous_24dp.xml
Normal file
9
app/src/main/res/drawable-night/ic_anonymous_24dp.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM4,12c0,-0.61 0.08,-1.21 0.21,-1.78L8.99,15v1c0,1.1 0.9,2 2,2v1.93C7.06,19.43 4,16.07 4,12zM17.89,17.4c-0.26,-0.81 -1,-1.4 -1.9,-1.4h-1v-3c0,-0.55 -0.45,-1 -1,-1h-6v-2h2c0.55,0 1,-0.45 1,-1L10.99,7h2c1.1,0 2,-0.9 2,-2v-0.41C17.92,5.77 20,8.65 20,12c0,2.08 -0.81,3.98 -2.11,5.4z"/>
|
||||||
|
</vector>
|
9
app/src/main/res/drawable-night/ic_log_out_24dp.xml
Normal file
9
app/src/main/res/drawable-night/ic_log_out_24dp.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM4,12c0,-4.42 3.58,-8 8,-8 1.85,0 3.55,0.63 4.9,1.69L5.69,16.9C4.63,15.55 4,13.85 4,12zM12,20c-1.85,0 -3.55,-0.63 -4.9,-1.69L18.31,7.1C19.37,8.45 20,10.15 20,12c0,4.42 -3.58,8 -8,8z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:pathData="M13,7h-2v4L7,11v2h4v4h2v-4h4v-2h-4L13,7zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"/>
|
||||||
|
</vector>
|
Loading…
Reference in New Issue
Block a user