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;
}
});
}
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);
}
Aggregations