import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.util.Log;

import flow.FlowContextWrapper;
import flow.InternalContextWrapper;

/**
 * Created by Zhuinden on 2016.05.26..
 */
public class ActivityUtils {
    private static final String TAG = "ActivityUtils";

    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) {
                return InternalContextWrapper.getActivity(context);
            } else {
                Context baseContext = ((ContextWrapper) context).getBaseContext();
                if(baseContext instanceof Activity) {
                    return (Activity)baseContext;
                }
            }
        }
        Log.e(TAG, "No activity could be found in [" + context + "]");
        throw new IllegalStateException("No activity could be found in [" + context + "]");
    }
}

@@ -1,20 +1,35 @@
+package flow;%0A%0A
 import android.app.A
@@ -138,77 +138,8 @@
 g;%0A%0A
-import flow.FlowContextWrapper;%0Aimport flow.InternalContextWrapper;%0A%0A
 /**%0A
@@ -395,16 +395,17 @@
 ctivity)
+ 
 context;
@@ -1169,16 +1169,17 @@
 ctivity)
+ 
 baseCont

reformat and merge current state