// Path: app/src/main/java/com/ccjeng/news/view/adapter/NewsCategoryAdapter.java
// public class NewsCategoryAdapter extends RecyclerView.Adapter<NewsCategoryAdapter.CustomViewHolder>{
// 
//     private String[] mArrayString;
//     private Context mContext;
// 
//     public NewsCategoryAdapter(Context context) {
//         this.mContext = context;
//     }
// 
//     public void setData(String[] arrayString) {
//         this.mArrayString = arrayString;
//         notifyDataSetChanged();
//     }
// 
//     @Override
//     public CustomViewHolder onCreateViewHolder(ViewGroup parent, int i) {
//         View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.category_item, parent, false);
// 
//         CustomViewHolder viewHolder = new CustomViewHolder(view);
// 
//         return viewHolder;
//     }
// 
//     @Override
//     public void onBindViewHolder(CustomViewHolder customViewHolder, int i) {
//         //Setting text view title
//         customViewHolder.textView.setText(mArrayString[i]);
//     }
// 
//     @Override
//     public int getItemCount() {
//         return (null != mArrayString ? mArrayString.length : 0);
//     }
// 
//     public class CustomViewHolder extends RecyclerView.ViewHolder {
//         //protected ImageView imageView;
//         protected TextView textView;
// 
//         public CustomViewHolder(View view) {
//             super(view);
//             //this.imageView = (ImageView) view.findViewById(R.id.icon);
//             this.textView = (TextView) view.findViewById(R.id.row);
//         }
// 
//     }
// }
// 
// Path: app/src/main/java/com/ccjeng/news/view/adapter/RecyclerItemClickListener.java
// public class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener {
//     private OnItemClickListener mListener;
// 
//     public interface OnItemClickListener {
//         public void onItemClick(View view, int position);
//     }
// 
//     GestureDetector mGestureDetector;
// 
//     public RecyclerItemClickListener(Context context, OnItemClickListener listener) {
//         mListener = listener;
//         mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
//             @Override
//             public boolean onSingleTapUp(MotionEvent e) {
//                 return true;
//             }
//         });
//     }
// 
//     @Override
//     public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) {
//         View childView = view.findChildViewUnder(e.getX(), e.getY());
//         if (childView != null && mListener != null && mGestureDetector.onTouchEvent(e)) {
//             mListener.onItemClick(childView, view.getChildAdapterPosition(childView));
//         }
//         return false;
//     }
// 
//     @Override
//     public void onTouchEvent(RecyclerView view, MotionEvent motionEvent) {
//     }
// 
//     @Override
//     public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
// 
//     }
// }


import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import com.ccjeng.news.R;
import com.ccjeng.news.view.adapter.NewsCategoryAdapter;
import com.ccjeng.news.view.adapter.RecyclerItemClickListener;

        FrameLayout fl = new FrameLayout(getActivity());
        fl.setLayoutParams(params);

        RecyclerView v = new RecyclerView(getActivity());

        LinearLayoutManager llm = new LinearLayoutManager(getActivity());
        v.setLayoutManager(llm);
        v.setHasFixedSize(true);

        switch (position) {
            case 0:
                newsSource = getResources().getStringArray(R.array.newsSourceTW);
                tabName = "TW";
                break;
            case 1:
                newsSource = getResources().getStringArray(R.array.newsSourceHK);
                tabName = "HK";
                break;
            case 2:
                newsSource = getResources().getStringArray(R.array.newsSourceSG);
                tabName = "SG";
                break;
        }

        NewsCategoryAdapter adapter = new NewsCategoryAdapter(getActivity());
        v.setAdapter(adapter);
        adapter.setData(newsSource);

        v.addOnItemTouchListener(
// Path: app/src/main/java/com/ccjeng/news/view/adapter/NewsCategoryAdapter.java
// public class NewsCategoryAdapter extends RecyclerView.Adapter<NewsCategoryAdapter.CustomViewHolder>{
// 
//     private String[] mArrayString;
//     private Context mContext;
// 
//     public NewsCategoryAdapter(Context context) {
//         this.mContext = context;
//     }
// 
//     public void setData(String[] arrayString) {
//         this.mArrayString = arrayString;
//         notifyDataSetChanged();
//     }
// 
//     @Override
//     public CustomViewHolder onCreateViewHolder(ViewGroup parent, int i) {
//         View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.category_item, parent, false);
// 
//         CustomViewHolder viewHolder = new CustomViewHolder(view);
// 
//         return viewHolder;
//     }
// 
//     @Override
//     public void onBindViewHolder(CustomViewHolder customViewHolder, int i) {
//         //Setting text view title
//         customViewHolder.textView.setText(mArrayString[i]);
//     }
// 
//     @Override
//     public int getItemCount() {
//         return (null != mArrayString ? mArrayString.length : 0);
//     }
// 
//     public class CustomViewHolder extends RecyclerView.ViewHolder {
//         //protected ImageView imageView;
//         protected TextView textView;
// 
//         public CustomViewHolder(View view) {
//             super(view);
//             //this.imageView = (ImageView) view.findViewById(R.id.icon);
//             this.textView = (TextView) view.findViewById(R.id.row);
//         }
// 
//     }
// }
// 
// Path: app/src/main/java/com/ccjeng/news/view/adapter/RecyclerItemClickListener.java
// public class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener {
//     private OnItemClickListener mListener;
// 
//     public interface OnItemClickListener {
//         public void onItemClick(View view, int position);
//     }
// 
//     GestureDetector mGestureDetector;
// 
//     public RecyclerItemClickListener(Context context, OnItemClickListener listener) {
//         mListener = listener;
//         mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
//             @Override
//             public boolean onSingleTapUp(MotionEvent e) {
//                 return true;
//             }
//         });
//     }
// 
//     @Override
//     public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) {
//         View childView = view.findChildViewUnder(e.getX(), e.getY());
//         if (childView != null && mListener != null && mGestureDetector.onTouchEvent(e)) {
//             mListener.onItemClick(childView, view.getChildAdapterPosition(childView));
//         }
//         return false;
//     }
// 
//     @Override
//     public void onTouchEvent(RecyclerView view, MotionEvent motionEvent) {
//     }
// 
//     @Override
//     public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
// 
//     }
// }


// Path: app/src/main/java/com/ccjeng/news/view/TabFragment.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import com.ccjeng.news.R;
import com.ccjeng.news.view.adapter.NewsCategoryAdapter;
import com.ccjeng.news.view.adapter.RecyclerItemClickListener;


        FrameLayout fl = new FrameLayout(getActivity());
        fl.setLayoutParams(params);

        RecyclerView v = new RecyclerView(getActivity());

        LinearLayoutManager llm = new LinearLayoutManager(getActivity());
        v.setLayoutManager(llm);
        v.setHasFixedSize(true);

        switch (position) {
            case 0:
                newsSource = getResources().getStringArray(R.array.newsSourceTW);
                tabName = "TW";
                break;
            case 1:
                newsSource = getResources().getStringArray(R.array.newsSourceHK);
                tabName = "HK";
                break;
            case 2:
                newsSource = getResources().getStringArray(R.array.newsSourceSG);
                tabName = "SG";
                break;
        }

        NewsCategoryAdapter adapter = new NewsCategoryAdapter(getActivity());
        v.setAdapter(adapter);
        adapter.setData(newsSource);

        v.addOnItemTouchListener(
                new RecyclerItemClickListener(getActivity(), new RecyclerItemClickListener.OnItemClickListener() {