aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler <bananeweizen@gmx.de>2013-12-25 08:05:42 +0100
committerMichael Keppler <bananeweizen@gmx.de>2013-12-25 08:05:42 +0100
commit7cdf30c21ad29c0b51e3a2e44f86932e981817a0 (patch)
tree0d37117c091bd02350104790ecdbccffe4f0d18c
parent78346dc4d407493b659d0076bfb66ba540a9002f (diff)
downloadcgeo-7cdf30c21ad29c0b51e3a2e44f86932e981817a0.zip
cgeo-7cdf30c21ad29c0b51e3a2e44f86932e981817a0.tar.gz
cgeo-7cdf30c21ad29c0b51e3a2e44f86932e981817a0.tar.bz2
fix #3471: avoid null being possible in the interface
This change also prohibits the same error to occur again in another implementation of the same interface and should therefore be preferred to just checking for null in the current interface implementation.
-rw-r--r--main/src/cgeo/geocaching/activity/AbstractViewPagerActivity.java7
-rw-r--r--main/src/cgeo/geocaching/ui/AbstractCachingListViewPageViewCreator.java6
-rw-r--r--main/src/cgeo/geocaching/ui/AbstractCachingPageViewCreator.java4
3 files changed, 12 insertions, 5 deletions
diff --git a/main/src/cgeo/geocaching/activity/AbstractViewPagerActivity.java b/main/src/cgeo/geocaching/activity/AbstractViewPagerActivity.java
index bb0273f..24c0a1b 100644
--- a/main/src/cgeo/geocaching/activity/AbstractViewPagerActivity.java
+++ b/main/src/cgeo/geocaching/activity/AbstractViewPagerActivity.java
@@ -7,6 +7,7 @@ import com.viewpagerindicator.TitlePageIndicator;
import com.viewpagerindicator.TitleProvider;
import org.apache.commons.lang3.tuple.Pair;
+import org.eclipse.jdt.annotation.NonNull;
import android.app.Activity;
import android.os.Bundle;
@@ -90,7 +91,7 @@ public abstract class AbstractViewPagerActivity<Page extends Enum<Page>> extends
/**
* Set the state of the view
*/
- public void setViewState(Bundle state);
+ public void setViewState(@NonNull Bundle state);
}
/**
@@ -153,7 +154,9 @@ public abstract class AbstractViewPagerActivity<Page extends Enum<Page>> extends
// Restore the state of the view if the page supports it
Bundle state = viewStates.get(page);
- creator.setViewState(state);
+ if (state != null) {
+ creator.setViewState(state);
+ }
container.addView(view, 0);
}
diff --git a/main/src/cgeo/geocaching/ui/AbstractCachingListViewPageViewCreator.java b/main/src/cgeo/geocaching/ui/AbstractCachingListViewPageViewCreator.java
index 75d90eb..11a37aa 100644
--- a/main/src/cgeo/geocaching/ui/AbstractCachingListViewPageViewCreator.java
+++ b/main/src/cgeo/geocaching/ui/AbstractCachingListViewPageViewCreator.java
@@ -2,6 +2,8 @@ package cgeo.geocaching.ui;
import cgeo.geocaching.activity.AbstractViewPagerActivity.PageViewCreator;
+import org.eclipse.jdt.annotation.NonNull;
+
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.View;
@@ -40,8 +42,8 @@ public abstract class AbstractCachingListViewPageViewCreator extends AbstractCac
*
*/
@Override
- public void setViewState(Bundle state) {
- if (view == null || state == null) {
+ public void setViewState(@NonNull Bundle state) {
+ if (view == null) {
return;
}
int logViewPosition = state.getInt(STATE_POSITION);
diff --git a/main/src/cgeo/geocaching/ui/AbstractCachingPageViewCreator.java b/main/src/cgeo/geocaching/ui/AbstractCachingPageViewCreator.java
index 568119e..9d87f2b 100644
--- a/main/src/cgeo/geocaching/ui/AbstractCachingPageViewCreator.java
+++ b/main/src/cgeo/geocaching/ui/AbstractCachingPageViewCreator.java
@@ -4,6 +4,8 @@ import cgeo.geocaching.activity.AbstractViewPagerActivity.PageViewCreator;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import org.eclipse.jdt.annotation.NonNull;
+
import android.os.Bundle;
import android.view.View;
@@ -48,7 +50,7 @@ public abstract class AbstractCachingPageViewCreator<ViewClass extends View> imp
* Restores the state of the view but just returns if not overridden.
*/
@Override
- public void setViewState(Bundle state) {
+ public void setViewState(@NonNull Bundle state) {
return;
}
}