Search in sources :

Example 21 with RecyclerView

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;
}
Also used : ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) EpisodeItemViewHolder(de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder) EpisodeItemViewHolder(de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder) RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) NonNull(androidx.annotation.NonNull)

Example 22 with RecyclerView

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;
}
Also used : FeedSearchResultAdapter(de.danoeh.antennapod.adapter.FeedSearchResultAdapter) EmptyViewHandler(de.danoeh.antennapod.view.EmptyViewHandler) EpisodeItemListRecyclerView(de.danoeh.antennapod.view.EpisodeItemListRecyclerView) RecyclerView(androidx.recyclerview.widget.RecyclerView) InputMethodManager(android.view.inputmethod.InputMethodManager) MainActivity(de.danoeh.antennapod.activity.MainActivity) EpisodeItemListAdapter(de.danoeh.antennapod.adapter.EpisodeItemListAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) EpisodeItemListRecyclerView(de.danoeh.antennapod.view.EpisodeItemListRecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) SearchView(androidx.appcompat.widget.SearchView) Nullable(androidx.annotation.Nullable)

Example 23 with RecyclerView

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;
}
Also used : SimpleItemAnimator(androidx.recyclerview.widget.SimpleItemAnimator) EmptyViewHandler(de.danoeh.antennapod.view.EmptyViewHandler) FeedItemMenuHandler(de.danoeh.antennapod.menuhandler.FeedItemMenuHandler) Handler(android.os.Handler) EmptyViewHandler(de.danoeh.antennapod.view.EmptyViewHandler) RecyclerView(androidx.recyclerview.widget.RecyclerView) EpisodeItemListRecyclerView(de.danoeh.antennapod.view.EpisodeItemListRecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) EpisodeItemListRecyclerView(de.danoeh.antennapod.view.EpisodeItemListRecyclerView) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) NonNull(androidx.annotation.NonNull)

Example 24 with RecyclerView

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();
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) DataFolderAdapter(de.danoeh.antennapod.adapter.DataFolderAdapter)

Example 25 with RecyclerView

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;
}
Also used : RecyclerView(androidx.recyclerview.widget.RecyclerView)

Aggregations

RecyclerView (androidx.recyclerview.widget.RecyclerView)352 View (android.view.View)232 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)156 TextView (android.widget.TextView)51 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)39 ImageView (android.widget.ImageView)29 Nullable (androidx.annotation.Nullable)29 Toolbar (androidx.appcompat.widget.Toolbar)25 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)20 Intent (android.content.Intent)19 NonNull (androidx.annotation.NonNull)19 StaggeredGridLayoutManager (androidx.recyclerview.widget.StaggeredGridLayoutManager)19 Bundle (android.os.Bundle)18 ViewGroup (android.view.ViewGroup)16 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)16 Context (android.content.Context)15 Rect (android.graphics.Rect)15 SuppressLint (android.annotation.SuppressLint)12 LayoutInflater (android.view.LayoutInflater)11