@Override
  public boolean handleMessage(Message msg) {
    switch (msg.what) {
      case Requester2.RESPONSE_TYPE_GET_DIARY_FORWORD:
        ZDialog.dismiss();
        GsonResponse2.getDiaryForwardUsersResponse gdpResponse =
            (GsonResponse2.getDiaryForwardUsersResponse) msg.obj;
        dpList = new ArrayList<GsonResponse2.getDiaryForwardUsers>();
        if (gdpResponse != null
            && gdpResponse.status.equals("0")
            && gdpResponse.forwords.length > 0) {
          for (int j = 0; j < gdpResponse.forwords.length; j++) {
            dpList.add(gdpResponse.forwords[j]);
          }
        } else {
          isShowAllPraise = true;
        }
        dpAdapter = new DiaryPraiseAdapter(dpList);
        lv.setAdapter(dpAdapter);
        lv.setOnItemClickListener(this);
        listView.onRefreshComplete();
        break;

      default:
        break;
    }
    return false;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_diary_praise);

    diaryID = getIntent().getStringExtra("diaryID");

    userID = ActiveAccount.getInstance(ZApplication.getInstance()).getUID();
    ai = AccountInfo.getInstance(userID);
    ZDialog.show(R.layout.progressdialog, true, true, this);
    Requester2.getDiaryForwardUsers(getHandler(), diaryID, null, null);

    otherUserID = getIntent().getStringExtra(INTENT_ACTION_USERID);

    isShowAllPraise = false;
    inflater = LayoutInflater.from(this);
    findViewById(R.id.iv_back).setOnClickListener(this);
    listView = (PullToRefreshListView) findViewById(R.id.lv_activity_diary_praise);
    listView.setOnRefreshListener(this);
    dpList = new ArrayList<GsonResponse2.getDiaryForwardUsers>();

    lv = listView.getRefreshableView();
  }
