package com.nextzy.mrsmile.mvp_example.calculator;

import android.view.View;

/**
 * Created by nextzy on 8/6/2016 AD.
 */
public class CalculatorPresenter implements CalculatorContractor.Presenter {

    private CalculatorContractor.View view;

    protected CalculatorPresenter() {

    }

    private CalculatorPresenter(CalculatorContractor.View view) {
        this.view = view;
    }

    public static CalculatorPresenter createPresenter(CalculatorContractor.View view) {
        return new CalculatorPresenter(view);
    }

    @Override
    public void viewClick(View view) {

    }

    @Override
    public int plusValue(int x, int y) {
        return x + y;
    }

    @Override
    public int minusValue(int x, int y) {
        return x - y;
    }

    @Override
    public int multiplyValue(int x, int y) {
        return x * y;
    }

    @Override
    public int divideValue(int x, int y) {
        return x / y;
    }

    @Override
    public void onStart() {

    }

    @Override
    public void onStop() {

    }
}

@@ -70,16 +70,88 @@
 ew.View;
+%0Aimport android.widget.Button;%0A%0Aimport com.nextzy.mrsmile.mvp_example.R;
 %0A%0A/**%0A *
@@ -648,24 +648,782 @@
 ew view) %7B%0A%0A
+        Button button;%0A%0A        if (view instanceof Button)%0A            button = (Button) view;%0A        else%0A            return;%0A%0A        int id = button.getId();%0A%0A        switch (id) %7B%0A            case R.id.btn_clear:%0A                this.view.setTextDisplay(%220.00%22);%0A                break;%0A            case R.id.btn_operator_equals:%0A                break;%0A            default:%0A                String displayText = this.view.getTextDisplay();%0A                String text = button.getText().toString();%0A%0A                if (displayText.equalsIgnoreCase(%220.00%22)) %7B%0A                    this.view.setTextDisplay(text);%0A                %7D else %7B%0A                    this.view.setTextDisplay(displayText + text);%0A                %7D%0A                break;%0A        %7D%0A
     %7D%0A%0A    @

update method viewClick in presenter