Your SlideShare is downloading. ×
  • Like
Android Opensources - ButterKnife, Lombok
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Android Opensources - ButterKnife, Lombok

  • 568 views
Published

How to use ButterKnife, Lombok, and how these change the way you code :)

How to use ButterKnife, Lombok, and how these change the way you code :)

Published in Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
568
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
8
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Android Opensources Steven Kim (김우성) 1 Yooii Studios
  • 2. 1. ButterKnife 2. Lombok 2 Yooii Studios
  • 3. ButterKnife? 3 Yooii Studios
  • 4. ButterKnife • http://jakewharton.github.io/butterknife/ • using Annotation Processing • No more findViewById in Activity, View, ListAdapter etc. • Simplify click listeners 4 Yooii Studios
  • 5. ButterKnife - before at activity class ExampleActivity extends Activity { TextView title; TextView subtitle; TextView footer; ! @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_activity); title = (TextView) findViewById(R.id.title); subtitle = (TextView) findViewById(R.id.subtitle); footer = (TextView) findViewById(R.id.footer); ! // TODO Use views... } } 5 Yooii Studios
  • 6. ButterKnife - after BuffetKnife at activity 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... } } 6 Yooii Studios
  • 7. ButterKnife - after BuffetKnife at view public class FancyFragment extends Fragment { @InjectView(R.id.button1) Button button1; @InjectView(R.id.button2) Button button2; ! @Override View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fancy_fragment, container, false); ButterKnife.inject(this, view); // TODO Use "injected" views... return view; } } 7 Yooii Studios
  • 8. ButterKnife - after BuffetKnife at list adapter static class ViewHolder { @InjectView(R.id.title) TextView name; @InjectView(R.id.job_title) TextView jobTitle; ! public ViewHolder(View view) { ButterKnife.inject(this, view); } } 8 Yooii Studios
  • 9. ButterKnife - after BuffetKnife at list adapter public class MyAdapter extends BaseAdapter { @Override public View getView(int position, View view, ViewGroup parent) { ViewHolder holder; view = inflater.inflate(R.layout.whatever, parent, false); ! ! ! } holder = new ViewHolder(view); holder.name.setText("John Doe"); // etc... return convertView; static class ViewHolder { @InjectView(R.id.title) TextView name; @InjectView(R.id.job_title) TextView jobTitle; public ViewHolder(View view) { ButterKnife.inject(this, view); } } 9 Yooii Studios
  • 10. Lombok ? 10 Yooii Studios
  • 11. Lombok • http://projectlombok.org/ • No more Getter / Setter! 11 Yooii Studios
  • 12. Lombok - before Lombok public class GetterSetterExample { private int age = 10; private String name; ! public int getAge() { return age; } public void setAge(int age) { this.age = age; } protected void setName(String name) { this.name = name; } } 12 Yooii Studios
  • 13. Lombok - after Lombok public class GetterSetterExample { @Getter @Setter private int age = 10; @Setter(AccessLevel.PROTECTED) private String name; } 13 Yooii Studios
  • 14. To be continued… • Android Annotations - Runtime DI(Dependency Injection) - • Robolectric (2.2+) - Testing - • http://androidannotations.org/ http://robolectric.org/ Otto - Event handler using bus - http://square.github.io/otto/ 14 Yooii Studios
  • 15. Thank you! 15 Yooii Studios