Skip to content

Instantly share code, notes, and snippets.

View mohammadt3anii's full-sized avatar

Mohammad Al-Ta'ani mohammadt3anii

  • jordan
View GitHub Profile
private Location bestLocation = null;
private Looper looper;
private boolean networkEnabled = false, gpsEnabled = false;
private synchronized void setLooper(Looper looper) {
this.looper = looper;
}
private synchronized void stopLooper() {
if (looper == null) return;
@mohammadt3anii
mohammadt3anii / Rx2ServiceBindingFactory.java
Created December 10, 2018 23:07 — forked from MisterRager/Rx2ServiceBindingFactory.java
Bind to an Android service using RxJava!
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Binder;
import android.os.IBinder;
import io.reactivex.Observable;
@mohammadt3anii
mohammadt3anii / ColoredPolylineOverlay
Created November 19, 2018 10:22 — forked from Dagothig/ColoredPolylineOverlay
Android colored polyline (uses TrailOverlay)
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Shader;
import com.google.android.gms.maps.model.LatLng;
@mohammadt3anii
mohammadt3anii / BaseRecyclerAdapter.java
Created October 24, 2018 23:48 — forked from iChintanSoni/BaseRecyclerAdapter.java
BaseRecyclerAdapter, a generic Recycler adapter, is an extended version from https://gist.github.com/chintansoni202/3c61aea787ae4bd49f26adee9dd40a08 This version should be used along with Data-binding. You can even pass empty view layout, if there is no list item.
public class BaseRecyclerAdapter<T, MVH extends BaseViewHolder<T>, EVH extends BaseViewHolder<T>> extends RecyclerView.Adapter<BaseViewHolder<T>> {
private static final int VIEW_TYPE_EMPTY = 0;
private static final int VIEW_TYPE_DATA = 1;
private List<T> list = new ArrayList<>();
@LayoutRes
private int emptyViewLayoutResource;
private Class<EVH> emptyViewHolder;
@LayoutRes
private int dataLayoutResource;