示例#1
0
 protected void sharePost() {
   if (null == post) {
     return;
   }
   mShareService.setShareContent(post.getTalkTitle());
   if (null != post.getMobilePic() || 10 < post.getMobilePic().length()) {
     mShareService.setShareMedia(new UMImage(this, post.getMobilePic()));
   }
   mShareService.openShare(this, false);
 }
示例#2
0
 private void getPostMark() {
   if (mApplication.isLogin()) {
     RequestParams params = new RequestParams();
     params.put("userId", mApplication.getUser().getId() + "");
     params.put("talkId", post.getId() + "");
     String url =
         getString(R.string.interface_domainName) + getString(R.string.interface_getpostmark);
     mClient.get(
         url,
         params,
         new JsonHttpResponseHandler() {
           @Override
           public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
             // TODO Auto-generated method stub
             super.onSuccess(statusCode, headers, response);
             if (null != response && response.has("state")) {
               try {
                 if (response.getString("state").equalsIgnoreCase("ok")) {
                   String result = response.getString("msg");
                   if (-1 < result.indexOf("dashang")) {
                     isReward = true;
                   }
                   if (-1 < result.indexOf("collect")) {
                     isCollect = true;
                   }
                   setButtonFunction();
                 }
               } catch (Exception e) {
                 // TODO: handle exception
               }
             }
           }
         });
   }
 }
示例#3
0
  private void configPlatforms() {
    String targetUrl = "http://www.mckuai.com/thread-" + post.getId() + ".html";
    String title = "麦块for我的世界盒子";
    String context = post.getTalkTitle();
    UMImage image;
    if (null != post.getMobilePic() && 10 < post.getMobilePic().length()) {
      image = new UMImage(this, post.getMobilePic());
    } else {
      image = new UMImage(this, R.drawable.icon_share_default);
    }

    String appID_QQ = "101155101";
    String appAppKey_QQ = "78b7e42e255512d6492dfd135037c91c";
    // 添加qq
    UMQQSsoHandler qqSsoHandler = new UMQQSsoHandler(this, appID_QQ, appAppKey_QQ);
    qqSsoHandler.setTargetUrl(targetUrl);
    qqSsoHandler.setTitle(title);
    qqSsoHandler.addToSocialSDK();
    // 添加QQ空间参数
    QZoneSsoHandler qZoneSsoHandler = new QZoneSsoHandler(this, appID_QQ, appAppKey_QQ);
    qZoneSsoHandler.setTargetUrl(targetUrl);
    qZoneSsoHandler.addToSocialSDK();

    String appIDWX = "wx49ba2c7147d2368d";
    String appSecretWX = "85aa75ddb9b37d47698f24417a373134";
    // 添加微信
    UMWXHandler wxHandler = new UMWXHandler(this, appIDWX, appSecretWX);
    wxHandler.setTargetUrl(targetUrl);
    wxHandler.setTitle(title);
    wxHandler.showCompressToast(false);
    wxHandler.addToSocialSDK();
    // 添加微信朋友圈
    UMWXHandler wxCircleHandler = new UMWXHandler(this, appIDWX, appSecretWX);
    wxCircleHandler.setToCircle(true);
    wxCircleHandler.setTargetUrl(targetUrl);
    wxHandler.showCompressToast(false);
    wxCircleHandler.setTitle(title);
    wxCircleHandler.addToSocialSDK();
    // 移除多余平台
    mShareService.getConfig().removePlatform(SHARE_MEDIA.TENCENT, SHARE_MEDIA.SINA);
    // 添加内容和图片
    mShareService.setShareContent(context);
    mShareService.setShareMedia(image);
  }
示例#4
0
 private void showPost() {
   if (null != post) {
     if (!isShowPost) {
       reply_layout.setVisibility(View.GONE);
       post_layout.setVisibility(View.VISIBLE);
       isShowPost = true;
     }
     tv_title.setText(getString(R.string.post_title));
     url = getString(R.string.interface_domainName) + getString(R.string.interface_showPost);
     url += "&id=" + post.getId();
     webView.loadUrl(url);
   } else {
     Toast.makeText(PostActivity.this, "没有获取取帖子信息", Toast.LENGTH_SHORT).show();
   }
 }
