3. New Activity Guide - addam01/android-rx-retro-kickstart GitHub Wiki

New Activity Guide

Overview

This tutorial is to set up new activities and new packages.

Create new package

If you are not planning to have multiple services or multiple API calling, I would recommend creating just one package to place your classes and activities in it.

  1. Create a package of your own, if you haven't done it yet.

  2. Create 5 sub packages,

    • Activities
    • Models
    • Views
    • Presenter
    • retroRest
  3. Create an activity in the Activities package.

  4. Create a presenter class in the Presenter package.

  5. Create a view interface, extend the view on Core package like so

     import com.example.addam.skeleton_app.core.View;
     public interface SampleView extends View {}
    
  6. Your presenter class implements Presenters from Core with the type of your view above like so

     public class SamplePresenter implements Presenters<SampleView> {}
    
  7. All of your API request and respond Objects goes to Model (Google up MVC style). Use JSONSchema2Pojo to convert your JSON to GSON annotation.

  8. All your REST threadings goes into the retroRest, we'll cover that in the next tutorial.

Summary of the OOP

Basically your classes should related like this

Activity -> Binds -> View -> Into -> Presenters

Presenter -> Handles logic for -> Acvtivity -> By handling events through -> View

Models -> Holds object for API request and response for -> Presenters -> In API threading from -> retroRest

⚠️ **GitHub.com Fallback** ⚠️