package com.miguelgaeta.bootstrap.mg_lifecycle;

import android.app.Activity;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.view.View;
import android.view.ViewGroup;

import com.miguelgaeta.bootstrap.mg_strings.MGStrings;

/**
 * Created by Miguel on 1/23/2015. Copyright 2014 Blitz Studios
 */
@SuppressWarnings("UnusedDeclaration")
class MGLifecycleContentView {

    /**
     * Sets the content view of an activity automatically if it is
     * found. Otherwise, does nothing.
     */
    static void setContentView(@NonNull Activity activity) {

        Integer contentView = MGLifecycleContentView.getContentView(activity.getClass(), activity);

        if (contentView != null) {

            activity.setContentView(contentView);
        }
    }

    /**
     * Attempts to fetch the content view of the fragment,
     * returns the unmodified input view if not found.
     */
    static View getContentView(@NonNull Fragment fragment, ViewGroup container, View view) {

        Integer contentView = MGLifecycleContentView.getContentView(fragment.getClass(), fragment.getActivity());

        if (contentView != null) {

            view = fragment.getActivity().getLayoutInflater().inflate(contentView, container, false);
        }

        return view;
    }

    /**
     * Fetch the content view of an activity using a
     * convention based naming approach - the activity name
     * lower cased and underscored.
     */
    private static Integer getContentView(@NonNull Class classObject, @NonNull Activity activity) {

        String className = classObject.getSimpleName();
        String classNameFormatted = MGStrings.camelCaseToLowerCaseUnderscores(className);

        int resourceId = activity.getResources().getIdentifier(classNameFormatted, "layout",
                activity.getApplicationContext().getPackageName());

        return resourceId == 0 ? null : resourceId;
    }
}

@@ -212,16 +212,113 @@
 Group;%0A%0A
+import com.miguelgaeta.bootstrap.R;%0Aimport com.miguelgaeta.bootstrap.mg_reflection.MGReflection;%0A
 import c
@@ -364,16 +364,16 @@
 trings;%0A
-
 %0A/**%0A * 
@@ -783,18 +783,8 @@
 ss()
-, activity
 );%0A%0A
@@ -1201,32 +1201,8 @@
 ss()
-, fragment.getActivity()
 );%0A%0A
@@ -1615,36 +1615,8 @@
 ject
-, @NonNull Activity activity
 ) %7B%0A
@@ -1775,62 +1775,41 @@
     
-int resourceId = activity.getResources().getIdentifier
+return MGReflection.getResourceId
 (cla
@@ -1829,137 +1829,23 @@
 ed, 
-%22
+R.
 layout
-%22,%0A                activity.getApplicationContext().getPackageName());%0A%0A        return resourceId == 0 ? null : resourceId
+.class)
 ;%0A  

Use MG Reflection for setting content view.