Search in sources :

Example 1 with MainPresenter

use of uk.ivanc.archimvp.presenter.MainPresenter in project archi by ivacf.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //Set up presenter
    presenter = new MainPresenter();
    presenter.attachView(this);
    setContentView(R.layout.activity_main);
    progressBar = (ProgressBar) findViewById(R.id.progress);
    infoTextView = (TextView) findViewById(R.id.text_info);
    //Set up ToolBar
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    //Set up RecyclerView
    reposRecycleView = (RecyclerView) findViewById(R.id.repos_recycler_view);
    setupRecyclerView(reposRecycleView);
    // Set up search button
    searchButton = (ImageButton) findViewById(R.id.button_search);
    searchButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            presenter.loadRepositories(editTextUsername.getText().toString());
        }
    });
    //Set up username EditText
    editTextUsername = (EditText) findViewById(R.id.edit_text_username);
    editTextUsername.addTextChangedListener(mHideShowButtonTextWatcher);
    editTextUsername.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                presenter.loadRepositories(editTextUsername.getText().toString());
                return true;
            }
            return false;
        }
    });
}
Also used : KeyEvent(android.view.KeyEvent) TextView(android.widget.TextView) MainPresenter(uk.ivanc.archimvp.presenter.MainPresenter) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 2 with MainPresenter

use of uk.ivanc.archimvp.presenter.MainPresenter in project archi by ivacf.

the class MainPresenterTest method setUp.

@Before
public void setUp() {
    ArchiApplication application = (ArchiApplication) RuntimeEnvironment.application;
    githubService = mock(GithubService.class);
    // Mock the retrofit service so we don't call the API directly
    application.setGithubService(githubService);
    // Change the default subscribe schedulers so all observables
    // will now run on the same thread
    application.setDefaultSubscribeScheduler(Schedulers.immediate());
    mainPresenter = new MainPresenter();
    mainMvpView = mock(MainMvpView.class);
    when(mainMvpView.getContext()).thenReturn(application);
    mainPresenter.attachView(mainMvpView);
}
Also used : GithubService(uk.ivanc.archimvp.model.GithubService) MainMvpView(uk.ivanc.archimvp.view.MainMvpView) MainPresenter(uk.ivanc.archimvp.presenter.MainPresenter) Before(org.junit.Before)

Aggregations

MainPresenter (uk.ivanc.archimvp.presenter.MainPresenter)2 RecyclerView (android.support.v7.widget.RecyclerView)1 KeyEvent (android.view.KeyEvent)1 View (android.view.View)1 TextView (android.widget.TextView)1 Before (org.junit.Before)1 GithubService (uk.ivanc.archimvp.model.GithubService)1 MainMvpView (uk.ivanc.archimvp.view.MainMvpView)1