Android Open Source - DEVIEW2014_AndroidApp_Demo App Context From Project Back to project page DEVIEW2014_AndroidApp_Demo .
License The source code is released under:
Apache License
If you think the Android project DEVIEW2014_AndroidApp_Demo 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.nhn.android.deview;
/ / w w w . j a v a 2 s . c o m
import android.content.Context;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.preference.Preference;
import android.util.DisplayMetrics;
public class AppContext {
public static final String PREF_KEY = "deview" ;
public static Context getContext() {
return DeViewApplication.mInstance;
}
public static SQLiteDatabase getDB() {
return DeViewApplication.mInstance.mDB.mDB;
}
/* AppContext Storage: Data Transfer */
public static void putValue(Class<?> cls,Object value) {
String key = cls.getName();
DeViewApplication.mInstance.saveObject(key, value);
}
public static <T> T getValue(Class<?> cls,boolean remove) {
String key = cls.getName();
T t = (T)DeViewApplication.mInstance.loadObject(key,remove);
return t;
}
//TO store key-values
public static void putValue(String key,Object value) {
DeViewApplication.mInstance.saveObject(key, value);
}
public static <T> T getValue(String key,boolean remove) {
T t = (T)DeViewApplication.mInstance.loadObject(key,remove);
return t;
}
//Shared Preference
public static SharedPreferences getAppPref() {
SharedPreferences pref = getContext().getSharedPreferences(PREF_KEY, 0);
return pref;
}
//To redirect to UI Thread
public static void post(Runnable r) {
DeViewApplication.mInstance.mHandler.post(r);
}
public static void postDelayed(Runnable r,int millis) {
DeViewApplication.mInstance.mHandler.postDelayed(r,millis);
}
// UI Conversion
public static int dp2px(float dp) {
return (int )(DeViewApplication.mInstance.mDesity * dp);
}
public static int getScreenWidth() {
return DeViewApplication.mInstance.mDisplay.getWidth();
}
}
Java Source Code List com.nhn.android.deview.AppContext.java com.nhn.android.deview.AppTable.java com.nhn.android.deview.DeViewApplication.java com.nhn.android.deview.DeviewSchemeActivity.java com.nhn.android.deview.MainDB.java com.nhn.android.deview.ThreadWorker.java com.nhn.android.deview.core.connector.DataConnectorListener.java com.nhn.android.deview.core.connector.DataDoc.java com.nhn.android.deview.core.connector.DataField.java com.nhn.android.deview.core.connector.DataSet.java com.nhn.android.deview.core.connector.DefaultDataConnector.java com.nhn.android.deview.core.db.CursorReader.java com.nhn.android.deview.core.db.DbTable.java com.nhn.android.deview.core.lifecycle.CycleBaseLayout.java com.nhn.android.deview.core.lifecycle.CycleControllable.java com.nhn.android.deview.core.lifecycle.CycleControllerActivity.java com.nhn.android.deview.core.lifecycle.CycleController.java com.nhn.android.deview.core.lifecycle.CycleFragment.java com.nhn.android.deview.core.listview.ListCellViewAdapter.java com.nhn.android.deview.core.listview.ListCellView.java com.nhn.android.deview.core.listview.PageViewPagerAdapter.java com.nhn.android.deview.core.listview.PageView.java com.nhn.android.deview.core.pager.SimplePagerAdapter.java com.nhn.android.deview.core.transfer.BundleField.java com.nhn.android.deview.core.transfer.BundleMapper.java com.nhn.android.deview.core.transfer.IntentUri.java com.nhn.android.deview.core.transfer.UriObject.java com.nhn.android.deview.core.view.DeclareView.java com.nhn.android.deview.core.view.ViewMapper.java com.nhn.android.deview.dao.DeviewUri.java com.nhn.android.deview.dao.MyMemoManager.java com.nhn.android.deview.dao.MyMemo.java com.nhn.android.deview.dao.MySchedule.java com.nhn.android.deview.dao.program.ProgramData.java com.nhn.android.deview.dao.program.ProgramListConnector.java com.nhn.android.deview.dao.program.ProgramListDoc.java com.nhn.android.deview.dao.program.ProgramManager.java com.nhn.android.deview.dao.program.ProgramTrack.java com.nhn.android.deview.dao.program.TrackListConnector.java com.nhn.android.deview.ui.main.MainActivity.java com.nhn.android.deview.ui.main.ProgramCellView.java com.nhn.android.deview.ui.main.ProgramPageView.java com.nhn.android.deview.ui.note.MemoCellView.java com.nhn.android.deview.ui.note.MemoListActivity.java com.nhn.android.deview.ui.note.MemoRecorder.java com.nhn.android.deview.ui.note.MyScheduleActivity.java com.nhn.android.deview.webviewer.MemoWebToolbar.java com.nhn.android.deview.webviewer.ProgramWebActivity.java com.nhn.android.deview.webviewer.WebPageView.java