diff options
Diffstat (limited to 'main/src/cgeo/geocaching/activity/ShowcaseViewBuilder.java')
| -rw-r--r-- | main/src/cgeo/geocaching/activity/ShowcaseViewBuilder.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/activity/ShowcaseViewBuilder.java b/main/src/cgeo/geocaching/activity/ShowcaseViewBuilder.java new file mode 100644 index 0000000..6b00f0f --- /dev/null +++ b/main/src/cgeo/geocaching/activity/ShowcaseViewBuilder.java @@ -0,0 +1,61 @@ +package cgeo.geocaching.activity; + +import com.github.amlcurran.showcaseview.ShowcaseView.Builder; +import com.github.amlcurran.showcaseview.targets.Target; + +import android.app.Activity; + +/** + * TODO: replace by simple utility class embedding a builder instead of inheriting from it + */ +public class ShowcaseViewBuilder extends Builder { + + private final Activity activity; + + public ShowcaseViewBuilder(final Activity activity) { + super(activity); + this.activity = activity; + } + + @Override + public ShowcaseViewBuilder setContentTitle(final int resId) { + setSingleshot(activity.getResources().getString(resId)); + return (ShowcaseViewBuilder) super.setContentTitle(resId); + } + + /** + * Use the hash of the title for the single shot remembering + * + * @param resId + */ + private void setSingleshot(final CharSequence title) { + super.singleShot(title.hashCode()); + } + + @Override + public ShowcaseViewBuilder setContentText(final int resId) { + return (ShowcaseViewBuilder) super.setContentText(resId); + } + + @Override + public ShowcaseViewBuilder setContentText(final CharSequence text) { + return (ShowcaseViewBuilder) super.setContentText(text); + } + + @Override + public ShowcaseViewBuilder setContentTitle(final CharSequence title) { + setSingleshot(title); + return (ShowcaseViewBuilder) super.setContentTitle(title); + } + + @Override + public ShowcaseViewBuilder setTarget(final Target target) { + return (ShowcaseViewBuilder) super.setTarget(target); + } + + public ShowcaseViewBuilder setContent(final int titleId, final int textId) { + setContentTitle(titleId); + return setContentText(textId); + } + +} |
