Lazy mode is available in AccountPostsActivity. Minor bugs fixed.

This commit is contained in:
Alex Ning 2019-08-16 09:37:23 +08:00
parent 054c5228d7
commit 627bad649b
9 changed files with 68 additions and 49 deletions

View File

@ -17,6 +17,7 @@ import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import javax.inject.Inject; import javax.inject.Inject;
@ -27,14 +28,17 @@ public class AccountPostsActivity extends AppCompatActivity implements UserThing
static final String EXTRA_USER_WHERE = "EUW"; static final String EXTRA_USER_WHERE = "EUW";
private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
private static final String NULL_ACCESS_TOKEN_STATE = "NATS"; private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
private static final String ACCESS_TOKEN_STATE = "ATS"; private static final String ACCESS_TOKEN_STATE = "ATS";
private static final String ACCOUNT_NAME_STATE = "ANS"; private static final String ACCOUNT_NAME_STATE = "ANS";
private static final String FRAGMENT_OUT_STATE = "FOS"; private static final String FRAGMENT_OUT_STATE = "FOS";
@BindView(R.id.collapsing_toolbar_layout_account_posts_activity) CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.appbar_layout_account_posts_activity) AppBarLayout appBarLayout; @BindView(R.id.appbar_layout_account_posts_activity) AppBarLayout appBarLayout;
@BindView(R.id.toolbar_account_posts_activity) Toolbar toolbar; @BindView(R.id.toolbar_account_posts_activity) Toolbar toolbar;
private boolean isInLazyMode = false;
private boolean mNullAccessToken = false; private boolean mNullAccessToken = false;
private String mAccessToken; private String mAccessToken;
private String mAccountName; private String mAccountName;
@ -42,6 +46,7 @@ public class AccountPostsActivity extends AppCompatActivity implements UserThing
private Fragment mFragment; private Fragment mFragment;
private Menu mMenu; private Menu mMenu;
private AppBarLayout.LayoutParams params;
private UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment; private UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment;
@ -117,25 +122,27 @@ public class AccountPostsActivity extends AppCompatActivity implements UserThing
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
if(savedInstanceState != null) { if(savedInstanceState != null) {
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE); mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE); mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE); mAccountName = savedInstanceState.getString(ACCOUNT_NAME_STATE);
isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
if(!mNullAccessToken && mAccessToken == null) { if(!mNullAccessToken && mAccessToken == null) {
getCurrentAccountAndBindView(); getCurrentAccountAndInitializeFragment();
} else { } else {
mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE); mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE);
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_account_posts_activity, mFragment).commit(); getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_account_posts_activity, mFragment).commit();
initializeFragment();
} }
} else { } else {
getCurrentAccountAndBindView(); getCurrentAccountAndInitializeFragment();
} }
userThingSortTypeBottomSheetFragment = new UserThingSortTypeBottomSheetFragment(); userThingSortTypeBottomSheetFragment = new UserThingSortTypeBottomSheetFragment();
} }
private void getCurrentAccountAndBindView() { private void getCurrentAccountAndInitializeFragment() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if(account == null) { if(account == null) {
mNullAccessToken = true; mNullAccessToken = true;
@ -167,6 +174,16 @@ public class AccountPostsActivity extends AppCompatActivity implements UserThing
if(mUserWhere != null && mUserWhere.equals(PostDataSource.USER_WHERE_GILDED)) { if(mUserWhere != null && mUserWhere.equals(PostDataSource.USER_WHERE_GILDED)) {
menu.findItem(R.id.action_sort_account_posts_activity).setVisible(true); menu.findItem(R.id.action_sort_account_posts_activity).setVisible(true);
} }
MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_account_posts_activity);
if(isInLazyMode) {
lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
collapsingToolbarLayout.setLayoutParams(params);
} else {
lazyModeItem.setTitle(R.string.action_start_lazy_mode);
params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
collapsingToolbarLayout.setLayoutParams(params);
}
return true; return true;
} }
@ -182,6 +199,20 @@ public class AccountPostsActivity extends AppCompatActivity implements UserThing
} }
return true; return true;
case R.id.action_lazy_mode_account_posts_activity: case R.id.action_lazy_mode_account_posts_activity:
MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_account_posts_activity);
if(isInLazyMode) {
((FragmentCommunicator) mFragment).stopLazyMode();
isInLazyMode = false;
lazyModeItem.setTitle(R.string.action_start_lazy_mode);
params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
collapsingToolbarLayout.setLayoutParams(params);
} else {
((FragmentCommunicator) mFragment).startLazyMode();
isInLazyMode = true;
lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
collapsingToolbarLayout.setLayoutParams(params);
}
return true; return true;
case android.R.id.home: case android.R.id.home:
finish(); finish();
@ -196,6 +227,7 @@ public class AccountPostsActivity extends AppCompatActivity implements UserThing
if (mFragment != null) { if (mFragment != null) {
getSupportFragmentManager().putFragment(outState, FRAGMENT_OUT_STATE, mFragment); getSupportFragmentManager().putFragment(outState, FRAGMENT_OUT_STATE, mFragment);
} }
outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
outState.putString(ACCESS_TOKEN_STATE, mAccessToken); outState.putString(ACCESS_TOKEN_STATE, mAccessToken);
outState.putString(ACCOUNT_NAME_STATE, mAccountName); outState.putString(ACCOUNT_NAME_STATE, mAccountName);
outState.putBoolean(NULL_ACCESS_TOKEN_STATE, mNullAccessToken); outState.putBoolean(NULL_ACCESS_TOKEN_STATE, mNullAccessToken);

