List of usage examples for android.os Message setTarget
public void setTarget(Handler target)
From source file:com.crust87.ffmpegexecutorsample.MainActivity.java
private void bindEvent() { mVideoCropView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override//from w w w. j av a 2 s. com 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:it.angrydroids.epub3reader.BookView.java
@Override public void onActivityCreated(Bundle saved) { super.onActivityCreated(saved); view = (WebView) getView().findViewById(R.id.Viewport); // enable JavaScript for cool things to happen! view.getSettings().setJavaScriptEnabled(true); // ----- SWIPE PAGE view.setOnTouchListener(new OnTouchListener() { @Override// w ww. j av a2s . com public boolean onTouch(View v, MotionEvent event) { if (state == ViewStateEnum.books) swipePage(v, event, 0); WebView view = (WebView) v; return view.onTouchEvent(event); } }); // ----- NOTE & LINK view.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { Message msg = new Message(); msg.setTarget(new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); String url = msg.getData().getString(getString(R.string.url)); if (url != null) navigator.setNote(url, index); } }); view.requestFocusNodeHref(msg); return false; } }); view.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { try { navigator.setBookPage(url, index); } catch (Exception e) { errorMessage(getString(R.string.error_LoadPage)); } return true; } }); view.addJavascriptInterface(new MyJavaScriptInterface(), "INTERFACE"); view.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { view.loadUrl( "javascript:window.INTERFACE.processContent(document.getElementsByTagName('body')[0].innerText);"); } }); PreButton = (Button) getView().findViewById(R.id.btn_prev_chunk); TopButton = (Button) getView().findViewById(R.id.btn_display_from_top); FwdButton = (Button) getView().findViewById(R.id.btn_fwd_chunk); PreButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { BtnPrevChunkOnClickListner(v); } }); TopButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { BtnDisplayTopOnClickListner(v); } }); FwdButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { BtnFwdChunkOnClickListner(v); } }); loadPage(viewedPage); }
From source file:com.example.manan.enhancedurdureader.EpubReader.BookView.java
@TargetApi(Build.VERSION_CODES.KITKAT) @Override//ww w . j a va2 s. com public void onActivityCreated(Bundle saved) { super.onActivityCreated(saved); view = (WebView) getView().findViewById(R.id.Viewport); view.getSettings().setTextZoom(textSize); mScaleDetector = new ScaleGestureDetector(getActivity().getBaseContext(), new ScaleGestureDetector.OnScaleGestureListener() { @Override public void onScaleEnd(ScaleGestureDetector detector) { } @Override public boolean onScaleBegin(ScaleGestureDetector detector) { return true; } @Override public boolean onScale(ScaleGestureDetector detector) { //Log.w(LOG_KEY, "zoom ongoing, scale: " + detector.getScaleFactor()); return false; } }); // enable JavaScript for cool things to happen! view.getSettings().setJavaScriptEnabled(true); // ----- SWIPE PAGE view.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { /* if (state == ViewStateEnum.books) swipePage(v, event, 0); //int fontSize, newFont;*/ WebView view = (WebView) v; switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: x1 = event.getX(); break; case MotionEvent.ACTION_UP: if (mode != ZOOM && swipeFlag) { //if (state == ViewStateEnum.books) //swipePage(v, event, 0); } break; case MotionEvent.ACTION_POINTER_DOWN: oldDist = spacing(event); if (oldDist > 10f) { mode = ZOOM; } break; case MotionEvent.ACTION_POINTER_UP: mode = NONE; break; case MotionEvent.ACTION_MOVE: if (mode == ZOOM) { float newDist = spacing(event); if (newDist > 10f) { float scale = newDist / oldDist; if (scale > 1) { int currentTextSize = view.getSettings().getTextZoom(); textSize = currentTextSize + 15; view.getSettings().setTextZoom(textSize); mode = NONE; swipeFlag = false; } else { int currentTextSize = view.getSettings().getTextZoom(); textSize = currentTextSize - 15; view.getSettings().setTextZoom(textSize); mode = NONE; swipeFlag = false; } } } break; } return view.onTouchEvent(event); } }); // ----- NOTE & LINK view.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { Message msg = new Message(); msg.setTarget(new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); String url = msg.getData().getString(getString(R.string.url)); if (url != null) navigator.setNote(url, index); } }); view.requestFocusNodeHref(msg); return false; } }); view.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { try { navigator.setBookPage(url, index); } catch (Exception e) { errorMessage(getString(R.string.error_LoadPage)); } return true; } }); loadPage(viewedPage); }
From source file:it.angrydroids.epub3reader.TextSelectionSupport.java
@Override public boolean onLongClick(View v) { if (!isInSelectionMode()) { mWebView.loadUrl("javascript:android.selection.longTouch();"); mScrolling = true;// w w w .j a va 2s. c om } Message msg = new Message(); msg.setTarget(new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); String url = msg.getData().getString("url"); if (url != null) navigator.setNote(url, index); } }); mWebView.requestFocusNodeHref(msg); return true; }
From source file:it.angrydroids.epub3reader.EpubReaderMain.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_epub_reader_main); // ----- get activity elements view1 = (WebView) findViewById(R.id.firstViewport); view2 = (WebView) findViewById(R.id.secondViewport); layout = (LinearLayout) findViewById(R.id.mainLayout); iconCloseView1 = (Button) findViewById(R.id.topRightFirstView); iconCloseView2 = (Button) findViewById(R.id.topRightSecondView); layoutView1 = (RelativeLayout) findViewById(R.id.firstViewportLayout); layoutView2 = (RelativeLayout) findViewById(R.id.secondViewportLayout); // -----// w w w.ja va 2 s . c o m // ----- get activity screen size DisplayMetrics metrics = this.getResources().getDisplayMetrics(); screenWidth = metrics.widthPixels; screenHeight = metrics.heightPixels; // ----- navigator = new EpubNavigator(getBaseContext()); // enable JavaScript for cool things to happen! view1.getSettings().setJavaScriptEnabled(true); view2.getSettings().setJavaScriptEnabled(true); // when the app starts, only one view is shown updateView1(ViewStateEnum.books); updateView2(ViewStateEnum.invisible); // ----- SWIPE PAGE view1.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (stateView1 == ViewStateEnum.books) { swipePage(v, event, BookEnum.first); } if (syncScrollActivated == true && stateView2 != ViewStateEnum.invisible) { // syncScroll(v, view2, event); work in progress } WebView view = (WebView) v; return view.onTouchEvent(event); } }); view2.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (stateView2 == ViewStateEnum.books) { swipePage(v, event, BookEnum.second); } WebView view = (WebView) v; return view.onTouchEvent(event); } }); // ----- // ----- VIEW CLOSING iconCloseView1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ViewStateEnum newState = navigator.closeView1(); ViewStateEnum oldState = stateView1; updateView1(newState); if (oldState == ViewStateEnum.books) { updateView2(ViewStateEnum.invisible); } } }); iconCloseView2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { updateView2(navigator.closeView2()); } }); // ----- // ----- NOTE & LINK view1.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { if (stateView1 == ViewStateEnum.books || stateView1 == ViewStateEnum.notes) { Message msg = new Message(); msg.setTarget(new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); String url = msg.getData().getString(getString(R.string.url)); if (url != null) if (stateView1 == ViewStateEnum.books || stateView1 == ViewStateEnum.notes) { updateView2(ViewStateEnum.notes); navigator.setView2(url); } else { navigator.setView1(url); } } }); view1.requestFocusNodeHref(msg); } return false; } }); view1.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { try { updateView1(navigator.setView1(url)); } catch (Exception e) { errorMessage(getString(R.string.error_LoadPage)); } return true; } }); view2.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { Message msg = new Message(); msg.setTarget(new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); String url = msg.getData().getString(getString(R.string.url)); if (url != null) { try { if (stateView2 == ViewStateEnum.books || stateView2 == ViewStateEnum.notes) { updateView1(ViewStateEnum.notes); navigator.setView1(url); } else { navigator.setView2(url); } } catch (Exception e) { errorMessage(getString(R.string.error_LoadPage)); } } } }); view2.requestFocusNodeHref(msg); return false; } }); view2.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { try { updateView2(navigator.setView2(url)); } catch (Exception e) { errorMessage(getString(R.string.error_LoadPage)); } return true; } }); // ----- // ----- LOAD STATE SharedPreferences preferences = getPreferences(MODE_PRIVATE); if (preferences.getBoolean(getString(R.string.bookOpen), false)) { loadState(preferences); } else { bookSelector = BookEnum.first; Intent goToChooser = new Intent(this, FileChooser.class); startActivityForResult(goToChooser, 0); } // ----- }
From source file:com.example.cuisoap.agrimac.homePage.demand.machineSelectDialogFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE); View view = inflater.inflate(R.layout.dialog_select_machine, container); list = (ListView) view.findViewById(R.id.machine_select_list); adapter = new machineSelectAdapter(mContext); data = new ArrayList<>(); list.setAdapter(adapter);/*from ww w.j ava 2 s .com*/ list.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { JSONObject jo = new JSONObject(); HashMap<String, String> item = (HashMap<String, String>) adapter.getItem(position); Intent i = new Intent(); i.setAction("select_machine"); i.putExtra("id", item.get("id")); i.putExtra("name", item.get("machine_name")); mContext.sendBroadcast(i); dismiss(); } }); Message m = Message.obtain(); JSONObject o = new JSONObject(); try { o.put("status", 0); JSONArray oo = new JSONArray("[{\n" + " \"driveType\": \"\",\n" + " \"driverName\": \"p\",\n" + " \"driverAge\": \"p\",\n" + " \"driverGender\": \"female\",\n" + " \"driverLicenseType\": \"R\",\n" + " \"driverLicense\": \"/sdcard/agrimac/driver2016_05_31_09_38_15.png\",\n" + " \"machineType\": \"\",\n" + " \"machineName\": \"p\",\n" + " \"machinePower\": \"1\",\n" + " \"passengerNum\": \"1\",\n" + " \"wheelDistance\": \"1\",\n" + " \"checkTime\": \"1\",\n" + " \"payType\": \"loan\",\n" + " \"machinePowerType\": \"\",\n" + " \"machineLicense1\": \"/sdcard/agrimac/machineinfo2016_05_31_09_38_34.png\",\n" + " \"machineLicense2\": \"/sdcard/agrimac/machineinfo2016_05_31_09_38_37.png\",\n" + " \"leaseMonth\": \"1\",\n" + " \"leaseTime\": \"1\",\n" + " \"workCondition\": \"\",\n" + " \"needType\": \"all\",\n" + " \"houseType\": \"normal_house\",\n" + " \"id\": \"1\"\n" + "}]"); o.put("data", oo); m.obj = o; m.setTarget(h); m.sendToTarget(); } catch (JSONException e) { e.printStackTrace(); } return view; }
From source file:com.iiordanov.bVNC.RemoteCanvas.java
@Override public boolean OnVerifiyCertificate(String subject, String issuer, String fingerprint) { android.util.Log.e(TAG, "OnVerifiyCertificate called."); // Send a message containing the certificate to our handler. Message m = new Message(); m.setTarget(handler); m.what = Constants.DIALOG_RDP_CERT;//from w ww . j a va 2 s. co m Bundle strings = new Bundle(); strings.putString("subject", subject); strings.putString("issuer", issuer); strings.putString("fingerprint", fingerprint); m.obj = strings; handler.sendMessage(m); // Block while user decides whether to accept certificate or not. // The activity ends if the user taps "No", so we block indefinitely here. synchronized (RemoteCanvas.this) { while (!certificateAccepted) { try { RemoteCanvas.this.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } } return true; }
From source file:com.example.cuisoap.agrimac.homePage.homeFragment.java
public void test() { Message m = Message.obtain(); JSONObject o = new JSONObject(); try {/* w w w.j a v a 2s . com*/ o.put("status", 0); JSONArray oo = new JSONArray("[{\n" + " \"driveType\": \"1\",\n" + " \"driverName\": \"p\",\n" + " \"driverAge\": \"p\",\n" + " \"driverGender\": \"female\",\n" + " \"licenseType\": \"R\",\n" + " \"driverLicense\": \"/sdcard/agrimac/driver2016_05_31_09_38_15.png\",\n" + " \"machineType\": \"\",\n" + " \"machineName\": \"p\",\n" + " \"machinePower\": \"1\",\n" + " \"passengerNum\": \"1\",\n" + " \"wheelDistance\": \"1\",\n" + " \"checkTime\": \"1\",\n" + " \"payType\": \"loan\",\n" + " \"machinePowerType\": \"\",\n" + " \"machineLicense1\": \"/sdcard/agrimac/machineinfo2016_05_31_09_38_34.png\",\n" + " \"machineLicense2\": \"/sdcard/agrimac/machineinfo2016_05_31_09_38_37.png\",\n" + " \"leaseMonth\": \"1\",\n" + " \"leaseTime\": \"1\",\n" + " \"workCondition\": \"\",\n" + " \"needType\": \"all\",\n" + " \"houseType\": \"normal_house\",\n" + " \"id\": \"1\"\n" + "}]"); o.put("data", oo); m.obj = o; m.setTarget(h); m.sendToTarget(); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.droid.app.fotobot.FotoBot.java
/** * ? ?// w w w . ja v a 2 s. com * * @param h handler, ?? * @param str ? ?? */ public void SendMessage(Handler h, String str) { Message msg = Message.obtain(); // Creates an new Message instance msg.obj = str; // Put the string into Message, into "obj" field. msg.setTarget(h); // Set the Handler msg.sendToTarget(); //Send the message }
From source file:com.droid.app.fotobot.FotoBot.java
/** * ? ?//from w ww.java2 s . c o m * * @param str ? ?? */ public void SendMessage(String str) { Message msg = Message.obtain(); // Creates an new Message instance msg.obj = str; // Put the string into Message, into "obj" field. msg.setTarget(h); // Set the Handler msg.sendToTarget(); //Send the message }