use of android.support.v7.widget.RecyclerView.Recycler in project AwesomeRecyclerView by forceLain.
the class AwesomeLayoutManager method fill.
private void fill(RecyclerView.Recycler recycler) {
View anchorView = getAnchorView();
viewCache.clear();
for (int i = 0, cnt = getChildCount(); i < cnt; i++) {
View view = getChildAt(i);
int pos = getPosition(view);
viewCache.put(pos, view);
}
for (int i = 0; i < viewCache.size(); i++) {
detachView(viewCache.valueAt(i));
}
switch(orientation) {
case VERTICAL:
fillUp(anchorView, recycler);
fillDown(anchorView, recycler);
break;
case HORIZONTAL:
fillLeft(anchorView, recycler);
fillRight(anchorView, recycler);
break;
}
for (int i = 0; i < viewCache.size(); i++) {
recycler.recycleView(viewCache.valueAt(i));
}
updateViewScale();
}
use of android.support.v7.widget.RecyclerView.Recycler in project AwesomeRecyclerView by forceLain.
the class AwesomeLayoutManager method fillRight.
private void fillRight(View anchorView, RecyclerView.Recycler recycler) {
int anchorPos;
int anchorLeft = 0;
if (anchorView != null) {
anchorPos = getPosition(anchorView);
anchorLeft = getDecoratedLeft(anchorView);
} else {
anchorPos = mAnchorPos;
}
int pos = anchorPos;
boolean fillRight = true;
int viewLeft = anchorLeft;
int itemCount = getItemCount();
int width = getWidth();
int height = getHeight();
final int widthSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY);
final int heightSpec = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.AT_MOST);
while (fillRight && pos < itemCount) {
View view = viewCache.get(pos);
if (view == null) {
view = recycler.getViewForPosition(pos);
addView(view);
measureChildWithDecorationsAndMargin(view, widthSpec, heightSpec);
int decoratedMeasuredHeight = getDecoratedMeasuredHeight(view);
int decoratedMeasuredWidth = getDecoratedMeasuredWidth(view);
layoutDecorated(view, viewLeft, 0, viewLeft + decoratedMeasuredWidth, decoratedMeasuredHeight);
} else {
attachView(view);
viewCache.remove(pos);
}
viewLeft = getDecoratedRight(view);
fillRight = viewLeft <= width;
pos++;
}
}
use of android.support.v7.widget.RecyclerView.Recycler in project fresco by facebook.
the class MainFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mConfig = Config.load(getContext());
// Initialize the SimpleAdapter
mSimpleAdapter = initializeSimpleAdapter(mConfig);
// We use a different layout based on the type of output
final View layout;
switch(mConfig.recyclerLayoutType) {
case Const.RECYCLER_VIEW_LAYOUT_VALUE:
layout = inflater.inflate(R.layout.content_recyclerview, container, false);
initializeRecyclerView(layout);
break;
case Const.LISTVIEW_LAYOUT_VALUE:
layout = inflater.inflate(R.layout.content_listview, container, false);
initializeListView(layout);
break;
case Const.GRID_RECYCLER_VIEW_LAYOUT_VALUE:
layout = inflater.inflate(R.layout.content_recyclerview, container, false);
initializeGridRecyclerView(layout);
break;
default:
throw new IllegalStateException("Recycler Layout not supported");
}
updateAdapter();
return layout;
}
use of android.support.v7.widget.RecyclerView.Recycler in project agera by google.
the class NotesFragment method onCreateView.
@Nullable
@Override
public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.notes_fragment, container, false);
// Find the clear button and wire the click listener to call the clear notes updatable
view.findViewById(R.id.clear).setOnClickListener(v -> notesStore.clearNotes());
// Find the add button and wire the click listener to show a dialog that in turn calls the add
// note from text from the notes store when adding notes
view.findViewById(R.id.add).setOnClickListener(v -> {
final EditText editText = new EditText(v.getContext());
editText.setId(R.id.edit);
new AlertDialog.Builder(v.getContext()).setTitle(R.string.add_note).setView(editText).setPositiveButton(R.string.add, (d, i) -> {
notesStore.insertNoteFromText(editText.getText().toString());
}).create().show();
});
// Setup the recycler view using the repository adapter
recyclerView = (RecyclerView) view.findViewById(R.id.result);
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
final ImageView imageView = (ImageView) view.findViewById(R.id.background);
updatable = () -> backgroundRepository.get().ifSucceededSendTo(imageView::setImageBitmap);
return view;
}
use of android.support.v7.widget.RecyclerView.Recycler in project DiscreteScrollView by yarolegovich.
the class DiscreteScrollLayoutManager method initChildDimensions.
private void initChildDimensions(RecyclerView.Recycler recycler) {
View viewToMeasure = recycler.getViewForPosition(0);
addView(viewToMeasure);
measureChildWithMargins(viewToMeasure, 0, 0);
int childViewWidth = getDecoratedMeasuredWidth(viewToMeasure);
int childViewHeight = getDecoratedMeasuredHeight(viewToMeasure);
childHalfWidth = childViewWidth / 2;
childHalfHeight = childViewHeight / 2;
scrollToChangeCurrent = orientationHelper.getDistanceToChangeCurrent(childViewWidth, childViewHeight);
detachAndScrapView(viewToMeasure, recycler);
}
Aggregations