Search in sources :

Example 86 with AbsListView

use of android.widget.AbsListView in project SmartAndroidSource by jaychou2012.

the class Common method onScrollStateChanged2.

private void onScrollStateChanged2(AbsListView lv, int scrollState) {
    lv.setTag(AQuery.TAG_NUM, scrollState);
    if (scrollState == SCROLL_STATE_IDLE) {
        int first = lv.getFirstVisiblePosition();
        int last = lv.getLastVisiblePosition();
        int count = last - first;
        ListAdapter la = lv.getAdapter();
        for (int i = 0; i <= count; i++) {
            long packed = i + first;
            View convertView = lv.getChildAt(i);
            Number targetPacked = (Number) convertView.getTag(AQuery.TAG_NUM);
            if (targetPacked != null) {
                la.getView((int) packed, convertView, lv);
                convertView.setTag(AQuery.TAG_NUM, null);
            } else {
            // AQUtility.debug("skip!");
            }
        }
    }
}
Also used : AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) ExpandableListView(android.widget.ExpandableListView) ExpandableListAdapter(android.widget.ExpandableListAdapter) ListAdapter(android.widget.ListAdapter)

Example 87 with AbsListView

use of android.widget.AbsListView in project ListViewAnimations by nhaarman.

the class MotionEventUtils method createMotionEvents.

public static List<MotionEvent> createMotionEvents(final AbsListView absListView, final int position, final float fromX, final float toX) {
    int[] listViewCoords = new int[2];
    absListView.getLocationOnScreen(listViewCoords);
    View view = absListView.getChildAt(position - absListView.getFirstVisiblePosition());
    int y = (int) (ViewHelper.getY(view) + view.getHeight() / 2) + listViewCoords[1];
    List<MotionEvent> results = new ArrayList<>();
    results.add(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, fromX, y, 0));
    float diff = fromX - toX;
    for (int i = 1; i < 10; i++) {
        float x = fromX + diff / 10 * i;
        results.add(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_MOVE, x, y, 0));
    }
    results.add(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, toX, y, 0));
    return results;
}
Also used : ArrayList(java.util.ArrayList) View(android.view.View) AbsListView(android.widget.AbsListView) MotionEvent(android.view.MotionEvent)

Example 88 with AbsListView

use of android.widget.AbsListView in project dialogplus by orhanobut.

the class DialogPlus method initExpandAnimator.

private void initExpandAnimator(Activity activity, int defaultHeight, int gravity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    int displayHeight = display.getHeight() - Utils.getStatusBarHeight(activity);
    if (defaultHeight == 0) {
        defaultHeight = (displayHeight * 2) / 5;
    }
    final View view = holder.getInflatedView();
    if (!(view instanceof AbsListView)) {
        return;
    }
    final AbsListView absListView = (AbsListView) view;
    view.setOnTouchListener(ExpandTouchListener.newListener(activity, absListView, contentContainer, gravity, displayHeight, defaultHeight));
}
Also used : AbsListView(android.widget.AbsListView) AbsListView(android.widget.AbsListView) AdapterView(android.widget.AdapterView)

Example 89 with AbsListView

use of android.widget.AbsListView in project Talon-for-Twitter by klinker24.

