Skip to content

Instantly share code, notes, and snippets.

View amitshekhariitbhu's full-sized avatar
🎯
Helping developers in getting high-paying tech jobs

AMIT SHEKHAR amitshekhariitbhu

🎯
Helping developers in getting high-paying tech jobs
View GitHub Profile

FlatBuffer Android Sample Application

This app shows how fast flat buffer works when we compare it with json.

How to start with flatBuffer

$ git clone https://github.com/google/flatbuffers.git
$ cd flatbuffers
  • Run the command on the basis of your platform

FlatBuffer Android Sample Application

This app shows how fast flat buffer works when we compare it with json.

How to start with flatBuffer

$ 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();

Using Fast Android Networking in your application

Add this in your build.gradle

compile 'com.amitshekhar.android:android-networking:1.0.2'

When using it with RxJava2

compile 'com.amitshekhar.android:rx2-android-networking:1.0.2'
/*
* Singleton class for default executor supplier
*/
public class DefaultExecutorSupplier{
/*
* Number of cores to decide the number of threads
*/
public static final int NUMBER_OF_CORES = Runtime.getRuntime().availableProcessors();
/*
/**
* Priority levels
*/
public enum Priority {
/**
* NOTE: DO NOT CHANGE ORDERING OF THOSE CONSTANTS UNDER ANY CIRCUMSTANCES.
* Doing so will make ordering incorrect.
*/
/**
public class PriorityThreadPoolExecutor extends ThreadPoolExecutor {
public PriorityThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,
TimeUnit unit, ThreadFactory threadFactory) {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit,new PriorityBlockingQueue<Runnable>(), threadFactory);
}
@Override
public Future<?> submit(Runnable task) {
PriorityFutureTask futureTask = new PriorityFutureTask((PriorityRunnable) task);