Beispiel #3
0
  private void modifyDiary() {
    ZDialog.show(R.layout.progressdialog, false, true, this, true);
    new Thread(
            new Runnable() {

              @Override
              public void run() {
                // TODO Auto-generated method stub
                if (isVideoRolated()) {
                  // 旋转操作
                  String videoID = DiaryController.getNextUUID();
                  String outVideoPath =
                      DiaryController.getAbsolutePathUnderUserDir() + "/video/" + videoID + ".mp4";
                  ZFileSystem.copy(curVideoPath, outVideoPath);
                  mMediaPlayer.saveOrientation(outVideoPath);
                  curVideoPath = outVideoPath;
                }
                final Intent intent = new Intent();

                // 删除缓存数据
                deleteCacheFile();

                if (!curVideoPath.equals(videoPath)) {
                  myDiary.modifyMainAttach(curVideoPath, "");
                  if (videoPath.endsWith(diaryEditNote.mediaPath)) {
                    intent.putExtra(
                        DiaryEditPreviewActivity.INTENT_ACTION_MEDIA_PATH, curVideoPath);
                  } else {
                    if (isVideoRolated()) {
                      mMediaPlayer.saveOrientation(curOriginalVideoPath);
                    }
                    intent.putExtra(
                        DiaryEditPreviewActivity.INTENT_ACTION_MEDIA_PATH, curOriginalVideoPath);
                  }
                }

                if (isCoverSetted()) {
                  if (ivCoverSetted != null) {
                    BitmapDrawable mDrawable = (BitmapDrawable) ivCoverSetted.getDrawable();
                    if (mDrawable != null) {
                      Bitmap image = mDrawable.getBitmap();
                      String imageID = DiaryController.getNextUUID();
                      String videoCoverPath =
                          DiaryController.getAbsolutePathUnderUserDir()
                              + "/pic/"
                              + imageID
                              + ".jpg";
                      if (image != null) {
                        if (BitmapUtils.saveBitmap2file(image, videoCoverPath)) {
                          Log.d(TAG, "saveBitmap2file sucessed");
                          myDiary.modifyVideoCover(videoCoverPath);
                        }
                      }
                    }
                  }
                  // 设置封面
                  /*Bitmap bmp = mMediaPlayer.videScreenCapture(videoCoverTime, EffectType.EFFECT_VIDEO_DEFAULT_WIDTH, EffectType.EFFECT_VIDEO_DEFAULT_WIDTH);

                  if (bmp != null) {
                  	curAngle = mMediaPlayer.getCurrentOrientation();
                  	bmp = BitmapUtils.rotate(bmp, (360-curAngle)%360, true);
                  	String imageID = DiaryController.getNextUUID();
                  	String videoCoverPath = DiaryController.getAbsolutePathUnderUserDir()  +  "/pic/" + imageID + ".jpg";
                  	if(BitmapUtils.saveBitmap2file(bmp, videoCoverPath)) {
                  		Log.d(TAG,"saveBitmap2file sucessed");
                  	}

                  	myDiary.modifyVideoCover(videoCoverPath);
                  } else {
                  	runOnUiThread(new Runnable() {

                  		@Override
                  		public void run() {
                  			// TODO Auto-generated method stub
                  			Toast.makeText(EditVideoActivity.this, "截屏失败", 1000).show();
                  		}
                  	});

                  }*/
                }

                runOnUiThread(
                    new Runnable() {

                      @Override
                      public void run() {
                        // TODO Auto-generated method stub
                        String diaryString = new Gson().toJson(myDiary);
                        intent.putExtra(
                            DiaryEditPreviewActivity.INTENT_ACTION_DIARY_STRING, diaryString);

                        setResult(RESULT_OK, intent);
                        ZDialog.dismiss();
                        finish();
                      }
                    });
              }
            })
        .start();
  }
  @Override
  public void onClick(View arg0) {
    // TODO Auto-generated method stub
    switch (arg0.getId()) {
        /*case R.id.ll_edit_media_sound_distinguish:
        goToPage(FRAGMENT_TEXT_INPUT, false);
        edit.setHorizontallyScrolling(false);
        break;*/
      case R.id.iv_back:
        finish();
        break;
      case R.id.iv_edit_done:
        if (isEditButtonPressed) {
          break;
        }
        isEditButtonPressed = true;

        Dialog dialog = ZDialog.show(R.layout.progressdialog, false, true, this, true);
        mMediaPlayer.stop();
        shortRecMediaPlayer.stop();
        dialogTitle = (TextView) dialog.findViewById(R.id.progress_dialog_tv);
        isMainAttachChanged = isMainAttachChanged();
        if (getString(R.string.edit_media_cover).equals(getEditDiaryStyle())) {
          if (isDiaryCreated()) {
            modTagsOrPosition();
            addAttach();
          } else { // 若日记未创建成功
            removeDiaryTask();
            createOfflineDiary();
          }
          saveLocalDiaryAndFinish();
        } else {
          saveAsNewDiary();
        }
        break;
      case R.id.ll_edit_diary_style:
        showDuplicateDiaryName();
        break;
      case R.id.iv_edit_voice_play:
        if (mMediaPlayer != null && mainAudioPath != null) {
          int status = mMediaPlayer.getStatus();
          Log.d(TAG, "mediapStatus = " + status);
          if (status == XEffectMediaPlayer.STATUS_UNKNOW
              || status == XEffectMediaPlayer.STATUS_STOP
              || status == XEffectMediaPlayer.STATUS_OPENED) {
            if (status == XEffectMediaPlayer.STATUS_UNKNOW) {
              if (videoAttachPath != null) {
                isPlayerPrepared = false;
                mMediaPlayer.open(mainAudioPath);
              }
            }
            if (isPlayerPrepared) {
              mMediaPlayer.play();
              if (audioMontageStartTime > 0.1) {
                mMediaPlayer.seek(audioMontageStartTime);
              }
            } else {
              isPlayerNeedToPlay = true;
            }
            ivPlay.setImageResource(R.drawable.btn_edit_audio_pause);
          } else if (mMediaPlayer.getStatus() == XEffectMediaPlayer.STATUS_PALYING) {
            mMediaPlayer.pause();
            ivPlay.setImageResource(R.drawable.btn_edit_audio_play);
          } else if (mMediaPlayer.getStatus() == XEffectMediaPlayer.STATUS_PAUSE) {
            ivPlay.setImageResource(R.drawable.btn_edit_audio_pause);
            mMediaPlayer.resume();
          }
        } else {
          Log.e(TAG, "mMediaPlayer  is null");
        }
        break;
      case R.id.ll_biezhen:
        if (shortRecMediaPlayer.isPlaying()) {
          tackView.stopAudio(shortRecMediaPlayer);
        } else {
          tackView.playAudio(audioPath, shortRecMediaPlayer);
        }
        break;
      case R.id.iv_edit_voice_thumbnails:
        if (fragmentType == FRAGMENT_DETAIL_MAIN_VIEW
            || fragmentType == FRAGMENT_TAG_VIEW
            || fragmentType == FRAGMENT_TEXT_INPUT) {
          mainLayout.setVisibility(View.VISIBLE);
          detailMainLayout.setVisibility(View.GONE);
          if (mMediaPlayer.getStatus() == XEffectMediaPlayer.STATUS_PAUSE) {
            mMediaPlayer.seek(0);
            mMediaPlayer.resume();
          } else {
            mMediaPlayer.play();
          }
          playProcess.setProgress(0);
          ivPlay.setImageResource(R.drawable.btn_edit_audio_pause);
        }
        break;
      case R.id.rl_activity_edit_voice_main:
        if (fragmentType == FRAGMENT_DETAIL_MAIN_VIEW
            || fragmentType == FRAGMENT_TAG_VIEW
            || fragmentType == FRAGMENT_TEXT_INPUT) {
          mainLayout.setVisibility(View.GONE);
          detailMainLayout.setVisibility(View.VISIBLE);
          if (mMediaPlayer.getStatus() == XEffectMediaPlayer.STATUS_PALYING) {
            mMediaPlayer.pause();
          }
          ivPlay.setImageResource(R.drawable.btn_edit_audio_play);
          break;
        }
    }
  }