private void onStatusRefresh(TwitterStatus status) { if (mTweetFeedListAdapter != null) { mStatus = status; mTweetFeedListAdapter.notifyDataSetChanged(); mTweetFeedListView.onRefreshComplete(); TweetSpotlightActivity spotlightActivity = (TweetSpotlightActivity) getActivity(); if (spotlightActivity != null) { spotlightActivity.onGetStatus(mStatus); } } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); // // // /* * mContentHandle = * TwitterManager.get().getContentHandle(getContentHandleBase(), * getScreenName(), null); */ mGetStatusCallback = TwitterManager.get().getFetchStatusInstance().new FinishedCallback() { @Override public void finished(TwitterFetchResult result, TwitterStatus status) { if (mTweetFeedListAdapter != null) { onStatusRefresh(status); updateViewVisibility(); } else if (result.getErrorMessage().contains("does not exist")) { TweetSpotlightActivity spotlightActivity = (TweetSpotlightActivity) getActivity(); if (spotlightActivity != null) { spotlightActivity.TweetDeleted(result.getErrorMessage()); } } mGetStatusCallback = null; } }; TweetSpotlightActivity spotlightActivity = (TweetSpotlightActivity) getActivity(); if (spotlightActivity != null) { mStatus = spotlightActivity.mStatus; } if (mStatus == null) { mStatus = TwitterManager.get().getStatus(getStatusId(), mGetStatusCallback); } setInitialDownloadState(InitialDownloadState.DOWNLOADED); // // // View resultView = inflater.inflate(R.layout.lane, null); configureLaneWidth(resultView); mViewSwitcher = (ViewSwitcher) resultView.findViewById(R.id.profileSwitcher); mTweetFeedListView = (PullToRefreshListView) resultView.findViewById(R.id.pull_to_refresh_listview); mTweetFeedListView.setOnRefreshListener( new OnRefreshListener() { @Override public void onRefresh() { mGetStatusCallback = TwitterManager.get().getFetchStatusInstance().new FinishedCallback() { @Override public void finished(TwitterFetchResult result, TwitterStatus status) { // TODO: Handle error properly if (result.isSuccessful()) { if (mStatus.mIsRetweet && mStatus.mOriginalRetweetId > 0) { mGetStatusCallback = TwitterManager.get().getFetchStatusInstance().new FinishedCallback() { @Override public void finished( TwitterFetchResult result, TwitterStatus status) { // TODO: Handle error properly if (result.isSuccessful()) { mStatus.mIsRetweetedByMe = status.mIsRetweetedByMe; onStatusRefresh(mStatus); } else if (result.getErrorMessage().contains("does not exist")) { TweetSpotlightActivity spotlightActivity = (TweetSpotlightActivity) getActivity(); if (spotlightActivity != null) { spotlightActivity.TweetDeleted(result.getErrorMessage()); } } mGetStatusCallback = null; } }; mStatus = status; TwitterManager.get() .getStatus(mStatus.mOriginalRetweetId, mGetStatusCallback); } else { onStatusRefresh(status); } } else if (result.getErrorMessage().contains("does not exist")) { TweetSpotlightActivity spotlightActivity = (TweetSpotlightActivity) getActivity(); if (spotlightActivity != null) { spotlightActivity.TweetDeleted(result.getErrorMessage()); } } mGetStatusCallback = null; } }; TwitterManager.get().getStatus(mStatus.mId, mGetStatusCallback); } }); mTweetFeedListAdapter = new TweetFeedListAdapter(inflater); mTweetFeedListView.getRefreshableView().setAdapter(mTweetFeedListAdapter); updateViewVisibility(); return resultView; }