// Path: app/src/main/java/io/petros/posts/app/PostsApplication.java
// @SuppressWarnings("checkstyle:overloadmethodsdeclarationorder")
// public class PostsApplication extends Application {
// 
//     private static ApplicationComponent applicationComponent;
// 
//     static {
//         AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); // NOTE: This enables the "proxy" trick on the vector images.
//     }
// 
//     @Inject AppSnackbarActions appSnackbarActions;
// 
//     // HELPER // ************************************************************************************************************
// 
//     public static ApplicationComponent getApplicationComponent() {
//         return applicationComponent;
//     }
// 
//     public static SnackbarActions snackbar(final Activity activity) {
//         return ((PostsApplication) activity.getApplication()).snackbar();
//     }
// 
//     // APPLICATION // *******************************************************************************************************
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         initDagger();
//         initRealm();
//         initTimber();
//         Timber.i("Posts application created!");
//     }
// 
//     private void initDagger() {
//         applicationComponent = DaggerApplicationComponent.builder()
//                 .appModule(new AppModule(this))
//                 .netModule(new NetModule(BASE_URL))
//                 .dataModule(new DataModule())
//                 .serviceModule(new ServiceModule())
//                 .activityModule(new ActivityModule()).build();
//         applicationComponent.inject(this);
//     }
// 
//     private void initTimber() {
//         Timber.plant(new Timber.DebugTree());
//     }
// 
//     protected void initRealm() {
//         Realm.init(this);
//     }
// 
//     // GET // ***************************************************************************************************************
// 
//     public Realm getDefaultRealmInstance() {
//         return Realm.getDefaultInstance();
//     }
// 
//     // ACTIONS // ***********************************************************************************************************
// 
//     public SnackbarActions snackbar() {
//         return appSnackbarActions;
//     }
// 
// }
// 
// Path: app/src/main/java/io/petros/posts/util/DeprecationUtilities.java
// public final class DeprecationUtilities {
// 
//     private DeprecationUtilities() {
//         throw new AssertionError();
//     }
// 
//     public static void setBackground(final View view, final int drawableId) {
//         final Drawable drawable = ContextCompat.getDrawable(view.getContext(), drawableId);
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
//             view.setBackground(drawable);
//         } else {
//             view.setBackgroundDrawable(drawable);
//         }
//     }
// 
// }


