Posts

Showing posts from October, 2017

Compressor Library Kotlin + Java

Image
    Compressor is a lightweight and powerful android image compression library. Compressor will allow you to compress large photos into smaller sized photos with very less or negligible loss in quality of the image.  Gradle dependencies { compile ' id.zelory:compressor: 2.1 . 0 ' }   Let's compress the image size! Compress Image File var compressedImageFile = Compressor( this ).compressToFile(actualImageFile)   Compress Image File to Bitmap var compressedImageBitmap = Compressor( this ).compressToBitmap(actualImageFile)   I want custom Compressor! var compressedImage =Compressor( this ) .setMaxWidth( 640 ) .setMaxHeight( 480 ) .setQuality( 75 ) .setCompressFormat(Bitmap.CompressFormat.WEBP) .setDestinationDirectoryPath(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath()) .compressToFile(actualImage)   Source: Compressor

Fast Android Networking Library Kotlin

Image
Requirements Fast Android Networking Library can be included in any Android application. Fast Android Networking Library supports Android 2.3 (Gingerbread) and later. Using Fast Android Networking Library in your application Add this in your build.gradle compile 'com.amitshekhar.android:android-networking:1.0.0'   Do not forget to add internet permission in manifest if already not present < uses-permission android :name= "android.permission.INTERNET" />   Then initialize it in onCreate() Method of application class : AndroidNetworking.initialize( applicationContext )   Making a GET Request AndroidNetworking.get( "https://fierce-cove-29863.herokuapp.com/getAllUsers/{pageNumber}" ) .addPathParameter( "pageNumber" , "0" ) .addQueryParameter( "limit" , "3" ) .addHeaders( "token" , "1234" ) .setTag( "test" ) .setPriority

Kotlin Android Extensions

This tutorial describes how to use Kotlin Android Extensions to improve support for Android development. In this tutorial we'll walk through the steps required to use the Kotlin Android Extensions plugin, enhancing the development experience with Android. Background Every Android developer knows well the findViewById() function. It is, without a doubt, a source of potential bugs and nasty code which is hard to read and support. While there are several libraries available that provide solutions to this problem, being libraries dependent on runtime, they require annotating fields for each View . The Kotlin Android Extensions plugin allows us to obtain the same experience we have with some of these libraries, without having to add any extra code or shipping any additional runtime. In essence, this would allow for the following code: // Using R.layout.activity_main from the main source set import kotlinx . android .

Getting started with Android and Kotlin

Image
This tutorial walks us through creating a simple Kotlin application for Android using Android Studio. Installing the Kotlin plugin The Kotlin plugin is bundled with Android Studio starting from version 3.0 . If you use an earlier version, you'll need to install the Kotlin plugin. Go to File | Settings | Plugins | Install JetBrains plugin… and then search for and install Kotlin . If you are looking at the "Welcome to Android Studio" screen, choose Configure | Plugins | Install JetBrains plugin… You'll need to restart the IDE after this completes. Creating a project It’s extremely easy to start using Kotlin for Android development. In this tutorial we’ll follow the warming up process with Android Studio. If using Intellij IDEA with Android, the process is almost the same. First let's create a new project. Choose Start a new Android Studio project or File | New project . The following dialogs walk you through the process of new project