@Override public void initData() { // 获取主贴id mMainId = getIntent().getLongExtra(ForumCommentActivity.INTENT_KEY_FOLLOWID, 0); mPraise_done = getIntent().getIntExtra(PostDetailActivity.INTENT_KEY_PRAISE_DONE, -1); mPraise_num = getIntent().getLongExtra(PostDetailActivity.INTENT_KEY_PRAISE_NUM, -1); mReply_num = getIntent().getLongExtra(PostDetailActivity.INTENT_KEY_REPLY_NUM, -1); if (mPraise_done != -1) { mTvComment.setText(Util.getLove(mReply_num)); mTvPraise.setText(Util.getLove(mPraise_num)); if (mPraise_done == PostEntity.C_PRAISE_DONE) { mIvPraise.setImageResource(R.drawable.big_image_like_click); } else { mIvPraise.setImageResource(R.drawable.big_image_like_normal); } } // 更多精品适配器 mLvMorePick.setAdapter(new MorePickAdapter(mContext)); // PostDetailExpandAdapter adapter = new // PostDetailExpandAdapter(mContext, mListView, null); // adapter.addFootView(vMorePick); // mListView.setAdapter(adapter); // 下载帖子详情 new PostDetailTask(false).execute(); // 恢复草稿箱 mInputBar.restorePostDraft( mEditContent, ApplicationVariable.INSTANCE.getUapUid(), mMainId, SEND_FAILED_SAVE_FILE_NAME); // 删除草稿 mInputBar.deletePostDraft( ApplicationVariable.INSTANCE.getUapUid(), mMainId, SEND_FAILED_SAVE_FILE_NAME); }
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (mInputBar != null && mInputBar.getCurrentSelectedTabId() == CommonInputBar.TAB_KEYBOARD) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { mInputBar.hideCommonInputBar(); } } return super.dispatchKeyEvent(event); }
private void savePostDraft() { if (mInputBar.isNeedSaveDraft()) { mInputBar.savePostDraft( mEditContent.getText().toString(), ApplicationVariable.INSTANCE.getUapUid(), mMainId, SEND_FAILED_SAVE_FILE_NAME); } }
// private SquareGifImageView mGifImage; // private int[] gifres = new // int[]{R.raw.g01,R.raw.g02,R.raw.g03,R.raw.g04,R.raw.g05,R.raw.g06,R.raw.g07,R.raw.g08,R.raw.g09,R.raw.g10, // R.raw.g11,R.raw.g12,R.raw.g13,R.raw.g14,R.raw.g15}; // int i = 0; // private void playGif() { // mGifImage.setGifImage(gifres[i%15]); // i++; // } @Override public void initComponent() { final View rlgif = findViewById(R.id.rlgif); rlgif.setOnClickListener(this); rlgif.setVisibility(View.GONE); // mGifImage = (SquareGifImageView) findViewById(R.id.gifimage); // mGifImage.setPlayCount(1); // mGifImage.setPlayFinishCallBack(new GifPlayFinishCallBack() { // // @Override // public void onGifPlayFinish() { // rlgif.setVisibility(View.GONE); // } // }); // playGif(); mCommonActivityTitle.hideRightBtn(); // fix BUG #57588 【48050】【论坛】当前贴子的用户不是本人时,点击删除区域,会显示弹窗 mCommonActivityTitle.setRightBtnEnabel(false); mListView = (ExpandableListView) findViewById(R.id.lv_post_detail); // 底部的更多精品 vMorePick = getLayoutInflater().inflate(R.layout.post_detail_more_pick_list, null); mBtnMore = (Button) vMorePick.findViewById(R.id.btn_more); mLvMorePick = (ListView) vMorePick.findViewById(R.id.lv_more); mListView.setGroupIndicator(null); // 点赞,评论按钮 mBottom = findViewById(R.id.ll_post_detail_bottom); mIvPraise = (ImageView) findViewById(R.id.iv_praise); mTvPraise = (TextView) findViewById(R.id.tv_post_detail_love); mTvComment = (TextView) findViewById(R.id.tv_post_detail_comment); // 点击评论后出现的输入界面 mBottomInput = findViewById(R.id.rl_input); mBtnSend = (Button) findViewById(R.id.btn_send); mEditContent = (EditText) findViewById(R.id.et_input); mInputBar = (CommonInputBar) findViewById(R.id.inputbar); mInputBar.initView(this, mEditContent); // 回复评论,只能文字 mInputTextOnly = findViewById(R.id.rl_input_textonly); mBtnSendText = (Button) mInputTextOnly.findViewById(R.id.btn_send_text); mEditText = (EditText) mInputTextOnly.findViewById(R.id.et_input_text); // 设置表情 // fix BUG #56253 // 【47954】【论坛】发布跟帖,输入几十个字后,再输入几个表情就无法输入表情了,但可以输入文字(MX3、三星s3) mInputBar.setSmileyViewParams( Smiley.TYPE_WEIBO, 0, Smileyhelper.NORMAL, new int[] {Smileyhelper.CAT, Smileyhelper.HISTORY}); mTvTip = (TextView) findViewById(R.id.tv_tip); mTvTipText = (TextView) findViewById(R.id.tv_tip_text); hideInput(); EventBus.getDefault().register(this); mActivityKey = ForumBeanConst.AC_LOADING_LEFT_POSTDETAIL; initTypeface(); }
@Override protected void onStop() { // TODO Auto-generated method stub super.onStop(); if (isOpenComment) { if (mInputBar != null && mInputBar.getCurrentSelectedTabId() == CommonInputBar.TAB_KEYBOARD) { mInputBar.hideCommonInputBar(); } } }
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mInputBar.onSaveInstanceState(outState); try { JSONObject jsonObject = mInputBar.getPostDraft(mEditContent.toString()); outState.putString("PostDraft", jsonObject.toString()); } catch (JSONException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
@Override protected void onStart() { super.onStart(); System.out.println("aaaa onStart"); if (isOpenComment) { // 判断跟帖输入框是否打开 Log.d("aa", "onStart aaaa:" + mInputBar.getCurrentSelectedTabId()); if (mInputBar.getCurrentSelectedTabId() != CommonInputBar.TAB_KEYBOARD) { // 隐藏输入法 Log.d("aa", "onStart aaaa隐藏输入法"); InputMethodUtils.hideSoftInput(mContext, mEditContent); // mListView.requestFocus(); } } }
@Override public boolean dispatchTouchEvent(MotionEvent event) { // BUG #57535 // 【发帖】发帖页面键盘弹出后,如果这时点击手机的HOME键、电源键或其他输入键盘上手机自带按钮进入其他页面,再返回到发帖页面,输入键盘会隐藏,小键盘按钮会高亮显示 if (isOpenComment) { if (event.getAction() == MotionEvent.ACTION_DOWN) { int[] l = {0, 0}; mEditContent.getLocationInWindow(l); int left = l[0], top = l[1]; int bottom = top + mEditContent.getHeight(), right = left + mEditContent.getWidth(); System.out.println( "left:" + left + "; top:" + top + ";bottom:" + bottom + ";right:" + right); if (event.getX() > left && event.getX() < right && event.getY() > top && event.getY() < bottom) { mInputBar.showCommonInputBar(); // return false; } else { InputMethodUtils.collapseSoftInputMethod(mContext, mEditContent.getWindowToken()); // return true; } } } return super.dispatchTouchEvent(event); }
@Override protected void onPause() { super.onPause(); MusicUtils.windowChange(); if (mInputBar != null) { mInputBar.stopPlayVoice(); } }
/** 隐藏输入法 */ private void hideInput() { // BUG #58725 【47997】【论坛】跟帖录音:编辑跟帖,录音点击暂停后点击非跟帖编辑区域,录音图标一直存在 mInputBar.cancelRecord(); mBottomInput.setVisibility(View.INVISIBLE); mBottom.setVisibility(View.VISIBLE); // 隐藏输入法 InputMethodUtils.hideSoftInput(mContext, mEditContent); mListView.requestFocus(); }
/** 显示输入法 */ private void showInput() { mBottomInput.setVisibility(View.VISIBLE); mBottom.setVisibility(View.INVISIBLE); // mInputBar.hideAll(); mInputBar.showCommonInputBar(); // 显示输入法 InputMethodUtils.showSoftInputMethod(mContext, mEditContent); mEditContent.requestFocus(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 回复数据 if (savedInstanceState != null) { String postDraft = (String) savedInstanceState.get("PostDraft"); JSONObject jsonObject = null; try { jsonObject = new JSONObject(postDraft); mInputBar.parsePostDraft(jsonObject, mEditContent); } catch (JSONException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } String imageFilePath = savedInstanceState.getString(CommonInputBar.CAMERAPATH); mInputBar.setPhotoFilePath(imageFilePath); } }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); mInputBar.onActivityResult(requestCode, resultCode, data); }
@Override public void onClick(View v) { int id = v.getId(); if (id == R.id.rl_post_detail_love) { // TODO点赞 if (!NetUtil.hasNet()) { return; } if (mPraise_done != -1) { if (PraiseTask.mPraiseMap.get(mMainId) == null) { PraiseTask.mPraiseMap.put(mMainId, 1); new PraiseTask(new PraiseEventBean(mMainId, mPraise_num, mPraise_done)).execute(); } else { // 操作请求中,不要频繁点击 GlobalToast.showToast(R.string.common_donnot_touchme, 0); } } } else if (id == R.id.rl_post_detail_comment) { // 评论 // TODO弹出输入框 switchMode(); } else if (id == R.id.rl_input) { switchMode(); } else if (id == R.id.btn_send) { mInputBar.cancelRecord(); // 发表跟帖 Boolean enable = (Boolean) v.getTag(); if (mEditContent == null || enable == null || !enable) { return; } else { String temp = mEditContent.getText().toString().replaceAll(" ", ""); temp = temp.replaceAll("\n", ""); if (temp.length() == 0) { GlobalToast.showToast(R.string.post_content_empty_hit, 0); return; } } new FollowTask(mMainId, mInputBar).execute(); // new SumitTopicTask(mMainPostId, mInputBar).execute(); // BUG #56254 建议:【47984】【论坛】发布跟帖-网络不可用时,提示失败信息,再点击评论按钮,之前输入的评论还保存 // clearEditText(mEditContent); switchMode(); } else if (id == R.id.et_input) { // 点击输入框 // fix BUG #57668 建议:【论坛】发表跟帖时,输入框操作会跳动影响使用体验,建议优化 if (mInputBar.getCurrentSelectedTabId() != CommonInputBar.TAB_KEYBOARD) { // mInputBar.setTabSelect(CommonInputBar.TAB_KEYBOARD); mInputBar.showCommonInputBar(); } // mInputBar.showCommonInputBar(); } else if (id == R.id.btn_more) { // 点击查看更多跟帖 // GlobalToast.showToast("全部跟帖", 0); UIHelper.showAllFollowActivity(mContext, mMainId, mFollow_num); } else if (id == R.id.rl_input_textonly) { switchTestOnlyMode(); } else if (id == R.id.btn_send_text) { String text = mEditText.getText().toString(); Boolean enable = (Boolean) v.getTag(); if (text == null || enable == null || !enable) { return; } if (!TextUtils.isEmpty(text)) { if (replyType == 1) { // 评论跟帖 ReplyFollowInfo info = new ReplyFollowInfo(mReplyFollowInfo.tid, text); new MyReplyFollowTask(info).execute(); } else if (replyType == 2) { // 回复评论 ReplyComment replyComment = new ReplyComment(mReplyInfo.oid, mReplyInfo.rid, mReplyInfo.user.uid, text); new MyReplyCommentTask(replyComment).execute(); } clearEditText(mEditText); } switchTestOnlyMode(); } else if (id == R.id.et_input_text) { if (mEditText.isFocused()) { // // ToastUtils.hideSoftInput(mContext, mEditText); // mListView.requestFocus(); } else { InputMethodUtils.showSoftInputMethod(mContext, mEditText); mEditText.requestFocus(); } } }