61
61
import androidx .appcompat .app .AlertDialog ;
62
62
import androidx .appcompat .app .AppCompatActivity ;
63
63
import androidx .appcompat .widget .AppCompatImageButton ;
64
- import androidx .appcompat .widget .AppCompatImageView ;
65
64
import androidx .core .content .ContextCompat ;
66
65
import androidx .core .content .FileProvider ;
67
66
import androidx .core .view .ContentInfoCompat ;
@@ -499,7 +498,7 @@ public void onResume() {
499
498
500
499
mRefresher .setRefreshing (false );
501
500
502
- updateFormValues (args );
501
+ updateFormValues ();
503
502
activity .sendNoteRead (0 );
504
503
}
505
504
@@ -726,7 +725,7 @@ public void onLongPress(MotionEvent e) {
726
725
return audio ;
727
726
}
728
727
729
- private void updateFormValues (Bundle args ) {
728
+ private void updateFormValues () {
730
729
if (!isAdded ()) {
731
730
return ;
732
731
}
@@ -762,20 +761,6 @@ private void updateFormValues(Bundle args) {
762
761
acs .isReader (Acs .Side .GIVEN ) ? View .GONE : View .VISIBLE );
763
762
}
764
763
765
- if (args != null ) {
766
- mMessageToSend = args .getString (MESSAGE_TO_SEND );
767
- mReplySeqID = args .getInt (MESSAGE_REPLY_ID );
768
- mReply = (Drafty ) args .getSerializable (MESSAGE_REPLY );
769
- mContentToForward = (Drafty ) args .getSerializable (ForwardToFragment .CONTENT_TO_FORWARD );
770
- mForwardSender = (Drafty ) args .getSerializable (ForwardToFragment .FORWARDING_FROM_USER );
771
- // Clear used arguments.
772
- args .remove (MESSAGE_TO_SEND );
773
- args .remove (MESSAGE_REPLY_ID );
774
- args .remove (MESSAGE_REPLY );
775
- args .remove (ForwardToFragment .CONTENT_TO_FORWARD );
776
- args .remove (ForwardToFragment .FORWARDING_FROM_USER );
777
- }
778
-
779
764
if (!mTopic .isWriter () || mTopic .isBlocked () || mTopic .isDeleted ()) {
780
765
setSendPanelVisible (activity , R .id .sendMessageDisabled );
781
766
} else if (mContentToForward != null ) {
@@ -1138,7 +1123,7 @@ public PromisedReply<ServerMessage> onSuccess(ServerMessage result) {
1138
1123
intent .addFlags (Intent .FLAG_ACTIVITY_REORDER_TO_FRONT );
1139
1124
startActivity (intent );
1140
1125
} else {
1141
- activity .runOnUiThread (() -> updateFormValues (null ));
1126
+ activity .runOnUiThread (() -> updateFormValues ());
1142
1127
}
1143
1128
return null ;
1144
1129
}
@@ -1155,7 +1140,7 @@ public PromisedReply<ServerMessage> onSuccess(ServerMessage result) {
1155
1140
@ SuppressLint ("NotifyDataSetChanged" )
1156
1141
void notifyDataSetChanged (boolean meta ) {
1157
1142
if (meta ) {
1158
- updateFormValues (null );
1143
+ updateFormValues ();
1159
1144
} else {
1160
1145
mMessagesAdapter .notifyDataSetChanged ();
1161
1146
}
@@ -1361,14 +1346,35 @@ private void showContentToForward(Activity activity, Drafty sender, Drafty conte
1361
1346
}
1362
1347
1363
1348
void topicChanged (String topicName , boolean reset ) {
1349
+ boolean changed = (mTopicName == null || !mTopicName .equals (topicName ));
1364
1350
mTopicName = topicName ;
1365
1351
if (mTopicName != null ) {
1366
1352
//noinspection unchecked
1367
1353
mTopic = (ComTopic <VxCard >) Cache .getTinode ().getTopic (mTopicName );
1368
1354
} else {
1369
1355
mTopic = null ;
1370
1356
}
1371
- updateFormValues (getArguments ());
1357
+
1358
+ if (changed ) {
1359
+ Bundle args = getArguments ();
1360
+ if (args != null ) {
1361
+ mMessageToSend = args .getString (MESSAGE_TO_SEND );
1362
+ mReplySeqID = args .getInt (MESSAGE_REPLY_ID );
1363
+ mReply = (Drafty ) args .getSerializable (MESSAGE_REPLY );
1364
+ mContentToForward = (Drafty ) args .getSerializable (ForwardToFragment .CONTENT_TO_FORWARD );
1365
+ mForwardSender = (Drafty ) args .getSerializable (ForwardToFragment .FORWARDING_FROM_USER );
1366
+ Log .i (TAG , "topicChanged " + mContentToForward , new Exception ("stacktrace" ));
1367
+
1368
+ // Clear used arguments.
1369
+ args .remove (MESSAGE_TO_SEND );
1370
+ args .remove (MESSAGE_REPLY_ID );
1371
+ args .remove (MESSAGE_REPLY );
1372
+ args .remove (ForwardToFragment .CONTENT_TO_FORWARD );
1373
+ args .remove (ForwardToFragment .FORWARDING_FROM_USER );
1374
+ }
1375
+ }
1376
+
1377
+ updateFormValues ();
1372
1378
if (reset ) {
1373
1379
runMessagesLoader (mTopicName );
1374
1380
}
@@ -1404,7 +1410,7 @@ public ContentInfoCompat onReceiveContent(@NonNull View view, @NonNull ContentIn
1404
1410
Operation op = AttachmentHandler .enqueueMsgAttachmentUploadRequest (activity ,
1405
1411
AttachmentHandler .ARG_OPERATION_IMAGE , args );
1406
1412
if (op != null ) {
1407
- op .getResult ().addListener ((Runnable ) ( ) -> {
1413
+ op .getResult ().addListener (() -> {
1408
1414
if (activity .isFinishing () || activity .isDestroyed ()) {
1409
1415
return ;
1410
1416
}
0 commit comments