1
0
mirror of https://github.com/TwidereProject/Twidere-Android synced 2025-01-31 17:04:59 +01:00

fixed instance state saving

This commit is contained in:
Mariotaku Lee 2016-03-24 16:36:18 +08:00
parent e8e96b3606
commit c10d3adbed
10 changed files with 26 additions and 19 deletions

View File

@ -713,8 +713,9 @@ public class ComposeActivity extends BaseActivity implements OnMenuItemClickList
if (savedInstanceState != null) { if (savedInstanceState != null) {
// Restore from previous saved state // Restore from previous saved state
mAccountsAdapter.setSelectedAccountIds(Utils.newParcelableArray( final UserKey[] selected = Utils.newParcelableArray(savedInstanceState
savedInstanceState.getParcelableArray(EXTRA_ACCOUNT_KEY), UserKey.CREATOR)); .getParcelableArray(EXTRA_ACCOUNT_KEYS), UserKey.CREATOR);
mAccountsAdapter.setSelectedAccountIds(selected);
mIsPossiblySensitive = savedInstanceState.getBoolean(EXTRA_IS_POSSIBLY_SENSITIVE); mIsPossiblySensitive = savedInstanceState.getBoolean(EXTRA_IS_POSSIBLY_SENSITIVE);
final ArrayList<ParcelableMediaUpdate> mediaList = savedInstanceState.getParcelableArrayList(EXTRA_MEDIA); final ArrayList<ParcelableMediaUpdate> mediaList = savedInstanceState.getParcelableArrayList(EXTRA_MEDIA);
if (mediaList != null) { if (mediaList != null) {

View File

@ -320,8 +320,8 @@ public final class DummyItemAdapter implements IStatusesAdapter<Object>,
} }
@Override @Override
public void setData(Object o) { public boolean setData(Object o) {
return false;
} }

View File

@ -210,7 +210,7 @@ public abstract class ParcelableStatusesAdapter extends LoadMoreSupportAdapter<R
return mData.get(dataPosition).account_key; return mData.get(dataPosition).account_key;
} }
public void setData(List<ParcelableStatus> data) { public boolean setData(List<ParcelableStatus> data) {
mData = data; mData = data;
if (data instanceof ObjectCursor || data == null || data.isEmpty()) { if (data instanceof ObjectCursor || data == null || data.isEmpty()) {
mLastItemFiltered = false; mLastItemFiltered = false;
@ -218,6 +218,7 @@ public abstract class ParcelableStatusesAdapter extends LoadMoreSupportAdapter<R
mLastItemFiltered = data.get(data.size() - 1).is_filtered; mLastItemFiltered = data.get(data.size() - 1).is_filtered;
} }
notifyDataSetChanged(); notifyDataSetChanged();
return true;
} }
public List<ParcelableStatus> getData() { public List<ParcelableStatus> getData() {

View File

@ -71,9 +71,10 @@ public class ParcelableUserListsAdapter extends LoadMoreSupportAdapter<RecyclerV
@Override @Override
public void setData(List<ParcelableUserList> data) { public boolean setData(List<ParcelableUserList> data) {
mData = data; mData = data;
notifyDataSetChanged(); notifyDataSetChanged();
return true;
} }
protected void bindUserList(UserListViewHolder holder, int position) { protected void bindUserList(UserListViewHolder holder, int position) {

View File

@ -73,9 +73,10 @@ public class ParcelableUsersAdapter extends LoadMoreSupportAdapter<RecyclerView.
@Override @Override
public void setData(List<ParcelableUser> data) { public boolean setData(List<ParcelableUser> data) {
mData = data; mData = data;
notifyDataSetChanged(); notifyDataSetChanged();
return true;
} }
protected void bindUser(UserViewHolder holder, int position) { protected void bindUser(UserViewHolder holder, int position) {

View File

@ -50,7 +50,7 @@ public interface IStatusesAdapter<Data> extends IContentCardAdapter, IGapSupport
boolean isSensitiveContentEnabled(); boolean isSensitiveContentEnabled();
void setData(Data data); boolean setData(Data data);
boolean shouldShowAccountsColor(); boolean shouldShowAccountsColor();

View File

@ -37,7 +37,7 @@ public interface IUserListsAdapter<Data> extends IContentCardAdapter {
int getUserListsCount(); int getUserListsCount();
void setData(Data data); boolean setData(Data data);
boolean shouldShowAccountsColor(); boolean shouldShowAccountsColor();

View File

@ -38,7 +38,7 @@ public interface IUsersAdapter<Data> extends IContentCardAdapter {
int getUserCount(); int getUserCount();
void setData(Data data); boolean setData(Data data);
@Nullable @Nullable
UserClickListener getUserClickListener(); UserClickListener getUserClickListener();

View File

@ -643,9 +643,9 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
} }
private void setConversation(List<ParcelableStatus> data) { private void setConversation(List<ParcelableStatus> data) {
mHasMoreConversation = data != null && !data.isEmpty();
final ReadPosition readPosition = saveReadPosition(); final ReadPosition readPosition = saveReadPosition();
mStatusAdapter.setData(data); final boolean changed = mStatusAdapter.setData(data);
mHasMoreConversation = data != null && changed;
restoreReadPosition(readPosition); restoreReadPosition(readPosition);
} }
@ -1930,9 +1930,10 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
} }
@Override @Override
public void setData(List<ParcelableStatus> data) { public boolean setData(List<ParcelableStatus> data) {
final ParcelableStatus status = mStatus; final ParcelableStatus status = mStatus;
if (status == null) return; if (status == null) return false;
boolean changed = !CompareUtils.objectEquals(mData, data);
mData = data; mData = data;
if (data == null || data.isEmpty()) { if (data == null || data.isEmpty()) {
setTypeCount(ITEM_IDX_CONVERSATION, 0); setTypeCount(ITEM_IDX_CONVERSATION, 0);
@ -1967,6 +1968,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
} }
notifyDataSetChanged(); notifyDataSetChanged();
updateItemDecoration(); updateItemDecoration();
return changed;
} }
@Override @Override

View File

@ -111,20 +111,20 @@ public final class TwidereLinkify implements Constants {
} }
public void applyAllLinks(@Nullable Spannable text, final UserKey accountKey, public void applyAllLinks(@Nullable Spannable text, final UserKey accountKey,
final long extraId, final boolean sensitive, final long extraId, final boolean sensitive,
final boolean skipLinksInText) { final boolean skipLinksInText) {
applyAllLinks(text, mOnLinkClickListener, accountKey, extraId, sensitive, applyAllLinks(text, mOnLinkClickListener, accountKey, extraId, sensitive,
mHighlightOption, skipLinksInText); mHighlightOption, skipLinksInText);
} }
public void applyAllLinks(@Nullable Spannable text, final UserKey accountKey, public void applyAllLinks(@Nullable Spannable text, final UserKey accountKey,
final boolean sensitive, final boolean skipLinksInText) { final boolean sensitive, final boolean skipLinksInText) {
applyAllLinks(text, mOnLinkClickListener, accountKey, -1, sensitive, mHighlightOption, skipLinksInText); applyAllLinks(text, mOnLinkClickListener, accountKey, -1, sensitive, mHighlightOption, skipLinksInText);
} }
public void applyAllLinks(@Nullable Spannable text, final UserKey accountKey, public void applyAllLinks(@Nullable Spannable text, final UserKey accountKey,
final long extraId, final boolean sensitive, final long extraId, final boolean sensitive,
final int highlightOption, final boolean skipLinksInText) { final int highlightOption, final boolean skipLinksInText) {
applyAllLinks(text, mOnLinkClickListener, accountKey, extraId, sensitive, highlightOption, skipLinksInText); applyAllLinks(text, mOnLinkClickListener, accountKey, extraId, sensitive, highlightOption, skipLinksInText);
} }
@ -258,6 +258,7 @@ public final class TwidereLinkify implements Constants {
break; break;
} }
case LINK_TYPE_STATUS: { case LINK_TYPE_STATUS: {
if (!USER_TYPE_TWITTER_COM.equals(accountKey.getHost())) break;
final int length = string.length(); final int length = string.length();
final URLSpan[] spans = string.getSpans(0, length, URLSpan.class); final URLSpan[] spans = string.getSpans(0, length, URLSpan.class);
for (final URLSpan span : spans) { for (final URLSpan span : spans) {