Android Open Source - InfoWallpaper Data Collector






From Project

Back to project page InfoWallpaper.

License

The source code is released under:

MIT License

If you think the Android project InfoWallpaper 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.andreashedin.infowallpaper;
/* ww  w.  j a v a 2s .c o m*/
import android.content.res.Resources;
import android.util.Log;

public abstract class DataCollector {
  protected LiveInfoWallpaper mParent = null;
  DataCollector(LiveInfoWallpaper parent) {
    mParent = parent;
  }
  
  protected String getNumberAsText(int num) {
    String[] numbers1 = new String[20];
    String[] numbers2 = new String[8];
    String[] numbers3 = new String[2];
    
    Resources resources = mParent.getResources();
    if(resources != null) {
      numbers1 = resources.getStringArray(R.array.numbers1);
      numbers2 = resources.getStringArray(R.array.numbers2);
      numbers3 = resources.getStringArray(R.array.numbers3);
    }
    
    String str = String.valueOf(num);
    
    if(num < 20 && num >= 0) {
      str = numbers1[num];
    }
    else {
      int thousand = num / 1000;
      num %= 1000;
      int hundred = num / 100;
      num %= 100;
      int tens = num / 10;
      num %= 10;
      int ones = num;
      
      str = "";
      if(thousand > 0 && thousand < 20) {
        str += numbers1[thousand];
        str += numbers3[1];
      }
      if(hundred > 0 && hundred < 10) {
        String temp = numbers1[hundred];
        temp += numbers3[0];
        
        if(str.length() > 0)
          temp = temp.toLowerCase();
        str += temp;
      }
      if(tens >= 2 && tens < 10) {
        String temp = numbers2[tens - 2];
        
        if(str.length() > 0)
          temp = temp.toLowerCase();
        str += temp;
      }
      if(tens == 1) {
        String temp = numbers1[ones + 10];
        
        if(str.length() > 0)
          temp = temp.toLowerCase();
        str += temp;
      }
      if(ones > 0 && ones < 10 && tens != 1) {
        String temp = numbers1[ones];
        
        if(str.length() > 0)
          temp = temp.toLowerCase();
        str += temp;
      }
    }
    
    return str;
  }
  
  abstract void update(Object object);
  abstract String updateInfoString(String string, boolean numbersAsText);
}




Java Source Code List

com.andreashedin.general.ColorPickerDialog.java
com.andreashedin.general.CustomizeInfoDialog.java
com.andreashedin.general.EnterStringDialog.java
com.andreashedin.general.PickItemDialog.java
com.andreashedin.general.PositionInfosDialog.java
com.andreashedin.general.SelectConfigurationDialog.java
com.andreashedin.general.TextSizeDialog.java
com.andreashedin.general.WeatherSettingsDialog.java
com.andreashedin.infowallpaper.Background.java
com.andreashedin.infowallpaper.BatteryDataCollector.java
com.andreashedin.infowallpaper.ColorHandler.java
com.andreashedin.infowallpaper.ConfigHandler.java
com.andreashedin.infowallpaper.CurrentSongDataCollector.java
com.andreashedin.infowallpaper.DataCollector.java
com.andreashedin.infowallpaper.DateTimeDataCollector.java
com.andreashedin.infowallpaper.DisplayValuePair.java
com.andreashedin.infowallpaper.InfoData.java
com.andreashedin.infowallpaper.InfoItem.java
com.andreashedin.infowallpaper.LiveInfoSettings.java
com.andreashedin.infowallpaper.LiveInfoWallpaper.java
com.andreashedin.infowallpaper.PhoneStatusDataCollector.java
com.andreashedin.infowallpaper.Phone.java
com.andreashedin.infowallpaper.SaveLoadData.java
com.andreashedin.infowallpaper.Screen.java
com.andreashedin.infowallpaper.WeatherDataCollector.java
com.andreashedin.infowallpaper.WeatherHandler.java