Permalink
Browse files

RC2: make Activity usable as baseContext for inflating custom viewgroups

  • Loading branch information...
1 parent ba9380a commit a315f00c13c5488ff5f34c80a35ce7469e4c64ab @Zhuinden committed Jan 8, 2017
View
@@ -1,6 +1,11 @@
Change Log
==========
+Flowless Version 1.0-RC2 *(2017-01-08)*
+---------------------------------------------
+* Fix: Make `ActivityUtils.getActivity()` work if provided `baseContext` is not `InternalContextWrapper`
+* Enhancement: ˙samples to use `setBaseContext(Activity)` to properly support `AppCompat*` inflation
+
Flowless Version 1.0-RC1 *(2017-01-04)*
---------------------------------------------
* Added: `KeyManager.isKeyRegistered()`
View
@@ -44,7 +44,7 @@ In order to use Flow(less), you need to add jitpack to your project root gradle:
and add the compile dependency to your module level gradle.
- compile 'com.github.Zhuinden:flowless:1.0-RC1'
+ compile 'com.github.Zhuinden:flowless:1.0-RC2'
Then, install Flow into your Activity:
@@ -63,7 +63,7 @@ public class MainActivity {
.defaultKey(FirstKey.create()) //
.dispatcher(flowDispatcher) //
.install(); //
- flowDispatcher.setBaseContext(newBase);
+ flowDispatcher.setBaseContext(this);
super.attachBaseContext(newBase);
}
@@ -14,13 +14,7 @@ public static Activity getActivity(Context context) {
if(context instanceof Activity) {
return (Activity) context;
} else if(context instanceof ContextWrapper) {
- if(context instanceof FlowContextWrapper) {
- FlowContextWrapper flowContextWrapper = (FlowContextWrapper) context;
- Context baseContext = flowContextWrapper.getBaseContext();
- if(baseContext instanceof InternalContextWrapper) {
- return InternalContextWrapper.getActivity(baseContext);
- }
- } else if(context instanceof InternalContextWrapper) {
+ if(context instanceof FlowContextWrapper || context instanceof InternalContextWrapper) {
return InternalContextWrapper.getActivity(context);
} else {
Context baseContext = ((ContextWrapper) context).getBaseContext();
@@ -26,7 +26,7 @@ protected void attachBaseContext(Context newBase) {
.globalKey(getGlobalKey()) //
.dispatcher(this) //
.install(); //
- transitionDispatcher.setBaseContext(newBase);
+ transitionDispatcher.setBaseContext(this);
super.attachBaseContext(newBase);
}
@@ -29,7 +29,7 @@ protected void attachBaseContext(Context newBase) {
.defaultKey(FirstKey.create()) //
.dispatcher(flowDispatcher) //
.install(); //
- flowDispatcher.setBaseContext(newBase);
+ flowDispatcher.setBaseContext(this);
super.attachBaseContext(newBase);
}
@@ -2,7 +2,6 @@
import android.annotation.TargetApi;
import android.content.Context;
-import android.content.ContextWrapper;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
@@ -11,6 +10,7 @@
import com.zhuinden.flow_alpha_master_detail.extracted.ExampleDispatcher;
+import flowless.ActivityUtils;
import flowless.Dispatcher;
import flowless.Traversal;
import flowless.TraversalCallback;
@@ -49,7 +49,7 @@ public SinglePaneContainer(Context context, AttributeSet attrs, int defStyleAttr
private void init() {
singleRootDispatcher = new ExampleDispatcher();
singleRootDispatcher.getRootHolder().setRoot(this);
- singleRootDispatcher.setBaseContext(((ContextWrapper)getContext()).getBaseContext());
+ singleRootDispatcher.setBaseContext(ActivityUtils.getActivity(getContext()));
}
@Override
@@ -29,7 +29,7 @@ protected void attachBaseContext(Context newBase) {
.defaultKey(FirstKey.create()) //
.dispatcher(flowDispatcher) //
.install(); //
- flowDispatcher.setBaseContext(newBase);
+ flowDispatcher.setBaseContext(this);
super.attachBaseContext(newBase);
}
@@ -28,7 +28,7 @@ protected void attachBaseContext(Context newBase) {
.defaultKey(SceneMainDefaultKey.create())
.dispatcher(transitionDispatcher)
.install();
- transitionDispatcher.setBaseContext(newBase);
+ transitionDispatcher.setBaseContext(this);
super.attachBaseContext(newBase);
}
@@ -28,7 +28,7 @@ protected void attachBaseContext(Context newBase) {
.defaultKey(FirstKey.create()) //
.dispatcher(flowDispatcher) //
.install(); //
- flowDispatcher.setBaseContext(newBase);
+ flowDispatcher.setBaseContext(this);
super.attachBaseContext(newBase);
}

0 comments on commit a315f00

Please sign in to comment.