use of com.instructure.pandarecycler.PandaRecyclerView in project instructure-android by instructure.
the class RubricFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_list, container, false);
rootView.findViewById(R.id.fragment_container).setBackgroundColor(Color.WHITE);
EmptyPandaView emptyRubricView = (EmptyPandaView) rootView.findViewById(R.id.emptyPandaView);
mRecyclerAdapter = new RubricRecyclerAdapter(getContext(), getCanvasContext(), new AdapterToFragmentCallback() {
@Override
public void onRowClicked(Object o, int position, boolean isOpenDetail) {
}
@Override
public void onRefreshFinished() {
setRefreshing(false);
}
});
configureRecyclerView(rootView, getContext(), mRecyclerAdapter, R.id.swipeRefreshLayout, R.id.emptyPandaView, R.id.listView);
PandaRecyclerView pandaRecyclerView = (PandaRecyclerView) rootView.findViewById(R.id.listView);
pandaRecyclerView.addItemDecoration(new RubricDecorator(getContext()));
return rootView;
}
use of com.instructure.pandarecycler.PandaRecyclerView in project instructure-android by instructure.
the class ParentFragment method configureRecyclerView.
@Override
public PandaRecyclerView configureRecyclerView(View rootView, Context context, final BaseRecyclerAdapter baseRecyclerAdapter, int swipeRefreshLayoutResId, int emptyViewResId, int recyclerViewResId, String emptyViewString, boolean withDivider) {
EmptyViewInterface emptyViewInterface = rootView.findViewById(emptyViewResId);
PandaRecyclerView recyclerView = rootView.findViewById(recyclerViewResId);
baseRecyclerAdapter.setSelectedItemId(getDefaultSelectedId());
recyclerView.setLayoutManager(new LinearLayoutManager(context));
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setEmptyView(emptyViewInterface);
emptyViewInterface.emptyViewText(emptyViewString);
emptyViewInterface.setNoConnectionText(getString(R.string.noConnection));
recyclerView.setSelectionEnabled(true);
recyclerView.setAdapter(baseRecyclerAdapter);
if (withDivider) {
recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL_LIST));
}
mSwipeRefreshLayout = rootView.findViewById(swipeRefreshLayoutResId);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if (!NetworkUtils.isNetworkAvailable()) {
mSwipeRefreshLayout.setRefreshing(false);
} else {
baseRecyclerAdapter.refresh();
}
}
});
return recyclerView;
}
use of com.instructure.pandarecycler.PandaRecyclerView in project instructure-android by instructure.
the class ParentFragment method configureRecyclerViewAsGrid.
public void configureRecyclerViewAsGrid(View rootView, final BaseRecyclerAdapter baseRecyclerAdapter, int swipeRefreshLayoutResId, int emptyViewResId, int recyclerViewResId, int emptyViewStringResId, final int span, View.OnClickListener emptyImageListener, Drawable... emptyImage) {
final int cardPadding = getResources().getDimensionPixelOffset(R.dimen.card_outer_margin);
EmptyViewInterface emptyViewInterface = (EmptyViewInterface) rootView.findViewById(emptyViewResId);
final PandaRecyclerView recyclerView = (PandaRecyclerView) rootView.findViewById(recyclerViewResId);
emptyViewInterface.emptyViewText(emptyViewStringResId);
emptyViewInterface.setNoConnectionText(getString(R.string.noConnection));
if (emptyImage != null && emptyImage.length > 0) {
emptyViewInterface.emptyViewImage(emptyImage[0]);
if (emptyImageListener != null && emptyViewInterface.getEmptyViewImage() != null) {
emptyViewInterface.getEmptyViewImage().setOnClickListener(emptyImageListener);
}
}
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), span, GridLayoutManager.VERTICAL, false);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (position < recyclerView.getAdapter().getItemCount()) {
int viewType = recyclerView.getAdapter().getItemViewType(position);
if (Types.TYPE_HEADER == viewType || PaginatedRecyclerAdapter.LOADING_FOOTER_TYPE == viewType) {
return span;
}
} else {
// if something goes wrong it will take up the entire space, but at least it won't crash
return span;
}
return 1;
}
});
if (mSpacingDecoration != null) {
recyclerView.removeItemDecoration(mSpacingDecoration);
}
if (baseRecyclerAdapter instanceof ExpandableRecyclerAdapter) {
mSpacingDecoration = new ExpandableGridSpacingDecorator(cardPadding);
} else {
mSpacingDecoration = new GridSpacingDecorator(cardPadding);
}
recyclerView.addItemDecoration(mSpacingDecoration);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemAnimator(new ExpandCollapseItemAnimator());
recyclerView.setEmptyView(emptyViewInterface);
recyclerView.setAdapter(baseRecyclerAdapter);
mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(swipeRefreshLayoutResId);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if (!com.instructure.pandautils.utils.Utils.isNetworkAvailable(getContext())) {
mSwipeRefreshLayout.setRefreshing(false);
} else {
baseRecyclerAdapter.refresh();
}
}
});
}
use of com.instructure.pandarecycler.PandaRecyclerView in project instructure-android by instructure.
the class RubricFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
if (savedInstanceState != null) {
getBundleDataWithCache(savedInstanceState);
}
this.currentAttempt = this.mSubmission.getAttempt();
mRecyclerAdapter = new RubricRecyclerAdapter(getContext(), getCanvasContext(), mAssignment, mSubmission, mSubmissionListener, new RubricAdapterToFragmentCallback() {
@Override
public void onFreeFormRowClicked(RubricCriterionRating rating, int position) {
}
@Override
public void onRowClicked(RubricCriterionRating rubricCriterionRating) {
}
@Override
public void onRowClicked(RubricCriterionRating rubricCriterionRating, int position) {
if (mAssignment.isFreeFormCriterionComments()) {
return;
}
mRecyclerAdapter.updateRubricAssessment(rubricCriterionRating);
}
@Override
public void onCommentRowClicked(RubricCriterionRating rating, int position) {
commentDialog = new RubricCommentDialog();
commentDialog.setArguments(RubricCommentDialog.createBundle(mRecyclerAdapter.getGroup((long) rating.getCriterionId().hashCode()), rating, position, mAssignment.isFreeFormCriterionComments()));
commentDialog.setTargetFragment(RubricFragment.this, 123);
commentDialog.show(getChildFragmentManager(), EditAssignmentDialog.TAG);
}
@Override
public void onRefreshFinished() {
setRefreshing(false);
}
});
configureRecyclerView(mRootView, getContext(), mRecyclerAdapter, R.id.swipeRefreshLayout, R.id.emptyPandaView, R.id.listView);
PandaRecyclerView pandaRecyclerView = (PandaRecyclerView) mRootView.findViewById(R.id.listView);
pandaRecyclerView.addItemDecoration(new RubricDecorator(getContext()));
return mRootView;
}
use of com.instructure.pandarecycler.PandaRecyclerView in project instructure-android by instructure.
the class RecyclerViewUtils method configureRecyclerViewAsGrid.
public static PandaRecyclerView configureRecyclerViewAsGrid(View rootView, final Context context, final BaseRecyclerAdapter baseRecyclerAdapter, int swipeRefreshLayoutResId, int emptyViewResId, int recyclerViewResId, final int span, String emptyViewString) {
EmptyViewInterface emptyViewInterface = (EmptyViewInterface) rootView.findViewById(emptyViewResId);
final PandaRecyclerView recyclerView = (PandaRecyclerView) rootView.findViewById(recyclerViewResId);
emptyViewInterface.emptyViewText(emptyViewString);
emptyViewInterface.setNoConnectionText(context.getString(R.string.noConnection));
GridLayoutManager layoutManager = new GridLayoutManager(context, span, GridLayoutManager.VERTICAL, false);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (position < recyclerView.getAdapter().getItemCount()) {
int viewType = recyclerView.getAdapter().getItemViewType(position);
if (Types.TYPE_HEADER == viewType || PaginatedRecyclerAdapter.LOADING_FOOTER_TYPE == viewType) {
return 1;
}
} else {
// if something goes wrong it will take up the entire space, but at least it won't crash
return 1;
}
return 1;
}
});
recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setEmptyView(emptyViewInterface);
recyclerView.setAdapter(baseRecyclerAdapter);
final SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(swipeRefreshLayoutResId);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if (!com.instructure.pandautils.utils.Utils.isNetworkAvailable(context)) {
swipeRefreshLayout.setRefreshing(false);
} else {
baseRecyclerAdapter.refresh();
}
}
});
return recyclerView;
}
Aggregations