public static void pubSoftWareTweet(Tweet tweet, int softid, AsyncHttpResponseHandler handler) {
   RequestParams params = new RequestParams();
   params.put("uid", tweet.getAuthorid());
   params.put("msg", tweet.getBody());
   params.put("project", softid);
   ApiHttpClient.post("action/api/software_tweet_pub", params, handler);
 }
 /**
  * 获取动弹详情
  *
  * @param tweet_id
  * @return
  * @throws AppException
  */
 public Tweet getTweet(int tweet_id, boolean isRefresh) throws AppException {
   Tweet tweet = null;
   String key = "tweet_" + tweet_id;
   if (isNetworkConnected() && (!isReadDataCache(key) || isRefresh)) {
     try {
       tweet = ApiClient.getTweetDetail(this, tweet_id);
       if (tweet != null) {
         Notice notice = tweet.getNotice();
         tweet.setNotice(null);
         tweet.setCacheKey(key);
         saveObject(tweet, key);
         tweet.setNotice(notice);
       }
     } catch (AppException e) {
       tweet = (Tweet) readObject(key);
       if (tweet == null) throw e;
     }
   } else {
     tweet = (Tweet) readObject(key);
     if (tweet == null) tweet = new Tweet();
   }
   return tweet;
 }
  public static void pubTweet(Tweet tweet, AsyncHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("uid", tweet.getAuthorid());
    params.put("msg", tweet.getBody());

    // Map<String, File> files = new HashMap<String, File>();
    if (!TextUtils.isEmpty(tweet.getImageFilePath())) {
      try {
        params.put("img", new File(tweet.getImageFilePath()));
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      }
    }
    if (!TextUtils.isEmpty(tweet.getAudioPath())) {
      try {
        params.put("amr", new File(tweet.getAudioPath()));
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      }
    }
    ApiHttpClient.post("action/api/tweet_pub", params, handler);
  }
Beispiel #4
0
 public void onClick(View v) {
   if (tweetDetail != null)
     UIHelper.showImageZoomDialog(v.getContext(), tweetDetail.getImgBig());
 }
Beispiel #5
0
 public void onClick(View v) {
   if (tweetDetail != null)
     UIHelper.showUserCenter(
         v.getContext(), tweetDetail.getAuthorId(), tweetDetail.getAuthor());
 }
 public static Tweet parse(InputStream inputStream) throws IOException, AppException {
   Tweet tweet = null;
   // 获得XmlPullParser解析器
   XmlPullParser xmlParser = Xml.newPullParser();
   try {
     xmlParser.setInput(inputStream, UTF8);
     // 获得解析到的事件类别,这里有开始文档,结束文档,开始标签,结束标签,文本等等事件。
     int evtType = xmlParser.getEventType();
     // 一直循环,直到文档结束
     while (evtType != XmlPullParser.END_DOCUMENT) {
       String tag = xmlParser.getName();
       switch (evtType) {
         case XmlPullParser.START_TAG:
           if (tag.equalsIgnoreCase(NODE_START)) {
             tweet = new Tweet();
           } else if (tweet != null) {
             if (tag.equalsIgnoreCase(NODE_ID)) {
               tweet.id = StringUtils.toInt(xmlParser.nextText(), 0);
             } else if (tag.equalsIgnoreCase(NODE_FACE)) {
               tweet.setFace(xmlParser.nextText());
             } else if (tag.equalsIgnoreCase(NODE_BODY)) {
               tweet.setBody(xmlParser.nextText());
             } else if (tag.equalsIgnoreCase(NODE_AUTHOR)) {
               tweet.setAuthor(xmlParser.nextText());
             } else if (tag.equalsIgnoreCase(NODE_AUTHORID)) {
               tweet.setAuthorId(StringUtils.toInt(xmlParser.nextText(), 0));
             } else if (tag.equalsIgnoreCase(NODE_COMMENTCOUNT)) {
               tweet.setCommentCount(StringUtils.toInt(xmlParser.nextText(), 0));
             } else if (tag.equalsIgnoreCase(NODE_PUBDATE)) {
               tweet.setPubDate(xmlParser.nextText());
             } else if (tag.equalsIgnoreCase(NODE_IMGSMALL)) {
               tweet.setImgSmall(xmlParser.nextText());
             } else if (tag.equalsIgnoreCase(NODE_IMGBIG)) {
               tweet.setImgBig(xmlParser.nextText());
             } else if (tag.equalsIgnoreCase(NODE_ATTACH)) {
               tweet.setAttach(xmlParser.nextText());
             } else if (tag.equalsIgnoreCase(NODE_APPCLIENT)) {
               tweet.setAppClient(StringUtils.toInt(xmlParser.nextText(), 0));
             }
             // 通知信息
             else if (tag.equalsIgnoreCase("notice")) {
               tweet.setNotice(new Notice());
             } else if (tweet.getNotice() != null) {
               if (tag.equalsIgnoreCase("atmeCount")) {
                 tweet.getNotice().setAtmeCount(StringUtils.toInt(xmlParser.nextText(), 0));
               } else if (tag.equalsIgnoreCase("msgCount")) {
                 tweet.getNotice().setMsgCount(StringUtils.toInt(xmlParser.nextText(), 0));
               } else if (tag.equalsIgnoreCase("reviewCount")) {
                 tweet.getNotice().setReviewCount(StringUtils.toInt(xmlParser.nextText(), 0));
               } else if (tag.equalsIgnoreCase("newFansCount")) {
                 tweet.getNotice().setNewFansCount(StringUtils.toInt(xmlParser.nextText(), 0));
               }
             }
           }
           break;
         case XmlPullParser.END_TAG:
           break;
       }
       // 如果xml没有结束,则导航到下一个节点
       evtType = xmlParser.next();
     }
   } catch (XmlPullParserException e) {
     throw AppException.xml(e);
   } finally {
     inputStream.close();
   }
   return tweet;
 }