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.

Andrei Diaconu

March 19, 2016
Tweet

More Decks by Andrei Diaconu

Other Decks in Technology

Transcript

  1. 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
  2. A B

  3. A

  4. A B

  5. ViewGroup • LinearLayout • RelativeLayout • FrameLayout • TableLayout •

    GridLayout • PercentFrameLayout, PercentRelativeLayout ?
  6. Intent explicit • Intent i = new Intent(context, FinalActivity.class); •

    i.putExtra("key","value"); • startActivity(i);
  7. Lectia 5 - Lists 1. Ce este reciclarea viewurilor? 2.

    ListView 3. Creating our list layout
  8. Lectia 6 - List Adapters 1. Date statice locale 2.

    Ce face un adaptor 3. Realizarea unui adaptor
  9. Lectia 7 - Consuming data 1. Ne uitam la un

    call REST online 2. Android UI Thread
  10. REST • Create • Read • Update • Delete •

    POST • GET • PUT • DELETE http://domain.com/api/cale/catre/resursa
  11. 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
  12. • 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
  13. JSON • Obiecte • Array • Chei - valori •

    {} • [] • "string" • 100 • true • false • null Valori posibile
  14. Lectia 8 - Retrofit 1. Creating our first call: search

    2. Integrating results with our adapter
  15. 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' 
 
 }
  16. 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);
  17. 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) {
 
 }
 });
  18. Lectia 9 - Loading 1. Add loading to the layout

    2. Hook loading visibility to retrofit
  19. 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
 }
 });
  20. Lectia 10 - Loading images 1. Add ImageView to layout

    2. Load user profile image using Picasso
  21. 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' 
 }