use of com.daimajia.slider.library.Animations.DescriptionAnimation 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.daimajia.slider.library.Animations.DescriptionAnimation 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.daimajia.slider.library.Animations.DescriptionAnimation in project CoCoin by Nightonke.
the class AccountBookListViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_account_book_list_view);
mContext = this;
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());
}
int size = RecordManager.getInstance(CoCoinApplication.getAppContext()).RECORDS.size();
if (RecordManager.getInstance(CoCoinApplication.getAppContext()).SELECTED_RECORDS == null) {
RecordManager.getInstance(CoCoinApplication.getAppContext()).SELECTED_RECORDS = new LinkedList<>();
}
RecordManager.getInstance(CoCoinApplication.getAppContext()).SELECTED_RECORDS.clear();
for (int i = 0; i < size; i++) {
CoCoinRecord record = new CoCoinRecord();
record.set(RecordManager.RECORDS.get(i));
RecordManager.getInstance(CoCoinApplication.getAppContext()).SELECTED_RECORDS.add(record);
}
RecordManager.getInstance(CoCoinApplication.getAppContext()).SELECTED_SUM = Double.valueOf(RecordManager.getInstance(CoCoinApplication.getAppContext()).SUM);
originalSum = RecordManager.getInstance(CoCoinApplication.getAppContext()).SELECTED_SUM;
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
setTitle("");
mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= Build.VERSION_CODES.LOLLIPOP) {
// Do something for lollipop and above versions
Window window = this.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ContextCompat.getColor(mContext, R.color.statusBarColor));
} else {
// do something for phones running an SDK before lollipop
View statusBarView = (View) findViewById(R.id.status_bar_view);
statusBarView.getLayoutParams().height = CoCoinUtil.getStatusBarHeight();
}
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);
searchView = (MaterialSearchView) findViewById(R.id.search_view);
searchView.setVoiceSearch(false);
searchView.setHint(mContext.getResources().getString(R.string.input_remark_to_search));
searchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
progressDialog = new MaterialDialog.Builder(mContext).title(R.string.selecting_title).content(R.string.selecting_content).cancelable(false).progress(true, 0).show();
new SelectRecordsByRemark(query).execute();
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
searchView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {
@Override
public void onSearchViewShown() {
//Do some magic
Log.d("Saver", "onSearchViewShown");
}
@Override
public void onSearchViewClosed() {
//Do some magic
Log.d("Saver", "onSearchViewClosed");
}
});
emptyTip = (TextView) findViewById(R.id.empty_tip);
emptyTip.setTypeface(CoCoinUtil.GetTypeface());
recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
layoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false);
recyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
recyclerViewTouchActionGuardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
recyclerViewTouchActionGuardManager.setEnabled(true);
recyclerViewSwipeManager = new RecyclerViewSwipeManager();
mAdapter = new MySwipeableItemAdapter(mContext, RecordManager.SELECTED_RECORDS, this, this);
mAdapter.setEventListener(new MySwipeableItemAdapter.EventListener() {
@Override
public void onItemRemoved(int position) {
activityOnItemRemoved(position);
}
@Override
public void onItemPinned(int position) {
activityOnItemPinned(position);
}
@Override
public void onItemViewClicked(View v, boolean pinned) {
int position = recyclerView.getChildAdapterPosition(v);
if (position != RecyclerView.NO_POSITION) {
activityOnItemClicked(position);
}
}
});
adapter = mAdapter;
wrappedAdapter = recyclerViewSwipeManager.createWrappedAdapter(mAdapter);
final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
animator.setSupportsChangeAnimations(false);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(wrappedAdapter);
recyclerView.setItemAnimator(animator);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
recyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(mContext, R.drawable.material_shadow_z1)));
}
recyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(mContext, R.drawable.list_divider_h), true));
// NOTE:
// The initialization order is very important! This order determines the priority of touch event handling.
//
// priority: TouchActionGuard > Swipe > DragAndDrop
recyclerViewTouchActionGuardManager.attachRecyclerView(recyclerView);
recyclerViewSwipeManager.attachRecyclerView(recyclerView);
verticalRecyclerViewFastScroller = (VerticalRecyclerViewFastScroller) findViewById(R.id.fast_scroller);
// Connect the recycler to the scroller (to let the scroller scroll the list)
verticalRecyclerViewFastScroller.setRecyclerView(recyclerView);
// Connect the scroller to the recycler (to let the recycler scroll the scroller's handle)
recyclerView.setOnScrollListener(verticalRecyclerViewFastScroller.getOnScrollListener());
CoCoinUtil.backupCoCoinRecord = null;
if (RecordManager.SELECTED_RECORDS.size() == 0) {
emptyTip.setVisibility(View.VISIBLE);
verticalRecyclerViewFastScroller.setVisibility(View.INVISIBLE);
} else {
emptyTip.setVisibility(View.GONE);
verticalRecyclerViewFastScroller.setVisibility(View.VISIBLE);
}
infoLayout = (FrameLayout) mDrawer.findViewById(R.id.info_layout);
LinearLayout.LayoutParams infoLayoutParams = new LinearLayout.LayoutParams(infoLayout.getLayoutParams());
infoLayoutParams.setMargins(0, CoCoinUtil.getStatusBarHeight() - CoCoinUtil.dpToPx(30), 0, 0);
infoLayout.setLayoutParams(infoLayoutParams);
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));
titleExpense = (TextView) findViewById(R.id.title_expense);
titleExpense.setTypeface(CoCoinUtil.typefaceLatoLight);
titleExpense.setText(CoCoinUtil.GetInMoney((int) (double) RecordManager.getInstance(mContext).SELECTED_SUM));
titleSum = (TextView) findViewById(R.id.title_sum);
titleSum.setTypeface(CoCoinUtil.typefaceLatoLight);
titleSum.setText(RecordManager.getInstance(mContext).SELECTED_RECORDS.size() + "'s");
// titleSlider = (SliderLayout)findViewById(R.id.title_slider);
// titleSlider.getLayoutParams().height = 48;
// titleSlider.getLayoutParams().width = 400 - CoCoinUtil.dpToPx(60 * 2);
//
// HashMap<String, Integer> urls2 = CoCoinUtil.getTransparentUrls();
//
// CustomTitleSliderView customTitleSliderView = new CustomTitleSliderView(0 + "'s", CoCoinFragmentManager.NUMBER_SLIDER);
// customTitleSliderView
// .image(urls2.get("0"))
// .setScaleType(BaseSliderView.ScaleType.Fit);
// titleSlider.addSlider(customTitleSliderView);
//
// customTitleSliderView = new CustomTitleSliderView(CoCoinUtil.GetInMoney(0), CoCoinFragmentManager.EXPENSE_SLIDER);
// customTitleSliderView
// .image(urls2.get("1"))
// .setScaleType(BaseSliderView.ScaleType.Fit);
// titleSlider.addSlider(customTitleSliderView);
//
// titleSlider.setPresetTransformer(SliderLayout.Transformer.ZoomOut);
// titleSlider.setCustomAnimation(new DescriptionAnimation());
// titleSlider.setDuration(3000);
// titleSlider.setCustomIndicator((PagerIndicator) findViewById(R.id.custom_indicator));
((TextView) findViewById(R.id.tag_title)).setTypeface(CoCoinUtil.GetTypeface());
((TextView) findViewById(R.id.tag_title_expense)).setTypeface(CoCoinUtil.GetTypeface());
((TextView) findViewById(R.id.tag_title_time)).setTypeface(CoCoinUtil.GetTypeface());
((TextView) findViewById(R.id.tag_title_tag)).setTypeface(CoCoinUtil.GetTypeface());
setMoney = (TextView) findViewById(R.id.select_expense);
setMoney.setTypeface(CoCoinUtil.GetTypeface());
setMoney.setOnClickListener(this);
noMoney = (TextView) findViewById(R.id.no_expense);
noMoney.setTypeface(CoCoinUtil.GetTypeface());
noMoney.setOnClickListener(this);
setTime = (TextView) findViewById(R.id.select_time);
setTime.setTypeface(CoCoinUtil.GetTypeface());
setTime.setOnClickListener(this);
noTime = (TextView) findViewById(R.id.no_time);
noTime.setTypeface(CoCoinUtil.GetTypeface());
noTime.setOnClickListener(this);
setTag = (TextView) findViewById(R.id.select_tag);
setTag.setTypeface(CoCoinUtil.GetTypeface());
setTag.setOnClickListener(this);
noTag = (TextView) findViewById(R.id.no_tag);
noTag.setTypeface(CoCoinUtil.GetTypeface());
noTag.setOnClickListener(this);
select = (TextView) findViewById(R.id.select);
select.setTypeface(CoCoinUtil.GetTypeface());
select.setOnClickListener(this);
leftExpense = (TextView) findViewById(R.id.left_expense);
leftExpense.setTypeface(CoCoinUtil.GetTypeface());
rightExpense = (TextView) findViewById(R.id.right_expense);
rightExpense.setTypeface(CoCoinUtil.GetTypeface());
leftTime = (TextView) findViewById(R.id.left_time);
leftTime.setTypeface(CoCoinUtil.GetTypeface());
rightTime = (TextView) findViewById(R.id.right_time);
rightTime.setTypeface(CoCoinUtil.GetTypeface());
tagImage = (ImageView) findViewById(R.id.tag_image);
tagName = (TextView) findViewById(R.id.tag_name);
tagName.setTypeface(CoCoinUtil.GetTypeface());
setConditions();
loadLogo();
}
use of com.daimajia.slider.library.Animations.DescriptionAnimation 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();
}
Aggregations