Skip to content

Instantly share code, notes, and snippets.

@VAdaihiep
VAdaihiep / SnappingRecyclerView.java
Created October 29, 2015 08:26
SnappingRecyclerView horizontal in simplest way. Original version: http://stackoverflow.com/a/29171652/1393920
package vn.mog.mygimi.home;
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
public final class SnappingRecyclerView extends RecyclerView {
@VAdaihiep
VAdaihiep / CursorToArrayListObject
Created January 19, 2015 11:16
Convert Cursor to ArrayList object
/**
* convert from cursor to arraylist of object
*
* @param <E>
*
* @param cursor
* @param class
* @return object
*/
public static <E> ArrayList<E> cursorToArrayListObject(Cursor cursor,
@VAdaihiep
VAdaihiep / GMapV2Direction.java
Created January 14, 2015 08:02
Draw route and get other information like instruction, duration, distance,... async. Add loopj android http async to use this gist. Usage: gmapV2Direction.drawRoute(...., new OnDrawedRouteListener(){...});
import android.text.Html;
import android.util.Log;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.PolylineOptions;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.TextHttpResponseHandler;
import org.apache.http.Header;
@VAdaihiep
VAdaihiep / AutoUpdateLocationService.java
Last active November 12, 2020 11:15
Tracking current location in background in interval. User google play service version 6.1.71. Use with newer google play service will be updated soon. Usage: context.startService(new Intent(context, AutoUpdateLocationService.class)); to start tracking. context.stopService(new Intent(context, AutoUpdateLocationService.class)); to stop tracking.
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient;
import com.google.android.gms.common.GooglePlayServicesUtil;