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 int getSmallestWidthDensity(Activity context) { | |
DisplayMetrics metrics = new DisplayMetrics(); | |
context.getWindowManager().getDefaultDisplay().getMetrics(metrics); | |
int widthPixels = metrics.widthPixels; | |
int heightPixels = metrics.heightPixels; | |
float scaleFactor = metrics.density; | |
float widthDp = widthPixels / scaleFactor; | |
float heightDp = heightPixels / scaleFactor; |
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 WearableCommunicator { | |
private static WearableCommunicator communicator; | |
public static WearableCommunicator getInstance() { | |
if (communicator == null) { | |
communicator = new WearableCommunicator(); | |
} | |
return communicator; | |
} |
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
using System; | |
using System.Security.Cryptography; | |
namespace MyNamespace | |
{ | |
public class Sha1Hasher | |
{ | |
public static string sha1Hash (string plaintext) | |
{ | |
SHA1 sh1 = SHA1.Create (); |
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
<?php | |
function drawCalendar($year, $month, $heading = null, $forceSixthRow = false) { | |
$daysInMonth = date("t", mktime(0, 0, 0, $month, 1, $year)); | |
$daysInPrevious = date("t", mktime(0, 0, 0, $month-1, 1, $year)); | |
$weekdayOfFirst = date("N", mktime(0, 0, 0, $month, 1, $year)) - 1; | |
$rows = ($forceSixthRow || $weekdayOfFirst + $daysInMonth > 35) ? 6 : 5; | |
echo '<table class="calendar" border="1">'; | |
if($heading != null) { | |
for ($i=0; $i < 7; $i++) { | |
echo '<th>'.$heading[$i].'</th>'; |
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 MetricsCalculator { | |
public static float convertDpToPixel(float dp,Context ctx) { | |
Resources resources = ctx.getResources(); | |
DisplayMetrics metrics = resources.getDisplayMetrics(); | |
return dp * (metrics.densityDpi / 160f); | |
} | |
public static float convertPixelToDp(float px, Context ctx) { | |
Resources resources = ctx.getResources(); |
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 RateAppManager { | |
private static final String MS_PREFS = Prefs.class.getSimpleName(); | |
private static SharedPreferences preferences; | |
private static final String APP_START_COUNT = "appStartCount"; | |
private static final String APP_INSTALL_TIMESTAMP = "appInstallTimestamp"; | |
private static final String RATE_DIALOG_SHOWN = "rateDialogShown"; | |
private static SharedPreferences getPreferences() { |
NewerOlder