import
android.os.Bundle;
import
android.view.View;
import
android.widget.AdapterView;
import
android.widget.ArrayAdapter;
import
android.widget.Button;
import
android.widget.Spinner;
import
androidx.appcompat.app.AppCompatActivity;
import
com.thecode.aestheticdialogs.AestheticDialog;
import
com.thecode.aestheticdialogs.DialogAnimation;
import
com.thecode.aestheticdialogs.DialogStyle;
import
com.thecode.aestheticdialogs.DialogType;
import
java.util.ArrayList;
public
class
MainActivity
extends
AppCompatActivity {
Spinner spStyle, spType, spAnimation;
Button btShow;
ArrayList<DialogStyle> styleList =
new
ArrayList<>();
ArrayList<DialogType> typeList =
new
ArrayList<>();
ArrayList<DialogAnimation> Animationlist =
new
ArrayList<>();
DialogStyle dialogStyle;
DialogAnimation dialogAnimation;
DialogType dialogType;
@Override
protected
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spStyle = findViewById(R.id.sp_style);
spType = findViewById(R.id.sp_type);
spAnimation = findViewById(R.id.sp_animation);
btShow = findViewById(R.id.bt_show);
styleList.add(DialogStyle.FLASH);
styleList.add(DialogStyle.CONNECTIFY);
styleList.add(DialogStyle.TOASTER);
styleList.add(DialogStyle.EMOJI);
styleList.add(DialogStyle.EMOTION);
styleList.add(DialogStyle.DRAKE);
styleList.add(DialogStyle.RAINBOW);
styleList.add(DialogStyle.FLAT);
spStyle.setAdapter(
new
ArrayAdapter<>(
this
, android.R.layout.simple_spinner_dropdown_item, styleList));
typeList.add(DialogType.ERROR);
typeList.add(DialogType.INFO);
typeList.add(DialogType.WARNING);
typeList.add(DialogType.SUCCESS);
spType.setAdapter(
new
ArrayAdapter<>(
this
, android.R.layout.simple_spinner_dropdown_item, typeList));
Animationlist.add(DialogAnimation.FADE);
Animationlist.add(DialogAnimation.CARD);
Animationlist.add(DialogAnimation.DEFAULT);
Animationlist.add(DialogAnimation.DIAGONAL);
Animationlist.add(DialogAnimation.IN_OUT);
Animationlist.add(DialogAnimation.SHRINK);
Animationlist.add(DialogAnimation.SLIDE_DOWN);
Animationlist.add(DialogAnimation.SLIDE_LEFT);
Animationlist.add(DialogAnimation.SLIDE_RIGHT);
Animationlist.add(DialogAnimation.SLIDE_UP);
Animationlist.add(DialogAnimation.SPIN);
Animationlist.add(DialogAnimation.SPLIT);
Animationlist.add(DialogAnimation.SWIPE_LEFT);
Animationlist.add(DialogAnimation.SWIPE_RIGHT);
Animationlist.add(DialogAnimation.WINDMILL);
Animationlist.add(DialogAnimation.ZOOM);
spAnimation.setAdapter(
new
ArrayAdapter<>(
this
, android.R.layout.simple_spinner_dropdown_item, Animationlist));
spStyle.setOnItemSelectedListener(
new
AdapterView.OnItemSelectedListener() {
@Override
public
void
onItemSelected(AdapterView<?> adapterView, View view,
int
i,
long
l) {
dialogStyle = styleList.get(i);
}
@Override
public
void
onNothingSelected(AdapterView<?> adapterView) {
}
});
spType.setOnItemSelectedListener(
new
AdapterView.OnItemSelectedListener() {
@Override
public
void
onItemSelected(AdapterView<?> adapterView, View view,
int
i,
long
l) {
dialogType = typeList.get(i);
}
@Override
public
void
onNothingSelected(AdapterView<?> adapterView) {
}
});
spAnimation.setOnItemSelectedListener(
new
AdapterView.OnItemSelectedListener() {
@Override
public
void
onItemSelected(AdapterView<?> adapterView, View view,
int
i,
long
l) {
dialogAnimation = Animationlist.get(i);
}
@Override
public
void
onNothingSelected(AdapterView<?> adapterView) {
}
});
btShow.setOnClickListener(
new
View.OnClickListener() {
@Override
public
void
onClick(View view) {
AestheticDialog.Builder builder =
new
AestheticDialog.Builder(MainActivity.
this
, dialogStyle, dialogType);
builder.setTitle(
"Title"
);
builder.setMessage(
"Message"
);
builder.setAnimation(dialogAnimation);
builder.show();
}
});
}
}