Skip to content

Commit

Permalink
Fix codinguser#892 - Adding Accounts to Favorite Tab instantly after …
Browse files Browse the repository at this point in the history
…clicking Favorite Status Button.
  • Loading branch information
RasheeqZaman committed Jun 2, 2021
1 parent 4a97b14 commit 7c7e4f7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,16 @@ public Fragment getItem(int i) {
if (currentFragment == null) {
switch (i) {
case INDEX_RECENT_ACCOUNTS_FRAGMENT:
currentFragment = AccountsListFragment.newInstance(AccountsListFragment.DisplayMode.RECENT);
currentFragment = AccountsListFragment.newInstance(this, AccountsListFragment.DisplayMode.RECENT);
break;

case INDEX_FAVORITE_ACCOUNTS_FRAGMENT:
currentFragment = AccountsListFragment.newInstance(AccountsListFragment.DisplayMode.FAVORITES);
currentFragment = AccountsListFragment.newInstance(this, AccountsListFragment.DisplayMode.FAVORITES);
break;

case INDEX_TOP_LEVEL_ACCOUNTS_FRAGMENT:
default:
currentFragment = AccountsListFragment.newInstance(AccountsListFragment.DisplayMode.TOP_LEVEL);
currentFragment = AccountsListFragment.newInstance(this, AccountsListFragment.DisplayMode.TOP_LEVEL);
break;
}
mFragmentPageReferenceMap.put(i, currentFragment);
Expand Down Expand Up @@ -199,6 +199,11 @@ public CharSequence getPageTitle(int position) {
public int getCount() {
return DEFAULT_NUM_PAGES;
}

@Override
public int getItemPosition(Object object){
return POSITION_NONE;
}
}

public AccountsListFragment getCurrentAccountListFragment(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import android.database.Cursor;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.Loader;
import android.support.v4.view.MenuItemCompat;
Expand Down Expand Up @@ -85,6 +85,7 @@ public class AccountsListFragment extends Fragment implements
AccountRecyclerAdapter mAccountRecyclerAdapter;
@BindView(R.id.account_recycler_view) EmptyRecyclerView mRecyclerView;
@BindView(R.id.empty_view) TextView mEmptyTextView;
private FragmentPagerAdapter accountViewPagerAdapter;

/**
* Describes the kinds of accounts that should be loaded in the accounts list.
Expand Down Expand Up @@ -135,9 +136,10 @@ public enum DisplayMode {
*/
private android.support.v7.widget.SearchView mSearchView;

public static AccountsListFragment newInstance(DisplayMode displayMode){
public static AccountsListFragment newInstance(FragmentPagerAdapter accountViewPagerAdapter, DisplayMode displayMode){
AccountsListFragment fragment = new AccountsListFragment();
fragment.mDisplayMode = displayMode;
fragment.accountViewPagerAdapter = accountViewPagerAdapter;
return fragment;
}

Expand Down Expand Up @@ -557,6 +559,8 @@ public void onClick(View v) {
holder.favoriteStatus.setImageResource(drawableResource);
if (mDisplayMode == DisplayMode.FAVORITES)
refresh();

accountViewPagerAdapter.notifyDataSetChanged();
}
});

Expand Down

0 comments on commit 7c7e4f7

Please sign in to comment.