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