Search in sources :

Example 1 with ImageFragment

use of com.mixiaoxiao.ninegag.fragment.ImageFragment in project 9GAG by Mixiaoxiao.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MxxSystemBarTintUtil.setSystemBarTintColor(this);
    SpannableString spannableString = new SpannableString("9GAG");
    String font = "LockScreen_Clock.ttf";
    spannableString.setSpan(new TypefaceSpan(font, Typeface.createFromAsset(getAssets(), font)), 0, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    getActionBar().setTitle(spannableString);
    getActionBar().setDisplayShowHomeEnabled(false);
    setContentView(R.layout.activity_main);
    mViewPager = (ViewPager) findViewById(R.id.main_viewpager);
    //		scaleImageView = (MxxScaleImageView) findViewById(R.id.main_mxxScaleImageView1);
    mViewPager.setOffscreenPageLimit(3);
    mTabStrip = (MxxPagerSlidingTabStrip) findViewById(R.id.main_tab);
    ArrayList<Fragment> fragments = new ArrayList<Fragment>();
    fragments.add(new GagFragmentHot());
    fragments.add(new GagFragmentTrending());
    fragments.add(new GagFragmentFresh());
    mViewPager.setAdapter(new GagAdapter2(getSupportFragmentManager(), fragments, new String[] { "hot", "trending", "fresh" }));
    mTabStrip.setViewPager(mViewPager);
    initTint();
    mTabStrip.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageSelected(int arg0) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
            // TODO Auto-generated method stub
            if (((ViewGroup) tabLayout).getChildAt(0).getTranslationY() != 0) {
                ((ViewGroup) tabLayout).getChildAt(0).setTranslationY(0);
            }
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        // TODO Auto-generated method stub
        }
    });
    mImageFragment = (ImageFragment) getSupportFragmentManager().findFragmentById(R.id.main_image_fragment);
    mTabStrip.post(new Runnable() {

        @Override
        public void run() {
            // TODO Auto-generated method stub
            getSupportFragmentManager().beginTransaction().hide(mImageFragment).commit();
        }
    });
}
Also used : GagFragmentTrending(com.mixiaoxiao.ninegag.fragment.GagFragmentTrending) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString) ImageFragment(com.mixiaoxiao.ninegag.fragment.ImageFragment) Fragment(android.support.v4.app.Fragment) GagFragment(com.mixiaoxiao.ninegag.fragment.GagFragment) ViewPager(android.support.v4.view.ViewPager) SpannableString(android.text.SpannableString) GagFragmentFresh(com.mixiaoxiao.ninegag.fragment.GagFragmentFresh) GagFragmentHot(com.mixiaoxiao.ninegag.fragment.GagFragmentHot) TypefaceSpan(com.mixiaoxiao.android.view.TypefaceSpan)

Aggregations

Fragment (android.support.v4.app.Fragment)1 ViewPager (android.support.v4.view.ViewPager)1 SpannableString (android.text.SpannableString)1 ViewGroup (android.view.ViewGroup)1 TypefaceSpan (com.mixiaoxiao.android.view.TypefaceSpan)1 GagFragment (com.mixiaoxiao.ninegag.fragment.GagFragment)1 GagFragmentFresh (com.mixiaoxiao.ninegag.fragment.GagFragmentFresh)1 GagFragmentHot (com.mixiaoxiao.ninegag.fragment.GagFragmentHot)1 GagFragmentTrending (com.mixiaoxiao.ninegag.fragment.GagFragmentTrending)1 ImageFragment (com.mixiaoxiao.ninegag.fragment.ImageFragment)1 ArrayList (java.util.ArrayList)1