Android : Unable to add window — token android.os.BinderProxy is not valid; is your activity running?












0















So I have an app which draws points on a custom imageview when we click the button 'Add Checkpoint'. Everytime a new point is added, two things happen -



1) A line is created joining the just added point and previous added point.
2) The line is divided into 'x' number of points, and the points are drawn over the line. (Look at the screenshot attached)



I basically pass a List to the custom imageview class from which I get the value of 'x'.



As you can see the points are divided equally on the line based on the value of 'x'



Now everytime the value of x exceeds let's say 70 or 80 (any high number), the app crashes and I get the following error -



Unable to add window -- token android.os.BinderProxy is not valid; is your activity running?



My activity is getting finished due to heavy UI operation. Any suggestions?



This is the function in my custom imageview which draws add the point to the List of points to be shown.



public void addMarker(float a, float b, Context ctx, List<SampleModel> mainList) {
DBHelperCSV helperCSV = new DBHelperCSV(ctx);
if (!mainList.isEmpty()) {
for (SampleModel m : mainList) {
System.out.println("Rushi : SSTList : " + m.sst);
}
}
int partsCount = mainList.size();
pointNumber = pointNumber + 1;
matrix.invert(inverse);
float pts = {
a + 45, b + 45
};
inverse.mapPoints(pts);
System.out.println("Rushi : Passed points :" + a + " " + b);
PointF mainPoint = new PointF(pts[0], pts[1]);
float mainSST = -999;
if (!mainList.isEmpty()) {
mainSST = Float.parseFloat(mainList.get(0).getSst());
}
PointModel mainPointModel = new PointModel(mainPoint, mainSST);
markers.add(mainPointModel);
PointF mainConvertedPoint = getConvertedPoint(mainPoint.x, mainPoint.y);


//
//pts[0] and pts[1] is the actual image point which is in markers list
System.out.println("Rushi : Mapped points :" + pts[0] + " " + pts[1]);
PointF convertedPoint = getConvertedPoint(pts[0], pts[1]);
System.out.println("Rushi : Converted points :" + convertedPoint.x + " " + convertedPoint.y);
convertedPoints.add(new PointModel(convertedPoint, mainSST));
invalidate();
Toast.makeText(ctx, "(" + convertedPoint.x + "," + convertedPoint.y + ")", Toast.LENGTH_SHORT).show();
if (markers.size() > 1) {
//Add partsCount-1 points between the markers.size() - 1 and markers.size() - 2
PointF justAddedPoint = markers.get(markers.size() - 1).point;
PointF previousPoint = markers.get(markers.size() - 2).point;
System.out.println("Divide : Previous point - " + "(" + previousPoint.x + "," + previousPoint.y + ")");
System.out.println("Divide : Just added point - " + "(" + justAddedPoint.x + "," + justAddedPoint.y + ")");
//Find d and d/n

if (partsCount > 2 && !((Activity)ctx).isFinishing()) {
double dist = Math.sqrt(((justAddedPoint.x - previousPoint.x) * (justAddedPoint.x - previousPoint.x)) + ((justAddedPoint.y - previousPoint.y) * (justAddedPoint.y - previousPoint.y)));
double tParts = partsCount - 1;
double dN = dist / tParts;

// new BackgroundWorker(ctx, dist, tParts - 1, dN, previousPoint, justAddedPoint, mainList).execute();
for (int i = 0; i < tParts - 1; i++) {
double m = (i + 1) * dN;
double n = dist - ((i + 1) * dN);
PointF point = new PointF();
double x = ((m * justAddedPoint.x + n * previousPoint.x) / dist);
double y = ((m * justAddedPoint.y + n * previousPoint.y) / dist);
point.set((float) x, (float) y);
//Map and add
float pts2 = {(float) x, (float) y};
inverse.mapPoints(pts2);
//Point and value
PointModel pointModel = new PointModel();
float sst = -999;
if (!mainList.isEmpty()) {
sst = Float.parseFloat(mainList.get(i + 1).getSst());
}
pointModel.setPoint(point);
pointModel.setSst(sst);
semiMarkers.add(pointModel);
convertedPoints.add(new PointModel(getConvertedPoint(point.x, point.y), sst));

System.out.println("Divide : Point " + (i + 1) + " - (" + point.x + "," + point.y + ")");
try {
Thread.sleep(4);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}

}

}


This is my onDraw() function -



@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
origWidth = this.getDrawable().getIntrinsicWidth();
origLength = this.getDrawable().getIntrinsicHeight();
if (markers.size() > 1) {
for (int i = 0; i < markers.size() - 1; i++) {
paintLine.setColor(Color.WHITE);
float pts = {markers.get(i).point.x, markers.get(i).point.y, markers.get(i + 1).point.x, markers.get(i + 1).point.y};
matrix.mapPoints(pts);
canvas.drawLine(pts[0], pts[1], pts[2], pts[3], paintLine);
}
}

for (int i = 0; i < markers.size(); i++) {
float pts = {markers.get(i).point.x, markers.get(i).point.y};
float sst = markers.get(i).sst;
matrix.mapPoints(pts);

if (sst <= 0 && sst >= -80) {
paintMain.setColor(Color.RED);
} else if (sst <= -80 && sst >= -90) {
paintMain.setColor(Color.BLUE);
} else if (sst <= -90 && sst >= -100) {
paintMain.setColor(Color.YELLOW);
} else if (sst <= -100 && sst >= -110) {
paintMain.setColor(getResources().getColor(R.color.lightgreen));
} else if (sst <= -110 && sst >= -140) {
paintMain.setColor(Color.GREEN);
} else if (sst == -999) {
paintMain.setColor(Color.BLACK);
}
canvas.drawCircle(pts[0], pts[1], 22, paintMain);
}

for (int i = 0; i < semiMarkers.size(); i++) {
float pts = {semiMarkers.get(i).point.x, semiMarkers.get(i).point.y};
float sst = semiMarkers.get(i).sst;
matrix.mapPoints(pts);
if (sst <= 0 && sst >= -80) {
paintForSemi.setColor(Color.RED);
} else if (sst <= -80 && sst >= -90) {
paintForSemi.setColor(Color.BLUE);
} else if (sst <= -90 && sst >= -100) {
paintForSemi.setColor(Color.YELLOW);
} else if (sst <= -100 && sst >= -110) {
paintForSemi.setColor(getResources().getColor(R.color.lightgreen));
} else if (sst <= -110 && sst >= -140) {
paintForSemi.setColor(Color.GREEN);
} else if (sst == -999) {
paintForSemi.setColor(Color.BLACK);
}
canvas.drawCircle(pts[0], pts[1], 11, paintForSemi);
}
}









share|improve this question



























    0















    So I have an app which draws points on a custom imageview when we click the button 'Add Checkpoint'. Everytime a new point is added, two things happen -



    1) A line is created joining the just added point and previous added point.
    2) The line is divided into 'x' number of points, and the points are drawn over the line. (Look at the screenshot attached)



    I basically pass a List to the custom imageview class from which I get the value of 'x'.



    As you can see the points are divided equally on the line based on the value of 'x'



    Now everytime the value of x exceeds let's say 70 or 80 (any high number), the app crashes and I get the following error -



    Unable to add window -- token android.os.BinderProxy is not valid; is your activity running?



    My activity is getting finished due to heavy UI operation. Any suggestions?



    This is the function in my custom imageview which draws add the point to the List of points to be shown.



    public void addMarker(float a, float b, Context ctx, List<SampleModel> mainList) {
    DBHelperCSV helperCSV = new DBHelperCSV(ctx);
    if (!mainList.isEmpty()) {
    for (SampleModel m : mainList) {
    System.out.println("Rushi : SSTList : " + m.sst);
    }
    }
    int partsCount = mainList.size();
    pointNumber = pointNumber + 1;
    matrix.invert(inverse);
    float pts = {
    a + 45, b + 45
    };
    inverse.mapPoints(pts);
    System.out.println("Rushi : Passed points :" + a + " " + b);
    PointF mainPoint = new PointF(pts[0], pts[1]);
    float mainSST = -999;
    if (!mainList.isEmpty()) {
    mainSST = Float.parseFloat(mainList.get(0).getSst());
    }
    PointModel mainPointModel = new PointModel(mainPoint, mainSST);
    markers.add(mainPointModel);
    PointF mainConvertedPoint = getConvertedPoint(mainPoint.x, mainPoint.y);


    //
    //pts[0] and pts[1] is the actual image point which is in markers list
    System.out.println("Rushi : Mapped points :" + pts[0] + " " + pts[1]);
    PointF convertedPoint = getConvertedPoint(pts[0], pts[1]);
    System.out.println("Rushi : Converted points :" + convertedPoint.x + " " + convertedPoint.y);
    convertedPoints.add(new PointModel(convertedPoint, mainSST));
    invalidate();
    Toast.makeText(ctx, "(" + convertedPoint.x + "," + convertedPoint.y + ")", Toast.LENGTH_SHORT).show();
    if (markers.size() > 1) {
    //Add partsCount-1 points between the markers.size() - 1 and markers.size() - 2
    PointF justAddedPoint = markers.get(markers.size() - 1).point;
    PointF previousPoint = markers.get(markers.size() - 2).point;
    System.out.println("Divide : Previous point - " + "(" + previousPoint.x + "," + previousPoint.y + ")");
    System.out.println("Divide : Just added point - " + "(" + justAddedPoint.x + "," + justAddedPoint.y + ")");
    //Find d and d/n

    if (partsCount > 2 && !((Activity)ctx).isFinishing()) {
    double dist = Math.sqrt(((justAddedPoint.x - previousPoint.x) * (justAddedPoint.x - previousPoint.x)) + ((justAddedPoint.y - previousPoint.y) * (justAddedPoint.y - previousPoint.y)));
    double tParts = partsCount - 1;
    double dN = dist / tParts;

    // new BackgroundWorker(ctx, dist, tParts - 1, dN, previousPoint, justAddedPoint, mainList).execute();
    for (int i = 0; i < tParts - 1; i++) {
    double m = (i + 1) * dN;
    double n = dist - ((i + 1) * dN);
    PointF point = new PointF();
    double x = ((m * justAddedPoint.x + n * previousPoint.x) / dist);
    double y = ((m * justAddedPoint.y + n * previousPoint.y) / dist);
    point.set((float) x, (float) y);
    //Map and add
    float pts2 = {(float) x, (float) y};
    inverse.mapPoints(pts2);
    //Point and value
    PointModel pointModel = new PointModel();
    float sst = -999;
    if (!mainList.isEmpty()) {
    sst = Float.parseFloat(mainList.get(i + 1).getSst());
    }
    pointModel.setPoint(point);
    pointModel.setSst(sst);
    semiMarkers.add(pointModel);
    convertedPoints.add(new PointModel(getConvertedPoint(point.x, point.y), sst));

    System.out.println("Divide : Point " + (i + 1) + " - (" + point.x + "," + point.y + ")");
    try {
    Thread.sleep(4);
    } catch (InterruptedException e) {
    e.printStackTrace();
    }
    }
    }

    }

    }


    This is my onDraw() function -



    @Override
    protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    origWidth = this.getDrawable().getIntrinsicWidth();
    origLength = this.getDrawable().getIntrinsicHeight();
    if (markers.size() > 1) {
    for (int i = 0; i < markers.size() - 1; i++) {
    paintLine.setColor(Color.WHITE);
    float pts = {markers.get(i).point.x, markers.get(i).point.y, markers.get(i + 1).point.x, markers.get(i + 1).point.y};
    matrix.mapPoints(pts);
    canvas.drawLine(pts[0], pts[1], pts[2], pts[3], paintLine);
    }
    }

    for (int i = 0; i < markers.size(); i++) {
    float pts = {markers.get(i).point.x, markers.get(i).point.y};
    float sst = markers.get(i).sst;
    matrix.mapPoints(pts);

    if (sst <= 0 && sst >= -80) {
    paintMain.setColor(Color.RED);
    } else if (sst <= -80 && sst >= -90) {
    paintMain.setColor(Color.BLUE);
    } else if (sst <= -90 && sst >= -100) {
    paintMain.setColor(Color.YELLOW);
    } else if (sst <= -100 && sst >= -110) {
    paintMain.setColor(getResources().getColor(R.color.lightgreen));
    } else if (sst <= -110 && sst >= -140) {
    paintMain.setColor(Color.GREEN);
    } else if (sst == -999) {
    paintMain.setColor(Color.BLACK);
    }
    canvas.drawCircle(pts[0], pts[1], 22, paintMain);
    }

    for (int i = 0; i < semiMarkers.size(); i++) {
    float pts = {semiMarkers.get(i).point.x, semiMarkers.get(i).point.y};
    float sst = semiMarkers.get(i).sst;
    matrix.mapPoints(pts);
    if (sst <= 0 && sst >= -80) {
    paintForSemi.setColor(Color.RED);
    } else if (sst <= -80 && sst >= -90) {
    paintForSemi.setColor(Color.BLUE);
    } else if (sst <= -90 && sst >= -100) {
    paintForSemi.setColor(Color.YELLOW);
    } else if (sst <= -100 && sst >= -110) {
    paintForSemi.setColor(getResources().getColor(R.color.lightgreen));
    } else if (sst <= -110 && sst >= -140) {
    paintForSemi.setColor(Color.GREEN);
    } else if (sst == -999) {
    paintForSemi.setColor(Color.BLACK);
    }
    canvas.drawCircle(pts[0], pts[1], 11, paintForSemi);
    }
    }









    share|improve this question

























      0












      0








      0








      So I have an app which draws points on a custom imageview when we click the button 'Add Checkpoint'. Everytime a new point is added, two things happen -



      1) A line is created joining the just added point and previous added point.
      2) The line is divided into 'x' number of points, and the points are drawn over the line. (Look at the screenshot attached)



      I basically pass a List to the custom imageview class from which I get the value of 'x'.



      As you can see the points are divided equally on the line based on the value of 'x'



      Now everytime the value of x exceeds let's say 70 or 80 (any high number), the app crashes and I get the following error -



      Unable to add window -- token android.os.BinderProxy is not valid; is your activity running?



      My activity is getting finished due to heavy UI operation. Any suggestions?



      This is the function in my custom imageview which draws add the point to the List of points to be shown.



      public void addMarker(float a, float b, Context ctx, List<SampleModel> mainList) {
      DBHelperCSV helperCSV = new DBHelperCSV(ctx);
      if (!mainList.isEmpty()) {
      for (SampleModel m : mainList) {
      System.out.println("Rushi : SSTList : " + m.sst);
      }
      }
      int partsCount = mainList.size();
      pointNumber = pointNumber + 1;
      matrix.invert(inverse);
      float pts = {
      a + 45, b + 45
      };
      inverse.mapPoints(pts);
      System.out.println("Rushi : Passed points :" + a + " " + b);
      PointF mainPoint = new PointF(pts[0], pts[1]);
      float mainSST = -999;
      if (!mainList.isEmpty()) {
      mainSST = Float.parseFloat(mainList.get(0).getSst());
      }
      PointModel mainPointModel = new PointModel(mainPoint, mainSST);
      markers.add(mainPointModel);
      PointF mainConvertedPoint = getConvertedPoint(mainPoint.x, mainPoint.y);


      //
      //pts[0] and pts[1] is the actual image point which is in markers list
      System.out.println("Rushi : Mapped points :" + pts[0] + " " + pts[1]);
      PointF convertedPoint = getConvertedPoint(pts[0], pts[1]);
      System.out.println("Rushi : Converted points :" + convertedPoint.x + " " + convertedPoint.y);
      convertedPoints.add(new PointModel(convertedPoint, mainSST));
      invalidate();
      Toast.makeText(ctx, "(" + convertedPoint.x + "," + convertedPoint.y + ")", Toast.LENGTH_SHORT).show();
      if (markers.size() > 1) {
      //Add partsCount-1 points between the markers.size() - 1 and markers.size() - 2
      PointF justAddedPoint = markers.get(markers.size() - 1).point;
      PointF previousPoint = markers.get(markers.size() - 2).point;
      System.out.println("Divide : Previous point - " + "(" + previousPoint.x + "," + previousPoint.y + ")");
      System.out.println("Divide : Just added point - " + "(" + justAddedPoint.x + "," + justAddedPoint.y + ")");
      //Find d and d/n

      if (partsCount > 2 && !((Activity)ctx).isFinishing()) {
      double dist = Math.sqrt(((justAddedPoint.x - previousPoint.x) * (justAddedPoint.x - previousPoint.x)) + ((justAddedPoint.y - previousPoint.y) * (justAddedPoint.y - previousPoint.y)));
      double tParts = partsCount - 1;
      double dN = dist / tParts;

      // new BackgroundWorker(ctx, dist, tParts - 1, dN, previousPoint, justAddedPoint, mainList).execute();
      for (int i = 0; i < tParts - 1; i++) {
      double m = (i + 1) * dN;
      double n = dist - ((i + 1) * dN);
      PointF point = new PointF();
      double x = ((m * justAddedPoint.x + n * previousPoint.x) / dist);
      double y = ((m * justAddedPoint.y + n * previousPoint.y) / dist);
      point.set((float) x, (float) y);
      //Map and add
      float pts2 = {(float) x, (float) y};
      inverse.mapPoints(pts2);
      //Point and value
      PointModel pointModel = new PointModel();
      float sst = -999;
      if (!mainList.isEmpty()) {
      sst = Float.parseFloat(mainList.get(i + 1).getSst());
      }
      pointModel.setPoint(point);
      pointModel.setSst(sst);
      semiMarkers.add(pointModel);
      convertedPoints.add(new PointModel(getConvertedPoint(point.x, point.y), sst));

      System.out.println("Divide : Point " + (i + 1) + " - (" + point.x + "," + point.y + ")");
      try {
      Thread.sleep(4);
      } catch (InterruptedException e) {
      e.printStackTrace();
      }
      }
      }

      }

      }


      This is my onDraw() function -



      @Override
      protected void onDraw(Canvas canvas) {
      super.onDraw(canvas);
      origWidth = this.getDrawable().getIntrinsicWidth();
      origLength = this.getDrawable().getIntrinsicHeight();
      if (markers.size() > 1) {
      for (int i = 0; i < markers.size() - 1; i++) {
      paintLine.setColor(Color.WHITE);
      float pts = {markers.get(i).point.x, markers.get(i).point.y, markers.get(i + 1).point.x, markers.get(i + 1).point.y};
      matrix.mapPoints(pts);
      canvas.drawLine(pts[0], pts[1], pts[2], pts[3], paintLine);
      }
      }

      for (int i = 0; i < markers.size(); i++) {
      float pts = {markers.get(i).point.x, markers.get(i).point.y};
      float sst = markers.get(i).sst;
      matrix.mapPoints(pts);

      if (sst <= 0 && sst >= -80) {
      paintMain.setColor(Color.RED);
      } else if (sst <= -80 && sst >= -90) {
      paintMain.setColor(Color.BLUE);
      } else if (sst <= -90 && sst >= -100) {
      paintMain.setColor(Color.YELLOW);
      } else if (sst <= -100 && sst >= -110) {
      paintMain.setColor(getResources().getColor(R.color.lightgreen));
      } else if (sst <= -110 && sst >= -140) {
      paintMain.setColor(Color.GREEN);
      } else if (sst == -999) {
      paintMain.setColor(Color.BLACK);
      }
      canvas.drawCircle(pts[0], pts[1], 22, paintMain);
      }

      for (int i = 0; i < semiMarkers.size(); i++) {
      float pts = {semiMarkers.get(i).point.x, semiMarkers.get(i).point.y};
      float sst = semiMarkers.get(i).sst;
      matrix.mapPoints(pts);
      if (sst <= 0 && sst >= -80) {
      paintForSemi.setColor(Color.RED);
      } else if (sst <= -80 && sst >= -90) {
      paintForSemi.setColor(Color.BLUE);
      } else if (sst <= -90 && sst >= -100) {
      paintForSemi.setColor(Color.YELLOW);
      } else if (sst <= -100 && sst >= -110) {
      paintForSemi.setColor(getResources().getColor(R.color.lightgreen));
      } else if (sst <= -110 && sst >= -140) {
      paintForSemi.setColor(Color.GREEN);
      } else if (sst == -999) {
      paintForSemi.setColor(Color.BLACK);
      }
      canvas.drawCircle(pts[0], pts[1], 11, paintForSemi);
      }
      }









      share|improve this question














      So I have an app which draws points on a custom imageview when we click the button 'Add Checkpoint'. Everytime a new point is added, two things happen -



      1) A line is created joining the just added point and previous added point.
      2) The line is divided into 'x' number of points, and the points are drawn over the line. (Look at the screenshot attached)



      I basically pass a List to the custom imageview class from which I get the value of 'x'.



      As you can see the points are divided equally on the line based on the value of 'x'



      Now everytime the value of x exceeds let's say 70 or 80 (any high number), the app crashes and I get the following error -



      Unable to add window -- token android.os.BinderProxy is not valid; is your activity running?



      My activity is getting finished due to heavy UI operation. Any suggestions?



      This is the function in my custom imageview which draws add the point to the List of points to be shown.



      public void addMarker(float a, float b, Context ctx, List<SampleModel> mainList) {
      DBHelperCSV helperCSV = new DBHelperCSV(ctx);
      if (!mainList.isEmpty()) {
      for (SampleModel m : mainList) {
      System.out.println("Rushi : SSTList : " + m.sst);
      }
      }
      int partsCount = mainList.size();
      pointNumber = pointNumber + 1;
      matrix.invert(inverse);
      float pts = {
      a + 45, b + 45
      };
      inverse.mapPoints(pts);
      System.out.println("Rushi : Passed points :" + a + " " + b);
      PointF mainPoint = new PointF(pts[0], pts[1]);
      float mainSST = -999;
      if (!mainList.isEmpty()) {
      mainSST = Float.parseFloat(mainList.get(0).getSst());
      }
      PointModel mainPointModel = new PointModel(mainPoint, mainSST);
      markers.add(mainPointModel);
      PointF mainConvertedPoint = getConvertedPoint(mainPoint.x, mainPoint.y);


      //
      //pts[0] and pts[1] is the actual image point which is in markers list
      System.out.println("Rushi : Mapped points :" + pts[0] + " " + pts[1]);
      PointF convertedPoint = getConvertedPoint(pts[0], pts[1]);
      System.out.println("Rushi : Converted points :" + convertedPoint.x + " " + convertedPoint.y);
      convertedPoints.add(new PointModel(convertedPoint, mainSST));
      invalidate();
      Toast.makeText(ctx, "(" + convertedPoint.x + "," + convertedPoint.y + ")", Toast.LENGTH_SHORT).show();
      if (markers.size() > 1) {
      //Add partsCount-1 points between the markers.size() - 1 and markers.size() - 2
      PointF justAddedPoint = markers.get(markers.size() - 1).point;
      PointF previousPoint = markers.get(markers.size() - 2).point;
      System.out.println("Divide : Previous point - " + "(" + previousPoint.x + "," + previousPoint.y + ")");
      System.out.println("Divide : Just added point - " + "(" + justAddedPoint.x + "," + justAddedPoint.y + ")");
      //Find d and d/n

      if (partsCount > 2 && !((Activity)ctx).isFinishing()) {
      double dist = Math.sqrt(((justAddedPoint.x - previousPoint.x) * (justAddedPoint.x - previousPoint.x)) + ((justAddedPoint.y - previousPoint.y) * (justAddedPoint.y - previousPoint.y)));
      double tParts = partsCount - 1;
      double dN = dist / tParts;

      // new BackgroundWorker(ctx, dist, tParts - 1, dN, previousPoint, justAddedPoint, mainList).execute();
      for (int i = 0; i < tParts - 1; i++) {
      double m = (i + 1) * dN;
      double n = dist - ((i + 1) * dN);
      PointF point = new PointF();
      double x = ((m * justAddedPoint.x + n * previousPoint.x) / dist);
      double y = ((m * justAddedPoint.y + n * previousPoint.y) / dist);
      point.set((float) x, (float) y);
      //Map and add
      float pts2 = {(float) x, (float) y};
      inverse.mapPoints(pts2);
      //Point and value
      PointModel pointModel = new PointModel();
      float sst = -999;
      if (!mainList.isEmpty()) {
      sst = Float.parseFloat(mainList.get(i + 1).getSst());
      }
      pointModel.setPoint(point);
      pointModel.setSst(sst);
      semiMarkers.add(pointModel);
      convertedPoints.add(new PointModel(getConvertedPoint(point.x, point.y), sst));

      System.out.println("Divide : Point " + (i + 1) + " - (" + point.x + "," + point.y + ")");
      try {
      Thread.sleep(4);
      } catch (InterruptedException e) {
      e.printStackTrace();
      }
      }
      }

      }

      }


      This is my onDraw() function -



      @Override
      protected void onDraw(Canvas canvas) {
      super.onDraw(canvas);
      origWidth = this.getDrawable().getIntrinsicWidth();
      origLength = this.getDrawable().getIntrinsicHeight();
      if (markers.size() > 1) {
      for (int i = 0; i < markers.size() - 1; i++) {
      paintLine.setColor(Color.WHITE);
      float pts = {markers.get(i).point.x, markers.get(i).point.y, markers.get(i + 1).point.x, markers.get(i + 1).point.y};
      matrix.mapPoints(pts);
      canvas.drawLine(pts[0], pts[1], pts[2], pts[3], paintLine);
      }
      }

      for (int i = 0; i < markers.size(); i++) {
      float pts = {markers.get(i).point.x, markers.get(i).point.y};
      float sst = markers.get(i).sst;
      matrix.mapPoints(pts);

      if (sst <= 0 && sst >= -80) {
      paintMain.setColor(Color.RED);
      } else if (sst <= -80 && sst >= -90) {
      paintMain.setColor(Color.BLUE);
      } else if (sst <= -90 && sst >= -100) {
      paintMain.setColor(Color.YELLOW);
      } else if (sst <= -100 && sst >= -110) {
      paintMain.setColor(getResources().getColor(R.color.lightgreen));
      } else if (sst <= -110 && sst >= -140) {
      paintMain.setColor(Color.GREEN);
      } else if (sst == -999) {
      paintMain.setColor(Color.BLACK);
      }
      canvas.drawCircle(pts[0], pts[1], 22, paintMain);
      }

      for (int i = 0; i < semiMarkers.size(); i++) {
      float pts = {semiMarkers.get(i).point.x, semiMarkers.get(i).point.y};
      float sst = semiMarkers.get(i).sst;
      matrix.mapPoints(pts);
      if (sst <= 0 && sst >= -80) {
      paintForSemi.setColor(Color.RED);
      } else if (sst <= -80 && sst >= -90) {
      paintForSemi.setColor(Color.BLUE);
      } else if (sst <= -90 && sst >= -100) {
      paintForSemi.setColor(Color.YELLOW);
      } else if (sst <= -100 && sst >= -110) {
      paintForSemi.setColor(getResources().getColor(R.color.lightgreen));
      } else if (sst <= -110 && sst >= -140) {
      paintForSemi.setColor(Color.GREEN);
      } else if (sst == -999) {
      paintForSemi.setColor(Color.BLACK);
      }
      canvas.drawCircle(pts[0], pts[1], 11, paintForSemi);
      }
      }






      android multithreading image memory imageview






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 26 '18 at 11:17









      Rushi DesaiRushi Desai

      136




      136
























          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53479958%2fandroid-unable-to-add-window-token-android-os-binderproxy-is-not-valid-is%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53479958%2fandroid-unable-to-add-window-token-android-os-binderproxy-is-not-valid-is%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Ottavio Pratesi

          Tricia Helfer

          15 giugno