Skip to content

Instantly share code, notes, and snippets.

@rogerhu
rogerhu / google-image-search-walkthrough
Last active September 11, 2023 02:47
Google Image Search
# Google Image Search
- SETUP see 0a_recording.txt BEFORE RECORDING
Keys: Cmd-Shift-O and Cmd-Shift-F
Tabs
- Grid image homework
- Project slides for Grid Image Search
- Guides
@rogerhu
rogerhu / MainActivity.java
Created November 30, 2015 09:03
SampleFragmentIconPagerAdapter
package codepath.com.tablayoutfun;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
@rogerhu
rogerhu / Contact.java
Last active June 9, 2022 23:32
Endless scrolling with RecyclerVIew
package codepath.com.recyclerviewfun;
import java.util.ArrayList;
import java.util.List;
public class Contact {
private String mName;
private boolean mOnline;
public Contact(String name, boolean online) {
// requires StringUtils -> better way?
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.net.CookieManager;
import java.net.CookiePolicy;
import java.net.CookieStore;
import java.net.URI;
import java.util.Arrays;
import java.util.HashMap;
@rogerhu
rogerhu / EndlessRecyclerViewScrollListener.java
Last active October 29, 2025 23:49
Endless RecyclerView scrolling for different layout managers
public abstract class EndlessRecyclerViewScrollListener extends RecyclerView.OnScrollListener {
// The minimum amount of items to have below your current scroll position
// before loading more.
private int visibleThreshold = 5;
// The current offset index of data you have loaded
private int currentPage = 0;
// The total number of items in the dataset after the last load
private int previousTotalItemCount = 0;
// True if we are still waiting for the last set of data to load.
private boolean loading = true;
@rogerhu
rogerhu / MultimediaDeserializer.java
Created February 12, 2016 05:58
MultimEdia deserializer
package codepath.com.nytimesfun;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import android.text.TextUtils;
import android.support.v7.widget.RecyclerView;
public class RecyclerViewSwipeListener extends RecyclerView.OnFlingListener {
private static final int SWIPE_VELOCITY_THRESHOLD = 2000;
boolean mIsScrollingVertically;
// change swipe listener depending on whether we are scanning items horizontally or vertically
RecyclerViewSwipeListener(boolean vertical) {
// Inspired from https://gist.github.com/adrianbk/c4982e5ebacc6b6ed902
apply plugin: 'maven-publish'
def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
}
def getOutputDir() {
if (isReleaseBuild()) {
@rogerhu
rogerhu / cloud.js
Created November 4, 2016 05:09
Parse Cloud Lab example
// See http://parseplatform.github.io/docs/js/guide/
// https://parseplatform.github.io/docs/js/guide/#query-constraints
Parse.Cloud.define('pushToChannel', function(request, response) {
var params = request.params;
var channel = params.channel;
if (!channel) {
response.error('must provide a channel');
@rogerhu
rogerhu / PushTest.java
Last active October 10, 2017 09:59
Push Testing
// See https://github.com/rogerhu/parse-server-push-marker-example/blob/master/cloud/main.js#L43-L66
// for corresponding server code.
public class PushTest {
public static void sendPushTest() {
JSONObject payload = new JSONObject();
try {
payload.put("sender", ParseInstallation.getCurrentInstallation().getInstallationId());
} catch (JSONException e) {