@Override
    public boolean onTouch(View v, MotionEvent event) {

      switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
          {
            ImageView view = (ImageView) v;
            // overlay is black with transparency of 0x77 (119)
            view.getDrawable().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP);
            view.invalidate();
            break;
          }
        case MotionEvent.ACTION_UP:
          //  Log.v(LOG_TAG,"ACTION_UP"+this.position+v.getClass());
          //  int itemPosition = mRecyclerView.getChildPosition(c);
          //  mRecyclerCardCallback.onItemImageClick(this.position);
        case MotionEvent.ACTION_CANCEL:
          {
            ImageView view = (ImageView) v;
            // clear the overlay
            view.getDrawable().clearColorFilter();
            view.invalidate();
            break;
          }
      }

      return true;
    }
Exemple #2
0
 public void onImageBitmapSet() {
   int imageWidth = mResultImageView.getDrawable().getIntrinsicWidth();
   int imageHeight = mResultImageView.getDrawable().getIntrinsicHeight();
   Matrix m = mResultImageView.getImageMatrix();
   RectF drawableRect = new RectF(0, 0, imageWidth, imageHeight);
   RectF viewRect =
       new RectF(
           0,
           0,
           ((View) mResultImageView.getParent()).getWidth(),
           ((View) mResultImageView.getParent()).getHeight());
   m.setRectToRect(drawableRect, viewRect, Matrix.ScaleToFit.CENTER);
   mResultImageView.setImageMatrix(m);
   mResultImageView.invalidate();
   mMatrix = m;
   Log.d(TAG, "init mMatrix: " + mMatrix.toString());
   Log.d(
       TAG,
       "init, imagehview: " + mResultImageView.getDrawable().toString() + " w: " + imageWidth);
   Log.d(TAG, "init, imageheight: " + imageHeight + " w: " + imageWidth);
   Log.d(
       TAG,
       "init, viewheight: "
           + ((View) mResultImageView.getParent()).getHeight()
           + " w: "
           + ((View) mResultImageView.getParent()).getWidth());
   if (progressDialog != null) {
     progressDialog.dismiss();
   }
 }
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != 0) {
      if (requestCode == ACTIVITY_SELECT_IMAGE) {

        Uri selectedImage = data.getData();
        String[] filePathColumn = {MediaStore.Images.Media.DATA};

        Cursor cursor =
            getSherlockActivity()
                .getContentResolver()
                .query(selectedImage, filePathColumn, null, null, null);
        cursor.moveToFirst();

        int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
        String filePath = cursor.getString(columnIndex);
        cursor.close();

        Bitmap bm = BitmapFactory.decodeFile(filePath);

        new OtsuAsyncTask(this).execute(bm);
        // new SeqSegmAsyncTask(segmentationHandler).execute(bm.copy(bm.getConfig(), true));

        ImageView iv = ((ImageView) getView().findViewById(R.id.image));
        iv.setImageBitmap(bm);
        iv.invalidate();
      }
    }
    super.onActivityResult(requestCode, resultCode, data);
  }
Exemple #4
0
 @Override
 public void onDraw(Canvas canvas, RectF latlonBounds, RectF tilesRect, DrawSettings nightMode) {
   boolean bold = routeLayer.getHelper().isFollowingMode();
   int color = !nightMode.isNightMode() ? Color.BLACK : Color.BLACK;
   if (paintText.getColor() != color) {
     paintText.setColor(color);
     paintSubText.setColor(color);
     paintSmallText.setColor(color);
     paintSmallSubText.setColor(color);
   }
   if (paintText.isFakeBoldText() != bold) {
     paintText.setFakeBoldText(bold);
     paintSubText.setFakeBoldText(bold);
     paintSmallText.setFakeBoldText(bold);
     paintSmallSubText.setFakeBoldText(bold);
   }
   // update data on draw
   rightStack.updateInfo();
   leftStack.updateInfo();
   if (view.getRotate() != cachedRotate) {
     cachedRotate = view.getRotate();
     compassView.invalidate();
   }
   lanesControl.updateInfo();
   //		topText.setTextColor(color);
   //		String text = "Пр.Независимости";
   //		float ts = topText.getPaint().measureText(text);
   //		int wth = topText.getRight() /*- compassView.getRight()*/;
   //		while(ts > wth && topText.getTextSize() - 1 > 5) {
   //			topText.setTextSize(topText.getTextSize() - 1);
   //			ts = topText.getPaint().measureText(text);
   //		}
   //		topText.setText(text);
 }
