Android Open Source - baracus-framework Managed Fragment






From Project

Back to project page baracus-framework.

License

The source code is released under:

Apache License

If you think the Android project baracus-framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.mantucon.baracus.context;
/*ww  w . j  a  v a 2 s . c  o m*/
import android.app.Fragment;
import android.view.View;

/**
 * Created with IntelliJ IDEA.
 * User: marcus
 * Date: 17.05.13
 * <p/>
 * This class is needed in order to juxtaposition the reinstantiaon of Fragment beans
 * by android e.g. when a device rotate happens - unless I have found something
 * more appropriate for it (Hooking into the lifecycle in android handling the fragments
 * must be possible)
 * <p/>
 * Simple inherit this class and register it as usual as a Fragment bean and all accesses
 * to injected beans will work fine :)
 */
public abstract class ManagedFragment extends Fragment {

    // set this View from derived classes if You want to use automatic error handling
    protected View view;

    public ManagedFragment() {
        BaracusApplicationContext.performInjectionsOn(this);
    }

    @Override
    public void onDestroyView() {
        if (view != null) { // if you use the automatic error routing extension, you MUST set the view
            // when inflating the form. Notice, this is normally done in the
            // onCreateView function. If You do not set the view field when inflating
            // a new view, you will create memory leaks, because all bound errorHandlers
            // cannot be marked for removal by the garbage collector because they are
            // held in the application context bound to the containing view instance!
            BaracusApplicationContext.unregisterErrorhandlersForView(this.view);
        }
        super.onDestroyView();
    }

    /**
     * enables the validation of the view onFocusChanged event
     * If you want Your View to
     * be able to receive a validation callback - e.g. in order to manage the
     * visibility of an OK-Button or sth. - Your View must implement
     * the @see ValidatableView interface in order to receive a validation
     * notification.
     * <p/>
     * Notice, You must set the underlying view instance to enable this feature!
     */
    public void enableFocusChangeBasedValidation() {
        BaracusApplicationContext.registerValidationListener(this.view);
    }


    /**
     * enables the validation of the view onFocusChanged event
     * If you want Your View to
     * be able to receive a validation callback - e.g. in order to manage the
     * visibility of an OK-Button or sth. - Your View must implement
     * the @see ValidatableView interface in order to receive a validation
     * notification.
     *
     * @param v - the underlying view, which will be set on the this.view variable
     *
     */
    public void enableFocusChangeBasedValidation(View v) {
        this.view = v;
        enableFocusChangeBasedValidation();
    }

}




Java Source Code List

net.mantucon.baracus.annotations.Bean.java
net.mantucon.baracus.context.AnnotationScanner.java
net.mantucon.baracus.context.BaracusApplicationContext.java
net.mantucon.baracus.context.BeanContainer.java
net.mantucon.baracus.context.Exceptions.java
net.mantucon.baracus.context.ManagedActivity.java
net.mantucon.baracus.context.ManagedFragment.java
net.mantucon.baracus.dao.BaracusOpenHelper.java
net.mantucon.baracus.dao.BaseDao.java
net.mantucon.baracus.dao.ConfigurationDao.java
net.mantucon.baracus.errorhandling.CustomErrorHandler.java
net.mantucon.baracus.errorhandling.ErrorHandler.java
net.mantucon.baracus.errorhandling.ErrorHandlingFactory.java
net.mantucon.baracus.errorhandling.ErrorSeverity.java
net.mantucon.baracus.errorhandling.StandardErrorHandler.java
net.mantucon.baracus.errorhandling.TextEditErrorHandler.java
net.mantucon.baracus.lifecycle.ApplicationContextInitializer.java
net.mantucon.baracus.lifecycle.Destroyable.java
net.mantucon.baracus.lifecycle.Initializeable.java
net.mantucon.baracus.migr8.MigrationStep.java
net.mantucon.baracus.migr8.ModelVersion000.java
net.mantucon.baracus.model.ConfigurationParameter.java
net.mantucon.baracus.orm.AbstractModelBase.java
net.mantucon.baracus.orm.FieldList.java
net.mantucon.baracus.orm.Field.java
net.mantucon.baracus.orm.Identifiable.java
net.mantucon.baracus.orm.LazyCollection.java
net.mantucon.baracus.orm.LazyMorphicCollection.java
net.mantucon.baracus.orm.LazyReference.java
net.mantucon.baracus.orm.LegacyModelBase.java
net.mantucon.baracus.orm.ModelBase.java
net.mantucon.baracus.orm.NullReference.java
net.mantucon.baracus.orm.ObjectReference.java
net.mantucon.baracus.orm.OptimisticLockingModelBase.java
net.mantucon.baracus.orm.OptmisticLocking.java
net.mantucon.baracus.orm.ReferenceLoader.java
net.mantucon.baracus.orm.Reference.java
net.mantucon.baracus.orm.Timestamped.java
net.mantucon.baracus.signalling.ConfigurationChangeListener.java
net.mantucon.baracus.signalling.DataChangeAwareComponent.java
net.mantucon.baracus.signalling.DataSetChangeAwareComponent.java
net.mantucon.baracus.signalling.DeleteAwareComponent.java
net.mantucon.baracus.signalling.GenericEventAwareComponent.java
net.mantucon.baracus.signalling.GenericEvent.java
net.mantucon.baracus.ui.ConstrainedEditText.java
net.mantucon.baracus.ui.ConstrainedSpinner.java
net.mantucon.baracus.ui.ErrorView.java
net.mantucon.baracus.ui.Popup.java
net.mantucon.baracus.util.DBBackup.java
net.mantucon.baracus.util.DataUtil.java
net.mantucon.baracus.util.DateUtil.java
net.mantucon.baracus.util.DayDate.java
net.mantucon.baracus.util.Logger.java
net.mantucon.baracus.util.StringUtil.java
net.mantucon.baracus.validation.AbstractValidator.java
net.mantucon.baracus.validation.ConstrainedView.java
net.mantucon.baracus.validation.ValidatableView.java
net.mantucon.baracus.validation.ValidationFactory.java
net.mantucon.baracus.validation.Validator.java
net.mantucon.baracus.validation.builtins.DateFromNow.java
net.mantucon.baracus.validation.builtins.NumberMustBeGreaterThanZero.java
net.mantucon.baracus.validation.builtins.StringIsNumericDouble.java
net.mantucon.baracus.validation.builtins.StringIsNumericInteger.java
net.mantucon.baracus.validation.builtins.StringNotEmpty.java