Back to project page achat.
The source code is released under:
GNU General Public License
If you think the Android project achat listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.anlong.im; /*w w w . ja v a2s.com*/ import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import android.app.Activity; import android.app.Application; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import com.anlong.im.constant.Constant; import com.anlong.im.constant.DataConstant; import com.anlong.im.dao.db.DatabaseAdapter; import com.anlong.im.dao.db.model.AppListDBInfo; import com.anlong.im.dao.db.model.SystemParameterDBinfo; import com.anlong.im.service.CoreService; import com.anlong.im.ui.util.MsgHandleProxy; import com.anlong.im.ui.util.SIPControl; import com.anlong.im.util.ImLog; import com.anlong.im.util.SharedPreferencesSave; import com.anlong.im.vo.FaceInfo; import com.anlong.im.vo.MessageInfo; import com.anlong.imsghandle.vo.OnlineUser; import com.anlong.imsghandle.vo.UserMessage; /** * * @Title: ImApp.java * @Package com.anlong.im * @Description: TODO Im ???? * @author anlong * @date 2013-4-27 ????9:27:05 * @version V1.0 * * */ public class ImApp extends Application { /** * ????????????false ????; */ public static boolean hasExited = false; /** * ?????????????? */ private boolean isSynchroHistroy= false; public boolean isSynchroHistroy() { return isSynchroHistroy; } public void setSynchroHistroy(boolean isSynchroHistroy) { this.isSynchroHistroy = isSynchroHistroy; } private LinkedList<Activity> activityList = new LinkedList<Activity>(); /** * ??????app?????? */ public static Boolean isRefreshAppList = false; /** * ??????app???? */ public static Boolean isLoadAppList = false; public static Boolean isShowHead = false; /** * app ?????????????????? */ public static List<AppListDBInfo> appList = new ArrayList<AppListDBInfo>(); /** * ?????? */ public static ImApp sInstance; /** * ??????????? */ public static String FACE_ZHENGZE_EN = ""; /** * ????????????? */ public static String FACE_ZHEGNZE_ZW=""; /** * ??????Map ??????id */ public static HashMap<String, Integer> FACE_MAP = new HashMap<String, Integer>(); /** * ????????map ??????? */ public static HashMap<String, String> FACE_NAME_MAP_ZW_TO_EN = new HashMap<String, String>(); /** * ????????map ??????? */ public static HashMap<String, String> FACE_NAME_MAP_EN_TO_ZN = new HashMap<String, String>(); /** * ?????Map */ public static HashMap<String, String> VOICE_MAP= new HashMap<String, String>(); /** * ?????? */ public static List<FaceInfo> FACE_LIST; /** * ????????? MessageInfo???? */ //public static HashMap<String,List<MessageInfo>> MSGLIST_FROM_PIC_MAP = new HashMap<String, List<MessageInfo>>(); /** * ???????????? * ??????????????? */ public static HashMap<String, UserMessage> sendMessageMap = new HashMap<String, UserMessage>(); public Bitmap samplePictureBitmap=null; /** * ????id */ private int userid; /** * ?? */ private int token; /** * ???????? */ private String username; /** * ???????id */ private int depid; private String server_ip; /** * ????? */ private String password; /** * ?????? * ?????? */ private String realName; /** * ?? */ private int sex=0; /** * ???????? ?? */ private int widthPixels; /** * ???????? ?? */ private int heightPixels; /** * ???? */ private static long heartbeattime = 0; /** * ???? * */ private static long system_time = System.currentTimeMillis(); /** * ?????? */ private SystemParameterDBinfo systemParameter; /** * ??????? */ private int groupLimit = 0; /** * ?????? */ private String icon_url; private String headImage; @Override public void onCreate() { super.onCreate(); sInstance = this; //???????????? // CrashHandler crashHandler = CrashHandler.getInstance(); // crashHandler.init(getApplicationContext()); } public int getSex() { sex=SharedPreferencesSave .getInstance(this) .getIntValue(DataConstant.SHAREDPREFERENCES_USER_SEX, 0); return sex; } public void setSex(int sex) { SharedPreferencesSave .getInstance(this). saveIntValue(DataConstant.SHAREDPREFERENCES_USER_SEX, sex); this.sex = sex; } public int getWidthPixels() { widthPixels = SharedPreferencesSave .getInstance(this) .getIntValue(DataConstant.SHAREDPREFERENCES_WIDTH_PIXELS, 0); return widthPixels; } public void setWidthPixels(int widthPixels) { SharedPreferencesSave .getInstance(this). saveIntValue(DataConstant.SHAREDPREFERENCES_WIDTH_PIXELS, widthPixels); this.widthPixels = widthPixels; } public int getHeightPixels() { heightPixels = SharedPreferencesSave .getInstance(this) .getIntValue(DataConstant.SHAREDPREFERENCES_HEIGHT_PIXELS, 0); return heightPixels; } public void setHeightPixels(int heightPixels) { SharedPreferencesSave .getInstance(this). saveIntValue(DataConstant.SHAREDPREFERENCES_HEIGHT_PIXELS, heightPixels); this.heightPixels = heightPixels; } public String getRealName() { realName = SharedPreferencesSave .getInstance(this).getStringValue(DataConstant.SHAREDPREFERENCES_USER_REALNAME, ""); return realName; } public void setRealName(String realName) { SharedPreferencesSave .getInstance(this).saveStringValue(DataConstant.SHAREDPREFERENCES_USER_REALNAME, realName); this.realName = realName; } public String getHeadImage() { headImage = SharedPreferencesSave .getInstance(this).getStringValue(DataConstant.SHAREDPREFERENCES_USER_HEAD, ""); return headImage; } public void setHeadImage(String headImage) { SharedPreferencesSave .getInstance(this).saveStringValue(DataConstant.SHAREDPREFERENCES_USER_HEAD, headImage); this.headImage = headImage; } public int getDepid() { depid=SharedPreferencesSave .getInstance(this) .getIntValue(DataConstant.SHAREDPREFERENCES_LOGIN_DEPID, 0); if(depid==0){ ImLog.e("ImApp","depid??"); } return depid; } public void setDepid(int depid) { SharedPreferencesSave .getInstance(this). saveIntValue(DataConstant.SHAREDPREFERENCES_LOGIN_DEPID, depid); this.depid = depid; } public int getUserid() { userid=SharedPreferencesSave .getInstance(this) .getIntValue(DataConstant.SHAREDPREFERENCES_LOGIN_ID, 0); if(userid==0){ ImLog.e("ImApp","??id??"); } return userid; } public void setUserid(int userid) { SharedPreferencesSave .getInstance(this). saveIntValue(DataConstant.SHAREDPREFERENCES_LOGIN_ID, userid); } public int getToken() { token=SharedPreferencesSave .getInstance(this) .getIntValue(DataConstant.SHAREDPREFERENCES_LOGIN_TOKEN, 0); if(token==0){ ImLog.e("ImApp","??????"); } return token; } public void setToken(int token) { SharedPreferencesSave .getInstance(this). saveIntValue(DataConstant.SHAREDPREFERENCES_LOGIN_TOKEN, token); this.token = token; } public String getIcon_url() { icon_url= SharedPreferencesSave .getInstance(this) .getStringValue(DataConstant.SHAREDPREFERENCES_USER_ICON_URL, ""); return icon_url; } public void setIcon_url(String icon_url) { SharedPreferencesSave .getInstance(this). saveStringValue(DataConstant.SHAREDPREFERENCES_USER_ICON_URL, icon_url); this.icon_url = icon_url; } public String getServer_ip() { server_ip= SharedPreferencesSave .getInstance(this). getStringValue(Constant.SHAREDPREFERENCES_KEY_SERVER_IP, ""); return server_ip; } public String getPassword() { password= SharedPreferencesSave .getInstance(this) .getStringValue(DataConstant.SHAREDPREFERENCES_USER_PWD, ""); return password; } public void setPassword(String password) { SharedPreferencesSave .getInstance(this). saveStringValue(DataConstant.SHAREDPREFERENCES_USER_PWD, password); this.password = password; } /** * ????????????????? * **/ public String getUsername() { username= SharedPreferencesSave .getInstance(this) .getStringValue(DataConstant.SHAREDPREFERENCES_USER_ACCONTNAME, ""); return username; } /** * ???????????????? * **/ public void setUsername(String username) { SharedPreferencesSave .getInstance(this). saveStringValue(DataConstant.SHAREDPREFERENCES_USER_ACCONTNAME, username); this.username = username; } public long getHeartbeattime() { long htime=SharedPreferencesSave .getInstance(this) .getLongValue(DataConstant.SHAREDPREFERENCES_NOW_HEARTBEAT_TIME, 0); if(htime>0){heartbeattime=htime;} return heartbeattime; } public void setHeartbeattime(long heartbeattime) { ImApp.heartbeattime = heartbeattime; SharedPreferencesSave .getInstance(this) .saveLongValue(DataConstant.SHAREDPREFERENCES_NOW_HEARTBEAT_TIME,heartbeattime); } public long getSystem_time() { long stime=SharedPreferencesSave .getInstance(this) .getLongValue(DataConstant.SHAREDPREFERENCES_NOW_SYSTEM_TIME, 0); if(stime>0){system_time=stime;} return system_time; } public void setSystem_time(long system_time) { ImApp.system_time = system_time; SharedPreferencesSave .getInstance(this) .saveLongValue(DataConstant.SHAREDPREFERENCES_NOW_SYSTEM_TIME,system_time); } public SystemParameterDBinfo getSystemParameter() { if(systemParameter!=null){ if(systemParameter.fileServer==null || systemParameter.fileServer==""){ systemParameter=DatabaseAdapter.getInstance(getApplicationContext()).selectSystemParameter(); } } else{ systemParameter=DatabaseAdapter.getInstance(getApplicationContext()).selectSystemParameter(); } return systemParameter; } public void setSystemParameter(SystemParameterDBinfo systemParameter) { this.systemParameter = systemParameter; } public int getGroupLimit() { return groupLimit; } public void setGroupLimit(int groupLimit) { this.groupLimit = groupLimit; } /** * ??????? */ public void beforeKill() { if (hasExited) { return; } clearSerData(); finishAll(); SIPControl.exitSIP(sInstance); ImLog.anlong("?????"); android.os.Process.killProcess(android.os.Process.myPid()); } /** * * @Title: clearSerData * @Description: TODO ????????????? * @author anlong * @param * @return void */ public void clearSerData(){ //TODO ?????????????? clearUseroOnlineState(getApplicationContext()); DatabaseAdapter.getInstance(getApplicationContext()).DestroyDBHelper(); //??????? stopService(new Intent(getApplicationContext(),CoreService.class)); setHeartbeattime(0); setUserid(0); hasExited = true; } /** * * @Title: clearUseroOnlineState * @Description: TODO ?????? * @author anlong * @param @param cxt * @return void */ public static void clearUseroOnlineState(Context cxt){ DatabaseAdapter.getInstance(cxt) .setAllUserInfoOnlineStateOnOff(); } /** * * @Description: TODO ????????? Context * @return Context */ public Context getContext() { return getApplicationContext(); } /** * ????????????? ??false ????; */ public static boolean hasExited() { return hasExited; } /** * * @Description: TODO ??APP?? * @return */ public static ImApp getsInstance() { if(sInstance==null){ sInstance=new ImApp(); } return sInstance; } /*** * ???????activity????????????? */ public void finishAll() { for (Activity act : activityList) { act.finish(); } activityList.clear(); } /*** * ????Activity?onCreate??????????????activity */ public void addActivity(Activity act) { activityList.add(act); } /*** * ????Activity?onDestroy??? */ public void removeActivity(Activity act) { activityList.remove(act); } /** * * @Description: TODO ????????????? * @param time * @return */ public Date getSystemTime() { return new Date(getSystem_time()); } private Bitmap bitmap = null; //???????????? public void setBitmapImage(Bitmap bitmap){ this.bitmap = bitmap; } public Bitmap getBitmapImage(){ return this.bitmap; } /** * ??????????? */ private String picThumbPath; public void setPicThumbPath(String picThumbPath){ this.picThumbPath = picThumbPath; } public String getPicThumbPath(){ return this.picThumbPath; } /** * ??????? */ private String picPath; public void setPicPath(String picPath){ this.picPath = picPath; } public String getPicPath(){ return this.picPath; } }