Java Code Examples for android.widget.AbsListView#post()

The following examples show how to use android.widget.AbsListView#post() . 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: ScrollingUtil.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
public static void scrollToBottom(final AbsListView absListView) {
    if (absListView != null) {
        if (absListView.getAdapter() != null && absListView.getAdapter().getCount() > 0) {
            absListView.post(new Runnable() {
                @Override
                public void run() {
                    absListView.setSelection(absListView.getAdapter().getCount() - 1);
                }
            });
        }
    }
}
 
Example 2
Source File: ScrollingUtil.java    From TwinklingRefreshLayout with Apache License 2.0 5 votes vote down vote up
public static void scrollToBottom(final AbsListView absListView) {
    if (absListView != null) {
        if (absListView.getAdapter() != null && absListView.getAdapter().getCount() > 0) {
            absListView.post(new Runnable() {
                @Override
                public void run() {
                    absListView.setSelection(absListView.getAdapter().getCount() - 1);
                }
            });
        }
    }
}
 
Example 3
Source File: ScrollingUtil.java    From Pas with Apache License 2.0 5 votes vote down vote up
public static void scrollToBottom(final AbsListView absListView) {
    if (absListView != null) {
        if (absListView.getAdapter() != null && absListView.getAdapter().getCount() > 0) {
            absListView.post(new Runnable() {
                @Override
                public void run() {
                    absListView.setSelection(absListView.getAdapter().getCount() - 1);
                }
            });
        }
    }
}
 
Example 4
Source File: MovieSlideTab.java    From moviedb-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onPageSelected(int position) {
    // Finds the current fragment and updates the list if needed
    // On orientation change loses reference to fragments, that's why every time we find our fragment.
    if (MainActivity.getMaxMem() / 1048576 <= 20) {
        if (currPos != position) {
            // Find the old fragment and clear the list to save up memory
            MovieList oldFragment = (MovieList) getFragmentManager().findFragmentByTag(getFragmentTag(currPos));
            oldFragment.cleanUp();
            oldFragment.setFragmentActive(false);
        }
    }
    currPos = position;
    activity.setCurrentMovViewPagerPos(position);
    boolean load = true;
    if (savedInstanceState != null)
        load = savedInstanceState.getBoolean("load");

    fragment = (MovieList) getFragmentManager().findFragmentByTag(getFragmentTag(position));
    if (fragment != null) {
        fragment.setFragmentActive(true);
        if (fragment.getMoviesList() != null && fragment.getMoviesList().size() > 0) {
            final AbsListView listView = fragment.getListView();
            final View toolbarView = activity.findViewById(R.id.toolbar);
            if (listView != null) {
                listView.post(new Runnable() {
                    @Override
                    public void run() {
                        // check if toolbar is hidden and minThreshold to scroll
                        if (toolbarView.getTranslationY() == -toolbarView.getHeight() && ((Scrollable) listView).getCurrentScrollY() < minThreshold) {
                            if (phone)
                                listView.smoothScrollBy((int) (56 * scale), 0);
                            else
                                listView.smoothScrollBy((int) (59 * scale), 0);
                        }
                    }
                });
            }
        }

        if (load) {
            if (fragment.getBackState() == 0)
                fragment.updateList();
            else
                fragment.setAdapter();

        } else savedInstanceState.putBoolean("load", true);
    }


}
 
Example 5
Source File: TVSlideTab.java    From moviedb-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onPageSelected(int position) {
    // Finds the current fragment and updates the list if needed
    // On orientation change loses reference to fragments, that's why every time we find our fragment.
    if (MainActivity.getMaxMem() / 1048576 <= 20) {
        if (currPos != position) {
            // Find the old fragment and clear the list to save up memory
            TVList oldFragment = (TVList) getFragmentManager().findFragmentByTag(getFragmentTag(currPos));
            oldFragment.cleanUp();
            oldFragment.setFragmentActive(false);
        }
    }
    currPos = position;
    activity.setCurrentTVViewPagerPos(position);
    boolean load = true;
    if (savedInstanceState != null)
        load = savedInstanceState.getBoolean("load");

    fragment = (TVList) getFragmentManager().findFragmentByTag(getFragmentTag(position));
    if (fragment != null) {
        fragment.setFragmentActive(true);
        if (fragment.getTVList() != null && fragment.getTVList().size() > 0) {
            final AbsListView listView = fragment.getListView();
            final View toolbarView = activity.findViewById(R.id.toolbar);
            if (listView != null) {
                listView.post(new Runnable() {
                    @Override
                    public void run() {
                        // check if toolbar is hidden and minThreshold to scroll
                        if (toolbarView.getTranslationY() == -toolbarView.getHeight() && ((Scrollable) listView).getCurrentScrollY() < minThreshold) {
                            if (phone)
                                listView.smoothScrollBy((int) (56 * scale), 0);
                            else
                                listView.smoothScrollBy((int) (59 * scale), 0);
                        }
                    }
                });
            }
        }

        if (load) {
            if (fragment.getBackState() == 0)
                fragment.updateList();
            else
                fragment.setAdapter();

        } else savedInstanceState.putBoolean("load", true);
    }


}