Skip to content

Instantly share code, notes, and snippets.

View deveshmittal's full-sized avatar

Devesh deveshmittal

View GitHub Profile
@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 / 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 / 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 / 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 / Source
Created November 19, 2015 12:26
Android source
http://source.android.com/source/index.html
@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.
*/
/*
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 / RetrofitCachingExample.java
Created November 19, 2015 11:06 — forked from swankjesse/RetrofitCachingExample.java
Demonstrate HTTP caching with OkHttp and Retrofit.
/*
* Copyright (C) 2013 Square, Inc.
*
* 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
*
* Unless required by applicable law or agreed to in writing, software
@deveshmittal
deveshmittal / MyClass.java
Last active November 18, 2015 17:46
How to write Double check Locking correctly
public class MyClass{
private volatile MyClass myClassObject;
public MyClass getInstance(){
MyClass helper = myClassObject;
// Optimisation for getting instance, if the helper has already been initialised return that.
if(helper == null){
synchronised(MyClass.this){
// Since synchronised block takes some time to initialise ,in the mean time another thread might have entered
// the synchronised block and initialised the helper variable. By ensuring that the myclassObject is volatile, we have established
// a happens-before functionality on the myClassObject.
@deveshmittal
deveshmittal / gist:ca2437ddb8b10766b358
Created November 13, 2015 19:47
Add environment variable to PATH in mac
/etc/profile
~/.bash_profile
~/.bash_login
~/.profile