-
public class BatchMessagingViewClass representing a Batch Messaging view.
This is used to manually handle display of Mobile Landings and In-App Messages.
BatchMessagingView should be instantiated from the static factory methods: loadMessagingView.
Then you will have to call showView or showFragment according to the kind.
Note that: this methods should be called from the UI thread.
Example:
{@code * val messagingView = Batch.Messaging.loadMessagingView(this, message) * when (messagingView.kind) { * BatchMessagingView.Kind.Fragment -> messagingView.showFragment(supportFragmentManager, "batch-landing") * BatchMessagingView.Kind.View -> messagingView.showView(this) * } * }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumBatchMessagingView.KindKind of view which can be wrapped by this class.
-
Field Summary
Fields Modifier and Type Field Description private final BatchMessagingView.Kindkind
-
Method Summary
Modifier and Type Method Description BatchMessagingView.KindgetKind()Get the kind of view wrapped. DialogFragmenttoFragment()Get the wrapped value as a DialogFragment. voidshowView(@NonNull() Activity activity)Shows the BatchMessagingView for the specified activity. voidshowView(@NonNull() View anchorView)Show the wrapped value as a View for the specified anchor view. voiddismissView(boolean animated)Dismiss the BatchMessagingView when it's View. voidshowFragment(@NonNull() FragmentActivity activity, @Nullable() String tag)Show the wrapped value as a DialogFragment. voidshowFragment(@NonNull() FragmentManager fragmentManager, @Nullable() String tag)Show the wrapped value as a DialogFragment. voiddismissFragment()Dismiss the BatchMessagingView when it's Fragment. -
-
Method Detail
-
getKind
@NonNull() BatchMessagingView.Kind getKind()
Get the kind of view wrapped.
-
toFragment
@Nullable() DialogFragment toFragment()
Get the wrapped value as a DialogFragment.
You should check the kind of view before calling this method.
-
showView
void showView(@NonNull() Activity activity)
Shows the BatchMessagingView for the specified activity.
This is equivalent to calling show(findViewById(android.R.id.content)).If you'd like to attach the message on a CoordinatorLayout, you should use showView,or have your activity implement Batch.Messaging.DisplayHintProvider.
This can only be called once per instance of BatchMessagingView, even if dismissView has been called.
You can run this method on any thread.
You should check the kind of view before calling this method.
- Parameters:
activity- Activity to display the banner on.
-
showView
void showView(@NonNull() View anchorView)
Show the wrapped value as a View for the specified anchor view.
Just like a Snack bar, the anchor view can be any view from your hierarchy.BatchMessagingView will automatically explore your view hierarchy to find the most appropriate view to display itself onto.Usually, this should be a CoordinatorLayout, or your root view.
This can only be called once per instance of BatchBannerView, even if dismissView has been called.
You can run this method on any thread.
You should check the kind of view before calling this method.
- Parameters:
anchorView- View used as a base to find the best view to be attached to.
-
dismissView
void dismissView(boolean animated)
Dismiss the BatchMessagingView when it's View.
Calling this doesn't allow you to call showView or showView again.
You should check the kind of view before calling this method.
- Parameters:
animated- true if the dismissal should be animated, false otherwise
-
showFragment
void showFragment(@NonNull() FragmentActivity activity, @Nullable() String tag)
Show the wrapped value as a DialogFragment.
You should check the kind of view before calling this method.
- Parameters:
activity- The activity to show the dialog in.tag- The tag to use for the fragment.
-
showFragment
void showFragment(@NonNull() FragmentManager fragmentManager, @Nullable() String tag)
Show the wrapped value as a DialogFragment.
You should check the kind of view before calling this method.
- Parameters:
fragmentManager- The fragment manager to use.tag- The tag to use for the fragment.
-
dismissFragment
void dismissFragment()
Dismiss the BatchMessagingView when it's Fragment.
You should check the kind of view before calling this method.
-
-
-
-