the class RetweetActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    landscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    context = this;
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    settings = AppSettings.getInstance(this);
    requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    setUpTheme();
    setContentView(R.layout.retweets_activity);
    setUpDrawer(3, getResources().getString(R.string.retweets));
    actionBar = getActionBar();
    actionBar.setTitle(getResources().getString(R.string.retweets));
    if (!settings.isTwitterLoggedIn) {
        Intent login = new Intent(context, LoginActivity.class);
        startActivity(login);
        finish();
    }
    listView = (AsyncListView) findViewById(R.id.listView);
    BitmapLruCache cache = App.getInstance(context).getBitmapCache();
    ArrayListLoader loader = new ArrayListLoader(cache, context);
    ItemManager.Builder builder = new ItemManager.Builder(loader);
    builder.setPreloadItemsEnabled(true).setPreloadItemsCount(50);
    builder.setThreadPoolSize(4);
    listView.setItemManager(builder.build());
    View viewHeader = getLayoutInflater().inflate(R.layout.ab_header, null);
    listView.addHeaderView(viewHeader, null, false);
    if (DrawerActivity.translucent) {
        if (Utils.hasNavBar(context)) {
            View footer = new View(context);
            footer.setOnClickListener(null);
            footer.setOnLongClickListener(null);
            ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getNavBarHeight(context));
            footer.setLayoutParams(params);
            listView.addFooterView(footer);
            listView.setFooterDividersEnabled(false);
        }
        if (!MainActivity.isPopup) {
            View view = new View(context);
            view.setOnClickListener(null);
            view.setOnLongClickListener(null);
            ListView.LayoutParams params2 = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getStatusBarHeight(context));
            view.setLayoutParams(params2);
            listView.addHeaderView(view);
            listView.setFooterDividersEnabled(false);
        }
    }
    final boolean isTablet = getResources().getBoolean(R.bool.isTablet);
    listView.setOnScrollListener(new AbsListView.OnScrollListener() {

        int mLastFirstVisibleItem = 0;

        @Override
        public void onScrollStateChanged(AbsListView absListView, int i) {
        }

        @Override
        public void onScroll(AbsListView absListView, final int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            final int lastItem = firstVisibleItem + visibleItemCount;
            if (lastItem == totalItemCount && canRefresh) {
                getRetweets();
            }
            if (!landscape && !isTablet) {
                // show and hide the action bar
                if (firstVisibleItem != 0) {
                    if (MainActivity.canSwitch) {
                        // used to show and hide the action bar
                        if (firstVisibleItem > mLastFirstVisibleItem) {
                            actionBar.hide();
                        } else if (firstVisibleItem < mLastFirstVisibleItem) {
                            actionBar.show();
                        }
                        mLastFirstVisibleItem = firstVisibleItem;
                    }
                } else {
                    actionBar.show();
                }
            }
            if (MainActivity.translucent && actionBar.isShowing()) {
                showStatusBar();
            } else if (MainActivity.translucent) {
                hideStatusBar();
            }
        }
    });
    getRetweets();
}
Also used : ArrayListLoader(com.klinker.android.twitter.adapters.ArrayListLoader) ItemManager(org.lucasr.smoothie.ItemManager) AbsListView(android.widget.AbsListView) Intent(android.content.Intent) AsyncListView(org.lucasr.smoothie.AsyncListView) View(android.view.View) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) BitmapLruCache(uk.co.senab.bitmapcache.BitmapLruCache) AsyncListView(org.lucasr.smoothie.AsyncListView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView)

Example 90 with AbsListView

use of android.widget.AbsListView in project Talon-for-Twitter by klinker24.

