mirror of
https://github.com/ankidroid/Anki-Android.git
synced 2024-09-19 19:42:17 +02:00
load fragment when performing action on cards
This commit updates the previewer when addition, deletion, renaming of cards.
This commit is contained in:
parent
a256d952bf
commit
502ce7f4eb
@ -570,6 +570,8 @@ open class CardTemplateEditor : AnkiActivity(), DeckSelectionListener {
|
|||||||
|
|
||||||
// update the tab
|
// update the tab
|
||||||
templateEditor.viewPager.adapter!!.notifyDataSetChanged()
|
templateEditor.viewPager.adapter!!.notifyDataSetChanged()
|
||||||
|
// Update the tab name in previewer
|
||||||
|
templateEditor.loadTemplatePreviewerFragmentIfFragmented()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1028,12 +1030,21 @@ open class CardTemplateEditor : AnkiActivity(), DeckSelectionListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute an action on the schema, asking the user to confirm that a full sync is ok
|
* Execute an action on the schema, asking the user to confirm that a full sync is ok
|
||||||
|
* If [schemaChangingAction] is successfully executed, then the template is reloaded.
|
||||||
|
*
|
||||||
|
* This method is always useful because all calls to executeWithSyncCheck may need to refresh the previewer.
|
||||||
|
* Due to conditional generation (e.g., {{#c5}}foo{{/c5}} which is non-empty only if it's the 5th card and is
|
||||||
|
* empty otherwise), it's important to reload the template. This is particularly useful for cloze types,
|
||||||
|
* where a card can move from the 5th to the 6th position due to adding an extra card type, causing content
|
||||||
|
* to change or be deleted.
|
||||||
|
*
|
||||||
* @param schemaChangingAction The action to execute (adding / removing card)
|
* @param schemaChangingAction The action to execute (adding / removing card)
|
||||||
*/
|
*/
|
||||||
private fun executeWithSyncCheck(schemaChangingAction: Runnable) {
|
private fun executeWithSyncCheck(schemaChangingAction: Runnable) {
|
||||||
try {
|
try {
|
||||||
templateEditor.getColUnsafe.modSchema()
|
templateEditor.getColUnsafe.modSchema()
|
||||||
schemaChangingAction.run()
|
schemaChangingAction.run()
|
||||||
|
templateEditor.loadTemplatePreviewerFragmentIfFragmented()
|
||||||
} catch (e: ConfirmModSchemaException) {
|
} catch (e: ConfirmModSchemaException) {
|
||||||
e.log()
|
e.log()
|
||||||
val d = ConfirmationDialog()
|
val d = ConfirmationDialog()
|
||||||
|
Loading…
Reference in New Issue
Block a user