// Path: app/src/main/java/jaakko/jaaska/apptycoon/ui/listener/FragmentBackButtonOnClickListener.java
// public class FragmentBackButtonOnClickListener implements View.OnClickListener {
//     private static final String TAG = "FBBOCL";
// 
//     private Bundle mArgs;
//     private int mPreviousFragment;
// 
//     /**
//      * Use this to simply navigate one step back on the navigation stack.
//      */
//     public FragmentBackButtonOnClickListener() {
// 
//     }
// 
//     /**
//      * Use this to navigate back AND pass a custom set of arguments with the transition to
//      * the target fragment.
//      *
//      * @param previousFragment ID of the fragment to navigate to
//      * @param args Custom set of arguments to pass with the transition
//      */
//     public FragmentBackButtonOnClickListener(int previousFragment, Bundle args) {
//         mPreviousFragment = previousFragment;
//         mArgs = args;
//     }
// 
//     @Override
//     public void onClick(View v) {
//         boolean customArgs = mArgs != null;
// 
//         Log.d(TAG, "onClick() - custom args set: " + customArgs);
// 
//         // If custom args are set, treat the transition as a 'regular' fragment transition.
//         Message msg = customArgs ? UiUpdateHandler.obtainReplaceFragmentMessage(mPreviousFragment) :
//                                     UiUpdateHandler.obtainGoBackMessage();
// 
//         if (customArgs) {
//             // Raise the flag telling that this 'regular' transition is actually a back transition.
//             mArgs.putBoolean(UiUpdateHandler.ARG_IS_BACK_TRANSITION, true);
//             mArgs.putAll(msg.getData()); // Add all the original args as well, as e.g. the target
//                                         // fragment ID is set there.
//             msg.setData(mArgs);
//         }
// 
//         msg.sendToTarget();
//     }
// }
// 
// Path: app/src/main/java/jaakko/jaaska/apptycoon/ui/listener/TextViewChangeColourOnTouchListener.java
// public class TextViewChangeColourOnTouchListener implements View.OnTouchListener {
// 
//     private int mOnTouchColor;
//     private int mOriginalColor;
// 
//     /**
//      * Constructor.
//      *
//      * Parameter colors are {@link android.graphics.Color Color} colors.
//      *
//      * @param onTouchColor Color of the text when touched.
//      * @param originalColor Original color of the text.
//      */
//     public TextViewChangeColourOnTouchListener(int onTouchColor, int originalColor) {
//         mOnTouchColor = onTouchColor;
//         mOriginalColor = originalColor;
//     }
// 
//     @Override
//     public boolean onTouch(View v, MotionEvent event) {
//         // The view is ALWAYS a TextViews.
//         TextView tv = (TextView) v;
// 
//         switch (event.getAction()) {
//             case MotionEvent.ACTION_DOWN:
//                 tv.setTextColor(mOnTouchColor);
//                 break;
//             default:
//                 tv.setTextColor(mOriginalColor);
//         }
//         return false;
//     }
// }


