List of usage examples for java.util Timer schedule
public void schedule(TimerTask task, Date time)
From source file:org.apache.flink.runtime.state.StateBackendTestBase.java
/** * Tests {@link ValueState#value()} and {@link InternalKvState#getSerializedValue(byte[])} * accessing the state concurrently. They should not get in the way of each * other.//from w w w . j a v a 2s .com */ @Test @SuppressWarnings("unchecked") public void testValueStateRace() throws Exception { final AbstractKeyedStateBackend<Integer> backend = createKeyedBackend(IntSerializer.INSTANCE); final Integer namespace = 1; final ValueStateDescriptor<String> kvId = new ValueStateDescriptor<>("id", String.class); kvId.initializeSerializerUnlessSet(new ExecutionConfig()); final TypeSerializer<Integer> keySerializer = IntSerializer.INSTANCE; final TypeSerializer<Integer> namespaceSerializer = IntSerializer.INSTANCE; final TypeSerializer<String> valueSerializer = kvId.getSerializer(); final ValueState<String> state = backend.getPartitionedState(namespace, IntSerializer.INSTANCE, kvId); @SuppressWarnings("unchecked") final InternalKvState<Integer> kvState = (InternalKvState<Integer>) state; /** * 1) Test that ValueState#value() before and after * KvState#getSerializedValue(byte[]) return the same value. */ // set some key and namespace final int key1 = 1; backend.setCurrentKey(key1); kvState.setCurrentNamespace(2); state.update("2"); assertEquals("2", state.value()); // query another key and namespace assertNull( getSerializedValue(kvState, 3, keySerializer, namespace, IntSerializer.INSTANCE, valueSerializer)); // the state should not have changed! assertEquals("2", state.value()); // re-set values kvState.setCurrentNamespace(namespace); /** * 2) Test two threads concurrently using ValueState#value() and * KvState#getSerializedValue(byte[]). */ // some modifications to the state final int key2 = 10; backend.setCurrentKey(key2); assertNull(state.value()); assertNull( getSerializedValue(kvState, key2, keySerializer, namespace, namespaceSerializer, valueSerializer)); state.update("1"); final CheckedThread getter = new CheckedThread("State getter") { @Override public void go() throws Exception { while (!isInterrupted()) { assertEquals("1", state.value()); } } }; final CheckedThread serializedGetter = new CheckedThread("Serialized state getter") { @Override public void go() throws Exception { while (!isInterrupted() && getter.isAlive()) { final String serializedValue = getSerializedValue(kvState, key2, keySerializer, namespace, namespaceSerializer, valueSerializer); assertEquals("1", serializedValue); } } }; getter.start(); serializedGetter.start(); // run both threads for max 100ms Timer t = new Timer("stopper"); t.schedule(new TimerTask() { @Override public void run() { getter.interrupt(); serializedGetter.interrupt(); this.cancel(); } }, 100); // wait for both threads to finish try { // serializedGetter will finish if its assertion fails or if // getter is not alive any more serializedGetter.sync(); // if serializedGetter crashed, getter will not know -> interrupt just in case getter.interrupt(); getter.sync(); t.cancel(); // if not executed yet } finally { // clean up backend.dispose(); } }
From source file:org.apache.hadoop.util.Shell.java
/** Run a command */ private void runCommand() throws IOException { ProcessBuilder builder = new ProcessBuilder(getExecString()); Timer timeOutTimer = null; ShellTimeoutTimerTask timeoutTimerTask = null; timedOut = new AtomicBoolean(false); completed = new AtomicBoolean(false); if (environment != null) { builder.environment().putAll(this.environment); }//w w w. ja va 2 s. c om if (dir != null) { builder.directory(this.dir); } builder.redirectErrorStream(redirectErrorStream); if (Shell.WINDOWS) { synchronized (WindowsProcessLaunchLock) { // To workaround the race condition issue with child processes // inheriting unintended handles during process launch that can // lead to hangs on reading output and error streams, we // serialize process creation. More info available at: // http://support.microsoft.com/kb/315939 process = builder.start(); } } else { process = builder.start(); } if (timeOutInterval > 0) { timeOutTimer = new Timer("Shell command timeout"); timeoutTimerTask = new ShellTimeoutTimerTask(this); //One time scheduling. timeOutTimer.schedule(timeoutTimerTask, timeOutInterval); } final BufferedReader errReader = new BufferedReader(new InputStreamReader(process.getErrorStream())); BufferedReader inReader = new BufferedReader(new InputStreamReader(process.getInputStream())); final StringBuffer errMsg = new StringBuffer(); // read error and input streams as this would free up the buffers // free the error stream buffer Thread errThread = new Thread() { @Override public void run() { try { String line = errReader.readLine(); while ((line != null) && !isInterrupted()) { errMsg.append(line); errMsg.append(System.getProperty("line.separator")); line = errReader.readLine(); } } catch (IOException ioe) { LOG.warn("Error reading the error stream", ioe); } } }; try { errThread.start(); } catch (IllegalStateException ise) { } try { parseExecResult(inReader); // parse the output // clear the input stream buffer String line = inReader.readLine(); while (line != null) { line = inReader.readLine(); } // wait for the process to finish and check the exit code exitCode = process.waitFor(); try { // make sure that the error thread exits errThread.join(); } catch (InterruptedException ie) { LOG.warn("Interrupted while reading the error stream", ie); } completed.set(true); //the timeout thread handling //taken care in finally block if (exitCode != 0) { throw new ExitCodeException(exitCode, errMsg.toString()); } } catch (InterruptedException ie) { throw new IOException(ie.toString()); } finally { if (timeOutTimer != null) { timeOutTimer.cancel(); } // close the input stream try { // JDK 7 tries to automatically drain the input streams for us // when the process exits, but since close is not synchronized, // it creates a race if we close the stream first and the same // fd is recycled. the stream draining thread will attempt to // drain that fd!! it may block, OOM, or cause bizarre behavior // see: https://bugs.openjdk.java.net/browse/JDK-8024521 // issue is fixed in build 7u60 InputStream stdout = process.getInputStream(); synchronized (stdout) { inReader.close(); } } catch (IOException ioe) { LOG.warn("Error while closing the input stream", ioe); } try { if (!completed.get()) { errThread.interrupt(); errThread.join(); } } catch (InterruptedException ie) { LOG.warn("Interrupted while joining errThread"); } try { InputStream stderr = process.getErrorStream(); synchronized (stderr) { errReader.close(); } } catch (IOException ioe) { LOG.warn("Error while closing the error stream", ioe); } process.destroy(); lastTime = Time.now(); } }
From source file:com.github.vatbub.tictactoe.view.Main.java
private void reloadImage(ImageView imageView, String imageURL, double newWidth, double newHeight) { if (loadTimerMap.get(imageURL) != null) { loadTimerMap.get(imageURL).cancel(); }// w w w .ja v a 2 s . c om Timer loadTimer = new Timer(); loadTimerMap.put(imageURL, loadTimer); loadTimer.schedule(new TimerTask() { @Override public void run() { Image image = new Image(imageURL, newWidth, newHeight, false, true); Platform.runLater(() -> imageView.setImage(image)); } }, 300); }
From source file:com.gizwits.smartlight.activity.MainListActivity.java
/** * Inits the events./* w w w. j a v a 2 s . com*/ */ private void initEvents() { ivMenu.setOnClickListener(this); tvTitle.setOnClickListener(this); llFooter.setOnClickListener(this); tvEditSceneName.setOnClickListener(this); iftttButton.setOnClickListener(this); iftttButton.setClickable(false); // etGroup.setOnClickListener(this); //For lightness moveStep1 = (float) (((float) screenWidth / (float) 254) * 0.8); //For Hue moveStep2 = (float) (((float) screenWidth / (float) 65279) * 0.8); //For saturation moveStep3 = (float) (((float) screenWidth / (float) 254) * 0.8); lvDevice.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (!mAdapter.getItem(position).isOnline()) return; if (mAdapter.getChoosedPos() == position) { mView.toggle(); return; } mAdapter.setChoosedPos(position); mXpgWifiDevice = bindlist.get(position); loginDevice(mXpgWifiDevice); } }); sbLightness.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: sbLightness.getParent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_CANCEL: sbLightness.getParent().requestDisallowInterceptTouchEvent(false); break; } return false; } }); sbLightness.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub mLightness = seekBar.getProgress(); text_light.layout((int) (mLightness * moveStep1), 20, screenWidth, 80); text_light.setText(Integer.toString(mLightness)); if (!selectGroup.equals("") && selectGroup != null) { mCenter.cLightnessGroup(selectGroup, seekBar.getProgress()); } else { mCenter.cLightness(selectSubDevice, seekBar.getProgress()); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // TODO Auto-generated method stub } }); sbSaturation.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: sbSaturation.getParent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_CANCEL: sbSaturation.getParent().requestDisallowInterceptTouchEvent(false); break; } return false; } }); sbSaturation.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub mSaturation = seekBar.getProgress(); text_saturation.layout((int) (mSaturation * moveStep3), 20, screenWidth, 80); text_saturation.setText(Integer.toString(mSaturation)); if (!selectGroup.equals("") && selectGroup != null) { mCenter.cSaturationGroup(selectGroup, seekBar.getProgress()); } else { mCenter.cSaturation(selectSubDevice, seekBar.getProgress()); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // TODO Auto-generated method stub } }); sbColor.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: sbColor.getParent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_CANCEL: sbColor.getParent().requestDisallowInterceptTouchEvent(false); break; } return false; } }); sbColor.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub mHue = seekBar.getProgress(); text_hue.layout((int) (mHue * moveStep2), 20, screenWidth, 80); text_hue.setText(Integer.toString(mHue)); if (!selectGroup.equals("") && selectGroup != null) { mCenter.cColorGroup(selectGroup, seekBar.getProgress()); } else { mCenter.cColor(selectSubDevice, seekBar.getProgress()); } } @Override public void onProgressChanged(SeekBar arg0, int progress, boolean fromUser) { } @Override public void onStartTrackingTouch(SeekBar bar) { } }); alpha_bg.setOnClickListener(this); ivEdit.setOnClickListener(this); sclContent.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub if (position == list.size() - 1) { Intent intent = new Intent(MainListActivity.this, EditGroupActivity.class); intent.putStringArrayListExtra("ledList", GroupDevice.getAllName(ledList)); intent.putExtra("did", "" + centralControlDevice.getDid()); startActivity(intent); } } }); sclContent.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh(RefreshableListView listView) { // TODO Auto-generated method stub Log.i(TAG, "slip down to refresh........."); mCenter.cGetGroups(setmanager.getUid(), setmanager.getToken(), Configs.PRODUCT_KEY_Sub);//? mCenter.cGetSubDevicesList(centralControlDevice); final Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { // TODO Auto-generated method stub runOnUiThread(new Runnable() { public void run() { sclContent.completeRefreshing(); } }); timer.cancel(); } }, 2000); } }); btnSwitch.setOnClickListener(this); addSceneButton.setOnClickListener(this); sceneListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> a, View v, int position, long id) { Object o = sceneListView.getItemAtPosition(position); scene obj_itemDetails = (scene) o; Log.i(TAG, "click now is " + obj_itemDetails.getName() + " " + obj_itemDetails.getValue()); } }); }
From source file:com.buaa.cfs.utils.Shell.java
/** Run a command */ private void runCommand() throws IOException { ProcessBuilder builder = new ProcessBuilder(getExecString()); Timer timeOutTimer = null; ShellTimeoutTimerTask timeoutTimerTask = null; timedOut = new AtomicBoolean(false); completed = new AtomicBoolean(false); if (environment != null) { builder.environment().putAll(this.environment); }/*from www .j a v a2 s . co m*/ if (dir != null) { builder.directory(this.dir); } builder.redirectErrorStream(redirectErrorStream); if (Shell.WINDOWS) { synchronized (WindowsProcessLaunchLock) { // To workaround the race condition issue with child processes // inheriting unintended handles during process launch that can // lead to hangs on reading output and error streams, we // serialize process creation. More info available at: // http://support.microsoft.com/kb/315939 process = builder.start(); } } else { process = builder.start(); } if (timeOutInterval > 0) { timeOutTimer = new Timer("Shell command timeout"); timeoutTimerTask = new ShellTimeoutTimerTask(this); //One time scheduling. timeOutTimer.schedule(timeoutTimerTask, timeOutInterval); } final BufferedReader errReader = new BufferedReader( new InputStreamReader(process.getErrorStream(), Charset.defaultCharset())); BufferedReader inReader = new BufferedReader( new InputStreamReader(process.getInputStream(), Charset.defaultCharset())); final StringBuffer errMsg = new StringBuffer(); // read error and input streams as this would free up the buffers // free the error stream buffer Thread errThread = new Thread() { @Override public void run() { try { String line = errReader.readLine(); while ((line != null) && !isInterrupted()) { errMsg.append(line); errMsg.append(System.getProperty("line.separator")); line = errReader.readLine(); } } catch (IOException ioe) { LOG.warn("Error reading the error stream", ioe); } } }; try { errThread.start(); } catch (IllegalStateException ise) { } catch (OutOfMemoryError oe) { LOG.error("Caught " + oe + ". One possible reason is that ulimit" + " setting of 'max user processes' is too low. If so, do" + " 'ulimit -u <largerNum>' and try again."); throw oe; } try { parseExecResult(inReader); // parse the output // clear the input stream buffer String line = inReader.readLine(); while (line != null) { line = inReader.readLine(); } // wait for the process to finish and check the exit code exitCode = process.waitFor(); // make sure that the error thread exits joinThread(errThread); completed.set(true); //the timeout thread handling //taken care in finally block if (exitCode != 0) { throw new ExitCodeException(exitCode, errMsg.toString()); } } catch (InterruptedException ie) { throw new IOException(ie.toString()); } finally { if (timeOutTimer != null) { timeOutTimer.cancel(); } // close the input stream try { // JDK 7 tries to automatically drain the input streams for us // when the process exits, but since close is not synchronized, // it creates a race if we close the stream first and the same // fd is recycled. the stream draining thread will attempt to // drain that fd!! it may block, OOM, or cause bizarre behavior // see: https://bugs.openjdk.java.net/browse/JDK-8024521 // issue is fixed in build 7u60 InputStream stdout = process.getInputStream(); synchronized (stdout) { inReader.close(); } } catch (IOException ioe) { LOG.warn("Error while closing the input stream", ioe); } if (!completed.get()) { errThread.interrupt(); joinThread(errThread); } try { InputStream stderr = process.getErrorStream(); synchronized (stderr) { errReader.close(); } } catch (IOException ioe) { LOG.warn("Error while closing the error stream", ioe); } process.destroy(); lastTime = Time.monotonicNow(); } }
From source file:com.zld.ui.ZldNewActivity.java
/** * ?Camera?//from ww w . j a v a2s .c o m */ private void initCameraInfo() { // TODO Auto-generated method stub /** ??1??? */ ArrayList<MyCameraInfo> selectCamera = sqliteManager.selectCamera(SqliteManager.PASSTYPE_OUT); if (selectCamera.size() != 0) { for (int i = 0; i < selectCamera.size(); i++) { final MyCameraInfo myCameraInfo = selectCamera.get(i); if (myCameraInfo.getIp() != null) { /** ???,3s??? */ TimerTask task = new TimerTask() { public void run() { Log.e(TAG, "??IP" + myCameraInfo.getIp()); CameraManager.openCamera(handler, myCameraInfo.getIp()); // entranceFragment.initFrame(myCameraInfo.getIp()); } }; Timer timer = new Timer(); timer.schedule(task, 3000); } } } // ???ID poleIDInList = new ArrayList<String>(); poleIDOutList = new ArrayList<String>(); }
From source file:com.zld.ui.ZldNewActivity.java
/** * ?Cameraip?? ??/*www. ja v a 2 s . c o m*/ */ public void controlExitPole() { Log.e(TAG, "cameraExitIp:" + cameraExitIp); if (cameraExitIp != null) { DecodeManager.getinstance().controlPole(DecodeManager.openPole, cameraExitIp); exitledinfo = selectIpOut.get(cameraExitIp); Timer timer = new Timer();//Timer timer.schedule(new TimerTask() { public void run() { if (socketUtil == null || exitledinfo == null) { return; } socketUtil.sendLedData(null, exitledinfo.getLedip(), null, null, false); this.cancel(); } }, 200);// new Thread(new Runnable() { // ????????????? public void run() { try { Thread.sleep(2000); DecodeManager.getinstance().controlPole(DecodeManager.openPole, cameraExitIp); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }).start(); /*???*/ // Log.e("taigan","?:"+result); // new Thread(new Runnable() { // @Override // public void run() { // uploadBrakeState(selectCameraOut.get(0),result+""); // } // }).start(); } }
From source file:com.zld.ui.ZldNewActivity.java
/*** * OrderDetailsFrament ??Led// w ww .ja v a 2s. c om */ public void sendLedShow(String collectFir, String collectSec, String content) { Log.e(TAG, "?:" + exitledinfo); String ip = ""; //???ip,???LED(???ip); if (exitledinfo == null) { if (selectCameraOut != null) { for (int i = 0; i < selectCameraOut.size(); i++) { MyCameraInfo myCameraInfo = selectCameraOut.get(i); if (myCameraInfo != null) { String passtype = myCameraInfo.getPasstype(); if (passtype != null && passtype.equals(Constant.sOne)) { ip = myCameraInfo.getIp(); } } } } exitledinfo = selectIpOut.get(ip); } if (exitledinfo != null) { String passtype = exitledinfo.getPasstype(); if (passtype != null && passtype.equals(Constant.sOne)) { Log.e(TAG, "??LED:" + " collect:" + collectSec + " content:" + content); if (null != exitledinfo.getLeduid() && exitledinfo.getLeduid().equals("41")) { if (collectFir != null) { exitLedFirShow = collectFir; Timer timer = new Timer();//Timer timer.schedule(new TimerTask() { public void run() { socketUtil.sendLedData(exitledinfo, "41", exitLedFirShow, null, false); exitLedFirShow = ""; this.cancel(); } }, 100);// } socketUtil.sendLedData(exitledinfo, "42", collectSec, content, true); } else { socketUtil.sendLedData(exitledinfo, "190351508", collectSec, content, true); } } } }
From source file:org.pbccrc.zsls.utils.Shell.java
/** Run a command */ private void runCommand() throws IOException { ProcessBuilder builder = new ProcessBuilder(getExecString()); Timer timeOutTimer = null; ShellTimeoutTimerTask timeoutTimerTask = null; timedOut = new AtomicBoolean(false); completed = new AtomicBoolean(false); if (environment != null) { builder.environment().putAll(this.environment); }//from ww w . j a v a2 s . co m if (dir != null) { builder.directory(this.dir); } builder.redirectErrorStream(redirectErrorStream); if (Shell.WINDOWS) { synchronized (WindowsProcessLaunchLock) { // To workaround the race condition issue with child processes // inheriting unintended handles during process launch that can // lead to hangs on reading output and error streams, we // serialize process creation. More info available at: // http://support.microsoft.com/kb/315939 process = builder.start(); } } else { process = builder.start(); } if (timeOutInterval > 0) { timeOutTimer = new Timer("Shell command timeout"); timeoutTimerTask = new ShellTimeoutTimerTask(this); //One time scheduling. timeOutTimer.schedule(timeoutTimerTask, timeOutInterval); } final BufferedReader errReader = new BufferedReader(new InputStreamReader(process.getErrorStream())); BufferedReader inReader = new BufferedReader(new InputStreamReader(process.getInputStream())); final StringBuffer errMsg = new StringBuffer(); // read error and input streams as this would free up the buffers // free the error stream buffer Thread errThread = new Thread() { @Override public void run() { boolean overErrMsg = false; try { String line = errReader.readLine(); while ((line != null) && !isInterrupted()) { if (!overErrMsg) { if (line.length() + errMsg.length() > ERR_MSG_BUFF_SIZE) overErrMsg = true; else { errMsg.append(line); errMsg.append(System.getProperty("line.separator")); } } line = errReader.readLine(); } } catch (IOException ioe) { LOG.warn("Error reading the error stream", ioe); } } }; try { errThread.start(); } catch (IllegalStateException ise) { } try { parseExecResult(inReader); // parse the output // clear the input stream buffer String line = inReader.readLine(); while (line != null) { line = inReader.readLine(); } // wait for the process to finish and check the exit code exitCode = process.waitFor(); // make sure that the error thread exits joinThread(errThread); completed.set(true); //the timeout thread handling //taken care in finally block if (exitCode != 0) { throw new ExitCodeException(exitCode, errMsg.toString()); } } catch (InterruptedException ie) { throw new IOException(ie.toString()); } finally { if (timeOutTimer != null) { timeOutTimer.cancel(); } // close the input stream try { // JDK 7 tries to automatically drain the input streams for us // when the process exits, but since close is not synchronized, // it creates a race if we close the stream first and the same // fd is recycled. the stream draining thread will attempt to // drain that fd!! it may block, OOM, or cause bizarre behavior // see: https://bugs.openjdk.java.net/browse/JDK-8024521 // issue is fixed in build 7u60 InputStream stdout = process.getInputStream(); synchronized (stdout) { inReader.close(); } } catch (IOException ioe) { LOG.warn("Error while closing the input stream", ioe); } if (!completed.get()) { errThread.interrupt(); joinThread(errThread); } try { InputStream stderr = process.getErrorStream(); synchronized (stderr) { errReader.close(); } } catch (IOException ioe) { LOG.warn("Error while closing the error stream", ioe); } process.destroy(); lastTime = clock.getTime(); } }
From source file:com.zld.ui.ZldNewActivity.java
/** * ?? : 2015314 ?:/*from w w w . j a v a2 s. co m*/ * * @param bundle ? * @throws IOException */ private void showHomeInfo(Bundle bundle) throws IOException { int height = bundle.getInt("carPlateheight"); int width = bundle.getInt("carPlatewidth"); int x = bundle.getInt("xCoordinate"); int y = bundle.getInt("yCoordinate"); String carPlate = bundle.getString("carPlate"); /*int billingType = bundle.getInt("billingType");// ?, int nType = bundle.getInt("nType"); int resType = bundle.getInt("resType");*/ byte[] byteArray = bundle.getByteArray("bitmap"); String ledContent = bundle.getString("led_content"); String cameraIp = bundle.getString("cameraIp"); long time = System.currentTimeMillis(); Log.e(TAG, "??" + carPlate + " " + time); SharedPreferencesUtils.setParam(getApplicationContext(), "zld_config", "carPlate", carPlate); SharedPreferencesUtils.setParam(getApplicationContext(), "zld_config", "current_time", time); /* ??ip??ledip?,?ledip??ledinfo,??? */ if (selectIpIn == null || selectIpIn.size() == 0) { showToast("???LED???"); } else { homeledinfo = selectIpIn.get(cameraIp); Timer timer = new Timer();//Timer timer.schedule(new TimerTask() { public void run() { socketUtil.sendLedData(null, homeledinfo.getLedip(), null, null, false); this.cancel(); } }, 200);// if (ledContent != null) { if (homeledinfo != null) { String passtype = homeledinfo.getPasstype(); if (passtype.equals(Constant.sZero)) { Log.e(TAG, "homeledinfo:" + homeledinfo); comeIntime = System.currentTimeMillis(); if (null != homeledinfo.getLeduid() && homeledinfo.getLeduid().equals("41")) { socketUtil.sendLedData(homeledinfo, "42", ledContent, "", true); } else { socketUtil.sendLedData(homeledinfo, "190351508", ledContent, "", true); } //** // PollingUtils.startPollingService(this, 0, 1, ShareUiService.class, // "com.zld.service.ShareUi_Temp"); } } } } Bitmap homeBitmap = ImageUitls.byteBitmap(byteArray); homeBitmap = BitmapUtil.zoomImg(homeBitmap, 1280, 720); entranceFragment.refreshView(homeBitmap); setDetailInCarState(ComeInCarState.ENTRANCE_COME_IN_CAR_STATE); if (listFragment != null) { Log.e("OrderListState", "?????" + OrderListState.getInstance().getState()); if (OrderListState.getInstance().isOrderFinishState()) {//???? if (x + width <= homeBitmap.getWidth() && y + height <= homeBitmap.getHeight()) { if (x < 10 && y < 10 && width < 10 && height < 10) { detailsFragment.refreshCarPlate(null); } else { Log.e(TAG, "???"); if (x > 0 && y > 0 && width > 0 && height > 0) { Bitmap smallCarPlateBmp = Bitmap.createBitmap(homeBitmap, x, y, width, height); detailsFragment.refreshCarPlate(smallCarPlateBmp); } } } else { detailsFragment.refreshCarPlate(null); } } } }