mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-11 08:48:06 +01:00
use static to avoid querying OS for version over and over.
This commit is contained in:
parent
f70a5bc6ee
commit
9a4a8c7b26
1 changed files with 11 additions and 9 deletions
|
@ -60,6 +60,7 @@ public class Utils {
|
||||||
private static Boolean s_isFirstBootThisVersion = null;
|
private static Boolean s_isFirstBootThisVersion = null;
|
||||||
private static Boolean s_deviceSupportSMS = null;
|
private static Boolean s_deviceSupportSMS = null;
|
||||||
private static Boolean s_isFirstBootEver = null;
|
private static Boolean s_isFirstBootEver = null;
|
||||||
|
private static Integer s_appVersion = null;
|
||||||
private static HashMap<String,String> s_phonesHash =
|
private static HashMap<String,String> s_phonesHash =
|
||||||
new HashMap<String,String>();
|
new HashMap<String,String>();
|
||||||
private static int s_nextCode = 0; // keep PendingIntents unique
|
private static int s_nextCode = 0; // keep PendingIntents unique
|
||||||
|
@ -405,16 +406,17 @@ public class Utils {
|
||||||
|
|
||||||
public static int getAppVersion( Context context )
|
public static int getAppVersion( Context context )
|
||||||
{
|
{
|
||||||
int version;
|
if ( null == s_appVersion ) {
|
||||||
|
try {
|
||||||
try {
|
int version = context.getPackageManager()
|
||||||
version = context.getPackageManager()
|
.getPackageInfo(context.getPackageName(), 0)
|
||||||
.getPackageInfo(context.getPackageName(), 0)
|
.versionCode;
|
||||||
.versionCode;
|
s_appVersion = new Integer( version );
|
||||||
} catch ( Exception e ) {
|
} catch ( Exception e ) {
|
||||||
version = 0;
|
DbgUtils.loge( e );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return version;
|
return null == s_appVersion? 0 : s_appVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setFirstBootStatics( Context context )
|
private static void setFirstBootStatics( Context context )
|
||||||
|
|
Loading…
Add table
Reference in a new issue