use of com.github.johnpersano.supertoasts.library.SuperToast in project SuperToasts by JohnPersano.
the class SuperToastFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final FloatingActionButton button = (FloatingActionButton) getActivity().findViewById(R.id.floating_action_button);
button.setOnClickListener(new View.OnClickListener() {
@Override
@SuppressWarnings("ResourceType")
public void onClick(View view) {
new SuperToast(getActivity()).setText("SuperToast").setDuration(AttributeUtils.getDuration(getActivity())).setFrame(AttributeUtils.getFrame(getActivity())).setColor(AttributeUtils.getColor(getActivity())).setAnimations(AttributeUtils.getAnimations(getActivity())).setColor(AttributeUtils.getColor(getActivity())).show();
}
});
}
use of com.github.johnpersano.supertoasts.library.SuperToast in project SuperToasts by JohnPersano.
the class Playground method getSuperToast.
private SuperToast getSuperToast() {
final Random random = new Random();
final SuperToast superToast = new SuperToast(Playground.this);
superToast.setText("SuperToast");
final int typefaceArbiter = random.nextInt(5);
switch(typefaceArbiter) {
case 1:
superToast.setTypefaceStyle(Typeface.BOLD);
break;
case 2:
superToast.setTypefaceStyle(Typeface.BOLD_ITALIC);
break;
case 3:
superToast.setTypefaceStyle(Typeface.ITALIC);
break;
default:
superToast.setTypefaceStyle(Typeface.NORMAL);
}
final int animationsArbiter = random.nextInt(4);
switch(animationsArbiter) {
case 1:
superToast.setAnimations(Style.ANIMATIONS_FADE);
break;
case 2:
superToast.setAnimations(Style.ANIMATIONS_FLY);
break;
case 3:
superToast.setAnimations(Style.ANIMATIONS_POP);
break;
default:
superToast.setAnimations(Style.ANIMATIONS_SCALE);
}
int red = random.nextInt(255);
int blue = random.nextInt(255);
int green = random.nextInt(255);
superToast.setColor(Color.argb(255, red, blue, green));
final int frameArbiter = random.nextInt(3);
switch(frameArbiter) {
case 1:
superToast.setFrame(Style.FRAME_KITKAT);
break;
case 2:
superToast.setFrame(Style.FRAME_LOLLIPOP);
break;
default:
superToast.setFrame(Style.FRAME_STANDARD);
break;
}
red = random.nextInt(255);
blue = random.nextInt(255);
green = random.nextInt(255);
superToast.setPriorityColor(Color.argb(255, red, blue, green));
final int gravityArbiter = random.nextInt(6);
switch(gravityArbiter) {
case 1:
superToast.setGravity(Gravity.TOP);
break;
case 2:
superToast.setGravity(Gravity.START);
break;
case 3:
superToast.setGravity(Gravity.END);
break;
default:
break;
}
final int durationArbiter = random.nextInt(3);
switch(durationArbiter) {
case 1:
superToast.setDuration(Style.DURATION_SHORT);
break;
case 2:
superToast.setDuration(Style.DURATION_LONG);
break;
default:
superToast.setDuration(Style.DURATION_MEDIUM);
break;
}
red = random.nextInt(255);
blue = random.nextInt(255);
green = random.nextInt(255);
superToast.setTextColor(Color.argb(255, red, blue, green));
final int textSizeArbiter = random.nextInt(3);
switch(textSizeArbiter) {
case 1:
superToast.setTextSize(Style.TEXTSIZE_SMALL);
break;
case 2:
superToast.setTextSize(Style.TEXTSIZE_LARGE);
break;
default:
superToast.setTextSize(Style.TEXTSIZE_MEDIUM);
break;
}
final int iconArbiter = random.nextInt(10);
switch(iconArbiter) {
case 1:
superToast.setIconResource(Style.ICONPOSITION_BOTTOM, R.drawable.ic_about);
break;
case 2:
superToast.setIconResource(Style.ICONPOSITION_LEFT, R.drawable.ic_about);
break;
case 3:
superToast.setIconResource(Style.ICONPOSITION_RIGHT, R.drawable.ic_about);
break;
case 4:
superToast.setIconResource(Style.ICONPOSITION_TOP, R.drawable.ic_about);
break;
default:
break;
}
return superToast;
}
Aggregations