Skip to content

Instantly share code, notes, and snippets.

View akbarsha03's full-sized avatar
🎯
I just keep trying

Akbarsha M akbarsha03

🎯
I just keep trying
View GitHub Profile
NotificationManagerCompat.from(context).apply {
notify(101, NotificationCompat.Builder(context).run {
setStyle(NotificationCompatV4.InboxStyle().addLine("You have new message"))
setContentTitle(getNotificationTitleForPreNougat(dialog, dialogMessages))
setAutoCancel(true)
setContentIntent(getPendingIntent()))
setSmallIcon(R.drawable.ic_launcher)
build()
})
object Api {
val instance: RestAPI = Retrofit.Builder().run {
baseUrl(AppConst.API.BASE_URL)
addCallAdapterFactory(RxJavaCallAdapterFactory.create())
addConverterFactory(JacksonConverterFactory.create(ObjectMapper()))
client(OkHttpClient.Builder()
.apply {
addInterceptor(HttpLoggingInterceptor()
.apply { level = HttpLoggingInterceptor.Level.BODY })
.takeIf { BuildConfig.DEBUG }
class Factory {
public static Api create() {
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
if (BuildConfig.DEBUG) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
httpClient.addInterceptor(logging);
}
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
NotificationCompat.Builder(this).apply builder@ { // object 1 reference
setSmallIcon(R.drawable.ic_launcher)
setContentTitle("My notification")
setContentText("Hello world!")
Intent(this, HomeActivity::class.java).apply resultIntent@ { // object 2 reference
TaskStackBuilder.create(this).apply {
addParentStack(HomeActivity::class.java)
addNextIntent(this@resultIntent)
this@builder.setContentIntent(getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT))
// object 1
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle("My notification")
.setContentText("Hello World!");
// object 2
Intent resultIntent = new Intent(this, ResultActivity.class);
val contact = ContactModel()
val isSuccess = contact.run {
var isSuccess = false
try {
ActiveAndroid.beginTransaction()
groupName = "GROUP NAME"
type "PRIVATE"
subject = "PHYSICS GROUP"
save()
data class Person(var name: String? = null, var address: Address? = null, var age: Int? = null, var sex: String? = null, var lat: Double? = null, var lng: Double? = null)
data class Address(var streetName: String? = null, var pinCode: String? = null)
Person().apply {
name = "PERSON NAME"
sex = "MALE"
address = Address().apply {
streetName = "STREET NAME"
pinCode = "560029"
}
AlertDialog.Builder(this).apply {
setMessage("Kotlin message")
this.setPositiveButton("button 1") { dialog, _ ->
dialog.dismiss()
}
setNegativeButton("button 2") { dialog, _ ->
dialog.dismiss()
}
create()
show()
val intent = Intent(Intent.ACTION_SEND).apply {
type = "text/plain"
putExtra(Intent.EXTRA_EMAIL, "emailaddress@emailaddress.com")
putExtra(Intent.EXTRA_EMAIL, "emailaddress@emailaddress.com")
putExtra(Intent.EXTRA_SUBJECT, "Subject")
putExtra(Intent.EXTRA_TEXT, "I'm email body.")
}
startActivity(intent)