Skip to content

Instantly share code, notes, and snippets.

@blackberry2016
blackberry2016 / RxBus1.java
Created Apr 25, 2018 — forked from jaredsburrows/RxBus1.java
RxBus for RxJava 1 and RxJava 2
View RxBus1.java
import rx.Observable;
import rx.subjects.PublishSubject;
import rx.subjects.SerializedSubject;
import rx.subjects.Subject;
/**
* @author <a href="mailto:jaredsburrows@gmail.com">Jared Burrows</a>
*/
public final class RxBus {
private final Subject<Object, Object> bus = new SerializedSubject<>(PublishSubject.create());
@blackberry2016
blackberry2016 / RxBus1.java
Created Apr 25, 2018 — forked from jaredsburrows/RxBus1.java
RxBus for RxJava 1 and RxJava 2
View RxBus1.java
import rx.Observable;
import rx.subjects.PublishSubject;
import rx.subjects.SerializedSubject;
import rx.subjects.Subject;
/**
* @author <a href="mailto:jaredsburrows@gmail.com">Jared Burrows</a>
*/
public final class RxBus {
private final Subject<Object, Object> bus = new SerializedSubject<>(PublishSubject.create());
@blackberry2016
blackberry2016 / item_pager
Last active Apr 9, 2018
ConstraintLayout Performance issue in RecyclerView. It's slow 50% than the LinearLayout
View item_pager
----------------ConstraintLayout---------------->
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/MatchWrap"
android:background="#D1BEA3">
<android.support.constraint.Guideline
android:id="@+id/guide_line"
View SearchViewFormatter.java
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ImageSpan;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SearchView;
import android.widget.TextView;
@blackberry2016
blackberry2016 / gist:aa3389b493fdbb3fdc3afb45d3842593
Created Feb 28, 2018 — forked from yqritc/gist:ccca77dc42f2364777e1
Equal column spacing for Android RecyclerView GridLayoutManager by using custom ItemDecoration
View gist:aa3389b493fdbb3fdc3afb45d3842593

ItemOffsetDecoration

public class ItemOffsetDecoration extends RecyclerView.ItemDecoration {

    private int mItemOffset;

    public ItemOffsetDecoration(int itemOffset) {
        mItemOffset = itemOffset;
    }
@blackberry2016
blackberry2016 / Glide4OkHttp3Dagger2Module.java
Created Feb 1, 2018 — forked from dptsolutions/Glide4OkHttp3Dagger2Module.java
Example AppGlideModule Injecting OkHttpClient using Dagger 2
View Glide4OkHttp3Dagger2Module.java
/**
* {@link AppGlideModule} for the app
*/
@Excludes(OkHttpLibraryGlideModule.class)
@GlideModule
public class MyAppGlideModule extends AppGlideModule {
//Below override should only be used if not using legacy modules registered via manifest
@Override
public boolean isManifestParsingEnabled() {