@@ -332,7 +332,7 @@ protected void onCollectionLoaded(Collection col) {
332
332
this .getWindow ().setSoftInputMode (WindowManager .LayoutParams .SOFT_INPUT_STATE_ALWAYS_HIDDEN );
333
333
334
334
Intent intent = getIntent ();
335
- Timber .d ("onCollectionLoaded: caller: %d" , mCaller );
335
+ Timber .d ("NoteEditor() onCollectionLoaded: caller: %d" , mCaller );
336
336
337
337
registerExternalStorageListener ();
338
338
@@ -532,7 +532,7 @@ public void onClick(View v) {
532
532
});
533
533
534
534
if (!mAddNote && mCurrentEditedCard != null ) {
535
- Timber .i ("NoteEditor:: Edit note activity successfully started with card id %d" , mCurrentEditedCard .getId ());
535
+ Timber .i ("onCollectionLoaded() Edit note activity successfully started with card id %d" , mCurrentEditedCard .getId ());
536
536
}
537
537
538
538
//set focus to FieldEditText 'first' on startup like Anki desktop
@@ -1067,19 +1067,22 @@ private void showCardTemplateEditor() {
1067
1067
// Pass the model ID
1068
1068
try {
1069
1069
intent .putExtra ("modelId" , getCurrentlySelectedModel ().getLong ("id" ));
1070
+ Timber .d ("showCardTemplateEditor() for model %s" , intent .getLongExtra ("modelId" , -1L ));
1070
1071
} catch (JSONException e ) {
1071
1072
throw new RuntimeException (e );
1072
1073
}
1073
1074
// Also pass the card ID if not adding new note
1074
1075
if (!mAddNote ) {
1075
1076
intent .putExtra ("noteId" , mCurrentEditedCard .note ().getId ());
1077
+ Timber .d ("showCardTemplateEditor() with note %s" , mCurrentEditedCard .note ().getId ());
1076
1078
}
1077
1079
startActivityForResultWithAnimation (intent , REQUEST_TEMPLATE_EDIT , ActivityTransitionAnimation .LEFT );
1078
1080
}
1079
1081
1080
1082
1081
1083
@ Override
1082
1084
protected void onActivityResult (int requestCode , int resultCode , Intent data ) {
1085
+ Timber .d ("onActivityResult() with request/result: %s/%s" , requestCode , resultCode );
1083
1086
super .onActivityResult (requestCode , resultCode , data );
1084
1087
1085
1088
if (resultCode == DeckPicker .RESULT_DB_ERROR ) {
@@ -1126,6 +1129,9 @@ else if (fieldEditText.hasFocus()) {
1126
1129
if (resultCode == RESULT_OK ) {
1127
1130
mReloadRequired = true ;
1128
1131
}
1132
+ // rebuild the model post-template-edit so we get the correct number of cards
1133
+ Timber .d ("onActivityResult() template edit - reloading model" );
1134
+ mEditorNote .reloadModel ();
1129
1135
updateCards (mEditorNote .model ());
1130
1136
break ;
1131
1137
}
@@ -1480,10 +1486,12 @@ private void updateTags() {
1480
1486
1481
1487
/** Update the list of card templates for current note type */
1482
1488
private void updateCards (JSONObject model ) {
1489
+ Timber .d ("updateCards()" );
1483
1490
try {
1484
1491
JSONArray tmpls = model .getJSONArray ("tmpls" );
1485
1492
String cardsList = "" ;
1486
1493
// Build comma separated list of card names
1494
+ Timber .d ("updateCards() template count is %s" , tmpls .length ());
1487
1495
for (int i = 0 ; i < tmpls .length (); i ++) {
1488
1496
String name = tmpls .getJSONObject (i ).optString ("name" );
1489
1497
// If more than one card then make currently selected card underlined
0 commit comments