@Override
  protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);

    if (null != savedInstanceState) {
      // 地理位置
      if (savedInstanceState.containsKey("location")) {
        locationString = savedInstanceState.getString("location");
        if (null == locationString || locationString.length() < 1) {
          choiceLocationTextView.setText("告诉我你在哪里....");
        } else {
          choiceLocationTextView.setText(locationString);
        }
      }
      // 内容
      if (savedInstanceState.containsKey("content")) {
        contentEditText.setText(savedInstanceState.getString("content"));
      }
      // 图片
      if (savedInstanceState.containsKey("images")) {
        ArrayList<String> imageList = savedInstanceState.getStringArrayList("images");
        for (String string : imageList) {
          addNewsImageView(string);
        }
      }

      // 最后拍的
      if (savedInstanceState.containsKey("tmpImageName")) {
        tmpImageName = savedInstanceState.getString("tmpImageName");
      }
    }
  }
  // /防止内存不够用
  @Override
  protected void onSaveInstanceState(Bundle outState) {

    // 内容
    outState.putString("content", contentEditText.getText().toString());
    // 地点
    outState.putString("location", locationString);
    // 图片
    ArrayList<String> imageList = new ArrayList<String>();
    int subviewsCount = addImageLayout.getChildCount();
    for (int i = 0; i < subviewsCount; i++) {
      View view = addImageLayout.getChildAt(i);
      if (null != view.getTag() && view != addImageView) {
        if (view.getTag() instanceof String) {
          imageList.add((String) view.getTag());
        }
      }
    }
    outState.putStringArrayList("images", imageList);
    if (null != tmpImageName && tmpImageName.length() > 0) {
      // 刚拍的照片
      outState.putString("tmpImageName", tmpImageName);
    }

    super.onSaveInstanceState(outState);
  }
 @Override
 protected void onRestoreInstanceState(Bundle savedInstanceState) {
   // TODO Auto-generated method stub
   super.onRestoreInstanceState(savedInstanceState);
   if (null != savedInstanceState) {
     tmpImageName = savedInstanceState.getString("tmpImageName");
   }
 }
  @Override
  // 销毁的时候清空缓存
  protected void onDestroy() {
    super.onDestroy();

    // 清除缓存
    for (int i = 0; i < addImageLayout.getChildCount(); i++) {
      View view = addImageLayout.getChildAt(i);
      // 如果不是添加按钮
      if (view != addImageView) {
        // 图片
        File file = new File((String) view.getTag());
        if (file.exists()) {
          file.delete();
        }
      }
    }
  }
 // 图片滤镜
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   // TODO Auto-generated method stub
   super.onActivityResult(requestCode, resultCode, data);
   if (resultCode == Activity.RESULT_OK) {
     String sdStatus = Environment.getExternalStorageState();
     if (!sdStatus.equals(Environment.MEDIA_MOUNTED)) { // 检测sd是否可用
       LogUtils.i("SD card is not avaiable/writeable right now.", 1);
       return;
     }
     // 头像需要缩放
     switch (requestCode) {
       case TAKE_PHOTO: // 当选择拍照时调用
         // 图片压缩
         int[] screenSize = getScreenSize();
         if (FileUtil.tempToLocalPath(tmpImageName, screenSize[0], screenSize[1])) {
           displayImage(tmpImageName);
         }
         break;
       case ALBUM_SELECT: // 当选择从本地获取图片时
         if (data != null) {
           @SuppressWarnings("unchecked")
           List<String> resultList =
               (List<String>) data.getSerializableExtra(GalleyActivity.INTENT_KEY_PHOTO_LIST);
           // 循环处理图片
           for (String fileRealPath : resultList) {
             // 只取一张
             int[] screenSize1 = getScreenSize();
             if (fileRealPath != null
                 && FileUtil.tempToLocalPath(
                     fileRealPath, tmpImageName, screenSize1[0], screenSize1[1])) {
               displayImage(tmpImageName);
               break;
             }
           }
         }
         break;
     }
   }
 }
 @Override
 public void onSaveInstanceState(Bundle outState) {
   // TODO Auto-generated method stub
   super.onSaveInstanceState(outState);
   outState.putSerializable("tmpImageName", tmpImageName);
 }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == Activity.RESULT_OK) {
      String sdStatus = Environment.getExternalStorageState();
      if (!sdStatus.equals(Environment.MEDIA_MOUNTED)) { // 检测sd是否可用
        LogUtils.i("SD card is not avaiable/writeable right now.", 1);
        return;
      }
      switch (requestCode) {
        case TAKE_PHOTO: // 当选择拍照时调用
          // 图片压缩
          int[] screenSize = getScreenSize();
          if (FileUtil.tempToLocalPath(tmpImageName, screenSize[0], screenSize[1])) {
            // filterImage(FileUtil.BIG_IMAGE_PATH + tmpImageName,
            // true);
            addNewsImageView(FileUtil.BIG_IMAGE_PATH + tmpImageName);
          }
          break;
        case ALBUM_SELECT: // 当选择从本地获取图片时
          /** **************** */
          @SuppressWarnings("unchecked")
          List<String> resultList =
              (List<String>) data.getSerializableExtra(GalleyActivity.INTENT_KEY_PHOTO_LIST);
          int[] screenSize1 = getScreenSize();
          long interval = System.currentTimeMillis() / 1000;
          // 循环处理图片
          for (String fileRealPath : resultList) {
            LogUtils.i(fileRealPath, 1);
            // 用户id+时间戳
            String fileName = UserManager.getInstance().getUser().getUid() + "" + interval + ".jpg";
            if (fileRealPath != null
                && FileUtil.tempToLocalPath(
                    fileRealPath, fileName, screenSize1[0], screenSize1[1])) {
              addNewsImageView(FileUtil.BIG_IMAGE_PATH + fileName);
            }
            // 命名规则以当前时间戳顺序加一
            interval++;
          }

          Timer timer = new Timer();
          timer.schedule(
              new TimerTask() {

                @Override
                public void run() {
                  // TODO Auto-generated method stub
                  // Message message = new Message();
                  // message.what = 1;
                  // handler.sendMessage(message);
                  timerHandler.post(
                      new Runnable() {
                        @Override
                        public void run() {
                          // TODO Auto-generated method stub
                          // 恢复点击
                          rightLayout.setEnabled(true);
                        }
                      });
                }
              },
              1000);

          /** **************** */
          // // 做非空判断
          // if (data != null) {
          // Uri uri = data.getData();
          // try {
          // ContentResolver cr = this.getContentResolver();
          // if (uri.toString().endsWith(".png")
          // || uri.toString().endsWith(".jpg")
          // || "image/jpeg".equals(cr.getType(uri))
          // || "image/png".equals(cr.getType(uri))) {
          // // 压缩存储
          // int[] screenSize1 = getScreenSize();
          // String fileRealPath = getRealPathFromURI(uri);
          // if (fileRealPath != null
          // && FileUtil.tempToLocalPath(fileRealPath,
          // tmpImageName, screenSize1[0],
          // screenSize1[1])) {
          // filterImage(FileUtil.BIG_IMAGE_PATH
          // + tmpImageName, true);
          // }
          // } else {
          //
          // }
          //
          // } catch (Exception e) {
          // e.printStackTrace();
          // }
          // }
          break;

          // 删除选中的照片
        case PHOTO_DELETE:
          if (data.hasExtra(PublisPhotoHandelActivity.INTENT_KEY_DELETE_URL)) {
            String tmpFilePath =
                data.getStringExtra(PublisPhotoHandelActivity.INTENT_KEY_DELETE_URL);
            deleteNewsImageView(tmpFilePath);
          }
          break;
      }
    } else {
      // 恢复点击
      rightLayout.setEnabled(true);
    }

    // 地理位置
    if (resultCode == LOCATION_SELECT) {
      String location = data.getStringExtra("location");
      if (null != location && !"".equals(location)) {
        locationString = location;
        choiceLocationTextView.setText(location);
      } else {
        locationString = "";
        choiceLocationTextView.setText("告诉我你在哪里....");
      }
    }
  }