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);
}
});
}
Aggregations