package com.playground.android_architect_playground.pages.colorpage;

import android.arch.lifecycle.LifecycleRegistry;
import android.arch.lifecycle.LifecycleRegistryOwner;
import android.arch.lifecycle.ViewModelProviders;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;

import com.playground.android_architect_playground.R;
import com.playground.android_architect_playground.logger.LogLifecycleObserver;
import com.playground.android_architect_playground.pages.colorpage.data.ColorEnum;
import com.playground.android_architect_playground.pages.colorpage.model.ColorViewModel;
import com.playground.android_architect_playground.pages.colorpage.view.ColorFragment;

import javax.inject.Inject;

import dagger.android.support.DaggerAppCompatActivity;

/**
 * Created by petnagy on 2017. 07. 05..
 */

public class ColorActivity extends DaggerAppCompatActivity implements LifecycleRegistryOwner {

    @Inject
    LogLifecycleObserver logger;

    @Inject
    LifecycleRegistry lifecycleRegistry;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.color_activity);
        getLifecycle().addObserver(logger);

        ColorViewModel colorViewModel = ViewModelProviders.of(this).get(ColorViewModel.class);
        colorViewModel.getBaseColor().setValue(ColorEnum.BLUE);

        FragmentTransaction ft1 = getSupportFragmentManager().beginTransaction();
        ft1.replace(R.id.fragment_one_holder, ColorFragment.newInstance(0));
        ft1.commit();

        FragmentTransaction ft2 = getSupportFragmentManager().beginTransaction();
        ft2.replace(R.id.fragment_two_holder, ColorFragment.newInstance(1));
        ft2.commit();

        FragmentTransaction ft3 = getSupportFragmentManager().beginTransaction();
        ft3.replace(R.id.fragment_three_holder, ColorFragment.newInstance(3));
        ft3.commit();

        FragmentTransaction ft4 = getSupportFragmentManager().beginTransaction();
        ft4.replace(R.id.fragment_four_holder, ColorFragment.newInstance(2));
        ft4.commit();
    }

    @Override
    public LifecycleRegistry getLifecycle() {
        return lifecycleRegistry;
    }

    public static Intent launchIntent(Context context) {
        return new Intent(context, ColorActivity.class);
    }
}

@@ -1479,18 +1479,34 @@
 action f
-t1
+ragmentTransaction
  = getSu
@@ -1557,18 +1557,34 @@
        f
-t1
+ragmentTransaction
 .replace
@@ -1654,481 +1654,214 @@
    f
-t1.commit();%0A%0A        FragmentTransaction ft2 = getSupportFragmentManager().beginTransaction();%0A        ft2.replace(R.id.fragment_two_holder, ColorFragment.newInstance(1));%0A        ft2.commit();%0A%0A        FragmentTransaction ft3 = getSupportFragmentManager().beginTransaction();%0A        ft3.replace(R.id.fragment_three_holder, ColorFragment.newInstance(3));%0A        ft3.commit();%0A%0A        FragmentTransaction ft4 = getSupportFragmentManager().beginTransaction();%0A        ft4
+ragmentTransaction.replace(R.id.fragment_two_holder, ColorFragment.newInstance(1));%0A        fragmentTransaction.replace(R.id.fragment_three_holder, ColorFragment.newInstance(3));%0A        fragmentTransaction
 .rep
@@ -1936,10 +1936,26 @@
    f
-t4
+ragmentTransaction
 .com

Simplify Color Activity