Exemple #5
0
 public void invalidate() {
   mWeakBitmap = null;
   if (mMaskBitmap != null) {
     mMaskBitmap.recycle();
   }
   super.invalidate();
 }
Exemple #6
0
  @Override
  public void onActivityResult(int requestCode, int resultCode, final Intent data) {

    if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
      if (resultCode == getActivity().RESULT_OK) {
        image_preview = new ImageView(getActivity());
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        Toast.makeText(getActivity(), "Successful take the photo!", Toast.LENGTH_SHORT).show();
        image_preview.setImageBitmap(convertJPG(fileURI));
        image_preview.invalidate();
        builder.setView(image_preview);
        builder.setTitle("Preview");
        builder
            .setNegativeButton(
                "OK",
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialogInterface, int i) {}
                })
            .show();

      } else if (resultCode == getActivity().RESULT_CANCELED) {
      } else {
        Toast.makeText(getActivity(), "Unsuccessful take the photo!", Toast.LENGTH_SHORT).show();
      }
    }
  }
Exemple #7
0
  public void updateMainContent(Card cc) {
    TextView cash = (TextView) findViewById(R.id.menu_text);
    if (game.getAddedCash() > 0)
      cash.setText("Cash: $" + game.getCash() + "  (+$" + game.getAddedCash() + ")");
    else if (game.getAddedCash() < 0)
      cash.setText("Cash: $" + game.getCash() + "  ($" + game.getAddedCash() + ")");
    else cash.setText("Cash: $" + game.getCash());

    LinearLayout ll = (LinearLayout) findViewById(R.id.linearLayout3);
    new Color();
    ll.setBackgroundColor(
        Color.rgb(
            game.getCurrentCard().getColor()[0],
            game.getCurrentCard().getColor()[1],
            game.getCurrentCard().getColor()[2]));

    TextView h1 = (TextView) findViewById(R.id.textView1);
    h1.setText(cc.getStreet().toUpperCase());

    TextView h2 = (TextView) findViewById(R.id.textView2);
    h2.setText(cc.getArea());

    TextView own = (TextView) findViewById(R.id.textView3);
    own.setText("" + cc.getOwner());

    TextView val = (TextView) findViewById(R.id.textView4);
    val.setText("$" + Integer.toString(cc.getValue()));

    TextView tax = (TextView) findViewById(R.id.textView5);
    tax.setText("$" + Integer.toString(cc.getTax()));

    TextView hou = (TextView) findViewById(R.id.textView6);
    String pri = new String();
    if (cc.getHousePrise() <= 0) pri = " --";
    else pri = Integer.toString(cc.getHousePrise());
    hou.setText("$" + pri);

    // The buttons
    buyStreet.setEnabled(
        game.getCash() >= game.getCurrentCard().getValue()
            && game.getCurrentCard().getStreet() != GameMechanics.DEFAULT_STREET
            && game.getPlayer().getUserId() != game.getCurrentCard().getOwnerId());

    buyHouse.setEnabled(
        game.getCash() >= game.getCurrentCard().getHousePrise()
            && game.getCurrentCard().getHouses() < 5
            && game.getCurrentCard().getStreet() != GameMechanics.DEFAULT_STREET
            && game.getPlayer().getUserId() == game.getCurrentCard().getOwnerId());

    // Do the houses
    for (int i = 1; i <= 5; i++) {
      ImageView houses = new ImageView(this);
      houses = (ImageView) findViewById(ivid[i]);
      if (cc.getHouses() >= i) houses.setImageResource(hoid[i]);
      else houses.setImageResource(hoid[0]);
      houses.invalidate();
    }

    return;
  }
 public void resistanceBand5(String resistanceVal, int colorVal) {
   resistance[4] = resistanceVal;
   paint.setColor(colorVal);
   canvas.drawRect(120, 91, 140, 9, paint);
   iView.invalidate();
   calcResistance();
 }
  @Override
  public void onResult(Bitmap bitmap) {

    int[][] se =
        new int[][] {
          {1, 1},
          {1, 1}
        };

    Bitmap bmFinal = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());

    BitmapUtils.erosion(bitmap, se);
    int m = BitmapUtils.dilate(bitmap, bmFinal, se);
    // int m = BitmapUtils.countSE(bitmap, se);

    int c = BitmapUtils.getPixelsCount(bmFinal);
    int pc = BitmapUtils.getContactCount(bmFinal);

    ImageView iv = ((ImageView) getView().findViewById(R.id.image2));
    iv.setImageBitmap(bmFinal);
    iv.invalidate();

    int r = c + m - pc;

    ((TextView) getView().findViewById(R.id.textView1))
        .setText("Segments: " + r + " = " + c + " + " + m + " - " + pc);
  }
