Search in sources :

Example 1 with FixedSpeedScroller

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));
    }
}
Also used : Window(android.view.Window) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) FixedSpeedScroller(com.nightonke.saver.ui.FixedSpeedScroller) SuperToast(com.github.johnpersano.supertoasts.SuperToast) ViewPager(android.support.v4.view.ViewPager) View(android.view.View) MyGridView(com.nightonke.saver.ui.MyGridView) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) MaterialIconView(net.steamcrafted.materialiconlib.MaterialIconView) PasswordChangeButtonGridViewAdapter(com.nightonke.saver.adapter.PasswordChangeButtonGridViewAdapter) Field(java.lang.reflect.Field) PasswordChangeFragmentAdapter(com.nightonke.saver.adapter.PasswordChangeFragmentAdapter) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) Interpolator(android.view.animation.Interpolator) ViewTreeObserver(android.view.ViewTreeObserver)

Example 2 with FixedSpeedScroller

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));
    }
}
Also used : Window(android.view.Window) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) FixedSpeedScroller(com.nightonke.saver.ui.FixedSpeedScroller) SuperToast(com.github.johnpersano.supertoasts.SuperToast) ViewPager(android.support.v4.view.ViewPager) View(android.view.View) MyGridView(com.nightonke.saver.ui.MyGridView) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) MaterialIconView(net.steamcrafted.materialiconlib.MaterialIconView) PasswordChangeButtonGridViewAdapter(com.nightonke.saver.adapter.PasswordChangeButtonGridViewAdapter) Field(java.lang.reflect.Field) PasswordChangeFragmentAdapter(com.nightonke.saver.adapter.PasswordChangeFragmentAdapter) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) Interpolator(android.view.animation.Interpolator) ViewTreeObserver(android.view.ViewTreeObserver)

Aggregations

ViewPager (android.support.v4.view.ViewPager)2 View (android.view.View)2 ViewTreeObserver (android.view.ViewTreeObserver)2 Window (android.view.Window)2 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)2 Interpolator (android.view.animation.Interpolator)2 AdapterView (android.widget.AdapterView)2 TextView (android.widget.TextView)2 SuperToast (com.github.johnpersano.supertoasts.SuperToast)2 PasswordChangeButtonGridViewAdapter (com.nightonke.saver.adapter.PasswordChangeButtonGridViewAdapter)2 PasswordChangeFragmentAdapter (com.nightonke.saver.adapter.PasswordChangeFragmentAdapter)2 FixedSpeedScroller (com.nightonke.saver.ui.FixedSpeedScroller)2 MyGridView (com.nightonke.saver.ui.MyGridView)2 Field (java.lang.reflect.Field)2 MaterialIconView (net.steamcrafted.materialiconlib.MaterialIconView)2