Search in sources :

Example 26 with RecyclerView

use of android.support.v7.widget.RecyclerView in project UltimateRecyclerView by cymcsg.

the class DividerItemDecoration method drawHorizontal.

public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 27 with RecyclerView

use of android.support.v7.widget.RecyclerView in project UltimateRecyclerView by cymcsg.

the class VerticalDividerItemDecoration method getDividerBound.

@Override
protected Rect getDividerBound(int position, RecyclerView parent, View child) {
    Rect bounds = new Rect(0, 0, 0, 0);
    int transitionX = (int) ViewCompat.getTranslationX(child);
    int transitionY = (int) ViewCompat.getTranslationY(child);
    RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
    bounds.top = parent.getPaddingTop() + mMarginProvider.dividerTopMargin(position, parent) + transitionY;
    bounds.bottom = parent.getHeight() - parent.getPaddingBottom() - mMarginProvider.dividerBottomMargin(position, parent) + transitionY;
    int dividerSize = getDividerSize(position, parent);
    if (mDividerType == DividerType.DRAWABLE) {
        bounds.left = child.getRight() + params.leftMargin + transitionX;
        bounds.right = bounds.left + dividerSize;
    } else {
        bounds.left = child.getRight() + params.leftMargin + dividerSize / 2 + transitionX;
        bounds.right = bounds.left;
    }
    return bounds;
}
Also used : Rect(android.graphics.Rect) RecyclerView(android.support.v7.widget.RecyclerView)

Example 28 with RecyclerView

use of android.support.v7.widget.RecyclerView in project PhotoPicker by donglua.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics());
    setContentView(R.layout.activity_main);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    photoAdapter = new PhotoAdapter(this, selectedPhotos);
    recyclerView.setLayoutManager(new StaggeredGridLayoutManager(4, OrientationHelper.VERTICAL));
    recyclerView.setAdapter(photoAdapter);
    findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            PhotoPicker.builder().setPhotoCount(9).setGridColumnCount(4).start(MainActivity.this);
        }
    });
    findViewById(R.id.button_no_camera).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            PhotoPicker.builder().setPhotoCount(7).setShowCamera(false).setPreviewEnabled(false).start(MainActivity.this);
        }
    });
    findViewById(R.id.button_one_photo).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            PhotoPicker.builder().setPhotoCount(1).start(MainActivity.this);
        }
    });
    findViewById(R.id.button_photo_gif).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            PhotoPicker.builder().setShowCamera(true).setShowGif(true).start(MainActivity.this);
        }
    });
    recyclerView.addOnItemTouchListener(new RecyclerItemClickListener(this, new RecyclerItemClickListener.OnItemClickListener() {

        @Override
        public void onItemClick(View view, int position) {
            if (photoAdapter.getItemViewType(position) == PhotoAdapter.TYPE_ADD) {
                PhotoPicker.builder().setPhotoCount(PhotoAdapter.MAX).setShowCamera(true).setPreviewEnabled(false).setSelected(selectedPhotos).start(MainActivity.this);
            } else {
                PhotoPreview.builder().setPhotos(selectedPhotos).setCurrentItem(position).start(MainActivity.this);
            }
        }
    }));
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Crashlytics(com.crashlytics.android.Crashlytics)

Example 29 with RecyclerView

use of android.support.v7.widget.RecyclerView in project UltimateRecyclerView by cymcsg.

the class ItemTouchListenerAdapter method onSingleTapUp.

@Override
public boolean onSingleTapUp(MotionEvent e) {
    View view = getChildViewUnder(e);
    if (view == null)
        return false;
    view.setPressed(false);
    int position = shiftAdjustInt(recyclerView.getChildAdapterPosition(view));
    if (position != AdmobAdapter.POSITION_ON_AD) {
        listener.onItemClick(recyclerView, view, position);
    }
    return true;
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 30 with RecyclerView

use of android.support.v7.widget.RecyclerView in project UltimateRecyclerView by cymcsg.

the class ViewPagerFragmentListSingle method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.listurv, container, false);
    final UltimateRecyclerView recyclerView = (UltimateRecyclerView) view.findViewById(R.id.scroll);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.setHasFixedSize(false);
    recyclerView.setRefreshing(false);
    setDummyData(recyclerView);
    ViewPagerTabFragmentParentFragment parentFragment = (ViewPagerTabFragmentParentFragment) getParentFragment();
    ViewGroup parentFView = (ViewGroup) parentFragment.getView();
    if (parentFragment != null) {
        recyclerView.setTouchInterceptionViewGroup((ViewGroup) parentFView.findViewById(R.id.container));
        if (parentFragment instanceof ObservableScrollViewCallbacks) {
            recyclerView.setScrollViewCallbacks(parentFragment);
            Log.d(TAG, "this is ObservableScrollViewCallbacks");
        }
    }
    return view;
}
Also used : ViewGroup(android.view.ViewGroup) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) ObservableScrollViewCallbacks(com.marshalchen.ultimaterecyclerview.ObservableScrollViewCallbacks) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) View(android.view.View)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)893 View (android.view.View)605 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)509 TextView (android.widget.TextView)191 GridLayoutManager (android.support.v7.widget.GridLayoutManager)130 ImageView (android.widget.ImageView)118 ArrayList (java.util.ArrayList)89 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)73 ViewGroup (android.view.ViewGroup)60 Toolbar (android.support.v7.widget.Toolbar)56 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)53 Intent (android.content.Intent)49 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)46 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)42 Context (android.content.Context)41 Bundle (android.os.Bundle)40 Nullable (android.support.annotation.Nullable)40 Handler (android.os.Handler)37 Rect (android.graphics.Rect)36 Paint (android.graphics.Paint)33