List of usage examples for android.os Handler post
public final boolean post(Runnable r)
From source file:com.licubeclub.zionhs.Notices.java
private void networkTask() { NetworkChecker NetCheck = new NetworkChecker(Notices.this); if (NetCheck.isNetworkConnected()) { final Handler mHandler = new Handler(); new Thread() { public void run() { mHandler.post(new Runnable() { public void run() { SRL.setRefreshing(true); }/*from w ww .j a v a 2s .c o m*/ }); //Task //Notices URL try { titlearray = new ArrayList<String>(); titleherfarray = new ArrayList<String>(); authorarray = new ArrayList<String>(); datearray = new ArrayList<String>(); // ? URL Document doc = Jsoup.connect(url).get(); Elements rawmaindata = doc.select(".listbody a"); //Get contents from tags,"a" which are in the class,"listbody" Elements rawauthordata = doc.select("td:eq(3)"); //? ? - 3 td ? Elements rawdatedata = doc.select("td:eq(4)"); // ? - 4 td ? String titlestring = rawmaindata.toString(); Log.i("Notices", "Parsed Strings" + titlestring); // ?? ? for (Element el : rawmaindata) { String titlherfedata = el.attr("href"); String titledata = el.attr("title"); titleherfarray.add("http://www.zion.hs.kr/" + titlherfedata); // add value to ArrayList titlearray.add(titledata); // add value to ArrayList } Log.i("Notices", "Parsed Link Array Strings" + titleherfarray); Log.i("Notices", "Parsed Array Strings" + titlearray); for (Element el : rawauthordata) { String authordata = el.text(); Log.d("Author", el.text()); authorarray.add(authordata); } for (Element el : rawdatedata) { String datedata = el.text(); Log.d("Date", el.text()); datearray.add(datedata); } } catch (IOException e) { e.printStackTrace(); } mHandler.post(new Runnable() { public void run() { //UI Task // ? adapter = new PostListAdapter(Notices.this, titlearray, datearray, authorarray); listview.setAdapter(adapter); listview.setOnItemClickListener(GoToWebPage); handler.sendEmptyMessage(0); SRL.setRefreshing(false); Toast.makeText(getApplicationContext(), getResources().getString(R.string.recent), Toast.LENGTH_LONG).show(); } }); } }.start(); } else { Toast.makeText(getApplicationContext(), getString(R.string.network_connection_warning), Toast.LENGTH_LONG).show(); } }
From source file:com.module.candychat.net.activity.PictureActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_share) { Handler uiHandler = new Handler(Looper.getMainLooper()); uiHandler.post(new Runnable() { @Override// ww w .j a v a 2 s . com public void run() { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, getShareImageUri(mImageTitle, mImageUrl)); shareIntent.setType("image/jpg"); shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(Intent.createChooser(shareIntent, "Share...")); //ShareUtils.shareImage(getApplicationContext(), getShareImageUri(mImageTitle,mImageUrl), "Share..."); } }); //return true; } else if (id == R.id.action_save) { Handler uiHandler = new Handler(Looper.getMainLooper()); uiHandler.post(new Runnable() { @Override public void run() { saveImageToGallery(); } }); //return true; } else if (id == android.R.id.home) { finish(); } return super.onOptionsItemSelected(item); }
From source file:com.sentaroh.android.Utilities.Dialog.ProgressSpinDialogFragment.java
@SuppressWarnings("unused") 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 v a 2 s . c o m*/ public void run() { mDialog.hide(); mDialog.getWindow().getCurrentFocus().invalidate(); initViewWidget(); Button btnCancel = (Button) mDialog.findViewById(R.id.progress_spin_dlg_fragment_btn_cancel); if (mDialogCancelBtnEnabled) btnCancel.setEnabled(true); else btnCancel.setEnabled(true); CommonDialog.setDlgBoxSizeCompact(mDialog); mDialog.show(); } }); } }
From source file:com.secupwn.aimsicd.ui.fragments.DeviceFragment.java
@Override public void onRefresh() { if (CellTracker.OCID_API_KEY != null && !CellTracker.OCID_API_KEY.equals("NA")) { Request request = createOpenCellIdApiCall(); okHttpClient.newCall(request).enqueue(getOpenCellIdResponseCallback()); } else {/*from w ww .ja v a2 s . co m*/ Handler refresh = new Handler(Looper.getMainLooper()); refresh.post(new Runnable() { public void run() { Helpers.sendMsg(getActivity(), getString(R.string.no_opencellid_key_detected)); swipeRefreshLayout.setRefreshing(false); } }); } }
From source file:com.actinarium.rhythm.control.RhythmNotificationService.java
private void handleNextGroup() { Application application = getApplication(); if (application instanceof RhythmControl.Host) { final RhythmControl rhythmControl = ((RhythmControl.Host) application).getRhythmControl(); Handler handler = new Handler(Looper.getMainLooper()); // Not using anonymous classes here to avoid leaking context handler.post(new NextGroupRunnable(rhythmControl)); }//w ww . j a v a 2s. co m }
From source file:dat255.grupp06.bibbla.fragments.ProfileFragment.java
/** * Update the contents of GUI elements with information from Backend, such * as name, current debt, books on loan and pending reservations. * @throws IllegalStateException if the backend is not set. * @see setBackend(Backend)/*from w ww . j a va 2 s .c o m*/ */ public void updateFromBackend() throws IllegalStateException { IBackend backend = BackendFactory.getBackend(); // These backend calls need user credentials. try { // The lists take some time so let's use Callback. // Name header backend.getUserName(new Callback() { @Override public void handleMessage(Message msg) { getUserNameDone(msg); } }); namePending = true; // Current debt backend.fetchUserDebt(new Callback() { @Override public void handleMessage(Message msg) { ProfileFragment.this.fetchDebtDone(msg); } }); debtPending = true; // Current loans backend.fetchLoans(new Callback() { @Override public void handleMessage(Message msg) { ProfileFragment.this.loansUpdateDone(msg); } }); loansPending = true; // Current reservations backend.fetchReservations(new Callback() { @Override public void handleMessage(Message msg) { ProfileFragment.this.reservationsUpdateDone(msg); } }, true); reservationsPending = true; //updateSpinnerState(); } catch (CredentialsMissingException e) { if (!dontLogin) { loginCallbackHandler.showCredentialsDialog(new Callback() { @Override public void handleMessage(Message msg) { updateFromBackend(); } }); } else { Handler handler = new Handler(); handler.post(new Runnable() { @Override public void run() { ((MainActivity) getSherlockActivity()).selectSearchTab(); } }); } } }
From source file:com.sentaroh.android.Utilities.Dialog.MessageDialogFragment.java
private void reInitViewWidget() { if (DEBUG_ENABLE) Log.v(APPLICATION_TAG, "reInitViewWidget"); if (!terminateRequired) { Handler hndl = new Handler(); hndl.post(new Runnable() { @Override/*from www. j ava 2 s. c o m*/ public void run() { mDialog.hide(); // mDialog.getWindow().getCurrentFocus().invalidate(); initViewWidget(); CommonDialog.setDlgBoxSizeCompact(mDialog); mDialog.onContentChanged(); mDialog.show(); } }); } }
From source file:com.sentaroh.android.Utilities.Dialog.ProgressBarDialogFragment.java
@SuppressWarnings("unused") private void reInitViewWidget() { if (DEBUG_ENABLE) Log.v(APPLICATION_TAG, "reInitViewWidget"); if (!mTerminateRequired) { Handler hndl = new Handler(); hndl.post(new Runnable() { @Override//from w w w .ja va 2 s . c om public void run() { mDialog.hide(); mDialog.getWindow().getCurrentFocus().invalidate(); initViewWidget(); Button btnCancel = (Button) mDialog.findViewById(R.id.progress_bar_dlg_fragment_btn_cancel); if (mDialogCancelBtnEnabled) btnCancel.setEnabled(true); else btnCancel.setEnabled(true); CommonDialog.setDlgBoxSizeCompact(mDialog); mDialog.show(); } }); } }
From source file:com.secupwn.aimsicd.ui.fragments.DeviceFragment.java
@NonNull private Callback getOpenCellIdResponseCallback() { return new Callback() { @Override//from www . j a v a 2 s . c o m public void onFailure(Request request, IOException e) { Handler refresh = new Handler(Looper.getMainLooper()); refresh.post(new Runnable() { public void run() { refreshFailed(); } }); } @Override public void onResponse(final Response response) throws IOException { Handler refresh = new Handler(Looper.getMainLooper()); refresh.post(new Runnable() { public void run() { Cell cell = responseToCell(response); processFinish(cell); } }); } }; }
From source file:org.apache.cordova.nodialogspeechrecognizer.SpeechRecognizer.java
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) { Boolean isValidAction = true; try {/* w ww . j a va 2 s . c o m*/ if (speech == null) { Handler loopHandler = new Handler(Looper.getMainLooper()); loopHandler.post(new Runnable() { @Override public void run() { speech = android.speech.SpeechRecognizer .createSpeechRecognizer(cordova.getActivity().getBaseContext()); speech.setRecognitionListener(new SpeechRecognitionListner()); } }); } } catch (Exception e) { Log.e(LOG_TAG, String.format("execute SpeechRecognitionActivity exception: %s", e.toString()), e); } this.callbackContext = callbackContext; // Action selector if ("startRecognize".equals(action)) { // recognize speech this.promptForMic(args); // startSpeechRecognitionActivity(args); } else if ("getSupportedLanguages".equals(action)) { getSupportedLanguages(); } else if ("checkSpeechRecognition".equals(action)) { checkSpeechRecognition(); } else { // Invalid action this.callbackContext.error("Unknown action: " + action); isValidAction = false; } return isValidAction; }