Blocking and muting now removes all statuses by that user in EVERY currently-loaded timeline.

This commit is contained in:
Vavassor 2017-04-21 23:16:05 -04:00
parent fcebbc2bdb
commit 5179d7e9b3
10 changed files with 137 additions and 71 deletions

View File

@ -28,6 +28,7 @@ import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
import android.support.design.widget.TabLayout; import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
@ -54,7 +55,7 @@ import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
public class AccountActivity extends BaseActivity { public class AccountActivity extends BaseActivity implements SFragment.OnUserRemovedListener {
private static final String TAG = "AccountActivity"; // logging tag private static final String TAG = "AccountActivity"; // logging tag
private String accountId; private String accountId;
@ -63,6 +64,7 @@ public class AccountActivity extends BaseActivity {
private boolean muting = false; private boolean muting = false;
private boolean isSelf; private boolean isSelf;
private TabLayout tabLayout; private TabLayout tabLayout;
private AccountPagerAdapter pagerAdapter;
private Account loadedAccount; private Account loadedAccount;
@BindView(R.id.account_locked) ImageView accountLockedView; @BindView(R.id.account_locked) ImageView accountLockedView;
@ -80,8 +82,7 @@ public class AccountActivity extends BaseActivity {
accountId = intent.getStringExtra("id"); accountId = intent.getStringExtra("id");
} }
SharedPreferences preferences = getSharedPreferences( SharedPreferences preferences = getPrivatePreferences();
getString(R.string.preferences_file_key), Context.MODE_PRIVATE);
String loggedInAccountId = preferences.getString("loggedInAccountId", null); String loggedInAccountId = preferences.getString("loggedInAccountId", null);
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
@ -142,6 +143,7 @@ public class AccountActivity extends BaseActivity {
// Setup the tabs and timeline pager. // Setup the tabs and timeline pager.
AccountPagerAdapter adapter = new AccountPagerAdapter(getSupportFragmentManager(), this, AccountPagerAdapter adapter = new AccountPagerAdapter(getSupportFragmentManager(), this,
accountId); accountId);
pagerAdapter = adapter;
String[] pageTitles = { String[] pageTitles = {
getString(R.string.title_statuses), getString(R.string.title_statuses),
getString(R.string.title_follows), getString(R.string.title_follows),
@ -165,6 +167,12 @@ public class AccountActivity extends BaseActivity {
} }
} }
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putString("accountId", accountId);
super.onSaveInstanceState(outState);
}
private void obtainAccount() { private void obtainAccount() {
mastodonAPI.account(accountId).enqueue(new Callback<Account>() { mastodonAPI.account(accountId).enqueue(new Callback<Account>() {
@Override @Override
@ -183,12 +191,6 @@ public class AccountActivity extends BaseActivity {
}); });
} }
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putString("accountId", accountId);
super.onSaveInstanceState(outState);
}
private void onObtainAccountSuccess(Account account) { private void onObtainAccountSuccess(Account account) {
loadedAccount = account; loadedAccount = account;
@ -289,6 +291,16 @@ public class AccountActivity extends BaseActivity {
updateButtons(); updateButtons();
} }
@Override
public void onUserRemoved(String accountId) {
for (Fragment fragment : pagerAdapter.getRegisteredFragments()) {
if (fragment instanceof StatusRemoveListener) {
StatusRemoveListener listener = (StatusRemoveListener) fragment;
listener.removePostsByUser(accountId);
}
}
}
private void updateFollowButton(FloatingActionButton button) { private void updateFollowButton(FloatingActionButton button) {
if (following) { if (following) {
button.setImageResource(R.drawable.ic_person_minus_24px); button.setImageResource(R.drawable.ic_person_minus_24px);

View File

@ -24,15 +24,20 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
class AccountPagerAdapter extends FragmentPagerAdapter { class AccountPagerAdapter extends FragmentPagerAdapter {
private Context context; private Context context;
private String accountId; private String accountId;
private String[] pageTitles; private String[] pageTitles;
private List<Fragment> registeredFragments;
AccountPagerAdapter(FragmentManager manager, Context context, String accountId) { AccountPagerAdapter(FragmentManager manager, Context context, String accountId) {
super(manager); super(manager);
this.context = context; this.context = context;
this.accountId = accountId; this.accountId = accountId;
registeredFragments = new ArrayList<>();
} }
void setPageTitles(String[] titles) { void setPageTitles(String[] titles) {
@ -73,4 +78,21 @@ class AccountPagerAdapter extends FragmentPagerAdapter {
title.setText(pageTitles[position]); title.setText(pageTitles[position]);
return view; return view;
} }
@Override
public Object instantiateItem(ViewGroup container, int position) {
Fragment fragment = (Fragment) super.instantiateItem(container, position);
registeredFragments.add(fragment);
return fragment;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
registeredFragments.remove((Fragment) object);
super.destroyItem(container, position, object);
}
List<Fragment> getRegisteredFragments() {
return registeredFragments;
}
} }

View File

@ -17,5 +17,4 @@ package com.keylesspalace.tusky;
interface AdapterItemRemover { interface AdapterItemRemover {
void removeItem(int position); void removeItem(int position);
void removeAllByAccountId(String accountId);
} }

View File

@ -20,7 +20,6 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.PersistableBundle; import android.os.PersistableBundle;
@ -43,12 +42,10 @@ import com.arlib.floatingsearchview.suggestions.SearchSuggestionsAdapter;
import com.arlib.floatingsearchview.suggestions.model.SearchSuggestion; import com.arlib.floatingsearchview.suggestions.model.SearchSuggestion;
import com.keylesspalace.tusky.entity.Account; import com.keylesspalace.tusky.entity.Account;
import com.mikepenz.google_material_typeface_library.GoogleMaterial; import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.typeface.GenericFont;
import com.mikepenz.materialdrawer.AccountHeader; import com.mikepenz.materialdrawer.AccountHeader;
import com.mikepenz.materialdrawer.AccountHeaderBuilder; import com.mikepenz.materialdrawer.AccountHeaderBuilder;
import com.mikepenz.materialdrawer.Drawer; import com.mikepenz.materialdrawer.Drawer;
import com.mikepenz.materialdrawer.DrawerBuilder; import com.mikepenz.materialdrawer.DrawerBuilder;
import com.mikepenz.materialdrawer.icons.MaterialDrawerFont;
import com.mikepenz.materialdrawer.model.DividerDrawerItem; import com.mikepenz.materialdrawer.model.DividerDrawerItem;
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; import com.mikepenz.materialdrawer.model.ProfileDrawerItem;
@ -69,8 +66,8 @@ import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
public class MainActivity extends BaseActivity { public class MainActivity extends BaseActivity implements SFragment.OnUserRemovedListener {
private static final String TAG = "MainActivity"; // logging tag and Volley request tag private static final String TAG = "MainActivity"; // logging tag
protected static int COMPOSE_RESULT = 1; protected static int COMPOSE_RESULT = 1;
private String loggedInAccountId; private String loggedInAccountId;
@ -518,12 +515,22 @@ public class MainActivity extends BaseActivity {
} }
@Override @Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults); super.onRequestPermissionsResult(requestCode, permissions, grantResults);
List<Fragment> fragments = getSupportFragmentManager().getFragments(); TimelinePagerAdapter adapter = (TimelinePagerAdapter) viewPager.getAdapter();
if (fragments != null) { for (Fragment fragment : adapter.getRegisteredFragments()) {
for (Fragment fragment : fragments) { fragment.onRequestPermissionsResult(requestCode, permissions, grantResults);
fragment.onRequestPermissionsResult(requestCode, permissions, grantResults); }
}
@Override
public void onUserRemoved(String accountId) {
TimelinePagerAdapter adapter = (TimelinePagerAdapter) viewPager.getAdapter();
for (Fragment fragment : adapter.getRegisteredFragments()) {
if (fragment instanceof StatusRemoveListener) {
StatusRemoveListener listener = (StatusRemoveListener) fragment;
listener.removePostsByUser(accountId);
} }
} }
} }

View File

@ -39,7 +39,7 @@ import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
public class NotificationsFragment extends SFragment implements public class NotificationsFragment extends SFragment implements
SwipeRefreshLayout.OnRefreshListener, StatusActionListener, SwipeRefreshLayout.OnRefreshListener, StatusActionListener, StatusRemoveListener,
NotificationsAdapter.NotificationActionListener { NotificationsAdapter.NotificationActionListener {
private static final String TAG = "Notifications"; // logging tag private static final String TAG = "Notifications"; // logging tag
@ -57,11 +57,6 @@ public class NotificationsFragment extends SFragment implements
return fragment; return fragment;
} }
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@ -117,12 +112,6 @@ public class NotificationsFragment extends SFragment implements
return rootView; return rootView;
} }
@Override
public void onResume() {
super.onResume();
sendFetchNotificationsRequest();
}
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
@ -142,13 +131,11 @@ public class NotificationsFragment extends SFragment implements
} }
private void sendFetchNotificationsRequest(final String fromId, String uptoId) { private void sendFetchNotificationsRequest(final String fromId, String uptoId) {
MastodonAPI api = ((BaseActivity) getActivity()).mastodonAPI;
if (fromId != null || adapter.getItemCount() <= 1) { if (fromId != null || adapter.getItemCount() <= 1) {
adapter.setFooterState(NotificationsAdapter.FooterState.LOADING); adapter.setFooterState(NotificationsAdapter.FooterState.LOADING);
} }
listCall = api.notifications(fromId, uptoId, null); listCall = mastodonAPI.notifications(fromId, uptoId, null);
listCall.enqueue(new Callback<List<Notification>>() { listCall.enqueue(new Callback<List<Notification>>() {
@Override @Override
@ -172,6 +159,10 @@ public class NotificationsFragment extends SFragment implements
sendFetchNotificationsRequest(null, null); sendFetchNotificationsRequest(null, null);
} }
public void removePostsByUser(String accountId) {
adapter.removeAllByAccountId(accountId);
}
private static boolean findNotification(List<Notification> notifications, String id) { private static boolean findNotification(List<Notification> notifications, String id) {
for (Notification notification : notifications) { for (Notification notification : notifications) {
if (notification.id.equals(id)) { if (notification.id.equals(id)) {

View File

@ -46,8 +46,14 @@ import retrofit2.Response;
* overlap functionality. So, I'm momentarily leaving it and hopefully working on those will clear * overlap functionality. So, I'm momentarily leaving it and hopefully working on those will clear
* up what needs to be where. */ * up what needs to be where. */
public abstract class SFragment extends BaseFragment { public abstract class SFragment extends BaseFragment {
interface OnUserRemovedListener {
void onUserRemoved(String accountId);
}
protected String loggedInAccountId; protected String loggedInAccountId;
protected String loggedInUsername; protected String loggedInUsername;
protected MastodonAPI mastodonAPI;
protected OnUserRemovedListener userRemovedListener;
protected static int COMPOSE_RESULT = 1; protected static int COMPOSE_RESULT = 1;
@Override @Override
@ -60,8 +66,12 @@ public abstract class SFragment extends BaseFragment {
loggedInUsername = preferences.getString("loggedInAccountUsername", null); loggedInUsername = preferences.getString("loggedInAccountUsername", null);
} }
public MastodonAPI getApi() { @Override
return ((BaseActivity) getActivity()).mastodonAPI; public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
BaseActivity activity = (BaseActivity) getActivity();
mastodonAPI = activity.mastodonAPI;
userRemovedListener = (OnUserRemovedListener) activity;
} }
protected void reply(Status status) { protected void reply(Status status) {
@ -84,8 +94,7 @@ public abstract class SFragment extends BaseFragment {
startActivityForResult(intent, COMPOSE_RESULT); startActivityForResult(intent, COMPOSE_RESULT);
} }
public void onSuccessfulStatus() { public void onSuccessfulStatus() {}
}
@Override @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
@ -115,16 +124,14 @@ public abstract class SFragment extends BaseFragment {
} }
@Override @Override
public void onFailure(Call<Status> call, Throwable t) { public void onFailure(Call<Status> call, Throwable t) {}
}
}; };
Call<Status> call; Call<Status> call;
if (reblog) { if (reblog) {
call = getApi().reblogStatus(id); call = mastodonAPI.reblogStatus(id);
} else { } else {
call = getApi().unreblogStatus(id); call = mastodonAPI.unreblogStatus(id);
} }
call.enqueue(cb); call.enqueue(cb);
callList.add(call); callList.add(call);
@ -149,23 +156,21 @@ public abstract class SFragment extends BaseFragment {
} }
@Override @Override
public void onFailure(Call<Status> call, Throwable t) { public void onFailure(Call<Status> call, Throwable t) {}
}
}; };
Call<Status> call; Call<Status> call;
if (favourite) { if (favourite) {
call = getApi().favouriteStatus(id); call = mastodonAPI.favouriteStatus(id);
} else { } else {
call = getApi().unfavouriteStatus(id); call = mastodonAPI.unfavouriteStatus(id);
} }
call.enqueue(cb); call.enqueue(cb);
callList.add(call); callList.add(call);
} }
private void mute(String id) { private void mute(String id) {
Call<Relationship> call = getApi().muteAccount(id); Call<Relationship> call = mastodonAPI.muteAccount(id);
call.enqueue(new Callback<Relationship>() { call.enqueue(new Callback<Relationship>() {
@Override @Override
public void onResponse(Call<Relationship> call, Response<Relationship> response) {} public void onResponse(Call<Relationship> call, Response<Relationship> response) {}
@ -174,10 +179,11 @@ public abstract class SFragment extends BaseFragment {
public void onFailure(Call<Relationship> call, Throwable t) {} public void onFailure(Call<Relationship> call, Throwable t) {}
}); });
callList.add(call); callList.add(call);
userRemovedListener.onUserRemoved(id);
} }
private void block(String id) { private void block(String id) {
Call<Relationship> call = getApi().blockAccount(id); Call<Relationship> call = mastodonAPI.blockAccount(id);
call.enqueue(new Callback<Relationship>() { call.enqueue(new Callback<Relationship>() {
@Override @Override
public void onResponse(Call<Relationship> call, retrofit2.Response<Relationship> response) {} public void onResponse(Call<Relationship> call, retrofit2.Response<Relationship> response) {}
@ -186,10 +192,11 @@ public abstract class SFragment extends BaseFragment {
public void onFailure(Call<Relationship> call, Throwable t) {} public void onFailure(Call<Relationship> call, Throwable t) {}
}); });
callList.add(call); callList.add(call);
userRemovedListener.onUserRemoved(id);
} }
private void delete(String id) { private void delete(String id) {
Call<ResponseBody> call = getApi().deleteStatus(id); Call<ResponseBody> call = mastodonAPI.deleteStatus(id);
call.enqueue(new Callback<ResponseBody>() { call.enqueue(new Callback<ResponseBody>() {
@Override @Override
public void onResponse(Call<ResponseBody> call, retrofit2.Response<ResponseBody> response) {} public void onResponse(Call<ResponseBody> call, retrofit2.Response<ResponseBody> response) {}
@ -242,12 +249,10 @@ public abstract class SFragment extends BaseFragment {
} }
case R.id.status_mute: { case R.id.status_mute: {
mute(accountId); mute(accountId);
adapter.removeAllByAccountId(accountId);
return true; return true;
} }
case R.id.status_block: { case R.id.status_block: {
block(accountId); block(accountId);
adapter.removeAllByAccountId(accountId);
return true; return true;
} }
case R.id.status_report: { case R.id.status_report: {

View File

@ -0,0 +1,5 @@
package com.keylesspalace.tusky;
interface StatusRemoveListener {
void removePostsByUser(String accountId);
}

View File

@ -142,7 +142,7 @@ class TimelineAdapter extends RecyclerView.Adapter implements AdapterItemRemover
notifyItemRemoved(position); notifyItemRemoved(position);
} }
public void removeAllByAccountId(String accountId) { void removeAllByAccountId(String accountId) {
for (int i = 0; i < statuses.size();) { for (int i = 0; i < statuses.size();) {
Status status = statuses.get(i); Status status = statuses.get(i);
if (accountId.equals(status.account.id)) { if (accountId.equals(status.account.id)) {

View File

@ -39,7 +39,7 @@ import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
public class TimelineFragment extends SFragment implements public class TimelineFragment extends SFragment implements
SwipeRefreshLayout.OnRefreshListener, StatusActionListener { SwipeRefreshLayout.OnRefreshListener, StatusActionListener, StatusRemoveListener {
private static final String TAG = "Timeline"; // logging tag private static final String TAG = "Timeline"; // logging tag
private Call<List<Status>> listCall; private Call<List<Status>> listCall;
@ -145,7 +145,7 @@ public class TimelineFragment extends SFragment implements
/* This is delayed until onActivityCreated solely because MainActivity.composeButton isn't /* This is delayed until onActivityCreated solely because MainActivity.composeButton isn't
* guaranteed to be set until then. */ * guaranteed to be set until then. */
if (followButtonPresent()) { if (composeButtonPresent()) {
/* Use a modified scroll listener that both loads more statuses as it goes, and hides /* Use a modified scroll listener that both loads more statuses as it goes, and hides
* the follow button on down-scroll. */ * the follow button on down-scroll. */
MainActivity activity = (MainActivity) getActivity(); MainActivity activity = (MainActivity) getActivity();
@ -202,7 +202,7 @@ public class TimelineFragment extends SFragment implements
return kind != Kind.TAG && kind != Kind.FAVOURITES; return kind != Kind.TAG && kind != Kind.FAVOURITES;
} }
private boolean followButtonPresent() { private boolean composeButtonPresent() {
return kind != Kind.TAG && kind != Kind.FAVOURITES && kind != Kind.USER; return kind != Kind.TAG && kind != Kind.FAVOURITES && kind != Kind.USER;
} }
@ -212,8 +212,6 @@ public class TimelineFragment extends SFragment implements
} }
private void sendFetchTimelineRequest(@Nullable final String fromId, @Nullable String uptoId) { private void sendFetchTimelineRequest(@Nullable final String fromId, @Nullable String uptoId) {
MastodonAPI api = ((BaseActivity) getActivity()).mastodonAPI;
if (fromId != null || adapter.getItemCount() <= 1) { if (fromId != null || adapter.getItemCount() <= 1) {
adapter.setFooterState(TimelineAdapter.FooterState.LOADING); adapter.setFooterState(TimelineAdapter.FooterState.LOADING);
} }
@ -237,27 +235,27 @@ public class TimelineFragment extends SFragment implements
switch (kind) { switch (kind) {
default: default:
case HOME: { case HOME: {
listCall = api.homeTimeline(fromId, uptoId, null); listCall = mastodonAPI.homeTimeline(fromId, uptoId, null);
break; break;
} }
case PUBLIC_FEDERATED: { case PUBLIC_FEDERATED: {
listCall = api.publicTimeline(null, fromId, uptoId, null); listCall = mastodonAPI.publicTimeline(null, fromId, uptoId, null);
break; break;
} }
case PUBLIC_LOCAL: { case PUBLIC_LOCAL: {
listCall = api.publicTimeline(true, fromId, uptoId, null); listCall = mastodonAPI.publicTimeline(true, fromId, uptoId, null);
break; break;
} }
case TAG: { case TAG: {
listCall = api.hashtagTimeline(hashtagOrId, null, fromId, uptoId, null); listCall = mastodonAPI.hashtagTimeline(hashtagOrId, null, fromId, uptoId, null);
break; break;
} }
case USER: { case USER: {
listCall = api.accountStatuses(hashtagOrId, fromId, uptoId, null); listCall = mastodonAPI.accountStatuses(hashtagOrId, fromId, uptoId, null);
break; break;
} }
case FAVOURITES: { case FAVOURITES: {
listCall = api.favourites(fromId, uptoId, null); listCall = mastodonAPI.favourites(fromId, uptoId, null);
break; break;
} }
} }
@ -269,6 +267,10 @@ public class TimelineFragment extends SFragment implements
sendFetchTimelineRequest(null, null); sendFetchTimelineRequest(null, null);
} }
public void removePostsByUser(String accountId) {
adapter.removeAllByAccountId(accountId);
}
private static boolean findStatus(List<Status> statuses, String id) { private static boolean findStatus(List<Status> statuses, String id) {
for (Status status : statuses) { for (Status status : statuses) {
if (status.id.equals(id)) { if (status.id.equals(id)) {

View File

@ -20,21 +20,31 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup; import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;
class TimelinePagerAdapter extends FragmentPagerAdapter { class TimelinePagerAdapter extends FragmentPagerAdapter {
private Fragment currentFragment; private int currentFragmentIndex;
private List<Fragment> registeredFragments;
TimelinePagerAdapter(FragmentManager manager) { TimelinePagerAdapter(FragmentManager manager) {
super(manager); super(manager);
currentFragmentIndex = 0;
registeredFragments = new ArrayList<>();
} }
public Fragment getCurrentFragment() { Fragment getCurrentFragment() {
return currentFragment; return registeredFragments.get(currentFragmentIndex);
}
List<Fragment> getRegisteredFragments() {
return registeredFragments;
} }
@Override @Override
public void setPrimaryItem(ViewGroup container, int position, Object object) { public void setPrimaryItem(ViewGroup container, int position, Object object) {
if (getCurrentFragment() != object) { if (position != currentFragmentIndex) {
currentFragment = ((Fragment) object); currentFragmentIndex = position;
} }
super.setPrimaryItem(container, position, object); super.setPrimaryItem(container, position, object);
} }
@ -69,4 +79,17 @@ class TimelinePagerAdapter extends FragmentPagerAdapter {
public CharSequence getPageTitle(int position) { public CharSequence getPageTitle(int position) {
return null; return null;
} }
@Override
public Object instantiateItem(ViewGroup container, int position) {
Fragment fragment = (Fragment) super.instantiateItem(container, position);
registeredFragments.add(fragment);
return fragment;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
registeredFragments.remove((Fragment) object);
super.destroyItem(container, position, object);
}
} }