Instantly share code, notes, and snippets.

sanimap@gmail.com laaptu

View GitHub Profile
@laaptu
laaptu / pull.sh
Created Mar 3, 2016
Simple shell script to pull files from Android private storage
View pull.sh
#!/bin/sh
# first argument pass the package name of the app
#echo $1
# the phone must be rooted for this to work
# this will dump the files directly in the location where this script is run
# ./pull.sh com.yourpackagename
adb shell "su -c 'chmod -R +rwx /data/data/$1;cp -r /data/data/$1/files /sdcard/;exit;'"
adb pull /sdcard/files
@laaptu
laaptu / SingleTon.java
Created Mar 3, 2016
Creating a singleton
View SingleTon.java
public class DbManager {
static volatile DbManager singleton = null;
private DbManager() {
}
public static DbManager getInstance() {
if (singleton == null) {
synchronized (DbManager.class) {
if (singleton == null)
singleton = new DbManager();
View lib2_MainPlayer$PlayAllShorts.class
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package tw.com.android.singularsdk.lib2;
import android.media.AudioTrack;
import android.os.SystemClock;
import android.util.Log;
@laaptu
laaptu / ParcelableSparseArray.java
Created Jul 15, 2015
Parcelable Sparse Array Implementation
View ParcelableSparseArray.java
package com.zala.model;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.SparseArray;
/**
* https://gist.github.com/kaushikgopal/9eea148a2188dc58fe37
*/
public class ParcelableSparseArray<T>
@laaptu
laaptu / DetailDeserializer.java
Last active Aug 29, 2015
Gson Deserializer test
View DetailDeserializer.java
package com.zala.utils.json;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.zala.model.base.Location;
import com.zala.model.base.Venue;
@laaptu
laaptu / ButtonProgress.java
Last active Jun 14, 2018
Using Styles values as custom attributes
View ButtonProgress.java
package com.zala.widgets;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.Gravity;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.zala.R;
@laaptu
laaptu / ApiManager.java
Last active Dec 13, 2016
Singleton class for RetroFit RestAdapter (Retrofit 1.9.0)
View ApiManager.java
import retrofit.RestAdapter;
/**
* Singleton class for Retrofit RestAdapter and API (Retrofit 1.9.0)
*/
public class ApiManager {
// interface containing HTTP methods as given by Retrofit
private static RegionApi regionApi;
// static adapter to be used in entire app
@laaptu
laaptu / Events.java
Last active Aug 29, 2015
Making a single class to hold all the Events that would be posted and listened by EventBus
View Events.java
public class Events {
public abstract static class Event {
public String getTag() {
return this.getClass().getSimpleName();
}
}
public static class SearchResultEvent extends Event {
public int resultCount;
@laaptu
laaptu / SelectCurrentFragmentInViewPager.java
Created Oct 13, 2014
FragmentStateAdapter select current fragment. Viewpager select current fragment
View SelectCurrentFragmentInViewPager.java
int id = viewPager.getCurrentItem();
System.out.println(id);
FragmentStatePagerAdapter adapter = (FragmentStatePagerAdapter) viewPager.getAdapter();
Fragment fragment = (Fragment) adapter.instantiateItem(viewPager, viewPager.getCurrentItem());
@laaptu
laaptu / tab_privacy_selector.xml
Created Oct 10, 2014
Selector for TextView and must be kept on res/color folder and applied as android:textColor="@color/yourselector.xml" to the TextView
View tab_privacy_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/blue" android:state_pressed="true" />
<item android:color="@color/blue" android:state_selected="true" />
<item android:color="@android:color/white" />
</selector>