use of androidx.recyclerview.widget.RecyclerView in project AntennaPod by AntennaPod.
the class NewEpisodesFragment method onCreateView.
@NonNull
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = super.onCreateView(inflater, container, savedInstanceState);
emptyView.setTitle(R.string.no_new_episodes_head_label);
emptyView.setMessage(R.string.no_new_episodes_label);
ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) {
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return false;
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
EpisodeItemViewHolder holder = (EpisodeItemViewHolder) viewHolder;
FeedItemMenuHandler.removeNewFlagWithUndo(NewEpisodesFragment.this, holder.getFeedItem());
}
};
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
itemTouchHelper.attachToRecyclerView(recyclerView);
return root;
}
use of androidx.recyclerview.widget.RecyclerView 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.RecyclerView in project AntennaPod by AntennaPod.
the class EpisodesListFragment method onCreateView.
@NonNull
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View root = inflater.inflate(R.layout.all_episodes_fragment, container, false);
txtvInformation = root.findViewById(R.id.txtvInformation);
recyclerView = root.findViewById(android.R.id.list);
recyclerView.setRecycledViewPool(((MainActivity) getActivity()).getRecycledViewPool());
setupLoadMoreScrollListener();
RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator();
if (animator instanceof SimpleItemAnimator) {
((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
}
SwipeRefreshLayout swipeRefreshLayout = root.findViewById(R.id.swipeRefresh);
swipeRefreshLayout.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance));
swipeRefreshLayout.setOnRefreshListener(() -> {
AutoUpdateManager.runImmediate(requireContext());
new Handler(Looper.getMainLooper()).postDelayed(() -> swipeRefreshLayout.setRefreshing(false), getResources().getInteger(R.integer.swipe_to_refresh_duration_in_ms));
});
progLoading = root.findViewById(R.id.progLoading);
progLoading.setVisibility(View.VISIBLE);
loadingMoreView = root.findViewById(R.id.loadingMore);
emptyView = new EmptyViewHandler(getContext());
emptyView.attachToRecyclerView(recyclerView);
emptyView.setIcon(R.drawable.ic_feed);
emptyView.setTitle(R.string.no_all_episodes_head_label);
emptyView.setMessage(R.string.no_all_episodes_label);
createRecycleAdapter(recyclerView, emptyView);
emptyView.hide();
return root;
}
use of androidx.recyclerview.widget.RecyclerView 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.RecyclerView in project Douya by DreaminginCodeZH.
the class NavigationViewAdapter method override.
public static NavigationViewAdapter override(NavigationView navigationView, NavigationAccountListLayout.Adapter accountListAdapter, NavigationAccountListLayout.Listener accountListListener) {
RecyclerView recyclerView = (RecyclerView) navigationView.getChildAt(navigationView.getChildCount() - 1);
NavigationViewAdapter adapter = new NavigationViewAdapter(navigationView, recyclerView.getAdapter(), accountListAdapter, accountListListener);
recyclerView.setAdapter(adapter);
return adapter;
}
Aggregations