Search in sources :

Example 1 with IconicFontDrawable

use of com.atermenji.android.iconicdroid.IconicFontDrawable in project IconicDroid by atermenji.

the class SimpleSampleActivity method initSimpleSample.

private void initSimpleSample() {
    mIconicFontDrawable = new IconicFontDrawable(this);
    mIconicFontDrawableButton = new IconicFontDrawable(this);
    mIconicFontDrawableButton.setIntrinsicWidth(BUTTON_ICON_INTRINSIC_WIDTH);
    mIconicFontDrawableButton.setIntrinsicHeight(BUTTON_ICON_INTRINSIC_HEIGHT);
    if (SDK_INT < JELLY_BEAN) {
        mIconView.setBackgroundDrawable(mIconicFontDrawable);
    } else {
        mIconView.setBackground(mIconicFontDrawable);
    }
    mChangeColorButton.setCompoundDrawablesWithIntrinsicBounds(mIconicFontDrawableButton, null, null, null);
    List<Icon> icons = new ArrayList<Icon>();
    icons.addAll(Arrays.asList(EntypoIcon.values()));
    icons.addAll(Arrays.asList(EntypoSocialIcon.values()));
    icons.addAll(Arrays.asList(FontAwesomeIcon.values()));
    icons.addAll(Arrays.asList(IconicIcon.values()));
    final ArrayAdapter<Icon> adapter = new ArrayAdapter<Icon>(this, android.R.layout.simple_spinner_item, icons);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mIconsSpinner.setAdapter(adapter);
    if (mIcon != null) {
        mIconicFontDrawable.setIcon(mIcon);
        mIconicFontDrawableButton.setIcon(mIcon);
        mIconsSpinner.setSelection(adapter.getPosition(mIcon));
        firstSelect = true;
    }
    mIconsSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            if (!firstSelect) {
                Icon icon = adapter.getItem(pos);
                mIconicFontDrawable.setIcon(icon);
                mIconicFontDrawableButton.setIcon(icon);
            } else {
                firstSelect = false;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    mIconicFontDrawable.setIconColor(Utils.randomColor());
    mIconicFontDrawableButton.setIconColor(Utils.randomColor());
    mCurPaddingTextView.setText("Padding: " + 0);
    mPaddingSeekBar.setMax(ICON_PADDING_MAX);
    mPaddingSeekBar.setProgress(0);
    mPaddingSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mIconicFontDrawable.setIconPadding(progress);
            mCurPaddingTextView.setText("Padding: " + progress);
        }
    });
    mChangeColorButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mIconicFontDrawable.setIconColor(Utils.randomColor());
            mIconicFontDrawable.setContourColor(Utils.randomColor());
            mIconicFontDrawableButton.setIconColor(Utils.randomColor());
            mIconicFontDrawableButton.setContourColor(Utils.randomColor());
        }
    });
    mDrawContourCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                mIconicFontDrawable.setContour(Utils.randomColor(), ICON_CONTOUR_WIDTH);
                mIconicFontDrawableButton.setContour(Utils.randomColor(), BUTTON_ICON_CONTOUR_WIDTH);
            }
            mIconicFontDrawable.drawContour(isChecked);
            mIconicFontDrawableButton.drawContour(isChecked);
        }
    });
}
Also used : ArrayList(java.util.ArrayList) OnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener) View(android.view.View) IconicFontDrawable(com.atermenji.android.iconicdroid.IconicFontDrawable) OnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) OnClickListener(android.view.View.OnClickListener) EntypoSocialIcon(com.atermenji.android.iconicdroid.icon.EntypoSocialIcon) EntypoIcon(com.atermenji.android.iconicdroid.icon.EntypoIcon) Icon(com.atermenji.android.iconicdroid.icon.Icon) FontAwesomeIcon(com.atermenji.android.iconicdroid.icon.FontAwesomeIcon) IconicIcon(com.atermenji.android.iconicdroid.icon.IconicIcon)

Aggregations

View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 OnItemSelectedListener (android.widget.AdapterView.OnItemSelectedListener)1 OnSeekBarChangeListener (android.widget.SeekBar.OnSeekBarChangeListener)1 IconicFontDrawable (com.atermenji.android.iconicdroid.IconicFontDrawable)1 EntypoIcon (com.atermenji.android.iconicdroid.icon.EntypoIcon)1 EntypoSocialIcon (com.atermenji.android.iconicdroid.icon.EntypoSocialIcon)1 FontAwesomeIcon (com.atermenji.android.iconicdroid.icon.FontAwesomeIcon)1 Icon (com.atermenji.android.iconicdroid.icon.Icon)1 IconicIcon (com.atermenji.android.iconicdroid.icon.IconicIcon)1 ArrayList (java.util.ArrayList)1