java - Identical fragments with different presenters -


i have activity 3 tabs: a, b & c. every tab, i’ve created fragment (-f) , presenter (-p). problem 3 fragments (a-f, b-f, c-f) same, presenters not. question how can avoid code duplicity? i’ve tried create basefragment , extend a-f, b-f, c-f, if i’m in a-f , happens c-f (like ui update), receive java.lang.nullpointerexception: attempt invoke virtual method 'void android.support.v7.widget.recyclerview.setvisibility(int)' on null object reference, because c-f @ destroyed (am right?) don't want create 3 same fragments same layouts.

i've done similar , i've found using views lot simpler , less buggy. android fragment managers can exhibit unpredictable behavior @ times when executing various transactions. here's quick sample of how can work:

youractivity extends activity {       view a,b,c;        @override       protected void oncreate(bundle savedinstancestate) {           = getlayoutinflater().inflate(r.layout.your_layout_id, null);           b = getlayoutinflater().inflate(r.layout.your_layout_id, null);           c = getlayoutinflater().inflate(r.layout.your_layout_id, null);       } } 

the activity presenter / controller android, go ahead , have logic here instead of defining presenter class now. on each tab press control view show. don't see code in performing fragment transition cannot comment sure if fragment destroyed.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -