Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #892 - Favourite Accounts not showing up Dynamically #899

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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