• Stars
    star
    127
  • Rank 282,790 (Top 6 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created almost 9 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

kotlin-android-extensions

kotlin-extensions

JitPack javadoc Build Status Join the chat at https://gitter.im/yongjhih/kotlin-android-extensions Kotlin

Usage

Database

Before:

db.beginTransaction();
try {
  db.delete("users", "first_name = ?", new String[] { "Andrew" });
  db.setTransactionSuccessful();
} finally {
  db.endTransaction()
}

or

Databases.from(db).inTransaction(it -> {
  it.delete("users", "first_name = ?", new String[] { "Andrew" });
});

After:

db.inTransation {
  delete("users", "first_name = ?", arrayOf("Andrew"))
}

Before:

String firstName = cursor.getString(cursor.getColumnIndexOrThrow("first_name"));

After:

val firstName = cursor.getString("first_name");

Before:

String firstName = null;
int firstNameColumnIndex = cursor.getColumnIndexOrThrow("first_name");
if (!cursor.isNull(firstNameColumnIndex)) {
  firstName = cursor.getString(firstNameColumnIndex);
}
firstNameView.setText(firstName != null ? firstName : "Andrew");

After:

val firstName = cursor.getStringOrNull("first_name")
firstNameView.setText(firstName ?: "Andrew")

SharedPreferences

Before:

SharePreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharePreferences.Editor editor = prefs.edit();
editor.putString("name", "Andrew Chen");
editor.putInt("age", 18, 14);
editor.apply();

After:

User(context).edit {
  name = "Andrew Chen"
  age = "18"
}

public class User(context: Context) : Preferences(context) {
  var name: String by Preference()
  var age: Int by Preference(default = 14)
}

or

User user = User(context)
user.name = "Andrew Chen"
user.age = 18
user.apply()

Bonus - SharedPreferences Extension:

Before:

SharedPreferences.Editor editor = prefs.edit();

editor.putString("first_name", "Andrew");
editor.putString("last_name", "Chen");
editor.remove("age");

editor.apply();

or

SharedPreferencesUtils.from(prefs).apply(editor -> {
  editor.putString("first_name", "Andrew");
  editor.putString("last_name", "Chen");
  editor.remove("age");
});

After:

prefs.edit {
  putString("first_name", "Andrew")
  putString("last_name", "Chen")
  remove("age")
}

System Services

Before:

NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

After:

val notificationManager = context.getNotificationManager()

Notification

Before:

Notification notification = new NotificationCompat.Builder(context)
  .setContentTitle("Hello")
  .setSubText("World")
  .build();

After:

val notification = Notification.build(context) {
  setContentTitle("Hello")
  setSubText("World")
}

Query

Math

Import from MichaelRocks/MathExtensions.kt

ThreeTen Backport (JSR-310)

LocalDateTime.now().toDate()
new Date().toLocalDateTime()

View

view.fadeOut()
view.fadeIn()
for (view in views.children())
if (view in views) {
  // ..
}
views += view
views -= view
views.forEach {}
views.filter {}

Misc

Installation

jitpack:

repositories {
    // ...
    maven { url "https://jitpack.io" }
}

dependencies {
    compile 'com.github.yongjhih.kotlin-extensions:kotlinx-android-sharedpreferences:-SNAPSHOT'
    compile 'com.github.yongjhih.kotlin-extensions:kotlinx-android-database:-SNAPSHOT'
    compile 'com.github.yongjhih.kotlin-extensions:kotlinx-android-system-services:-SNAPSHOT'
    compile 'com.github.yongjhih.kotlin-extensions:kotlinx-android-notification:-SNAPSHOT'
    compile 'com.github.yongjhih.kotlin-extensions:kotlinx-math:-SNAPSHOT'
    compile 'com.github.yongjhih.kotlin-extensions:kotlinx-threetenbp:-SNAPSHOT'
    compile 'com.github.yongjhih.kotlin-extensions:kotlinx-android-view:-SNAPSHOT'
}

jcenter (not ready yet):

dependencies {
    compile 'com.infstory:kotlinx-android-sharedpreferences:1.0.0'
    compile 'com.infstory:kotlinx-android-database:1.0.0'
    compile 'com.infstory:kotlinx-android-system-services:1.0.0'
    compile 'com.infstory:kotlinx-android-notification:1.0.0'
    compile 'com.infstory:kotlinx-math:1.0.0'
    compile 'com.infstory:kotlinx-android-view:1.0.0'
}

License

Copyright 2015 8tory, Inc.

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.

More Repositories

1

android-proguards

AAR proguards
Java
762
star
2

docker-parse-server

Provide docker images and docker stack for parse-server npm versions and latest commit
JavaScript
475
star
3

android-gitbook

Open Android
CSS
207
star
4

RetroFacebook

Retrofit Facebook Android SDK
Java
192
star
5

proguard-annotations

proguard-annotations AAR
Java
172
star
6

RxParse

Reactive Parse
Java
140
star
7

mocker

Fluent mockito
Java
97
star
8

awesome-android-awesomeness

A curated list of android awesomeness
84
star
9

SwitchPreferenceCompat

SwitchPreferenceCompat from https://plus.google.com/+ChristianGollner/posts/badausxo1J6
Java
43
star
10

mismeter

A Simple Meter View for Android
Java
39
star
11

RxBolts

Reactive Bolts-Android Framework
Java
32
star
12

rxfirebase

RxJava2 and Kotlin for Firebase
Java
30
star
13

AutoJson

AutoLoganSquare = AutoValue + LoganSquare
Java
29
star
14

pepk

PEPK - Play Encrypt Private Key - Imported from pepk-src.jar
Java
29
star
15

CardView

CardView v7 for eclipse
Java
27
star
16

RecyclerList

Easy to use RecyclerView
Java
27
star
17

depth

Depth Menu for Android: REDIRECT to
27
star
18

dagger2-sample

CoffeeMaker Sample
Java
27
star
19

auto-parse

AutoValue for ParseObject
Java
26
star
20

RxMediaStore

RxMediaStore
Java
26
star
21

AutoCursor

AutoCursor
Java
25
star
22

squery

8Query - Query Builder
Java
24
star
23

JavaPoetic

JavaPoet Simple Builder
Java
23
star
24

docker-android-studio

Shell
21
star
25

drupalfit

A drupal services rest client with retrofit for android
Java
21
star
26

RxFacebook

Facebook in RxJava
Java
19
star
27

rx-mqtt

Java
18
star
28

rx-receiver

RxJava1/2 for Android BroadcastReceiver
Java
16
star
29

android-gradle-plugin

Import from aosp https://android.googlesource.com/platform/tools/base
Java
15
star
30

rc

rcfiles/dotfiles
Perl
13
star
31

flutter_childed

Avoid Widget Hell
Dart
6
star
32

parse-cloud-code

Allow signInWithTwitch for Parse Cloud Code
JavaScript
6
star
33

docker-android

Dockerfile
6
star
34

docker-alpine-android

6
star
35

parse-android-sdk

parse.com android-sdk
Shell
6
star
36

RxList

Reactive List
Java
5
star
37

rxtasks

RxTasks for GMS
Java
5
star
38

flutter_aws

Amazon Pinpoint SDK for flutter
Kotlin
5
star
39

converter-logansquare-retrofit

Converter LoganSquare for retrofit
Java
4
star
40

rx-net

Reactive network for Android
Java
4
star
41

retrofit2.bak

Retrofit2 turns your REST API into a Java interface
Java
4
star
42

HealingBrush

git clone https://android.googlesource.com/platform/frameworks/rs.git
Java
4
star
43

discord-tts-bot

discord tts bot
Python
4
star
44

simple-parse

No more put("key", value)
Java
3
star
45

parse-android-sdk.m2

From https://github.com/8tory/parse-android-sdk
3
star
46

attrs-view

Java
3
star
47

RxJava-Operators

Java
3
star
48

rxjava2-sample

2
star
49

flutter_play_licensing

For flutter, https://github.com/google/play-licensing
Kotlin
2
star
50

ActiveAndroid-Preference

Allow Preference using ActiveAndroid ORM to persist settings
Java
2
star
51

aws-ktx

Kotlin
2
star
52

fh2py

Battlefild2 FH2 python
Python
2
star
53

aoe2-aoc-1.0c-scenario

=_=|||ๅ กไป”
2
star
54

routs

Simple Router with Prefix Tree
Java
2
star
55

RxJava2RxJava2

2
star
56

kotlin-system-services

[Deprecated]
Kotlin
2
star
57

mender-python

Mender SDK for python
Python
2
star
58

RxJava-retrofit-github-sample

Sample for https://speakerdeck.com/jakewharton/2014-1
Java
2
star
59

android-ui-example

markushi/android-ui example
Java
2
star
60

docker-mosquitto

Shell
1
star
61

docker-dex2jar

Shell
1
star
62

resources

1
star
63

gradle-java-test-boilerplate

Java
1
star
64

rx-facebook-sdk.js

rxjs for facebook sdk
JavaScript
1
star
65

retromqtt

1
star
66

docker-elasticsearch-logstash-kibana

docker-ELK
1
star
67

facebook-content-provider

FacebookContentProvider supports picture
Java
1
star
68

lolrtmpsclient

Automatically exported from code.google.com/p/lolrtmpsclient
Java
1
star
69

android-system-services

Easy to retrieve system service
Java
1
star
70

docker-webdis

Shell
1
star
71

flutter_embrace

Dart
1
star
72

bf2py

Battlefild2 python
Python
1
star
73

RetroFirebase

1
star
74

android-sdk-maven

mirror android sdk local maven
1
star
75

docker-aosp

Provides AOSP build environment
Shell
1
star
76

android-facebook-stickers

1
star
77

rx-websocket.js

JavaScript
1
star
78

assertj-rxjava2

TODO
1
star
79

parse-facebook-v3

Parse Facebook Android SDK
Shell
1
star
80

flutter_ext

A set of Dart extensions for Flutter development
Dart
1
star
81

bloctog

1
star
82

docker-logstash-webdis

ELKRW
1
star
83

android-gradle-plugin.m2

maven repo for https://github.com/yongjhih/android-gradle-plugin
1
star
84

rx-telephony

Java
1
star
85

rx-twitch.js

JavaScript
1
star
86

screenshot-tests-for-android-boilerplate

Kotlin
1
star
87

open-webook

1
star
88

docker-alpine-openjdk

1
star
89

RxJava-GroupByTest

Java
1
star
90

streamsupport-snapshot

Backport of Java 8 java.util.stream API to Java 6/7 and Android [Deprecated]
Java
1
star
91

ParseCompat

Compatable Parse
Java
1
star
92

gwtwiki

git-svn http://gwtwiki.googlecode.com/svn/
Java
1
star
93

RxAutoParcel

1
star
94

mender-material

JavaScript
1
star
95

docker-flutter

Dockerfile
1
star
96

android-material-arsenal

1
star
97

gradle-init.rxjava

Java
1
star
98

simple-processor

1
star
99

docker-gradle

Install gradle wrapper by docker container
Shell
1
star
100

android-i18n-plurals

Java
1
star