question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question regarding getView() and reference the View in the presenter.

See original GitHub issue

This is simply a question, please label it as such.

I understand getView() is deprecated. The docs comments on the method mention the following:

/**
 * Please, use restartableXX and deliverXX methods for pushing data from RxPresenter into View.
 */

What if an Android Context is needed, in cases like parsing a local .json file from assets?

For example:

InputStream is = getView().getAssets().open("data.json");

What is the best practice for this particular case?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Orbytcommented, Jun 14, 2017

We’re explicitly avoiding dependency injection for this project. I was considering reading the file into a String in the Activity and then just passing the presenter the JSON String, but wanted to determine any alternatives.

0reactions
konmikcommented, Oct 23, 2017

I need more data on the issue, preferable a minimal repo with reproduced error. Is looks like yet another support library bug for me (I remember they broke view lifecycle inside fragment one day, so this also can be the reason).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android MVP - Should avoid using R.string references in ...
I consider that there's no reason to call any android code in Presenter (But you always can do it). So in your case:...
Read more >
Android MVP — An End to if (view != null) - Medium
A Presenter, in an Android app architected using Model View Presenter (MVP), might see its reference to the View become null at any...
Read more >
Ted Mosby - Software Architect - Hannes Dorfmann
The view usually has a reference to its presenter. ... the presenter by checking isViewAttached() and using getView() to get the reference.
Read more >
Model-View-Presenter implementation thoughts
I was thinking maybe the view should be a static class? Then the dialogs GetView and get the Presenter from there... I'd been...
Read more >
Introduction to Automated Android Testing - Part 4
A presenter does not care about how a view shows the results, nor how it shows an error. Similarly, a view doesn't care...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found