use of com.nightonke.saver.ui.FixedSpeedScroller in project CoCoin by Nightonke.
the class EditPasswordActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_password);
overridePendingTransition(R.anim.trans_left_in, R.anim.trans_left_out);
mContext = this;
int currentapiVersion = 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
}
viewPager = (ViewPager) findViewById(R.id.viewpager);
try {
Interpolator sInterpolator = new AccelerateInterpolator();
Field mScroller;
mScroller = ViewPager.class.getDeclaredField("mScroller");
mScroller.setAccessible(true);
FixedSpeedScroller scroller = new FixedSpeedScroller(viewPager.getContext(), sInterpolator);
scroller.setmDuration(1000);
mScroller.set(viewPager, scroller);
} catch (NoSuchFieldException e) {
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
}
adapter = new PasswordChangeFragmentAdapter(getSupportFragmentManager());
viewPager.setOffscreenPageLimit(3);
viewPager.setScrollBarFadeDuration(1000);
viewPager.setAdapter(adapter);
myGridView = (MyGridView) findViewById(R.id.gridview);
myGridViewAdapter = new PasswordChangeButtonGridViewAdapter(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();
}
});
superToast = new SuperToast(this);
title = (TextView) findViewById(R.id.title);
title.setTypeface(CoCoinUtil.typefaceLatoLight);
if (SettingManager.getInstance().getFirstTime()) {
title.setText(mContext.getResources().getString(R.string.app_name));
} else {
title.setText(mContext.getResources().getString(R.string.change_password));
}
}
use of com.nightonke.saver.ui.FixedSpeedScroller in project CoCoin by Nightonke.
the class SetPasswordActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_password);
overridePendingTransition(R.anim.trans_left_in, R.anim.trans_left_out);
mContext = this;
int currentapiVersion = 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
}
viewPager = (ViewPager) findViewById(R.id.viewpager);
try {
Interpolator sInterpolator = new AccelerateInterpolator();
Field mScroller;
mScroller = ViewPager.class.getDeclaredField("mScroller");
mScroller.setAccessible(true);
FixedSpeedScroller scroller = new FixedSpeedScroller(viewPager.getContext(), sInterpolator);
scroller.setmDuration(1000);
mScroller.set(viewPager, scroller);
} catch (NoSuchFieldException e) {
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
}
passwordAdapter = new PasswordChangeFragmentAdapter(getSupportFragmentManager());
viewPager.setOffscreenPageLimit(2);
viewPager.setScrollBarFadeDuration(1000);
viewPager.setAdapter(passwordAdapter);
myGridView = (MyGridView) findViewById(R.id.gridview);
myGridViewAdapter = new PasswordChangeButtonGridViewAdapter(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.setVisibility(View.INVISIBLE);
superToast = new SuperToast(this);
title = (TextView) findViewById(R.id.title);
title.setTypeface(CoCoinUtil.typefaceLatoLight);
if (SettingManager.getInstance().getFirstTime()) {
title.setText(mContext.getResources().getString(R.string.app_name));
} else {
title.setText(mContext.getResources().getString(R.string.change_password));
}
}
Aggregations