Search in sources :

Example 1 with IFieldController

use of com.ichi2.anki.multimediacard.fields.IFieldController in project AnkiChinaAndroid by ankichinateam.

the class MultimediaEditFieldActivity method recreateEditingUi.

private void recreateEditingUi(ChangeUIRequest newUI, @Nullable Bundle savedInstanceState) {
    Timber.d("recreateEditingUi()");
    // Permissions are checked async, save our current state to allow continuation
    mCurrentChangeRequest = newUI;
    // As we only get here a second time if we have the required permissions
    if (newUI.getRequiresPermissionCheck() && performPermissionRequest(newUI.getField())) {
        newUI.markAsPermissionRequested();
        return;
    }
    IControllerFactory controllerFactory = BasicControllerFactory.getInstance(getCol().getTime());
    IFieldController fieldController = controllerFactory.createControllerForField(newUI.getField());
    if (fieldController == null) {
        Timber.w("Field controller creation failed");
        UIRecreationHandler.onControllerCreationFailed(newUI, this);
        return;
    }
    UIRecreationHandler.onPreFieldControllerReplacement(mFieldController);
    mFieldController = fieldController;
    mField = newUI.getField();
    setupUIController(mFieldController, savedInstanceState);
    LinearLayout linearLayout = findViewById(R.id.LinearLayoutInScrollViewFieldEdit);
    linearLayout.removeAllViews();
    mFieldController.createUI(this, linearLayout);
    UIRecreationHandler.onPostUICreation(newUI, this);
}
Also used : IControllerFactory(com.ichi2.anki.multimediacard.fields.IControllerFactory) IFieldController(com.ichi2.anki.multimediacard.fields.IFieldController) LinearLayout(android.widget.LinearLayout)

Example 2 with IFieldController

use of com.ichi2.anki.multimediacard.fields.IFieldController in project Anki-Android by ankidroid.

the class MultimediaEditFieldActivity method recreateEditingUi.

private void recreateEditingUi(ChangeUIRequest newUI, @Nullable Bundle savedInstanceState) {
    Timber.d("recreateEditingUi()");
    // Permissions are checked async, save our current state to allow continuation
    mCurrentChangeRequest = newUI;
    // As we only get here a second time if we have the required permissions
    if (newUI.getRequiresPermissionCheck() && performPermissionRequest(newUI.getField())) {
        newUI.markAsPermissionRequested();
        return;
    }
    IControllerFactory controllerFactory = BasicControllerFactory.getInstance();
    IFieldController fieldController = controllerFactory.createControllerForField(newUI.getField());
    if (fieldController == null) {
        Timber.w("Field controller creation failed");
        UIRecreationHandler.onControllerCreationFailed(newUI, this);
        return;
    }
    UIRecreationHandler.onPreFieldControllerReplacement(mFieldController);
    mFieldController = fieldController;
    mField = newUI.getField();
    setupUIController(mFieldController, savedInstanceState);
    LinearLayout linearLayout = findViewById(R.id.LinearLayoutInScrollViewFieldEdit);
    linearLayout.removeAllViews();
    mFieldController.createUI(this, linearLayout);
    UIRecreationHandler.onPostUICreation(newUI, this);
}
Also used : IControllerFactory(com.ichi2.anki.multimediacard.fields.IControllerFactory) IFieldController(com.ichi2.anki.multimediacard.fields.IFieldController) LinearLayout(android.widget.LinearLayout)

Aggregations

LinearLayout (android.widget.LinearLayout)2 IControllerFactory (com.ichi2.anki.multimediacard.fields.IControllerFactory)2 IFieldController (com.ichi2.anki.multimediacard.fields.IFieldController)2