private void cacheHidenSubtitle() { if (getTag() == null || !(getTag() instanceof Element)) return; Element currElement = (Element) getTag(); long currTime = getCurrentTime(); long endTime = currElement.getEndTime().getTime(); if (currTime >= endTime + SUBTITLE_DELAY_TIME_MAX / 10) { // for Fast Forward mHandler.removeCallbacksAndMessages(null); mHandler.sendEmptyMessage(MESSAGE_SUBTITLE_START); } else { if (endTime - currTime > SUBTITLE_DELAY_TIME_MAX) { Element preElement = getElement(currTime); if (preElement != null && preElement.getStartTime().getTime() < endTime - SUBTITLE_DELAY_TIME_MAX) { // for Fast back mHandler.removeCallbacksAndMessages(null); mHandler.sendEmptyMessage(MESSAGE_SUBTITLE_START); return; } mHandler.sendEmptyMessageDelayed(MESSAGE_SUBTITLE_HIDEN_CACHE, SUBTITLE_DELAY_TIME_MAX); } else { mHandler.sendEmptyMessageDelayed(MESSAGE_SUBTITLE_END_HIDEN, endTime - currTime); } } }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.address_tv: break; case R.id.priceinfo_tv: break; case R.id.bedinfo_tv: break; case R.id.infolong_tv: break; case R.id.service_tv: break; case R.id.contactway_tv: break; case R.id.common_title_left: finish(); break; case R.id.common_title_right: // 收藏或者已收藏 if (store) { // 删除数据库保存 ZhaopinDBHelper.getInstance(context).deleteZhaopin(zhaopindetailbean); handler.sendEmptyMessage(UNCHOOSE); } else { // 插入数据库 ZhaopinDBHelper.getInstance(context).addZhaopin(zhaopindetailbean); handler.sendEmptyMessage(CHOOSE); } break; default: break; } }
@Override public synchronized void run() { try { Log.d(TAG, "Starting"); // If anything needs to be obtained using the network, get it now. // This greatly reduces the complexity of seamless handover, which // tries to recreate the tunnel without shutting down everything. // In this mode, all we need to know is the server address. InetSocketAddress server = new InetSocketAddress(serverAddress, Integer.parseInt(serverPort)); // We try to create the tunnel for several times. for (int attempt = 0; attempt < CONNECTION_RETRY_COUNT; ++attempt) { handler.sendEmptyMessage(R.string.connecting); // Reset the counter if we were connected. if (run(server)) { attempt = 0; } // Sleep for a while. This also checks if we got interrupted. Thread.sleep(CONNECTION_WAIT_TIMOUT); } Log.d(TAG, "Giving up"); } catch (InterruptedException e) { Log.e(TAG, "VPN thread interrupted " + e); } finally { try { fileDescriptor.close(); } catch (IOException e) { Log.e(TAG, "FileDescriptor close failed " + e); } fileDescriptor = null; vpnParameters = null; handler.sendEmptyMessage(R.string.disconnected); Log.d(TAG, "Exiting"); } }
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { // TODO Auto-generated method stub switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: flingX = (int) ev.getRawX(); flingY = (int) ev.getRawY(); break; case MotionEvent.ACTION_MOVE: break; case MotionEvent.ACTION_UP: int tmp = (int) ev.getRawX(); int tmpy = (int) ev.getRawY(); if (Math.abs(tmpy - flingY) <= 100) { if (flingX - tmp > 100) { isFling = true; mHandler.sendEmptyMessage(MessageID.MESSAGE_FLING_NEXT); } else if (tmp - flingX > 100) { isFling = true; mHandler.sendEmptyMessage(MessageID.MESSAGE_FLING_PRE); } else { isFling = false; } } else { isFling = false; } break; } return super.onInterceptTouchEvent(ev); }
public void init() { context = ZhaopinDetailActivity.this; title_left = (ImageView) findViewById(R.id.common_title_left); title_right = (ImageView) findViewById(R.id.common_title_right); title_mid = (TextView) findViewById(R.id.common_title_mid); title_left.setOnClickListener(this); title_right.setOnClickListener(this); wv = (WebView) findViewById(R.id.wv); progress = (ProgressBar) findViewById(R.id.progress); ZhaopinDetailBean temp = ZhaopinDBHelper.getInstance(context).getZhaopin(zhaopinbasebean.getUrl()); if (temp == null) { store = false; handler.sendEmptyMessage(UNCHOOSE); } else { store = true; handler.sendEmptyMessage(CHOOSE); zhaopindetailbean = temp; } if (store) { wv.loadData(zhaopindetailbean.getContent(), "text/html", "UTF-8"); } else { getData(zhaopinbasebean); } }
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { adapter.swapCursor(cursor); if (isDualPane) { if (cursor.moveToFirst()) { /** If list is not empty, trying to restore previously displayed details. */ restoreHandler.sendEmptyMessage(0); } else { /** If list became empty, removing previously displayed details */ removeDetailsHandler.sendEmptyMessage(0); } } /** If there is no sync going and list is empty, refreshing list. */ Account account = AccountService.getAccount(); if (account != null) { boolean syncActive = ContentResolver.isSyncActive(account, Contract.CONTENT_AUTHORITY); boolean syncPending = ContentResolver.isSyncPending(account, Contract.CONTENT_AUTHORITY); if (!cursor.moveToFirst() && firstLoad && !(syncActive || syncPending)) { refreshList(); } } firstLoad = false; setRefreshIndicationState(updateManager.isUpdating(UpdateManager.UpdateType.ALARMS)); }
public void onComplete(final String response, final Object state) { // Log.d(tag, " onComplete()"); JSONObject jobj; try { jobj = new JSONObject(response); final String picURL = jobj.getJSONObject("picture") .getJSONObject("data") .getString("url") .replaceFirst("^https", "http"); Fb fb = Fb.getInstance(); fb.setUserName(jobj.getString("name")); fb.setUserUID(jobj.getString("id")); fb.setUserPicNotAvailable(); handler.sendEmptyMessage(1); // User info update Bitmap userpic_bitmap = Utility.getBitmap(picURL); if (null == userpic_bitmap) return; try { FileOutputStream fos = new FileOutputStream(fb.getUserPicFilename()); userpic_bitmap.compress(CompressFormat.JPEG, 100, fos); } catch (FileNotFoundException e) { e.printStackTrace(); } fb.setUserPicAvailable(); handler.sendEmptyMessage(1); // User info update } catch (JSONException e) { e.printStackTrace(); } }
@Override public void run() { // Needed to close the ProgressDialog. Looper.prepare(); try { // example file name: sms_backup_2012-05-23_133700.xml String dateStr = DateFormat.format("yyyy-MM-dd_hhmmss", System.currentTimeMillis()).toString(); File backupFile = new File(getExternalFilesDir(null), "sms_backup_" + dateStr + ".xml"); OutputStream out = new FileOutputStream(backupFile); SmsWriter backupCreator = new XmlSmsWriter(); backupCreator.setOutputstream(out); backupCreator.startBackup(); backupSms(SmsFolder.INBOX, backupCreator); backupSms(SmsFolder.OUTBOX, backupCreator); backupCreator.finishBackup(); out.close(); handler.sendEmptyMessage(HANDLER_WHAT_SUCCESSFULL); } catch (IOException e) { handler.sendEmptyMessage(HANDLER_WHAT_ERROR_MESSAGE); Log.e(TAG, getString(R.string.error_cant_write_file), e); } finally { handler.sendEmptyMessage(HANDLER_WHAT_CLOSE_PROGRESS_DIALOG); Looper.myLooper().quit(); } }
private void setApplicationData() { final String[] from = new String[] {"appname", "pname"}; final int[] to = new int[] {android.R.id.text1, android.R.id.text2}; List<Map<String, Object>> mSysData = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> mLocalData = new ArrayList<Map<String, Object>>(); PackageManager pm = getPackageManager(); List<PackageInfo> pal = pm.getInstalledPackages(0); for (int i = 0, size = pal.size(); i < size; i++) { PackageInfo p = pal.get(i); ApplicationInfo ai = p.applicationInfo; HashMap<String, Object> map = new HashMap<String, Object>(); map.put(from[0], ai.loadLabel(pm).toString()); map.put(from[1], p.packageName); if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) > 0) { mSysData.add(map); } else { mLocalData.add(map); } } if (!mSysData.isEmpty()) { mHandler.sendEmptyMessage(1); mSysLv.setAdapter( new SimpleAdapter(this, mSysData, android.R.layout.simple_list_item_2, from, to)); } if (!mLocalData.isEmpty()) { mHandler.sendEmptyMessage(2); mLocalLv.setAdapter( new SimpleAdapter(this, mLocalData, android.R.layout.simple_list_item_2, from, to)); } mHandler.sendEmptyMessage(0); }
@Override public void onPrepared(MediaPlayer mp) { if (isPrepare) { if (playType == PLAY_TYPE_LOD || playType == PLAY_TYPE_ONDEMAND) { // TODO 数据库操作 记忆续播 MPConPlayManager cPm = MPConPlayUtils.findConnectionPlay(currentPosition, parentName, getChildName()); if (cPm != null && cPm.getEpisodePos() == currentPosition && cPm.getPlayIndex() != 0) { mp.seekTo(cPm.getPlayIndex()); } mHandler.sendEmptyMessage(SHOW_CONTROL_ANIMATION); } mp.start(); isPrepare = false; if (mDialog != null && mDialog.isShowing()) { mDialog.dismiss(); } // 判断是否是本地播放或在线点播 if (playType == PLAY_TYPE_LOD || playType == PLAY_TYPE_ONDEMAND) { if (mp.isPlaying() && !mSeekBar.isPressed()) { mHandler.sendEmptyMessage(UPDATA_PLAY_TIME); } } mProgressBar.setVisibility(View.INVISIBLE); mPlayer.setScreenOnWhilePlaying(true); } }
private void fillData(String result) { DealData dealData = null; try { dealData = GsonUtil.json2bean(result, DealData.class); ArrayList<Deal> deals = dealData.getData().getDeals(); if (isRefresh) { mAllDeals.clear(); convenientBanner.setcurrentitem(0); } mAllDeals.addAll(deals); if (newsListAdapter == null) { newsListAdapter = new TabListAdapter(mContext, mAllDeals); home_Xlistview.setAdapter(newsListAdapter); } else { newsListAdapter.setData(mAllDeals); newsListAdapter.notifyDataSetChanged(); } mHandler.sendEmptyMessage(MSG_STOP_REFRESH); home_Xlistview.setVisibility(View.VISIBLE); hideBaseLoading(); } catch (Exception e) { hideBaseLoading(); if (mAllDeals.size() == 0 && !isRefresh) { showLoadingError(); } else { mHandler.sendEmptyMessage(MSG_STOP_REFRESH); ToastUtil.showToast(mContext, "亲,加载错误啦,请重试."); } e.printStackTrace(); } }
private boolean checkSdCard() { // check sdcard space if (Util.isSdcardAvailable(this)) { File f = new File(mPath); if (f.exists()) { long insufficientSpace = Util.getExtraSpaceNeeded(this, (long) (1.5 * f.length())); if (insufficientSpace < 0) { if (mHandler != null) { mHandler.sendEmptyMessage(SystemUpdateService.MSG_SDCARDINSUFFICENT); } return false; } } else { if (mHandler != null) { mHandler.sendEmptyMessage(SystemUpdateService.MSG_SDCARDPACKAGEINVALIDATE); } } } else { if (mHandler != null) { mHandler.sendEmptyMessage(SystemUpdateService.MSG_SDCARDUNKNOWNERROR); } else { mDownloadInfo.resetDownloadInfo(); } return false; } return true; }
@Override public void run() { // TODO Auto-generated method stub LognAndSign logn = new LognAndSign(); ReturnMessage result = logn.Logn(name, password); // 得到登陸的結果 /*if (result != ReturnMessage.Success) {//如果不成功 if (result == ReturnMessage.UserNameRepeat) {//用戶名重複 handler.sendEmptyMessage(0x88); } else { handler.sendEmptyMessage(0x99); } } else { handler.sendEmptyMessage(0x22); }*/ switch (result) { case InternetError: handler.sendEmptyMessage(0x11); break; case ParseError: handler.sendEmptyMessage(0x99); break; case ServerError: handler.sendEmptyMessage(0x33); break; case Success: handler.sendEmptyMessage(0x22); break; case UserNameRepeat: handler.sendEmptyMessage(0x88); break; } }
/** * Sets the current state and notifies listeners, if necessary. * * @param stateFlags The state flags. */ private void setStateLocked(int stateFlags) { final boolean enabled = (stateFlags & STATE_FLAG_ACCESSIBILITY_ENABLED) != 0; final boolean touchExplorationEnabled = (stateFlags & STATE_FLAG_TOUCH_EXPLORATION_ENABLED) != 0; final boolean highTextContrastEnabled = (stateFlags & STATE_FLAG_HIGH_TEXT_CONTRAST_ENABLED) != 0; final boolean wasEnabled = mIsEnabled; final boolean wasTouchExplorationEnabled = mIsTouchExplorationEnabled; final boolean wasHighTextContrastEnabled = mIsHighTextContrastEnabled; // Ensure listeners get current state from isZzzEnabled() calls. mIsEnabled = enabled; mIsTouchExplorationEnabled = touchExplorationEnabled; mIsHighTextContrastEnabled = highTextContrastEnabled; if (wasEnabled != enabled) { mHandler.sendEmptyMessage(MyHandler.MSG_NOTIFY_ACCESSIBILITY_STATE_CHANGED); } if (wasTouchExplorationEnabled != touchExplorationEnabled) { mHandler.sendEmptyMessage(MyHandler.MSG_NOTIFY_EXPLORATION_STATE_CHANGED); } if (wasHighTextContrastEnabled != highTextContrastEnabled) { mHandler.sendEmptyMessage(MyHandler.MSG_NOTIFY_HIGH_TEXT_CONTRAST_STATE_CHANGED); } }
/* * (non-Javadoc) * * @see com.gizwits.framework.activity.BaseActivity#didSetDeviceWifi(int, * com.xtremeprog.xpgconnect.XPGWifiDevice) */ @Override protected void didSetDeviceWifi(int error, XPGWifiDevice device) { if (error == 0) { handler.sendEmptyMessage(handler_key.CONFIG_SUCCESS.ordinal()); } else { handler.sendEmptyMessage(handler_key.CONFIG_FAILED.ordinal()); } }
@Override public void callBackPlaybackVideoData( byte[] videobuf, int h264Data, int len, int width, int height, int time, int frameType, int originframeLen) { // TODO Auto-generated method stub i1++; if (exit == false) { exit = true; new MyThread().start(); } this.time = time; videodata = videobuf; videoDataLen = len; nVideoWidth = width; nVideoHeight = height; time1 = this.time * 1000; timeShow = setDeviceTime(time1, tzStr); if (h264Data == 1) { // H264 mHandler.sendEmptyMessage(1); } else { // MJPEG mHandler.sendEmptyMessage(2); } /// 音频数据 if (h264Data == 0 && frameType == 6) { // Log.e("vst ", "h264Data == 0 && FrameType == 6 "); /* * if (!isOpen) { StartAudio(); isOpen = true; } */ if (!audioPlayer.isAudioPlaying()) { return; } CustomBufferHead head = new CustomBufferHead(); CustomBufferData data = new CustomBufferData(); head.length = len; // Log.e("vst ", "h264Data == 0 && FrameType == 6 " + "len" + len); head.startcode = AUDIO_BUFFER_START_CODE; data.head = head; data.data = videobuf; AudioBuffer.addData(data); Message msg = new Message(); Bundle b = new Bundle(); b.putInt("oneFramesize", originframeLen); msg.setData(b); return; } }
private PicasaSyncManager(Context context) { mHasWifiConnectivity = false; mIsRoaming = false; mIsPlugged = false; mBackgroundData = false; mSyncRequests = new ArrayList(); mContext = context.getApplicationContext(); mFacade = PicasaFacade.get(mContext); mSyncHelper = PicasaSyncHelper.getInstance(mContext); HandlerThread handlerthread = new HandlerThread("picasa-sync-manager", 10); handlerthread.start(); mSyncHandler = new Handler(handlerthread.getLooper()) { public final void handleMessage(Message message) { switch (message.what) { case 1: access$200(); break; case 2: access$300(); break; case 3: updateTasksInternal(); break; case 4: mSyncHelper.syncAccounts(mFacade.getAuthority()); break; case 5: access$400((Boolean) message.obj); break; case 6: access$100(); break; default: throw new AssertionError( (new StringBuilder("unknown message: ")).append(message.what).toString()); } } }; mSyncHandler.sendEmptyMessage(6); mSyncHandler.sendEmptyMessage(4); mSyncHandler.sendEmptyMessage(2); mSyncHandler.sendEmptyMessage(5); OnAccountsUpdateListener onaccountsupdatelistener = new OnAccountsUpdateListener() { public final void onAccountsUpdated(Account aaccount[]) { Log.i("gp.PicasaSyncManager", "account change detect - update database"); mSyncHandler.sendEmptyMessage(4); } }; AccountManager.get(mContext) .addOnAccountsUpdatedListener(onaccountsupdatelistener, null, false); }
private void showFloat(boolean isShow) { System.out.println("------" + isShow); if (isShow) { mHandler.sendEmptyMessage(MSG_SHOW); mIsShow = true; } else { mHandler.sendEmptyMessage(MSG_HIDE); mIsShow = false; } }
private void requestToken() { final Parameters params = new Parameters(); params.put("oauth_callback", callback); final String method = "GET"; OAuth.signOAuth( host, pathRequest, method, https, params, null, null, consumerKey, consumerSecret); final HttpResponse response = Network.getRequest(getUrlPrefix() + host + pathRequest, params); if (Network.isSuccess(response)) { final String line = Network.getResponseData(response); int status = STATUS_ERROR; if (StringUtils.isNotBlank(line)) { assert line != null; final MatcherWrapper paramsMatcher1 = new MatcherWrapper(paramsPattern1, line); if (paramsMatcher1.find()) { OAtoken = paramsMatcher1.group(1); } final MatcherWrapper paramsMatcher2 = new MatcherWrapper(paramsPattern2, line); if (paramsMatcher2.find()) { OAtokenSecret = paramsMatcher2.group(1); } if (StringUtils.isNotBlank(OAtoken) && StringUtils.isNotBlank(OAtokenSecret)) { setTempTokens(OAtoken, OAtokenSecret); try { final Parameters paramsBrowser = new Parameters(); paramsBrowser.put("oauth_token", OAtoken); final String encodedParams = EntityUtils.toString(new UrlEncodedFormEntity(paramsBrowser)); startActivity( new Intent( Intent.ACTION_VIEW, Uri.parse(getUrlPrefix() + host + pathAuthorize + "?" + encodedParams))); status = STATUS_SUCCESS; } catch (ParseException e) { Log.e("OAuthAuthorizationActivity.requestToken", e); } catch (IOException e) { Log.e("OAuthAuthorizationActivity.requestToken", e); } } } requestTokenHandler.sendEmptyMessage(status); } else { final String extErrMsg = getExtendedErrorMsg(response); if (StringUtils.isNotBlank(extErrMsg)) { final Message msg = requestTokenHandler.obtainMessage(STATUS_ERROR_EXT_MSG, extErrMsg); requestTokenHandler.sendMessage(msg); } else { requestTokenHandler.sendEmptyMessage(STATUS_ERROR); } } }
protected void didRequestSendPhoneSMSCode(int result, java.lang.String errorMessage) { Log.e("AppTest", result + ", " + errorMessage); if (result == 0) { // 发送成功 handler.sendEmptyMessage(FINISH); } else if (result == 9037) { handler.sendEmptyMessage(TOAST2); } else if (result == 9015) { // 发送失败 handler.sendEmptyMessage(TOAST1); handler.sendEmptyMessage(CaptchaCode); } }
@Override public int onStartCommand(Intent intent, int flags, int startId) { super.onStartCommand(intent, flags, startId); Utility.checkSelfAllPermissions(this); if (!Utility.hasPermission(Utility.PERMISSION_COARSE_LOCATION) && !Utility.hasPermission(Utility.PERMISSION_FINE_LOCATION)) { if (mHandler != null) mHandler.sendEmptyMessage(MSG_STOP_SELF); return START_NOT_STICKY; } PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); if (DEBUG) Log.d(TAG, "Service has received start id " + startId + ": " + intent); mReturnAddress = intent.getStringExtra("return_address"); if (mReturnAddress == null || mReturnAddress.isEmpty()) { Log.e(TAG, "Lack return address"); return START_NOT_STICKY; } mPrecise = intent.getIntExtra("precise", 10); mTrack = intent.getIntExtra("track", 1); if (mPrecise <= 0) mPrecise = 1; if (mPrecise >= 20) mPrecise = 20; if (mTrack <= 0) mTrack = 1; else if ((mTrack * mPrecise) > 240) mTrack = 240 / mPrecise; if (DEBUG) Log.d(TAG, "Precise " + mPrecise + ", Track " + mTrack); mReceiver = new MyReceiver(); IntentFilter filter = new IntentFilter(Utility.ACTION_STOP_BACKGROUND); registerReceiver(mReceiver, filter); synchronized (mLock) { if (mThread != null) return START_NOT_STICKY; mThread = new HandlerThread("H1"); mThread.start(); mStartTime = 0; if (DEBUG) Log.d(TAG, "thread started"); mHandler = new Handler(mThread.getLooper(), this); mHandler.sendEmptyMessage(MSG_GET_LOCATION); // Need keep wake until the location is updated. if (Utility.hasPermission(Utility.PERMISSION_WAKE_LOCK)) { mWakelock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "WRU"); mWakelock.acquire(); } doReportStart(); } // We want this service to continue running until it is explicitly // stopped, so return sticky. return START_STICKY; }
@Override public void success(Object o, Response response) { ResponseData responseData = (ResponseData) o; UpdatePreference(responseData.cityName.toString().toLowerCase(), responseData); if (IsInfosUpdated()) { if (mScreenHandler != null) { mScreenHandler.sendEmptyMessage(Constants.kmiHANDLER_DATA_READY); } } else { mScreenHandler.sendEmptyMessage(Constants.kmiHANDLER_UPDATE_PROGRESS); } }
@Override public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what) { case 1: setmap(urlstr); calssAdapter = new CalssAdapter(array, ReplyPhoto.this); calss.setAdapter(calssAdapter); break; case 2: Toast.makeText(ReplyPhoto.this, "获取分类失败,请检查网络", Toast.LENGTH_SHORT).show(); break; case 3: Toast.makeText(ReplyPhoto.this, "暂无分类", Toast.LENGTH_SHORT).show(); break; case 4: dialog.dismiss(); Toast.makeText(ReplyPhoto.this, "失败", Toast.LENGTH_SHORT).show(); break; case 5: dialog.dismiss(); JSONObject jsonObject = JSON.parseObject(str); int a = jsonObject.getIntValue("ret"); if (a == 200) { JSONObject jsonObject1 = jsonObject.getJSONObject("data"); int b = jsonObject1.getIntValue("code"); if (b == 0) { // Bimp.tempSelectBitmap.clear(); Bimp.tempSelectBitmap.clear(); Bimp.max = 0; Intent intent = new Intent("data.broadcast.action"); sendBroadcast(intent); for (int i = 0; i < PublicWay.activityList.size(); i++) { if (null != PublicWay.activityList.get(i)) { PublicWay.activityList.get(i).finish(); } } // finish(); Intent intent1 = new Intent(); intent1.setAction("com.servicedemo4"); intent1.putExtra("getmeeage", "4"); ReplyPhoto.this.sendBroadcast(intent1); } else { handlers.sendEmptyMessage(4); } } else { handlers.sendEmptyMessage(4); } break; } }
public void getLocationByWifi() { WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); String mac = wifiManager.getConnectionInfo().getBSSID(); if (mac == null) { return; } DefaultHttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("http://www.google.com/loc/json"); JSONObject holder = new JSONObject(); try { holder.put("version", "1.1.0"); holder.put("host", "maps.google.com"); JSONObject data; JSONArray array = new JSONArray(); data = new JSONObject(); data.put("mac_address", mac); data.put("signal_strength", 8); data.put("age", 0); array.put(data); holder.put("wifi_towers", array); StringEntity se = new StringEntity(holder.toString()); post.setEntity(se); HttpResponse resp = client.execute(post); int state = resp.getStatusLine().getStatusCode(); if (state == HttpStatus.SC_OK) { HttpEntity entity = resp.getEntity(); if (entity != null) { BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent())); StringBuffer sb = new StringBuffer(); String resute = ""; while ((resute = br.readLine()) != null) { sb.append(resute); } br.close(); data = new JSONObject(sb.toString()); data = (JSONObject) data.get("location"); getAddress(String.valueOf(data.get("latitude")), String.valueOf(data.get("longitude"))); } else { handler.sendEmptyMessage(MESSAGE_OVER); } } else { handler.sendEmptyMessage(MESSAGE_OVER); } } catch (Exception e) { handler.sendEmptyMessage(MESSAGE_OVER); } }
public void onRotationChangedLocked(DisplayContent displayContent, int rotation) { if (DEBUG_ROTATION) { Slog.i( LOG_TAG, "Rotaton: " + Surface.rotationToString(rotation) + " displayId: " + displayContent.getDisplayId()); } /// M:[ALPS01397351]Fix system server JE @{ // mMagnifedViewport.onRotationChangedLocked(); mHandler.sendEmptyMessage(MyHandler.MESSAGE_ON_ROTATION_CHANGED); /// @} mHandler.sendEmptyMessage(MyHandler.MESSAGE_NOTIFY_ROTATION_CHANGED); }
@Override public void onQueryFail(int type, WDTException wdtEx) { if (null == wdtEx) { mHandler.sendEmptyMessage(type); return; } switch (wdtEx.getStatus()) { case 1064: mHandler.sendEmptyMessage(HandlerCases.QUERY_FAIL); break; default: break; } }
/** 画面にタッチされたとき */ public boolean onTouch(View v, MotionEvent event) { if (v == titleView) { handler.sendEmptyMessage(1); player.stop(); sePool.play(map.get(R.raw.click), 0.5f, 0.5f, 0, 0, 1.0f); } else if (v == endView) { handler.sendEmptyMessage(0); player.stop(); sePool.play(map.get(R.raw.click), 0.5f, 0.5f, 0, 0, 1.0f); } return false; }
@Override public void onRefresh() { if (onRefresh_number) { if (Tools.isConnect(getApplicationContext())) { onRefresh_number = false; buttonClick(); } else { onLoad(); onRefresh_number = true; handler.sendEmptyMessage(2); } } else { handler.sendEmptyMessage(3); } }
@Override protected void onResume() { super.onResume(); if (mPhone != null && !Utils.isWifiOnly(getApplicationContext())) { mPhoneStateReceiver.registerIntent(); updateSignalStrength(); updateServiceState(mPhone.getServiceState()); updateDataState(); mTelephonyManager.listen( mPhoneStateListener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE); if (mShowLatestAreaInfo) { registerReceiver( mAreaInfoReceiver, new IntentFilter(CB_AREA_INFO_RECEIVED_ACTION), CB_AREA_INFO_SENDER_PERMISSION, null); // Ask CellBroadcastReceiver to broadcast the latest area info received Intent getLatestIntent = new Intent(GET_LATEST_CB_AREA_INFO_ACTION); sendBroadcastAsUser(getLatestIntent, UserHandle.ALL, CB_AREA_INFO_SENDER_PERMISSION); } } registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); mHandler.sendEmptyMessage(EVENT_UPDATE_STATS); }
@Override public void showWithoutParse(String URI) throws RemoteException { Log.v(TAG, "Showing playing URI " + URI); // Show an URI without interrupting/losing the current stream if (!mLibVLC.isPlaying()) return; mEventManager.addHandler(mEventHandler); mMediaList.clear(); mPrevious.clear(); // Prevent re-parsing the media, which would mean losing the connection mCurrentMedia = new Media( getApplicationContext(), URI, 0, 0, Media.TYPE_AUDIO, null, URI, VLCApplication.getAppContext().getString(R.string.unknown_artist), VLCApplication.getAppContext().getString(R.string.unknown_genre), VLCApplication.getAppContext().getString(R.string.unknown_album), 0, 0, "", -1, -1); mMediaList.add(mCurrentMedia); // Notify everyone mHandler.sendEmptyMessage(SHOW_PROGRESS); showNotification(); executeUpdate(); }