Skip to content

Instantly share code, notes, and snippets.

@leeyc09
leeyc09 / OkHttp3NetworkFetcher.java
Created January 15, 2016 09:34
Fresco Network fetcher that uses OkHttp3 as a backend.
package your.package
import android.net.Uri;
import android.os.Looper;
import android.os.SystemClock;
import com.facebook.common.logging.FLog;
import com.facebook.imagepipeline.image.EncodedImage;
import com.facebook.imagepipeline.producers.BaseNetworkFetcher;
import com.facebook.imagepipeline.producers.BaseProducerContextCallbacks;
@bolot
bolot / android.xml
Created June 22, 2015 18:57
A few live templates for Android Studio. On my Mac, this file lives in `~/Library/Preferences/AndroidStudioPreview1.3/templates/android.xml`. The location of the file depends on the version of Android Studio and the type of the operating system.
<templateSet group="android">
<template name="focvb" value="@Override&#10;public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {&#10; View view = inflater.inflate(R.layout.fragment_$END$, container, false);&#10; ButterKnife.inject(this, view);&#10; return view;&#10;}&#10;" description="Fragment onCreateView with ButterKnife" toReformat="true" toShortenFQNames="true">
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="false" />
<option name="JAVA_EXPRESSION" value="true" />
<option name="JAVA_DECLARATION" value="true" />
<option name="JAVA_COMMENT" value="false" />
<option name="JAVA_STRING" value="false" />
<option name="COMPLETION" value="false" />
package com.segmentfault.app.view;
import android.content.Context;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.NestedScrollingChild;
import android.support.v4.view.NestedScrollingChildHelper;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.AttributeSet;
import android.view.MotionEvent;
@yrom
yrom / PagerActivity.java
Created May 30, 2015 08:12
sample of RecycledViewPool
public class PagerActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_paper);
ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(new PageAdapter(getSupportFragmentManager()));
}
package blog;
import java.util.List;
import rx.Observable;
public class WidgetAndArticles {
static final class Widget {
String articleName;
String articleUrl;
@nightbear1009
nightbear1009 / MainActivity.java
Created March 2, 2015 14:44
ScrollingToolBar
package com.scrolltoolbar;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@nickbutcher
nickbutcher / 1 search_bar.xml
Last active March 26, 2022 10:03
Demonstrating morphing a search icon into a search field. To do this we use an AnimatedVectorDrawable (https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html) made up of two paths. The first is the search icon (as a single line) the second is the horizontal bar. We then animate the 'trimPathStart' property …
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@polbins
polbins / README.md
Last active February 29, 2024 09:58
Simple RecyclerView Divider

Simple RecyclerView Divider

Simple Horizontal Divider Item Decoration for RecyclerView

    mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(
            getApplicationContext()
    	));

NOTE: Add item decoration prior to setting the adapter

@ssinss
ssinss / EndlessRecyclerOnScrollListener.java
Last active January 19, 2024 08:52
Endless RecyclerView OnScrollListener
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
@meoyawn
meoyawn / EmptyRecyclerView.java
Created November 1, 2014 11:20
RecyclerView doesn't have an emptyView support, we gotta fix that
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class EmptyRecyclerView extends RecyclerView {
@Nullable View emptyView;