use of com.winsonchiu.reader.rx.ObserverError in project Reader by TheKeeperOfPie.
the class FragmentThreadList method onCreateView.
@SuppressWarnings("ResourceType")
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
initialize();
view = bind(inflater.inflate(R.layout.fragment_thread_list, container, false));
setUpToolbar();
buttonExpandActions.setOnClickListener(v -> toggleLayoutActions());
behaviorButtonExpandActions = new ScrollAwareFloatingActionButtonBehavior(getActivity(), null, new ScrollAwareFloatingActionButtonBehavior.OnVisibilityChangeListener() {
@Override
public void onStartHideFromScroll() {
hideLayoutActions(0);
}
@Override
public void onEndHideFromScroll() {
buttonExpandActions.setImageResource(R.drawable.ic_unfold_more_white_24dp);
buttonExpandActions.setColorFilter(themer.getColorFilterAccent());
}
});
((CoordinatorLayout.LayoutParams) buttonExpandActions.getLayoutParams()).setBehavior(behaviorButtonExpandActions);
buttonJumpTop.setOnClickListener(v -> scrollToPositionWithOffset(0, 0));
buttonJumpTop.setOnLongClickListener(v -> {
Toast.makeText(getActivity(), getString(R.string.content_description_button_jump_top), Toast.LENGTH_SHORT).show();
return false;
});
buttonClearViewed.setOnClickListener(v -> controllerLinks.clearViewed(historian));
buttonClearViewed.setOnLongClickListener(v -> {
Toast.makeText(getActivity(), getString(R.string.content_description_button_clear_viewed), Toast.LENGTH_SHORT).show();
return false;
});
// Margin is included within shadow margin on pre-Lollipop, so remove all regular margin
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
((CoordinatorLayout.LayoutParams) buttonExpandActions.getLayoutParams()).setMargins(0, 0, 0, 0);
int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics());
LinearLayout.LayoutParams layoutParamsJumpTop = (LinearLayout.LayoutParams) buttonJumpTop.getLayoutParams();
layoutParamsJumpTop.setMargins(0, 0, 0, 0);
buttonJumpTop.setLayoutParams(layoutParamsJumpTop);
LinearLayout.LayoutParams layoutParamsClearViewed = (LinearLayout.LayoutParams) buttonClearViewed.getLayoutParams();
layoutParamsClearViewed.setMargins(0, 0, 0, 0);
buttonClearViewed.setLayoutParams(layoutParamsClearViewed);
RelativeLayout.LayoutParams layoutParamsActions = (RelativeLayout.LayoutParams) layoutActions.getLayoutParams();
layoutParamsActions.setMarginStart(margin);
layoutParamsActions.setMarginEnd(margin);
layoutActions.setLayoutParams(layoutParamsActions);
}
buttonExpandActions.setColorFilter(themer.getColorFilterAccent());
buttonJumpTop.setColorFilter(themer.getColorFilterAccent());
buttonClearViewed.setColorFilter(themer.getColorFilterAccent());
swipeRefreshThreadList.setOnRefreshListener(() -> {
controllerLinks.reload();
});
AdapterListener adapterListener = new AdapterListener() {
@Override
public void requestMore() {
controllerLinks.loadMore();
}
@Override
public void scrollAndCenter(int position, int height) {
UtilsAnimation.scrollToPositionWithCentering(position, recyclerThreadList, height, 0, 0, false);
}
@Override
public void hideToolbar() {
AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
}
@Override
public void clearDecoration() {
behaviorButtonExpandActions.animateOut(buttonExpandActions);
AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
}
@Override
public void requestDisallowInterceptTouchEventVertical(boolean disallow) {
recyclerThreadList.requestDisallowInterceptTouchEvent(disallow);
swipeRefreshThreadList.requestDisallowInterceptTouchEvent(disallow);
itemTouchHelper.select(null, CustomItemTouchHelper.ACTION_STATE_IDLE);
}
@Override
public void requestDisallowInterceptTouchEventHorizontal(boolean disallow) {
itemTouchHelper.setDisallow(disallow);
}
};
AdapterLink.ViewHolderLink.Listener listener = new LinksListenerBase(mListener.getEventListenerBase()) {
@Override
public void onVote(Link link, AdapterLink.ViewHolderLink viewHolderLink, Likes vote) {
mListener.getEventListenerBase().onVote(link, vote).subscribe(new ObserverEmpty<Link>() {
@Override
public void onError(Throwable e) {
controllerLinks.getEventHolder().getErrors().call(LinksError.VOTE);
}
@Override
public void onNext(Link link) {
controllerLinks.update(link);
}
});
}
@Override
public void onDelete(Link link) {
new AlertDialog.Builder(getContext()).setTitle(R.string.delete_post).setMessage(link.getTitle()).setPositiveButton(R.string.yes, (dialog, which) -> {
mListener.getEventListenerBase().onDelete(link).subscribe(new ObserverEmpty<Link>() {
@Override
public void onError(Throwable e) {
controllerLinks.getEventHolder().getErrors().call(LinksError.DELETE);
}
@Override
public void onNext(Link link) {
controllerLinks.remove(link);
}
});
}).setNegativeButton(R.string.no, null).show();
}
@Override
public void onReport(Link link) {
// TODO: Add link title
new AlertDialog.Builder(getContext()).setTitle(R.string.report_title).setSingleChoiceItems(Report.getDisplayReasons(getResources()), -1, (dialog, which) -> {
reportSelected = Report.values()[which];
}).setPositiveButton(R.string.ok, (dialog, which) -> {
if (reportSelected == Report.OTHER) {
View viewDialog = LayoutInflater.from(getContext()).inflate(R.layout.dialog_text_input, null, false);
final EditText editText = (EditText) viewDialog.findViewById(R.id.edit_text);
editText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(100) });
new AlertDialog.Builder(getContext()).setView(viewDialog).setTitle(R.string.item_report).setPositiveButton(R.string.ok, (dialog1, which1) -> {
mListener.getEventListenerBase().onReport(link, editText.getText().toString()).subscribe(new ObserverError<String>() {
@Override
public void onError(Throwable e) {
controllerLinks.getEventHolder().getErrors().call(LinksError.REPORT);
}
});
}).setNegativeButton(R.string.cancel, (dialog1, which1) -> {
dialog1.dismiss();
}).show();
} else if (reportSelected != null) {
mListener.getEventListenerBase().onReport(link, reportSelected.getReason()).subscribe(new ObserverError<String>() {
@Override
public void onError(Throwable e) {
controllerLinks.getEventHolder().getErrors().call(LinksError.REPORT);
}
});
}
}).setNegativeButton(R.string.cancel, null).show();
}
@Override
public void onSave(Link link) {
if (link.isSaved()) {
mListener.getEventListenerBase().onUnsave(link).subscribe(new ObserverEmpty<Link>() {
@Override
public void onError(Throwable e) {
controllerLinks.getEventHolder().getErrors().call(LinksError.UNSAVE);
}
@Override
public void onNext(Link link) {
controllerLinks.update(link);
}
});
} else {
mListener.getEventListenerBase().onSave(link).subscribe(new ObserverEmpty<Link>() {
@Override
public void onError(Throwable e) {
controllerLinks.getEventHolder().getErrors().call(LinksError.SAVE);
}
@Override
public void onNext(Link link) {
controllerLinks.update(link);
}
});
}
}
@Override
public void onMarkNsfw(Link link) {
if (link.isOver18()) {
mListener.getEventListenerBase().onUnmarkNsfw(link).subscribe(new ObserverEmpty<Link>() {
@Override
public void onError(Throwable e) {
controllerLinks.getEventHolder().getErrors().call(LinksError.UNMARK_NSFW);
}
@Override
public void onNext(Link link) {
controllerLinks.update(link);
}
});
} else {
mListener.getEventListenerBase().onMarkNsfw(link).subscribe(new ObserverEmpty<Link>() {
@Override
public void onError(Throwable e) {
controllerLinks.getEventHolder().getErrors().call(LinksError.MARK_NSFW);
}
@Override
public void onNext(Link link) {
controllerLinks.update(link);
}
});
}
}
};
adapterLinkList = new AdapterLinkList(getActivity(), adapterListener, eventListenerHeader, listener);
adapterLinkGrid = new AdapterLinkGrid(getActivity(), adapterListener, eventListenerHeader, listener);
adapterLink = AppSettings.MODE_GRID.equals(preferences.getString(AppSettings.INTERFACE_MODE, AppSettings.MODE_GRID)) ? adapterLinkGrid : adapterLinkList;
itemDecorationDivider = new ItemDecorationDivider(getActivity(), ItemDecorationDivider.VERTICAL_LIST);
// recyclerThreadList.setItemAnimator(null);
resetAdapter(adapterLink);
recyclerThreadList.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
switch(newState) {
case RecyclerView.SCROLL_STATE_IDLE:
case RecyclerView.SCROLL_STATE_DRAGGING:
picasso.resumeTag(AdapterLink.TAG_PICASSO);
break;
case RecyclerView.SCROLL_STATE_SETTLING:
picasso.pauseTag(AdapterLink.TAG_PICASSO);
break;
}
}
});
itemTouchHelper = new CustomItemTouchHelper(new CustomItemTouchHelper.SimpleCallback(getActivity(), R.drawable.ic_visibility_off_white_24dp, ItemTouchHelper.START | ItemTouchHelper.END, ItemTouchHelper.START | ItemTouchHelper.END) {
@Override
public float getSwipeThreshold(RecyclerView.ViewHolder viewHolder) {
if (layoutManager instanceof StaggeredGridLayoutManager) {
return 1f / ((StaggeredGridLayoutManager) layoutManager).getSpanCount();
}
return 0.5f;
}
@Override
public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
if (viewHolder.getAdapterPosition() == 0) {
return 0;
}
ViewGroup.LayoutParams layoutParams = viewHolder.itemView.getLayoutParams();
if (layoutParams instanceof StaggeredGridLayoutManager.LayoutParams && !((StaggeredGridLayoutManager.LayoutParams) layoutParams).isFullSpan()) {
int spanCount = layoutManager instanceof StaggeredGridLayoutManager ? ((StaggeredGridLayoutManager) layoutManager).getSpanCount() : 2;
int spanIndex = ((StaggeredGridLayoutManager.LayoutParams) layoutParams).getSpanIndex() % spanCount;
if (spanIndex == 0) {
return ItemTouchHelper.END;
} else if (spanIndex == spanCount - 1) {
return ItemTouchHelper.START;
}
}
return super.getSwipeDirs(recyclerView, viewHolder);
}
@Override
public boolean isLongPressDragEnabled() {
return false;
}
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return false;
}
@Override
public void onSwiped(final RecyclerView.ViewHolder viewHolder, int direction) {
// Offset by 1 due to subreddit header
Link link = controllerLinks.hideLink(viewHolder.getAdapterPosition());
mListener.getEventListenerBase().hide(link);
if (snackbar != null) {
snackbar.dismiss();
}
SpannableString text = new SpannableString(link.isHidden() ? getString(R.string.link_hidden) : getString(R.string.link_shown));
text.setSpan(new ForegroundColorSpan(themer.getColorFilterPrimary().getColor()), 0, text.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
//noinspection ResourceType
snackbar = Snackbar.make(recyclerThreadList, text, UtilsAnimation.SNACKBAR_DURATION).setActionTextColor(themer.getColorFilterPrimary().getColor()).setAction(R.string.undo, v -> {
mListener.getEventListenerBase().hide(link);
controllerLinks.reshowLastHiddenLink();
});
snackbar.getView().setBackgroundColor(themer.getColorPrimary());
snackbar.show();
}
});
itemTouchHelper.attachToRecyclerView(recyclerThreadList);
recyclerThreadList.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
// rv.getChildViewHolder(rv.findChildViewUnder(e.getX(), e.getY()));
return false;
}
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
});
if (layoutManager instanceof LinearLayoutManager) {
recyclerThreadList.setPadding(0, 0, 0, 0);
} else {
int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
recyclerThreadList.setPadding(padding, 0, padding, 0);
}
textSidebar.setMovementMethod(LinkMovementMethod.getInstance());
buttonSubscribe.setOnClickListener(v -> controllerLinks.subscribe());
return view;
}
use of com.winsonchiu.reader.rx.ObserverError in project Reader by TheKeeperOfPie.
the class FragmentCommentsInner method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
scrollToPaddingTop = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics());
scrollToPaddingBottom = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 56, getResources().getDisplayMetrics());
layoutRoot = (CustomFrameLayout) inflater.inflate(R.layout.fragment_comments_inner, container, false);
CallbackYouTubeDestruction callbackYouTubeDestruction = () -> {
adapterCommentList.destroyYouTubePlayerFragments();
adapterLink.destroyYouTubePlayerFragments();
};
swipeRefreshCommentList = (SwipeRefreshLayout) layoutRoot.findViewById(R.id.swipe_refresh_comment_list);
swipeRefreshCommentList.setOnRefreshListener(() -> controllerComments.reloadAllComments());
linearLayoutManager = new LinearLayoutManager(getActivity());
recyclerCommentList = (RecyclerView) layoutRoot.findViewById(R.id.recycler_comment_list);
recyclerCommentList.setLayoutManager(linearLayoutManager);
recyclerCommentList.setHasFixedSize(true);
recyclerCommentList.setItemAnimator(null);
AdapterListener adapterListenerComment = new AdapterListener() {
@Override
public void scrollAndCenter(int position, int height) {
linearLayoutManager.scrollToPositionWithOffset(position, 0);
}
@Override
public void hideToolbar() {
callback.hideToolbar();
}
@Override
public void clearDecoration() {
callback.clearDecoration();
}
@Override
public void requestMore() {
controllerComments.loadMoreComments();
}
@Override
public void requestDisallowInterceptTouchEventVertical(boolean disallow) {
recyclerCommentList.requestDisallowInterceptTouchEvent(disallow);
swipeRefreshCommentList.requestDisallowInterceptTouchEvent(disallow);
}
@Override
public void requestDisallowInterceptTouchEventHorizontal(boolean disallow) {
}
};
AdapterLink.ViewHolderLink.Listener listenerLink = new LinksListenerBase(mListener.getEventListenerBase()) {
@Override
public void onVote(Link link, AdapterLink.ViewHolderLink viewHolderLink, Likes vote) {
}
@Override
public void onDelete(Link link) {
}
@Override
public void onReport(Link link) {
}
@Override
public void onSave(Link link) {
}
@Override
public void onMarkNsfw(Link link) {
}
};
AdapterCommentList.ViewHolderComment.Listener listenerComment = new AdapterCommentList.ViewHolderComment.Listener() {
@Override
public void onToggleComment(Comment comment) {
controllerComments.toggleComment(comment);
}
@Override
public void onShowReplyEditor(Comment comment) {
}
@Override
public void onEditComment(Comment comment, String text) {
}
@Override
public void onSendComment(Comment comment, String text) {
}
@Override
public void onMarkRead(Comment comment) {
}
@Override
public void onLoadNestedComments(Comment comment) {
controllerComments.loadNestedComments(comment);
}
@Override
public void onJumpToParent(Comment comment) {
controllerComments.jumpToParent(comment);
}
@Override
public void onViewProfile(Comment comment) {
}
@Override
public void onCopyText(Comment comment) {
}
@Override
public void onDeleteComment(Comment comment) {
}
@Override
public void onReport(Comment comment) {
// TODO: Add comment text
new AlertDialog.Builder(getContext()).setTitle(R.string.report_title).setSingleChoiceItems(Report.getDisplayReasons(getResources()), -1, (dialog, which) -> {
reportSelected = Report.values()[which];
}).setPositiveButton(R.string.ok, (dialog, which) -> {
if (reportSelected == Report.OTHER) {
View viewDialog = LayoutInflater.from(getContext()).inflate(R.layout.dialog_text_input, null, false);
final EditText editText = (EditText) viewDialog.findViewById(R.id.edit_text);
editText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(100) });
new AlertDialog.Builder(getContext()).setView(viewDialog).setTitle(R.string.item_report).setPositiveButton(R.string.ok, (dialog1, which1) -> {
mListener.getEventListenerBase().onReport(link, editText.getText().toString()).subscribe(new ObserverError<String>() {
@Override
public void onError(Throwable e) {
controllerComments.getEventHolder().getErrors().call(CommentsError.REPORT);
}
});
}).setNegativeButton(R.string.cancel, (dialog1, which1) -> {
dialog1.dismiss();
}).show();
} else if (reportSelected != null) {
mListener.getEventListenerBase().onReport(link, reportSelected.getReason()).subscribe(new ObserverError<String>() {
@Override
public void onError(Throwable e) {
controllerComments.getEventHolder().getErrors().call(CommentsError.REPORT);
}
});
}
}).setNegativeButton(R.string.cancel, null).show();
}
@Override
public void onVoteComment(Comment comment, AdapterCommentList.ViewHolderComment viewHolderComment, Likes vote) {
}
@Override
public void onSave(Comment comment) {
}
};
adapterCommentList = new AdapterCommentList(getActivity(), adapterListenerComment, listenerComment, listenerLink, youTubeListener, callbackYouTubeDestruction, getArguments().getBoolean(ARG_IS_GRID, false), getArguments().getString(ARG_FIRST_LINK_NAME), getArguments().getInt(ARG_COLOR_LINK, 0), getArguments().getBoolean(ARG_ACTIONS_EXPANDED, false));
observer = new RecyclerView.AdapterDataObserver() {
@Override
public void onItemRangeChanged(int positionStart, int itemCount) {
super.onItemRangeChanged(positionStart, itemCount);
if (positionStart == 0) {
callback.releaseYouTube();
}
}
};
adapterCommentList.registerAdapterDataObserver(observer);
recyclerCommentList.setAdapter(adapterCommentList);
layoutManagerLink = new LinearLayoutManagerWrapHeight(getActivity(), LinearLayoutManager.VERTICAL, false);
layoutManagerLink.setOnSizeChangedListener((width, height, oldWidth, oldHeight) -> {
if (postExpanded && targetExpandPostHeight == 0) {
targetExpandPostHeight = height + heightExpandHandle;
postExpanded = false;
expandPost(true);
}
});
AdapterListener adapterListenerLink = new AdapterListener() {
@Override
public void scrollAndCenter(int position, int height) {
layoutManagerLink.scrollToPositionWithOffset(position, 0);
}
@Override
public void hideToolbar() {
callback.hideToolbar();
}
@Override
public void clearDecoration() {
callback.clearDecoration();
}
@Override
public void requestMore() {
}
@Override
public void requestDisallowInterceptTouchEventVertical(boolean disallow) {
recyclerLink.requestDisallowInterceptTouchEvent(disallow);
}
@Override
public void requestDisallowInterceptTouchEventHorizontal(boolean disallow) {
}
};
adapterLink = new AdapterLinkHeader(getActivity(), controllerComments, adapterListenerLink, listenerLink, youTubeListener, callbackYouTubeDestruction, getArguments().getBoolean(ARG_IS_GRID, false), getArguments().getString(ARG_FIRST_LINK_NAME), getArguments().getInt(ARG_COLOR_LINK, 0), getArguments().getBoolean(ARG_ACTIONS_EXPANDED, false));
final GestureDetectorCompat gestureDetectorExpand = new GestureDetectorCompat(getActivity(), new GestureDetector.SimpleOnGestureListener() {
private float startY;
private int startHeight;
@Override
public boolean onDown(MotionEvent e) {
if (targetExpandPostHeight == 0) {
targetExpandPostHeight = layoutManagerLink.getFirstChildHeight() + heightExpandHandle;
}
if (e.getY() > imageExpandIndicator.getY() && e.getY() < imageExpandIndicator.getY() + heightExpandHandle) {
startY = e.getY();
startHeight = targetExpandPostHeight;
} else {
startY = 0;
}
return super.onDown(e);
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (startY == 0) {
return super.onScroll(e1, e2, distanceX, distanceY);
}
float distance = e2.getY() - startY;
targetExpandPostHeight = (int) Math.min(startHeight + distance, layoutRoot.getHeight());
layoutExpandPostInner.getLayoutParams().height = targetExpandPostHeight;
layoutExpandPostInner.requestLayout();
return super.onScroll(e1, e2, distanceX, distanceY);
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (startY == 0) {
return super.onFling(e1, e2, velocityX, velocityY);
}
if (velocityY < -expandFlingThreshold) {
startY = 0;
expandPost(false);
return true;
} else if (velocityY > expandFlingThreshold) {
startY = 0;
targetExpandPostHeight = layoutRoot.getHeight() - heightExpandHandle;
postExpanded = false;
expandPost(true);
return true;
}
return super.onFling(e1, e2, velocityX, velocityY);
}
});
heightExpandHandle = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 33, getResources().getDisplayMetrics());
expandFlingThreshold = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, EXPAND_FLING_THRESHOLD, getResources().getDisplayMetrics());
layoutExpandPostInner = (ViewGroup) layoutRoot.findViewById(R.id.layout_expand_post_inner);
imageExpandIndicator = (ImageView) layoutRoot.findViewById(R.id.image_expand_indicator);
imageExpandIndicator.setColorFilter(themer.getColorFilterIcon());
layoutRoot.setDispatchTouchListener((v, event) -> gestureDetectorExpand.onTouchEvent(event));
recyclerLink = (RecyclerView) layoutRoot.findViewById(R.id.recycler_link);
recyclerLink.setLayoutManager(layoutManagerLink);
recyclerLink.setItemAnimator(null);
if (savedInstanceState != null) {
String youtubeId = savedInstanceState.getString(ARG_YOUTUBE_ID, null);
if (!TextUtils.isEmpty(youtubeId)) {
callback.loadYouTubeVideo(youtubeId, savedInstanceState.getInt(ARG_YOUTUBE_TIME, 0));
}
}
if (savedInstanceState != null && savedInstanceState.containsKey("Link")) {
adapterLink.setAnimationFinished(true);
adapterCommentList.setAnimationFinished(true);
controllerComments.setLinkFromCache((Link) savedInstanceState.get("Link"));
} else if (link != null) {
controllerComments.setLink(link);
link = null;
}
adapterCommentList.setData(controllerComments.getData());
if (animationFinished) {
setAnimationFinished(true);
}
return layoutRoot;
}
Aggregations