Search in sources :

Example 11 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);
    setDummyData(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 12 with ObservableListView

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);
}
Also used : ObservableListView(com.github.ksoichiro.android.observablescrollview.ObservableListView) AbsListView(android.widget.AbsListView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) View(android.view.View) ObservableListView(com.github.ksoichiro.android.observablescrollview.ObservableListView)

Example 13 with ObservableListView

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;
}
Also used : ObservableListView(com.github.ksoichiro.android.observablescrollview.ObservableListView)

Example 14 with ObservableListView

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;
}
Also used : ObservableListView(com.github.ksoichiro.android.observablescrollview.ObservableListView) ViewGroup(android.view.ViewGroup) ObservableScrollViewCallbacks(com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks) View(android.view.View) ObservableListView(com.github.ksoichiro.android.observablescrollview.ObservableListView) Fragment(android.support.v4.app.Fragment)

Example 15 with ObservableListView

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);
            }
        }
    }
}
Also used : ObservableListView(com.github.ksoichiro.android.observablescrollview.ObservableListView) Fragment(android.support.v4.app.Fragment) View(android.view.View) ObservableListView(com.github.ksoichiro.android.observablescrollview.ObservableListView)

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