import android.graphics.Color;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import javax.annotation.Nullable;
import io.petros.posts.R;
import io.petros.posts.app.PostsApplication;
import io.petros.posts.util.DeprecationUtilities;
import timber.log.Timber;
    public void setCoordinatorLayout(final CoordinatorLayout coordinatorLayout) {
        this.coordinatorLayout = coordinatorLayout;
    }

    // SNACKBAR // **********************************************************************************************************

    @SuppressWarnings("checkstyle:whitespacearound")
    public void info(final int textResId) {
        final String text = application.getString(textResId);
        if (coordinatorLayout != null) {
            final Snackbar snackbar = Snackbar.make(coordinatorLayout, text, Snackbar.LENGTH_LONG) // @formatter:off
                    .setAction(defaultActionText, v -> {}); // @formatter:on
            setColors(snackbar, 0, R.color.white, R.color.color_accent);
            snackbar.show();
        } else {
            Toast.makeText(application, text, Toast.LENGTH_LONG).show();
        }
    }

    private void setColors(final Snackbar snackbar, final int backgroundColorId, final int textColorId, final int actionTextColorId) {
        changeSnackbarBackgroundColor(snackbar, backgroundColorId);
        changeSnackbarTextColor(snackbar, textColorId);
        changeSnackbarActionTextColor(snackbar, actionTextColorId);
    }

    private void changeSnackbarBackgroundColor(final Snackbar snackbar, final int backgroundColorId) {
        final View snackbarView = snackbar.getView();
        if (backgroundColorId != 0) {
            snackbarView.setBackgroundColor(ContextCompat.getColor(application, backgroundColorId));
        } else { // This is the snackbar's default background color.
// Path: app/src/main/java/io/petros/posts/app/PostsApplication.java
// @SuppressWarnings("checkstyle:overloadmethodsdeclarationorder")
// public class PostsApplication extends Application {
// 
//     private static ApplicationComponent applicationComponent;
// 
//     static {
//         AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); // NOTE: This enables the "proxy" trick on the vector images.
//     }
// 
//     @Inject AppSnackbarActions appSnackbarActions;
// 
//     // HELPER // ************************************************************************************************************
// 
//     public static ApplicationComponent getApplicationComponent() {
//         return applicationComponent;
//     }
// 
//     public static SnackbarActions snackbar(final Activity activity) {
//         return ((PostsApplication) activity.getApplication()).snackbar();
//     }
// 
//     // APPLICATION // *******************************************************************************************************
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         initDagger();
//         initRealm();
//         initTimber();
//         Timber.i("Posts application created!");
//     }
// 
//     private void initDagger() {
//         applicationComponent = DaggerApplicationComponent.builder()
//                 .appModule(new AppModule(this))
//                 .netModule(new NetModule(BASE_URL))
//                 .dataModule(new DataModule())
//                 .serviceModule(new ServiceModule())
//                 .activityModule(new ActivityModule()).build();
//         applicationComponent.inject(this);
//     }
// 
//     private void initTimber() {
//         Timber.plant(new Timber.DebugTree());
//     }
// 
//     protected void initRealm() {
//         Realm.init(this);
//     }
// 
//     // GET // ***************************************************************************************************************
// 
//     public Realm getDefaultRealmInstance() {
//         return Realm.getDefaultInstance();
//     }
// 
//     // ACTIONS // ***********************************************************************************************************
// 
//     public SnackbarActions snackbar() {
//         return appSnackbarActions;
//     }
// 
// }
// 
// Path: app/src/main/java/io/petros/posts/util/DeprecationUtilities.java
// public final class DeprecationUtilities {
// 
//     private DeprecationUtilities() {
//         throw new AssertionError();
//     }
// 
//     public static void setBackground(final View view, final int drawableId) {
//         final Drawable drawable = ContextCompat.getDrawable(view.getContext(), drawableId);
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
//             view.setBackground(drawable);
//         } else {
//             view.setBackgroundDrawable(drawable);
//         }
//     }
// 
// }


// Path: app/src/main/java/io/petros/posts/app/actions/AppSnackbarActions.java
import android.graphics.Color;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import javax.annotation.Nullable;
import io.petros.posts.R;
import io.petros.posts.app.PostsApplication;
import io.petros.posts.util.DeprecationUtilities;
import timber.log.Timber;

    public void setCoordinatorLayout(final CoordinatorLayout coordinatorLayout) {
        this.coordinatorLayout = coordinatorLayout;
    }

    // SNACKBAR // **********************************************************************************************************

    @SuppressWarnings("checkstyle:whitespacearound")
    public void info(final int textResId) {
        final String text = application.getString(textResId);
        if (coordinatorLayout != null) {
            final Snackbar snackbar = Snackbar.make(coordinatorLayout, text, Snackbar.LENGTH_LONG) // @formatter:off
                    .setAction(defaultActionText, v -> {}); // @formatter:on
            setColors(snackbar, 0, R.color.white, R.color.color_accent);
            snackbar.show();
        } else {
            Toast.makeText(application, text, Toast.LENGTH_LONG).show();
        }
    }

    private void setColors(final Snackbar snackbar, final int backgroundColorId, final int textColorId, final int actionTextColorId) {
        changeSnackbarBackgroundColor(snackbar, backgroundColorId);
        changeSnackbarTextColor(snackbar, textColorId);
        changeSnackbarActionTextColor(snackbar, actionTextColorId);
    }

    private void changeSnackbarBackgroundColor(final Snackbar snackbar, final int backgroundColorId) {
        final View snackbarView = snackbar.getView();
        if (backgroundColorId != 0) {
            snackbarView.setBackgroundColor(ContextCompat.getColor(application, backgroundColorId));
        } else { // This is the snackbar's default background color.
            DeprecationUtilities.setBackground(snackbarView, R.drawable.snackbar__design_snackbar_background);