Search in sources :

Example 6 with MaterialViewPager

use of com.github.florent37.materialviewpager.MaterialViewPager in project CoCoin by Nightonke.

the class AccountBookTagViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;
    setContentView(R.layout.activity_account_book_tag_view);
    mViewPager = (MaterialViewPager) findViewById(R.id.materialViewPager);
    View view = mViewPager.getRootView();
    TextView title = (TextView) view.findViewById(R.id.logo_white);
    title.setTypeface(CoCoinUtil.typefaceLatoLight);
    title.setText(SettingManager.getInstance().getAccountBookName());
    mViewPager.getPagerTitleStrip().setTypeface(CoCoinUtil.typefaceLatoLight, Typeface.NORMAL);
    setTitle("");
    toolbar = mViewPager.getToolbar();
    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    userName = (TextView) findViewById(R.id.user_name);
    userEmail = (TextView) findViewById(R.id.user_email);
    userName.setTypeface(CoCoinUtil.typefaceLatoRegular);
    userEmail.setTypeface(CoCoinUtil.typefaceLatoLight);
    User user = BmobUser.getCurrentUser(CoCoinApplication.getAppContext(), User.class);
    if (user != null) {
        userName.setText(user.getUsername());
        userEmail.setText(user.getEmail());
    }
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        final ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setDisplayShowHomeEnabled(true);
            actionBar.setDisplayShowTitleEnabled(true);
            actionBar.setDisplayUseLogoEnabled(false);
            actionBar.setHomeButtonEnabled(true);
        }
    }
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawer, 0, 0);
    mDrawer.setDrawerListener(mDrawerToggle);
    View logo = findViewById(R.id.logo_white);
    if (logo != null) {
        logo.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mViewPager.notifyHeaderChanged();
            }
        });
    }
    tagModeAdapter = new TagViewFragmentAdapter(getSupportFragmentManager());
    mViewPager.getViewPager().setOffscreenPageLimit(tagModeAdapter.getCount());
    mViewPager.getViewPager().setAdapter(tagModeAdapter);
    mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());
    mViewPager.clearAnimation();
    if (SettingManager.getInstance().getShowPicture()) {
        mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {

            @Override
            public HeaderDesign getHeaderDesign(int page) {
                return HeaderDesign.fromColorAndUrl(CoCoinUtil.GetTagColor(RecordManager.TAGS.get(page).getId()), CoCoinUtil.GetTagUrl(RecordManager.TAGS.get(page).getId()));
            }
        });
    } else {
        mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {

            @Override
            public HeaderDesign getHeaderDesign(int page) {
                return HeaderDesign.fromColorAndDrawable(CoCoinUtil.GetTagColor(RecordManager.TAGS.get(page).getId()), CoCoinUtil.GetTagDrawable(-3));
            }
        });
    }
    myGridView = (MyGridView) mDrawer.findViewById(R.id.grid_view);
    drawerTagChooseAdapter = new DrawerTagChooseGridViewAdapter(mContext);
    myGridView.setAdapter(drawerTagChooseAdapter);
    myGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
            YoYo.with(Techniques.Bounce).delay(0).duration(700).playOn(view);
            mViewPager.getViewPager().setCurrentItem(position);
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    mDrawer.closeDrawers();
                }
            }, 700);
        }
    });
    profileImage = (CircleImageView) mDrawer.findViewById(R.id.profile_image);
    profileImage.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (SettingManager.getInstance().getLoggenOn()) {
                CoCoinUtil.showToast(mContext, R.string.change_logo_tip);
            } else {
                CoCoinUtil.showToast(mContext, R.string.login_tip);
            }
        }
    });
    mDemoSlider = (SliderLayout) findViewById(R.id.slider);
    HashMap<String, Integer> urls = CoCoinUtil.GetDrawerTopUrl();
    for (String name : urls.keySet()) {
        CustomSliderView customSliderView = new CustomSliderView(this);
        // initialize a SliderLayout
        customSliderView.image(urls.get(name)).setScaleType(BaseSliderView.ScaleType.Fit);
        mDemoSlider.addSlider(customSliderView);
    }
    mDemoSlider.setPresetTransformer(SliderLayout.Transformer.ZoomOut);
    mDemoSlider.setCustomAnimation(new DescriptionAnimation());
    mDemoSlider.setDuration(4000);
    mDemoSlider.setCustomIndicator((PagerIndicator) findViewById(R.id.custom_indicator));
    loadLogo();
}
Also used : MaterialViewPager(com.github.florent37.materialviewpager.MaterialViewPager) BmobUser(cn.bmob.v3.BmobUser) User(com.nightonke.saver.model.User) HeaderDesign(com.github.florent37.materialviewpager.header.HeaderDesign) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) TagViewFragmentAdapter(com.nightonke.saver.adapter.TagViewFragmentAdapter) Handler(android.os.Handler) CustomSliderView(com.nightonke.saver.ui.CustomSliderView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) MyGridView(com.nightonke.saver.ui.MyGridView) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) BaseSliderView(com.daimajia.slider.library.SliderTypes.BaseSliderView) CustomSliderView(com.nightonke.saver.ui.CustomSliderView) DescriptionAnimation(com.daimajia.slider.library.Animations.DescriptionAnimation) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) DrawerTagChooseGridViewAdapter(com.nightonke.saver.adapter.DrawerTagChooseGridViewAdapter) ActionBar(android.support.v7.app.ActionBar)

