use of androidx.recyclerview.widget.LinearLayoutManager in project AntennaPod by AntennaPod.
the class SearchFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.search_fragment, container, false);
setupToolbar(layout.findViewById(R.id.toolbar));
progressBar = layout.findViewById(R.id.progressBar);
recyclerView = layout.findViewById(R.id.recyclerView);
recyclerView.setRecycledViewPool(((MainActivity) getActivity()).getRecycledViewPool());
adapter = new EpisodeItemListAdapter((MainActivity) getActivity());
recyclerView.setAdapter(adapter);
RecyclerView recyclerViewFeeds = layout.findViewById(R.id.recyclerViewFeeds);
LinearLayoutManager layoutManagerFeeds = new LinearLayoutManager(getActivity());
layoutManagerFeeds.setOrientation(RecyclerView.HORIZONTAL);
recyclerViewFeeds.setLayoutManager(layoutManagerFeeds);
adapterFeeds = new FeedSearchResultAdapter((MainActivity) getActivity());
recyclerViewFeeds.setAdapter(adapterFeeds);
emptyViewHandler = new EmptyViewHandler(getContext());
emptyViewHandler.attachToRecyclerView(recyclerView);
emptyViewHandler.setIcon(R.drawable.ic_search);
emptyViewHandler.setTitle(R.string.search_status_no_results);
emptyViewHandler.setMessage(R.string.type_to_search);
EventBus.getDefault().register(this);
chip = layout.findViewById(R.id.feed_title_chip);
chip.setOnCloseIconClickListener(v -> {
getArguments().putLong(ARG_FEED, 0);
searchWithProgressBar();
});
chip.setVisibility((getArguments().getLong(ARG_FEED, 0) == 0) ? View.GONE : View.VISIBLE);
chip.setText(getArguments().getString(ARG_FEED_NAME, ""));
if (getArguments().getString(ARG_QUERY, null) != null) {
search();
}
searchView.setOnQueryTextFocusChangeListener((view, hasFocus) -> {
if (hasFocus) {
showInputMethod(view.findFocus());
}
});
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(recyclerView.getWindowToken(), 0);
}
}
});
return layout;
}
use of androidx.recyclerview.widget.LinearLayoutManager in project Douya by DreaminginCodeZH.
the class BroadcastFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
CustomTabsHelperFragment.attachTo(this);
mResource = BroadcastAndCommentListResource.attachTo(mBroadcastId, mBroadcast, this);
AppCompatActivity activity = (AppCompatActivity) getActivity();
activity.setTitle(getTitle());
activity.setSupportActionBar(mToolbar);
mContainerLayout.setOnClickListener(view -> onFinish());
ViewCompat.setTransitionName(mSharedView, Broadcast.makeTransitionName(mBroadcastId));
// This magically gives better visual effect when the broadcast is partially visible. Using
// setEnterSharedElementCallback() disables this hack when no transition is used to start
// this Activity.
ActivityCompat.setEnterSharedElementCallback(activity, new SharedElementCallback() {
@Override
public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
mBroadcastCommentList.scrollToPosition(0);
}
});
mToolbar.setOnDoubleClickListener(view -> {
mBroadcastCommentList.smoothScrollToPosition(0);
return true;
});
mSwipeRefreshLayout.setOnRefreshListener(() -> {
mResource.loadBroadcast();
mResource.loadCommentList(false);
});
mBroadcastCommentList.setHasFixedSize(true);
mBroadcastCommentList.setItemAnimator(new NoChangeAnimationItemAnimator());
mBroadcastCommentList.setLayoutManager(new LinearLayoutManager(activity));
mBroadcastAdapter = new SingleBroadcastAdapter(null, this);
// BroadcastLayout will take care of showing the effective broadcast.
// noinspection deprecation
setBroadcast(mResource.getBroadcast());
mCommentAdapter = new CommentAdapter(mResource.getCommentList(), (parent, itemView, item, position) -> onShowCommentAction(item));
mAdapter = new LoadMoreAdapter(mBroadcastAdapter, mCommentAdapter);
mBroadcastCommentList.setAdapter(mAdapter);
mBroadcastCommentList.addOnScrollListener(new OnVerticalScrollListener() {
public void onScrolledToBottom() {
mResource.loadCommentList(true);
}
});
mSendButton.setOnClickListener(view -> onSendComment());
TooltipUtils.setup(mSendButton);
View.OnLongClickListener sendTooltipListener = mSendButton.getOnLongClickListener();
mSendButton.setOnLongClickListener(view -> {
if (!Settings.LONG_CLICK_TO_SHOW_SEND_COMMENT_ACTIVITY.getValue()) {
return sendTooltipListener.onLongClick(view);
}
onShowSendCommentActivity();
return true;
});
updateSendCommentStatus();
if (savedInstanceState == null) {
if (mShowSendComment) {
TransitionUtils.postAfterTransition(this, this::onShowCommentIme);
}
}
TransitionUtils.setEnterReturnExplode(this);
TransitionUtils.setupTransitionOnActivityCreated(this);
}
use of androidx.recyclerview.widget.LinearLayoutManager in project Douya by DreaminginCodeZH.
the class BaseItemDataAdapter method createCelebrityListHolder.
protected CelebrityListHolder createCelebrityListHolder(ViewGroup parent) {
CelebrityListHolder holder = new CelebrityListHolder(ViewUtils.inflate(R.layout.item_fragment_celebrity_list, parent));
holder.celebrityList.setHasFixedSize(true);
holder.celebrityList.setLayoutManager(new LinearLayoutManager(parent.getContext(), LinearLayoutManager.HORIZONTAL, false));
holder.celebrityList.addItemDecoration(new DividerItemDecoration(DividerItemDecoration.HORIZONTAL, R.drawable.transparent_divider_vertical_16dp, holder.celebrityList.getContext()));
holder.celebrityList.setAdapter(new CelebrityListAdapter());
return holder;
}
use of androidx.recyclerview.widget.LinearLayoutManager in project AntennaPod by AntennaPod.
the class ChooseDataFolderDialog method showDialog.
public static void showDialog(final Context context, Consumer<String> handlerFunc) {
View content = View.inflate(context, R.layout.choose_data_folder_dialog, null);
AlertDialog dialog = new AlertDialog.Builder(context).setView(content).setTitle(R.string.choose_data_directory).setMessage(R.string.choose_data_directory_message).setNegativeButton(R.string.cancel_label, null).create();
((RecyclerView) content.findViewById(R.id.recyclerView)).setLayoutManager(new LinearLayoutManager(context));
DataFolderAdapter adapter = new DataFolderAdapter(context, path -> {
dialog.dismiss();
handlerFunc.accept(path);
});
((RecyclerView) content.findViewById(R.id.recyclerView)).setAdapter(adapter);
if (adapter.getItemCount() > 0) {
dialog.show();
} else {
new AlertDialog.Builder(context).setTitle(R.string.error_label).setMessage(R.string.external_storage_error_msg).setPositiveButton(android.R.string.ok, null).show();
}
}
use of androidx.recyclerview.widget.LinearLayoutManager in project Douya by DreaminginCodeZH.
the class ProfileFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
CustomTabsHelperFragment.attachTo(this);
mResource = ProfileResource.attachTo(mUserIdOrUid, mSimpleUser, mUser, this);
mScrollLayout.setListener(new ProfileLayout.Listener() {
@Override
public void onEnterAnimationEnd() {
}
@Override
public void onExitAnimationEnd() {
getActivity().finish();
}
});
if (savedInstanceState == null) {
mScrollLayout.enter();
}
mDismissView.setOnClickListener(view -> exit());
AppCompatActivity activity = (AppCompatActivity) getActivity();
activity.setSupportActionBar(mToolbar);
activity.getSupportActionBar().setTitle(null);
if (mResource.hasUser()) {
mHeaderLayout.bindUser(mResource.getUser());
} else if (mResource.hasSimpleUser()) {
mHeaderLayout.bindSimpleUser(mResource.getSimpleUser());
}
mHeaderLayout.setListener(this);
mToolbar.setOnDoubleClickListener(view -> {
if (!mScrollLayout.isHeaderCollapsed()) {
return false;
}
mScrollLayout.animateHeaderViewScroll(false);
return true;
});
if (ViewUtils.hasSw600Dp(activity)) {
mContentList.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
} else {
mContentList.setLayoutManager(new LinearLayoutManager(activity));
}
mAdapter = new ProfileAdapter(this);
mContentList.setAdapter(mAdapter);
mContentStateLayout.setLoading();
if (mResource.isAnyLoaded()) {
mResource.notifyChangedIfLoaded();
}
}
Aggregations