Exemplo n.º 1
0
  /**
   * This is the entry point of every feather tools. The main activity catches the tool onClick
   * listener and notify the filtermanager.
   *
   * @param tag the tag
   */
  public void activateEffect(final EffectEntry tag) {
    if (!getEnabled() || !isClosed() || mBitmap == null) return;

    if (mCurrentEffect != null)
      throw new IllegalStateException("There is already an active effect. Cannot activate new");
    if (mEffectLoader == null)
      mEffectLoader = (EffectLoaderService) getService(EffectLoaderService.class);

    final AbstractEffectPanel effect = mEffectLoader.load(tag);

    if (effect != null) {
      mCurrentEffect = effect;
      mCurrentEntry = tag;

      setCurrentState(STATE.OPENING);
      prepareEffectPanel(effect, tag);

      Tracker.recordTag(mCurrentEntry.name.name().toLowerCase(Locale.US) + ": opened");
      mContext
          .getBottomBar()
          .setOnPanelOpenListener(
              new OnPanelOpenListener() {

                @Override
                public void onOpened() {
                  setCurrentState(STATE.OPENED);
                  mContext.getBottomBar().setOnPanelOpenListener(null);
                }

                @Override
                public void onOpening() {
                  mCurrentEffect.onOpening();
                }
              });

      mContext.getBottomBar().open();
    }
  }
Exemplo n.º 2
0
  /**
   * On close.
   *
   * @param isConfirmed the is confirmed
   */
  private void onClose(final boolean isConfirmed) {

    logger.info("onClose");

    setCurrentState(STATE.CLOSING);

    mContext
        .getBottomBar()
        .setOnPanelCloseListener(
            new OnPanelCloseListener() {

              @Override
              public void onClosed() {
                setCurrentState(isConfirmed ? STATE.CLOSED_CONFIRMED : STATE.CLOSED_CANCEL);
                mContext.getBottomBar().setOnPanelCloseListener(null);
              }

              @Override
              public void onClosing() {
                mCurrentEffect.onClosing();
              }
            });
    mContext.getBottomBar().close();
  }