Android Open Source - android-molecules-livewallpaper Wallpaper Element






From Project

Back to project page android-molecules-livewallpaper.

License

The source code is released under:

Copyright (c) 2012 Dominik Raymann <dominik.raymann@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "S...

If you think the Android project android-molecules-livewallpaper 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 ch.raymi.android.molecules;
/*from w w w  .j a  v a2 s  . c o  m*/
import org.jmol.api.JmolViewer;

import android.graphics.Canvas;

public abstract class WallpaperElement {
  private final long mStarted;
  private final long mDuration;
  private final String mId;

  public WallpaperElement(String id, long duration) {
    mStarted = System.currentTimeMillis();
    mDuration = duration;
    mId = id;
  }

  protected long shownSince() {
    long t = System.currentTimeMillis() - mStarted;
    return t > 0 ? t : 0;
  }

  public boolean show(Canvas c, JmolViewer v) {
    draw(c, v);
    return shownSince() > mDuration;
  }

  protected abstract void draw(Canvas c, JmolViewer v);

  @Override
  public boolean equals(Object o) {
    if (!(o instanceof WallpaperElement)) {
      return false;
    }
    return ((WallpaperElement)o).mId.equals(this.mId);
  }

  @Override
  public int hashCode() {
    return this.mId.hashCode();
  }
}




Java Source Code List

ch.raymi.android.molecules.AndroidPlatform.java
ch.raymi.android.molecules.Image.java
ch.raymi.android.molecules.MoleculeName.java
ch.raymi.android.molecules.Molecule.java
ch.raymi.android.molecules.MoleculesWallpaperPreferences.java
ch.raymi.android.molecules.MoleculesWallpaper.java
ch.raymi.android.molecules.WallpaperElement.java