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

Android training in 10 sessions

Android training in 10 sessions

Not sure what the context for this training was, but it seems to be an extensive dive into Android in 10 separate lessons.

3d14b1dcd13755bcbafc5ac9c9ab1426?s=128

Andrei Diaconu

March 19, 2016
Tweet

Transcript

  1. Android Intro Stack Overflow edition

  2. 12 10 Lectii 1. Setup & Basic 2. 1 Buton

    3. Tipuri de layout 4. Comunicarea intre ecrane 5. Liste 6. Adaptoare pentru liste 7. Consumarea Datelor 8. Retrofit 9. Indicatori de incarcare 10.Actiuni pe liste 11.Incarcarea imaginilor 12.Salvarea datelor
  3. Lectia 1 - Setup 1. Setup Android Studio 2. Terminologie

    POO 3. Structura fisiere
  4. https://developer.android.com/sdk/index.html

  5. None
  6. • Clasa • Obiect • Atribut • Metoda • Parametru

  7. • Android Manifest • Resurse Android • Layout • Drawable

    • Values • Java
  8. Lectia 2 - Un Buton 1. XML Layout 2. Java

  9. Layout

  10. Layout

  11. Java

  12. Lectia 3 - Layout types • width, height • Tipuri

    de ViewGroup
  13. Abc wrap_content Abc match_parent Ab 50px

  14. LinearLayout

  15. Abc Bcdef Gol

  16. A B

  17. A

  18. A B

  19. RelativeLayout

  20. id view-ul pozitionat

  21. ViewGroup • LinearLayout • RelativeLayout • FrameLayout • TableLayout •

    GridLayout • PercentFrameLayout, PercentRelativeLayout ?
  22. Nume Andrei Prenume Popescu Formular

  23. Nume AndreiLoremIpsumLoremIpsum Prenume Popescu Formular

  24. Nume AndreiLoremIpsumLoremIp... Prenume Popescu Formular

  25. http://bit.ly/itst-day2

  26. Search text Search Stack Overflow Cazul nostru

  27. Lectia 4 - Intents 1. Activitate de rezultate 2. Intenturi

    intre activitati
  28. Intent • actiune • parametri

  29. Intent • explicite • implicite

  30. context.startActivity(intent)

  31. Intent explicit • Intent i = new Intent(context, FinalActivity.class); •

    i.putExtra("key","value"); • startActivity(i);
  32. Exemple implicite • ACTION_VIEW • ACTION_SEND

  33. Lectia 5 - Lists 1. Ce este reciclarea viewurilor? 2.

    ListView 3. Creating our list layout
  34. Reciclarea viewurilor

  35. Reciclarea viewurilor

  36. Cazul nostru List << >>

  37. Lectia 6 - List Adapters 1. Date statice locale 2.

    Ce face un adaptor 3. Realizarea unui adaptor
  38. Adaptor

  39. Adaptor public View getView(View convertView, int position) convertView = null

    sau view reciclat
  40. Lectia 7 - Consuming data 1. Ne uitam la un

    call REST online 2. Android UI Thread
  41. REST http://domain.com/api/cale/catre/resursa

  42. REST • Create • Read • Update • Delete http://domain.com/api/cale/catre/resursa

  43. REST • Create • Read • Update • Delete •

    POST • GET • PUT • DELETE http://domain.com/api/cale/catre/resursa
  44. POST /api/cale/catre/resursa HTTP/1.1 Host: domain.com Content-Length: 123 Accept: */* User-Agent:

    Mozilla/5.0 ... Content-Type: application/x-www-form-urlencoded parametru1=valoare1&parametru2=valoare2
  45. GET https://api.stackexchange.com/2.2/search

  46. GET https://api.stackexchange.com/2.2/search? intitle=android&site=stackoverflow

  47. None
  48. • items: Array de Obiect • tags: Array de string

    • owner: Obiect • reputation: int • user_id: int • profile_image: string • is_answered: boolean • view_count: int • link: string • title: string
  49. JSON • Obiecte • Array • Chei - valori

  50. JSON • Obiecte • Array • Chei - valori •

    {} • [] • "string" • 100 • true • false • null Valori posibile
  51. Android UI Thread

  52. http://bit.ly/itst-day3

  53. Lectia 8 - Retrofit 1. Creating our first call: search

    2. Integrating results with our adapter
  54. http://square.github.io/retrofit https://github.com/google/gson

  55. build.gradle dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
 testCompile 'junit:junit:4.12'


    compile 'com.android.support:appcompat-v7:23.2.0'
 
 compile 'com.squareup.retrofit2:retrofit:2.0.0' compile 'com.squareup.retrofit2:converter-gson:2.0.0' 
 
 }
  56. public interface StackOverflowService {
 @GET("/2.2/search?site=stackoverflow")
 Call<SearchResponse> search(@Query("intitle") String query);
 }

  57. public interface StackOverflowService {
 @GET("/2.2/search?site=stackoverflow")
 Call<SearchResponse> search(@Query("intitle") String query);
 }

    Retrofit retrofit = new Retrofit.Builder()
 .baseUrl("https://api.stackexchange.com/")
 .addConverterFactory(GsonConverterFactory.create())
 .build(); StackOverflowService service = retrofit.create(StackOverflowService.class);
  58. Call<SearchResponse> searchCall = service.search("android");
 
 searchCall.enqueue(new Callback<SearchResponse>() {
 @Override
 public

    void onResponse(Call<SearchResponse> call, Response<SearchResponse> response) {
 Toast.makeText(MainActivity.this, "This many elements: "+response.body().items.size(), Toast.LENGTH_SHORT).show();
 }
 
 @Override
 public void onFailure(Call<SearchResponse> call, Throwable t) {
 
 }
 });
  59. Lectia 9 - Loading 1. Add loading to the layout

    2. Hook loading visibility to retrofit
  60. http://bit.ly/itst_day4

  61. Call<SearchResponse> searchCall = service.search("android"); 
 // Show loading 
 searchCall.enqueue(new

    Callback<SearchResponse>() {
 @Override
 public void onResponse(Call<SearchResponse> call, Response<SearchResponse> response) {
 // Hide loading
 }
 
 @Override
 public void onFailure(Call<SearchResponse> call, Throwable t) { // Hide loading
 }
 });
  62. Lectia 10 - Loading images 1. Add ImageView to layout

    2. Load user profile image using Picasso
  63. build.gradle dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
 testCompile 'junit:junit:4.12'


    compile 'com.android.support:appcompat-v7:23.2.0'
 
 compile 'com.squareup.retrofit2:retrofit:2.0.0' compile 'com.squareup.retrofit2:converter-gson:2.0.0' 
 compile 'com.github.bumptech.glide:glide:3.7.0' 
 }
  64. Glide.with(parent.getContext())
 .load(question.owner.profile_image)
 .placeholder(R.drawable.placeholder)
 .into(imageView);

  65. Keep in touch • https://www.facebook.com/ITst.Iasi • http://bit.ly/android-iasi