Search in sources :

Example 6 with ObservableListView

use of com.github.ksoichiro.android.observablescrollview.ObservableListView in project Android-ObservableScrollView by ksoichiro.

the class ListViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_listview);
    ObservableListView scrollable = (ObservableListView) findViewById(R.id.scrollable);
    scrollable.setScrollViewCallbacks(this);
    UiTestUtils.setDummyData(this, scrollable);
    scrollable.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        }
    });
}
Also used : ObservableListView(com.github.ksoichiro.android.observablescrollview.ObservableListView) AbsListView(android.widget.AbsListView)

Example 7 with ObservableListView

use of com.github.ksoichiro.android.observablescrollview.ObservableListView in project Android-ObservableScrollView by ksoichiro.

the class ViewPagerTab2ListViewFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_listview, container, false);
    Activity parentActivity = getActivity();
    final ObservableListView listView = (ObservableListView) view.findViewById(R.id.scroll);
    UiTestUtils.setDummyData(getActivity(), listView);
    listView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.container));
    if (parentActivity instanceof ObservableScrollViewCallbacks) {
        listView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
    }
    return view;
}
Also used : ObservableListView(com.github.ksoichiro.android.observablescrollview.ObservableListView) Activity(android.app.Activity) ObservableScrollViewCallbacks(com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks) View(android.view.View) ObservableListView(com.github.ksoichiro.android.observablescrollview.ObservableListView)

Example 8 with ObservableListView

use of com.github.ksoichiro.android.observablescrollview.ObservableListView in project Android-ObservableScrollView by ksoichiro.

the class ParallaxToolbarListViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_parallaxtoolbarlistview);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    mImageView = findViewById(R.id.image);
    mToolbarView = findViewById(R.id.toolbar);
    mToolbarView.setBackgroundColor(ScrollUtils.getColorWithAlpha(0, getResources().getColor(R.color.primary)));
    mParallaxImageHeight = getResources().getDimensionPixelSize(R.dimen.parallax_image_height);
    mListView = (ObservableListView) findViewById(R.id.list);
    mListView.setScrollViewCallbacks(this);
    // Set padding view for ListView. This is the flexible space.
    View paddingView = new View(this);
    AbsListView.LayoutParams lp = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, mParallaxImageHeight);
    paddingView.setLayoutParams(lp);
    // This is required to disable header's list selector effect
    paddingView.setClickable(true);
    mListView.addHeaderView(paddingView);
    setDummyData(mListView);
    // mListBackgroundView makes ListView's background except header view.
    mListBackgroundView = findViewById(R.id.list_background);
}
Also used : AbsListView(android.widget.AbsListView) View(android.view.View) AbsListView(android.widget.AbsListView) ObservableListView(com.github.ksoichiro.android.observablescrollview.ObservableListView)

Example 9 with ObservableListView

use of com.github.ksoichiro.android.observablescrollview.ObservableListView in project Android-ObservableScrollView by ksoichiro.

the class SlidingUpListViewActivity method createScrollable.

@Override
protected ObservableListView createScrollable() {
    ObservableListView listView = (ObservableListView) findViewById(R.id.scroll);
    listView.setScrollViewCallbacks(this);
    setDummyData(listView);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Toast.makeText(SlidingUpListViewActivity.this, "Item " + (position + 1) + " clicked", Toast.LENGTH_SHORT).show();
        }
    });
    return listView;
}
Also used : ObservableListView(com.github.ksoichiro.android.observablescrollview.ObservableListView) AdapterView(android.widget.AdapterView) View(android.view.View) AdapterView(android.widget.AdapterView) ObservableListView(com.github.ksoichiro.android.observablescrollview.ObservableListView)

Example 10 with ObservableListView

use of com.github.ksoichiro.android.observablescrollview.ObservableListView in project Android-ObservableScrollView by ksoichiro.

the class FlexibleSpaceWithImageListViewFragment method setScrollY.

@SuppressWarnings("NewApi")
@Override
public void setScrollY(int scrollY, int threshold) {
    View view = getView();
    if (view == null) {
        return;
    }
    ObservableListView listView = (ObservableListView) view.findViewById(R.id.scroll);
    if (listView == null) {
        return;
    }
    View firstVisibleChild = listView.getChildAt(0);
    if (firstVisibleChild != null) {
        int offset = scrollY;
        int position = 0;
        if (threshold < scrollY) {
            int baseHeight = firstVisibleChild.getHeight();
            position = scrollY / baseHeight;
            offset = scrollY % baseHeight;
        }
        listView.setSelectionFromTop(position, -offset);
    }
}
Also used : ObservableListView(com.github.ksoichiro.android.observablescrollview.ObservableListView) View(android.view.View) AbsListView(android.widget.AbsListView) ObservableListView(com.github.ksoichiro.android.observablescrollview.ObservableListView) SuppressLint(android.annotation.SuppressLint)

Aggregations

ObservableListView (com.github.ksoichiro.android.observablescrollview.ObservableListView)29 View (android.view.View)18 AbsListView (android.widget.AbsListView)11 ObservableScrollViewCallbacks (com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks)7 Activity (android.app.Activity)5 Fragment (android.support.v4.app.Fragment)5 Bundle (android.os.Bundle)4 SuppressLint (android.annotation.SuppressLint)3 TextView (android.widget.TextView)3 ArrayList (java.util.ArrayList)3 ViewTreeObserver (android.view.ViewTreeObserver)2 Context (android.content.Context)1 Nullable (android.support.annotation.Nullable)1 ViewGroup (android.view.ViewGroup)1 AdapterView (android.widget.AdapterView)1 FrameLayout (android.widget.FrameLayout)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 ScrollState (com.github.ksoichiro.android.observablescrollview.ScrollState)1 MapActivity (net.osmand.plus.activities.MapActivity)1