use of com.nightonke.saver.adapter.DrawerMonthViewRecyclerViewAdapter.OnItemClickListener 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();
}
Aggregations