title: how to set value to property of custom imageview?
body: <p>I have a custom Imageview class like below. I have a field called timeInterval which I pass it in constructor, but in onDraw it's value is 0. What is the proper way to pass this? also I don't know if I can pass it dynamically as attribute.</p>
  
  <pre><code>public class ProgressBarView extends AppCompatImageView {
  
      private final Handler mHandler = new Handler();
      private int mTimeInterval;
      private int mColor;
      private int[] mLocations = new int[2];
  
      public ProgressBarView(Context context, int timeInterval) {
          super(context);
          mTimeInterval = timeInterval;
          init(null);
      }
  
      public ProgressBarView(Context context, AttributeSet attrst) {
          super(context, attrst);
          init(attrst);
      }
  
      public ProgressBarView(Context context, AttributeSet attrs, int defStyle) {
          super(context, attrs, defStyle);
          init(attrs);
      }
  
      private void init(AttributeSet attrs) {
          if (attrs == null) {
              return;
          }
          TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ProgressBarView);
          mColor = typedArray.getColor(R.styleable.ProgressBarView_overlay_color, Color.BLACK);
      }
  
      public void updatePainting() {
          mHandler.postDelayed(this::invalidate, mTimeInterval / 360);
      }
  
      @Override
      public void onDraw(final Canvas canvas) {
          if (mTimeInterval == 0) {
              return;
          }
          Calendar now = Calendar.getInstance();
          int seconds = now.get(Calendar.SECOND);
          int mStartAngel = (int) (((float) (seconds % (mTimeInterval / 1000))
                  / (mTimeInterval / 1000)) * 360);
          final Paint paint = new Paint(Paint.DITHER_FLAG);
          paint.setColor(mColor);
          paint.setStyle(Paint.Style.FILL);
          paint.setAlpha(-50);
          getLocationOnScreen(mLocations);
          int radius = getWidth() / 2;
          float centreX = this.getX() + radius;
          if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.LOLLIPOP) {
              canvas.drawArc(centreX - radius, centreX - radius, centreX + radius, centreX + radius, 0, mStartAngel, true, paint);
          } else {
              final RectF oval = new RectF();
              oval.set(centreX - radius, centreX - radius, centreX + radius, centreX + radius);
              canvas.drawArc(oval, 0, mStartAngel, true, paint);
          }
          updatePainting();
      }
  }
  </code></pre>
  
  <p>I instantiate it like this:</p>
  
  <pre><code>mProgressBarView = new ProgressBarView(getContext(), timeInterval);
  
  </code></pre>