View File

@ -13,7 +13,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProviders; import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -79,7 +79,7 @@ public class FollowedUsersListingFragment extends Fragment {
FollowedUsersRecyclerViewAdapter adapter = new FollowedUsersRecyclerViewAdapter(mActivity); FollowedUsersRecyclerViewAdapter adapter = new FollowedUsersRecyclerViewAdapter(mActivity);
mRecyclerView.setAdapter(adapter); mRecyclerView.setAdapter(adapter);
mSubscribedUserViewModel = ViewModelProviders.of(this, mSubscribedUserViewModel = new ViewModelProvider(this,
new SubscribedUserViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, getArguments().getString(EXTRA_ACCOUNT_NAME))) new SubscribedUserViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, getArguments().getString(EXTRA_ACCOUNT_NAME)))
.get(SubscribedUserViewModel.class); .get(SubscribedUserViewModel.class);
mSubscribedUserViewModel.getAllSubscribedUsers().observe(this, subscribedUserData -> { mSubscribedUserViewModel.getAllSubscribedUsers().observe(this, subscribedUserData -> {

View File

@ -26,7 +26,7 @@ import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter; import androidx.fragment.app.FragmentPagerAdapter;
import androidx.lifecycle.ViewModelProviders; 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.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
@ -313,7 +313,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
accountRecyclerView.setNestedScrollingEnabled(false); accountRecyclerView.setNestedScrollingEnabled(false);
accountRecyclerView.setAdapter(adapter); accountRecyclerView.setAdapter(adapter);
accountViewModel = ViewModelProviders.of(this, accountViewModel = new ViewModelProvider(this,
new AccountViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName)).get(AccountViewModel.class); new AccountViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName)).get(AccountViewModel.class);
accountViewModel.getAccountsExceptCurrentAccountLiveData().observe(this, adapter::changeAccountsDataset); accountViewModel.getAccountsExceptCurrentAccountLiveData().observe(this, adapter::changeAccountsDataset);

View File

@ -17,7 +17,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull; 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.ViewModelProviders; import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -124,7 +124,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
SubredditListingViewModel.Factory factory = new SubredditListingViewModel.Factory(mRetrofit, query, SubredditListingViewModel.Factory factory = new SubredditListingViewModel.Factory(mRetrofit, query,
PostDataSource.SORT_TYPE_RELEVANCE); PostDataSource.SORT_TYPE_RELEVANCE);
mSubredditListingViewModel = ViewModelProviders.of(this, factory).get(SubredditListingViewModel.class); mSubredditListingViewModel = new ViewModelProvider(this, factory).get(SubredditListingViewModel.class);
mSubredditListingViewModel.getSubreddits().observe(this, subredditData -> mAdapter.submitList(subredditData)); mSubredditListingViewModel.getSubreddits().observe(this, subredditData -> mAdapter.submitList(subredditData));
mSubredditListingViewModel.getInitialLoadingState().observe(this, networkState -> { mSubredditListingViewModel.getInitialLoadingState().observe(this, networkState -> {

View File

@ -14,7 +14,7 @@ import android.widget.LinearLayout;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProviders; import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -93,7 +93,7 @@ public class SubscribedSubredditsListingFragment extends Fragment {
mRecyclerView.setAdapter(adapter); mRecyclerView.setAdapter(adapter);
mSubscribedSubredditViewModel = ViewModelProviders.of(this, mSubscribedSubredditViewModel = new ViewModelProvider(this,
new SubscribedSubredditViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, accountName)) new SubscribedSubredditViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, accountName))
.get(SubscribedSubredditViewModel.class); .get(SubscribedSubredditViewModel.class);
mSubscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this, subscribedSubredditData -> { mSubscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this, subscribedSubredditData -> {

View File

@ -14,7 +14,7 @@ import android.widget.TextView;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProviders; import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -103,7 +103,7 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
UserListingViewModel.Factory factory = new UserListingViewModel.Factory(mRetrofit, mQuery, UserListingViewModel.Factory factory = new UserListingViewModel.Factory(mRetrofit, mQuery,
PostDataSource.SORT_TYPE_RELEVANCE); PostDataSource.SORT_TYPE_RELEVANCE);
mUserListingViewModel = ViewModelProviders.of(this, factory).get(UserListingViewModel.class); mUserListingViewModel = new ViewModelProvider(this, factory).get(UserListingViewModel.class);
mUserListingViewModel.getUsers().observe(this, UserData -> mAdapter.submitList(UserData)); mUserListingViewModel.getUsers().observe(this, UserData -> mAdapter.submitList(UserData));
mUserListingViewModel.getInitialLoadingState().observe(this, networkState -> { mUserListingViewModel.getInitialLoadingState().observe(this, networkState -> {

View File

@ -20,7 +20,7 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProviders; import androidx.lifecycle.ViewModelProvider;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager; import com.bumptech.glide.RequestManager;
@ -135,13 +135,6 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
} }
}); });
int statusBarResourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (statusBarResourceId > 0) {
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
params.topMargin = getResources().getDimensionPixelSize(statusBarResourceId);
toolbar.setLayoutParams(params);
}
int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (navBarResourceId > 0) { if (navBarResourceId > 0) {
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
@ -195,14 +188,14 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
subredditNameTextView.setText(title); subredditNameTextView.setText(title);
toolbar.setTitle(title); toolbar.setTitle(title);
ViewGroup.MarginLayoutParams toolbarParams = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
toolbarParams.topMargin = statusBarHeight;
toolbar.setLayoutParams(toolbarParams);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
params.topMargin = statusBarHeight;
glide = Glide.with(this); glide = Glide.with(this);
mSubredditViewModel = ViewModelProviders.of(this, mSubredditViewModel = new ViewModelProvider(this,
new SubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, subredditName)) new SubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, subredditName))
.get(SubredditViewModel.class); .get(SubredditViewModel.class);
mSubredditViewModel.getSubredditLiveData().observe(this, subredditData -> { mSubredditViewModel.getSubredditLiveData().observe(this, subredditData -> {

View File

@ -22,7 +22,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter; import androidx.fragment.app.FragmentPagerAdapter;
import androidx.lifecycle.ViewModelProviders; import androidx.lifecycle.ViewModelProvider;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
@ -145,15 +145,16 @@ public class ViewUserDetailActivity extends AppCompatActivity implements UserThi
statusBarHeight = resources.getDimensionPixelSize(resourceId); statusBarHeight = resources.getDimensionPixelSize(resourceId);
} }
String title = "u/" + username;
userNameTextView.setText(title);
Toolbar toolbar = findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setTitle(title);
setSupportActionBar(toolbar);
ViewGroup.MarginLayoutParams toolbarLayoutParams = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); ViewGroup.MarginLayoutParams toolbarLayoutParams = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
toolbarLayoutParams.topMargin = statusBarHeight; toolbarLayoutParams.topMargin = statusBarHeight;
toolbar.setLayoutParams(toolbarLayoutParams);
String title = "u/" + username;
userNameTextView.setText(title);
toolbar.setTitle(title);
setSupportActionBar(toolbar);
expandedTabTextColor = resources.getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTextColor); expandedTabTextColor = resources.getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTextColor);
expandedTabBackgroundColor = resources.getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTabBackground); expandedTabBackgroundColor = resources.getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTabBackground);
@ -197,15 +198,7 @@ public class ViewUserDetailActivity extends AppCompatActivity implements UserThi
} }
}); });
int statusBarResourceId = resources.getIdentifier("status_bar_height", "dimen", "android"); showToast = true;
if (statusBarResourceId > 0) {
int navBarHeight = resources.getDimensionPixelSize(statusBarResourceId);
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
params.topMargin = navBarHeight;
toolbar.setLayoutParams(params);
showToast = true;
}
} else { } else {
appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() { appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() {
@Override @Override
@ -226,7 +219,7 @@ public class ViewUserDetailActivity extends AppCompatActivity implements UserThi
subscribedUserDao = mRedditDataRoomDatabase.subscribedUserDao(); subscribedUserDao = mRedditDataRoomDatabase.subscribedUserDao();
glide = Glide.with(this); glide = Glide.with(this);
userViewModel = ViewModelProviders.of(this, new UserViewModel.Factory(getApplication(), mRedditDataRoomDatabase, username)) userViewModel = new ViewModelProvider(this, new UserViewModel.Factory(getApplication(), mRedditDataRoomDatabase, username))
.get(UserViewModel.class); .get(UserViewModel.class);
userViewModel.getUserLiveData().observe(this, userData -> { userViewModel.getUserLiveData().observe(this, userData -> {
if (userData != null) { if (userData != null) {
@ -280,13 +273,13 @@ public class ViewUserDetailActivity extends AppCompatActivity implements UserThi
public void onUserFollowingSuccess() { public void onUserFollowingSuccess() {
subscribeUserChip.setText(R.string.unfollow); subscribeUserChip.setText(R.string.unfollow);
subscribeUserChip.setChipBackgroundColor(resources.getColorStateList(R.color.colorAccent)); subscribeUserChip.setChipBackgroundColor(resources.getColorStateList(R.color.colorAccent));
makeSnackbar(R.string.followed, false); showMessage(R.string.followed, false);
subscriptionReady = true; subscriptionReady = true;
} }
@Override @Override
public void onUserFollowingFail() { public void onUserFollowingFail() {
makeSnackbar(R.string.follow_failed, false); showMessage(R.string.follow_failed, false);
subscriptionReady = true; subscriptionReady = true;
} }
}); });
@ -297,13 +290,13 @@ public class ViewUserDetailActivity extends AppCompatActivity implements UserThi
public void onUserFollowingSuccess() { public void onUserFollowingSuccess() {
subscribeUserChip.setText(R.string.follow); subscribeUserChip.setText(R.string.follow);
subscribeUserChip.setChipBackgroundColor(resources.getColorStateList(R.color.backgroundColorPrimaryDark)); subscribeUserChip.setChipBackgroundColor(resources.getColorStateList(R.color.backgroundColorPrimaryDark));
makeSnackbar(R.string.unfollowed, false); showMessage(R.string.unfollowed, false);
subscriptionReady = true; subscriptionReady = true;
} }
@Override @Override
public void onUserFollowingFail() { public void onUserFollowingFail() {
makeSnackbar(R.string.unfollow_failed, false); showMessage(R.string.unfollow_failed, false);
subscriptionReady = true; subscriptionReady = true;
} }
}); });
@ -396,7 +389,7 @@ public class ViewUserDetailActivity extends AppCompatActivity implements UserThi
@Override @Override
public void onFetchUserDataFailed() { public void onFetchUserDataFailed() {
makeSnackbar(R.string.cannot_fetch_user_info, true); showMessage(R.string.cannot_fetch_user_info, true);
mFetchUserInfoSuccess = false; mFetchUserInfoSuccess = false;
} }
}); });
@ -493,7 +486,7 @@ public class ViewUserDetailActivity extends AppCompatActivity implements UserThi
outState.putString(ACCOUNT_NAME_STATE, mAccountName); outState.putString(ACCOUNT_NAME_STATE, mAccountName);
} }
private void makeSnackbar(int resId, boolean retry) { private void showMessage(int resId, boolean retry) {
if(showToast) { if(showToast) {
Toast.makeText(this, resId, Toast.LENGTH_SHORT).show(); Toast.makeText(this, resId, Toast.LENGTH_SHORT).show();
} else { } else {

View File

@ -13,6 +13,7 @@
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout <com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar_layout_account_posts_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways" app:layout_scrollFlags="scroll|enterAlways"