Category Archives: Android

Android Image Compression Using ImageZipper

How to Android Image Compression Using ImageZipper Library
How to Android Image Compression Using ImageZipper Library

We all know that good UI is important key factor for app success and for UI informative image is most important. But nowadays we don’t care about the size of that image which makes app bigger and bigger in size. ImageZipper is an image compression library which helps you to compress your images both in default and custom way. It allows you to control you the width, height, format, orientation and quality of Image. It ease out the task to send images to the server.

How to Android Image Compression Using ImageZipper Library?

How to Android Image Compression  Using ImageZipper Library

Gradle

Add this to your root build.gradle file:

allprojects {
repositories {

maven { url “https://jitpack.io” }
}
}

Default Compressor

File imageZipperFile=new ImageZipper(this).compressToFile(actualFile);

OK Now Get me Bitmap!!

Bitmap b=new ImageZipper(MainActivity.this).compressToBitmap(actualFile);

See full article here: ImageZipper – Android Image Compression Library

Get File from Clound Using FileStack File Picker in Android

FileStack Android allow your users to pull in their content from Dropbox, Facebook, and more!

FileStack Android : Amazing Cloud File Picker

It is an amazing cloud integrated file picker by which you got ability to integrate and allow your users to upload and download content from more than 20 cloud drives.

FileStack Android library provides an activity that your app can spawn that allows the user to open and save files.

FileStack Android Example
FileStack Android Example

How to use FileStack Android library:

For Gradle users:

compile ‘io.filepicker:filepicker-android:4.0.2’

By default the following services are available (meaning of keys in brackets is described below):

  • Gallery (GALLERY)
  • Camera (CAMERA)
  • Facebook (FACEBOOK)
  • Amazon Cloud Drive (CLOUDDRIVE)
  • Dropbox (DROPBOX)
  • Box (BOX)
  • Gmail (GMAIL)
  • Instagram (INSTAGRAM)
  • Flickr (FLICKR)
  • Picasa (PICASA)
  • Github (GITHUB)
  • Google Drive (GOOGLE_DRIVE)
  • Evernote (EVERNOTE)
  • OneDrive (SKYDRIVE)

See more here : FileStack Android : Amazing Cloud File Picker 

How to Add Uber Car Animation in Android? 

How to Add Uber Car Animation in Android
How to Add Uber Car Animation in Android

I found a question on Quora about How to add Uber car animation in Android application. I really like this question and found a solution which help you if want to do this in your application.

Solution is UberCarAnimation is an Android library which showing movement of car on map like in Uber.

  • Parse the “overview_polyline” from the JSON by providing the appropriate GET parameters. For eg:

https://maps.googleapis.com/maps/api/directions/json?” +
“mode=driving&”
+ “transit_routing_preference=less_driving&”
+ “origin=” + latitude + “,” + longitude + “&”
+ “destination=” + destination + “&”
+ “key=” + getResources().getString(R.string.google_directions_key)

  • Decode the polyline which will provide you with list of latitudes and longitudes that is List<LatLng> to be apt.
  • Create a value animator by providing the ofFloatValue, setting duration and adding update listener in Handler

ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1);
valueAnimator.setDuration(3000);
valueAnimator.setInterpolator(new LinearInterpolator());
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
//CODE
});

  • Finally set position of marker to the new position, also evaluating the bearing between the consecutive points so that it seems car is turning literally and finally update camera as:

marker.setPosition(newPos);
marker.setAnchor(0.5f, 0.5f);
marker.setRotation(getBearing(startPosition, newPos));
mMap.moveCamera(CameraUpdateFactory
.newCameraPosition
(new CameraPosition.Builder()
target(newPos)
.zoom(15.5f)
.build()));

 

See full article: Add Uber Car Animation Android

How to Add FloatingView Animation in Android?

In previous article, we focused on Shadow image with Material Shadow library and today we come with cool animation with View using FloatingView animation library in Android. It can make the target view floating above the anchor view with cool animation.

You can see demo(FloatingView Animation) below:

FloatingView in Android
FloatingView Animation in Android

Let’s move on to implementation of FloatingView Animation:

Build gradle

First of all we need to add dependencies in build.gradle.

dependencies {
compile ‘com.ufreedom.uikit:FloatingViewLib:1.0.2’
}

Create floating element

Use FloatingBuilder to create a FloatingElement

FloatingElement builder = new FloatingBuilder()
.anchorView(View)
.targetView(View)
.offsetX(int)
.offsetY(int)
.floatingTransition(FloatingTransition)
.build();

