This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final float calculateDistanceTo(Location fromLocation, Location toLocation) { | |
return fromLocation.distanceTo(toLocation); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final float[] calculateDistanceTo(Location fromLocation, Location toLocation) { | |
float[] results = new float[]; | |
double startLatitude = fromLocation.getLatitude(); | |
double startLongitude = fromLocation.getLongitude(); | |
double endLatitude = toLocation.getLatitude(); | |
double endLongitude = toLocation.getLongitude(); | |
fromLocation.distanceBetween(startLatitude, startLongitude, endLatitude, endLongitude, results); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
View.requestRectangleOnScreen(Rect rectangle, boolean immediate); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final void resizeViewGroup(ViewGroup viewGroup, int width, int height) { | |
viewGroup.setMinimumWidth(width); | |
viewGroup.setMinimumHeight(height); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* How to use access files stored in the assets folder: | |
* | |
* Files saved in the assets/ directory are not given a resource ID, so you can't reference them through the R class or from XML resources. | |
* Instead, you can query files in the assets/ directory like a normal file system and read raw data using AssetManager. | |
* | |
* However, if all you require is the ability to read raw data (such as a video or audio file), then save the file in the res/raw/ directory | |
* and read a stream of bytes using openRawResource(). | |
* | |
* Notes: | |
* * AssetManager.list(String path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Singleton { | |
// Private constructor prevents instantiation from other classes | |
private Singleton() {} | |
/** | |
* SingletonHolder is loaded on the first execution of Singleton.getInstance() | |
* or the first access to SingletonHolder.INSTANCE, not before. | |
*/ | |
private static class SingletonHolder { | |
private static final Singleton INSTANCE = new Singleton(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remove the Activity parameter if this is being placed into a class that derives from Activity | |
public void launchHomeScreen(Activity activity) { | |
Intent homeIntent = new Intent(Intent.ACTION_MAIN, null); | |
homeIntent.addCategory(Intent.CATEGORY_HOME); | |
homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); | |
activity.startActivity(homeIntent); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final String determineDeviceIpAddress() { | |
try { | |
Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); | |
if (en != null) { | |
for (; en.hasMoreElements() ;) { | |
NetworkInterface intf = en.nextElement(); | |
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { | |
InetAddress inetAddress = enumIpAddr.nextElement(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Canvas c = new Canvas(bitmap); | |
ColorMatrix yuvMatrix = new ColorMatrix(); | |
yuvMatrix.setRGB2YUV(); | |
ColorFilter filter = new ColorMatrixColorFilter(yuvMatrix); | |
// TODO: the rest... | |
/************************************************************************* | |
static void setBackground(View v, Bitmap bm) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.codeswimmer.android.executor; | |
import java.util.concurrent.Executor; | |
import android.os.Handler; | |
import android.os.SystemClock; | |
public class PeriodicExecutor implements Executor { | |
private static final Handler poller = new Handler(); | |
private Runnable command; |