I am having a lot of trouble trying to get rid of a lot of static variables that are present in my app code.
For instance, I have a QueryUtils.JAVA and here I am setting max value to a progress bar on three diferent fragments.
EstatisticasFragment.ef.loadingIndicator.setMax(acumuladorResultados);
ResultadosFragment.rf.loadingIndicatorResultados.setMax(acumuladorResultados);
DeletadosFragment.df.loadingIndicatorDeletados.setMax(acumuladorResultados);
Now, on each Fragment I am doing this:
static EstatisticasFragment ef;
static DeletadosFragment df;
static ResultadosFragment rf;
I know this causes memory leak, but everything I try to do ends up in the same pitfall where non-static variables cannot be referenced from a static context.
Thanks!
--------------------------EDITED--------------------------
Taking a better look, it seems to me that QueryUtils is meant to be all static, but how can I make the interaction between Activity QueryUtils (Static) and Fragment (Non Static)?
Thanks!
--------------------------EDITED--------------------------
you can make a new class with all the variables you are using as static variables and create getter setters for the variables.Now instantiate your class object in the class where you want to use the variables and set the variables using setters function