import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import jaakko.jaaska.apptycoon.R;
import jaakko.jaaska.apptycoon.ui.listener.FragmentBackButtonOnClickListener;
import jaakko.jaaska.apptycoon.ui.listener.TextViewChangeColourOnTouchListener;
     *
     * @param fragmentId ID of the fragment to navigate back to.
     * @param args Arguments to pass to the previous fragment.
     */
    protected void showCustomBackButton(int fragmentId, @Nullable Bundle args) {
        Log.d(TAG, "setBackTargetFragment() - fragmentId = " + fragmentId);
        mBackFragment = fragmentId;
        mBackArgs = args;
        bindBackButton();
    }

    /**
     * Set an action for the action button on the fragment title bar.
     * @param label Label to be shown on the action button.
     * @param action Action to perform when the button is clicked.
     */
    protected void setAction(String label, Action action) {
        Log.d(TAG, "setAction() - label = '" + label + "'");
        mActionLabel = label;
        mAction = action;
        bindActionButton();
    }

    private void bindBackButton() {
        Log.d(TAG, "bindBackButton()");
        mTextViewBack.setVisibility(View.VISIBLE);
        mTextViewBack.setOnTouchListener(new TextViewChangeColourOnTouchListener(Color.BLACK,
                mTextViewBack.getCurrentTextColor()));

        // Use the listener with custom target and arguments if they're defined.
// Path: app/src/main/java/jaakko/jaaska/apptycoon/ui/listener/FragmentBackButtonOnClickListener.java
// public class FragmentBackButtonOnClickListener implements View.OnClickListener {
//     private static final String TAG = "FBBOCL";
// 
//     private Bundle mArgs;
//     private int mPreviousFragment;
// 
//     /**
//      * Use this to simply navigate one step back on the navigation stack.
//      */
//     public FragmentBackButtonOnClickListener() {
// 
//     }
// 
//     /**
//      * Use this to navigate back AND pass a custom set of arguments with the transition to
//      * the target fragment.
//      *
//      * @param previousFragment ID of the fragment to navigate to
//      * @param args Custom set of arguments to pass with the transition
//      */
//     public FragmentBackButtonOnClickListener(int previousFragment, Bundle args) {
//         mPreviousFragment = previousFragment;
//         mArgs = args;
//     }
// 
//     @Override
//     public void onClick(View v) {
//         boolean customArgs = mArgs != null;
// 
//         Log.d(TAG, "onClick() - custom args set: " + customArgs);
// 
//         // If custom args are set, treat the transition as a 'regular' fragment transition.
//         Message msg = customArgs ? UiUpdateHandler.obtainReplaceFragmentMessage(mPreviousFragment) :
//                                     UiUpdateHandler.obtainGoBackMessage();
// 
//         if (customArgs) {
//             // Raise the flag telling that this 'regular' transition is actually a back transition.
//             mArgs.putBoolean(UiUpdateHandler.ARG_IS_BACK_TRANSITION, true);
//             mArgs.putAll(msg.getData()); // Add all the original args as well, as e.g. the target
//                                         // fragment ID is set there.
//             msg.setData(mArgs);
//         }
// 
//         msg.sendToTarget();
//     }
// }
// 
// Path: app/src/main/java/jaakko/jaaska/apptycoon/ui/listener/TextViewChangeColourOnTouchListener.java
// public class TextViewChangeColourOnTouchListener implements View.OnTouchListener {
// 
//     private int mOnTouchColor;
//     private int mOriginalColor;
// 
//     /**
//      * Constructor.
//      *
//      * Parameter colors are {@link android.graphics.Color Color} colors.
//      *
//      * @param onTouchColor Color of the text when touched.
//      * @param originalColor Original color of the text.
//      */
//     public TextViewChangeColourOnTouchListener(int onTouchColor, int originalColor) {
//         mOnTouchColor = onTouchColor;
//         mOriginalColor = originalColor;
//     }
// 
//     @Override
//     public boolean onTouch(View v, MotionEvent event) {
//         // The view is ALWAYS a TextViews.
//         TextView tv = (TextView) v;
// 
//         switch (event.getAction()) {
//             case MotionEvent.ACTION_DOWN:
//                 tv.setTextColor(mOnTouchColor);
//                 break;
//             default:
//                 tv.setTextColor(mOriginalColor);
//         }
//         return false;
//     }
// }


// Path: app/src/main/java/jaakko/jaaska/apptycoon/ui/fragment/AppTycoonFragment.java
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import jaakko.jaaska.apptycoon.R;
import jaakko.jaaska.apptycoon.ui.listener.FragmentBackButtonOnClickListener;
import jaakko.jaaska.apptycoon.ui.listener.TextViewChangeColourOnTouchListener;

     *
     * @param fragmentId ID of the fragment to navigate back to.
     * @param args Arguments to pass to the previous fragment.
     */
    protected void showCustomBackButton(int fragmentId, @Nullable Bundle args) {
        Log.d(TAG, "setBackTargetFragment() - fragmentId = " + fragmentId);
        mBackFragment = fragmentId;
        mBackArgs = args;
        bindBackButton();
    }

    /**
     * Set an action for the action button on the fragment title bar.
     * @param label Label to be shown on the action button.
     * @param action Action to perform when the button is clicked.
     */
    protected void setAction(String label, Action action) {
        Log.d(TAG, "setAction() - label = '" + label + "'");
        mActionLabel = label;
        mAction = action;
        bindActionButton();
    }

    private void bindBackButton() {
        Log.d(TAG, "bindBackButton()");
        mTextViewBack.setVisibility(View.VISIBLE);
        mTextViewBack.setOnTouchListener(new TextViewChangeColourOnTouchListener(Color.BLACK,
                mTextViewBack.getCurrentTextColor()));

        // Use the listener with custom target and arguments if they're defined.
        FragmentBackButtonOnClickListener listener = mBackFragment < 0 ?