List of usage examples for android.app Activity runOnUiThread
public final void runOnUiThread(Runnable action)
From source file:im.vector.util.VectorUtils.java
/** * Display the licenses text./*from w ww .ja va 2s. c om*/ * @param activity the activity */ public static void displayThirdPartyLicenses(final Activity activity) { if (null != mMainAboutDialog) { mMainAboutDialog.dismiss(); mMainAboutDialog = null; } activity.runOnUiThread(new Runnable() { @Override public void run() { WebView view = (WebView) LayoutInflater.from(activity).inflate(R.layout.dialog_licenses, null); view.loadUrl("file:///android_asset/open_source_licenses.html"); View titleView = LayoutInflater.from(activity).inflate(R.layout.dialog_licenses_header, null); view.setScrollbarFadingEnabled(false); mMainAboutDialog = new AlertDialog.Builder(activity).setCustomTitle(titleView).setView(view) .setPositiveButton(android.R.string.ok, null).create(); mMainAboutDialog.show(); } }); }
From source file:br.com.hotforms.usewaze.UseWaze.java
private void callWaze(final String url) { final Activity activity = this.cordova.getActivity(); activity.runOnUiThread(new Runnable() { @Override/*from www . j av a 2s . co m*/ public void run() { try { Intent intent = null; intent = new Intent(Intent.ACTION_VIEW); // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent". // Adding the MIME type to http: URLs causes them to not be handled by the downloader. Uri uri = Uri.parse(url); if ("file".equals(uri.getScheme())) { intent.setDataAndType(uri, webView.getResourceApi().getMimeType(uri)); } else { intent.setData(uri); } activity.startActivity(intent); } catch (ActivityNotFoundException ex) { String urlMarket = "market://details?id=com.waze"; Intent intent = null; intent = new Intent(Intent.ACTION_VIEW); // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent". // Adding the MIME type to http: URLs causes them to not be handled by the downloader. Uri uri = Uri.parse(urlMarket); if ("file".equals(uri.getScheme())) { intent.setDataAndType(uri, webView.getResourceApi().getMimeType(uri)); } else { intent.setData(uri); } activity.startActivity(intent); } } }); }
From source file:tv.ouya.sdk.OuyaUnityPlugin.java
public static void getOuyaContentInstalled() { try {/*from w w w . jav a 2 s . com*/ //Log.i(TAG, "getOuyaContentInstalled"); final Activity activity = IOuyaActivity.GetActivity(); if (null != activity) { Runnable runnable = new Runnable() { public void run() { OuyaContent ouyaContent = IOuyaActivity.GetOuyaContent(); UnityOuyaFacade unityOuyaFacade = IOuyaActivity.GetUnityOuyaFacade(); if (null == unityOuyaFacade) { Log.e(TAG, "unityOuyaFacade is null"); } else { unityOuyaFacade.getOuyaContentInstalled(); } } }; activity.runOnUiThread(runnable); } } catch (Exception e) { Log.e(TAG, "getOuyaContentInstalled: exception=" + e.toString()); } }
From source file:org.messic.android.controllers.PlaylistController.java
private void refreshData(final PlaylistAdapter adapter, final Activity activity, final PlaylistFragment pf, final SwipeRefreshLayout srl) { adapter.clear();/*w ww . ja v a 2 s . c o m*/ activity.runOnUiThread(new Runnable() { public void run() { adapter.notifyDataSetChanged(); } }); for (int i = 0; i < rlist.length; i++) { adapter.addPlaylist(rlist[i]); } pf.eventPlaylistInfoLoaded(); activity.runOnUiThread(new Runnable() { public void run() { adapter.notifyDataSetChanged(); } }); if (srl != null) srl.setRefreshing(false); }
From source file:org.messic.android.controllers.ExploreController.java
private void refreshData(MDMAlbum[] response, final AlbumAdapter adapter, final Activity activity, final ExploreFragment rf, final SwipeRefreshLayout srl) { adapter.clear();/*from www . j av a 2 s. c o m*/ activity.runOnUiThread(new Runnable() { public void run() { adapter.notifyDataSetChanged(); } }); for (int i = 0; i < response.length; i++) { adapter.addAlbum(response[i]); } rf.eventExploreInfoLoaded(); activity.runOnUiThread(new Runnable() { public void run() { adapter.notifyDataSetChanged(); } }); if (srl != null) srl.setRefreshing(false); }
From source file:ca.ualberta.cmput301.t03.trading.toptraders.TopTradersFragment.java
private void refreshTopTradersUI() { Activity activity = getActivity(); if (activity != null) { activity.runOnUiThread(new Runnable() { @Override/* w ww . j av a 2 s. c o m*/ public void run() { topTradersLayout.removeAllViews(); for (TopTrader trader : topTraders) { TableRow row = (TableRow) LayoutInflater.from(TopTradersFragment.this.getContext()) .inflate(R.layout.attrib_row, null); ((TextView) row.findViewById(R.id.attrib_name)).setText(trader.getUserName()); ((TextView) row.findViewById(R.id.attrib_value)) .setText(trader.getSuccessfulTradeCount().toString()); topTradersLayout.addView(row); } swipeRefreshLayout.setRefreshing(false); } }); } }
From source file:com.userhook.hookpoint.UHHookPointMessage.java
public void execute(final Activity activity) { final UHHookPoint hookPoint = this; final UHMessageView messageView = new UHMessageView(activity, this); activity.runOnUiThread(new Runnable() { @Override/*from w w w. j a v a 2s.c o m*/ public void run() { // check for current activity so we have the top most activity in case another activity // has started since the hook points were loaded Activity currentActivity = UserHook.getActivityLifecycle().getCurrentActivity(); ViewGroup rootView = (ViewGroup) currentActivity.findViewById(android.R.id.content); rootView.addView(messageView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); messageView.showDialog(); UserHook.trackHookPointDisplay(hookPoint); } }); }
From source file:org.messic.android.controllers.RandomController.java
private void refreshData(final SongAdapter adapter, final Activity activity, final RandomFragment rf, final SwipeRefreshLayout srl) { adapter.clear();//from w w w .jav a2 s.c om activity.runOnUiThread(new Runnable() { public void run() { adapter.notifyDataSetChanged(); } }); for (int i = 0; i < rlist.length; i++) { List<MDMSong> songs = rlist[i].getSongs(); for (int j = 0; j < songs.size(); j++) { MDMSong song = songs.get(j); adapter.addSong(song); } } rf.eventRandomInfoLoaded(); activity.runOnUiThread(new Runnable() { public void run() { adapter.notifyDataSetChanged(); } }); if (srl != null) srl.setRefreshing(false); }
From source file:com.audiokernel.euphonyrmt.fragments.OutputsFragment.java
@Override public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) { mApp.oMPDAsyncHelper.execAsync(new Runnable() { @Override/*from w ww. j av a 2s . c o m*/ public void run() { final MPD mpd = mApp.oMPDAsyncHelper.oMPD; final MPDOutput output = mOutputs.get(position); try { if (getListView().isItemChecked(position)) { mpd.enableOutput(output.getId()); } else { mpd.disableOutput(output.getId()); } } catch (final IOException | MPDException e) { Log.e(TAG, "Failed to modify output.", e); } final Activity activity = getActivity(); if (activity != null) { activity.runOnUiThread(new Runnable() { @Override public void run() { refreshOutputs(); } }); } } }); }
From source file:com.audiokernel.euphonyrmt.fragments.OutputsFragment.java
public void refreshOutputs() { mApp.oMPDAsyncHelper.execAsync(new Runnable() { @Override// w ww . j a v a 2s . c om public void run() { try { final List<MPDOutput> mpdOutputs = mApp.oMPDAsyncHelper.oMPD.getOutputs(); mOutputs.clear(); mOutputs.addAll(mpdOutputs); } catch (final IOException | MPDException e) { Log.e(TAG, "Failed to list outputs.", e); } final Activity activity = getActivity(); if (activity != null) { activity.runOnUiThread(new Runnable() { @Override @SuppressWarnings("unchecked") public void run() { try { ((BaseAdapter) getListAdapter()).notifyDataSetChanged(); final ListView list = getListView(); for (int i = 0; i < mOutputs.size(); i++) { list.setItemChecked(i, mOutputs.get(i).isEnabled()); } } catch (IllegalStateException e) { Log.e(TAG, "Illegal Activity state while trying to refresh output list"); } } }); } } }); }