public class Library
extends java.lang.Object
| Constructor and Description |
|---|
Library() |
| Modifier and Type | Method and Description |
|---|---|
static int[] |
citySorter(double[] lats,
double[] lngs)
Takes a collection of nine cities and sorts them NW to SE, so that on a 3x3 grid
they appear in roughly the correct relative positions according to their co-ordinates.
|
static void |
copyFileFromAssets(java.lang.String asset,
java.lang.String destination,
android.content.Context ctx)
Copies a file from the assets folder to an internal destination
Modified from textbook - Beginning Android 4 Application Development, Wei-Meng Lee - 2012
|
static java.lang.String |
dateFormat(java.lang.String time)
Formats a timestamp for use by this app
|
static int[] |
getOrdersFromSort(double[] array)
Get the mapping from a sorted array to its original, unsorted state
|
static int |
indexFind(double[] array,
double value)
My version of Java's
Arrays.indexOf(). |
static java.lang.String[] |
readWebpageToArray(java.lang.String url)
Stores the contents of a text file from a URL into an
ArrayList of Strings |
static int |
readWebpageToInt(java.lang.String url)
Gets an integer from a webpage
|
static int[][] |
splitArray(int[] array)
Split an array of length 9 into a 2D, 3x3 array
|
static int |
valueColour(double value,
int type)
Converts a raw weather variable value to a relative one to be used for accessing an array index (
whereby the array specifies a colour spectrum ).
|
public static java.lang.String[] readWebpageToArray(java.lang.String url)
ArrayList of Stringsurl - from the webArrayList of Strings, one per line of the text file; empty array on failurepublic static int readWebpageToInt(java.lang.String url)
url - from the webpublic static void copyFileFromAssets(java.lang.String asset,
java.lang.String destination,
android.content.Context ctx)
throws java.io.IOException
asset - the filename of the file in the assets folderdestination - the full destination file pathctx - java.io.IOExceptionpublic static java.lang.String dateFormat(java.lang.String time)
time - a UNIX timestamp in secondspublic static int valueColour(double value,
int type)
value - the raw value in native (UK) unitstype - the weather variable type:public static int indexFind(double[] array,
double value)
Arrays.indexOf(). Mine works on doubles, Java's does not. array - value - public static int[] getOrdersFromSort(double[] array)
array - unsortedpublic static int[][] splitArray(int[] array)
array - the 1D arraypublic static int[] citySorter(double[] lats,
double[] lngs)
lats - latitudes of the citieslngs - longitudes of the cities