List of usage examples for android.os Message sendToTarget
public void sendToTarget()
From source file:ru.gelin.android.weather.notification.skin.impl.BaseWeatherNotificationReceiver.java
protected void notifyHandler(Weather weather) { synchronized (BaseWeatherNotificationReceiver.class) { //monitor of static methods if (handler == null) { return; }//w ww . ja v a2s.c o m Message message = handler.obtainMessage(); Bundle bundle = message.getData(); bundle.putParcelable(WEATHER_KEY, new ParcelableWeather2(weather)); message.sendToTarget(); } }
From source file:com.crust87.ffmpegexecutorsample.MainActivity.java
private void bindEvent() { mVideoCropView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override/*from ww w .j a v a2 s. co m*/ public void onPrepared(MediaPlayer mp) { mVideoCropView.start(); } }); mExecutor.setFFmepgExecutorListener(new FFmpegExecutor.FFmepgExecutorListener() { @Override public void onReadProcessLine(String line) { Log.d("TEST", line); Message message = Message.obtain(); message.obj = line; message.setTarget(mMessageHandler); message.sendToTarget(); } @Override public void onFinishProcess() { Toast.makeText(getApplicationContext(), "Finish FFmpeg Process", Toast.LENGTH_LONG).show(); if (mProgressDialog != null) { mProgressDialog.dismiss(); mProgressDialog = null; } } @Override public void onError(Exception e) { } }); }
From source file:com.dynamsoft.camera.DBR.java
@Override public void onPreviewFrame(byte[] data, Camera camera) { if (mFinished && !mIsDialogShowing) { mFinished = false;//from ww w . j a v a 2 s . c om Camera.Size size = camera.getParameters().getPreviewSize(); mImageHeight = size.height; mBarcodeReader.readSingleAsync(data, size.width, size.height, mBarcodeFormat, new FinishCallback() { @Override public void onFinish(ReadResult readResult) { Message message = handler.obtainMessage(READ_RESULT, readResult); message.sendToTarget(); } }); } }
From source file:com.amaze.filemanager.ui.icons.IconHolder.java
/** * Method that returns a drawable reference of a FileSystemObject. * * @param iconView View to load the drawable into * @param fso The FileSystemObject reference * @param defaultIcon Drawable to be used in case no specific one could be found * @return Drawable The drawable reference *///from ww w . jav a 2 s . c o m public void loadDrawable(ImageView iconView, final String fso, Drawable defaultIcon) { if (!mUseThumbs) { return; } // Is cached? final String filePath = fso; if (this.mAppIcons.containsKey(filePath)) { iconView.setImageBitmap(this.mAppIcons.get(filePath)); return; } mRequests.put(iconView, fso); new Thread(new Runnable() { @Override public void run() { mHandler.removeMessages(MSG_DESTROY); if (mWorkerThread == null || mWorkerHandler == null) { mWorkerThread = new HandlerThread("IconHolderLoader"); mWorkerThread.start(); mWorkerHandler = new WorkerHandler(mWorkerThread.getLooper()); } Message msg = mWorkerHandler.obtainMessage(MSG_LOAD, fso); msg.sendToTarget(); } }).start(); }
From source file:com.dynamsoft.demo.dynamsoftbarcodereaderdemo.DBR.java
private void openCamera() { new Thread(new Runnable() { @Override// w w w . ja va 2 s.co m public void run() { mCamera = getCameraInstance(); if (mCamera != null) { mCamera.setDisplayOrientation(90); Camera.Parameters cameraParameters = mCamera.getParameters(); List<String> supportList = cameraParameters.getSupportedFocusModes(); if (supportList.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) cameraParameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); else if (supportList.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) cameraParameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO); mCamera.setParameters(cameraParameters); } Message message = handler.obtainMessage(OPEN_CAMERA, 1); message.sendToTarget(); } }).start(); }
From source file:com.amaze.carbonfilemanager.ui.icons.IconHolder.java
/** * Method that returns a drawable reference of a FileSystemObject. * * @param iconView View to load the drawable into * @param fso The FileSystemObject reference * @param defaultIcon Drawable to be used in case no specific one could be found * @return Drawable The drawable reference *//*w ww . ja va2 s . com*/ public void loadDrawable(final ImageView iconView, final String fso, Drawable defaultIcon) { if (!mUseThumbs) { return; } // Is cached? final String filePath = fso; if (this.mAppIcons.containsKey(filePath)) { iconView.setImageBitmap(this.mAppIcons.get(filePath)); return; } new Thread(new Runnable() { @Override public void run() { mHandler.removeMessages(MSG_DESTROY); if (mWorkerThread == null || mWorkerHandler == null) { mWorkerThread = new HandlerThread("IconHolderLoader"); mWorkerThread.start(); mWorkerHandler = new WorkerHandler(mWorkerThread.getLooper()); } mRequests.put(iconView, fso); Message msg = mWorkerHandler.obtainMessage(MSG_LOAD, fso); msg.sendToTarget(); } }).start(); }
From source file:com.dynamsoft.demo.dynamsoftbarcodereaderdemo.DBR.java
@Override public void onPreviewFrame(byte[] data, Camera camera) { if (isFirstTime) { isFirstTime = false;//from www .j a va 2 s. c o m Log.i("xiao", "width: " + camera.getParameters().getPreviewSize().width + ", height: " + camera.getParameters().getPreviewSize().height); try { File file = new File(Environment.getExternalStorageDirectory() + "/tmp.yuv"); Log.i("xiao", "path: " + file.getAbsolutePath()); FileOutputStream output = new FileOutputStream(file); output.write(data); output.flush(); output.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } if (mFinished && !mIsDialogShowing) { mFinished = false; //mStartTime = SystemClock.currentThreadTimeMillis(); mStartTime = new Date().getTime(); Camera.Size size = camera.getParameters().getPreviewSize(); try { TextResult[] readResult = mBarcodeReader.decodeBuffer(data, size.width, size.height, size.width, EnumImagePixelFormat.IPF_NV21, ""); Message message = handler.obtainMessage(READ_RESULT, readResult); message.sendToTarget(); } catch (BarcodeReaderException e) { e.printStackTrace(); } } }
From source file:es.curso.android.streamingVLC.VideoActivity.java
@Override public void setSurfaceSize(int width, int height, int visible_width, int visible_height, int sar_num, int sar_den) { Message msg = Message.obtain(mHandler, VideoSizeChanged, width, height); msg.sendToTarget(); }
From source file:com.projectsexception.myapplist.iconloader.IconManager.java
/** * Handles state messages for a particular task object * @param iconTask A task object//from www . jav a2 s . c o m * @param state The state of the task */ @SuppressLint("HandlerLeak") public void handleState(IconTask iconTask, int state) { switch (state) { // The task finished downloading and decoding the image case TASK_COMPLETE: // Puts the image into cache if (iconTask.isCacheEnabled() && iconTask.getPackageName() != null && iconTask.getDrawable() != null) { // If the task is set to cache the results, put the buffer // that was // successfully decoded into the cache mIconCache.put(iconTask.getPackageName(), iconTask.getDrawable()); } // Gets a Message object, stores the state in it, and sends it to the Handler Message completeMessage = mHandler.obtainMessage(state, iconTask); completeMessage.sendToTarget(); break; // In all other cases, pass along the message without any other action. default: mHandler.obtainMessage(state, iconTask).sendToTarget(); break; } }
From source file:com.orpheusdroid.screenrecorder.RecorderService.java
private void indexFile() { //Create a new ArrayList and add the newly created video file path to it ArrayList<String> toBeScanned = new ArrayList<>(); toBeScanned.add(SAVEPATH);/* ww w . j a v a2s. co m*/ String[] toBeScannedStr = new String[toBeScanned.size()]; toBeScannedStr = toBeScanned.toArray(toBeScannedStr); //Request MediaScannerConnection to scan the new file and index it MediaScannerConnection.scanFile(this, toBeScannedStr, null, new MediaScannerConnection.OnScanCompletedListener() { @Override public void onScanCompleted(String path, Uri uri) { Log.i(Const.TAG, "SCAN COMPLETED: " + path); //Show toast on main thread Message message = mHandler.obtainMessage(); message.sendToTarget(); stopSelf(); } }); }