Example 7 with MaterialViewPager

use of com.github.florent37.materialviewpager.MaterialViewPager in project CoCoin by Nightonke.

the class FeedbackActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;
    setContentView(R.layout.activity_help);
    mViewPager = (MaterialViewPager) findViewById(R.id.materialViewPager);
    mViewPager.getPagerTitleStrip().setTypeface(CoCoinUtil.getInstance().typefaceLatoLight, Typeface.NORMAL);
    mViewPager.getPagerTitleStrip().setAllCaps(false);
    mViewPager.getPagerTitleStrip().setUnderlineColor(Color.parseColor("#00000000"));
    mViewPager.getPagerTitleStrip().setIndicatorColor(Color.parseColor("#00000000"));
    mViewPager.getPagerTitleStrip().setUnderlineHeight(0);
    mViewPager.getPagerTitleStrip().setIndicatorHeight(0);
    setTitle("");
    toolbar = mViewPager.getToolbar();
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        final ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setDisplayShowHomeEnabled(true);
            actionBar.setDisplayShowTitleEnabled(true);
            actionBar.setDisplayUseLogoEnabled(false);
            actionBar.setHomeButtonEnabled(true);
        }
    }
    View logo = findViewById(R.id.logo_white);
    if (logo != null) {
        logo.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mViewPager.notifyHeaderChanged();
            }
        });
    }
    adapter = new HelpFragmentAdapter(getSupportFragmentManager(), 1);
    mViewPager.getViewPager().setAdapter(adapter);
    mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());
    mViewPager.getPagerTitleStrip().invalidate();
    mViewPager.getViewPager().setOffscreenPageLimit(2);
    mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {

        @Override
        public HeaderDesign getHeaderDesign(int page) {
            return HeaderDesign.fromColorAndDrawable(ContextCompat.getColor(CoCoinApplication.getAppContext(), R.color.my_blue), ContextCompat.getDrawable(CoCoinApplication.getAppContext(), R.drawable.cocoin_blue_bg));
        }
    });
}
Also used : MaterialViewPager(com.github.florent37.materialviewpager.MaterialViewPager) HeaderDesign(com.github.florent37.materialviewpager.header.HeaderDesign) HelpFragmentAdapter(com.nightonke.saver.adapter.HelpFragmentAdapter) View(android.view.View) ActionBar(android.support.v7.app.ActionBar)

Example 8 with MaterialViewPager

use of com.github.florent37.materialviewpager.MaterialViewPager in project CoCoin by Nightonke.

