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);
setDummyData(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 FlexibleSpaceWithImageListViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_flexiblespacewithimagelistview);
mFlexibleSpaceImageHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
mFlexibleSpaceShowFabOffset = getResources().getDimensionPixelSize(R.dimen.flexible_space_show_fab_offset);
mActionBarSize = getActionBarSize();
mImageView = findViewById(R.id.image);
mOverlayView = findViewById(R.id.overlay);
ObservableListView listView = (ObservableListView) findViewById(R.id.list);
listView.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, mFlexibleSpaceImageHeight);
paddingView.setLayoutParams(lp);
// This is required to disable header's list selector effect
paddingView.setClickable(true);
listView.addHeaderView(paddingView);
setDummyData(listView);
mTitleView = (TextView) findViewById(R.id.title);
mTitleView.setText(getTitle());
setTitle(null);
mFab = findViewById(R.id.fab);
mFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(FlexibleSpaceWithImageListViewActivity.this, "FAB is clicked", Toast.LENGTH_SHORT).show();
}
});
mFabMargin = getResources().getDimensionPixelSize(R.dimen.margin_standard);
ViewHelper.setScaleX(mFab, 0);
ViewHelper.setScaleY(mFab, 0);
// 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 FillGap3ListViewActivity method createScrollable.
@Override
protected ObservableListView createScrollable() {
ObservableListView listView = (ObservableListView) findViewById(R.id.scroll);
listView.setScrollViewCallbacks(this);
setDummyDataFew(listView);
return listView;
}
use of com.github.ksoichiro.android.observablescrollview.ObservableListView in project Android-ObservableScrollView by ksoichiro.
the class ViewPagerTabFragmentListViewFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_listview, container, false);
final ObservableListView listView = (ObservableListView) view.findViewById(R.id.scroll);
setDummyData(listView);
Fragment parentFragment = getParentFragment();
ViewGroup viewGroup = (ViewGroup) parentFragment.getView();
if (viewGroup != null) {
listView.setTouchInterceptionViewGroup((ViewGroup) viewGroup.findViewById(R.id.container));
if (parentFragment instanceof ObservableScrollViewCallbacks) {
listView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentFragment);
}
}
return view;
}
use of com.github.ksoichiro.android.observablescrollview.ObservableListView in project Android-ObservableScrollView by ksoichiro.
the class ViewPagerTabListViewActivity method propagateToolbarState.
private void propagateToolbarState(boolean isShown) {
int toolbarHeight = mToolbarView.getHeight();
// Set scrollY for the fragments that are not created yet
mPagerAdapter.setScrollY(isShown ? 0 : toolbarHeight);
// Set scrollY for the active fragments
for (int i = 0; i < mPagerAdapter.getCount(); i++) {
// Skip current item
if (i == mPager.getCurrentItem()) {
continue;
}
// Skip destroyed or not created item
Fragment f = mPagerAdapter.getItemAt(i);
if (f == null) {
continue;
}
View view = f.getView();
if (view == null) {
continue;
}
ObservableListView listView = (ObservableListView) view.findViewById(R.id.scroll);
if (isShown) {
// Scroll up
if (0 < listView.getCurrentScrollY()) {
listView.setSelection(0);
}
} else {
// Scroll down (to hide padding)
if (listView.getCurrentScrollY() < toolbarHeight) {
listView.setSelection(1);
}
}
}
}
Aggregations