This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@BindingAdapter({"bind:imageUrl", "bind:error"}) | |
public static void loadImage(ImageView view, String url, Drawable error) { | |
Picasso.with(view.getContext()).load(url).error(error).into(view); | |
} | |
private class Todo { | |
public final ObservableField<String> image = new ObservableField<>(); | |
public final ObservableField<String> date = new ObservableField<>(); | |
public final ObservableInt priority = new ObservableInt(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools"> | |
<data> | |
<variable | |
name="todo" | |
type="com.b00sti.models.Todo" /> | |
</data> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Observable<User> getFromApi(String username) { | |
Retrofit retrofit = new Retrofit.Builder() | |
.addCallAdapterFactory(RxJava2CallAdapterFactory.createWithScheduler(Schedulers.io())) | |
.addConverterFactory(GsonConverterFactory.create()) | |
.baseUrl(ENDPOINT) | |
.build(); | |
UserService apiService = retrofit.create(UserService.class); | |
return apiService.getUser(username); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UserService apiService = retrofit.create(UserService.class); | |
String username = "b00sti"; | |
Call<User> call = apiService.getUser(username); | |
call.enqueue(new Callback<User>() { | |
@Override | |
public void onResponse(Call<User> call, Response<User> response) { | |
int statusCode = response.code(); | |
User user = response.body(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final String ENDPOINT = "http://api.b00sti.com/"; | |
Retrofit retrofit = new Retrofit.Builder() | |
.baseUrl(ENDPOINT) | |
.addConverterFactory(GsonConverterFactory.create()) | |
.build(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface UserService { | |
@GET("users/{username}") | |
Call<User> getUser(@Path("username") String username); | |
@GET("group/{id}/users") | |
Call<List<User>> groupList(@Path("id") int groupId, @Query("sort") String sort); | |
@POST("users/new") | |
Call<User> createUser(@Body User user); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@EActivity(R.layout.translate) // Sets content view to R.layout.translate | |
public class TranslateActivity extends Activity { | |
@ViewById // Injects R.id.textInput | |
EditText textInput; | |
@ViewById(R.id.myTextView) // Injects R.id.myTextView | |
TextView result; | |
@AnimationRes // Injects android.R.anim.fade_in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<color name="red_50">#FFEBEE</color> | |
<color name="red_100">#FFCDD2</color> | |
<color name="red_200">#EF9A9A</color> | |
<color name="red_300">#E57373</color> | |
<color name="red_400">#EF5350</color> | |
<color name="red_500">#F44336</color> | |
<color name="red_600">#E53935</color> | |
<color name="red_700">#D32F2F</color> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NonNullExapmle { | |
private String placeName; | |
public NonNullExapmle(Place place) { | |
if (place != null) { | |
throw new NullPointerException("place"); | |
} | |
this.placeName = place.getName(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NonNullExapmle { | |
private String placeName; | |
public NonNullExapmle(@NonNull Place place) { | |
this.placeName = place.getName(); | |
} | |
} |
NewerOlder