A collection of Kotlin extensions for Android
**Java** ````java Intent intent = new Intent(this, SuperPowersActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); ````Kotlin
val flags = flags(Intent.FLAG_ACTIVITY_NEW_TASK, Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity<SuperPowersActivity>(flags)
Java
LayoutInflater layoutInflater = LayoutInflater.from(this);
View awesomeView = layoutInflater.inflate(R.layout.my_awesome_layout, null);
Kotlin
val awesomeView = inflateLayout(R.layout.my_awesome_layout)
Kotlin
i("Howdy! Info")
d("Knock knock! Debug")
e("Grim, Error")
wtf("Damn! WTF")
Kotlin
getDefaultSharedPreferences().putBoolean("KEY_WALKTHROUGH_COMPLETE", complete)
Kotlin
showShortToast(R.string.welcome)
Kotlin
showShortToast(view)
Java
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Kotlin
val alarmManager = context.alarmManager()
val notificationManager = context.notificationManager()
Kotlin
val sourceSansPro = typefaceFromAssets("fonts/source-sans-pro.ttf")
More extensions under development.
Copyright 2015 Mobs & Geeks
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.