summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionMeasure.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionMeasure.java')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionMeasure.java31
1 files changed, 25 insertions, 6 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionMeasure.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionMeasure.java
index c2408ca718..b40a7be24c 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionMeasure.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionMeasure.java
@@ -2,6 +2,8 @@ package com.mapbox.mapboxsdk.attribution;
import android.graphics.Bitmap;
import android.graphics.PointF;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import android.widget.TextView;
import java.util.Arrays;
@@ -27,6 +29,7 @@ public class AttributionMeasure {
this.margin = margin;
}
+ @Nullable
public AttributionLayout measure() {
Chain chain = new Chain(
new FullLogoLongTextCommand(),
@@ -45,7 +48,8 @@ public class AttributionMeasure {
private static class FullLogoLongTextCommand implements Command {
- public AttributionLayout execute(AttributionMeasure measure) {
+ @Nullable
+ public AttributionLayout execute(@NonNull AttributionMeasure measure) {
float width = measure.getLogoContainerWidth() + measure.getTextViewContainerWidth();
boolean fitBounds = width <= measure.getMaxSize();
if (fitBounds) {
@@ -57,8 +61,9 @@ public class AttributionMeasure {
}
private static class FullLogoShortTextCommand implements Command {
+ @Nullable
@Override
- public AttributionLayout execute(AttributionMeasure measure) {
+ public AttributionLayout execute(@NonNull AttributionMeasure measure) {
float width = measure.getLogoContainerWidth() + measure.getTextViewShortContainerWidth();
boolean fitBounds = width <= measure.getMaxSizeShort();
if (fitBounds) {
@@ -70,8 +75,9 @@ public class AttributionMeasure {
}
private static class SmallLogoLongTextCommand implements Command {
+ @Nullable
@Override
- public AttributionLayout execute(AttributionMeasure measure) {
+ public AttributionLayout execute(@NonNull AttributionMeasure measure) {
float width = measure.getLogoSmallContainerWidth() + measure.getTextViewContainerWidth();
boolean fitBounds = width <= measure.getMaxSize();
if (fitBounds) {
@@ -83,8 +89,9 @@ public class AttributionMeasure {
}
private static class SmallLogoShortTextCommand implements Command {
+ @Nullable
@Override
- public AttributionLayout execute(AttributionMeasure measure) {
+ public AttributionLayout execute(@NonNull AttributionMeasure measure) {
float width = measure.getLogoContainerWidth() + measure.getTextViewShortContainerWidth();
boolean fitBounds = width <= measure.getMaxSizeShort();
if (fitBounds) {
@@ -96,8 +103,9 @@ public class AttributionMeasure {
}
private static class LongTextCommand implements Command {
+ @Nullable
@Override
- public AttributionLayout execute(AttributionMeasure measure) {
+ public AttributionLayout execute(@NonNull AttributionMeasure measure) {
float width = measure.getTextViewContainerWidth() + measure.margin;
boolean fitBounds = width <= measure.getMaxSize();
if (fitBounds) {
@@ -108,8 +116,9 @@ public class AttributionMeasure {
}
private static class ShortTextCommand implements Command {
+ @Nullable
@Override
- public AttributionLayout execute(AttributionMeasure measure) {
+ public AttributionLayout execute(@NonNull AttributionMeasure measure) {
float width = measure.getTextViewShortContainerWidth() + measure.margin;
boolean fitBounds = width <= measure.getMaxSizeShort();
if (fitBounds) {
@@ -121,6 +130,7 @@ public class AttributionMeasure {
}
private static class NoTextCommand implements Command {
+ @NonNull
@Override
public AttributionLayout execute(AttributionMeasure measure) {
return new AttributionLayout(null, null, false);
@@ -145,6 +155,7 @@ public class AttributionMeasure {
this.commands = Arrays.asList(commands);
}
+ @Nullable
public AttributionLayout start(AttributionMeasure measure) {
AttributionLayout attributionLayout = null;
for (Command command : commands) {
@@ -158,6 +169,7 @@ public class AttributionMeasure {
}
public interface Command {
+ @Nullable
AttributionLayout execute(AttributionMeasure measure);
}
@@ -193,36 +205,43 @@ public class AttributionMeasure {
private TextView textViewShort;
private float marginPadding;
+ @NonNull
public Builder setSnapshot(Bitmap snapshot) {
this.snapshot = snapshot;
return this;
}
+ @NonNull
public Builder setLogo(Bitmap logo) {
this.logo = logo;
return this;
}
+ @NonNull
public Builder setLogoSmall(Bitmap logoSmall) {
this.logoSmall = logoSmall;
return this;
}
+ @NonNull
public Builder setTextView(TextView textView) {
this.textView = textView;
return this;
}
+ @NonNull
public Builder setTextViewShort(TextView textViewShort) {
this.textViewShort = textViewShort;
return this;
}
+ @NonNull
public Builder setMarginPadding(float marginPadding) {
this.marginPadding = marginPadding;
return this;
}
+ @NonNull
public AttributionMeasure build() {
return new AttributionMeasure(snapshot, logo, logoSmall, textView, textViewShort, marginPadding);
}