List of usage examples for android.os Handler post
public final boolean post(Runnable r)
From source file:com.mobshep.mobileshepherd.BrokenCrypto1.java
private void startTimerOne() { final Handler handler = new Handler(); Runnable runnable = new Runnable() { public void run() { try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace();//ww w . j av a 2s . c om } handler.post(new Runnable() { public void run() { messageOne.setVisibility(View.VISIBLE); } }); } }; new Thread(runnable).start(); }
From source file:com.mobshep.mobileshepherd.BrokenCrypto1.java
private void startTimerTwo() { final Handler handler = new Handler(); Runnable runnable = new Runnable() { public void run() { try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace();/*from w ww.j av a 2 s . c om*/ } handler.post(new Runnable() { public void run() { messageTwo.setVisibility(View.VISIBLE); } }); } }; new Thread(runnable).start(); }
From source file:com.mobshep.mobileshepherd.BrokenCrypto1.java
private void startTimerThree() { final Handler handler = new Handler(); Runnable runnable = new Runnable() { public void run() { try { Thread.sleep(7000); } catch (InterruptedException e) { e.printStackTrace();/*from w w w .j a v a2s . co m*/ } handler.post(new Runnable() { public void run() { messageThree.setVisibility(View.VISIBLE); } }); } }; new Thread(runnable).start(); }
From source file:com.kciray.android.filemanager.MainActivity.java
@Override public void onClickItem(int categoryId, Object data) { DrawerCategories categories = DrawerCategories.values()[categoryId]; switch (categories) { case BOOKMARKS: case SYSTEM://w ww.j a v a 2 s . c om final ExFile bookmarkFile = (ExFile) data; activeDirView.goToDir(bookmarkFile); //TODO - file operation IN OTHER THREAD!!! Handler handler = new Handler(getBaseContext().getMainLooper()); handler.post(navDrawer::closeDrawers); break; } }
From source file:com.android.adcnx.adlib.plugin.AdConnectLibrary.java
private PluginResult hide(final String callbackID) { log("Hide function called."); if (_lib == null) { return createResultWithJSONMessage(Status.ERROR, "AdConnect Library not created."); }//w ww . j a va2 s. c o m Handler h = new Handler(ctx.getContext().getMainLooper()); h.post(new Runnable() { public void run() { _lib.stopLoading(); _lib.setVisibility(View.GONE); updateHideStatus(callbackID); } }); PluginResult result = createResultWithJSONMessage(Status.NO_RESULT, "Hiding..."); result.setKeepCallback(true); return result; }
From source file:com.ferid.app.classroom.statistics.StatisticalListActivity.java
/** * Run time searching/*from w w w . java 2s. c o m*/ * @param searchText */ private void searchEngine(final String searchText) { Handler handler = new Handler(); handler.post(new Runnable() { @Override public void run() { ArrayList<AttendanceStatistics> tmpList = new ArrayList<>(); for (AttendanceStatistics as : wholeAttendanceList) { if (as.getStudentName().toLowerCase().startsWith(searchText.toLowerCase())) { tmpList.add(as); } } attendanceList.clear(); attendanceList.addAll(tmpList); adapter.notifyDataSetChanged(); } }); }
From source file:com.android.adcnx.adlib.plugin.AdConnectLibrary.java
private PluginResult show(final String callbackID) { log("Show function called."); if (_lib == null) { return createResultWithJSONMessage(Status.ERROR, "AdConnect Library not created."); }//from w w w .ja v a 2 s . c om Handler h = new Handler(ctx.getContext().getMainLooper()); h.post(new Runnable() { public void run() { _lib.setVisibility(View.VISIBLE); if (_currAdRequest != null) { _lib.loadAd(_currAdRequest); } updateShowStatus(callbackID); } }); PluginResult result = createResultWithJSONMessage(Status.NO_RESULT, "Showing..."); result.setKeepCallback(true); return result; }
From source file:com.floyd.http.AbstractRequest.java
/** * ??api<br/>/* ww w .j a v a2 s. c o m*/ * requestcallback?{@link Callback#onCompleted(Response, Object)}?<br> * ?{@code Response}Response?http response code ?200?<br> * ????????<br> * * @param request * @return ???,?http{@link Response#isSuccess()} false */ public Response execute() { Response response = null; try { decorateRequest(); switch (getHttpMethod()) { case POST: response = doPost(url, parameters, headers, attachments, SO_CONNECT_TIMEOUT, SO_READ_TIMEOUT); break; case GET: response = doGet(url, parameters, headers, DEFAULT_CHARSET, SO_CONNECT_TIMEOUT, SO_READ_TIMEOUT); break; default: return response; } //Log.v(sTAG, ""+response); if (response == null) { throw new IOException("response is null"); } } catch (Exception e1) { Log.e(sTAG, "exception: " + e1.getMessage()); if (response == null) { response = Response.fromError(e1, null); } else { response.setRequestError(new RequestError(e1, null)); } } if (this.callback != null) { final Response resp = response; final AbstractRequest req = this; // do callback Handler callbackHandler = req.getCallbackHandler(); if (callbackHandler == null) { // Run on this thread. req.getCallback().onCompleted(resp, req.getRequestFlag()); } else { // Post to the handler. callbackHandler.post(new Runnable() { public void run() { req.getCallback().onCompleted(resp, req.getRequestFlag()); } }); } } return response; }
From source file:com.sentaroh.android.DriveRecorder.Log.LogFileListDialogFragment.java
private void reInitViewWidget() { if (DEBUG_ENABLE) Log.v(APPLICATION_TAG, "reInitViewWidget"); if (!mTerminateRequired) { Handler hndl = new Handler(); hndl.post(new Runnable() { @Override/*w w w.j a va2s. c o m*/ public void run() { saveViewContents(); initViewWidget(); restoreViewContents(); } }); } }
From source file:com.zapto.park.ParkActivity.java
public boolean onOptionsItemSelected(MenuItem item) { Intent i = null;// www . j av a 2 s .c om switch (item.getItemId()) { // Add User case 1: Dialog d = new Dialog(cActivity); final Dialog dialog = d; d.setContentView(R.layout.dialog_add_employee); d.setTitle(R.string.create_user_title); final EditText first_name = (EditText) d.findViewById(R.id.employee_first); final EditText last_name = (EditText) d.findViewById(R.id.employee_last); Button button_getinfo = (Button) d.findViewById(R.id.button_getinfo); button_getinfo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { EmployeeDB edb = new EmployeeDB(context); String first = first_name.getText().toString(); String last = last_name.getText().toString(); ContentValues cv = new ContentValues(); cv.put("totable_first", first); cv.put("totable_last", last); cv.put("totable_license", Globals.LICENSE_KEY); // Log request in database. ContentValues cv2 = new ContentValues(); cv2.put("first", first); cv2.put("last", last); // Query database. edb.insertEmployee(cv2); // Close our database. edb.close(); dialog.dismiss(); } }); d.show(); break; // Settings case 2: Log.i(LOG_TAG, "Settings menu clicked."); i = new Intent(this, SettingsActivity.class); startActivity(i); break; case 3: Log.i(LOG_TAG, "View Log Loading."); i = new Intent(this, ListViewActivity.class); startActivity(i); break; case 4: doInit(); Handler handler = new Handler(); handler.post(new Runnable() { @Override public void run() { updateEmployees(); doPendingRequests(); } }); break; case 5: Log.i(LOG_TAG, "SendEmailActivity Loading."); i = new Intent(this, SendEmailActivity.class); startActivity(i); break; case 6: Log.i(LOG_TAG, "View Log Loading."); i = new Intent(this, ListViewActivity.class); startActivity(i); break; } return true; }