List of usage examples for android.os Message Message
public Message()
From source file:com.xmobileapp.rockplayer.LastFmEventImporter.java
/********************************* * // w ww . j av a2 s . c om * Get Artist Events * @throws SAXException * @throws ParserConfigurationException * *********************************/ public void getArtistEvents() throws SAXException, ParserConfigurationException { /* * Initialize Artist Cursor */ artistCursor = ((RockPlayer) context).contentResolver.query(MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI, ((RockPlayer) context).ARTIST_COLS, // we should minimize the number of columns null, // all albums null, // parameters to the previous parameter - which is null also null // sort order, SQLite-like ); /* * Declare & Initialize some vars */ String artistName = null; String artistNameFiltered = null; String artistConcertFileName = null; SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); SAXParser saxParser = saxParserFactory.newSAXParser(); XMLReader xmlReader = saxParser.getXMLReader(); XMLArtistEventHandler xmlHandler = new XMLArtistEventHandler(); xmlHandler.myLocation = this.myLocation; xmlReader.setContentHandler(xmlHandler); /* * Set Distance Limit */ xmlHandler.MAX_DISTANCE = this.concertRadius; /* * Loop through the artists */ artistCursor.moveToFirst(); for (int i = 0; i < artistCursor.getCount(); i++) { /* * Get artist name */ artistName = artistCursor.getString(artistCursor.getColumnIndex(MediaStore.Audio.Artists.ARTIST)); if (artistName.equals("<unknown>")) { artistCursor.moveToNext(); continue; } artistNameFiltered = filterString(artistName); artistConcertFileName = ((RockPlayer) context).FILEX_CONCERT_PATH + validateFileName(artistName); /* * UI feedback */ Bundle data = new Bundle(); data.putString("info", artistName); Message msg = new Message(); msg.setData(data); ((RockPlayer) context).analyseConcertInfoHandler.sendMessage(msg); /* * If we dont have yet or info is too old, update the concert info of this artist */ if (hasConcertInfo(artistName) == false || concertInfoNeedsUpdate(artistName) == true) { Log.i("INET", "Getting concert info from LastFM"); if (hasConcertInfo(artistName) == false) Log.i("INET", "Because there is no concert info yet"); if (concertInfoNeedsUpdate(artistName) == true) Log.i("INET", "Because Info is too old"); File artistConcertFile = new File(artistConcertFileName); if (!artistConcertFile.exists()) { try { artistConcertFile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } URL lastFmApiRequest; try { lastFmApiRequest = new URL( this.LAST_FM_API_URL + "&artist=" + URLEncoder.encode(artistNameFiltered)); BufferedInputStream bufferedURLStream = new BufferedInputStream(lastFmApiRequest.openStream()); BufferedOutputStream bufferedFileWriter = new BufferedOutputStream( new FileOutputStream(artistConcertFile)); byte[] buf = new byte[1024]; int len; while ((len = bufferedURLStream.read(buf)) >= 0) bufferedFileWriter.write(buf, 0, len); bufferedURLStream.close(); bufferedFileWriter.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } /* * get event list from cached XML files */ File artistConcertFile = new File(artistConcertFileName); if (artistConcertFile.exists() && artistConcertFile.length() > 0) { try { BufferedReader xmlFileReader = new BufferedReader( new InputStreamReader(new FileInputStream(artistConcertFile))); xmlHandler.resetList(); xmlHandler.artist = artistName; xmlReader.parse(new InputSource(xmlFileReader)); insertListInListByDate(xmlHandler.artistEventList); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } artistCursor.moveToNext(); } /* * Debug */ ArtistEvent artistEventDebug = null; if (!artistEventList.isEmpty()) { artistEventList.getFirst(); ListIterator<ArtistEvent> listIterator = artistEventList.listIterator(0); for (artistEventDebug = listIterator.next(); listIterator .hasNext() == true; artistEventDebug = listIterator.next()) { if (artistEventDebug != null) Log.i("DBG", artistEventDebug.date + " " + artistEventDebug.city); // Log.i("DBG", artistEventDebug.date+" "+artistEventDebug.city+" "+artistEventDebug.artist); else Log.i("DBG", "NULL"); } } /* * Update Adapter */ eventLinkedListAdapter = new EventLinkedListAdapter(context, R.layout.eventlist_item, artistEventList); if (eventLinkedListAdapter == null) Log.i("NULL", "NULL"); ((RockPlayer) context).updateEventListHandler.sendEmptyMessage(0); /* * Give feedback to the user */ Bundle data = new Bundle(); Message msg = new Message(); data.putString("info", "Done!"); msg.setData(data); ((RockPlayer) context).analyseConcertInfoHandler.sendMessage(msg); }
From source file:com.jackie.movies.ui.DetailActivity.java
private void loadList(String url, final int what, final Class<? extends Parcelable> classOfT) { Uri.Builder builder = Uri.parse(url).buildUpon(); builder.appendQueryParameter(Constants.API_KEY_PARAM, getString(R.string.api_key_v3_auth)); builder.appendQueryParameter(Constants.LANGUAGE_PARAM, Locale.getDefault().getLanguage()); url = builder.build().toString();/*w w w. j a v a 2s . com*/ HttpUtils.get(this, url, new HttpUtils.HttpCallBack() { @Override public void onConnect() { Log.d(TAG, "onConnect: "); } @Override public void onCanceled() { Log.d(TAG, "onCanceled: "); } @Override public void onSuccess(String response) { Log.d(TAG, "onSuccess() called with: response = [" + response + "]"); Gson gson = new GsonBuilder().create(); Bundle bundle = new Bundle(); bundle.putParcelable(EXTRA_ENTITY, gson.fromJson(response, classOfT)); Message message = new Message(); message.what = what; message.setData(bundle); handler.sendMessage(message); } @Override public void onFailure(IOException e) { Log.e(TAG, "onFailure: ", e); } }); }
From source file:com.cettco.buycar.activity.OrderDetailActivity.java
protected void getData() { // String url = GlobalData.getBaseUrl() + "/cars/list.json"; // httpCache.clear(); String url = GlobalData.getBaseUrl() + "/tenders/" + tender_id + ".json"; HttpConnection.setCookie(getApplicationContext()); nullDataLayout.setVisibility(View.GONE); progressLayout.setVisibility(View.VISIBLE); HttpConnection.get(url, new AsyncHttpResponseHandler() { @Override/* w w w . ja v a 2s . c om*/ public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { // TODO Auto-generated method stub System.out.println("fail"); Message message = new Message(); message.what = 2; mHandler.sendMessage(message); } @Override public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { // TODO Auto-generated method stub System.out.println("seccuss"); try { String result = new String(arg2, "UTF-8"); System.out.println("result:" + result); Gson gson = new Gson(); detailEntity = gson.fromJson(result, OrderDetailEntity.class); // Type listType = new TypeToken<ArrayList<DealerEntity>>() // { // }.getType(); // dealerList = new Gson().fromJson(result, listType); // System.out.println("size:"+dealerList.size()); Message message = new Message(); message.what = 1; mHandler.sendMessage(message); // System.out.println("result:"+result); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); }
From source file:org.cocos2dx.lib.TextInputWraper.java
public static void openIMEKeyboard() { Message msg = new Message(); msg.what = HANDLER_OPEN_IME_KEYBOARD; msg.obj = mainView.getContentText(); handler.sendMessage(msg);/*from www . ja v a 2s . c om*/ }
From source file:com.emorym.android_pusher.Pusher.java
public void connect() { String prefix = mEncrypted ? HTTPS_PREFIX : HTTP_PREFIX; int port = mEncrypted ? WSS_PORT : WS_PORT; String path = "/app/" + mApplicationkey + "?client=js&version=" + VERSION; try {/*from w w w. j a v a 2 s. c om*/ URI url = new URI(prefix + HOST + ":" + port + path); if (Log.isLoggable(TAG, DEBUG)) Log.d(TAG, "Connecting to: " + url.toString()); mWebSocket = new WebSocketConnection(url); mWebSocket.setTrustAllCerts(trustAllCerts); mWebSocket.setEventHandler(new WebSocketEventHandler() { public void onOpen() { if (Log.isLoggable(TAG, DEBUG)) Log.d(TAG, "WebSocket Open"); subscribeToAllChannels(); } public void onMessage(WebSocketMessage message) { try { if (Log.isLoggable(TAG, DEBUG)) Log.d(TAG, "Message: " + message.getText()); JSONObject jsonMessage = new JSONObject(message.getText()); String event = jsonMessage.optString("event", null); if (event.equals("pusher:connection_established")) { JSONObject data = new JSONObject(jsonMessage.getString("data")); mSocketId = data.getString("socket_id"); if (Log.isLoggable(TAG, DEBUG)) Log.d(TAG, "Connection Established with Socket Id: " + mSocketId); } else { Bundle b = new Bundle(); b.putString("event", event); b.putString("data", jsonMessage.getString("data")); // backwards compatibility b.putString("type", "pusher"); b.putString("message", message.getText()); if (jsonMessage.has("channel")) { b.putString("channel", jsonMessage.getString("channel")); } Message msg = new Message(); msg.setData(b); mHandler.sendMessage(msg); } } catch (JSONException e) { if (Log.isLoggable(TAG, DEBUG)) Log.d(TAG, "JSON exception", e); } } public void onClose() { if (Log.isLoggable(TAG, DEBUG)) Log.d(TAG, "WebSocket Closed"); } }); mWatchdog = new Thread(new Runnable() { public void run() { boolean interrupted = false; while (!interrupted) { try { Thread.sleep(WATCHDOG_SLEEP_TIME_MS); if (!mWebSocket.isConnected()) mWebSocket.connect(); } catch (InterruptedException e) { interrupted = true; } catch (Exception e) { if (Log.isLoggable(TAG, DEBUG)) Log.d(TAG, "Exception connecting", e); } } } }); mWatchdog.start(); } catch (WebSocketException e) { if (Log.isLoggable(TAG, DEBUG)) Log.d(TAG, "Web socket exception", e); } catch (URISyntaxException e) { if (Log.isLoggable(TAG, DEBUG)) Log.d(TAG, "URI syntax exception", e); } }
From source file:com.changxiang.game.sdk.net.AsyncHttpGet.java
@Override public void run() { String ret = ""; try {//from w w w. j a v a 2 s . c o m if (parameter != null && parameter.size() > 0) { StringBuilder bulider = new StringBuilder(); for (RequestParameter p : parameter) { if (bulider.length() != 0) { bulider.append("&"); } bulider.append(Util.encode(p.getName())); bulider.append("="); bulider.append(Util.encode(p.getValue())); } // url += "?" + bulider.toString(); url += "?" + bulider.toString() + "&sign=" + MD5Util.MD5(bulider.toString() + "1234" + CXGameConfig.SERVERKEY); System.out.println("===" + url); } LogUtil.d("AsyncHttpGet : ", url); for (int i = 0; i < CXGameConfig.CONNECTION_COUNT; i++) { try { request = new HttpGet(url); if (CXGameConfig.isGzip) { request.addHeader("Accept-Encoding", "gzip"); } else { request.addHeader("Accept-Encoding", "default"); } // httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, connectTimeout); // ? httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, readTimeout); HttpResponse response = httpClient.execute(request); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode == HttpStatus.SC_OK) { InputStream is = response.getEntity().getContent(); BufferedInputStream bis = new BufferedInputStream(is); bis.mark(2); // ?? byte[] header = new byte[2]; int result = bis.read(header); // reset?? bis.reset(); // ?GZIP? int headerData = getShort(header); // Gzip ? ? 0x1f8b if (result != -1 && headerData == 0x1f8b) { is = new GZIPInputStream(bis); } else { is = bis; } InputStreamReader reader = new InputStreamReader(is, "utf-8"); char[] data = new char[100]; int readSize; StringBuffer sb = new StringBuffer(); while ((readSize = reader.read(data)) > 0) { sb.append(data, 0, readSize); } ret = sb.toString(); bis.close(); reader.close(); } else { RequestException exception = new RequestException(RequestException.IO_EXCEPTION, "??,??" + statusCode); ret = ErrorUtil.errorJson("-1", exception.getMessage()); LogUtil.d("connection url", "" + i); continue; } break; } catch (Exception e) { if (i == CXGameConfig.CONNECTION_COUNT - 1) { RequestException exception = new RequestException(RequestException.IO_EXCEPTION, ""); ret = ErrorUtil.errorJson("-1", exception.getMessage()); } else { LogUtil.d("connection url", "" + i); continue; } } } } catch (java.lang.IllegalArgumentException e) { RequestException exception = new RequestException(RequestException.IO_EXCEPTION, CXGameConfig.ERROR_MESSAGE); ret = ErrorUtil.errorJson("-2", exception.getMessage()); } finally { if (!CXGameConfig.IS_STOP_REQUEST) { Message msg = new Message(); msg.obj = ret; msg.getData().putSerializable("callback", callBack); resultHandler.sendMessage(msg); } if (customLoadingDialog != null && customLoadingDialog.isShowing()) { customLoadingDialog.dismiss(); customLoadingDialog = null; } } super.run(); }
From source file:com.baofeng.game.sdk.net.AsyncHttpGet.java
@Override public void run() { String ret = ""; try {//w ww . j ava2s .c o m if (parameter != null && parameter.size() > 0) { StringBuilder bulider = new StringBuilder(); for (RequestParameter p : parameter) { if (bulider.length() != 0) { bulider.append("&"); } bulider.append(Util.encode(p.getName())); bulider.append("="); bulider.append(Util.encode(p.getValue())); } // url += "?" + bulider.toString(); url += "?" + bulider.toString() + "&sign=" + MD5Util.MD5(bulider.toString() + "1234" + BFGameConfig.SERVERKEY); // System.out.println("@@@"+bulider.toString()); } LogUtil.d("AsyncHttpGet : ", url); for (int i = 0; i < BFGameConfig.CONNECTION_COUNT; i++) { try { request = new HttpGet(url); if (BFGameConfig.isGzip) { request.addHeader("Accept-Encoding", "gzip"); } else { request.addHeader("Accept-Encoding", "default"); } // httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, connectTimeout); // ? httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, readTimeout); HttpResponse response = httpClient.execute(request); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode == HttpStatus.SC_OK) { InputStream is = response.getEntity().getContent(); BufferedInputStream bis = new BufferedInputStream(is); bis.mark(2); // ?? byte[] header = new byte[2]; int result = bis.read(header); // reset?? bis.reset(); // ?GZIP? int headerData = getShort(header); // Gzip ? ? 0x1f8b if (result != -1 && headerData == 0x1f8b) { is = new GZIPInputStream(bis); } else { is = bis; } InputStreamReader reader = new InputStreamReader(is, "utf-8"); char[] data = new char[100]; int readSize; StringBuffer sb = new StringBuffer(); while ((readSize = reader.read(data)) > 0) { sb.append(data, 0, readSize); } ret = sb.toString(); bis.close(); reader.close(); } else { RequestException exception = new RequestException(RequestException.IO_EXCEPTION, "??,??" + statusCode); ret = ErrorUtil.errorJson("-1", exception.getMessage()); LogUtil.d("connection url", "" + i); continue; } break; } catch (Exception e) { if (i == BFGameConfig.CONNECTION_COUNT - 1) { RequestException exception = new RequestException(RequestException.IO_EXCEPTION, ""); ret = ErrorUtil.errorJson("-1", exception.getMessage()); } else { LogUtil.d("connection url", "" + i); continue; } } } } catch (java.lang.IllegalArgumentException e) { RequestException exception = new RequestException(RequestException.IO_EXCEPTION, BFGameConfig.ERROR_MESSAGE); ret = ErrorUtil.errorJson("-2", exception.getMessage()); } finally { if (!BFGameConfig.IS_STOP_REQUEST) { Message msg = new Message(); msg.obj = ret; msg.getData().putSerializable("callback", callBack); resultHandler.sendMessage(msg); } if (customLoadingDialog != null && customLoadingDialog.isShowing()) { customLoadingDialog.dismiss(); customLoadingDialog = null; } } super.run(); }
From source file:com.loftcat.ui.utils.slidingmenu.fragment.MiddleFragment.java
public void setAccount(AccountVo account) { this.account = account; if (x != 0) { title_bar.setVisibility(View.INVISIBLE); title_progressbar.setVisibility(View.VISIBLE); }/*from w ww .j a v a2 s . co m*/ Oauth2AccessToken oauth2AccessToken = new Oauth2AccessToken(account.getToken(), account.getExpires_in()); oauth2AccessToken.setExpiresIn(account.getExpires_in()); utility.setAccessToken(oauth2AccessToken); Log.e("error", "getExpiresTime:" + utility.getAccessToken().getExpiresTime()); statusesAPI = new StatusesAPI(utility.getAccessToken()); // statusesAPI.friendsTimeline(since_id, 0l, 20, count++, false, // FEATURE.ALL, false, new RequestListener() { // // @Override // public void onIOException(IOException arg0) { // Log.d("RESULT", "arg0: || " + arg0); // // } // // @Override // public void onError(WeiboException arg0) { // Log.d("RESULT", "arg0: || " + arg0); // // } // // @Override // public void onComplete(String arg0) { // Message message = new Message(); // message.obj = arg0; // message.what = 1; // hanlder.sendMessage(message); // } // }); friendshipsAPI = new FriendshipsAPI(utility.getAccessToken()); Log.d("RESULT", "friendshipsAPI.groups"); friendshipsAPI.groups(new RequestListener() { @Override public void onIOException(IOException arg0) { Log.d("RESULT", arg0.toString()); } @Override public void onError(WeiboException arg0) { Log.d("RESULT", arg0.toString()); } @SuppressWarnings("unchecked") @Override public void onComplete(String arg0) { JSONObject jsonObject; try { jsonObject = new JSONObject(arg0); JSONArray jsonArray = jsonObject.getJSONArray("lists"); groups = new ArrayList<GroupsVo>(); GroupsVo groupsVo = new GroupsVo(); groupsVo.setName(""); groupsVo.setId(0); groups.add(groupsVo); // ArrayList<GroupsVo> list=; groups.addAll((ArrayList<GroupsVo>) gson.fromJson(jsonArray.toString(), new TypeToken<ArrayList<GroupsVo>>() { }.getType())); // groups.addAll((ArrayList<GroupsVo>) JSONHelper // .parseCollection(jsonArray, ArrayList.class, // GroupsVo.class)); Log.d("RESULT", groups.size() + "size"); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } Message msg = new Message(); msg.what = 10; msg.arg1 = x; hanlder.sendMessage(msg); } }); }
From source file:org.cocos2dx.lib.TextInputWraper.java
public static void closeIMEKeyboard() { Message msg = new Message(); msg.what = HANDLER_CLOSE_IME_KEYBOARD; handler.sendMessage(msg); }
From source file:activities.Activity_Main.java
/** Called when the activity is first created. */ @Override/* www.j ava 2 s .c om*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); myself = this; setContentView(R.layout.activity_home); SP_params = PreferenceManager.getDefaultSharedPreferences(this); SP_prefEditor = SP_params.edit(); Tracer = tracerengine.getInstance(SP_params); //Added by Doume File storage = new File(Environment.getExternalStorageDirectory() + "/domodroid/.conf/"); if (!storage.exists()) storage.mkdirs(); //Configure Tracer tool initial state File logpath = new File(Environment.getExternalStorageDirectory() + "/domodroid/.log/"); if (!logpath.exists()) logpath.mkdirs(); String currlogpath = SP_params.getString("LOGNAME", ""); if (currlogpath.equals("")) { //Not yet existing prefs : Configure debugging by default, to configure Tracer currlogpath = Environment.getExternalStorageDirectory() + "/domodroid/.log/"; SP_prefEditor.putString("LOGPATH", currlogpath); SP_prefEditor.putString("LOGNAME", "Domodroid.txt"); SP_prefEditor.putBoolean("SYSTEMLOG", false); SP_prefEditor.putBoolean("TEXTLOG", false); SP_prefEditor.putBoolean("SCREENLOG", false); SP_prefEditor.putBoolean("LOGCHANGED", true); SP_prefEditor.putBoolean("LOGAPPEND", false); } else { SP_prefEditor.putBoolean("LOGCHANGED", true); //To force Tracer to consider current settings } //prefEditor.putBoolean("SYSTEMLOG", false); // For tests : no system logs.... SP_prefEditor.putBoolean("SYSTEMLOG", true); // For tests : with system logs.... SP_prefEditor.commit(); Tracer.set_profile(SP_params); // Create .nomedia file, that will prevent Android image gallery from showing domodroid file String nomedia = Environment.getExternalStorageDirectory() + "/domodroid/.nomedia"; try { if (!(new File(nomedia).exists())) { new FileOutputStream(nomedia).close(); } } catch (Exception e) { } appname = (ImageView) findViewById(R.id.app_name); LoadSelections(); // Prepare a listener to know when a sync dialog is closed... if (sync_listener == null) { sync_listener = new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { Tracer.d(mytag, "sync dialog has been closed !"); // Is it success or fail ? if (((Dialog_Synchronize) dialog).need_refresh) { // Sync has been successful : Force to refresh current main view Tracer.d(mytag, "sync dialog requires a refresh !"); reload = true; // Sync being done, consider shared prefs are OK VG_parent.removeAllViews(); if (WU_widgetUpdate != null) { WU_widgetUpdate.resync(); } else { Tracer.i(mytag + ".onCreate", "WidgetUpdate is null startCacheengine!"); startCacheEngine(); } Bundle b = new Bundle(); //Notify sync complete to parent Dialog b.putInt("id", 0); b.putString("type", "root"); Message msg = new Message(); msg.setData(b); if (widgetHandler != null) widgetHandler.sendMessage(msg); // That should force to refresh Views /* */ if (WU_widgetUpdate != null) { WU_widgetUpdate.Disconnect(0); //That should disconnect all opened widgets from cache engine //widgetUpdate.dump_cache(); //For debug dont_kill = true; // to avoid engines kill when onDestroy() } onResume(); } else { Tracer.d(mytag, "sync dialog end with no refresh !"); } ((Dialog_Synchronize) dialog).need_refresh = false; } }; } //update thread sbanim = new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == 0) { appname.setImageDrawable(getResources().getDrawable(R.drawable.app_name2)); } else if (msg.what == 1) { appname.setImageDrawable(getResources().getDrawable(R.drawable.app_name3)); } else if (msg.what == 2) { appname.setImageDrawable(getResources().getDrawable(R.drawable.app_name1)); } else if (msg.what == 3) { appname.setImageDrawable(getResources().getDrawable(R.drawable.app_name4)); } else if (msg.what == 8000) { Tracer.e(mytag, "Request to display message : 8000"); /* if(dialog_message == null) { Create_message_box(); } dialog_message.setMessage("Starting cache engine..."); dialog_message.show(); */ } else if (msg.what == 8999) { //Cache engine is ready for use.... if (Tracer != null) Tracer.e(mytag, "Cache engine has notified it's ready !"); cache_ready = true; if (end_of_init_requested) end_of_init(); PG_dialog_message.dismiss(); } } }; //power management final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); this.PM_WakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, ""); this.PM_WakeLock.acquire(); //titlebar final FrameLayout titlebar = (FrameLayout) findViewById(R.id.TitleBar); titlebar.setBackgroundDrawable(Gradients_Manager.LoadDrawable("title", 40)); //Parent view VG_parent = (ViewGroup) findViewById(R.id.home_container); LL_house_map = new LinearLayout(this); LL_house_map .setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); LL_house_map.setOrientation(LinearLayout.HORIZONTAL); LL_house_map.setPadding(5, 5, 5, 5); house = new Basic_Graphical_zone(getApplicationContext(), 0, Graphics_Manager.Names_Agent(this, "House"), "", "house", 0, "", null); house.setPadding(0, 0, 5, 0); map = new Basic_Graphical_zone(getApplicationContext(), 0, Graphics_Manager.Names_Agent(this, "Map"), "", "map", 0, "", null); map.setPadding(5, 0, 0, 0); LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1.0f); house.setLayoutParams(param); house.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (SP_params.getBoolean("SYNC", false)) { loadWigets(0, "root"); historyPosition++; history.add(historyPosition, new String[] { "0", "root" }); } else { if (AD_notSyncAlert == null) createAlert(); AD_notSyncAlert.show(); } } }); map.setLayoutParams(param); map.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (SP_params.getBoolean("SYNC", false)) { //dont_freeze=true; //To avoid WidgetUpdate engine freeze Tracer.w(mytag, "Before call to Map, Disconnect widgets from engine !"); if (WU_widgetUpdate != null) { WU_widgetUpdate.Disconnect(0); //That should disconnect all opened widgets from cache engine //widgetUpdate.dump_cache(); //For debug dont_kill = true; // to avoid engines kill when onDestroy() } INTENT_map = new Intent(Activity_Main.this, Activity_Map.class); Tracer.d(mytag, "Call to Map, run it now !"); Tracer.Map_as_main = false; startActivity(INTENT_map); } else { if (AD_notSyncAlert == null) createAlert(); AD_notSyncAlert.show(); } } }); LL_house_map.addView(house); LL_house_map.addView(map); init_done = false; // Detect if it's the 1st use after installation... if (!SP_params.getBoolean("SPLASH", false)) { // Yes, 1st use ! init_done = false; reload = false; if (backupprefs.exists()) { // A backup exists : Ask if reload it Tracer.v(mytag, "settings backup found after a fresh install..."); DialogInterface.OnClickListener reload_listener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Tracer.e(mytag, "Reload dialog returns : " + which); if (which == dialog.BUTTON_POSITIVE) { reload = true; } else if (which == dialog.BUTTON_NEGATIVE) { reload = false; } check_answer(); dialog.dismiss(); } }; dialog_reload = new AlertDialog.Builder(this); dialog_reload.setMessage(getText(R.string.home_reload)); dialog_reload.setTitle(getText(R.string.reload_title)); dialog_reload.setPositiveButton(getText(R.string.reloadOK), reload_listener); dialog_reload.setNegativeButton(getText(R.string.reloadNO), reload_listener); dialog_reload.show(); init_done = false; //A choice is pending : Rest of init has to be completed... } else { //No settings backup found Tracer.v(mytag, "no settings backup found after fresh install..."); end_of_init_requested = true; // open server config view Intent helpI = new Intent(Activity_Main.this, Preference.class); startActivity(helpI); } } else { // It's not the 1st use after fresh install // This method will be followed by 'onResume()' end_of_init_requested = true; } if (SP_params.getBoolean("SYNC", false)) { //A config exists and a sync as been done by past. if (WU_widgetUpdate == null) { Tracer.i(mytag + ".onCreate", "Params splach is false and WidgetUpdate is null startCacheengine!"); startCacheEngine(); } } Tracer.e(mytag, "OnCreate() complete !"); // End of onCreate (UIThread) }