Skip to content

Instantly share code, notes, and snippets.

View deveshmittal's full-sized avatar

Devesh deveshmittal

View GitHub Profile
/*
When we do a longer running async operation that returns the callback on an Activity
like
Asynctask<T,U, K>
AsyncTask is only for operations between the background thread and Main UI Thread.
the methods are
void onPreExecute(){}
K doInBackground(T type1){
..
return type3_Object;
@deveshmittal
deveshmittal / OkHttpStack.java
Created November 19, 2015 12:14 — forked from JakeWharton/OkHttpStack.java
A `HttpStack` implementation for Volley that uses OkHttp as its transport.
import com.android.volley.toolbox.HurlStack;
import com.squareup.okhttp.OkHttpClient;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* An {@link com.android.volley.toolbox.HttpStack HttpStack} implementation which
* uses OkHttp as its transport.
*/
@deveshmittal
deveshmittal / Source
Created November 19, 2015 12:26
Android source
http://source.android.com/source/index.html
@deveshmittal
deveshmittal / Butterknife
Created November 20, 2015 19:12
How butterknife works?
How ButterKnife actually works?
Java Annotation Processing
Annotation processing is a tool build in javac for scanning and processing annotations at compile time.
You can define your own annotations and a custom processor to handle them.
Annotations are scanned and processed at compile time.
An Annotation Processor reads java code, process its annotations and generate java code in response.
@deveshmittal
deveshmittal / dagger android app steps
Created November 20, 2015 19:31
Dagger 2 Android app
Guide for Dagger 2.0 (Revised Edition 5):
The steps are the following:
1.) add Dagger to your build.gradle files:
top level build.gradle:
.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
@deveshmittal
deveshmittal / dagger android
Created November 20, 2015 19:42
Dagger resources android
http://stackoverflow.com/questions/27036933/how-to-set-up-dagger-dependency-injection-from-scratch-in-android-project
http://siphon9.net/loune/2015/04/dagger-2-0-android-migration-tips/
https://github.com/google/dagger/issues/107#issuecomment-71524636
https://github.com/square/dagger/issues/379
http://code.tutsplus.com/tutorials/dependency-injection-with-dagger-2-on-android--cms-23345
https://github.com/joesteele/dagger2-component-scopes-test/blob/master/app/src/main/java/net/joesteele/daggercomponentstest/MainActivity.java
http://frogermcs.github.io/dagger-1-to-2-migration/
https://github.com/google/dagger/tree/master/examples/android-activity-graphs
https://speakerdeck.com/ogaclejapan/dagger2-has-been-released
@deveshmittal
deveshmittal / MVP pattern resources
Created November 20, 2015 20:03
MVP pattern resources
https://medium.com/@artem_zin/m-model-from-mvc-mvp-in-android-flow-and-mortar-bd1e50c45395#.fx16i7o50
http://magenic.com/Blog/Post/6/An-MVP-Pattern-for-Android
https://medium.com/ribot-labs/approaching-android-with-mvvm-8ceec02d5442#.pkip2bkyo
http://fernandocejas.com/2014/09/03/architecting-android-the-clean-way/
http://hannesdorfmann.com/android/mosby/
https://plus.google.com/communities/114285790907815804707
http://programmers.stackexchange.com/questions/133134/is-model-view-presenter-mvp-scheme-useful-for-android
@deveshmittal
deveshmittal / mvp.java
Created December 16, 2015 14:57
Clean Architecture
//BasePresenter.java
public interface BasePresenter<V extends BaseView> {
/**
* Set or attach the view to this presenter
*/
public void attachView(V view);
/**
* Will be called if the view has been destroyed. Typically this method will
@deveshmittal
deveshmittal / mvp.java
Created December 16, 2015 14:57
Clean Architecture
//BasePresenter.java
public interface BasePresenter<V extends BaseView> {
/**
* Set or attach the view to this presenter
*/
public void attachView(V view);
/**
* Will be called if the view has been destroyed. Typically this method will
@deveshmittal
deveshmittal / FlowLayout.java
Created March 12, 2016 16:55
FlowLayout.java
public class FlowLayout extends ViewGroup {
public static final int HORIZONTAL = 0;
public static final int VERTICAL = 1;
private int horizontalSpacing = 0;
private int verticalSpacing = 0;
private int orientation = 0;
private boolean debugDraw = false;