use of com.nightonke.saver.adapter.ButtonGridViewAdapter in project CoCoin by Nightonke.
the class EditRecordActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_record);
overridePendingTransition(R.anim.trans_left_in, R.anim.trans_left_out);
mContext = this;
superToast = new SuperToast(this);
Bundle extras = getIntent().getExtras();
if (extras != null) {
position = extras.getInt("POSITION");
CoCoinUtil.editRecordPosition = RecordManager.SELECTED_RECORDS.size() - 1 - position;
} else {
CoCoinUtil.editRecordPosition = -1;
}
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
}
// edit viewpager///////////////////////////////////////////////////////////////////////////////////
editViewPager = (CoCoinScrollableViewPager) findViewById(R.id.edit_pager);
editViewPager.setOverScrollMode(View.OVER_SCROLL_NEVER);
editAdapter = new EditMoneyRemarkFragmentAdapter(getSupportFragmentManager(), CoCoinFragmentManager.EDIT_RECORD_ACTIVITY_FRAGMENT);
editViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
if (position == 1) {
CoCoinFragmentManager.editRecordActivityEditRemarkFragment.editRequestFocus();
} else {
CoCoinFragmentManager.editRecordActivityEditMoneyFragment.editRequestFocus();
}
}
@Override
public void onPageSelected(int position) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
editViewPager.setAdapter(editAdapter);
// tag viewpager////////////////////////////////////////////////////////////////////////////////////
tagViewPager = (ViewPager) findViewById(R.id.viewpager);
tagViewPager.setOverScrollMode(View.OVER_SCROLL_NEVER);
if (RecordManager.TAGS.size() % 8 == 0)
tagAdapter = new TagChooseFragmentAdapter(getSupportFragmentManager(), RecordManager.TAGS.size() / 8);
else
tagAdapter = new TagChooseFragmentAdapter(getSupportFragmentManager(), RecordManager.TAGS.size() / 8 + 1);
tagViewPager.setAdapter(tagAdapter);
myGridView = (MyGridView) findViewById(R.id.gridview);
myGridViewAdapter = new ButtonGridViewAdapter(this);
myGridView.setAdapter(myGridViewAdapter);
myGridView.setOnItemClickListener(gridViewClickListener);
myGridView.setOnItemLongClickListener(gridViewLongClickListener);
myGridView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
myGridView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
View lastChild = myGridView.getChildAt(myGridView.getChildCount() - 1);
myGridView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, lastChild.getBottom()));
}
});
back = (MaterialIconView) findViewById(R.id.back);
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
}
use of com.nightonke.saver.adapter.ButtonGridViewAdapter in project CoCoin by Nightonke.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mContext = this;
// Bmob.initialize(CoCoinApplication.getAppContext(), CoCoin.APPLICATION_ID);
// CrashReport.initCrashReport(CoCoinApplication.getAppContext(), "900016815", false);
// RecordManager.getInstance(CoCoinApplication.getAppContext());
// CoCoinUtil.init(CoCoinApplication.getAppContext());
appUpdateManager = new AppUpdateManager(mContext);
appUpdateManager.checkUpdateInfo(false);
sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
Sensor magneticSensor = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
Sensor accelerometerSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
sensorManager.registerListener(listener, magneticSensor, SensorManager.SENSOR_DELAY_GAME);
sensorManager.registerListener(listener, accelerometerSensor, SensorManager.SENSOR_DELAY_GAME);
superToast = new SuperToast(this);
superActivityToast = new SuperActivityToast(this, SuperToast.Type.PROGRESS_HORIZONTAL);
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
Log.d("Saver", "Version number: " + currentapiVersion);
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
}
User user = BmobUser.getCurrentUser(CoCoinApplication.getAppContext(), User.class);
if (user != null) {
SettingManager.getInstance().setLoggenOn(true);
SettingManager.getInstance().setUserName(user.getUsername());
SettingManager.getInstance().setUserEmail(user.getEmail());
showToast(WELCOME_BACK);
// 允许用户使用应用
} else {
SettingManager.getInstance().setLoggenOn(false);
//缓存用户对象为空时, 可打开用户注册界面…
}
guillotineBackground = findViewById(R.id.guillotine_background);
toolBarTitle = (TextView) findViewById(R.id.guillotine_title);
toolBarTitle.setTypeface(CoCoinUtil.typefaceLatoLight);
toolBarTitle.setText(SettingManager.getInstance().getAccountBookName());
// edit viewpager///////////////////////////////////////////////////////////////////////////////////
editViewPager = (CoCoinScrollableViewPager) findViewById(R.id.edit_pager);
editAdapter = new EditMoneyRemarkFragmentAdapter(getSupportFragmentManager(), CoCoinFragmentManager.MAIN_ACTIVITY_FRAGMENT);
editViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
if (position == 1) {
if (CoCoinFragmentManager.mainActivityEditRemarkFragment != null)
CoCoinFragmentManager.mainActivityEditRemarkFragment.editRequestFocus();
} else {
if (CoCoinFragmentManager.mainActivityEditMoneyFragment != null)
CoCoinFragmentManager.mainActivityEditMoneyFragment.editRequestFocus();
}
}
@Override
public void onPageSelected(int position) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
editViewPager.setAdapter(editAdapter);
// tag viewpager////////////////////////////////////////////////////////////////////////////////////
tagViewPager = (ViewPager) findViewById(R.id.viewpager);
if (RecordManager.getInstance(mContext).TAGS.size() % 8 == 0)
tagAdapter = new TagChooseFragmentAdapter(getSupportFragmentManager(), RecordManager.TAGS.size() / 8);
else
tagAdapter = new TagChooseFragmentAdapter(getSupportFragmentManager(), RecordManager.TAGS.size() / 8 + 1);
tagViewPager.setAdapter(tagAdapter);
// button grid view/////////////////////////////////////////////////////////////////////////////////
myGridView = (MyGridView) findViewById(R.id.gridview);
myGridViewAdapter = new ButtonGridViewAdapter(this);
myGridView.setAdapter(myGridViewAdapter);
myGridView.setOnItemClickListener(gridViewClickListener);
myGridView.setOnItemLongClickListener(gridViewLongClickListener);
myGridView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
myGridView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
View lastChild = myGridView.getChildAt(myGridView.getChildCount() - 1);
myGridView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, lastChild.getBottom()));
ViewGroup.LayoutParams params = transparentLy.getLayoutParams();
params.height = myGridView.getMeasuredHeight();
}
});
ButterKnife.inject(this);
if (toolbar != null) {
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(null);
}
toolbar.hideOverflowMenu();
guillotineMenu = LayoutInflater.from(this).inflate(R.layout.guillotine, null);
root.addView(guillotineMenu);
transparentLy = (LinearLayout) guillotineMenu.findViewById(R.id.transparent_ly);
guillotineColorLy = (LinearLayout) guillotineMenu.findViewById(R.id.guillotine_color_ly);
guillotineToolBar = (Toolbar) guillotineMenu.findViewById(R.id.toolbar);
menuToolBarTitle = (TextView) guillotineMenu.findViewById(R.id.guillotine_title);
menuToolBarTitle.setTypeface(CoCoinUtil.typefaceLatoLight);
menuToolBarTitle.setText(SettingManager.getInstance().getAccountBookName());
radioButton0 = (RadioButton) guillotineMenu.findViewById(R.id.radio_button_0);
radioButton1 = (RadioButton) guillotineMenu.findViewById(R.id.radio_button_1);
radioButton2 = (RadioButton) guillotineMenu.findViewById(R.id.radio_button_2);
radioButton3 = (RadioButton) guillotineMenu.findViewById(R.id.radio_button_3);
passwordTip = (TextView) guillotineMenu.findViewById(R.id.password_tip);
passwordTip.setText(mContext.getResources().getString(R.string.password_tip));
passwordTip.setTypeface(CoCoinUtil.typefaceLatoLight);
radioButtonLy = (LinearLayout) guillotineMenu.findViewById(R.id.radio_button_ly);
statusButton = (MaterialMenuView) guillotineMenu.findViewById(R.id.status_button);
statusButton.setState(MaterialMenuDrawable.IconState.ARROW);
statusButton.setOnClickListener(statusButtonOnClickListener);
animation = new GuillotineAnimation.GuillotineBuilder(guillotineMenu, guillotineMenu.findViewById(R.id.guillotine_hamburger), contentHamburger).setStartDelay(RIPPLE_DURATION).setActionBarViewForAnimation(toolbar).setClosedOnStart(true).setGuillotineListener(new GuillotineListener() {
@Override
public void onGuillotineOpened() {
isPassword = true;
}
@Override
public void onGuillotineClosed() {
isPassword = false;
CoCoinFragmentManager.mainActivityEditMoneyFragment.editRequestFocus();
radioButton0.setChecked(false);
radioButton1.setChecked(false);
radioButton2.setChecked(false);
radioButton3.setChecked(false);
inputPassword = "";
statusButton.setState(MaterialMenuDrawable.IconState.ARROW);
}
}).build();
toolbar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
animation.open();
}
});
if (SettingManager.getInstance().getFirstTime()) {
Intent intent = new Intent(mContext, ShowActivity.class);
startActivity(intent);
}
if (SettingManager.getInstance().getShowMainActivityGuide()) {
boolean wrapInScrollView = true;
new MaterialDialog.Builder(this).title(R.string.guide).typeface(CoCoinUtil.GetTypeface(), CoCoinUtil.GetTypeface()).customView(R.layout.main_activity_guide, wrapInScrollView).positiveText(R.string.ok).show();
SettingManager.getInstance().setShowMainActivityGuide(false);
}
}
Aggregations