Android Open Source - LearningAndroid2edYamba2 Freshness View






From Project

Back to project page LearningAndroid2edYamba2.

License

The source code is released under:

Apache License

If you think the Android project LearningAndroid2edYamba2 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.marakana.android.yamba;
//from w w w .jav  a 2s . c  o  m
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.util.AttributeSet;
import android.view.View;

public class FreshnessView extends View {
  private static final int LINE_HEIGHT = 30;
  private long timestamp = -1;
  private Paint paint;

  public FreshnessView(Context context, AttributeSet attrs) {
    super(context, attrs);

    paint = new Paint();
    paint.setARGB(255, 0, 255, 0);
    paint.setStyle(Style.FILL_AND_STROKE);
    paint.setStrokeWidth(LINE_HEIGHT);

    setMinimumHeight(LINE_HEIGHT);
  }

  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (timestamp == -1)
      return;
    long delta = System.currentTimeMillis() - timestamp;
    double hours = delta / 3600000.0;
    double multiplier = 1-(Math.min(hours, 24) / 24.0);
    int width = (int) (getWidth() * multiplier);
    canvas.drawLine(0, 0, width, 0, paint);
  }

  public void setTimestamp(long timestamp) {
    this.timestamp = timestamp;
    this.invalidate();
  }
}




Java Source Code List

com.marakana.android.yamba.BootReceiver.java
com.marakana.android.yamba.DbHelper.java
com.marakana.android.yamba.DetailsActivity.java
com.marakana.android.yamba.DetailsFragment.java
com.marakana.android.yamba.FreshnessView.java
com.marakana.android.yamba.MainActivity.java
com.marakana.android.yamba.NotificationReceiver.java
com.marakana.android.yamba.RefreshService.java
com.marakana.android.yamba.SettingsActivity.java
com.marakana.android.yamba.SettingsFragment.java
com.marakana.android.yamba.StatusActivity.java
com.marakana.android.yamba.StatusContract.java
com.marakana.android.yamba.StatusFragment.java
com.marakana.android.yamba.StatusProvider.java
com.marakana.android.yamba.SubActivity.java
com.marakana.android.yamba.TimelineFragment.java
com.marakana.android.yamba.YambaWidget.java