Exemple #10
0
 public void setImageDrawable(Drawable imageDrawable, boolean gone) {
   if (imageDrawable != null) {
     imageView.setImageDrawable(imageDrawable);
     imageView.setVisibility(View.VISIBLE);
   } else {
     imageView.setVisibility(gone ? View.GONE : View.INVISIBLE);
   }
   imageView.invalidate();
 }
 @SuppressLint("ClickableViewAccessibility")
 @Override
 public boolean onTouch(View v, MotionEvent event) {
   switch (event.getAction()) {
     case MotionEvent.ACTION_DOWN:
       {
         ((ImageView) v).getDrawable().setColorFilter(0xe0f47521, Mode.SRC_ATOP);
         ((ImageView) v).invalidate();
         break;
       }
     case MotionEvent.ACTION_UP:
       {
         ((ImageView) v).getDrawable().clearColorFilter();
         ((ImageView) v).invalidate();
         break;
       }
   }
   return false;
 }
        @Override
        public boolean onTouch(View v, MotionEvent event) {

          switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
              {
                ImageView view = (ImageView) v.findViewById(R.id.image);
                // overlay is black with transparency of 0x77 (119)
                view.getDrawable().setColorFilter(0x99000000, PorterDuff.Mode.SRC_ATOP);
                Log.d("check", " " + view.getId());
                view.invalidate();
                TextView text = (TextView) v.findViewById(R.id.text);
                text.setBackgroundColor(Color.LTGRAY);
                text.invalidate();
                break;
              }
            case MotionEvent.ACTION_UP:
              {
                ImageView view = (ImageView) v.findViewById(R.id.image);
                // clear the overlay
                view.getDrawable().clearColorFilter();
                view.invalidate();
                TextView text = (TextView) v.findViewById(R.id.text);
                text.setBackgroundColor(Color.TRANSPARENT);
                text.invalidate();

                v.performClick();
                break;
              }
            case MotionEvent.ACTION_CANCEL:
              {
                ImageView view = (ImageView) v.findViewById(R.id.image);
                // clear the overlay
                view.getDrawable().clearColorFilter();
                view.invalidate();
                TextView text = (TextView) v.findViewById(R.id.text);
                text.setBackgroundColor(Color.TRANSPARENT);
                text.invalidate();
                break;
              }
          }
          return true;
        }
Exemple #13
0
    @Override
    public boolean onTouch(View v, MotionEvent event) {
      ImageView view = (ImageView) v;

      // Dump touch event to log
      dumpEvent(event);

      // Handle touch events here...
      switch (event.getAction() & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN:
          mSavedMatrix.set(mMatrix);
          start.set(event.getX(), event.getY());
          Log.d(TAG, "mode=DRAG");
          mode = DRAG;
          break;
        case MotionEvent.ACTION_POINTER_DOWN:
          oldDist = spacing(event);
          Log.d(TAG, "oldDist=" + oldDist);
          if (oldDist > 10f) {
            mSavedMatrix.set(mMatrix);
            midPoint(mid, event);
            mode = ZOOM;
            Log.d(TAG, "mode=ZOOM");
          }
          break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_POINTER_UP:
          mode = NONE;
          Log.d(TAG, "mode=NONE");
          break;
        case MotionEvent.ACTION_MOVE:
          if (mode == DRAG) {
            // ...
            mMatrix.set(mSavedMatrix);
            mMatrix.postTranslate(event.getX() - start.x, event.getY() - start.y);
          } else if (mode == ZOOM) {
            float newDist = spacing(event);
            Log.d(TAG, "newDist=" + newDist);
            if (newDist > 10f) {
              mMatrix.set(mSavedMatrix);
              float scale = newDist / oldDist;
              mMatrix.postScale(scale, scale, mid.x, mid.y);
            }
          }
          break;
      }

      Log.d(TAG, "mMatrix: " + mMatrix.toString());
      view.setImageMatrix(mMatrix);
      view.invalidate();
      return true; // indicate event was handled
    }
