Skip to content

Instantly share code, notes, and snippets.

View cnevinc's full-sized avatar

Nevin cnevinc

View GitHub Profile
@cnevinc
cnevinc / addFooterHeaderView
Created May 8, 2014 17:36
set footer/header view of a listview
LinearLayout v = (LinearLayout) LayoutInflater.from(this)
.inflate(R.layout.listview_header, null);
swipeListView.addFooterView(v);
swipeListView.addHeaderView(v);
swipeListView.setAdapter(adapter);
@cnevinc
cnevinc / merge_to_master
Created August 8, 2014 23:00
merge dev to master
git checkout master
git pull origin master
git merge develop
git push origin master
package com.example.drawtest;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.RectF;
public class XXXXXApplication extends Application
{
public XXXXXApplication()
{
instance = this;
}
public void onCreate()
{
params = new Bundle();
SpInfo spinfo = new SpInfo(this);
@cnevinc
cnevinc / Application.java
Created March 22, 2015 10:02
Application.java
public class Application extends ContextWrapper implements ComponentCallbacks2 {
public Application() {
super(null);
}
/**
* Called when the application is starting, before any activity, service,
* or receiver objects (excluding content providers) have been created.
* Implementations should be as quick as possible (for example using
* lazy initialization of state) since the time spent in this function
* directly impacts the performance of starting the first activity,
/**
* Proxying implementation of Context that simply delegates all of its calls to
* another Context. Can be subclassed to modify behavior without changing
* the original Context.
*/
public class ContextWrapper extends Context {
Context mBase;
public ContextWrapper(Context base) {
mBase = base;
package com.example.scalpeldrawer;
import android.app.Activity;
import android.content.Context;
import android.support.v4.widget.DrawerLayout;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
/** Got flaky tests? Shampoo them away. */
public final class ShampooRule implements TestRule {
private final int iterations;
public ShampooRule(int iterations) {
if (iterations < 1) throw new IllegalArgumentException("iterations < 1: " + iterations);
@cnevinc
cnevinc / RxJavaFunActivity.java
Last active August 29, 2015 14:25
Just 9 lines of code to get the first 5 items from api server. There's no ways of going back to life without rxJava and retrolambda.
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
@cnevinc
cnevinc / HomeActivityTest.java
Created September 16, 2015 02:14
My first unit test
import com.biideal.biibonus.util.Config;
import junit.framework.TestCase;
import java.util.HashMap;
/**
* Testing my home activity
*/