public void configure(TwitterStatus twitterStatus, LayoutInflater inflater, Callbacks callbacks) { mTwitterStatus = twitterStatus; mInflater = inflater; mCallbacks = callbacks; mLoadingView = (RelativeLayout) findViewById(R.id.conversation_feed_loading); mConversationView = (LinearLayout) findViewById(R.id.conversation_feed_loaded); TwitterContentHandleBase base = new TwitterContentHandleBase( TwitterConstant.ContentType.STATUSES, TwitterConstant.StatusesType.PREVIOUS_CONVERSATION); mContentHandle = new TwitterContentHandle( base, twitterStatus.mUserScreenName, Long.valueOf(mTwitterStatus.mId).toString()); TwitterStatuses cachedStatuses = TwitterManager.get().getContentFeed(mContentHandle); if (cachedStatuses != null && cachedStatuses.getStatusCount() > 0) { setStatuses(cachedStatuses); updateViewVisibility(true); } else { TwitterManager.get() .triggerFetchStatuses( mContentHandle, null, new TwitterFetchStatusesFinishedCallback() { @Override public void finished(TwitterFetchResult result, TwitterStatuses feed) { if (result.isSuccessful()) { setStatuses(feed); } updateViewVisibility(true); } }, 1); } }
/* * (non-Javadoc) * @see com.tweetlanes.android.view.ComposeBaseFragment#onSendClick(java.lang.String) */ @Override protected void onSendClick(String status) { if (status != null) { String otherUserScreenName = getOtherUserScreenName(); int statusLength = mStatusValidator.getTweetLength(status); if (otherUserScreenName == null) { showSimpleAlert(R.string.alert_direct_message_no_recipient); } else if (mStatusValidator.isValidTweet(status) == false) { showSimpleAlert( mStatusValidator.getTweetLength(status) <= Validator.MAX_TWEET_LENGTH ? R.string.alert_direct_message_invalid : R.string.alert_direct_message_too_long); } else if (statusLength > 0) { AccountDescriptor account = getApp().getCurrentAccount(); if (account != null) { mUpdatingStatus = true; mEditText.setHint(null); mEditText.setEnabled(false); mSendButton.setEnabled(false); TwitterManager.get() .sendDirectMessage( account.getId(), otherUserScreenName, status, mOnSetStatusCallback); showToast(getString(R.string.posting_direct_message_ongoing)); /* ComposeTweetDefault currentStatus = new ComposeTweetDefault(getApp().getCurrentAccountScreenName(), status, getInReplyToId(), getMediaFilePath()); if (mListener != null) { mListener.saveDraft(currentStatus.toString()); mListener.onStatusUpdateRequest(); } setComposeTweetDefault(currentStatus); */ updateStatusHint(); // mSendingNotification = NotificationHelper.get().notify(getActivity(), builder); } } } }
@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; }