Java Code Examples for androidx.appcompat.app.AppCompatActivity#runOnUiThread()
The following examples show how to use
androidx.appcompat.app.AppCompatActivity#runOnUiThread() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Form.java From J2ME-Loader with Apache License 2.0 | 6 votes |
public int append(final Item item) { if (item.hasOwnerForm()) { throw new IllegalStateException(); } items.add(item); item.setOwnerForm(this); if (layout != null) { AppCompatActivity a = getParentActivity(); if (a != null) { View v = item.getItemView(); a.runOnUiThread(() -> layout.addView(v)); } } return items.size() - 1; }
Example 2
Source File: Form.java From J2ME-Loader with Apache License 2.0 | 6 votes |
public void set(final int index, final Item item) { if (item.hasOwnerForm()) { throw new IllegalStateException(); } items.set(index, item).setOwnerForm(null); item.setOwnerForm(this); if (layout != null) { AppCompatActivity a = getParentActivity(); if (a != null) { a.runOnUiThread(() -> { View v = item.getItemView(); layout.removeViewAt(index); layout.addView(v, index); }); } } }
Example 3
Source File: FindFragment.java From tindroid with Apache License 2.0 | 6 votes |
@Override public void toggleProgressIndicator(final boolean visible) { if (mProgress == null) { return; } AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity == null) { return; } activity.runOnUiThread(new Runnable() { @Override public void run() { if (visible) { mProgress.show(); } else { mProgress.hide(); } } }); }
Example 4
Source File: Form.java From J2ME-Loader with Apache License 2.0 | 5 votes |
public void insert(final int index, final Item item) { if (item.hasOwnerForm()) { throw new IllegalStateException(); } items.add(index, item); item.setOwnerForm(this); if (layout != null) { AppCompatActivity a = getParentActivity(); if (a != null) { View v = item.getItemView(); a.runOnUiThread(() -> layout.addView(v, index)); } } }
Example 5
Source File: Form.java From J2ME-Loader with Apache License 2.0 | 5 votes |
public void delete(final int index) { items.remove(index).setOwnerForm(null); if (layout != null) { AppCompatActivity a = getParentActivity(); if (a != null) { a.runOnUiThread(() -> layout.removeViewAt(index)); } } }
Example 6
Source File: Form.java From J2ME-Loader with Apache License 2.0 | 5 votes |
public void deleteAll() { for (Item item : items) { item.setOwnerForm(null); } items.clear(); if (layout != null) { AppCompatActivity a = getParentActivity(); if (a != null) { a.runOnUiThread(() -> layout.removeAllViews()); } } }
Example 7
Source File: BandwidthFragment.java From ETSMobile-Android2 with Apache License 2.0 | 5 votes |
private void setProgressBar(final double total, final double quota) { AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity != null) { activity.runOnUiThread(new Runnable() { @Override public void run() { progressBar.setMax((int) quota); progressBar.setProgress((int) total); String text = getString(R.string.bandwidth_used, total, quota, getString(R.string.gigaoctetx)); progressBarTv.setText(text); } }); } }
Example 8
Source File: BottinFragment.java From ETSMobile-Android2 with Apache License 2.0 | 4 votes |
@SuppressWarnings({"rawtypes", "unchecked"}) void updateUI() { AppCompatActivity activity = (AppCompatActivity) getActivity(); try { DatabaseHelper dbHelper = new DatabaseHelper(activity); // Création du queryBuilder, permettant de lister les employés par leur nom de service QueryBuilder<FicheEmploye, String> queryBuilder = (QueryBuilder<FicheEmploye, String>) dbHelper.getDao(FicheEmploye.class).queryBuilder(); queryBuilder.orderBy("Service", true); PreparedQuery<FicheEmploye> preparedQuery = queryBuilder.prepare(); List<FicheEmploye> listEmployes = dbHelper.getDao(FicheEmploye.class).query(preparedQuery); // Si le contenu n'est pas vide, l'ajouter au listDataHeader et listDataChild if (listEmployes.size() > 0) { String nomService = ""; String previousNomService = ""; listDataHeader.clear(); ArrayList<FicheEmploye> listEmployesOfService = new ArrayList<>(); // Pour le premier élément dans la liste FicheEmploye employe = listEmployes.get(0); nomService = employe.Service; listDataHeader.add(nomService); listEmployesOfService.add(employe); previousNomService = nomService; // Pour les prochains éléments dans la liste for (int i = 1; i < listEmployes.size(); i++) { employe = listEmployes.get(i); nomService = employe.Service; if (!listDataHeader.contains(nomService)) { listDataHeader.add(nomService); Collections.sort(listEmployesOfService, new Comparator<FicheEmploye>() { @Override public int compare(FicheEmploye f1, FicheEmploye f2) { return f1.Nom.compareTo(f2.Nom); } }); listDataChild.put(previousNomService, listEmployesOfService); listEmployesOfService = new ArrayList<>(); previousNomService = nomService; } listEmployesOfService.add(employe); } // Pour les derniers éléments dans la liste listDataChild.put(previousNomService, listEmployesOfService); if (activity != null) { activity.runOnUiThread(new Runnable() { public void run() { listAdapter = new ExpandableListAdapter(getActivity(), listDataHeader, listDataChild); expListView.setAdapter(listAdapter); listAdapter.notifyDataSetChanged(); } }); } // Rétablissement du filtre de recherche CharSequence searchText = searchView.getQuery(); if (searchText.length() != 0) onQueryTextChange(searchText.toString()); // Si le contenu est vide, télécharger le bottin } else { // Le contenu est vide. afficherRafraichissementEtRechargerBottin(); } } catch (Exception e) { Log.e("BD FicheEmploye", "" + e.getMessage()); } }