This app shows how fast flat buffer works when we compare it with json.
$ git clone https://github.com/google/flatbuffers.git
$ cd flatbuffers
- Run the command on the basis of your platform
package com.memory.test; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.support.annotation.Nullable; | |
import android.support.v7.app.AppCompatActivity; | |
/** | |
* Created by amitshekhar on 06/05/16. | |
*/ |
<resources> | |
<!-- Customize theme for floating. --> | |
<style name="AppTheme.Transparent" parent="Theme.AppCompat.Light.NoActionBar"> | |
<item name="android:windowIsTranslucent">true</item> | |
<item name="android:windowBackground">@android:color/transparent</item> | |
<item name="android:windowContentOverlay">@null</item> | |
<item name="windowNoTitle">true</item> | |
<item name="android:windowIsFloating">true</item> | |
<item name="android:backgroundDimEnabled">false</item> | |
</style> |
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.memory.test"> | |
<application/> | |
<activity | |
android:name=".MainActivity" | |
android:configChanges="orientation|keyboardHidden" | |
android:screenOrientation="portrait"> | |
<intent-filter> |
// Write this in onBackPress of your MainActivity | |
public class MainActivity extends AppCompatActivity{ | |
@Override | |
public void onBackPressed() { | |
super.onBackPressed(); | |
// This is important : Hack to open a dummy activity for 200-500ms (cannot be noticed by user as it is for 500ms | |
// and transparent floating activity and auto finishes) | |
startActivity(new Intent(this, DummyActivity.class)); | |
finish(); |
/** | |
* Priority levels | |
*/ | |
public enum Priority { | |
/** | |
* NOTE: DO NOT CHANGE ORDERING OF THOSE CONSTANTS UNDER ANY CIRCUMSTANCES. | |
* Doing so will make ordering incorrect. | |
*/ | |
/** |
public class PriorityThreadFactory implements ThreadFactory { | |
private final int mThreadPriority; | |
public PriorityThreadFactory(int threadPriority) { | |
mThreadPriority = threadPriority; | |
} | |
@Override | |
public Thread newThread(final Runnable runnable) { |
public class MainThreadExecutor implements Executor { | |
private final Handler handler = new Handler(Looper.getMainLooper()); | |
@Override | |
public void execute(Runnable runnable) { | |
handler.post(runnable); | |
} | |
} |
public class DefaultExecutorSupplier{ | |
private final PriorityThreadPoolExecutor mForBackgroundTasks; | |
private DefaultExecutorSupplier() { | |
mForBackgroundTasks = new PriorityThreadPoolExecutor( | |
NUMBER_OF_CORES * 2, | |
NUMBER_OF_CORES * 2, | |
60L, |
public class PriorityRunnable implements Runnable { | |
private final Priority priority; | |
public PriorityRunnable(Priority priority) { | |
this.priority = priority; | |
} | |
@Override | |
public void run() { |