// Path: app/src/main/java/com/github/cchao/touchnews/ui/adapter/ImageFragmentsPagerAdapter.java
// public class ImageFragmentsPagerAdapter extends FragmentPagerAdapter {
//     private List<Fragment> mListFragments = null;
//     private String[] mTitles = null;
// 
//     public ImageFragmentsPagerAdapter(FragmentManager fm, String[] titles, List fragments) {
//         super(fm);
//         mListFragments = fragments;
//         mTitles = titles;
// 
//     }
// 
//     @Override
//     public int getCount() {
//         if (mListFragments != null) {
//             return mListFragments.size();
//         } else {
//             return 0;
//         }
//     }
// 
//     @Override
//     public Fragment getItem(int position) {
//         if (mListFragments != null && position >= 0 && position < mListFragments.size()) {
//             return mListFragments.get(position);
//         } else {
//             return null;
//         }
//     }
// 
//     @Override
//     public CharSequence getPageTitle(int position) {
//         return mTitles[position];
//     }
// }


import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.github.cchao.touchnews.R;
import com.github.cchao.touchnews.ui.adapter.ImageFragmentsPagerAdapter;
import java.util.ArrayList;
import java.util.List;
import butterknife.Bind;
import butterknife.ButterKnife;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        View view = inflater.inflate(R.layout.fragment_image, null);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        setTableLayout();
    }

    private void initData() {
        mTitles = getResources().getStringArray(R.array.news_titles);

        mFragments = new ArrayList<>();
        for (int i = 0; i < mTitles.length; i++) {
            Bundle mBundle = new Bundle();
            mBundle.putInt("flag", i);
//                        Fragment fragment = new NewsListFragments ( );
//                        fragment.setArguments ( mBundle );
//                        mFragments.add ( i, fragment );
        }
    }

    private void setTableLayout() {

// Path: app/src/main/java/com/github/cchao/touchnews/ui/adapter/ImageFragmentsPagerAdapter.java
// public class ImageFragmentsPagerAdapter extends FragmentPagerAdapter {
//     private List<Fragment> mListFragments = null;
//     private String[] mTitles = null;
// 
//     public ImageFragmentsPagerAdapter(FragmentManager fm, String[] titles, List fragments) {
//         super(fm);
//         mListFragments = fragments;
//         mTitles = titles;
// 
//     }
// 
//     @Override
//     public int getCount() {
//         if (mListFragments != null) {
//             return mListFragments.size();
//         } else {
//             return 0;
//         }
//     }
// 
//     @Override
//     public Fragment getItem(int position) {
//         if (mListFragments != null && position >= 0 && position < mListFragments.size()) {
//             return mListFragments.get(position);
//         } else {
//             return null;
//         }
//     }
// 
//     @Override
//     public CharSequence getPageTitle(int position) {
//         return mTitles[position];
//     }
// }


// Path: app/src/main/java/com/github/cchao/touchnews/ui/fragment/ImageContainerFragment.java
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.github.cchao.touchnews.R;
import com.github.cchao.touchnews.ui.adapter.ImageFragmentsPagerAdapter;
import java.util.ArrayList;
import java.util.List;
import butterknife.Bind;
import butterknife.ButterKnife;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        View view = inflater.inflate(R.layout.fragment_image, null);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        setTableLayout();
    }

    private void initData() {
        mTitles = getResources().getStringArray(R.array.news_titles);

        mFragments = new ArrayList<>();
        for (int i = 0; i < mTitles.length; i++) {
            Bundle mBundle = new Bundle();
            mBundle.putInt("flag", i);
//                        Fragment fragment = new NewsListFragments ( );
//                        fragment.setArguments ( mBundle );
//                        mFragments.add ( i, fragment );
        }
    }

    private void setTableLayout() {

        mFragmentsPagerAdapter = new ImageFragmentsPagerAdapter(getActivity().getSupportFragmentManager(), mTitles, mFragments);