Exemple #14
0
 public void setTopImageDrawable(Drawable imageDrawable, String topText) {
   if (imageDrawable != null) {
     topImageView.setImageDrawable(imageDrawable);
     topImageView.setVisibility(View.VISIBLE);
     topTextView.setVisibility(View.VISIBLE);
     topTextView.setText(topText == null ? "" : topText);
   } else {
     topImageView.setVisibility(View.GONE);
     topTextView.setVisibility(View.GONE);
   }
   topTextView.invalidate();
   topImageView.invalidate();
 }
 public void setImageBitmap(Bitmap b) {
   if (b != null && b.isRecycled()) return;
   if (imageView != null) {
     if (bitmap != b) {
       imageView.setImageBitmap(b);
       imageView.invalidate();
       /*
       if (bitmap != null && !bitmap.isRecycled())
       	bitmap.recycle();
       	*/
       bitmap = b;
     }
   }
 }
  /** Turns analyzing on and off -- makes new canvas (and visualizer) */
  public void toggleAnalyse(View v) {
    if (started) {
      if (MainActivity.autoSave) {
        T.cancel();
      }
      timeCount = 0;
      started = false;
      analyseButtonText.setText("Start Analyzing");
      recordTask.cancel(true);
      bitmap = Bitmap.createBitmap((int) imageWidth, (int) imageHeight, Bitmap.Config.ARGB_8888);
      canvas = new Canvas(bitmap);
      imageView.setImageBitmap(bitmap);
      canvas.drawColor(0xFF444444);
      imageView.invalidate();
      note[0] = ""; // resets note
      if (!MainActivity.analyzeMode) {
        visualizer.release();
      }
    } else {
      timeCount = 0;

      if (MainActivity.autoSave) {
        T = new Timer();
        T.scheduleAtFixedRate(
            new TimerTask() {
              @Override
              public void run() {
                getActivity()
                    .runOnUiThread(
                        new Runnable() {
                          @Override
                          public void run() {
                            timeCount++;
                          }
                        });
              }
            },
            10,
            10);
        setFileName();
        writeToFile("", false);
      }

      drawVisualization(imageView, "start");
      if (!MainActivity.analyzeMode) {
        visualizer = new Visualizer(0);
      }
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // Hide Navigation/Status/Action bars
    int UI_OPTIONS =
        View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
    getWindow().getDecorView().setSystemUiVisibility(UI_OPTIONS);
    super.onCreate(savedInstanceState);

    ActionBar ab = getSupportActionBar();
    if (ab != null) ab.hide();

    setContentView(R.layout.activity_main);

    iv = (ImageView) findViewById(R.id.iv);
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getRealSize(size);
    float dw = size.x;
    float dh = size.y;

    maxY = (float) (dh * 0.65);

    bitmap = Bitmap.createBitmap((int) dw, (int) dh, Bitmap.Config.ARGB_8888);
    canvas = new Canvas(bitmap);
    paint = new Paint();
    paint.setColor(Color.BLUE);
    paint.setStrokeWidth((float) 3);
    iv.setImageBitmap(bitmap);

    // horizontal
    canvas.drawLine((float) 0, maxY, dw, maxY, paint);
    iv.invalidate();
    // vertical
    canvas.drawLine((float) (dw * 0.125), 0, (float) (dw * 0.125), dh, paint);
    iv.invalidate();
    canvas.drawLine((float) (dw * 0.375), 0, (float) (dw * 0.375), dh, paint);
    iv.invalidate();
    canvas.drawLine((float) (dw * 0.625), 0, (float) (dw * 0.625), dh, paint);
    iv.invalidate();
    canvas.drawLine((float) (dw * 0.875), 0, (float) (dw * 0.875), dh, paint);
    iv.invalidate();

    P1 = new PointF((float) (dw * 0.125) + 5, maxY - 5);
    P2 = new PointF((float) (dw * 0.375) + 5, maxY - 5);
    P3 = new PointF((float) (dw * 0.625) + 5, maxY - 5);
    P4 = new PointF((float) (dw * 0.875) + 5, maxY - 5);
    paint.setColor(Color.RED);
    canvas.drawLine(P1.x, P1.y, P4.x, P4.y, paint);
    iv.invalidate();
    startNotification();
  }
  private void init(Context context) {
    mContext = context;

    mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);

    View v = LayoutInflater.from(context).inflate(R.layout.view_main, null);

    compassView = (ImageView) v.findViewById(R.id.compass_view);
    canvasView = (ImageView) v.findViewById(R.id.canvas_view);

    // Resize canvasView
    ResizeImageView.resizeImageView(
        canvasView, ResolutionUtil.displayWidth(context), ResolutionUtil.displayWidth(context));

    Bitmap bitmap =
        Bitmap.createBitmap(
            ResolutionUtil.displayWidth(context),
            ResolutionUtil.displayHeight(context),
            Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);

    // Draw transparent screen
    Paint transPainter = new Paint();
    transPainter.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
    canvas.drawRect(0, 0, bitmap.getWidth(), bitmap.getHeight(), transPainter);

    Paint drawPaint = new Paint();
    drawPaint.reset();
    drawPaint.setFlags(Paint.DITHER_FLAG);
    drawPaint.setAntiAlias(true);
    drawPaint.setSubpixelText(true);
    drawPaint.setColor(Color.GREEN);
    drawPaint.setStyle(Paint.Style.STROKE);
    drawPaint.setStrokeJoin(Paint.Join.ROUND);
    drawPaint.setStrokeCap(Paint.Cap.ROUND);
    drawPaint.setStrokeWidth(10);
    canvas.drawLines(
        new float[] {bitmap.getWidth() / 2, bitmap.getHeight() / 2, bitmap.getWidth() / 2, 0},
        drawPaint);

    canvasView.setImageBitmap(bitmap);

    // invoke canvasView
    canvasView.invalidate();

    addView(v);
  }
  @Override
  public boolean onTouch(View v, MotionEvent event) {
    ImageView view = (ImageView) v;
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
      case MotionEvent.ACTION_DOWN:
        savedMatrix.set(matrix);
        start.set(event.getX(), event.getY());
        mode = DRAG;
        break;
      case MotionEvent.ACTION_POINTER_DOWN:
        oldDist = spacing(event);
        if (oldDist > 10f) {
          savedMatrix.set(matrix);
          midPoint(mid, event);
          mode = ZOOM;
        }
        break;
      case MotionEvent.ACTION_UP:
      case MotionEvent.ACTION_POINTER_UP:
        mode = NONE;
        break;
      case MotionEvent.ACTION_MOVE:
        if (mode == DRAG) {
          // ...
          matrix.set(savedMatrix);
          matrix.postTranslate(event.getX() - start.x, event.getY() - start.y);
          start_x = event.getX() - start.x;
          start_y = event.getY() - start.y;
        } else if (mode == ZOOM) {
          float newDist = spacing(event);
          if (newDist > 10f) {
            matrix.set(savedMatrix);
            float scale = newDist / oldDist;
            mAspect = scale;
            matrix.postScale(scale, scale, mid.x, mid.y);
          }
        }
        break;
    }

    view.setImageMatrix(matrix);
    view.invalidate();
    return true;
  }
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null
        && (Intent.ACTION_DELETE.equals(intent.getAction())
            || Intent.ACTION_INSERT.equals(intent.getAction()) && intentProcessed)) {
      Log.d(LOG, "Service got shutdown intent");
      Ntf.show(this, false);
      stopSelf();
      intentProcessed = true;
      return START_NOT_STICKY;
    }

    Ntf.show(this, true);
    intentProcessed = true;
    if (intent != null) {
      Cfg.Pattern = intent.getIntExtra(TaskerActivity.BUNDLE_PATTERN, Cfg.Pattern);
      updatePattern();
      view.invalidate();
    }
    return START_STICKY;
  }
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
      case CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE:
        try {
          reset();
          System.gc();
          Bitmap bitmap =
              MediaStore.Images.Media.getBitmap(getContentResolver(), Uri.fromFile(photo));
          bitmap = ExifUtils.rotateBitmap(photo.getAbsolutePath(), bitmap);
          ByteArrayOutputStream out = new ByteArrayOutputStream();
          bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
          Bitmap decoded = BitmapFactory.decodeStream(new ByteArrayInputStream(out.toByteArray()));
          decoded = PhotoUtils.getResizedBitmap(decoded, decoded.getWidth());
          resultImage = decoded;
          imageView.setImageBitmap(decoded);
          imageView.invalidate();

        } catch (IOException e) {
          e.printStackTrace();
        }
        break;
    }
  }
 @Override
 public void invalidate() {
   super.invalidate();
   image = drawableToBitmap(getDrawable());
   if (shader != null || canvasSize > 0) refreshBitmapShader();
 }
 /** Invalidates the pressed/focused states. */
 public void invalidatePressedFocusedStates(ImageView v) {
   mStatesUpdated = false;
   if (v != null) {
     v.invalidate();
   }
 }
 @Override
 public void updateCaptcha(Drawable captcha) {
   imageRegCaptcha.setImageDrawable(captcha);
   imageRegCaptcha.invalidate();
 }
 /** Updates ImageView with current transformation. */
 private void updateImageView() {
   mImageView.setImageMatrix(mPinchToZoomTransformation.getMatrix());
   mImageView.invalidate();
 }
 public void invalidate(int l, int t, int r, int b) {
   super.invalidate(l, t, r, b);
   image = drawableToBitmap(getDrawable());
   if (shader != null || canvasSize > 0) refreshBitmapShader();
 }
 // override this for more sophisticated choice of invalidation
 @Override
 public void run() {
   container.invalidate();
 }
 protected void onPostExecute(Bitmap result) {
   bmImage.setImageBitmap(result);
   bmImage.invalidate();
 }
 public boolean updateInfo(DrawSettings drawSettings) {
   boolean visible = false;
   int locimminent = -1;
   int[] loclanes = null;
   int dist = 0;
   // TurnType primary = null;
   if ((rh == null || !rh.isFollowingMode())
       && trackingUtilities.isMapLinkedToLocation()
       && settings.SHOW_LANES.get()) {
     RouteDataObject ro = locationProvider.getLastKnownRouteSegment();
     Location lp = locationProvider.getLastKnownLocation();
     if (ro != null) {
       float degree = lp == null || !lp.hasBearing() ? 0 : lp.getBearing();
       loclanes = RouteResultPreparation.parseTurnLanes(ro, degree / 180 * Math.PI);
       if (loclanes == null) {
         loclanes = RouteResultPreparation.parseLanes(ro, degree / 180 * Math.PI);
       }
     }
   } else if (rh != null && rh.isRouteCalculated()) {
     if (rh.isFollowingMode() && settings.SHOW_LANES.get()) {
       NextDirectionInfo r = rh.getNextRouteDirectionInfo(new NextDirectionInfo(), false);
       if (r != null && r.directionInfo != null && r.directionInfo.getTurnType() != null) {
         loclanes = r.directionInfo.getTurnType().getLanes();
         // primary = r.directionInfo.getTurnType();
         locimminent = r.imminent;
         // Do not show too far
         if ((r.distanceTo > 800 && r.directionInfo.getTurnType().isSkipToSpeak())
             || r.distanceTo > 1200) {
           loclanes = null;
         }
         dist = r.distanceTo;
       }
     } else {
       int di = MapRouteInfoControl.getDirectionInfo();
       if (di >= 0
           && MapRouteInfoControl.isControlVisible()
           && di < rh.getRouteDirections().size()) {
         RouteDirectionInfo next = rh.getRouteDirections().get(di);
         if (next != null) {
           loclanes = next.getTurnType().getLanes();
           // primary = next.getTurnType();
         }
       }
     }
   }
   visible = loclanes != null && loclanes.length > 0;
   if (visible) {
     if (!Arrays.equals(lanesDrawable.lanes, loclanes)
         || (locimminent == 0) != lanesDrawable.imminent) {
       lanesDrawable.imminent = locimminent == 0;
       lanesDrawable.lanes = loclanes;
       lanesDrawable.updateBounds();
       lanesView.setImageDrawable(null);
       lanesView.setImageDrawable(lanesDrawable);
       lanesView.requestLayout();
       lanesView.invalidate();
     }
     if (distChanged(dist, this.dist)) {
       this.dist = dist;
       if (dist == 0) {
         lanesShadowText.setText("");
         lanesText.setText("");
       } else {
         lanesShadowText.setText(OsmAndFormatter.getFormattedDistance(dist, app));
         lanesText.setText(OsmAndFormatter.getFormattedDistance(dist, app));
       }
       lanesShadowText.invalidate();
       lanesText.invalidate();
     }
   }
   updateVisibility(lanesShadowText, visible && shadowRadius > 0);
   updateVisibility(lanesText, visible);
   updateVisibility(lanesView, visible);
   updateVisibility(centerInfo, visible || progress.getVisibility() == View.VISIBLE);
   return true;
 }