Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kickstart your Android development

Kickstart your Android development

Presentation / workshop for App Start Contest

Dino Kovač

March 24, 2016
Tweet

More Decks by Dino Kovač

Other Decks in Programming

Transcript

  1. ABOUT INFINUM • independent design and development agency • 90

    employees • 15 Android Engineers • hundreds of projects
  2. SHORTCUTS • CTRL + SHIFT + A → find action

    • SHIFT + F6 → rename • ALT + F7 → find usages • CTRL + SHIFT + O → open file
  3. DEVELOPER TOOLS ON DEVICE • to enable press build number

    7 times (Settings - About phone) • you get a bunch of useful options
  4. HIERARCHY VIEWER • inspect your view hierarchy at runtime •

    profile measure/layout/draw and find bottlenecks • comes with Android SDK
  5. GLIDE • simple image loading library • built-in caching •

    animated gifs! • https://github.com/bumptech/glide Glide.with(this).load("http://goo.gl/gEgYUd").into(imageView);
  6. OKHTTP • fast, well-tested and maintained http client • many

    features (spdy and http/2 support, websockets, …) • nice API (as opposed to HttpURLConnection) • http://square.github.io/okhttp/
  7. public class LoginResponse implements Serializable {
 
 @SerializedName("id")
 private String

    accessToken;
 
 @SerializedName("userId")
 private String userId;
 
 @SerializedName("ttl")
 private int timeToLive;
 
 public String getAccessToken() {
 return accessToken;
 }
 
 public String getUserId() {
 return userId;
 }
 
 public int getTimeToLive() {
 return timeToLive;
 }
 }
  8. RETROFIT • ‘turns your HTTP API into a Java interface’

    • http://square.github.io/retrofit/
  9. public interface ApiService {
 
 @POST("/api/users/login")
 Call<LoginResponse> authenticateUser(@Body LoginRequest loginRequest);


    
 @POST("/api/users")
 Call<RegisterResponse> registerUser(@Body RegisterRequest registerRequest);
 
 @GET("/api/users/{userId}/timezones")
 Call<List<Timezone>> getTimezones(@Path("userId") String userId);
 
 @DELETE("/api/users/{userId}/timezones/{timezoneId}")
 Call<Void> deleteTimezone(@Path("userId") String userId, @Path("timezoneId") String timezoneId);
 
 @POST("/api/users/{userId}/timezones")
 Call<Void> createTimezone(@Path("userId") String userId, @Body Timezone timezone);
 
 @GET("/api/users")
 Call<List<User>> getUsers();
 
 @PUT("/api/users/{userId}")
 Call<User> updateUser(@Path("userId") String userId, @Body User user);
 
 @DELETE("/api/users/{userId}")
 Call<Void> deleteUser(@Path("userId") String userId);
 
 @GET("/api/users/{userId}/roles")
 Call<List<UserRole>> getUserRoles(@Path("userId") String userId); }
  10. BUTTERKNIFE • reduces boilerplate code to get view references •

    generates similar code to what you would write • also does resource binding (strings, drawables, colors, …) • http://jakewharton.github.io/butterknife/
  11. WITHOUT BUTTERKNIFE TextView helloText;
 TextView secondHelloText;
 @Override
 protected void onCreate(Bundle

    savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main); secondHelloText = (TextView) findViewById(R.id.text_hello2);
 secondHelloText.setOnClickListener(new View.OnClickListener() {
 @Override
 public void onClick(View v) {
 // TODO
 }
 }); helloText = (TextView) findViewById(R.id.text_hello); // TODO
 }
  12. WITH BUTTERKNIFE // build.gradle compile 'com.jakewharton:butterknife:7.0.1' // MainActivity.java @Bind(R.id.text_hello2)
 TextView

    secondHelloText;
 
 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 ButterKnife.bind(this); // TODO
 }
 
 @OnClick(R.id.text_hello)
 protected void onHelloClicked() {
 // TODO
 }
  13. HUGO • Annotation-triggered method call logging • https://github.com/JakeWharton/hugo @DebugLog
 public

    String getName() {
 return name;
 } V/EXAMPLE: ⇢ GETNAME() V/EXAMPLE: ⇠ GETNAME [0MS] = "JAKE WHARTON"
  14. DBFLOW • ORM library with annotation processing • generates code

    for interaction with SQLite databases so you don’t have to write it by hand
  15. DBINSPECTOR • adds additional launcher icon for viewing db contents

    and schema • great for debugging db issues • https://github.com/infinum/android_dbinspector/
  16. THREETEN-ABP • backport of the new Date API introduced in

    Java 8 (JSR-310) • https://github.com/JakeWharton/ThreeTenABP
  17. MAGIC VIEWS • easily use custom fonts in your app

    • https://github.com/ikocijan/MagicViews
  18. • Jake Wharton • Reto Meier • Cyril Mottier •

    Dan Lew • Chris Banes • Mark Murphy • Mark Allison PEOPLE TO FOLLOW
  19. INFINUM ANDROID TALKS • http://www.meetup.com/Infinum-Android-Talks-Zagreb/ • new libs • practical

    tips • a place to ask for advice • next event: 7.4.2016. at 18h CET (Strojarska 22)
  20. Any questions? [email protected] @DINO_BLACKSMITH Visit infinum.co or find us on

    social networks: infinum.co infinumco infinumco infinum