Skip to content

Instantly share code, notes, and snippets.

@vaibhav-jani
vaibhav-jani / DividerScroll.java
Created December 21, 2015 07:31
RecyclerView Devider
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
@vaibhav-jani
vaibhav-jani / MusicStore.Java
Created January 8, 2016 12:17
MusicStore.Java
public ArrayList<MusicBean> getMusic(){
ArrayList<MusicBean> alMusic = new ArrayList<>();
Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
String[] projection = {MediaStore.Audio.Media._ID,
MediaStore.Audio.Media.ARTIST, MediaStore.Audio.Media.TITLE,
MediaStore.Audio.Media.DATA, MediaStore.Audio.Media.DISPLAY_NAME,
@vaibhav-jani
vaibhav-jani / PullingDbFromDevice.bat
Last active April 2, 2016 15:50
Pulling database from android device batch
adb pull data/data/your.package/databases/yourDb.sqlite C:\Users\Your.Name\Desktop
adb pull data/data/your.package/shared_prefs/your_preference_file_name.xml C:\Users\Your.Name\Desktop
pause
start "" "C:/Program Files (x86)/SqliteBrowser3/bin/sqlitebrowser" C:\Users\Your.Name\Desktop\yourDb.sqlite
public Bitmap getScreenshotFromRecyclerView(RecyclerView view) {
RecyclerView.Adapter adapter = view.getAdapter();
Bitmap bigBitmap = null;
if (adapter != null) {
int size = adapter.getItemCount();
int height = 0;
Paint paint = new Paint();
int iHeight = 0;
final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
@vaibhav-jani
vaibhav-jani / EncryptedAppPrefecerences,java
Created March 3, 2016 14:23
Encrypted App Prefecerences java
/**
* Warning, this gives a false sense of security. If an attacker has enough access to
* acquire your password store, then he almost certainly has enough access to acquire your
* source binary and figure out your encryption key. However, it will prevent casual
* investigators from acquiring passwords, and thereby may prevent undesired negative
* publicity.
*/
public class ObscuredSharedPreferences implements SharedPreferences {
protected static final String UTF8 = "utf-8";
private static final char[] SEKRIT = ... ; // INSERT A RANDOM PASSWORD HERE.
import android.content.Context;
import android.content.SharedPreferences;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
import java.lang.reflect.Field;
import java.util.Set;
import java.util.prefs.AbstractPreferences;
@vaibhav-jani
vaibhav-jani / CircularPropertyAnimation.Java
Last active June 13, 2016 06:55
Animation : Rotate view across another view
package ui.animation;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Transformation;
public class CircularPropertyAnimation extends Animation {
private float startAngle = 90;
@vaibhav-jani
vaibhav-jani / GreetingClient.java
Created April 19, 2016 06:24 — forked from anonymous/GreetingClient.java
Socket sample Java
// File Name GreetingClient.java
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;
@vaibhav-jani
vaibhav-jani / ExampleActivity.java
Last active June 8, 2016 11:11
Custom parallax collapsing toolbar
package com.example.vaibhav.testingapp;
import android.graphics.drawable.ColorDrawable;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import com.utils.Logger;
import com.utils.PixelUtils;
@vaibhav-jani
vaibhav-jani / SlidingTabLayout.java
Created June 14, 2016 10:20
Sliding tab (to customize viewpage indicator)
import android.content.Context;
import android.graphics.Typeface;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;