Lessons from converting an app to 100% Kotlin

One concern that people will raise about converting to Kotlin is the number of methods added by its standard library. Thanks to massive libraries like the support library and GMS, many apps are in danger of bumping up against the Dex method limit. I used the dexcount gradle plugin to break down the method count before and after the rewrite. The end result is that the total method count after proguard decreased by 10% from 5491 to 4987 (not counting GMS or appcompat). The code count decreased by 30% from 12,371 lines of Java, to 8,564 lines of Kotlin.

http://bit.ly/2b0ejBF

Connecting your App to a Wi-Fi Device

With the growth of the Internet of Things, connecting Android applications to Wi-Fi enabled devices is becoming more and more common. Whether you’re building an app for a remote viewfinder, to set up a connected light bulb, or to control a quadcopter, if it’s Wi-Fi based you will need to connect to a hotspot that may not have Internet connectivity.

From Lollipop onwards the OS became a little more intelligent, allowing multiple network connections and not routing data to networks that don’t have Internet connectivity. That’s very useful for users as they don’t lose connectivity when they’re near Wi-Fis with captive portals. Data routing APIs were added for developers, so you can ensure that only the appropriate app traffic is routed over the Wi-Fi connection to the external device.

http://android-developers.blogspot.com.br/2016/07/connecting-your-app-to-wi-fi-device.html

Simple, sophisticated failure handling

Failsafe is a lightweight, zero-dependency library for handling failures. It was designed to be as easy to use as possible, with a concise API for handling everday use cases and the flexibility to handle everything else. Failsafe features:

Supports Java 6+ though the documentation uses lambdas for simplicity.

https://github.com/jhalterman/failsafe

RecyclerViewTools – Collection of tools for RecyclerView

Collection of tools for RecyclerView.

This collection was developed with two main goals: easy to code (very simple API) & robust (it really works). Includes:

  • Headers, Footers & Sections for RecyclerView. Based on a common “wrap” adapter.
  • Extended SwipeRefreshLayout to use when Recycler is not direct child (e.g. on CoordinatorLayout)
  • Implementation of OnItemClickListener for RecyclerView (works standalone or in conjunction with headers, footers & sections).
  • FastScrollToTop function.

https://github.com/eyeem/RecyclerViewTools

AES256 PasswordBased Encryption/Decryption

USAGE:

Initialise a SecureMyText object with following syntax

SecureMyText secure=new SecureMyText(context,String password for encryption);

Use the created object to perform encryption.

For encrypting the text

String encrypted_text = secure.encrypt(string to be encrypted);

For getting final encrypted text containing salt and IV to be transferred.

String encrypted_text_to_be_transferred = secure.EncryptToFinalTransferText(string to be encrypted);

For decrypting initialization remains the same

String plain_text = secure.decrypt(string to be decrypted);

For more details look for the SecureText class in main java folder. All the instructions are given in the file itself. Copy the lightweight class into your project and customise it according to your needs.

The sample folder has the sample android application that shows a sample implementation of the encryption/decryption.

Explaination of the whole encryption and decryption process taking example of app to server communication with notes and flow diagrams is attached.

https://github.com/rishelarora/AES256PasswordBasedEncryption-Decryption

CHRONIX – A fast and efficient time series storage based on Apache Lucene and Apache Solr

Chronix natively speaks time series. You can store nearly every kind of data type within a time series due to its flexible design. You decide what a time series looks like.

Chronix is built to store time series highly compressed and for fast access times. In comparison to related time series databases, Chronix does not only take 5 to 171 times less space, but it also shaves off 83% of the access time, and up to 78% off the runtime on a mix of real world queries. For the measurements we used a commodity hardware laptop computer and Chronix using the Apache Solr scenario (single node).

Chronix supports three different scenarios, pursuing different goals:

  1. Chronix Storage: Use Chronix as a small storage library and plug it into your application. It stores the time series using Apache Lucene.
  2. Chronix Server: Combine Chronix with Apache Solr for a typical client-server scenario. Apache Solr offers several useful features like scalability, fault tolerance, distributed indexing, or replication.
  3. Chronix Spark: Whenever you need a parallel and distributed time series processing, integrate Chronix with Apache Spark. Leverage Apache Spark to process a time series in parallel.

http://chronix.io/

Close Encounters of The Java Memory Model Kind

Two years ago I painfully researched and built JMM Pragmatics talk and transcript, hoping it would highlight the particular dark corners of the Java Memory Models for those who cannot afford to spend years studying the formalisms, and deriving the actionable insights from them. JMM Pragmatics has helped many people, but there is still lots of confusion about what Memory Model guarantees, and what it does not.

In this post, we will try to follow up on particular misunderstandings about Java Memory Model, hopefully on the practical examples. The examples use the APIs from the jcstress suite, which are concise enough for a reader, and are runnable.

 

cart twitter updates

This is a fairly large piece of writing. In this age of attention-scarce Internet it would normally be presented as a series of posts, one section each. Let’s pretend we did that 🙂 If you run out of time/patience to read through, bookmark, and restart from the section you’ve left at.

Most examples in this post came from public and private discussions we’ve had over the years. I would not claim they cover all memory model abuses. If you have an interesting case that is not covered here, don’t hesitate to drop me a mail, and we can see if it fits the narrative somewhere. concurrency-interest is the mailing list where you can discuss interesting cases in public.

http://shipilev.net/blog/2016/close-encounters-of-jmm-kind/