Search in sources :

Example 6 with HeaderDesign

use of com.github.florent37.materialviewpager.header.HeaderDesign in project easy by MehdiBenmesa.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setTitle("");
    ButterKnife.bind(this);
    final Toolbar toolbar = mViewPager.getToolbar();
    if (toolbar != null) {
        setSupportActionBar(toolbar);
    }
    mViewPager.getViewPager().setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int position) {
            switch(position % 4) {
                //    return WebViewFragment.newInstance();
                default:
                    return RecyclerViewFragment.newInstance();
            }
        }

        @Override
        public int getCount() {
            return 4;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            switch(position % 4) {
                case 0:
                    return "Selection";
                case 1:
                    return "Actualités";
                case 2:
                    return "Professionnel";
                case 3:
                    return "Divertissement";
            }
            return "";
        }
    });
    mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {

        @Override
        public HeaderDesign getHeaderDesign(int page) {
            switch(page) {
                case 0:
                    return HeaderDesign.fromColorResAndUrl(R.color.green, "http://phandroid.s3.amazonaws.com/wp-content/uploads/2014/06/android_google_moutain_google_now_1920x1080_wallpaper_Wallpaper-HD_2560x1600_www.paperhi.com_-640x400.jpg");
                case 1:
                    return HeaderDesign.fromColorResAndUrl(R.color.blue, "http://www.hdiphonewallpapers.us/phone-wallpapers/540x960-1/540x960-mobile-wallpapers-hd-2218x5ox3.jpg");
                case 2:
                    return HeaderDesign.fromColorResAndUrl(R.color.cyan, "http://www.droid-life.com/wp-content/uploads/2014/10/lollipop-wallpapers10.jpg");
                case 3:
                    return HeaderDesign.fromColorResAndUrl(R.color.red, "http://www.tothemobile.com/wp-content/uploads/2014/07/original.jpg");
            }
            return null;
        }
    });
    mViewPager.getViewPager().setOffscreenPageLimit(mViewPager.getViewPager().getAdapter().getCount());
    mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());
    final View logo = findViewById(R.id.logo_white);
    if (logo != null) {
        logo.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mViewPager.notifyHeaderChanged();
                Toast.makeText(getApplicationContext(), "Yes, the title is clickable", Toast.LENGTH_SHORT).show();
            }
        });
    }
}
Also used : FragmentStatePagerAdapter(android.support.v4.app.FragmentStatePagerAdapter) MaterialViewPager(com.github.florent37.materialviewpager.MaterialViewPager) HeaderDesign(com.github.florent37.materialviewpager.header.HeaderDesign) Fragment(android.support.v4.app.Fragment) RecyclerViewFragment(com.github.florent37.materialviewpager.sample.fragment.RecyclerViewFragment) BindView(butterknife.BindView) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Example 7 with HeaderDesign

use of com.github.florent37.materialviewpager.header.HeaderDesign in project easy by MehdiBenmesa.

the class MaterialViewPager method onPageSelected.

//region ViewPagerOnPageListener
@Override
public void onPageSelected(int position) {
    if (position == lastPosition || listener == null) {
        return;
    }
    HeaderDesign headerDesign = listener.getHeaderDesign(position);
    if (headerDesign == null) {
        return;
    }
    int fadeDuration = 400;
    int color = headerDesign.getColor();
    if (headerDesign.getColorRes() != 0) {
        color = getContext().getResources().getColor(headerDesign.getColorRes());
    }
    if (headerDesign.getDrawable() != null) {
        setImageDrawable(headerDesign.getDrawable(), fadeDuration);
    } else {
        setImageUrl(headerDesign.getImageUrl(), fadeDuration);
    }
    setColor(color, fadeDuration);
    lastPosition = position;
}
Also used : HeaderDesign(com.github.florent37.materialviewpager.header.HeaderDesign)

Example 8 with HeaderDesign

use of com.github.florent37.materialviewpager.header.HeaderDesign in project easy by MehdiBenmesa.

