Search in sources :

Example 1 with FadeChangeHandler

use of com.bluelinelabs.conductor.changehandler.FadeChangeHandler in project Conductor by bluelinelabs.

the class HomeController method onFabClicked.

private void onFabClicked(boolean fromFab) {
    SpannableString details = new SpannableString("A small, yet full-featured framework that allows building View-based Android applications");
    details.setSpan(new AbsoluteSizeSpan(16, true), 0, details.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    final String url = "https://github.com/bluelinelabs/Conductor";
    SpannableString link = new SpannableString(url);
    link.setSpan(new URLSpan(url) {

        @Override
        public void onClick(View widget) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        }
    }, 0, link.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    SpannableStringBuilder description = new SpannableStringBuilder();
    description.append(details);
    description.append("\n\n");
    description.append(link);
    ControllerChangeHandler pushHandler = fromFab ? new TransitionChangeHandlerCompat(new FabToDialogTransitionChangeHandler(), new FadeChangeHandler(false)) : new FadeChangeHandler(false);
    ControllerChangeHandler popHandler = fromFab ? new TransitionChangeHandlerCompat(new FabToDialogTransitionChangeHandler(), new FadeChangeHandler()) : new FadeChangeHandler();
    getRouter().pushController(RouterTransaction.with(new DialogController("Conductor", description)).pushChangeHandler(pushHandler).popChangeHandler(popHandler));
}
Also used : ControllerChangeHandler(com.bluelinelabs.conductor.ControllerChangeHandler) FadeChangeHandler(com.bluelinelabs.conductor.changehandler.FadeChangeHandler) Intent(android.content.Intent) FabToDialogTransitionChangeHandler(com.bluelinelabs.conductor.demo.changehandler.FabToDialogTransitionChangeHandler) SpannableString(android.text.SpannableString) URLSpan(android.text.style.URLSpan) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) AbsoluteSizeSpan(android.text.style.AbsoluteSizeSpan) SpannableString(android.text.SpannableString) TransitionChangeHandlerCompat(com.bluelinelabs.conductor.changehandler.TransitionChangeHandlerCompat) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 2 with FadeChangeHandler

use of com.bluelinelabs.conductor.changehandler.FadeChangeHandler in project Conductor by bluelinelabs.

the class ParentController method addChild.

private void addChild(final int index) {
    @IdRes final int frameId = getResources().getIdentifier("child_content_" + (index + 1), "id", getActivity().getPackageName());
    final ViewGroup container = (ViewGroup) getView().findViewById(frameId);
    final Router childRouter = getChildRouter(container).setPopsLastView(true);
    if (!childRouter.hasRootController()) {
        ChildController childController = new ChildController("Child Controller #" + index, ColorUtil.getMaterialColor(getResources(), index), false);
        childController.addLifecycleListener(new LifecycleListener() {

            @Override
            public void onChangeEnd(@NonNull Controller controller, @NonNull ControllerChangeHandler changeHandler, @NonNull ControllerChangeType changeType) {
                if (!isBeingDestroyed()) {
                    if (changeType == ControllerChangeType.PUSH_ENTER && !hasShownAll) {
                        if (index < NUMBER_OF_CHILDREN - 1) {
                            addChild(index + 1);
                        } else {
                            hasShownAll = true;
                        }
                    } else if (changeType == ControllerChangeType.POP_EXIT) {
                        if (index > 0) {
                            removeChild(index - 1);
                        } else {
                            getRouter().popController(ParentController.this);
                        }
                    }
                }
            }
        });
        childRouter.setRoot(RouterTransaction.with(childController).pushChangeHandler(new FadeChangeHandler()).popChangeHandler(new FadeChangeHandler()));
    }
}
Also used : ControllerChangeHandler(com.bluelinelabs.conductor.ControllerChangeHandler) FadeChangeHandler(com.bluelinelabs.conductor.changehandler.FadeChangeHandler) IdRes(android.support.annotation.IdRes) ViewGroup(android.view.ViewGroup) ControllerChangeType(com.bluelinelabs.conductor.ControllerChangeType) Router(com.bluelinelabs.conductor.Router) Controller(com.bluelinelabs.conductor.Controller) BaseController(com.bluelinelabs.conductor.demo.controllers.base.BaseController)

Example 3 with FadeChangeHandler

use of com.bluelinelabs.conductor.changehandler.FadeChangeHandler in project Conductor by bluelinelabs.

the class ControllerChangeHandlerTests method testSaveRestore.

