Skip to content

Commit

Permalink
Fix for #288 remember new tweet count on reload
Browse files Browse the repository at this point in the history
  • Loading branch information
BlythMeister committed Sep 13, 2013
1 parent e314e69 commit 6e531f5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
2 changes: 2 additions & 0 deletions android/libraries/TweetLanesCore/res/xml/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
<change>Fix - Profile URL is now expanded from a t.co</change>
<change>Fix - Close several leaks dealing with the image loader</change>
<change>Fix - Significantly reduce overdraw in lists containing tweets</change>
<change>Fix - Force close when switching accounts</change>
<change>Fix - New tweet count on close and re-open</change>
<change>Other - Large codebase tidy-up - hopefully small improvement to performance, size and reliability</change>
</release>
<release version="1.2.0" versioncode="49">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void fetchNewestTweets(final long sinceStatusId, Long maxStatusId) {
if (mTweetDataRefreshCallback == null) {

if (maxStatusId == null) {
if(getActivity() != null){
if (getActivity() != null) {
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
}
mTimesFetchCalled = 0;
Expand Down Expand Up @@ -362,6 +362,9 @@ public void onJumpToTop() {
}

private static final String KEY_VISIBLE_STATUS_ID = "visibleStatusId";
private static final String KEY_LAST_SEEN_STATUS_ID = "lastSeenStatusId";
private static final String KEY_HIDE_LIST_HEADING = "hideListHeading";
private static final String KEY_REFRESH_STATUS_ID = "refreshStatusId";
private static final String KEY_STATUSES = "statuses";

/*
Expand Down Expand Up @@ -430,6 +433,9 @@ public String getDataToCache() {
JSONObject object = new JSONObject();
try {
object.put(KEY_VISIBLE_STATUS_ID, visibleStatusId);
object.put(KEY_LAST_SEEN_STATUS_ID, mLastTwitterStatusIdSeen);
object.put(KEY_REFRESH_STATUS_ID, mTwitterStatusIdWhenRefreshed);
object.put(KEY_HIDE_LIST_HEADING, mHidingListHeading);
JSONArray statusArray = new JSONArray();
int statusCount = statuses.getStatusCount();
for (int i = 0; i < statusCount; ++i) {
Expand Down Expand Up @@ -460,6 +466,16 @@ boolean configureCachedStatuses() {
object = new JSONObject(cachedData);
if (object.has(KEY_VISIBLE_STATUS_ID)) {
mResumeStatusId = object.getLong(KEY_VISIBLE_STATUS_ID);
if (object.has(KEY_LAST_SEEN_STATUS_ID)) {
mLastTwitterStatusIdSeen = object.getLong(KEY_LAST_SEEN_STATUS_ID);
}
if (object.has(KEY_HIDE_LIST_HEADING)) {
mHidingListHeading = object.getBoolean(KEY_HIDE_LIST_HEADING);
}
if (object.has(KEY_REFRESH_STATUS_ID)) {
mTwitterStatusIdWhenRefreshed = object.getLong(KEY_REFRESH_STATUS_ID);
}

if (object.has(KEY_STATUSES)) {
String statusesAsString = object.getString(KEY_STATUSES);
if (statusesAsString != null) {
Expand All @@ -474,6 +490,10 @@ boolean configureCachedStatuses() {
TwitterManager.get().getFetchStatusesInstance().cacheHashtags(_mCachedStatusFeed);

setStatusFeed(_mCachedStatusFeed, false);
if (getStatusFeed() != null) {
updateListHeading(getStatusFeed().getStatusIndex(mLastTwitterStatusIdSeen));
}

return true;
}
}
Expand Down Expand Up @@ -749,7 +769,7 @@ void beginListHeadingCount() {
}

/*
*
*
*/ private final OnClickListener mListHeadingHideImageOnClickListener = new OnClickListener() {

@Override
Expand Down Expand Up @@ -777,8 +797,7 @@ void updateListHeading(int firstVisibleItem) {
TwitterStatuses twitterStatuses = getStatusFeed();
TwitterStatus status = null;

if(twitterStatuses!=null)
{
if (twitterStatuses != null) {
status = twitterStatuses.getStatus(firstVisibleItem);
}

Expand All @@ -798,7 +817,7 @@ void updateListHeading(int firstVisibleItem) {
R.string.new_posts));
} else {

if (status != null && status.mId >= mLastTwitterStatusIdSeen) {
if (status != null && status.mId >= mLastTwitterStatusIdSeen) {
mLastTwitterStatusIdSeen = status.mId;
}

Expand All @@ -808,7 +827,7 @@ void updateListHeading(int firstVisibleItem) {
}
} else {

if (status != null && status.mId >= mLastTwitterStatusIdSeen) {
if (status != null && status.mId >= mLastTwitterStatusIdSeen) {
mLastTwitterStatusIdSeen = status.mId;
}

Expand Down Expand Up @@ -921,7 +940,7 @@ private void onRefreshFinished(TwitterStatuses feed) {
}

mTweetDataRefreshCallback = null;
if(getActivity() != null){
if (getActivity() != null) {
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
}
Expand Down Expand Up @@ -1319,17 +1338,17 @@ public void finished(TwitterFetchResult result, TwitterStatus status) {
showToast(getString(R.string.retweeted_marking_un_successful));
}
} else {
if (result.getErrorMessage() == null){
if (result.getErrorMessage() == null) {
showUnsuccessful = true;
} else if(!result.getErrorMessage().equals("CancelPressed") && !result.getErrorMessage().equals("QutotePressed")){
} else if (!result.getErrorMessage().equals("CancelPressed") && !result.getErrorMessage().equals("QutotePressed")) {
showUnsuccessful = true;
}
}
} else {
showUnsuccessful = true;
}

if(showUnsuccessful){
if (showUnsuccessful) {
showToast(getString(R.string.retweeted_un_successful));
}
}
Expand Down

0 comments on commit 6e531f5

Please sign in to comment.