Skip to content

Instantly share code, notes, and snippets.

View andersonleite's full-sized avatar
🎯
Focusing

Anderson Leite andersonleite

🎯
Focusing
View GitHub Profile
// Retrofit Interface
@GET("/group/{id}/users")
List<User> groupList(@Path("id") int groupId);
// Chamada ao Endpoint com retorno em JSON
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint("https://api.github.com")
.setRequestInterceptor(requestInterceptor)
.build();
@GET("/user/{id}/photo")
Observable<Photo> getUserPhoto(@Path("id") int id);
@andersonleite
andersonleite / House.java
Last active August 29, 2015 14:23
Parcelable
public class House implements Parcelable {
private Integer rooms;
private String color;
protected House(Parcel in) {
rooms = in.readByte() == 0x00 ? null : in.readInt();
color = in.readString();
}
def myVar = {String str, int num -> println "$str : $num" }
//execute closure
myVar('age', 30)
#output: age : 30
task myTask {
println "Configuration stage" // Configuration stage
doLast {
println "Execution stage" // Execution stage
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
allprojects {
@andersonleite
andersonleite / gist:2db06f63711797693686
Last active August 29, 2015 14:23
Views for GridLayoutManager
<!- activity_main.xml ->
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
android:clipToPadding="false"/>
<!- item.xml ->
/**
* Created by andersonl on 6/18/15.
*/
public class GridLettersAdapter extends RecyclerView.Adapter<Letter> {
char[] alphabet = "abcdefghijklmnopqrstuvwxyz".toCharArray();
private List<String> letters;
public GridLettersAdapter() {
int count = alphabet.length;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new GridLayoutManager(this, 3));
/**
* Created by andersonl on 6/18/15.
*/
public class GridDecoration extends RecyclerView.ItemDecoration {
private int margin;
public GridDecoration(Context context) {
margin = context.getResources().getDimensionPixelSize(R.dimen.item_margin);
}