// Path: common-android-utils/src/main/java/com/common/android/utils/ContextHelper.java
// public class ContextHelper {
// 
//     @Nullable
//     private static WeakReference<Application> application;
// 
//     @Nullable
//     private static WeakReference<Context> context;
// 
//     private ContextHelper() throws IllegalAccessException {
//         throw new IllegalAccessException();
//     }
// 
//     public static void with(@NonNull final Application application) {
//         ContextHelper.application = new WeakReference<>(application);
//         application.registerActivityLifecycleCallbacks(createActivityLifecycleCallbacks());
//     }
// 
//     public static void setApplication(@Nullable Application application) {
//         if (application == null) {
//             ContextHelper.application = null;
//         }
// 
//         ContextHelper.application = new WeakReference<>(application);
//     }
// 
//     public static void setContext(@Nullable final Context context) {
//         if (context == null) {
//             ContextHelper.context = null;
//             return;
//         }
// 
//         ContextHelper.context = new WeakReference<>(context);
//     }
// 
//     @Nullable
//     public static Application getApplication() {
//         return application != null
//                 ? application.get()
//                 : null;
//     }
// 
//     @Nullable
//     public static Context getContext() {
//         return context != null
//                 ? context.get()
//                 : null;
//     }
// 
//     @Nullable
//     public static FragmentActivity getFragmentActivity() {
//         if (context == null)
//             return null;
// 
//         return context.get() instanceof FragmentActivity
//                 ? (FragmentActivity) context.get()
//                 : null;
//     }
// 
//     @Nullable
//     public static AppCompatActivity getAppCompatActivity() {
//         if (context == null)
//             return null;
// 
//         return context.get() instanceof AppCompatActivity
//                 ? (AppCompatActivity) context.get()
//                 : null;
//     }
// 
//     @Nullable
//     public static Activity getActivity() {
//         if (context == null)
//             return null;
// 
//         return context.get() instanceof Activity
//                 ? (Activity) context.get()
//                 : null;
//     }
// 
//     public static final AtomicBoolean isRunning = new AtomicBoolean(false);
// 
//     private static Application.ActivityLifecycleCallbacks createActivityLifecycleCallbacks() {
//         return new Application.ActivityLifecycleCallbacks() {
//             @Override
//             public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
//                 setContext(activity);
//                 isRunning.set(true);
//             }
// 
//             @Override
//             public void onActivityStarted(Activity activity) {
//                 setContext(activity);
//                 isRunning.set(true);
//             }
// 
//             @Override
//             public void onActivityResumed(Activity activity) {
//                 setContext(activity);
//                 isRunning.set(true);
//             }
// 
//             @Override
//             public void onActivityPaused(Activity activity) {
//                 isRunning.set(false);
//             }
// 
//             @Override
//             public void onActivityStopped(Activity activity) {
//                 isRunning.set(false);
//             }
// 
//             @Override
//             public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// 
//             }
// 
//             @Override
//             public void onActivityDestroyed(Activity activity) {
//                 isRunning.set(false);
//             }
//         };
//     }
// 
//     public static void onTerminate() {
// 
//         if (context != null)
//             context.clear();
// 
//         context = null;
// 
//         if (application != null)
//             application.clear();
// 
//         application = null;
// 
//         isRunning.set(false);
//     }
// }
// 
// Path: common-android-utils/src/main/java/com/common/android/utils/ContextHelper.java
// @Nullable
// public static Activity getActivity() {
//     if (context == null)
//         return null;
// 
//     return context.get() instanceof Activity
//             ? (Activity) context.get()
//             : null;
// }
// 
// Path: common-android-utils/src/main/java/com/common/android/utils/ContextHelper.java
// @Nullable
// public static Context getContext() {
//     return context != null
//             ? context.get()
//             : null;
// }
// 
// Path: common-android-utils/src/main/java/com/common/android/utils/extensions/ResourceExtensions.java
// public static int color(@ColorRes final int color) {
//     return ContextCompat.getColor(getContext(), color);
// }
// 
// Path: common-android-utils/src/main/java/com/common/android/utils/extensions/ViewExtensions.java
// public static View inflate(@LayoutRes final int layout, @Nullable final ViewGroup parent, final boolean attachToRoot) {
//     return getActivity().getLayoutInflater().inflate(layout, parent, attachToRoot);
// }


import android.support.annotation.ColorRes;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.common.android.utils.ContextHelper;
import com.common.android.utils.R;
import static android.text.TextUtils.isEmpty;
import static com.common.android.utils.ContextHelper.getActivity;
import static com.common.android.utils.ContextHelper.getContext;
import static com.common.android.utils.extensions.ResourceExtensions.color;
import static com.common.android.utils.extensions.ViewExtensions.inflate;
package com.common.android.utils.extensions;




/**
 * Created by Jan Rabe on 24/09/15.
 */
final public class ToastExtensions {

    public static boolean showToastMessages = true;

    private ToastExtensions() throws IllegalAccessException {
        throw new IllegalAccessException();
    }

    public static void toast(@Nullable final String message) {
        if (!showToastMessages)
            return;

        if (isEmpty(message))
            return;

        getActivity().runOnUiThread(() -> {
            final Toast toast = Toast.makeText(getContext(), message, Toast.LENGTH_LONG);
            toast.setGravity(Gravity.BOTTOM, 0, 100);
            toast.show();
        });
    }

