Comments (10)
@RiccardoM Sorry for responding too late. I found the problem, It's because your custom views has same Loader
id so android give you same presenter instance.
I'm working on it to fix this problem
from easymvp.
@RiccardoM I don't think it's a bug as it's not using the same instance. Take a look at this gist. This behavior is expected as you're using the static
keyword. EasyMVP is creating multiple presenters but they all have the same pointer to the counter
variable.
Does your presenter still show numbers from 0 to 9 if you remove the static
keyword?
from easymvp.
@mohamad-amin The problem that I've described is that, instead of the correct 0 1 2 3 4 5 6 7 8 9
string, the code that I've presented prints the incorrect 0 0 0 0 0 0 0 0 0 0
. This is possibile if and only if the injected presenter instance is always the first that is created, otherwise it would correctly print 0 1 2 3 4 5 6 7 8 9
if the injection would perform as expected (creating always a new presenter instance).
from easymvp.
Any progress on this @SaeedMasoumi?
from easymvp.
@SaeedMasoumi Thanks man, appreciate it a lot.
from easymvp.
@SaeedMasoumi Any update on this?
from easymvp.
@RiccardoM Sorry for late response,
I fixed this issue with @PresenterId
annotation. Actually I can't found any better solution according to the limitation of android loaders.
So your ViewImp
class should change to
@CustomView(presenter = Presenter.class)
public class ViewImpl extends android.View implements View {
@Presenter Presenter presenter;
@BindView(R2.id.icon_label_textview) TextView labelTextView;
@PresenterId
int id = 0;
public ViewImpl(Context context, int id){ // or any way you can fill "id"
View view = LayoutInflater.from(context).inflate(R.layout.view_layout, this);
ButterKnife.bind(this, view);
this.id = id;
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
presenter.setupView();
}
@Override
public void setLabelText(String text) {
labelTextView.setText(text);
}
See this test case for more info
from easymvp.
Also this bug fix will be included in 1.2.0-beta5 release
from easymvp.
@SaeedMasoumi I guess it's fair as long as it solves the problem that many have encoutered. If, looking trough the code on how you made this happen, I find a better solution, I'll post it here just so later viewers can see it.
I also think that this new annotation should be inserted into the README.md file to let everyone know its existence.
Thank you again, great job.
from easymvp.
@RiccardoM Thanks, EasyMVP calls getLoaderManager().initLoader(ID, ... , ... );
method, by default the ID is a simple counter object so when you create multiple instances of a class it will assign same id to them, There will be better solutions maybe, I think it can be simplified with putting ids in Bundle
, but i encountered some bugs in custom View
s
from easymvp.
Related Issues (20)
- If I want to call onViewAttached on Activity.onCreate, how could I modify code? HOT 1
- ButterKnife.bind(this); is Caused by: java.lang.IllegalStateException: Required view 'base_layout' with ID 2131427412 for field 'view' was not found. If this view is optional add '@Nullable' (fields) or '@Optional' (methods) 。。。。 HOT 1
- In Presenter using (Activity)getView().getContext() occasionally reporting null pointer errors HOT 1
- easymvp-rx2-api not uploaded to bintray
- easymvp-rx2-api HOT 1
- NullPointerException on Presenter#onViewAttached while using android.app.Activity HOT 1
- Mocking views in presenter testing HOT 4
- [Discussion] Improving @PresenterId annotation HOT 1
- Lint support
- Forgetting @FragmentView makes Gradle crash without any error HOT 1
- [Bug] ViewDelegate generator have problems with inner Interfaces in Kotlin
- Integrating with Architecture Components HOT 1
- Injection is broken with the latest Dagger 2 release HOT 1
- EasyMVP and Robolectric annotations problem
- NullPointerException in ViewDelegates
- Activity view's presenter is not attached on first creation
- Updating com.android.support:design to 27.1.1 causes null presenter
- 我把项目下载下来运行报错
- 我在子module中使用报错,是不是不支持?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easymvp.