Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Choosing Right!
Search
Alexey Buzdin
February 19, 2015
Programming
0
52
Choosing Right!
How an Android library can fix your needs.
Alexey Buzdin
February 19, 2015
Tweet
Share
More Decks by Alexey Buzdin
See All by Alexey Buzdin
Make you Gadget Talk: Google Assistant
larchaon
0
83
Writing A Plugin for Android Studio
larchaon
1
89
Marvel of Annotation Processing in Java Mobius 2017
larchaon
0
120
How to Become a Successful Programmer
larchaon
0
100
Kotlin JS: Is it a Thing?
larchaon
0
190
Marvel of Annotations in Java/Android
larchaon
0
86
Testing RESTful services: GoT JavaDay Kiev Edition
larchaon
0
64
Automate the Mobile
larchaon
0
180
Google I/O 2016 Retrospective
larchaon
0
77
Other Decks in Programming
See All in Programming
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.8k
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
170
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
340
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
340
色々なIaCツールを実際に触って比較してみる
iriikeita
0
330
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
230
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
3
690
ヤプリ新卒SREの オンボーディング
masaki12
0
130
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
230
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
190
Featured
See All Featured
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Visualization
eitanlees
145
15k
Scaling GitHub
holman
458
140k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
How STYLIGHT went responsive
nonsquared
95
5.2k
4 Signs Your Business is Dying
shpigford
180
21k
Optimizing for Happiness
mojombo
376
70k
The Cult of Friendly URLs
andyhume
78
6k
Speed Design
sergeychernyshev
25
620
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Transcript
Choosing Right! How an Android library can fix your needs
Alexey Buzdin
ORMs - Fast
ORMs - Fast - Supports Cursor
Cursor new FlowCursorList<>(true, TestModel.class, Condition.column(TestModel$Table.NAME) .like("pasta%")); on getItem -> move
Cursor
ORMs - Fast - Supports Cursor - Supports Migration
ORMs - Fast - Supports Cursor - Supports Migration -
Supports Query Syntax
Query Syntax new Select().from(Item.class) .orderBy(“RANDOM()") .executeSingle();
ORMs Bonus points - Model Callbacks
Model Callbacks @Override protected void beforeSave() { updatedAt = System.currentTimeMillis();
} @Override protected void afterDelete() { // clean up some things? }
ORMs Bonus points - Supports Relations - Model Callbacks
ORMs Bonus points - Supports Relations - Model Callbacks -
Supports Custom Converters - Supports Transactions
ORMs Bonus points - Supports Relations - Model Callbacks -
Supports Custom Converters - Supports Transactions
DBFlow https://github.com/Raizlabs/DBFlow ActiveAndroid ORMLite Ollie https://github.com/pardom/ActiveAndroid https://github.com/pardom/Ollie https://github.com/j256/ormlite-android https://github.com/emilsjolander/sprinkles Sprinkles
Images - Image transformations - ImageView recycling - Automatic memory
and disk caching
Images https://github.com/loopj/android-smart-image-view https://github.com/square/picasso
Dependency Injection - Fast - No boilerplate - Minimum configuration
- Support scopes and providers - Android system services in scope
Dependency Injection https://github.com/google/dagger https://github.com/roboguice/roboguice https://github.com/square/dagger RoboGuice 3.0 Dagger Dagger 2.0
RoboGuice Defaults https://github.com/roboguice/roboguice/blob/master/ roboguice/src/main/java/roboguice/config/ DefaultRoboModule.java
Dagger
Dagger 2.0
Resource Injection - View injection - Resource injection - Listeners
injection
InjectViews class ExampleActivity extends Activity { @InjectView(R.id.title) TextView title; @InjectView(R.id.subtitle)
TextView subtitle; @InjectView(R.id.footer) TextView footer; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_activity); ButterKnife.inject(this); // TODO Use "injected" views... } }
InjectView Holder static class ViewHolder { @InjectView(R.id.title) TextView name; @InjectView(R.id.job_title)
TextView jobTitle; public ViewHolder(View view) { ButterKnife.inject(this, view); } }
Listeners @OnClick(R.id.submit) public void submit(View view) { // TODO submit
data to server... } @OnItemSelected(R.id.list_view) void onItemSelected(int position) { // TODO ... }
Inject Resource public class MyActivity extends RoboActivity { @InjectResource(R.anim.my_animation) Animation
myAnimation; @InjectResource(R.string.app_name) String appName; // the rest of your code }
Resource Injection RoboGuice 3.0 https://github.com/roboguice/roboguice ButterKnife https://github.com/JakeWharton/butterknife AndroidAnnotations https://github.com/excilys/androidannotations
REST - Multipart request body and file upload - Support
URL param and query param - Support JSON, XML - Header Manipulation
REST https://github.com/square/retrofit Retrofit AndroidAnnotations https://github.com/excilys/androidannotations
AndroidAnnotations @Rest("http://www.bookmarks.com") public interface BookmarkClient { @Get("/bookmarks/{userId}?search={search}") Bookmarks getBookmarks(String search,
String userId); } ……. @RestService BookmarkClient restClient; …….
Retrofit RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint("https://api.github.com") .build(); GitHubService service
= restAdapter.create(GitHubService.class); public interface GitHubService { @GET("/users/{user}/repos") List<Repo> listRepos(@Path("user") String user); }
HTTP http://loopj.com/android-async-http/ Android Async Http https://github.com/square/okhttp OK-Http
Tests https://github.com/square/assertj-android https://github.com/robolectric/robolectric https://github.com/RobotiumTech/robotium https://code.google.com/p/android-test-kit/wiki/Espresso AssertJ Robolectric Espresso Robotium
Robotium public void testPreferenceIsSaved() throws Exception { Solo solo =
new Solo(getInstrumentation(), getActivity()); solo.clickOnText("txt"); solo.clearEditText(2); solo.enterText(2, "robotium"); solo.clickOnButton("Save"); solo.goBack(); solo.clickOnText("Edit File Extensions"); assertTrue(solo.searchText(“application/robotium")); } } public class EditorTest extends ActivityInstrumentationTestCase2<EditorActivity> {
Robolectric @RunWith(RobolectricTestRunner.class) public class MyActivityTest { @Test public void clickingButton_shouldChangeResultsViewText()
throws Exception { Activity activity = Robolectric.buildActivity(MyActivity.class).create().get(); Button pressMeButton = (Button) activity.findViewById(R.id.press_me_button); TextView results = (TextView) activity.findViewById(R.id.results_text_view); pressMeButton.performClick(); String resultsText = results.getText().toString(); assertThat(resultsText, equalTo("Testing Android Rocks!")); } }
AssertJ assertThat(layout).isVisible() .isVertical() .hasChildCount(4) .hasShowDividers(SHOW_DIVIDERS_MIDDLE); assertThat(view).isGone();
Validation https://github.com/inmite/android-validation-komensky https://github.com/ragunathjawahar/android-saripaar Android Validation Komensky Android Saripaar
Android Saripaar @NotEmpty @Email private EditText emailEditText; @Password(min = 6,
scheme = Password.Scheme.ALPHA_NUMERIC_MIXED_CASE_SYMBOLS) private EditText passwordEditText; @ConfirmPassword private EditText confirmPasswordEditText; @Checked(message = "You must agree to the terms.") private CheckBox iAgreeCheckBox; new Validator(this).validate();
Android Validation Komensky @NotEmpty(messageId = R.string.validation_name) @MinLength(value = 3, messageId
= R.string.validation_name_length, order = 2) private EditText mNameEditText; FormValidator.validate(this, new SimpleErrorPopupCallback(this));
Misc Pidcat https://github.com/square/otto Otto https://github.com/JakeWharton/pidcat https://github.com/avast/android-butterknife-zelezny Android Butterknife Zelezny
Pidcat
Android Butterknife Zelezny
Otto Bus bus = new Bus(); bus.post(new AnswerAvailableEvent(42)); @Subscribe public
void answerAvailable(AnswerAvailableEvent event) { // TODO: React to the event somehow! } bus.register(this); @Produce public AnswerAvailableEvent produceAnswer() { // Assuming 'lastAnswer' exists. return new AnswerAvailableEvent(this.lastAnswer); }