d onPostSuccess(Context context) { super.onPostSuccess(context); ArrayList<GroupPhotoItem> photos = new ArrayList<>(); photos.add(currentPhotoItem); updatePhotoPaidUI(); DBService.getInstance(getApplicationContext()).addGroupPhotoList(photos); } }; getPhotoOrderInfoTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), UrlContainer.BOUGHT_PHOTO_URL); } private void clickGetPhoto(String type){ if(type.equals(PAY_TYPE_NO_MARK)){ if(!TextUtils.isEmpty(currentPhotoItem.mediumPhotoUrl)){ jumpWhenPaid(); return; } }else if(type.equals(PAY_TYPE_ORIGIN)){ if(!TextUtils.isEmpty(currentPhotoItem.rawPhotoUrl)){ jumpWhenPaid(); return; } } doGetPrice(type); } private void doGetPrice(final String type) { if (getPriceTask != null && getPriceTask.getStatus() == AsyncTask.Status.RUNNING) { getPriceTask.cancel(true); } HashMap<String, String> params = new HashMap<>(); params.put("photo_id", currentPhotoItem.photoId); params.put("user_id", Preferences.getInstance(this).getUserId()); params.put("photo_type",type); getPriceTask = new HttpPostTask(this, params) { int price = 0; @Override protected boolean parseResponse(Context context, String response) { try { JSONObject json = new JSONObject(response); int status = json.getInt("status"); if (status == 200) { JSONObject info = json.getJSONObject("data"); price = info.getInt("price"); LogHelper.d(TAG, " doGetPrice parseResponse status ok and price="+price); return true; } } catch (Exception e) { LogHelper.d(TAG, " doGetPrice parseResponse error :" + e); } return false; } @Override protected void onPostFail(Context context) { super.onPostFail(context); ToastUtils.showShortToast(context,R.string.get_price_fail); } @Override protected void onPostSuccess(Context context) { super.onPostSuccess(context); if(type.equals(PAY_TYPE_NO_MARK)){ getWipeWaterPrintLayout.setVisibility(View.GONE); buyWipeWaterPrintTextView.setVisibility(View.VISIBLE); buyWipeWaterPrintTextView.setNumber(price/100.0f); }else if(type.equals(PAY_TYPE_ORIGIN)){ getHDPhotoLayout.setVisibility(View.GONE); buyHDPhotoTextView.setVisibility(View.VISIBLE); buyHDPhotoTextView.setNumber(price/100.0f); } } }; getPriceTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(),UrlContainer.GET_PRICE_URL); } private void doFetchCommentListTask() { if (fetchCommentListTask != null && fetchCommentListTask.getStatus() == AsyncTask.Status.RUNNING) { fetchCommentListTask.cancel(true); } HashMap<String, String> params = new HashMap<>(); params.put("user_id", Preferences.getInstance(this).getUserId()); params.put("group_id", currentPhotoItem.groupId); params.put("photo_id", currentPhotoItem.photoId); fetchCommentListTask = new HttpPostTask(this, params) { private ArrayList<CommentBean> commentsList; @Override protected boolean parseResponse(Context context, String response) { try { JSONObject json = new JSONObject(response); int status = json.getInt("status"); if (status == 200) { LogHelper.d(TAG, " fetchCommentListTask parseResponse status ok"); JSONObject info = json.getJSONObject("data"); JSONArray commentArray = info.getJSONArray("comments"); if (commentArray != null && commentArray.length() > 0) { int len = commentArray.length(); commentsList = new ArrayList<>(); for (int k = 0; k < len; k++) { JSONObject obj = commentArray.getJSONObject(k); CommentBean bean = new CommentBean(); bean.avatarUrl = obj.getString("avatar"); bean.comment = obj.getString("comment"); bean.nickname = obj.getString("nickname"); bean.time = obj.getString("created_at"); bean.userId = obj.getString("user_id"); commentsList.add(bean); } } return true; } } catch (Exception e) { LogHelper.d(TAG, " fetchCommentListTask parseResponse error :" + e); } return false; } @Override protected void onPostFail(Context context) { super.onPostFail(context); } @Override protected void onPostSuccess(Context context) { super.onPostSuccess(context); if (commentsList != null) { photoCommentText.setText("("+String.valueOf(commentsList.size())+")"); commentListView.setVisibility(View.VISIBLE); commentArrowImg.setImageResource(R.drawable.arrow_up); CommentListAdapter adapter = new CommentListAdapter(PhotoDetailsActivity.this, commentsList); commentListView.setAdapter(adapter); } } }; fetchCommentListTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(),UrlContainer.PHOTO_COMMENT_LIST_URL); } private void doFetchThumbListTask() { if (fetchThumbUpListTask != null && fetchThumbUpListTask.getStatus() == AsyncTask.Status.RUNNING) { fetchThumbUpListTask.cancel(true); } HashMap<String, String> params = new HashMap<>(); params.put("user_id", Preferences.getInstance(this).getUserId()); params.put("group_id", currentPhotoItem.groupId); params.put("photo_id", currentPhotoItem.photoId); fetchThumbUpListTask = new HttpPostTask(this, params) { private ArrayList<CommentBean> thumbupList; @Override protected boolean parseResponse(Context context, String response) { try { JSONObject json = new JSONObject(response); int status = json.getInt("status"); if (status == 200) { LogHelper.d(TAG, " fetchThumbUpListTask parseResponse status ok"); JSONObject info = json.getJSONObject("data"); thumbupList = new ArrayList<>(); JSONArray commentArray = info.getJSONArray("thumbups"); if (commentArray != null && commentArray.length() > 0) { int len = commentArray.length(); for (int k = 0; k < len; k++) { JSONObject obj = commentArray.getJSONObject(k); CommentBean bean = new CommentBean(); bean.avatarUrl = obj.getString("avatar"); bean.nickname = obj.getString("nickname"); bean.userId = obj.getString("user_id"); thumbupList.add(bean); } } return true; } } catch (Exception e) { LogHelper.d(TAG, " fetchThumbUpListTask parseResponse error :" + e); } return false; } @Override protected void onPostFail(Context context) { super.onPostFail(context); } @Override protected void onPostSuccess(Context context) { super.onPostSuccess(context); if(thumbupList.size()>0){ photoThumbupText.setText("("+String.valueOf(thumbupList.size())+")"); thumbAvatarsLayout.setVisibility(View.VISIBLE); thumbArrowImg.setImageResource(R.drawable.arrow_up); thumbAvatarsLayout.removeAllViews(); for(CommentBean bean : thumbupList){ RoundedImageView avatar = new RoundedImageView(context); avatar.setBorderWidth((float)DeviceUtils.dip2px(context, 1)); avatar.setBorderColor(Color.parseColor("#F7F7F7")); avatar.setCornerRadius(DeviceUtils.dip2px(context, 5)); thumbAvatarsLayout.addView(avatar); PhotoLoader.getInstance(context).displayImage(bean.avatarUrl, avatar,PhotoLoader.getUserAvatarOptions()); ViewGroup.LayoutParams params = avatar.getLayoutParams(); params.width = DeviceUtils.dip2px(context,40); params.height = DeviceUtils.dip2px(context,40); avatar.setLayoutParams(params); avatar.setPadding(DeviceUtils.dip2px(context, 6),0,DeviceUtils.dip2px(context, 6),DeviceUtils.dip2px(context, 12)); } } } }; fetchThumbUpListTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), UrlContainer.PHOTO_LIKE_LIST_URL); } private String processingThumbPhotoId; private void doPhotoThumbUpTask() { if(currentPhotoItem.thumbUp){ ToastUtils.showShortToast(this,R.string.already_thumb_up); return; } if(currentPhotoItem.photoId.equals(processingThumbPhotoId)){ return; } if (submitThumbUpTask != null && submitThumbUpTask.getStatus() == AsyncTask.Status.RUNNING) { submitThumbUpTask.cancel(true); } HashMap<String, String> params = new HashMap<>(); params.put("user_id", Preferences.getInstance(this).getUserId()); params.put("group_id", currentPhotoItem.groupId); params.put("photo_id", currentPhotoItem.photoId); processingThumbPhotoId = currentPhotoItem.photoId; submitThumbUpTask = new HttpPostTask(this, params) { @Override protected boolean parseResponse(Context context, String response) { try { JSONObject json = new JSONObject(response); int status = json.getInt("status"); if (status == 200) { LogHelper.d(TAG, " submitThumbUpTask parseResponse status ok"); return true; } } catch (Exception e) { LogHelper.d(TAG, " submitThumbUpTask parseResponse error :" + e); } return false; } @Override protected void onPostFail(Context context) { super.onPostFail(context); processingThumbPhotoId = null; ToastUtils.showShortToast(getApplicationContext(),R.string.photo_like_fail); } @Override protected void onPostSuccess(Context context) { super.onPostSuccess(context); photoThumbupText.setText("("+String.valueOf(currentPhotoItem.commentNum+1)+")"); if(processingThumbPhotoId!=null && currentPhotoItem!=null && processingThumbPhotoId.equals(currentPhotoItem.photoId)){ currentPhotoItem.thumbUp = true; } processingThumbPhotoId = null; doFetchThumbListTask(); } }; submitThumbUpTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), UrlContainer.PHOTO_LIKE_URL); } private void doPhotoCommentTask(String comment) { if(TextUtils.isEmpty(comment)){ return; } if (submitCommentTask != null && submitCommentTask.getStatus() == AsyncTask.Status.RUNNING) { submitCommentTask.cancel(true); } HashMap<String, String> params = new HashMap<>(); params.put("user_id", Preferences.getInstance(this).getUserId()); params.put("group_id", currentPhotoItem.groupId); params.put("photo_id", currentPhotoItem.photoId); params.put("comment", comment); submitCommentTask = new HttpPostTask(this, params) { @Override protected boolean parseResponse(Context context, String response) { try { JSONObject json = new JSONObject(response); int status = json.getInt("status"); if (status == 200) { LogHelper.d(TAG, " submitCommentTask parseResponse status ok"); return true; } } catch (Exception e) { LogHelper.d(TAG, " submitCommentTask parseResponse error :" + e); } return false; } @Override protected void onPostFail(Context context) { super.onPostFail(context); ToastUtils.showShortToast(getApplicationContext(),R.string.photo_comment_fail); } @Override protected void onPostSuccess(Context context) { super.onPostSuccess(context); photoCommentText.setText("("+String.valueOf(currentPhotoItem.commentNum+1)+")"); doFetchCommentListTask(); } }; submitCommentTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(),UrlContainer.PHOTO_COMMENT_URL); } @Override public void onResult(String transaction,int code) { switch (code){ case BaseResp.ErrCode.ERR_OK: jumpWhenPaid(); break; case BaseResp.ErrCode.ERR_AUTH_DENIED: case BaseResp.ErrCode.ERR_COMM: case BaseResp.ErrCode.ERR_SENT_FAILED: case BaseResp.ErrCode.ERR_UNSUPPORT: ToastUtils.showShortToast(getApplicationContext(),R.string.wx_pay_check); doCheckOrder(transaction); break; case BaseResp.ErrCode.ERR_USER_CANCEL: break; } } private void jumpWhenPaid(){ Intent intent = new Intent(this, PaidPhotoActivity.class); intent.putExtra("photo_item",currentPhotoItem); startActivity(intent); } } Kodo/kodo - Gogs: Go Git Service

1 次代碼提交 (5a8859fa5e6eaf7ae582c526897a66b92e82382e)

作者 SHA1 備註 提交日期
  Brightcells 3114315824 add pc official website 10 年之前