Search in sources :

Example 1 with IControllerFactory

use of com.ichi2.anki.multimediacard.fields.IControllerFactory 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 IControllerFactory

use of com.ichi2.anki.multimediacard.fields.IControllerFactory in project Anki-Android by Ramblurr.

the class EditFieldActivity method recreateEditingUi.

private void recreateEditingUi() {
    IControllerFactory controllerFactory = BasicControllerFactory.getInstance();
    mFieldController = controllerFactory.createControllerForField(mField);
    if (mFieldController == null) {
        // Log.d(AnkiDroidApp.TAG, "Field controller creation failed");
        return;
    }
    mFieldController.setField(mField);
    mFieldController.setFieldIndex(mFieldIndex);
    mFieldController.setNote(mNote);
    mFieldController.setEditingActivity(this);
    LinearLayout linearLayout = (LinearLayout) findViewById(R.id.LinearLayoutInScrollViewFieldEdit);
    linearLayout.removeAllViews();
    mFieldController.createUI(linearLayout);
}
Also used : IControllerFactory(com.ichi2.anki.multimediacard.fields.IControllerFactory) LinearLayout(android.widget.LinearLayout)

Example 3 with IControllerFactory

use of com.ichi2.anki.multimediacard.fields.IControllerFactory 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)3 IControllerFactory (com.ichi2.anki.multimediacard.fields.IControllerFactory)3 IFieldController (com.ichi2.anki.multimediacard.fields.IFieldController)2