Back to project page screenplay.
The source code is released under:
MIT License
If you think the Android project screenplay listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.davidstemmer.screenplay.scene; /* ww w . j a va 2 s. com*/ import android.content.Context; import android.view.View; import android.view.ViewGroup; import mortar.Blueprint; import mortar.Mortar; import mortar.MortarScope; /** * Created by weefbellington on 10/20/14. */ public abstract class ScopedScene extends StandardScene implements Blueprint { private MortarScope scope; @Override public View setUp(Context context, ViewGroup parent) { return super.setUp(createScope(context), parent); } @Override public View tearDown(Context context, ViewGroup parent) { View destroyed = super.tearDown(context, parent); destroyScope(context); return destroyed; } private Context createScope(Context context) { MortarScope parentScope = Mortar.getScope(context); scope = parentScope.requireChild(this); Context childContext = scope.createContext(context); Mortar.inject(childContext, this); onCreateScope(scope); return childContext; } private void destroyScope(Context context) { MortarScope parentScope = Mortar.getScope(context); parentScope.destroyChild(scope); scope = null; onDestroyScope(); } public void onCreateScope(MortarScope scope) {} public void onDestroyScope() {} }