public void hideCurrentSlideup(boolean animate) { SlideupViewWrapper slideupWrapperView = mSlideupViewWrapper; if (slideupWrapperView != null) { Slideup slideup = slideupWrapperView.getSlideup(); if (slideup != null) { slideup.setAnimateOut(animate); } slideupWrapperView.close(); } }
@Override public View createSlideupView(Activity activity, Slideup slideup) { View slideupView = activity.getLayoutInflater().inflate(R.layout.com_appboy_slideup_view, null); TextView message = (TextView) slideupView.findViewById(R.id.com_appboy_slideup_message); message.setText(slideup.getMessage()); if (slideup.getClickAction() == ClickAction.NONE) { ImageView chevron = (ImageView) slideupView.findViewById(R.id.com_appboy_slideup_chevron); chevron.setVisibility(View.GONE); } return slideupView; }
@Override public void onClicked(SlideupCloser slideupCloser, View slideupView, Slideup slideup) { Log.d(TAG, "SlideupViewWrapper.ISlideupViewLifecycleListener.onClicked called."); if (slideup.getClickAction() != ClickAction.NONE) { slideup.logClick(); } // Perform the slideup clicked listener action from the host application first. This give // the app the option to override the values that are sent from the server and handle the // slideup differently depending on where the user is in the app. // // To modify the default slideup clicked behavior, mutate the necessary slideup members. // As // an example, if the slideup were to navigate to the news feed when it was clicked, the // behavior can be cancelled by setting the click action to NONE. boolean handled = getSlideupManagerListener().onSlideupClicked(slideup, slideupCloser); if (!handled) { // Perform the default (or modified) slideup clicked behavior. performSlideupClicked(slideup, slideupCloser); } }
private void performSlideupClicked(Slideup slideup, SlideupCloser slideupCloser) { switch (slideup.getClickAction()) { case NEWS_FEED: slideup.setAnimateOut(false); slideupCloser.close(false); getAppboyNavigator() .gotoNewsFeed(mActivity, BundleUtils.mapToBundle(slideup.getExtras())); break; case URI: slideup.setAnimateOut(false); slideupCloser.close(false); IAction action = ActionFactory.createUriAction(mActivity, slideup.getUri().toString()); action.execute(mActivity); break; case NONE: slideupCloser.close(true); break; default: slideupCloser.close(false); break; } }
/** * Registers the slideup manager, which will listen to and display incoming slideup messages. The * current Activity is required in order to properly inflate and display the slideup view. * * <p>Important note: Every Activity must call registerSlideupManager in the onResume lifecycle * method, otherwise slideup messages may be lost! * * @param activity The current Activity. */ public void registerSlideupManager(Activity activity) { // We need the current Activity so that we can inflate or programmatically create the slideup // View for each Activity. We cannot share the View because doing so would create a memory leak. mActivity = activity; // We have a special check to see if the host app switched to a different Activity (or recreated // the same Activity during an orientation change) so that we can redisplay the slideup. if (mCarryoverSlideup != null) { mCarryoverSlideup.setAnimateIn(false); displaySlideup(mCarryoverSlideup); mCarryoverSlideup = null; } // Every time the AppboySlideupManager is registered to an Activity, we add a slideup subscriber // which listens to new slideups, adds it to the stack, and displays it if it can. mSlideupEventSubscriber = createSlideupEventSubscriber(); Appboy.getInstance(activity).subscribeToNewSlideups(mSlideupEventSubscriber); }
@Override public void beforeOpened(View slideupView, Slideup slideup) { Log.d(TAG, "SlideupViewWrapper.ISlideupViewLifecycleListener.beforeOpened called."); slideup.logImpression(); }