the class NoteAbsenceActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setTitle("");
    ButterKnife.bind(this);
    final Toolbar toolbar = mViewPager.getToolbar();
    if (toolbar != null) {
        setSupportActionBar(toolbar);
    }
    Intent intent = getIntent();
    String jsonString = intent.getStringExtra("user");
    try {
        user = new JSONObject(jsonString);
        SessionManager sessionManager = new SessionManager(this);
        sessionManager.createLoginSession(user.getString("name"), user.getString("mail"), user.getString("_id"));
        Resources res = getResources();
        String text = user.getString("lastname") + " " + user.getString("name");
        ((TextView) findViewById(R.id.logo_white)).setText(text);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    /*
        mViewPager.getViewPager().setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {

            @Override
            public Fragment getItem(int position) {
                switch (position % 3) {
                    case 0:
                        return AbsenceFragment.newInstance(user);
                    case 1:
                        return AbsenceFragment.newInstance(user);
                    default:
                        return AbsenceFragment.newInstance(user);
                }
            }

            @Override
            public int getCount() {
                return 3;
            }

            @Override
            public CharSequence getPageTitle(int position) {
                switch (position % 3) {
                    case 0:
                        return getResources().getString(R.string.NoteManager);
                    case 1:
                        return getResources().getString(R.string.AbsentManager);
                    case 2:
                        return getResources().getString(R.string.TimetableManager);

                }
                return "";
            }
        });
*/
    mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {

        @Override
        public HeaderDesign getHeaderDesign(int page) {
            switch(page) {
                case 0:
                    return HeaderDesign.fromColorResAndUrl(R.color.green, "http://phandroid.s3.amazonaws.com/wp-content/uploads/2014/06/android_google_moutain_google_now_1920x1080_wallpaper_Wallpaper-HD_2560x1600_www.paperhi.com_-640x400.jpg");
                case 1:
                    return HeaderDesign.fromColorResAndUrl(R.color.blue, "http://www.hdiphonewallpapers.us/phone-wallpapers/540x960-1/540x960-mobile-wallpapers-hd-2218x5ox3.jpg");
                case 2:
                    return HeaderDesign.fromColorResAndUrl(R.color.cyan, "http://www.droid-life.com/wp-content/uploads/2014/10/lollipop-wallpapers10.jpg");
            }
            return null;
        }
    });
    mViewPager.getViewPager().setOffscreenPageLimit(mViewPager.getViewPager().getAdapter().getCount());
    mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());
    final View logo = findViewById(R.id.logo_white);
    if (logo != null) {
        logo.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mViewPager.notifyHeaderChanged();
                Toast.makeText(getApplicationContext(), "Yes, the title is clickable", Toast.LENGTH_SHORT).show();
            }
        });
    }
}
Also used : MaterialViewPager(com.github.florent37.materialviewpager.MaterialViewPager) SessionManager(dz.easy.androidclient.Util.SessionManager) HeaderDesign(com.github.florent37.materialviewpager.header.HeaderDesign) JSONException(org.json.JSONException) Intent(android.content.Intent) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View) JSONObject(org.json.JSONObject) TextView(android.widget.TextView) Resources(android.content.res.Resources) Toolbar(android.support.v7.widget.Toolbar)

Example 9 with HeaderDesign

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

the class AboutActivity 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(), 2);
    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 10 with HeaderDesign

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

the class AccountBookCustomViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;
    setContentView(R.layout.activity_account_book_custom_view);
    mViewPager = (MaterialViewPager) findViewById(R.id.materialViewPager);
    View view = mViewPager.getRootView();
    TextView title = (TextView) view.findViewById(R.id.logo_white);
    title.setTypeface(CoCoinUtil.getInstance().typefaceLatoLight);
    title.setText(SettingManager.getInstance().getAccountBookName());
    mViewPager.getPagerTitleStrip().setTypeface(CoCoinUtil.GetTypeface(), Typeface.NORMAL);
    mViewPager.getPagerTitleStrip().setVisibility(View.INVISIBLE);
    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();
            }
        });
    }
    customViewFragmentAdapter = new CustomViewFragmentAdapter(getSupportFragmentManager());
    mViewPager.getViewPager().setOffscreenPageLimit(1);
    mViewPager.getViewPager().setAdapter(customViewFragmentAdapter);
    mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());
    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) CustomViewFragmentAdapter(com.nightonke.saver.adapter.CustomViewFragmentAdapter) HeaderDesign(com.github.florent37.materialviewpager.header.HeaderDesign) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) ActionBar(android.support.v7.app.ActionBar)

Aggregations

HeaderDesign (com.github.florent37.materialviewpager.header.HeaderDesign)14 View (android.view.View)12 MaterialViewPager (com.github.florent37.materialviewpager.MaterialViewPager)12 ActionBar (android.support.v7.app.ActionBar)8 TextView (android.widget.TextView)7 Toolbar (android.support.v7.widget.Toolbar)4 BindView (butterknife.BindView)4 Fragment (android.support.v4.app.Fragment)3 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)3 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 Intent (android.content.Intent)2 Handler (android.os.Handler)2 RecyclerViewFragment (com.github.florent37.materialviewpager.sample.fragment.RecyclerViewFragment)2