import
android.os.Bundle;
import
android.view.View;
import
android.view.WindowManager;
import
android.widget.TextView;
import
android.widget.Toast;
import
androidx.appcompat.app.AppCompatActivity;
import
com.tapadoo.alerter.Alerter;
import
com.tapadoo.alerter.OnHideAlertListener;
import
com.tapadoo.alerter.OnShowAlertListener;
public
class
MainActivity
extends
AppCompatActivity {
TextView txt1, txt2, txt3, txt4, txt5, txt6, txt7, txt8, txt9, txt10;
@Override
protected
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
txt1 = findViewById(R.id.txt1);
txt2 = findViewById(R.id.txt2);
txt3 = findViewById(R.id.txt3);
txt4 = findViewById(R.id.txt4);
txt5 = findViewById(R.id.txt5);
txt6 = findViewById(R.id.txt6);
txt7 = findViewById(R.id.txt7);
txt8 = findViewById(R.id.txt8);
txt9 = findViewById(R.id.txt9);
txt10 = findViewById(R.id.txt10);
txt1.setOnClickListener(
new
View.OnClickListener() {
@Override
public
void
onClick(View view) {
simpleAlert();
}
});
txt2.setOnClickListener(
new
View.OnClickListener() {
@Override
public
void
onClick(View view) {
withBackgroundColor();
}
});
txt3.setOnClickListener(
new
View.OnClickListener() {
@Override
public
void
onClick(View view) {
withIcon();
}
});
txt4.setOnClickListener(
new
View.OnClickListener() {
@Override
public
void
onClick(View view) {
withOnScreenDuration();
}
});
txt5.setOnClickListener(
new
View.OnClickListener() {
@Override
public
void
onClick(View view) {
withoutTitle();
}
});
txt6.setOnClickListener(
new
View.OnClickListener() {
@Override
public
void
onClick(View view) {
withOnClickListener();
}
});
txt7.setOnClickListener(
new
View.OnClickListener() {
@Override
public
void
onClick(View view) {
withVerboseText();
}
});
txt8.setOnClickListener(
new
View.OnClickListener() {
@Override
public
void
onClick(View view) {
withSwipeToDismiss();
}
});
txt9.setOnClickListener(
new
View.OnClickListener() {
@Override
public
void
onClick(View view) {
withProgressBar();
}
});
txt10.setOnClickListener(
new
View.OnClickListener() {
@Override
public
void
onClick(View view) {
withVisibilityCallbacks();
}
});
}
public
void
simpleAlert() {
Alerter.create(MainActivity.
this
).setTitle(
"Geeks For Geeks"
)
.setText(
"A portal for Computer Science Student"
).show();
}
public
void
withBackgroundColor() {
Alerter.create(
this
).setTitle(
"Geeks For Geeks"
)
.setText(
"A portal for Computer Science Student"
).setBackgroundColorRes(R.color.purple_200)
.show();
}
public
void
withoutTitle() {
Alerter.create(
this
)
.setText(
"A portal for Computer Science Student"
).show();
}
public
void
withOnClickListener() {
Alerter.create(
this
).setTitle(
"Geeks For Geeks"
)
.setText(
"A portal for Computer Science Student"
).setDuration(
10000
).setOnClickListener(
new
View.OnClickListener() {
@Override
public
void
onClick(View view) {
Toast.makeText(MainActivity.
this
,
"You Clicked Me"
, Toast.LENGTH_LONG).show();
}
}).show();
}
public
void
withVerboseText() {
Alerter.create(
this
).setTitle(
"Geeks For Geeks"
)
.setText(
"A portal for Computer Science Student"
+
"A portal for Computer Science Student"
+
"A portal for Computer Science Student"
).show();
}
public
void
withIcon() {
Alerter.create(
this
).setTitle(
"Geeks For Geeks"
)
.setText(
"A portal for Computer Science Student"
).setIcon(R.drawable.ic_launcher_foreground).setIconColorFilter(
0
)
.show();
}
public
void
withOnScreenDuration() {
Alerter.create(
this
).setTitle(
"Geeks For Geeks"
)
.setText(
"A portal for Computer Science Student"
).setDuration(
10000
)
.show();
}
public
void
withSwipeToDismiss() {
Alerter.create(
this
).setTitle(
"Geeks For Geeks"
)
.setText(
"A portal for Computer Science Student"
).enableSwipeToDismiss()
.show();
}
public
void
withProgressBar() {
Alerter.create(
this
).setTitle(
"Geeks For Geeks"
)
.setText(
"A portal for Computer Science Student"
).enableProgress(
true
)
.setProgressColorRes(R.color.purple_200)
.show();
}
public
void
withVisibilityCallbacks() {
Alerter.create(
this
).setTitle(
"Geeks For Geeks"
)
.setText(
"A portal for Computer Science Student"
).setDuration(
10000
).setOnShowListener(
new
OnShowAlertListener() {
@Override
public
void
onShow() {
Toast.makeText(MainActivity.
this
,
"On Show "
, Toast.LENGTH_SHORT).show();
}
}).setOnHideListener(
new
OnHideAlertListener() {
@Override
public
void
onHide() {
Toast.makeText(MainActivity.
this
,
"On Hide "
, Toast.LENGTH_SHORT).show();
}
}).show();
}
}