All Projects → vpaliy → Android Extensions

vpaliy / Android Extensions

Licence: mit
Android Extensions

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Android Extensions

Time.dart
⏰ Type-safe DateTime and Duration calculations, powered by extensions.
Stars: ✭ 363 (+1916.67%)
Mutual labels:  extensions
Android Maps Extensions
Android Maps Extensions is a library extending capabilities of Google Maps Android API v2.
Stars: ✭ 404 (+2144.44%)
Mutual labels:  extensions
Oscnews
Chrome 插件,查看开源中国软件更新资讯,文档导航,GitHub 趋势榜,linux命令索引,浏览历史记录和时钟页面。
Stars: ✭ 582 (+3133.33%)
Mutual labels:  extensions
Pext
Python-based extendable tool
Stars: ✭ 380 (+2011.11%)
Mutual labels:  extensions
Enhancer
A collection of utilities to enhance the Unity Editor
Stars: ✭ 394 (+2088.89%)
Mutual labels:  extensions
Whatif
☔ Fluent expressions of Kotlin for handling single if-else statements, nullable, collections, and boolean.
Stars: ✭ 450 (+2400%)
Mutual labels:  extensions
Towel
Throw in the towel.
Stars: ✭ 333 (+1750%)
Mutual labels:  extensions
Rxjavaextensions
RxJava 2.x & 3.x extra sources, operators and components and ports of many 1.x companion libraries.
Stars: ✭ 662 (+3577.78%)
Mutual labels:  extensions
Kotlin Flow Extensions
Extensions to the Kotlin Flow library.
Stars: ✭ 404 (+2144.44%)
Mutual labels:  extensions
Ramda Adjunct
Ramda Adjunct is the most popular and most comprehensive set of functional utilities for use with Ramda, providing a variety of useful, well tested functions with excellent documentation.
Stars: ✭ 550 (+2955.56%)
Mutual labels:  extensions
Kahelpers
Kotlin Extensions (Android extensions) and Helpers for smoother Android development
Stars: ✭ 382 (+2022.22%)
Mutual labels:  extensions
Zson
ZSON is a PostgreSQL extension for transparent JSONB compression
Stars: ✭ 385 (+2038.89%)
Mutual labels:  extensions
Swiftyutils
All the reusable code that we need in each project
Stars: ✭ 490 (+2622.22%)
Mutual labels:  extensions
Lulumi Browser
Lulumi-browser is a lightweight browser coded with Vue.js 2 and Electron.
Stars: ✭ 367 (+1938.89%)
Mutual labels:  extensions
Fsharpplus
Extensions for F#
Stars: ✭ 589 (+3172.22%)
Mutual labels:  extensions
Webpack Extension Reloader
A upgrade from 🔥webpack-chrome-extension-reloader🔥, now on all browsers
Stars: ✭ 355 (+1872.22%)
Mutual labels:  extensions
Extensions
Source code of Raindrop.io browser extension (Chrome, Firefox, Opera)
Stars: ✭ 446 (+2377.78%)
Mutual labels:  extensions
Vscode Create Tests
A vscode extension to quickly create test files.
Stars: ✭ 16 (-11.11%)
Mutual labels:  extensions
Versaplayer
Versatile Video Player implementation for iOS, macOS, and tvOS
Stars: ✭ 608 (+3277.78%)
Mutual labels:  extensions
Vanara
A set of .NET libraries for Windows implementing PInvoke calls to many native Windows APIs with supporting wrappers.
Stars: ✭ 544 (+2922.22%)
Mutual labels:  extensions

android-extensions

Build Status

This repository contains a set of android extensions which I use in my apps.

Animation Extensions

  1. Apply the same scale factor to X and Y.
view.animate().scale(1.f).start()
  1. An easier way to build the animator object.
view.animator {
    scale(factor=1.5f)
    translationX(distanceX())
    translationY(distanceY())
    duration=300L
    startDelay=100L
    interpolator=AccelerateInterpolator()
 }.start()
  1. Now it's super easy to build a width/height animator. You just need to pass the end height/width.
 view.getHeightAnimator(view.height/2).start()
  1. Or you can do something like this:
 view.getHeightAnimator(endHeight).apply { 
    duration=300
    startDelay=10
    interpolator=AccelerateInterpolator()
 }.start()
  1. Adding listeners is easier:
  view.animator().onStart{}.onEnd{}.onCancel{}.onRepeat{}.animator().apply{
      duration=300
      startDelay=50
      scale(0.5f)
  }.start()

Note! You don't want to use the listeners in the apply{} block. It will create a new listener each time, without preserving the previous listeners.

Don't do that:

  view.animator().apply{
     onEnd{}
     onStart{}
  }.start()

Or this:

  view.animator().apply{
     onStart{
        onEnd{}
     }   
   }.start()

Common Extensions

  1. Eliminate the tedious "if" problem in Kotlin.
val condition=...
val result=if(condition) 1 else 0

Here's a better way to do this:

 val condition=...
 val result=condition then 1?:0
  1. If you need to check a parameter for null and then pass it into a function:
fun requestItem(id:String?):Int{
   if(id!=null){
      return fetch(id)
   }
   return error()
}

A bit better:

fun request(id:String?)=id then(this::fetch)?:error()

Add an exception:

fun requestItem(id:String?):Int{
   if(id!=null){
      return fetch(id)
   }
   throw IllegalArgumentException()
}
fun request(id:String?)=id then(this::fetch)?:throw IllegalArgumentException()

Logs

  • Equivalent of Log.i(javaClass.simpleName,message)

    val list:List<User> =fetchData()
    list.forEach{ info(it) }
    
  • Equivalent of Log.e(javaClass.simpleName,message)

    val list:List<User> =fetchData()
    list.forEach{ error(it) }
    
  • Equivalent of Log.d(javaClass.simpleName,message)

    val list:List<User> =fetchData()
    list.forEach{ debug(it) }
    
  • Equivalent of Log.wtf(javaClass.simpleName,message)

    val list:List<User> =fetchData()
    list.forEach{ wtf(it) }
    
  • Equivalent of Log.v(javaClass.simpleName,message)

    val list:List<User> =fetchData()
    list.forEach{ verbose(it) }
    
  • Equivalent of Log.w(javaClass.simpleName,message)

    val list:List<User> =fetchData()
    list.forEach{ warning(it) }
    

Assign you own tags:

 error(tag="Tag",message)

Or you use tags from the context:

 repository.requestItem(object:Callback{
    override fun onSuccess(item: Item) {
        info(this@MainActivity,item)
    }

    override fun onError(ex: Throwable) {
        error(this@MainActivity,ex)
    }
 })

The output would be: MainActivity: message

Also, you can use a function that will provide a message.Consider this example:

  repository.requestItem(object:Callback{
     override fun onSuccess(item: Person) {
        warning(this@MainActivity){
            "He is ${item.age} years old"
        }
     }

     override fun onError(ex: Throwable) {
         error(this@MainActivity){
             ex.cause
         }
     }
  })

Also, you can chain log calls:

  list.forEach{
    info(it).warning(it).error(it)
  }

Installation

allprojects {
  repositories {
     maven { url 'https://jitpack.io' }
  }
}
dependencies {
     compile 'com.github.vpaliyX:android-extensions:-SNAPSHOT'
}

License

MIT License

Copyright (c) 2017 Vasyl Paliy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].