示例#5
0
  private void collectPost() {
    if (mApplication.isLogin()) {
      String url;
      if (isCollect) {
        url =
            getString(R.string.interface_domainName)
                + getString(R.string.interface_cancle_collectpost);
      } else {
        url = getString(R.string.interface_domainName) + getString(R.string.interface_collectpost);
      }
      RequestParams params = new RequestParams();
      params.put("userId", mApplication.getUser().getId());
      params.put("talkId", post.getId());
      mClient.get(
          url,
          params,
          new JsonHttpResponseHandler() {
            @Override
            public void onStart() {
              // TODO Auto-generated method stub
              super.onStart();
              if (isCollect) {
                popupLoadingToast("正在取消收藏...");
              } else {
                popupLoadingToast("正在添加到背包...");
              }
            }

            @Override
            public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
              // TODO Auto-generated method stub
              super.onSuccess(statusCode, headers, response);
              if (response.has("state")) {
                try {
                  // Log.e(TAG, response.toString());
                  if (response.getString("state").equalsIgnoreCase("ok")) {
                    if (isCollect) {
                      Toast.makeText(PostActivity.this, "取消关注成功!", Toast.LENGTH_SHORT).show();
                    } else {
                      Toast.makeText(PostActivity.this, "帖子关注成功,可在背包中看到!", Toast.LENGTH_SHORT)
                          .show();
                    }
                    cancleLodingToast(true);
                    // btn_collect.setEnabled(false);
                    isCollect = !isCollect;
                    setButtonFunction();
                    return;
                  } else {
                    Toast.makeText(PostActivity.this, "操作失败!", Toast.LENGTH_LONG).show();
                    cancleLodingToast(false);
                    return;
                  }
                } catch (JSONException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                  cancleLodingToast(false);
                  // showNotification("自动收获机器被熊孩子玩坏了!");
                  showNotification(1, "操作失败!", R.id.rl_post);
                }
              }
            }

            @Override
            public void onFailure(
                int statusCode, Header[] headers, String responseString, Throwable throwable) {
              // TODO Auto-generated method stub
              super.onFailure(statusCode, headers, responseString, throwable);
              cancleLodingToast(false);
              //					Toast.makeText(PostActivity.this, "收藏失败,原因:" + throwable.getLocalizedMessage(),
              // Toast.LENGTH_SHORT)
              //							.show();
              showNotification(1, "收藏失败!", R.id.rl_post);
            }
          });
    } else {
      callLogin(COLLECT_POST);
    }
  }
示例#6
0
  private void rewardPost() {
    if (mApplication.isLogin()) {
      String url = getString(R.string.interface_domainName) + getString(R.string.interface_reward);
      RequestParams params = new RequestParams();
      params.put("userId", mApplication.getUser().getId());
      params.put("talkId", post.getId());
      mClient.post(
          url,
          params,
          new JsonHttpResponseHandler() {
            @Override
            public void onStart() {
              // TODO Auto-generated method stub
              super.onStart();
              popupLoadingToast("正在打赏楼主!");
            }

            /*
             * (non-Javadoc)
             *
             * @see
             * com.loopj.android.http.JsonHttpResponseHandler#onSuccess(int,
             * org.apache.http.Header[], org.json.JSONObject)
             */
            @Override
            public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
              // TODO Auto-generated method stub
              super.onSuccess(statusCode, headers, response);
              try {
                if (response.has("state") && response.getString("state").equalsIgnoreCase("ok")) {
                  showNotification(1, "打赏成功!楼主获得了1个钻石", R.id.rl_post);
                  //							Toast.makeText(PostActivity.this, "打赏成功!\n楼主获得了1个钻石",
                  // Toast.LENGTH_SHORT).show();
                  cancleLodingToast(true);
                  isReward = true;
                  setButtonFunction();
                  return;
                } else {
                  showNotification(1, "打赏失败!", R.id.rl_post);
                  //							Toast.makeText(PostActivity.this, "打赏失败!原因:" + response.getString("msg"),
                  //									Toast.LENGTH_SHORT).show();
                  cancleLodingToast(false);
                  return;
                }
              } catch (Exception e) {
                // TODO: handle exception
                e.printStackTrace();
              }
              showNotification(1, "打赏失败!", R.id.rl_post);
              //					Toast.makeText(PostActivity.this, "打赏失败!", Toast.LENGTH_SHORT).show();
              cancleLodingToast(false);
            }

            /*
             * (non-Javadoc)
             *
             * @see
             * com.loopj.android.http.JsonHttpResponseHandler#onFailure(int,
             * org.apache.http.Header[], java.lang.String,
             * java.lang.Throwable)
             */
            @Override
            public void onFailure(
                int statusCode, Header[] headers, String responseString, Throwable throwable) {
              // TODO Auto-generated method stub
              super.onFailure(statusCode, headers, responseString, throwable);
              showNotification(1, "操作失败!", R.id.rl_post);
              //					Toast.makeText(PostActivity.this, "操作失败!原因:" + throwable.getLocalizedMessage(),
              // Toast.LENGTH_SHORT)
              //							.show();
              cancleLodingToast(false);
            }
          });
    } else {
      callLogin(REWARD_POST);
    }
  }