コード例 #1
0
 @Override
 public void onAnimationEnd(BubbleFlowView sender) {
   TabView currentTab = ((BubbleFlowDraggable) sender).getCurrentTab();
   if (currentTab != null && currentTab.getContentView() != null) {
     currentTab.getContentView().saveLoadTime();
   }
 }
コード例 #2
0
 private void onBubbleFlowCollapseFinished() {
   mBubbleDraggable.setVisibility(View.VISIBLE);
   TabView tab = mBubbleFlowDraggable.getCurrentTab();
   if (tab != null) {
     tab.setImitator(mBubbleDraggable);
   }
   mSetBubbleFlowGone = true;
   mBubbleFlowDraggable.postDelayed(mSetBubbleFlowGoneRunnable, 33);
 }
コード例 #3
0
  private void showClosePrompt(final TabView tabView) {
    String title = null;
    if (tabView.getUrl() != null && MainApplication.sTitleHashMap != null) {
      String urlAsString = tabView.getUrl().toString();
      title = MainApplication.sTitleHashMap.get(urlAsString);
    }
    String message;
    if (title != null) {
      message =
          String.format(mContext.getResources().getString(R.string.undo_close_tab_title), title);
    } else {
      message = mContext.getResources().getString(R.string.undo_close_tab_no_title);
    }
    tabView.mWasRestored = false;
    Prompt.show(
        message,
        mContext.getResources().getString(R.string.action_undo).toUpperCase(),
        Prompt.LENGTH_SHORT,
        true,
        new Prompt.OnPromptEventListener() {
          @Override
          public void onActionClick() {
            if (tabView.mWasRestored == false) {
              tabView.mIsClosing = false;
              restoreTab(tabView);
              tabView.getContentView().onRestored();
            }
          }

          @Override
          public void onClose() {
            if (tabView.mWasRestored == false) {
              tabView.destroy();
            }
          }
        });
  }
コード例 #4
0
  public boolean closeTab(
      TabView tabView,
      Constant.BubbleAction action,
      boolean animateOff,
      boolean canShowUndoPrompt) {

    if (tabView == null) {
      CrashTracking.log("closeTab attempt on null tabView");
      return false;
    }

    // If the tab is already closing, do nothing. Otherwise we could end up in a weird state,
    // where we attempt to show multiple prompts and crashing upon tab restore.
    if (null == tabView || tabView.mIsClosing == true) {
      CrashTracking.log("Ignoring duplicate tabView close request");
      return false;
    }
    if (null != tabView) {
      tabView.mIsClosing = true;
    } else {
      CrashTracking.log("attempt to access on null tabView");
      return false;
    }

    boolean contentViewShowing = contentViewShowing();
    CrashTracking.log(
        "MainController.closeTab(): action:"
            + action.toString()
            + ", contentViewShowing:"
            + contentViewShowing
            + ", visibleTabCount:"
            + getVisibleTabCount()
            + ", activeTabCount:"
            + getActiveTabCount()
            + ", canShowUndoPrompt:"
            + canShowUndoPrompt
            + ", animateOff:"
            + animateOff
            + ", canShowUndoPrompt:"
            + canShowUndoPrompt);
    if (mBubbleFlowDraggable != null) {
      mBubbleFlowDraggable.closeTab(
          tabView, animateOff, action, tabView != null ? tabView.getTotalTrackedLoadTime() : -1);
    }

    int activeTabCount = getActiveTabCount();
    showBadge(activeTabCount > 1 ? true : false);
    if (activeTabCount == 0) {
      hideBubbleDraggable();
      // Ensure BubbleFlowDraggable gets at least 1 update in the event items are animating off
      // screen. See #237.
      scheduleUpdate();

      MainApplication.postEvent(mContext, mMinimizeExpandedActivityEvent);
    }

    if (tabView == null) {
      CrashTracking.logHandledException(new RuntimeException("tabView = null"));
    } else {
      if (canShowUndoPrompt && Settings.get().getShowUndoCloseTab()) {
        showClosePrompt(tabView);
      } else {
        destroyTabOnDelay(tabView);
      }
    }

    return getActiveTabCount() > 0;
  }