List of usage examples for android.widget ListAdapter getCount
int getCount();
From source file:dev.ukanth.ufirewall.MainActivity.java
private void selectAllLAN(boolean flag) { if (this.listview == null) { this.listview = (ListView) this.findViewById(R.id.listview); }/* www . ja v a2 s. co m*/ ListAdapter adapter = listview.getAdapter(); if (adapter != null) { int count = adapter.getCount(), item; for (item = 0; item < count; item++) { PackageInfoData data = (PackageInfoData) adapter.getItem(item); if (data.uid != Api.SPECIAL_UID_ANY) { data.selected_lan = flag; } setDirty(true); } ((BaseAdapter) adapter).notifyDataSetChanged(); } }
From source file:dev.ukanth.ufirewall.MainActivity.java
private void selectAllVPN(boolean flag) { if (this.listview == null) { this.listview = (ListView) this.findViewById(R.id.listview); }//from www . j a v a 2 s. c o m ListAdapter adapter = listview.getAdapter(); if (adapter != null) { int count = adapter.getCount(), item; for (item = 0; item < count; item++) { PackageInfoData data = (PackageInfoData) adapter.getItem(item); if (data.uid != Api.SPECIAL_UID_ANY) { data.selected_vpn = flag; } setDirty(true); } ((BaseAdapter) adapter).notifyDataSetChanged(); } }
From source file:dev.ukanth.ufirewall.MainActivity.java
private void selectAllRoam(boolean flag) { if (this.listview == null) { this.listview = (ListView) this.findViewById(R.id.listview); }/* w w w. j av a2 s. co m*/ ListAdapter adapter = listview.getAdapter(); if (adapter != null) { int count = adapter.getCount(), item; for (item = 0; item < count; item++) { PackageInfoData data = (PackageInfoData) adapter.getItem(item); if (data.uid != Api.SPECIAL_UID_ANY) { data.selected_roam = flag; } setDirty(true); } ((BaseAdapter) adapter).notifyDataSetChanged(); } }
From source file:dev.ukanth.ufirewall.MainActivity.java
private void selectAll3G(boolean flag) { if (this.listview == null) { this.listview = (ListView) this.findViewById(R.id.listview); }//from w ww .ja va2 s.c om ListAdapter adapter = listview.getAdapter(); if (adapter != null) { int count = adapter.getCount(), item; for (item = 0; item < count; item++) { PackageInfoData data = (PackageInfoData) adapter.getItem(item); if (data.uid != Api.SPECIAL_UID_ANY) { data.selected_3g = flag; } setDirty(true); } ((BaseAdapter) adapter).notifyDataSetChanged(); } }
From source file:dev.ukanth.ufirewall.MainActivity.java
private void clearAll() { if (this.listview == null) { this.listview = (ListView) this.findViewById(R.id.listview); }//from w w w . j a va 2 s . c o m ListAdapter adapter = listview.getAdapter(); if (adapter != null) { int count = adapter.getCount(), item; for (item = 0; item < count; item++) { PackageInfoData data = (PackageInfoData) adapter.getItem(item); data.selected_wifi = false; data.selected_3g = false; data.selected_roam = false; data.selected_vpn = false; data.selected_lan = false; setDirty(true); } ((BaseAdapter) adapter).notifyDataSetChanged(); } }
From source file:dev.ukanth.ufirewall.MainActivity.java
private void selectRevert() { if (this.listview == null) { this.listview = (ListView) this.findViewById(R.id.listview); }//from w w w.j av a 2s . c o m ListAdapter adapter = listview.getAdapter(); if (adapter != null) { int count = adapter.getCount(), item; for (item = 0; item < count; item++) { PackageInfoData data = (PackageInfoData) adapter.getItem(item); if (data.uid != Api.SPECIAL_UID_ANY) { data.selected_wifi = !data.selected_wifi; data.selected_3g = !data.selected_3g; data.selected_roam = !data.selected_roam; data.selected_vpn = !data.selected_vpn; data.selected_lan = !data.selected_lan; } setDirty(true); } ((BaseAdapter) adapter).notifyDataSetChanged(); } }
From source file:dev.ukanth.ufirewall.MainActivity.java
private void selectRevert(int flag) { if (this.listview == null) { this.listview = (ListView) this.findViewById(R.id.listview); }/*from ww w.j a va 2 s . c o m*/ ListAdapter adapter = listview.getAdapter(); if (adapter != null) { int count = adapter.getCount(), item; for (item = 0; item < count; item++) { PackageInfoData data = (PackageInfoData) adapter.getItem(item); if (data.uid != Api.SPECIAL_UID_ANY) { switch (flag) { case R.id.img_wifi: data.selected_wifi = !data.selected_wifi; break; case R.id.img_3g: data.selected_3g = !data.selected_3g; break; case R.id.img_roam: data.selected_roam = !data.selected_roam; break; case R.id.img_vpn: data.selected_vpn = !data.selected_vpn; break; case R.id.img_lan: data.selected_lan = !data.selected_lan; break; } } setDirty(true); } ((BaseAdapter) adapter).notifyDataSetChanged(); } }
From source file:com.juick.android.MessagesFragment.java
private void init(final boolean moveToTop) { if (implicitlyCreated) return;//w w w . ja v a 2s . c om parent.imagePreviewHelper = listAdapter.imagePreviewHelper = new ImagePreviewHelper( (ViewGroup) getView().findViewById(R.id.imagepreview_container), parent); final MessageListBackingData savedMainList = JuickAdvancedApplication.instance.getSavedList(getActivity()); final ListView lv = getListView(); boolean canUseMainList = getActivity() instanceof MainActivity; // if (savedMainList != null && canUseMainList) { messagesSource = savedMainList.messagesSource; initListWithMessages(savedMainList.messages); int selectItem = 0; ListAdapter wrappedAdapter = lv.getAdapter(); for (int i = 0; i < wrappedAdapter.getCount(); i++) { Object ai = wrappedAdapter.getItem(i); if (ai != null && ai instanceof JuickMessage) { if (((JuickMessage) ai).getMID().equals(savedMainList.topMessageId)) { selectItem = i; } } } lv.setSelectionFromTop(selectItem, savedMainList.topMessageScrollPos); JuickAdvancedApplication.instance.setSavedList(null, false); } else { final MessagesLoadNotification messagesLoadNotification = new MessagesLoadNotification(getActivity(), handler); Thread thr = new Thread("Download messages (init)") { public void run() { final MessagesLoadNotification notification = messagesLoadNotification; final Utils.Function<Void, RetainedData> then = new Utils.Function<Void, RetainedData>() { @Override public Void apply(final RetainedData mespos) { handler.post(new Runnable() { @Override public void run() { notification.statusText.setText("Filter and format.."); } }); Log.w("com.juick.advanced", "getFirst: before filter"); final ArrayList<JuickMessage> messages = filterMessages(mespos.messages); Log.w("com.juick.advanced", "getFirst: after filter"); Boolean ownView = null; if (!JuickMessagesAdapter.dontKeepParsed(parent)) { for (JuickMessage juickMessage : messages) { if (ownView == null) { MicroBlog blog = MainActivity.microBlogs .get(juickMessage.getMID().getMicroBlogCode()); ownView = blog instanceof OwnRenderItems; } if (!ownView) { juickMessage.parsedText = JuickMessagesAdapter.formatMessageText(parent, juickMessage, false); } } } final Parcelable listPosition = mespos.viewState; if (isAdded()) { if (messages.size() == 0) { handler.post(new Runnable() { @Override public void run() { if (notification.lastError == null) { notification.statusText .setText(parent.getString(R.string.EmptyList)); } else { notification.statusText.setText( "Error obtaining messages: " + notification.lastError); } notification.progressBar.setVisibility(View.GONE); } }); } final Activity activity = getActivity(); if (activity != null) { final Parcelable finalListPosition = listPosition; activity.runOnUiThread(new Runnable() { public void run() { try { if (isAdded()) { lastPrepareMessages(messages, new Runnable() { @Override public void run() { if (!hasListView()) { handler.postDelayed(this, 300); return; } initListWithMessages(messages); if (moveToTop) { lv.setSelection(0); } else { if (finalListPosition != null) { lv.onRestoreInstanceState(finalListPosition); } else { //setSelection(messagesSource.supportsBackwardRefresh() ? 1 : 0); setSelection(0); } } Log.w("com.juick.advanced", "getFirst: end."); handler.postDelayed(new Runnable() { @Override public void run() { onListLoaded(); } }, 10); } }); } } catch (IllegalStateException e) { Toast.makeText(activity, e.toString(), Toast.LENGTH_LONG).show(); } } }); } } else { Log.w("com.juick.advanced", "getFirst: not added!"); } return null; } }; if (getActivity() != null) messagesSource.setContext(getActivity()); if (restoreData == null) { messagesSource.getFirst(notification, new Utils.Function<Void, ArrayList<JuickMessage>>() { @Override public Void apply(ArrayList<JuickMessage> juickMessages) { return then.apply(new RetainedData(juickMessages, null)); } }); } else { then.apply((RetainedData) restoreData); restoreData = null; } } }; thr.setPriority(Thread.MIN_PRIORITY); thr.start(); } }
From source file:com.wewow.MainActivity.java
public void fixListViewHeight(ListView listView) { // ??ListView? ListAdapter listAdapter = listView.getAdapter(); int totalHeight = 0; if (listAdapter == null) { return;/*w ww . j av a 2 s . c o m*/ } for (int i = 0, len = listAdapter.getCount(); i < len; i++) { View listViewItem = listAdapter.getView(i, null, listView); // ?View listViewItem.measure(0, 0); // ? totalHeight += listViewItem.getMeasuredHeight(); } ViewGroup.LayoutParams params = listView.getLayoutParams(); // listView.getDividerHeight()?? // params.heightListView? params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutParams(params); viewPager.setFocusable(true); viewPager.setFocusableInTouchMode(true); viewPager.requestFocus(); }
From source file:cn.ieclipse.af.view.StaggeredGridView.java
public void setAdapter(ListAdapter adapter) { if (mAdapter != null) { mAdapter.unregisterDataSetObserver(mObserver); }//from w ww . j a va2 s . c o m // TODO: If the new adapter says that there are stable IDs, remove certain layout records // and onscreen views if they have changed instead of removing all of the state here. clearAllState(); mAdapter = adapter; mDataChanged = true; mOldItemCount = mItemCount = adapter != null ? adapter.getCount() : 0; if (adapter != null) { adapter.registerDataSetObserver(mObserver); mRecycler.setViewTypeCount(adapter.getViewTypeCount()); mHasStableIds = adapter.hasStableIds(); } else { mHasStableIds = false; } populate(); }