Skip to content

Instantly share code, notes, and snippets.

View garymabin's full-sized avatar

Bin Ma garymabin

  • Thoughtworks
  • China
View GitHub Profile
@garymabin
garymabin / INotifier
Created September 17, 2014 02:58
Code for exchanging Parcelable data between work thread and main thread
public interface INotifier {
void onNewData(Parcelable payload);
}
@garymabin
garymabin / INotifier
Created September 17, 2014 03:08
Code for switching data between work thread and main thread using Handler.post()
public interface INotifier {
void onNewData(Object payload);
}
@garymabin
garymabin / AnimatedGifDrawable
Created January 29, 2015 02:36
gif image utils
import java.io.InputStream;
import android.graphics.Bitmap;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
public class AnimatedGifDrawable extends AnimationDrawable {
private int mCurrentIndex = 0;
@garymabin
garymabin / VideoTextureView
Created July 9, 2015 06:08
Ijkplayer video container based on TextureView
/*
* Copyright (C) 2006 The Android Open Source Project
* Copyright (C) 2012 YIXIA.COM
* Copyright (C) 2013 Zhang Rui <[email protected]>
* 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
@garymabin
garymabin / OkHttpStack
Created July 17, 2015 07:15
OkHttpStack
package com.brd.igoshow.common;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@garymabin
garymabin / BasicJSONRequest
Created July 17, 2015 08:56
BasicJSONRequest
package com.brd.igoshow.core.request;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import static android.content.DialogInterface.BUTTON_NEGATIVE;
import static android.content.DialogInterface.BUTTON_NEUTRAL;
import static android.content.DialogInterface.BUTTON_POSITIVE;
public class MainActivity extends Activity {