@@ -82,28 +82,30 @@ public class MomentActivity extends BaseHttpListActivity<CommentItem, CommentAda
8282 * @return
8383 */
8484 public static Intent createIntent (Context context , long momentId , boolean showKeyboard ) {
85- return createIntent (context , momentId , showKeyboard , 0 , null );
85+ return createIntent (context , momentId , showKeyboard , 0 , 0 , null );
8686 }
8787 /**启动这个Activity的Intent
8888 * @param context
8989 * @param momentId
9090 * @param toCommentId
91+ * @param toUserId
9192 * @param toUserName
9293 * @return
9394 */
94- public static Intent createIntent (Context context , long momentId , long toCommentId , String toUserName ) {
95- return createIntent (context , momentId , toCommentId > 0 , toCommentId , toUserName );
95+ public static Intent createIntent (Context context , long momentId , long toCommentId , long toUserId , String toUserName ) {
96+ return createIntent (context , momentId , toCommentId > 0 , toCommentId , toUserId , toUserName );
9697 }
9798 /**启动这个Activity的Intent
9899 * @param context
99100 * @param momentId
100101 * @param showKeyboard
101102 * @param toCommentId
103+ * @param toUserId
102104 * @param toUserName
103105 * @return
104106 */
105107 public static Intent createIntent (Context context , long momentId , boolean showKeyboard
106- , long toCommentId , String toUserName ) {
108+ , long toCommentId , long toUserId , String toUserName ) {
107109 return new Intent (context , MomentActivity .class ).
108110 putExtra (INTENT_MOMENT_ID , momentId ).
109111 putExtra (INTENT_SHOW_KEYBOARD , showKeyboard ).
@@ -214,13 +216,13 @@ public void refreshAdapter() {
214216 * @param toCommentItem
215217 */
216218 public void showInput (CommentItem toCommentItem_ ) {
217- showInput (toCommentItem_ , -1 );
219+ showInput (toCommentItem_ , -1 , - 1 );
218220 }
219221 /**显示输入评论
220222 * @param toCommentItem
221223 * @param position
222224 */
223- public void showInput (CommentItem toCommentItem_ , final int position ) {
225+ public void showInput (CommentItem toCommentItem_ , final int position , final int index ) {
224226 this .toCommentItem = toCommentItem_ ;
225227 final long toCommentId = toCommentItem == null ? 0 : toCommentItem .getComment ().getId ();
226228 runUiThread (new Runnable () {
@@ -306,14 +308,15 @@ public void run() {
306308 /**发送评论(回复)
307309 */
308310 public void sendComment () {
309- long toCommentId = toCommentItem == null ? -1 : toCommentItem .getId ();
310311 String content = StringUtil .getTrimedString (etMomentInput );
311312 if (StringUtil .isNotEmpty (content , true ) == false ) {
312313 showShortToast ("请先输入评论" );
313314 return ;
314315 }
316+ long toCommentId = toCommentItem == null ? 0 : toCommentItem .getId ();
317+ long toUserId = toCommentId <= 0 ? 0 : toCommentItem .getUserId ();
315318
316- HttpRequest .addComment (momentId , toCommentId , content , toCommentId <= 0 ? HTTP_COMMENT : HTTP_REPLY , this );
319+ HttpRequest .addComment (momentId , toCommentId , toUserId , content , toCommentId <= 0 ? HTTP_COMMENT : HTTP_REPLY , this );
317320
318321 hideKeyboard ();
319322 }
@@ -356,6 +359,7 @@ public void getListAsync(final int page) {
356359 HttpRequest .getCommentList (momentId , 4 , page , -page , this );
357360 }
358361
362+ //TODO 还是直接在Request中获取childList?
359363 @ Override
360364 public List <CommentItem > parseArray (String json ) {
361365 List <CommentItem > list = JSON .parseArray (new JSONResponse (json ).getArray (
@@ -391,7 +395,7 @@ public List<CommentItem> parseArray(String json) {
391395 if (childList == null ) {
392396 childList = new ArrayList <>();
393397 }
394- child .setToUser (parent .getUser ());
398+ child .setToUser (parent .getUser ());//TODO 不一定是parent的User
395399 childList .add (child );
396400
397401 parent .setChildList (childList );
@@ -484,7 +488,7 @@ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, l
484488 });
485489 }
486490
487- private void onComemntItemClick (int position ,boolean isLong ) {
491+ private void onComemntItemClick (int position , boolean isLong ) {
488492 if (adapter == null ){
489493 return ;
490494 }
@@ -493,7 +497,11 @@ private void onComemntItemClick(int position,boolean isLong) {
493497 return ;
494498 }
495499
496- CommentItem item = adapter .getItem (position );
500+ onCommentClick (adapter .getItem (position ), position , -1 , isLong );
501+ }
502+
503+ @ Override
504+ public void onCommentClick (CommentItem item , int position , int index , boolean isLong ) {
497505 if (isLong ) {
498506 if (item == null || momentItem == null ) {
499507 return ;
@@ -505,13 +513,8 @@ private void onComemntItemClick(int position,boolean isLong) {
505513 }
506514 new AlertDialog (context , null , "删除这条评论?" , true , DIALOG_DELETE_COMMENT , MomentActivity .this ).show ();
507515 } else {
508- showInput (item , position );
509- }
510- }
511-
512- @ Override
513- public void onCommentClick (CommentItem cb ) {
514-
516+ showInput (item , position , index );
517+ }
515518 }
516519
517520 private static final int DIALOG_DELETE_COMMENT = 1 ;
0 commit comments