@Test
public void testSaveRestore() {
    HorizontalChangeHandler horizontalChangeHandler = new HorizontalChangeHandler();
    FadeChangeHandler fadeChangeHandler = new FadeChangeHandler(120, false);
    RouterTransaction transaction = RouterTransaction.with(new TestController()).pushChangeHandler(horizontalChangeHandler).popChangeHandler(fadeChangeHandler);
    RouterTransaction restoredTransaction = new RouterTransaction(transaction.saveInstanceState());
    ControllerChangeHandler restoredHorizontal = restoredTransaction.pushChangeHandler();
    ControllerChangeHandler restoredFade = restoredTransaction.popChangeHandler();
    assertEquals(horizontalChangeHandler.getClass(), restoredHorizontal.getClass());
    assertEquals(fadeChangeHandler.getClass(), restoredFade.getClass());
    HorizontalChangeHandler restoredHorizontalCast = (HorizontalChangeHandler) restoredHorizontal;
    FadeChangeHandler restoredFadeCast = (FadeChangeHandler) restoredFade;
    assertEquals(horizontalChangeHandler.getAnimationDuration(), restoredHorizontalCast.getAnimationDuration());
    assertEquals(horizontalChangeHandler.removesFromViewOnPush(), restoredHorizontalCast.removesFromViewOnPush());
    assertEquals(fadeChangeHandler.getAnimationDuration(), restoredFadeCast.getAnimationDuration());
    assertEquals(fadeChangeHandler.removesFromViewOnPush(), restoredFadeCast.removesFromViewOnPush());
}
Also used : FadeChangeHandler(com.bluelinelabs.conductor.changehandler.FadeChangeHandler) TestController(com.bluelinelabs.conductor.util.TestController) HorizontalChangeHandler(com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler) Test(org.junit.Test)

Example 4 with FadeChangeHandler

use of com.bluelinelabs.conductor.changehandler.FadeChangeHandler in project Conductor by bluelinelabs.

the class CityGridController method onModelRowClick.

void onModelRowClick(CityModel model) {
    String imageTransitionName = getResources().getString(R.string.transition_tag_image_named, model.title);
    String titleTransitionName = getResources().getString(R.string.transition_tag_title_named, model.title);
    List<String> names = new ArrayList<>();
    names.add(imageTransitionName);
    names.add(titleTransitionName);
    getRouter().pushController(RouterTransaction.with(new CityDetailController(model.drawableRes, model.title)).pushChangeHandler(new TransitionChangeHandlerCompat(new SharedElementDelayingChangeHandler(names), new FadeChangeHandler())).popChangeHandler(new TransitionChangeHandlerCompat(new SharedElementDelayingChangeHandler(names), new FadeChangeHandler())));
}
Also used : TransitionChangeHandlerCompat(com.bluelinelabs.conductor.changehandler.TransitionChangeHandlerCompat) FadeChangeHandler(com.bluelinelabs.conductor.changehandler.FadeChangeHandler) ArrayList(java.util.ArrayList) SharedElementDelayingChangeHandler(com.bluelinelabs.conductor.demo.changehandler.SharedElementDelayingChangeHandler)

Example 5 with FadeChangeHandler

use of com.bluelinelabs.conductor.changehandler.FadeChangeHandler in project Conductor by bluelinelabs.

the class RouterTests method testRemovesAllViewsOnDestroy.

@Test
public void testRemovesAllViewsOnDestroy() {
    Controller controller1 = new TestController();
    Controller controller2 = new TestController();
    router.setRoot(RouterTransaction.with(controller1));
    router.pushController(RouterTransaction.with(controller2).pushChangeHandler(new FadeChangeHandler(false)));
    assertEquals(2, router.container.getChildCount());
    router.destroy(true);
    assertEquals(0, router.container.getChildCount());
}
Also used : FadeChangeHandler(com.bluelinelabs.conductor.changehandler.FadeChangeHandler) TestController(com.bluelinelabs.conductor.util.TestController) TestController(com.bluelinelabs.conductor.util.TestController) Test(org.junit.Test)

Aggregations

FadeChangeHandler (com.bluelinelabs.conductor.changehandler.FadeChangeHandler)5 ControllerChangeHandler (com.bluelinelabs.conductor.ControllerChangeHandler)2 TransitionChangeHandlerCompat (com.bluelinelabs.conductor.changehandler.TransitionChangeHandlerCompat)2 TestController (com.bluelinelabs.conductor.util.TestController)2 Test (org.junit.Test)2 Intent (android.content.Intent)1 IdRes (android.support.annotation.IdRes)1 RecyclerView (android.support.v7.widget.RecyclerView)1 SpannableString (android.text.SpannableString)1 SpannableStringBuilder (android.text.SpannableStringBuilder)1 AbsoluteSizeSpan (android.text.style.AbsoluteSizeSpan)1 URLSpan (android.text.style.URLSpan)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 Controller (com.bluelinelabs.conductor.Controller)1 ControllerChangeType (com.bluelinelabs.conductor.ControllerChangeType)1 Router (com.bluelinelabs.conductor.Router)1