The use of FloatingBuilder can be configured to have:

  • anchorView :Anchor, is you want to float animation in which View above
  • target:Target, The view which you want to float
  • offsetX:X direction of offset, unit PX
  • offsetY: Y direction of offset, unit PX
  • floatingTransition : Floating effect, the default is ScaleFloatingTransition

Source: Add FloatingView Animation in Android » Tell Me How – A Place for Technology Geekier

How to Add Material Shadow in Android?

Recently we discuss about Kotlin Native and daily used kotlin code, today we are going to discuss about Google’s Material Shadow library.

Add Material Shadow in Android

Material Shadow is a library for seamlessly integrating Material shadows. The library takes existing material shadows to next level by adding the following features :

  • Convex shadows : The shadows are not only rectangular or circular, they can take any convex shape depending on the view and its content.
  • Support for shadow offsets : The library allows developers to set X and Y offset for the shadows.
  • Support for shadow intensity : The library also has support for setting shadow intensity via shadowAlpha attribute.
  • Shadows for semi-transparent views : The library allows shadows for semi-transparent views.
  • Support for Async Shadow calculations : The library allows the operations to be async to avoid blocking the UI thread for long calculations.
  • Shadow animations : The library supports fade out animation for shadow.

How to use this library?

Just add the following dependency in your app’s build.gradle

dependencies {
compile ‘com.sdsmdg.harjot:materialshadows:1.2.5’
}

Example Usage 1 (Simple)

XML

<com.sdsmdg.harjot.materialshadows.MaterialShadowViewWrapper
android:layout_width=”match_parent”
android:layout_height=”match_parent”>

<ImageView
android:layout_width=”130dp”
android:layout_height=”130dp”
android:elevation=”5dp”
android:src=”@drawable/poly” />

</com.sdsmdg.harjot.materialshadows.MaterialShadowViewWrapper>

Result

Simple example of Material Shadow

See other example and full article here >> : Material Shadow for Android 

Top 20 Daily used Kotlin Code Snippet

In past month i did some work on Kotlin and some article you can see on this trending topic. So today i am here with the list of daily used Kotlin code snippet which every developer need to know.

Daily used Kotlin Code Snippet

It is a collection of random and frequently used idioms in Kotlin. If you have a favorite idiom, contribute it by sending a comment below.

List of Daily used Kotlin Code Snippet

Creating DTOs (POJOs/POCOs)

  1. data class Customer(val name: String, val email: String)

provides a Customer class with the following functionality:

  • getters (and setters in case of var{: .keyword }s) for all properties
  • equals()
  • hashCode()
  • toString()
  • copy()
  • component1()component2(), …, for all properties (see Data classes)

Default values for function parameters

  1. fun foo(a: Int = 0, b: String = “”) {}

Do you know : What is Kotlin Native?

Filtering a list

  1. val positives = list.filter { x -> x > 0 }

Or alternatively, even shorter:

  1. val positives = list.filter { it > 0 }

Do you use this : Koin – Kotlin Dependency Injection

String Interpolation

  1. println(“Name $name”)

Source: Top 20 Daily used Kotlin Code Snippet

How Kotlin Native can replace JVM?

Kotlin Native is another step toward making Kotlin usable throughout a modern application. Eventually, it will be possible to use Kotlin to write every component, from the server back-end to the web or mobile clients. Sharing the skill set is one big motivation for this scenario.

Kotlin Native replace JVM

Kotlin is all about knowing that Kotlin is compatible with Java because it is built for use on the JVM. Kotlin is often Android or backend. More than that (or whatever ran on our beloved JVM).

More on Kotlin : See other interesting tutorial and news about Kotlin

What if one day we do not want to use the JVM?

In some cases we may have to say goodbye to the JVM for some reason.

  • Want to use existing native library library?
  • Run native app on various platforms.
  • I want to use the machine resources to it.
  • Boring JVM

For these reasons, we have to find a way to bring our beloved Kotlin to native applications.

Recommended article : Top 30 Android Tools Every Developer should Know

What is Native?

Speaking of native, come up with a few, and then summarize what it is. What’s the difference with the JVM?

Native translator is native If in a computer system is to run our command set directly on the platform or machine code, each system will have a different format. Even though it is the same work.

The JVM gets a set of bytes of code to figure out how to execute that statement.

If compared Running a direct command set is better than passing another system. Because we have control over the machine.

For Kotlin geekers : Bye bye Gradle and Maven !! Say hello Kotlin Kobalt

And What is Kotlin Native?

Kotlin Native is a compiler that allows us to write a native app with Kotlin. It uses the LLVM compiler to create machine code based on the platform we want. This can now be done on the

  • Mac OS X
  • Linux
  • Apple iOS
  • Raspberry Pi
  • Windows
  • Web Assembly (in the future)

Source: Kotlin Native replace JVM