// Path: demo/src/main/java/com/gtomato/android/util/Metrics.java
// public class Metrics {
// 	/**
// 	 * Covert dp to px
// 	 * @param dp
// 	 * @param context
// 	 * @return pixel
// 	 */
// 	public static float convertDpToPixel(float dp, Context context){
// 		float px = dp * getDensity(context);
// 		return px;
// 	}
// 
// 	/**
// 	 * Covert px to dp
// 	 * @param px
// 	 * @param context
// 	 * @return dp
// 	 */
// 	public static float convertPixelToDp(float px, Context context){
// 		float dp = px / getDensity(context);
// 		return dp;
// 	}
// 
// 	/**
// 	 * Get density
// 	 * 120dpi = 0.75
// 	 * 160dpi = 1 (default)
// 	 * 240dpi = 1.5
// 	 * @param context
// 	 * @return
// 	 */
// 	public static float getDensity(Context context){
// 		DisplayMetrics metrics = context.getResources().getDisplayMetrics();
// 		return metrics.density;
// 	}
// }


import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.gtomato.android.util.Metrics;
import java.util.Random;
package com.gtomato.android.demo.carouselviewdemo;






/**
 * A simple {@link android.support.v4.app.Fragment} subclass.
 */
public class RandomPageFragment extends Fragment {
	public final static String TEXT = "TEXT";

	private String text;

	public RandomPageFragment() {
		// Required empty public constructor
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		text = getArguments().getString(TEXT);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
	                         Bundle savedInstanceState) {
		return createView(getActivity(), 100, 150, text);
	}

	public static View createView(Context context, int widthDp, int heightDp, String text) {
//		FrameLayout l = new FrameLayout(context);
//		l.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
		Log.d("page", "w = " + widthDp + ", h = " + heightDp);

		TextView textView = new TextView(context);
		textView.setId(R.id.carousel_child_container);
		textView.setLayoutParams(new FrameLayout.LayoutParams(
// Path: demo/src/main/java/com/gtomato/android/util/Metrics.java
// public class Metrics {
// 	/**
// 	 * Covert dp to px
// 	 * @param dp
// 	 * @param context
// 	 * @return pixel
// 	 */
// 	public static float convertDpToPixel(float dp, Context context){
// 		float px = dp * getDensity(context);
// 		return px;
// 	}
// 
// 	/**
// 	 * Covert px to dp
// 	 * @param px
// 	 * @param context
// 	 * @return dp
// 	 */
// 	public static float convertPixelToDp(float px, Context context){
// 		float dp = px / getDensity(context);
// 		return dp;
// 	}
// 
// 	/**
// 	 * Get density
// 	 * 120dpi = 0.75
// 	 * 160dpi = 1 (default)
// 	 * 240dpi = 1.5
// 	 * @param context
// 	 * @return
// 	 */
// 	public static float getDensity(Context context){
// 		DisplayMetrics metrics = context.getResources().getDisplayMetrics();
// 		return metrics.density;
// 	}
// }


// Path: demo/src/main/java/com/gtomato/android/demo/carouselviewdemo/RandomPageFragment.java
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.gtomato.android.util.Metrics;
import java.util.Random;

package com.gtomato.android.demo.carouselviewdemo;






/**
 * A simple {@link android.support.v4.app.Fragment} subclass.
 */
public class RandomPageFragment extends Fragment {
	public final static String TEXT = "TEXT";

	private String text;

	public RandomPageFragment() {
		// Required empty public constructor
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		text = getArguments().getString(TEXT);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
	                         Bundle savedInstanceState) {
		return createView(getActivity(), 100, 150, text);
	}

	public static View createView(Context context, int widthDp, int heightDp, String text) {
//		FrameLayout l = new FrameLayout(context);
//		l.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
		Log.d("page", "w = " + widthDp + ", h = " + heightDp);

		TextView textView = new TextView(context);
		textView.setId(R.id.carousel_child_container);
		textView.setLayoutParams(new FrameLayout.LayoutParams(
				widthDp > 0 ? (int) Metrics.convertDpToPixel(widthDp, context) : ViewGroup.LayoutParams.MATCH_PARENT,