Android Open Source - no-frills-cpu-classic Frequency






From Project

Back to project page no-frills-cpu-classic.

License

The source code is released under:

Apache License

If you think the Android project no-frills-cpu-classic 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 it.sineo.android.noFrillsCPUClassic.extra;
/*  w w w . j a  v a 2  s.c o m*/
import java.text.NumberFormat;

public class Frequency {

  /*
   * We don't need synchronized access to it.
   */
  private static NumberFormat nf;

  static {
    nf = NumberFormat.getNumberInstance();
    nf.setMinimumFractionDigits(1);
    nf.setMaximumFractionDigits(3);
  }

  private String value;
  private Integer mhz;

  public Frequency(String value) {
    setValue(value);
  }

  public Integer getMHz() {
    return mhz;
  }

  public String toString() {
    if (mhz < 1000) {
      return mhz + " kHz";
    } else if (mhz < (1000 * 1000)) {
      return (mhz / 1000) + " MHz";
    } else {
      /*
       * "crude" GHz aren't pretty.
       */
      return nf.format(mhz / (double) (1000 * 1000)) + " GHz";
    }
  }

  public String getValue() {
    return value;
  }

  public void setValue(String value) {
    this.value = value;
    this.mhz = Integer.parseInt(value);
  }

  @Override
  public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((value == null) ? 0 : value.hashCode());
    return result;
  }

  @Override
  public boolean equals(Object obj) {
    if (this == obj)
      return true;
    if (obj == null)
      return false;
    if (getClass() != obj.getClass())
      return false;
    Frequency other = (Frequency) obj;
    if (value == null) {
      if (other.value != null)
        return false;
    } else if (!value.equals(other.value))
      return false;
    return true;
  }
}




Java Source Code List

it.sineo.android.noFrillsCPUClassic.BootReceiver.java
it.sineo.android.noFrillsCPUClassic.activity.AboutActivity.java
it.sineo.android.noFrillsCPUClassic.activity.MainActivity.java
it.sineo.android.noFrillsCPUClassic.activity.PreferencesActivity.java
it.sineo.android.noFrillsCPUClassic.activity.StatsActivity.java
it.sineo.android.noFrillsCPUClassic.extra.Constants.java
it.sineo.android.noFrillsCPUClassic.extra.Frequency.java
it.sineo.android.noFrillsCPUClassic.extra.PatternReplacerInputFilter.java
it.sineo.android.noFrillsCPUClassic.extra.Stats.java
it.sineo.android.noFrillsCPUClassic.extra.SysUtils.java
it.sineo.android.noFrillsCPUClassic.extra.Theme.java
it.sineo.android.noFrillsCPUClassic.service.BootService.java
it.sineo.android.noFrillsCPUClassic.service.ShutdownService.java
it.sineo.android.noFrillsCPUClassic.widget.StatsWidget.java