    static void toast(@StringRes final int resourceId) {
        if (!showToastMessages)
            return;

// Path: common-android-utils/src/main/java/com/common/android/utils/ContextHelper.java
// public class ContextHelper {
// 
//     @Nullable
//     private static WeakReference<Application> application;
// 
//     @Nullable
//     private static WeakReference<Context> context;
// 
//     private ContextHelper() throws IllegalAccessException {
//         throw new IllegalAccessException();
//     }
// 
//     public static void with(@NonNull final Application application) {
//         ContextHelper.application = new WeakReference<>(application);
//         application.registerActivityLifecycleCallbacks(createActivityLifecycleCallbacks());
//     }
// 
//     public static void setApplication(@Nullable Application application) {
//         if (application == null) {
//             ContextHelper.application = null;
//         }
// 
//         ContextHelper.application = new WeakReference<>(application);
//     }
// 
//     public static void setContext(@Nullable final Context context) {
//         if (context == null) {
//             ContextHelper.context = null;
//             return;
//         }
// 
//         ContextHelper.context = new WeakReference<>(context);
//     }
// 
//     @Nullable
//     public static Application getApplication() {
//         return application != null
//                 ? application.get()
//                 : null;
//     }
// 
//     @Nullable
//     public static Context getContext() {
//         return context != null
//                 ? context.get()
//                 : null;
//     }
// 
//     @Nullable
//     public static FragmentActivity getFragmentActivity() {
//         if (context == null)
//             return null;
// 
//         return context.get() instanceof FragmentActivity
//                 ? (FragmentActivity) context.get()
//                 : null;
//     }
// 
//     @Nullable
//     public static AppCompatActivity getAppCompatActivity() {
//         if (context == null)
//             return null;
// 
//         return context.get() instanceof AppCompatActivity
//                 ? (AppCompatActivity) context.get()
//                 : null;
//     }
// 
//     @Nullable
//     public static Activity getActivity() {
//         if (context == null)
//             return null;
// 
//         return context.get() instanceof Activity
//                 ? (Activity) context.get()
//                 : null;
//     }
// 
//     public static final AtomicBoolean isRunning = new AtomicBoolean(false);
// 
//     private static Application.ActivityLifecycleCallbacks createActivityLifecycleCallbacks() {
//         return new Application.ActivityLifecycleCallbacks() {
//             @Override
//             public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
//                 setContext(activity);
//                 isRunning.set(true);
//             }
// 
//             @Override
//             public void onActivityStarted(Activity activity) {
//                 setContext(activity);
//                 isRunning.set(true);
//             }
// 
//             @Override
//             public void onActivityResumed(Activity activity) {
//                 setContext(activity);
//                 isRunning.set(true);
//             }
// 
//             @Override
//             public void onActivityPaused(Activity activity) {
//                 isRunning.set(false);
//             }
// 
//             @Override
//             public void onActivityStopped(Activity activity) {
//                 isRunning.set(false);
//             }
// 
//             @Override
//             public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// 
//             }
// 
//             @Override
//             public void onActivityDestroyed(Activity activity) {
//                 isRunning.set(false);
//             }
//         };
//     }
// 
//     public static void onTerminate() {
// 
//         if (context != null)
//             context.clear();
// 
//         context = null;
// 
//         if (application != null)
//             application.clear();
// 
//         application = null;
// 
//         isRunning.set(false);
//     }
// }
// 
// Path: common-android-utils/src/main/java/com/common/android/utils/ContextHelper.java
// @Nullable
// public static Activity getActivity() {
//     if (context == null)
//         return null;
// 
//     return context.get() instanceof Activity
//             ? (Activity) context.get()
//             : null;
// }
// 
// Path: common-android-utils/src/main/java/com/common/android/utils/ContextHelper.java
// @Nullable
// public static Context getContext() {
//     return context != null
//             ? context.get()
//             : null;
// }
// 
// Path: common-android-utils/src/main/java/com/common/android/utils/extensions/ResourceExtensions.java
// public static int color(@ColorRes final int color) {
//     return ContextCompat.getColor(getContext(), color);
// }
// 
// Path: common-android-utils/src/main/java/com/common/android/utils/extensions/ViewExtensions.java
// public static View inflate(@LayoutRes final int layout, @Nullable final ViewGroup parent, final boolean attachToRoot) {
//     return getActivity().getLayoutInflater().inflate(layout, parent, attachToRoot);
// }


// Path: common-android-utils/src/main/java/com/common/android/utils/extensions/ToastExtensions.java
import android.support.annotation.ColorRes;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.common.android.utils.ContextHelper;
import com.common.android.utils.R;
import static android.text.TextUtils.isEmpty;
import static com.common.android.utils.ContextHelper.getActivity;
import static com.common.android.utils.ContextHelper.getContext;
import static com.common.android.utils.extensions.ResourceExtensions.color;
import static com.common.android.utils.extensions.ViewExtensions.inflate;

package com.common.android.utils.extensions;




/**
 * Created by Jan Rabe on 24/09/15.
 */
final public class ToastExtensions {

    public static boolean showToastMessages = true;

    private ToastExtensions() throws IllegalAccessException {
        throw new IllegalAccessException();
    }

    public static void toast(@Nullable final String message) {
        if (!showToastMessages)
            return;

        if (isEmpty(message))
            return;

        getActivity().runOnUiThread(() -> {
            final Toast toast = Toast.makeText(getContext(), message, Toast.LENGTH_LONG);
            toast.setGravity(Gravity.BOTTOM, 0, 100);
            toast.show();
        });
    }

    static void toast(@StringRes final int resourceId) {
        if (!showToastMessages)
            return;

        getActivity().runOnUiThread(() -> {