Android Opensources - ButterKnife, Lombok
Upcoming SlideShare
Loading in...5
×
 

Android Opensources - ButterKnife, Lombok

on

  • 811 views

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 :)

Statistics

Views

Total Views
811
Views on SlideShare
811
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Android Opensources - ButterKnife, Lombok Android Opensources - ButterKnife, Lombok Presentation Transcript

  • Android Opensources Steven Kim (김우성) 1 Yooii Studios
  • 1. ButterKnife 2. Lombok 2 Yooii Studios
  • ButterKnife? 3 Yooii Studios
  • ButterKnife • http://jakewharton.github.io/butterknife/ • using Annotation Processing • No more findViewById in Activity, View, ListAdapter etc. • Simplify click listeners 4 Yooii Studios
  • 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
  • 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
  • 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
  • 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
  • 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
  • Lombok ? 10 Yooii Studios
  • Lombok • http://projectlombok.org/ • No more Getter / Setter! 11 Yooii Studios
  • 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
  • Lombok - after Lombok public class GetterSetterExample { @Getter @Setter private int age = 10; @Setter(AccessLevel.PROTECTED) private String name; } 13 Yooii Studios
  • 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
  • Thank you! 15 Yooii Studios