コード例 #1
0
ファイル: DashboardOnMap.java プロジェクト: AmZaf/Osmand
  private void initActionButton() {
    actionButton = new ImageView(mapActivity);
    int btnSize = (int) mapActivity.getResources().getDimension(R.dimen.map_button_size);
    int topPad = (int) mapActivity.getResources().getDimension(R.dimen.dashboard_map_top_padding);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(btnSize, btnSize);
    int marginRight = btnSize / 4;
    params.setMargins(
        0, landscape ? 0 : topPad - 2 * btnSize, marginRight, landscape ? marginRight : 0);
    params.gravity = landscape ? Gravity.BOTTOM | Gravity.RIGHT : Gravity.TOP | Gravity.RIGHT;
    actionButton.setLayoutParams(params);
    actionButton.setScaleType(ScaleType.CENTER);
    actionButton.setImageDrawable(
        mapActivity.getResources().getDrawable(R.drawable.map_my_location));

    actionButton.setBackgroundDrawable(
        mapActivity.getResources().getDrawable(R.drawable.btn_circle_blue));
    hideActionButton();
    actionButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (getMyApplication().accessibilityEnabled()) {
              mapActivity.getMapActions().whereAmIDialog();
            } else {
              mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
            }
            hideDashboard();
          }
        });
  }
コード例 #2
0
ファイル: DashboardOnMap.java プロジェクト: AmZaf/Osmand
  private void updateTopButton(int scrollY) {

    if (actionButton != null && portrait && isActionButtonVisible()) {
      double scale = mapActivity.getResources().getDisplayMetrics().density;
      int originalPosition = mFlexibleSpaceImageHeight - (int) (80 * scale);
      int minTop = mFlexibleBlurSpaceHeight + (int) (5 * scale);
      FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) actionButton.getLayoutParams();
      if (minTop > originalPosition - scrollY) {
        hideActionButton();
      } else {
        actionButton.setVisibility(View.VISIBLE);
        lp.topMargin = originalPosition - scrollY;
        ((FrameLayout) actionButton.getParent()).updateViewLayout(actionButton, lp);
      }
    }
  }
コード例 #3
0
ファイル: DashboardOnMap.java プロジェクト: AmZaf/Osmand
  public void setDashboardVisibility(
      boolean visible, DashboardType type, DashboardType prevItem, boolean animation) {
    if (visible == this.visible && type == visibleType) {
      return;
    }
    this.previousVisibleType = prevItem;
    this.visible = visible;
    boolean refresh = this.visibleType == type;
    this.visibleType = type;
    DashboardOnMap.staticVisible = visible;
    DashboardOnMap.staticVisibleType = type;
    mapActivity.enableDrawer();
    if (visible) {
      mapViewLocation = mapActivity.getMapLocation();
      mapRotation = mapActivity.getMapRotate();
      mapLinkedToLocation = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
      myLocation = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
      mapActivity.getMapViewTrackingUtilities().setDashboard(this);
      mapActivity.disableDrawer();
      dashboardView.setVisibility(View.VISIBLE);
      if (isActionButtonVisible()) {
        actionButton.setVisibility(View.VISIBLE);
      } else {
        hideActionButton();
      }
      updateDownloadBtn();
      View listViewLayout = dashboardView.findViewById(R.id.dash_list_view_layout);
      ScrollView scrollView = (ScrollView) dashboardView.findViewById(R.id.main_scroll);
      if (visibleType == DashboardType.DASHBOARD) {
        addOrUpdateDashboardFragments();
        scrollView.setVisibility(View.VISIBLE);
        scrollView.scrollTo(0, 0);
        listViewLayout.setVisibility(View.GONE);
        onScrollChanged(scrollView.getScrollY(), false, false);
      } else {
        scrollView.setVisibility(View.GONE);
        listViewLayout.setVisibility(View.VISIBLE);
        if (listView instanceof ObservableListView) {
          onScrollChanged(listView.getScrollY(), false, false);
        }
        if (refresh) {
          refreshContent(false);
        } else {
          updateListAdapter();
          updateListBackgroundHeight();
        }
      }
      mapActivity
          .findViewById(R.id.toolbar_back)
          .setVisibility(isBackButtonVisible() ? View.VISIBLE : View.GONE);
      mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE);

      updateToolbarActions();
      // fabButton.showFloatingActionButton();
      open(dashboardView.findViewById(R.id.animateContent), animation);
      updateLocation(true, true, false);
      //			addOrUpdateDashboardFragments();
    } else {
      mapActivity.getMapViewTrackingUtilities().setDashboard(null);
      hide(dashboardView.findViewById(R.id.animateContent), animation);
      mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE);
      hideActionButton();
      for (WeakReference<DashBaseFragment> df : fragList) {
        if (df.get() != null) {
          df.get().onCloseDash();
        }
      }
    }
  }