public void constructSlices() {
    final Resources res = mContext.getResources();

    // Clear the slices
    mPieContainer.clearSlices();

    // Construct navbar slice
    int inner = res.getDimensionPixelSize(R.dimen.pie_navbar_radius);
    int outer = inner + res.getDimensionPixelSize(R.dimen.pie_navbar_height);
    mNavigationSlice =
        new PieSliceContainer(mPieContainer, PieSlice.IMPORTANT | PieDrawable.DISPLAY_ALL);
    mNavigationSlice.setGeometry(START_ANGLE, 180 - 2 * EMPTY_ANGLE, inner, outer);

    // Construct maybe navbar slice second layer
    ArrayList<ActionConfig> buttonsConfig = ActionHelper.getPieSecondLayerConfig(mContext);
    mSecondLayerActive = buttonsConfig.size() > 0;
    if (mSecondLayerActive) {
      inner = res.getDimensionPixelSize(R.dimen.pie_navbar_second_layer_radius);
      outer = inner + res.getDimensionPixelSize(R.dimen.pie_navbar_height);
      mNavigationSliceSecondLayer =
          new PieSliceContainer(mPieContainer, PieSlice.IMPORTANT | PieDrawable.DISPLAY_ALL);
      mNavigationSliceSecondLayer.setGeometry(START_ANGLE, 180 - 2 * EMPTY_ANGLE, inner, outer);
    }

    // Setup buttons and add the slices finally
    mPieContainer.addSlice(mNavigationSlice);
    if (mSecondLayerActive) {
      mPieContainer.addSlice(mNavigationSliceSecondLayer);
      // Adjust dimensions for sysinfo when second layer is active
      inner = res.getDimensionPixelSize(R.dimen.pie_sysinfo_second_layer_radius);
    } else {
      inner = res.getDimensionPixelSize(R.dimen.pie_sysinfo_radius);
    }

    // Construct sysinfo slice
    outer = inner + res.getDimensionPixelSize(R.dimen.pie_sysinfo_height);
    mSysInfo = new PieSysInfo(mContext, mPieContainer, this, PieDrawable.DISPLAY_NOT_AT_TOP);
    mSysInfo.setGeometry(START_ANGLE, 180 - 2 * EMPTY_ANGLE, inner, outer);
    mPieContainer.addSlice(mSysInfo);
  }
  public void detachContainer(boolean onExit) {
    if (mPieContainer == null || !mAttached) {
      return;
    }
    if (isShowing() && !onExit) {
      mIsDetaching = true;
      return;
    }
    mIsDetaching = false;
    mAttached = false;

    mPieManager.updateEdgeGestureActivationListener(mPieActivationListener, 0);

    if (mTelephonyManager != null) {
      mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
    }

    mContext.getContentResolver().unregisterContentObserver(mSettingsObserver);

    mContext.unregisterReceiver(mBroadcastReceiver);

    mPieContainer.clearSlices();
    mPieContainer = null;
  }