Search in sources :

Example 31 with LinearLayoutManager

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;
}
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 32 with LinearLayoutManager

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);
}
Also used : ToastUtils(me.zhanghai.android.douya.util.ToastUtils) Bundle(android.os.Bundle) DoubleClickToolbar(me.zhanghai.android.douya.ui.DoubleClickToolbar) OnVerticalScrollListener(me.zhanghai.android.douya.ui.OnVerticalScrollListener) ProgressBar(android.widget.ProgressBar) FrameLayout(android.widget.FrameLayout) Comment(me.zhanghai.android.douya.network.api.info.frodo.Comment) LoadMoreAdapter(me.zhanghai.android.douya.ui.LoadMoreAdapter) GetOnLongClickListenerImageButton(me.zhanghai.android.douya.ui.GetOnLongClickListenerImageButton) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) BindView(butterknife.BindView) FragmentUtils(me.zhanghai.android.douya.util.FragmentUtils) ShareUtils(me.zhanghai.android.douya.util.ShareUtils) Fragment(androidx.fragment.app.Fragment) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) NoChangeAnimationItemAnimator(me.zhanghai.android.douya.ui.NoChangeAnimationItemAnimator) ViewCompat(androidx.core.view.ViewCompat) WebViewActivity(me.zhanghai.android.douya.ui.WebViewActivity) DeleteBroadcastManager(me.zhanghai.android.douya.broadcast.content.DeleteBroadcastManager) LikeBroadcastManager(me.zhanghai.android.douya.broadcast.content.LikeBroadcastManager) ConfirmDiscardContentDialogFragment(me.zhanghai.android.douya.ui.ConfirmDiscardContentDialogFragment) ThreadMode(org.greenrobot.eventbus.ThreadMode) ViewGroup(android.view.ViewGroup) DoubanUtils(me.zhanghai.android.douya.util.DoubanUtils) List(java.util.List) Nullable(androidx.annotation.Nullable) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) CustomTabsHelperFragment(me.zhanghai.android.customtabshelper.CustomTabsHelperFragment) EventBusUtils(me.zhanghai.android.douya.eventbus.EventBusUtils) ButterKnife(butterknife.ButterKnife) BroadcastCommentSentEvent(me.zhanghai.android.douya.eventbus.BroadcastCommentSentEvent) ApiError(me.zhanghai.android.douya.network.api.ApiError) FragmentFinishable(me.zhanghai.android.douya.ui.FragmentFinishable) MenuItem(android.view.MenuItem) Settings(me.zhanghai.android.douya.settings.info.Settings) ImeUtils(me.zhanghai.android.douya.util.ImeUtils) MenuInflater(android.view.MenuInflater) Menu(android.view.Menu) ClipboardUtils(me.zhanghai.android.douya.util.ClipboardUtils) LogUtils(me.zhanghai.android.douya.util.LogUtils) Broadcast(me.zhanghai.android.douya.network.api.info.frodo.Broadcast) TooltipUtils(me.zhanghai.android.douya.util.TooltipUtils) BroadcastCommentSendErrorEvent(me.zhanghai.android.douya.eventbus.BroadcastCommentSendErrorEvent) ActivityCompat(androidx.core.app.ActivityCompat) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) LayoutInflater(android.view.LayoutInflater) ViewUtils(me.zhanghai.android.douya.util.ViewUtils) DeleteBroadcastCommentManager(me.zhanghai.android.douya.broadcast.content.DeleteBroadcastCommentManager) TransitionUtils(me.zhanghai.android.douya.util.TransitionUtils) TextUtils(android.text.TextUtils) R(me.zhanghai.android.douya.R) BroadcastCommentCountFixer(me.zhanghai.android.douya.broadcast.content.BroadcastCommentCountFixer) RebroadcastBroadcastManager(me.zhanghai.android.douya.broadcast.content.RebroadcastBroadcastManager) Subscribe(org.greenrobot.eventbus.Subscribe) SendBroadcastCommentManager(me.zhanghai.android.douya.broadcast.content.SendBroadcastCommentManager) BroadcastAndCommentListResource(me.zhanghai.android.douya.broadcast.content.BroadcastAndCommentListResource) SharedElementCallback(androidx.core.app.SharedElementCallback) Activity(android.app.Activity) EditText(android.widget.EditText) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) OnVerticalScrollListener(me.zhanghai.android.douya.ui.OnVerticalScrollListener) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) BindView(butterknife.BindView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) SharedElementCallback(androidx.core.app.SharedElementCallback) LoadMoreAdapter(me.zhanghai.android.douya.ui.LoadMoreAdapter) NoChangeAnimationItemAnimator(me.zhanghai.android.douya.ui.NoChangeAnimationItemAnimator)

Example 33 with LinearLayoutManager

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;
}
Also used : LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerItemDecoration(me.zhanghai.android.douya.ui.DividerItemDecoration)

Example 34 with LinearLayoutManager

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();
    }
}
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 35 with LinearLayoutManager

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();
    }
}
Also used : AppCompatActivity(androidx.appcompat.app.AppCompatActivity) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Aggregations

LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)470 RecyclerView (androidx.recyclerview.widget.RecyclerView)281 View (android.view.View)183 TextView (android.widget.TextView)65 ArrayList (java.util.ArrayList)37 Nullable (androidx.annotation.Nullable)33 Bundle (android.os.Bundle)32 Toolbar (androidx.appcompat.widget.Toolbar)32 Intent (android.content.Intent)30 ImageView (android.widget.ImageView)27 List (java.util.List)24 Test (org.junit.Test)24 Context (android.content.Context)23 NonNull (androidx.annotation.NonNull)23 ViewGroup (android.view.ViewGroup)22 AlertDialog (androidx.appcompat.app.AlertDialog)21 ContextualCard (com.android.settings.homepage.contextualcards.ContextualCard)20 LayoutInflater (android.view.LayoutInflater)18 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)16 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)16