Ejemplo n.º 1
0
 private void sendPrepare() {
   String postT = parentObj.getString("Subject", "");
   String postC = postContent.getText().toString();
   if (postC.length() == 0) {
     postContent.requestFocus();
     UI.toast("内容不能为空");
     return;
   }
   File upload = null;
   /*if (frame.getVisibility() == View.VISIBLE) {
   	Bitmap bitmap = null;
   	try {
   		if (contentUri != null) {
   			bitmap = resizeBitmap(getContentResolver(), contentUri, 400, 300);
   		} else if (outputFileUri != null) {
   			bitmap = resizeBitmap(outputFileUri, 400, 300);
   		}
   	} catch (FileNotFoundException e) {}
   	if (bitmap == null) {
   		UI.toast("图片已经不存在,请重新选择");
   		return;
   	}
   	upload = new File(MainApp.getOutCacheDir(), TEMP_IMAGE);
   	try {
   		FileOutputStream out = new FileOutputStream(upload);
   		bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
   	} catch (Exception e) { e.printStackTrace(); }
   }*/
   sendNow(postT, postC, upload);
 }
Ejemplo n.º 2
0
  private void initAllData(Intent intent) {

    String obj = intent.getStringExtra(EXTRA_OBJ);
    try {
      JSONObject json = new JSONObject(obj);
      parentObj = new JSONObjectExt(json);
      String subject = parentObj.getString("Subject", "");
      mChildCount = parentObj.getInt("ChildCount", 0);
      mChildCount = intent.getIntExtra(EXTRA_CNT, mChildCount);
      title.setText(subject);
    } catch (JSONException e) {
      finish();
      UI.toast("无法加载内容");
      e.printStackTrace();
      return;
    }

    mPID = intent.getLongExtra(EXTRA_PID, 0l);
    mCount = 12;
    mReachEnd = false;
    cachedData = new DataArray(null);
    adapter.notifyDataSetChanged();

    onLoadMore(false);
  }
Ejemplo n.º 3
0
 public DataItem(JSONObject j) {
   json = new JSONObjectExt(j);
   id = json.getLong("Id", -1l);
   date = json.getString("Timestamp", Utils.DATETIME.format(new Date()));
 }
Ejemplo n.º 4
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      if (position == 0) {
        if (topicView == null) {
          topicView = View.inflate(UI.getActivity(), R.layout.forum_item, null);
          topicView.setBackgroundColor(0xddffffff);
          topicView.setPadding(0, 0, 0, 0);
          convertView = topicView;
          JSONObjectExt json = parentObj;

          String subject = json.getString("Subject", "");
          String content = json.getString("Content", "");
          String time = json.getString("Timestamp", "");
          String photourl = json.getString("PhotoUrl", null);
          TextView tv = (TextView) convertView.findViewById(R.id.forum_subject);
          tv.setText(subject);
          tv = (TextView) convertView.findViewById(R.id.forum_content);
          tv.setText(content);
          tv = (TextView) convertView.findViewById(R.id.forum_time);
          tv.setText(time);

          final ImageView iv = (ImageView) convertView.findViewById(R.id.forum_image);

          if (photourl == null) {
            topicView.findViewById(R.id.forum_image_frame).setVisibility(View.GONE);
          } else {
            // photourl = Request.HOST + photourl;
            photourl = Request.getImageUrl(photourl, 0);
            final Uri uri = Uri.parse(photourl);
            topicView.findViewById(R.id.forum_image_frame).setVisibility(View.VISIBLE);
            Bitmap bitmap = null;
            bitmap =
                imageManager.loadImage(
                    new HttpImageManager.LoadRequest(
                        uri,
                        iv,
                        new HttpImageManager.OnLoadResponseListener() {

                          @Override
                          public void onLoadResponse(LoadRequest r, final Bitmap data) {}

                          @Override
                          public void onLoadProgress(
                              LoadRequest r, long totalContentSize, long loadedContentSize) {}

                          @Override
                          public void onLoadError(LoadRequest r, Throwable e) {
                            iv.setImageResource(R.color.transparent);
                          }

                          @Override
                          public boolean onBeforeSetImageBitmap(ImageView v, Bitmap data) {
                            showBitmapForView(v, data);
                            return false;
                          }
                        }),
                    true);
            if (bitmap != null) {
              showBitmapForView(iv, bitmap);
            }
          }
        }
        convertView = topicView;
        TextView tv = (TextView) convertView.findViewById(R.id.forum_child_count);
        tv.setText(mChildCount + "条回复");
        return convertView;
      }

      final DataItem g = (DataItem) getItem(position);
      if (convertView == null || convertView == topicView) {
        convertView = View.inflate(UI.getActivity(), R.layout.forum_feedback_item, null);
      }
      // animation begin ---------------
      if (position == Math.max(0, getCount() - mCount) && !mReachEnd) {
        onLoadMore(false);
      }
      // animation end --------------

      JSONObjectExt json = g.json;

      String content = json.getString("Content", "");

      TextView tv = (TextView) convertView.findViewById(R.id.subitem_content);
      tv.setText(content);
      tv = (TextView) convertView.findViewById(R.id.subitem_time);
      tv.setText(g.date);

      // View divider = convertView.findViewById(R.id.subitem_divider);

      /*if (position != 1) {
      	divider.setVisibility(View.VISIBLE);
      } else {
      	divider.setVisibility(View.GONE);
      }*/

      return convertView;
    }