blinskey / greek-reference

An ancient Greek lexicon and grammar for Android.
https://play.google.com/store/apps/details?id=com.benlinskey.greekreference
Apache License 2.0
29 stars 5 forks source link

DialogFragments should be static #155

Closed blinskey closed 8 years ago

blinskey commented 8 years ago

From Gradle:

:GreekReference:lintVitalRelease/home/blinskey/src/greek-reference/GreekReference/src/main/java/com/benlinskey/greekreference/views/AbstractContainerActivity.java:90: Error: Fragments should be static such that they can be re-instantiated by the system, and anonymous classes are not static [ValidFragment]
        DialogFragment fragment = new DialogFragment() {
                                      ~~~~~~~~~~~~~~
/home/blinskey/src/greek-reference/GreekReference/src/main/java/com/benlinskey/greekreference/views/MainActivity.java:466: Error: Fragments should be static such that they can be re-instantiated by the system, and anonymous classes are not static [ValidFragment]
        DialogFragment dialog = new DialogFragment() {
                                    ~~~~~~~~~~~~~~
/home/blinskey/src/greek-reference/GreekReference/src/main/java/com/benlinskey/greekreference/views/MainActivity.java:494: Error: Fragments should be static such that they can be re-instantiated by the system, and anonymous classes are not static [ValidFragment]
        DialogFragment dialog = new DialogFragment() {
                                    ~~~~~~~~~~~~~~

   Explanation for issues of type "ValidFragment":
   From the Fragment documentation:
   Every fragment must have an empty constructor, so it can be instantiated
   when restoring its activity's state. It is strongly recommended that
   subclasses do not have other constructors with parameters, since these
   constructors will not be called when the fragment is re-instantiated;
   instead, arguments can be supplied by the caller with setArguments(Bundle)
   and later retrieved by the Fragment with getArguments().

   http://developer.android.com/reference/android/app/Fragment.html#Fragment()

We'll need to make these classes static and implement fragment-to-fragment communication in order to invoke the necessary callback methods.