示例#1
0
 private void submitPost() {
   hideIME();
   setStateFromView();
   PostState state = PostState.getState();
   StatusUpdate statusUpdate = state.toStatusUpdate();
   MainActivity activity = (MainActivity) getActivity();
   final Account account = activity.getAccount();
   final Consumer consumer = activity.getConsumer();
   Twitter twitter = TwitterApi.getTwitter(consumer, account);
   TweetTask tweetTask = new TweetTask(twitter, statusUpdate, state.getMediaFilePath(), activity);
   tweetTask.execute();
   PostState.newState().beginTransaction().commit();
   activity.setSelectedPageIndex(MainActivity.ADAPTER_HOME);
 }
示例#2
0
  @Override
  public void onPostStateChange(final PostState postState) {
    Logger.debug("PostFragment PostStateChange");
    final MainActivity activity = (MainActivity) getActivity();
    if (editText != null) {
      final int start = postState.getSelectionStart();
      final int end = postState.getSelectionEnd();
      editText.removeTextChangedListener(this);
      editText.setTextKeepState(postState.getText());
      editText.addTextChangedListener(this);
      updateTextCount(editText.getText());
      new UIHandler() {
        @Override
        public void run() {
          editText.setSelection(start, end);
        }
      }.postAtFrontOfQueue();
    }
    if (viewGroupReply != null) {
      if (postState.getInReplyToStatusID() >= 0) {
        viewGroupReply.setVisibility(View.VISIBLE);
        final Account account = activity.getAccount();
        final Consumer consumer = activity.getConsumer();
        Twitter twitter = TwitterApi.getTwitter(consumer, account);
        TwitterUtils.tryGetStatus(
            twitter,
            account,
            postState.getInReplyToStatusID(),
            new TwitterUtils.StatusCallback() {
              @Override
              public void success(Status status) {
                View header = viewGroupReply.findViewById(R.id.layout_post_reply_status);
                header =
                    new StatusViewModel(status, account)
                        .getView(activity, activity.getLayoutInflater(), header);
                header.setBackgroundColor(getResources().getColor(R.color.transparent));
                header.setClickable(false);
              }

              @Override
              public void error() {
                viewGroupReply.setVisibility(View.GONE);
              }
            });
        ImageButton imageButtonDeleteReply =
            (ImageButton) viewGroupReply.findViewById(R.id.button_post_reply_delete);
        imageButtonDeleteReply.setOnClickListener(this);
      } else {
        viewGroupReply.setVisibility(View.GONE);
      }
    }
    if (viewGroupMedia != null) {
      ImageView imageViewMedia = (ImageView) viewGroupMedia.findViewById(R.id.image_post_media);
      if (TextUtils.isEmpty(postState.getMediaFilePath())) {
        viewGroupMedia.setVisibility(View.GONE);
      } else {
        viewGroupMedia.setVisibility(View.VISIBLE);
      }
      new BitmapThumbnailTask(activity, postState.getMediaFilePath(), imageViewMedia).execute();
    }
  }