List of usage examples for android.widget BaseAdapter notifyDataSetChanged
public void notifyDataSetChanged()
From source file:cz.cvut.jirutjak.fastimport.droid.controllers.HistoryController.java
public void deleteSnippet(int position) { Snippet snippet = snippets.get(position); BaseAdapter adapter = (BaseAdapter) view.getListAdapter(); try {/* w w w.j av a 2 s . c o m*/ services.clipboard().deleteSnippet(snippet.getId()); context.getDAO().delete(snippet.getId(), Snippet.class); snippets.remove(position); adapter.notifyDataSetChanged(); } catch (RestClientException ex) { view.showNoConnection(); } }
From source file:com.josecalles.tistiq.mvp.view.MainActivity.java
private void refreshContactList() { for (int j = 0, count = mNavigationView.getChildCount(); j < count; j++) { final View child = mNavigationView.getChildAt(j); if (child != null && child instanceof ListView) { final ListView menuView = (ListView) child; final HeaderViewListAdapter adapter = (HeaderViewListAdapter) menuView.getAdapter(); final BaseAdapter wrapped = (BaseAdapter) adapter.getWrappedAdapter(); wrapped.notifyDataSetChanged(); }/*from w w w . jav a2s .c o m*/ } }
From source file:com.wly.net.PortScannerActivity.java
@Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean result = true; if (actionId == EditorInfo.IME_ACTION_NEXT || actionId == EditorInfo.IME_ACTION_DONE) { // the user is done typing. switch (v.getId()) { case R.id.host_name_text: Toast.makeText(this, "In host_name_text case statement.", Toast.LENGTH_SHORT).show(); host = ((EditText) v).getText().toString(); if (validateUrl(host)) Toast.makeText(this, "The url " + host + " is valid.", Toast.LENGTH_SHORT).show(); if (validateIp(host)) Toast.makeText(this, "The ip address " + host + " is valid.", Toast.LENGTH_SHORT).show(); break; case R.id.port_range_text: parsePorts(((EditText) v).getText().toString()); BaseAdapter adapter = (BaseAdapter) ((PortListFragment) getSupportFragmentManager() .findFragmentById(R.id.port_list_fragment)).getListAdapter(); adapter.notifyDataSetInvalidated(); adapter.notifyDataSetChanged(); break; default:/*from w w w . ja va2s .c o m*/ result = false; break; } } return result; // pass on to other listeners. }
From source file:org.bienvenidoainternet.app.MainActivity.java
public void refreshNavigator() { for (int i = 0, count = navigationView.getChildCount(); i < count; i++) { final View child = navigationView.getChildAt(i); if (child != null && child instanceof ListView) { final ListView menuView = (ListView) child; final HeaderViewListAdapter adapter = (HeaderViewListAdapter) menuView.getAdapter(); final BaseAdapter wrapped = (BaseAdapter) adapter.getWrappedAdapter(); wrapped.notifyDataSetChanged(); }//from ww w . j av a 2 s .com } }
From source file:uk.ac.horizon.artcodes.activity.NavigationActivity.java
private void updateAccounts() { final Menu menu = binding.navigation.getMenu(); final MenuItem libraries = menu.findItem(R.id.nav_libraries); final SubMenu subMenu = libraries.getSubMenu(); while (subMenu.size() > 0) { subMenu.removeItem(subMenu.getItem(0).getItemId()); }//from w w w .j av a 2 s .c om final List<Account> accounts = getServer().getAccounts(); for (int index = 0; index < accounts.size(); index++) { final Account account = accounts.get(index); final MenuItem menuItem = subMenu.add(R.id.navigation, index, Menu.NONE, account.getDisplayName()); if (account.getId().equals("local")) { menuItem.setIcon(R.drawable.ic_folder_24dp); } else { menuItem.setIcon(R.drawable.ic_cloud_24dp); } menuItem.setCheckable(true); } final MenuItem menuItem = subMenu.add(R.id.navigation, R.id.nav_addaccount, Menu.NONE, R.string.nav_addaccount); menuItem.setIcon(R.drawable.ic_add_24dp); for (int i = 0, count = binding.navigation.getChildCount(); i < count; i++) { final View child = binding.navigation.getChildAt(i); if (child != null && child instanceof ListView) { final ListView menuView = (ListView) child; final HeaderViewListAdapter adapter = (HeaderViewListAdapter) menuView.getAdapter(); final BaseAdapter wrapped = (BaseAdapter) adapter.getWrappedAdapter(); wrapped.notifyDataSetChanged(); } } getServer().loadRecent(new LoadCallback<List<String>>() { @Override public void loaded(List<String> item) { final MenuItem recent = menu.findItem(R.id.nav_recent); if (recent != null) { recent.setVisible(!item.isEmpty()); } } @Override public void error(Throwable e) { GoogleAnalytics.trackException(e); } }); getServer().loadStarred(new LoadCallback<List<String>>() { @Override public void loaded(List<String> item) { final MenuItem starred = menu.findItem(R.id.nav_starred); if (starred != null) { starred.setVisible(!item.isEmpty()); } } @Override public void error(Throwable e) { GoogleAnalytics.trackException(e); } }); }
From source file:com.esri.android.mapsapp.MapsAppActivity.java
/** * Updates the navigation drawer items.//from w w w. j a v a 2 s . c o m */ private void updateDrawer() { mDrawerItems.clear(); DrawerItem item; if (AccountManager.getInstance().isSignedIn()) { // user info LinearLayout userInfoView = (LinearLayout) getLayoutInflater().inflate(R.layout.drawer_item_user_layout, null); TextView textView = (TextView) userInfoView.findViewById(R.id.drawer_item_fullname_textview); textView.setText(AccountManager.getInstance().getPortalUser().getFullName()); textView = (TextView) userInfoView.findViewById(R.id.drawer_item_username_textview); textView.setText(AccountManager.getInstance().getPortalUser().getUsername()); item = new DrawerItem(userInfoView, null); mDrawerItems.add(item); // Sign Out LinearLayout view_signOut = (LinearLayout) getLayoutInflater().inflate(R.layout.drawer_item_layout, null); TextView text_drawer_signOut = (TextView) view_signOut.findViewById(R.id.drawer_item_textview); ImageView icon_drawer_signOut = (ImageView) view_signOut.findViewById(R.id.drawer_item_icon); text_drawer_signOut.setText(getString(R.string.sign_out)); icon_drawer_signOut.setImageResource(R.drawable.ic_profile); item = new DrawerItem(view_signOut, new DrawerItem.OnClickListener() { @Override public void onClick() { signOut(); } }); mDrawerItems.add(item); // My Maps LinearLayout view_myMaps = (LinearLayout) getLayoutInflater().inflate(R.layout.drawer_item_layout, null); TextView text_drawer_myMaps = (TextView) view_myMaps.findViewById(R.id.drawer_item_textview); ImageView icon_drawer_myMaps = (ImageView) view_myMaps.findViewById(R.id.drawer_item_icon); text_drawer_myMaps.setText(getString(R.string.my_maps)); icon_drawer_myMaps.setImageResource(R.drawable.ic_map32); item = new DrawerItem(view_myMaps, new DrawerItem.OnClickListener() { @Override public void onClick() { showContentBrowser(); } }); mDrawerItems.add(item); } else { // Adding the Sign In item in the drawer LinearLayout view_signIn = (LinearLayout) getLayoutInflater().inflate(R.layout.drawer_item_layout, null); TextView text_drawer_signIn = (TextView) view_signIn.findViewById(R.id.drawer_item_textview); ImageView icon_drawer_signIn = (ImageView) view_signIn.findViewById(R.id.drawer_item_icon); text_drawer_signIn.setText(getString(R.string.sign_in)); icon_drawer_signIn.setImageResource(R.drawable.ic_profile); item = new DrawerItem(view_signIn, new DrawerItem.OnClickListener() { @Override public void onClick() { showSignInActivity(); } }); mDrawerItems.add(item); } // Adding the basemap item in the drawer LinearLayout view_basemap = (LinearLayout) getLayoutInflater().inflate(R.layout.drawer_item_layout, null); TextView text_drawer_basemap = (TextView) view_basemap.findViewById(R.id.drawer_item_textview); ImageView icon_drawer_basemap = (ImageView) view_basemap.findViewById(R.id.drawer_item_icon); text_drawer_basemap.setText(getString(R.string.menu_basemaps)); icon_drawer_basemap.setImageResource(R.drawable.action_basemaps); item = new DrawerItem(view_basemap, new DrawerItem.OnClickListener() { @Override public void onClick() { // Show BasemapsDialogFragment to offer a choice if basemaps. // This calls back to onBasemapChanged() if one is selected. BasemapsDialogFragment basemapsFrag = new BasemapsDialogFragment(); basemapsFrag.setBasemapsDialogListener(new BasemapsDialogFragment.BasemapsDialogListener() { @Override public void onBasemapChanged(String itemId) { showMap(null, itemId); } }); basemapsFrag.show(getFragmentManager(), null); mDrawerLayout.closeDrawers(); } }); mDrawerItems.add(item); BaseAdapter adapter = (BaseAdapter) mDrawerList.getAdapter(); if (adapter == null) { adapter = new DrawerItemListAdapter(); mDrawerList.setAdapter(adapter); } else { adapter.notifyDataSetChanged(); } }
From source file:it.mb.whatshare.MainActivity.java
/** * Removes all inbound paired devices./* w w w . j a va 2 s. c o m*/ */ public void deleteAllInbound() { if (!getApplicationContext().deleteFile(INBOUND_DEVICES_FILENAME)) { if (!inboundDevices.isEmpty()) { Toast.makeText(this, R.string.delete_all_inbound_fail_notification, Toast.LENGTH_SHORT).show(); return; } } inboundDevices = new ArrayList<PairedDevice>(); BaseAdapter listAdapter = getListAdapter(); listAdapter.notifyDataSetChanged(); Toast.makeText(this, R.string.delete_all_inbound_notification, Toast.LENGTH_SHORT).show(); }
From source file:it.mb.whatshare.MainActivity.java
/** * Removes the currently selected device from the list of inbound devices. */// ww w. j a v a 2s .c o m void removePaired() { if (deviceSelectedContextMenu != null) { Utils.debug("removePaired(): removing %s... success? %s", deviceSelectedContextMenu.name, inboundDevices.remove(deviceSelectedContextMenu)); deviceSelectedContextMenu = null; writePairedInboundFile(inboundDevices); BaseAdapter listAdapter = getListAdapter(); listAdapter.notifyDataSetChanged(); } else { Utils.debug("removePaired(): no device is currently set to be unpaired"); } }
From source file:it.mb.whatshare.MainActivity.java
/** * Renames the currently selected device. */// ww w . j a v a 2 s . c o m void onSelectedDeviceRenamed() { if (deviceSelectedContextMenu != null) { Utils.debug("renamePaired(): renamed %s to %s", deviceSelectedContextMenu.type, deviceSelectedContextMenu.name); deviceSelectedContextMenu = null; writePairedInboundFile(inboundDevices); BaseAdapter listAdapter = getListAdapter(); listAdapter.notifyDataSetChanged(); } else { Utils.debug("renamePaired(): no device is currently set to be renamed"); } }
From source file:com.mobicage.rogerthat.AddFriendsActivity.java
private Bitmap getAvatar(final Contact c, int type) { Bitmap avatar;// w w w . ja va 2s . co m switch (type) { case TYPE_AB_MATCH: case TYPE_SMS: case TYPE_MAIL: avatar = mPhoneContacts.getAvatar(c); break; case TYPE_FB_MATCH: final FacebookContact fbc = (FacebookContact) c; if (mFbAvatars.containsKey(fbc.email)) { avatar = mFbAvatars.get(fbc.email); } else { avatar = null; // Load avatar in the background L.d("Downloading fb avatar: " + fbc.pictureUrl); mFbAvatars.put(fbc.email, null); new SafeAsyncTask<Object, Object, Object>() { @Override protected Object safeDoInBackground(Object... params) { try { return BitmapFactory .decodeStream((InputStream) new URL((String) params[0]).getContent()); } catch (MalformedURLException e) { L.bug("Could not download Facebook avatar: " + fbc.pictureUrl, e); } catch (IOException e) { L.bug("Could not download Facebook avatar: " + fbc.pictureUrl, e); } catch (Exception e) { L.bug("Could not download Facebook avatar: " + fbc.pictureUrl, e); } return null; }; @Override protected void safeOnPostExecute(Object result) { Bitmap bitmap = (Bitmap) result; if (bitmap != null) { mFbAvatars.put(fbc.email, bitmap); ListView listView = (ListView) findViewById(R.id.add_via_facebook_result); BaseAdapter adapter = (BaseAdapter) listView.getAdapter(); adapter.notifyDataSetChanged(); } } @Override protected void safeOnCancelled(Object result) { } @Override protected void safeOnProgressUpdate(Object... values) { } @Override protected void safeOnPreExecute() { }; }.execute(fbc.pictureUrl); } break; default: avatar = null; break; } if (avatar == null) avatar = mFriendsPlugin.getMissingFriendAvatarBitmap(); else avatar = ImageHelper.getRoundedCornerAvatar(avatar); return avatar; }