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) {
}
});
}
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;
}
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);
}
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;
}
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);
}
}
Aggregations