Search in sources :

Example 6 with MyGridView

use of com.nightonke.saver.ui.MyGridView 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 7 with MyGridView

use of com.nightonke.saver.ui.MyGridView 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)

Example 8 with MyGridView

use of com.nightonke.saver.ui.MyGridView in project CoCoin by Nightonke.

the class TagChooseFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.tag_choose_fragment, container, false);
    myGridView = (MyGridView) view.findViewById(R.id.gridview);
    fragmentPosition = getArguments().getInt("position");
    if (fragmentPosition >= CoCoinFragmentManager.tagChooseFragments.size()) {
        while (fragmentPosition >= CoCoinFragmentManager.tagChooseFragments.size()) {
            CoCoinFragmentManager.tagChooseFragments.add(new TagChooseFragment());
        }
    }
    CoCoinFragmentManager.tagChooseFragments.set(fragmentPosition, this);
    tagAdapter = new TagChooseGridViewAdapter(getActivity(), fragmentPosition);
    myGridView.setAdapter(tagAdapter);
    myGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            try {
                ((OnTagItemSelectedListener) activity).onTagItemPicked(position);
                ((OnTagItemSelectedListener) activity).onAnimationStart(RecordManager.TAGS.get(fragmentPosition * 8 + position + 2).getId());
            } catch (ClassCastException cce) {
                cce.printStackTrace();
            }
        }
    });
    return view;
}
Also used : TagChooseGridViewAdapter(com.nightonke.saver.adapter.TagChooseGridViewAdapter) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) MyGridView(com.nightonke.saver.ui.MyGridView) AdapterView(android.widget.AdapterView)

Aggregations

View (android.view.View)8 AdapterView (android.widget.AdapterView)8 MyGridView (com.nightonke.saver.ui.MyGridView)8 TextView (android.widget.TextView)7 ViewPager (android.support.v4.view.ViewPager)5 ViewTreeObserver (android.view.ViewTreeObserver)5 SuperToast (com.github.johnpersano.supertoasts.SuperToast)5 Window (android.view.Window)4 ImageView (android.widget.ImageView)3 PasswordChangeButtonGridViewAdapter (com.nightonke.saver.adapter.PasswordChangeButtonGridViewAdapter)3 PasswordChangeFragmentAdapter (com.nightonke.saver.adapter.PasswordChangeFragmentAdapter)3 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)2 Interpolator (android.view.animation.Interpolator)2 BmobUser (cn.bmob.v3.BmobUser)2 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)2 BaseSliderView (com.daimajia.slider.library.SliderTypes.BaseSliderView)2 ButtonGridViewAdapter (com.nightonke.saver.adapter.ButtonGridViewAdapter)2 EditMoneyRemarkFragmentAdapter (com.nightonke.saver.adapter.EditMoneyRemarkFragmentAdapter)2 TagChooseFragmentAdapter (com.nightonke.saver.adapter.TagChooseFragmentAdapter)2 User (com.nightonke.saver.model.User)2