<commit_before>package siarhei.luskanau.iot.lamp.remote.control;

import android.os.Bundle;
import android.support.v7.widget.SwitchCompat;
import android.widget.Checkable;
import android.widget.Toast;

import javax.inject.Inject;

import siarhei.luskanau.iot.lamp.presenter.listen.ListenLampStatePresenter;
import siarhei.luskanau.iot.lamp.presenter.listen.ListenLampStateView;
import siarhei.luskanau.iot.lamp.presenter.send.SendLampStatePresenter;
import siarhei.luskanau.iot.lamp.presenter.send.SendLampStateView;
import siarhei.luskanau.iot.lamp.remote.control.dagger.component.DaggerLampComponent;
import siarhei.luskanau.iot.lamp.remote.control.dagger.component.LampComponent;

public class MainActivity extends BaseComponentActivity implements ListenLampStateView, SendLampStateView {

    @Inject
    protected ListenLampStatePresenter listenLampStatePresenter;
    @Inject
    protected SendLampStatePresenter sendLampStatePresenter;

    private SwitchCompat switchCompat;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        this.initializeInjector();

        listenLampStatePresenter.setView(this);
        sendLampStatePresenter.setView(this);

        switchCompat = (SwitchCompat) findViewById(R.id.switchCompat);
        switchCompat.setOnClickListener(v -> {
            boolean isChecked = ((Checkable) v).isChecked();
            sendLampStatePresenter.sendLampState(isChecked);
        });
    }

    private void initializeInjector() {
        LampComponent lampComponent = DaggerLampComponent.builder()
                .applicationComponent(getApplicationComponent())
                .activityModule(getActivityModule())
                .build();
        lampComponent.inject(this);
    }

    @Override
    protected void onResume() {
        super.onResume();

        listenLampStatePresenter.listenLampState();
    }

    @Override
    protected void onPause() {
        super.onPause();

        listenLampStatePresenter.destroy();
        sendLampStatePresenter.destroy();
    }

    @Override
    public void showLampState(Boolean lampState) {
        switchCompat.setChecked(lampState);
    }

    @Override
    public void showErrorMessage(CharSequence errorMessage) {
        Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT).show();
    }
}<commit_msg>Changes in RemoteControl App related life cycle<commit_after>package siarhei.luskanau.iot.lamp.remote.control;

import android.os.Bundle;
import android.support.v7.widget.SwitchCompat;
import android.widget.Checkable;
import android.widget.Toast;

import javax.inject.Inject;

import siarhei.luskanau.iot.lamp.presenter.listen.ListenLampStatePresenter;
import siarhei.luskanau.iot.lamp.presenter.listen.ListenLampStateView;
import siarhei.luskanau.iot.lamp.presenter.send.SendLampStatePresenter;
import siarhei.luskanau.iot.lamp.presenter.send.SendLampStateView;
import siarhei.luskanau.iot.lamp.remote.control.dagger.component.DaggerLampComponent;
import siarhei.luskanau.iot.lamp.remote.control.dagger.component.LampComponent;

public class MainActivity extends BaseComponentActivity implements ListenLampStateView, SendLampStateView {

    @Inject
    protected ListenLampStatePresenter listenLampStatePresenter;
    @Inject
    protected SendLampStatePresenter sendLampStatePresenter;

    private SwitchCompat switchCompat;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        this.initializeInjector();

        listenLampStatePresenter.setView(this);
        sendLampStatePresenter.setView(this);

        switchCompat = (SwitchCompat) findViewById(R.id.switchCompat);
        switchCompat.setOnClickListener(v -> {
            boolean isChecked = ((Checkable) v).isChecked();
            sendLampStatePresenter.sendLampState(isChecked);
        });
    }

    private void initializeInjector() {
        LampComponent lampComponent = DaggerLampComponent.builder()
                .applicationComponent(getApplicationComponent())
                .activityModule(getActivityModule())
                .build();
        lampComponent.inject(this);
    }

    @Override
    protected void onResume() {
        super.onResume();

        listenLampStatePresenter.listenLampState();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        listenLampStatePresenter.destroy();
        sendLampStatePresenter.destroy();
    }

    @Override
    public void showLampState(Boolean lampState) {
        switchCompat.setChecked(lampState);
    }

    @Override
    public void showErrorMessage(CharSequence errorMessage) {
        Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT).show();
    }
}
{'fraction_non_alphanumeric': 0.08851379168382051, 'fraction_numerical': 0.0004116920543433512, 'mean_word_length': 3.70377541142304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4337320', 'n_tokens_mistral': 1428, 'n_tokens_neox': 1380, 'n_words': 204}