use of com.github.florent37.materialviewpager.header.HeaderDesign in project CoCoin by Nightonke.
the class AccountBookTodayViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_account_book_today_view);
SuperToast.cancelAllSuperToasts();
mContext = this;
mViewPager = (MaterialViewPager) findViewById(R.id.materialViewPager);
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());
}
setFonts();
View view = mViewPager.getRootView();
title = (TextView) view.findViewById(R.id.logo_white);
title.setTypeface(CoCoinUtil.typefaceLatoLight);
title.setText(SettingManager.getInstance().getAccountBookName());
mViewPager.getPagerTitleStrip().setTypeface(CoCoinUtil.GetTypeface(), Typeface.NORMAL);
setTitle("");
toolbar = mViewPager.getToolbar();
mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
custom = (MaterialRippleLayout) mDrawer.findViewById(R.id.custom_layout);
tags = (MaterialRippleLayout) mDrawer.findViewById(R.id.tag_layout);
months = (MaterialRippleLayout) mDrawer.findViewById(R.id.month_layout);
list = (MaterialRippleLayout) mDrawer.findViewById(R.id.list_layout);
report = (MaterialRippleLayout) mDrawer.findViewById(R.id.report_layout);
sync = (MaterialRippleLayout) mDrawer.findViewById(R.id.sync_layout);
settings = (MaterialRippleLayout) mDrawer.findViewById(R.id.settings_layout);
help = (MaterialRippleLayout) mDrawer.findViewById(R.id.help_layout);
feedback = (MaterialRippleLayout) mDrawer.findViewById(R.id.feedback_layout);
about = (MaterialRippleLayout) mDrawer.findViewById(R.id.about_layout);
syncIcon = (MaterialIconView) mDrawer.findViewById(R.id.sync_icon);
setIconEnable(syncIcon, SettingManager.getInstance().getLoggenOn());
monthExpenseTip = (TextView) mDrawer.findViewById(R.id.month_expense_tip);
monthExpenseTip.setTypeface(CoCoinUtil.GetTypeface());
monthExpense = (RiseNumberTextView) mDrawer.findViewById(R.id.month_expense);
monthExpense.setTypeface(CoCoinUtil.typefaceLatoLight);
if (SettingManager.getInstance().getIsMonthLimit()) {
monthExpenseTip.setVisibility(View.VISIBLE);
monthExpense.setText("0");
} else {
monthExpenseTip.setVisibility(View.INVISIBLE);
monthExpense.setVisibility(View.INVISIBLE);
}
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) {
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
monthExpense.setText("0");
}
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
monthExpense.withNumber(RecordManager.getCurrentMonthExpense()).setDuration(500).start();
}
};
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();
}
});
}
todayModeAdapter = new TodayViewFragmentAdapter(getSupportFragmentManager());
mViewPager.getViewPager().setOffscreenPageLimit(todayModeAdapter.getCount());
mViewPager.getViewPager().setAdapter(todayModeAdapter);
mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());
mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {
@Override
public HeaderDesign getHeaderDesign(int page) {
return HeaderDesign.fromColorAndDrawable(CoCoinUtil.GetTagColor(page - 2), CoCoinUtil.GetTagDrawable(-3));
}
});
setListeners();
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();
}
use of com.github.florent37.materialviewpager.header.HeaderDesign in project CoCoin by Nightonke.
the class HelpActivity 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(), 0);
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));
}
});
}
use of com.github.florent37.materialviewpager.header.HeaderDesign in project CoCoin by Nightonke.
the class AccountBookMonthViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = this;
setContentView(R.layout.activity_account_book_month_view);
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());
}
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.GetTypeface(), Typeface.NORMAL);
setTitle("");
toolbar = mViewPager.getToolbar();
mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
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();
}
});
}
monthModeAdapter = new MonthViewFragmentAdapter(getSupportFragmentManager());
mViewPager.getViewPager().setOffscreenPageLimit(monthModeAdapter.getCount());
mViewPager.getViewPager().setAdapter(monthModeAdapter);
mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());
if (monthModeAdapter.getCount() == 1) {
mViewPager.getPagerTitleStrip().setVisibility(View.INVISIBLE);
}
mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {
@Override
public HeaderDesign getHeaderDesign(int page) {
return HeaderDesign.fromColorAndDrawable(CoCoinUtil.GetTagColor(RecordManager.TAGS.get(page).getId()), CoCoinUtil.GetTagDrawable(-3));
}
});
recyclerView = (RecyclerView) mDrawer.findViewById(R.id.recycler_view);
drawerMonthViewRecyclerViewAdapter = new DrawerMonthViewRecyclerViewAdapter(mContext);
recyclerView.setAdapter(drawerMonthViewRecyclerViewAdapter);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
recyclerView.setItemAnimator(new DefaultItemAnimator());
drawerMonthViewRecyclerViewAdapter.SetOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
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();
}
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();
}
});
}
}
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();
}
});
}
}
Aggregations