LiveTyping/u2020-mvp

There's a problem with Registry class

Closed this issue · 0 comments

cosic commented

In u2020-mvp as example of app the Registry looks like a good solution for attachment/detachment a view to presenter. But for production app there's problems with attachment view to presenter when I try to open the same activity that already has existed in activity stack with Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP flags.

For example, there're in activity stack:

Activity A1 (ViewA1, presenterA1)
Activity B (ViewB, presenterB)

And I add new Activity A:

Activity A2 (ViewA2)

So, I haven't had the attached presenter.

What it's happened when I made startActivity(ActivityA.class):

ActivityA2.onCreate(); /* Created a new presenter for Activity2. 
Generated key in Registry class. This key the same like as at 
Activity1 presenter. So it will be replaced. */
ActivityA2.onStart(); /* Look for the existing presenter by key 
and makes the attachment the view to presenter. */
ActivityB.onStop();
ActivityA1.onStop(); /* Look for the presenter by key and makes
 the detachment view from presenter. */

So, we got ActivityA2 with presenter without attached view.