the class FavoritesActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    landscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    context = this;
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    settings = AppSettings.getInstance(this);
    requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    setUpTheme();
    setContentView(R.layout.retweets_activity);
    setUpDrawer(4, getResources().getString(R.string.favorite_tweets));
    actionBar = getActionBar();
    actionBar.setTitle(getResources().getString(R.string.favorite_tweets));
    if (!settings.isTwitterLoggedIn) {
        Intent login = new Intent(context, LoginActivity.class);
        startActivity(login);
        finish();
    }
    listView = (AsyncListView) findViewById(R.id.listView);
    BitmapLruCache cache = App.getInstance(context).getBitmapCache();
    ArrayListLoader loader = new ArrayListLoader(cache, context);
    ItemManager.Builder builder = new ItemManager.Builder(loader);
    builder.setPreloadItemsEnabled(true).setPreloadItemsCount(50);
    builder.setThreadPoolSize(4);
    listView.setItemManager(builder.build());
    View viewHeader = getLayoutInflater().inflate(R.layout.ab_header, null);
    listView.addHeaderView(viewHeader, null, false);
    if (DrawerActivity.translucent) {
        if (Utils.hasNavBar(context)) {
            View footer = new View(context);
            footer.setOnClickListener(null);
            footer.setOnLongClickListener(null);
            ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getNavBarHeight(context));
            footer.setLayoutParams(params);
            listView.addFooterView(footer);
            listView.setFooterDividersEnabled(false);
        }
        if (!MainActivity.isPopup) {
            View view = new View(context);
            view.setOnClickListener(null);
            view.setOnLongClickListener(null);
            ListView.LayoutParams params2 = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getStatusBarHeight(context));
            view.setLayoutParams(params2);
            listView.addHeaderView(view);
            listView.setFooterDividersEnabled(false);
        }
    }
    final boolean isTablet = getResources().getBoolean(R.bool.isTablet);
    listView.setOnScrollListener(new AbsListView.OnScrollListener() {

        int mLastFirstVisibleItem = 0;

        @Override
        public void onScrollStateChanged(AbsListView absListView, int i) {
        }

        @Override
        public void onScroll(AbsListView absListView, final int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            final int lastItem = firstVisibleItem + visibleItemCount;
            if (lastItem == totalItemCount && canRefresh) {
                getFavorites();
            }
            // show and hide the action bar
            if (firstVisibleItem != 0) {
                if (MainActivity.canSwitch) {
                    // used to show and hide the action bar
                    if (firstVisibleItem > mLastFirstVisibleItem) {
                        if (!landscape && !isTablet) {
                            actionBar.hide();
                        }
                    } else if (firstVisibleItem < mLastFirstVisibleItem) {
                        if (!landscape && !isTablet) {
                            actionBar.show();
                        }
                        if (translucent) {
                            statusBar.setVisibility(View.VISIBLE);
                        }
                    }
                    mLastFirstVisibleItem = firstVisibleItem;
                }
            } else {
                if (!landscape && !isTablet) {
                    actionBar.show();
                }
            }
            if (MainActivity.translucent && actionBar.isShowing()) {
                showStatusBar();
            } else if (MainActivity.translucent) {
                hideStatusBar();
            }
        }
    });
    getFavorites();
    final LinearLayout spinner = (LinearLayout) findViewById(R.id.list_progress);
    spinner.setVisibility(View.VISIBLE);
}
Also used : ArrayListLoader(com.klinker.android.twitter.adapters.ArrayListLoader) ItemManager(org.lucasr.smoothie.ItemManager) AbsListView(android.widget.AbsListView) Intent(android.content.Intent) AsyncListView(org.lucasr.smoothie.AsyncListView) View(android.view.View) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) BitmapLruCache(uk.co.senab.bitmapcache.BitmapLruCache) AsyncListView(org.lucasr.smoothie.AsyncListView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) LinearLayout(android.widget.LinearLayout)

Aggregations

AbsListView (android.widget.AbsListView)223 View (android.view.View)126 ListView (android.widget.ListView)80 AdapterView (android.widget.AdapterView)54 TextView (android.widget.TextView)46 ViewGroup (android.view.ViewGroup)33 ImageView (android.widget.ImageView)29 ScrollView (android.widget.ScrollView)23 RecyclerView (android.support.v7.widget.RecyclerView)21 GridView (android.widget.GridView)21 SuppressLint (android.annotation.SuppressLint)20 OnScrollListener (android.widget.AbsListView.OnScrollListener)19 Intent (android.content.Intent)17 ArrayList (java.util.ArrayList)16 Context (android.content.Context)12 Point (android.graphics.Point)12 Handler (android.os.Handler)12 WebView (android.webkit.WebView)12 ExpandableListView (android.widget.ExpandableListView)12 ArrayListLoader (com.klinker.android.twitter.adapters.ArrayListLoader)10