the class AccountBookReportViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;
    setContentView(R.layout.activity_account_book_report_view);
    mViewPager = (MaterialViewPager) findViewById(R.id.materialViewPager);
    View view = mViewPager.getRootView();
    TextView title = (TextView) view.findViewById(R.id.logo_white);
    title.setTypeface(CoCoinUtil.typefaceLatoLight);
    title.setText(SettingManager.getInstance().getAccountBookName());
    mViewPager.getPagerTitleStrip().setTypeface(CoCoinUtil.getInstance().typefaceLatoLight, Typeface.NORMAL);
    mViewPager.getPagerTitleStrip().setTextSize(45);
    mViewPager.getPagerTitleStrip().setUnderlineColor(Color.parseColor("#00000000"));
    mViewPager.getPagerTitleStrip().setIndicatorColor(Color.parseColor("#00000000"));
    mViewPager.getPagerTitleStrip().setUnderlineHeight(0);
    mViewPager.getPagerTitleStrip().setIndicatorHeight(0);
    mViewPager.getPagerTitleStrip().setOnTabReselectedListener(new PagerSlidingTabStrip.OnTabReselectedListener() {

        @Override
        public void onTabReselected(int position) {
        //                if (CoCoinFragmentManager.reportViewFragment != null)
        //                    CoCoinFragmentManager.reportViewFragment.showDataDialog();
        }
    });
    setTitle("");
    toolbar = mViewPager.getToolbar();
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        final ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setDisplayShowHomeEnabled(true);
            actionBar.setDisplayShowTitleEnabled(true);
            actionBar.setDisplayUseLogoEnabled(false);
            actionBar.setHomeButtonEnabled(true);
        }
    }
    View logo = findViewById(R.id.logo_white);
    if (logo != null) {
        logo.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mViewPager.notifyHeaderChanged();
            }
        });
    }
    reportViewFragmentAdapter = new ReportViewFragmentAdapter(getSupportFragmentManager());
    mViewPager.getViewPager().setOffscreenPageLimit(1);
    mViewPager.getViewPager().setAdapter(reportViewFragmentAdapter);
    mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());
    mViewPager.getPagerTitleStrip().invalidate();
    mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {

        @Override
        public HeaderDesign getHeaderDesign(int page) {
            return HeaderDesign.fromColorAndDrawable(CoCoinUtil.GetTagColor(-3), CoCoinUtil.GetTagDrawable(-3));
        }
    });
}
Also used : MaterialViewPager(com.github.florent37.materialviewpager.MaterialViewPager) PagerSlidingTabStrip(com.astuetz.PagerSlidingTabStrip) HeaderDesign(com.github.florent37.materialviewpager.header.HeaderDesign) TextView(android.widget.TextView) ReportViewFragmentAdapter(com.nightonke.saver.adapter.ReportViewFragmentAdapter) TextView(android.widget.TextView) View(android.view.View) ActionBar(android.support.v7.app.ActionBar)

Aggregations

ActionBar (android.support.v7.app.ActionBar)8 View (android.view.View)8 MaterialViewPager (com.github.florent37.materialviewpager.MaterialViewPager)8 HeaderDesign (com.github.florent37.materialviewpager.header.HeaderDesign)8 TextView (android.widget.TextView)5 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)3 BmobUser (cn.bmob.v3.BmobUser)3 DescriptionAnimation (com.daimajia.slider.library.Animations.DescriptionAnimation)3 BaseSliderView (com.daimajia.slider.library.SliderTypes.BaseSliderView)3 HelpFragmentAdapter (com.nightonke.saver.adapter.HelpFragmentAdapter)3 User (com.nightonke.saver.model.User)3 CustomSliderView (com.nightonke.saver.ui.CustomSliderView)3 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)3 Handler (android.os.Handler)2 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 AdapterView (android.widget.AdapterView)1 PagerSlidingTabStrip (com.astuetz.PagerSlidingTabStrip)1 CustomViewFragmentAdapter (com.nightonke.saver.adapter.CustomViewFragmentAdapter)1