Skip to content

Instantly share code, notes, and snippets.

View prasannaboppe's full-sized avatar

Prasanna Boppe prasannaboppe

  • Back Bench Boys
  • Bangalore
View GitHub Profile
@prasannaboppe
prasannaboppe / DrawCirclesView.java
Created October 7, 2016 11:24
Draw circles with given color and show some text in each circle.
package com.android.gifts.bottomnavigation;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.text.TextPaint;
import android.util.AttributeSet;
@prasannaboppe
prasannaboppe / Section.java
Last active November 10, 2016 17:31
RecyclerView with Headers (LinearLayout)
public class Section {
public String title;
public String desc;
public List<App> apps;
public class App {
public String title;
public String rating;
}
@prasannaboppe
prasannaboppe / HeaderFooterRecyclerAdapter.java
Created November 10, 2016 17:43
RecyclerView with Header and Footer
package com.prasanna.recyclerview.samples;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.LinkedList;
import java.util.List;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include <jni.h>
#include "platform/android/jni/JniHelper.h"
#include "AndroidInterfaceManager.h"
#include "InterfaceManagerInstance.h"
#include "CommonData.h"
using namespace std;
@prasannaboppe
prasannaboppe / ClickItemTouchListener.java
Created September 19, 2017 10:52
RecyclerView Utils
package recyclerview;
import android.content.Context;
import android.os.Build;
import android.support.v4.view.MotionEventCompat;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.OnItemTouchListener;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.View;
@prasannaboppe
prasannaboppe / Util.java
Created October 11, 2017 09:15
Export Sqlite Database
public void exportDatabase() {
try {
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
if (sd.canWrite()) {
String currentDBPath = "path to db";
String backupDBPath = "path to export";
File currentDB = new File(data, currentDBPath);
File backupDB = new File(sd, backupDBPath);
@prasannaboppe
prasannaboppe / KotlinSingleton.kt
Created November 28, 2018 10:07
Singleton implementation for Kotlin (took it from Google sample)
/**
* Created by Prasanna on 28-11-2018.
*/
class KotlinSingleton {
companion object {
@Volatile
private var INSTANCE: KotlinSingleton? = null
fun getInstance(id: String): KotlinSingleton = INSTANCE ?: synchronized(this) {
INSTANCE ?: buildInstance(id).also { INSTANCE = it }
@prasannaboppe
prasannaboppe / ComputationFuture.java
Created February 21, 2020 06:00
Wrapping an asynchronous computation into a synchronous (blocking) computation.
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class ComputationFuture<T> implements Future<T> {