Java Code Examples for android.widget.ListView#post()
The following examples show how to use
android.widget.ListView#post() .
These examples are extracted from open source projects.
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 Project: arcusandroid File: LawnAndGardenMoreListFragment.java License: Apache License 2.0 | 6 votes |
@Override public void onResume() { super.onResume(); View rootView = getView(); if (rootView == null) { return; // onCreate returned null } listView = (ListView) rootView.findViewById(android.R.id.list); listView.setDivider(null); listener = LawnAndGardenDeviceMoreController.instance().setCallback(this); listView.post(new Runnable() { @Override public void run() { listView.setSelection(scrollPosition); } }); }
Example 2
Source Project: Musicoco File: OptionsDialog.java License: Apache License 2.0 | 6 votes |
public OptionsDialog(Activity activity) { this.activity = activity; this.mDialog = new Dialog(activity, R.style.BottomDialog); mDialog.getWindow().setGravity(Gravity.BOTTOM); mDialog.getWindow().setWindowAnimations(R.style.BottomDialog_Animation); mDialog.setCanceledOnTouchOutside(true); View view = LayoutInflater.from(activity).inflate(R.layout.options_container, null); listView = (ListView) view.findViewById(R.id.options_list); contentView = (LinearLayout) view.findViewById(R.id.options_container); titleText = (TextView) view.findViewById(R.id.options_title); divide = view.findViewById(R.id.options_divide); mDialog.setContentView(view); listView.post(new Runnable() { @Override public void run() { setDialogHeight(); } }); Utils.hideNavAndStatus(mDialog.getWindow().getDecorView()); }
Example 3
Source Project: VCL-Android File: AudioBrowserFragment.java License: Apache License 2.0 | 6 votes |
@Override public void onResume() { super.onResume(); mMainActivity = (MainActivity) getActivity(); if (mMediaLibrary.isWorking()) mHandler.sendEmptyMessageDelayed(MSG_LOADING, 300); else if (mGenresAdapter.isEmpty() || mArtistsAdapter.isEmpty() || mAlbumsAdapter.isEmpty() || mSongsAdapter.isEmpty()) updateLists(); else { updateEmptyView(mViewPager.getCurrentItem()); focusHelper(false, mLists.get(mViewPager.getCurrentItem()).getId()); } mMediaLibrary.addUpdateHandler(mHandler); mMediaLibrary.setBrowser(this); final ListView current = (ListView)mLists.get(mViewPager.getCurrentItem()); current.post(new Runnable() { @Override public void run() { mSwipeRefreshLayout.setEnabled(current.getFirstVisiblePosition() == 0); } }); }
Example 4
Source Project: BotLibre File: ChatActivity.java License: Eclipse Public License 1.0 | 6 votes |
public void debug(final String text) { if (!DEBUG) { return; } final ListView list = (ListView) findViewById(R.id.chatList); list.post(new Runnable() { @Override public void run() { ChatResponse ready = new ChatResponse(); ready.message = text; messages.add(ready); ((ChatListAdapter)list.getAdapter()).notifyDataSetChanged(); list.invalidateViews(); if (list.getCount() > 2) { list.setSelection(list.getCount() - 2); } } }); return; }
Example 5
Source Project: BotLibre File: ChatActivity.java License: Eclipse Public License 1.0 | 6 votes |
public static void debug(final String text) { if (!DEBUG) { return; } final ListView list = (ListView) activity.findViewById(R.id.chatList); list.post(new Runnable() { @Override public void run() { ChatResponse ready = new ChatResponse(); ready.message = text; messages.add(ready); ((ChatListAdapter)list.getAdapter()).notifyDataSetChanged(); list.invalidateViews(); if (list.getCount() > 2) { list.setSelection(list.getCount() - 2); } } }); return; }
Example 6
Source Project: BotLibre File: ChatActivity.java License: Eclipse Public License 1.0 | 6 votes |
public static void debug(final String text) { if (!DEBUG) { return; } final ListView list = (ListView) activity.findViewById(R.id.chatList); list.post(new Runnable() { @Override public void run() { ChatResponse ready = new ChatResponse(); ready.message = text; messages.add(ready); ((ChatListAdapter)list.getAdapter()).notifyDataSetChanged(); list.invalidateViews(); if (list.getCount() > 2) { list.setSelection(list.getCount() - 2); } } }); return; }
Example 7
Source Project: BotLibre File: ChatActivity.java License: Eclipse Public License 1.0 | 6 votes |
public void debug(final String text) { if (!DEBUG) { return; } final ListView list = (ListView) findViewById(R.id.chatList); list.post(new Runnable() { @Override public void run() { ChatResponse ready = new ChatResponse(); ready.message = text; messages.add(ready); ((ChatListAdapter)list.getAdapter()).notifyDataSetChanged(); list.invalidateViews(); if (list.getCount() > 2) { list.setSelection(list.getCount() - 2); } } }); return; }
Example 8
Source Project: MCPDict File: FavoriteCursorAdapter.java License: MIT License | 6 votes |
public static void scrollListToShowItem(final ListView list, final View view) { list.post(new Runnable() { @Override public void run() { int top = view.getTop(); int bottom = view.getBottom(); int height = bottom - top; int listTop = list.getPaddingTop(); int listBottom = list.getHeight() - list.getPaddingBottom(); int listHeight = listBottom - listTop; int y = (height > listHeight || bottom > listBottom) ? (listBottom - height) : (top < listTop) ? listTop : top; int position = list.getPositionForView(view); list.setSelectionFromTop(position, y); } }); }
Example 9
Source Project: microMathematics File: FileListView.java License: GNU General Public License v3.0 | 5 votes |
public final void setSelection(int i, int y_) { final ListView flv$ = listView; final int position$ = i, y$ = y_; flv$.post(new Runnable() { public void run() { flv$.setSelectionFromTop(position$, y$ > 0 ? y$ : flv$.getHeight() / 2); } }); currentPosition = i; }
Example 10
Source Project: meatspace-android File: UIUtils.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * scroll to bottom a listview without animation * * @param listView listview to scroll * @param adapter associated adapter */ public static void scrollToBottom(final ListView listView, final Adapter adapter) { listView.post(new Runnable() { @Override public void run() { listView.setSelection(adapter.getCount() - 1); } }); }
Example 11
Source Project: NIM_Android_UIKit File: ListViewUtil.java License: MIT License | 5 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private static void scrollToPosition(final ListView messageListView, final int position, final int y, final ScrollToPositionListener listener) { messageListView.post(new Runnable() { @Override public void run() { messageListView.setSelectionFromTop(position, y); if (listener != null) { listener.onScrollEnd(); } } }); }
Example 12
Source Project: Dashchan File: ViewUnit.java License: Apache License 2.0 | 5 votes |
boolean handlePostForDoubleClick(final View view) { final PostViewHolder holder = ListViewUtils.getViewHolder(view, PostViewHolder.class); if (holder != null) { if (holder.comment.getVisibility() != View.VISIBLE || holder.comment.isSelectionEnabled()) { return false; } long t = System.currentTimeMillis(); long timeout = holder.comment.getPreferredDoubleTapTimeout(); if (t - holder.lastCommentClick > timeout) { holder.lastCommentClick = t; } else { final ListView listView = (ListView) view.getParent(); final int position = listView.getPositionForView(view); holder.comment.startSelection(); int padding = holder.comment.getSelectionPadding(); if (padding > 0) { final int listHeight = listView.getHeight() - listView.getPaddingTop() - listView.getPaddingBottom(); listView.post(() -> { int end = holder.comment.getSelectionEnd(); if (end >= 0) { Layout layout = holder.comment.getLayout(); int line = layout.getLineForOffset(end); int count = layout.getLineCount(); if (count - line <= 4) { listView.setSelectionFromTop(position, listHeight - view.getHeight()); } } }); } } return true; } else { return false; } }
Example 13
Source Project: Dashchan File: ThreadsPage.java License: Apache License 2.0 | 5 votes |
public void apply() { ListView listView = getListView(); listView.removeCallbacks(this); listPosition = null; positionInfo = null; if (listView.getWidth() > 0) { run(); } else { listView.post(this); } }
Example 14
Source Project: Dashchan File: ThreadsPage.java License: Apache License 2.0 | 5 votes |
public void onListLayout(int width) { if (currentWidth != width) { currentWidth = width; ListView listView = getListView(); listView.removeCallbacks(this); boolean gridMode = getAdapter().isGridMode(); listPosition = gridMode ? ListPosition.obtain(listView) : null; positionInfo = gridMode ? getAdapter().getPositionInfo(listPosition.position) : null; listView.post(this); } }
Example 15
Source Project: Dashchan File: ListPosition.java License: Apache License 2.0 | 5 votes |
public void apply(final ListView listView) { if (listView.getHeight() == 0) { listView.post(() -> listView.setSelectionFromTop(position, y)); } else { listView.setSelectionFromTop(position, y); } }
Example 16
Source Project: rss File: ListFragmentFavourites.java License: GNU General Public License v3.0 | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ListView listView = getListView(); registerForContextMenu(listView); listView.post(new LoadFavourites()); listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new MultiModeListenerFavourites(listView, getResources())); }
Example 17
Source Project: Android-Commons File: UI.java License: Apache License 2.0 | 5 votes |
/** * Scrolls to the bottom of the specified `ListView` component * * @param listView the `ListView` component */ public static void scrollToBottom(final ListView listView) { listView.post(new Runnable() { @Override public void run() { final int itemCount = listView.getAdapter().getCount(); if (itemCount > 0) { listView.setSelection(itemCount - 1); } } }); }
Example 18
Source Project: onpc File: MediaFragment.java License: GNU General Public License v3.0 | 4 votes |
private void setSelection(int i, int y_) { final ListView flv$ = listView; final int position$ = i, y$ = y_; flv$.post(() -> flv$.setSelectionFromTop(position$, y$ > 0 ? y$ : flv$.getHeight() / 2)); }
Example 19
Source Project: BlackList File: InformationFragment.java License: Apache License 2.0 | 4 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); listView = (ListView) view.findViewById(R.id.help_list); InformationArrayAdapter adapter = new InformationArrayAdapter(getContext()); adapter.addTitle(R.string.About); String title = getString(R.string.app_name) + " (" + getAppVersion() + ")"; adapter.addText(title, getString(R.string.Info_about)); adapter.addTitle(R.string.Attention); adapter.addText(R.string.Info_attention); adapter.addTitle(R.string.Messaging); adapter.addText(R.string.Info_messaging); adapter.addTitle(R.string.Black_list); adapter.addText(R.string.Info_black_list); adapter.addTitle(R.string.White_list); adapter.addText(R.string.Info_white_list); adapter.addTitle(R.string.Journal); adapter.addText(R.string.Info_journal); adapter.addTitle(R.string.Settings); adapter.addText(R.string.Info_settings); adapter.addTitle(R.string.Licence); adapter.addText(R.string.Info_licence); adapter.addTitle(R.string.Author); adapter.addText(R.string.Info_author); // add adapter to the ListView and scroll list to position listView.setAdapter(adapter); listView.post(new Runnable() { @Override public void run() { listView.setSelection(listPosition); } }); }
Example 20
Source Project: Kernel-Tuner File: FMActivity.java License: GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { //supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); setContentView(R.layout.fm); fListView = (ListView) findViewById(R.id.list); path = savedInstanceState != null ? savedInstanceState.getString(CURR_DIR) : FILE_SEPARATOR;//Environment.getExternalStorageDirectory().toString(); fListView.setDrawingCacheEnabled(true); fAdapter = new FMAdapter(this, R.layout.fm_row); fListView.setAdapter(fAdapter); ls(path, false); getSupportActionBar().setSubtitle(path); fListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) { FMEntry entry = fAdapter.getItem(pos); if(entry.getType() == TYPE_DIRECTORY || entry.getType() == TYPE_DIRECTORY_LINK) { Parcelable state = fListView.onSaveInstanceState(); listScrollStates.put(path, state); backstack.add(path); path = entry.getType() == TYPE_DIRECTORY_LINK ? entry.getLink() : entry.getPath(); validatePath(); ls(path, false); } else if(entry.getType() == TYPE_FILE || entry.getType() == TYPE_LINK) { //TODO } } }); if(savedInstanceState != null) { backstack = (LinkedList<String>) savedInstanceState.getSerializable(BACKSTACK); Parcelable listState = savedInstanceState.getParcelable("list_position"); if(listState != null)fListView.post(new RestoreListStateRunnable(listState)); } }