Search in sources :

Example 1 with ContentFromDialogFragment

use of com.odysee.app.dialog.ContentFromDialogFragment in project odysee-android by OdyseeTeam.

the class ChannelContentFragment method onCreateView.

public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_channel_content, container, false);
    currentSortBy = ContentSortDialogFragment.ITEM_SORT_BY_NEW;
    currentContentFrom = ContentFromDialogFragment.ITEM_FROM_PAST_WEEK;
    sortLink = root.findViewById(R.id.channel_content_sort_link);
    contentFromLink = root.findViewById(R.id.channel_content_time_link);
    sortLinkText = root.findViewById(R.id.channel_content_sort_link_text);
    contentFromLinkText = root.findViewById(R.id.channel_content_time_link_text);
    bigContentLoading = root.findViewById(R.id.channel_content_main_progress);
    contentLoading = root.findViewById(R.id.channel_content_load_progress);
    noContentView = root.findViewById(R.id.channel_content_no_claim_search_content);
    contentList = root.findViewById(R.id.channel_content_list);
    LinearLayoutManager llm = new LinearLayoutManager(getContext());
    contentList.setLayoutManager(llm);
    contentList.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
            if (contentClaimSearchLoading) {
                return;
            }
            LinearLayoutManager lm = (LinearLayoutManager) recyclerView.getLayoutManager();
            if (lm != null) {
                int visibleItemCount = lm.getChildCount();
                int totalItemCount = lm.getItemCount();
                int pastVisibleItems = lm.findFirstVisibleItemPosition();
                if (pastVisibleItems + visibleItemCount >= totalItemCount) {
                    if (!contentHasReachedEnd) {
                        // load more
                        currentClaimSearchPage++;
                        fetchClaimSearchContent();
                    }
                }
            }
        }
    });
    sortLink.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            ContentSortDialogFragment dialog = ContentSortDialogFragment.newInstance();
            dialog.setCurrentSortByItem(currentSortBy);
            dialog.setSortByListener(new ContentSortDialogFragment.SortByListener() {

                @Override
                public void onSortByItemSelected(int sortBy) {
                    onSortByChanged(sortBy);
                }
            });
            Context context = getContext();
            if (context instanceof MainActivity) {
                MainActivity activity = (MainActivity) context;
                dialog.show(activity.getSupportFragmentManager(), ContentSortDialogFragment.TAG);
            }
        }
    });
    contentFromLink.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            ContentFromDialogFragment dialog = ContentFromDialogFragment.newInstance();
            dialog.setCurrentFromItem(currentContentFrom);
            dialog.setContentFromListener(new ContentFromDialogFragment.ContentFromListener() {

                @Override
                public void onContentFromItemSelected(int contentFromItem) {
                    onContentFromChanged(contentFromItem);
                }
            });
            Context context = getContext();
            if (context instanceof MainActivity) {
                MainActivity activity = (MainActivity) context;
                dialog.show(activity.getSupportFragmentManager(), ContentFromDialogFragment.TAG);
            }
        }
    });
    return root;
}
Also used : Context(android.content.Context) MainActivity(com.odysee.app.MainActivity) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) ContentFromDialogFragment(com.odysee.app.dialog.ContentFromDialogFragment) RecyclerView(androidx.recyclerview.widget.RecyclerView) ContentSortDialogFragment(com.odysee.app.dialog.ContentSortDialogFragment)

Example 2 with ContentFromDialogFragment

use of com.odysee.app.dialog.ContentFromDialogFragment in project odysee-android by OdyseeTeam.

the class FollowingFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_following, container, false);
    // Following page is sorted by new by default, past week if sort is top
    currentSortBy = ContentSortDialogFragment.ITEM_SORT_BY_NEW;
    currentContentFrom = ContentFromDialogFragment.ITEM_FROM_PAST_WEEK;
    findFollowingContainer = root.findViewById(R.id.find_following_container);
    titleView = root.findViewById(R.id.find_following_page_title);
    infoView = root.findViewById(R.id.following_page_info);
    horizontalChannelList = root.findViewById(R.id.following_channel_list);
    layoutSortContainer = root.findViewById(R.id.following_filter_container);
    sortLink = root.findViewById(R.id.following_sort_link);
    sortLinkText = root.findViewById(R.id.following_sort_link_text);
    filterLink = root.findViewById(R.id.filter_by_channel_link);
    contentFromLink = root.findViewById(R.id.following_time_link);
    contentFromLinkText = root.findViewById(R.id.following_time_link_text);
    suggestedChannelGrid = root.findViewById(R.id.following_suggested_grid);
    suggestedDoneButton = root.findViewById(R.id.following_suggested_done_button);
    contentList = root.findViewById(R.id.following_content_list);
    bigContentLoading = root.findViewById(R.id.following_main_progress);
    contentLoading = root.findViewById(R.id.following_content_progress);
    channelListLoading = root.findViewById(R.id.following_channel_load_progress);
    discoverLink = root.findViewById(R.id.following_discover_link);
    noContentView = root.findViewById(R.id.following_no_claim_search_content);
    Context context = getContext();
    GridLayoutManager glm = new GridLayoutManager(context, 3);
    suggestedChannelGrid.setLayoutManager(glm);
    suggestedChannelGrid.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
            if (suggestedClaimSearchLoading) {
                return;
            }
            GridLayoutManager lm = (GridLayoutManager) recyclerView.getLayoutManager();
            if (lm != null) {
                int visibleItemCount = lm.getChildCount();
                int totalItemCount = lm.getItemCount();
                int pastVisibleItems = lm.findFirstVisibleItemPosition();
                if (pastVisibleItems + visibleItemCount >= totalItemCount) {
                    if (!suggestedHasReachedEnd) {
                        // load more
                        currentSuggestedPage++;
                        fetchSuggestedChannels();
                    }
                }
            }
        }
    });
    LinearLayoutManager cllm = new LinearLayoutManager(context, RecyclerView.HORIZONTAL, false);
    horizontalChannelList.setLayoutManager(cllm);
    LinearLayoutManager llm = new LinearLayoutManager(context);
    contentList.setLayoutManager(llm);
    contentList.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
            if (contentClaimSearchLoading) {
                return;
            }
            LinearLayoutManager lm = (LinearLayoutManager) recyclerView.getLayoutManager();
            if (lm != null) {
                int visibleItemCount = lm.getChildCount();
                int totalItemCount = lm.getItemCount();
                int pastVisibleItems = lm.findFirstVisibleItemPosition();
                if (pastVisibleItems + visibleItemCount >= totalItemCount) {
                    if (!contentHasReachedEnd) {
                        // load more
                        currentClaimSearchPage++;
                        fetchClaimSearchContent();
                    }
                }
            }
        }
    });
    suggestedDoneButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            int selected = suggestedChannelAdapter == null ? 0 : suggestedChannelAdapter.getSelectedCount();
            int remaining = MIN_SUGGESTED_SUBSCRIBE_COUNT - selected;
            if (remaining == MIN_SUGGESTED_SUBSCRIBE_COUNT) {
                Snackbar.make(getView(), R.string.select_five_subscriptions, Snackbar.LENGTH_LONG).show();
            } else {
                fetchSubscriptions();
                showSubscribedContent();
                fetchAndResolveChannelList();
            }
        }
    });
    if (context != null) {
        SharedPreferences sharedpreferences = context.getSharedPreferences("lbry_shared_preferences", Context.MODE_PRIVATE);
        Helper.setViewVisibility(horizontalChannelList, sharedpreferences.getBoolean("subscriptions_filter_visibility", false) ? View.VISIBLE : View.GONE);
    }
    filterLink.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Helper.setViewVisibility(horizontalChannelList, horizontalChannelList.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
        }
    });
    sortLink.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            ContentSortDialogFragment dialog = ContentSortDialogFragment.newInstance();
            dialog.setCurrentSortByItem(currentSortBy);
            dialog.setSortByListener(new ContentSortDialogFragment.SortByListener() {

                @Override
                public void onSortByItemSelected(int sortBy) {
                    onSortByChanged(sortBy);
                }
            });
            Context context = getContext();
            if (context instanceof MainActivity) {
                MainActivity activity = (MainActivity) context;
                dialog.show(activity.getSupportFragmentManager(), ContentSortDialogFragment.TAG);
            }
        }
    });
    contentFromLink.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            ContentFromDialogFragment dialog = ContentFromDialogFragment.newInstance();
            dialog.setCurrentFromItem(currentContentFrom);
            dialog.setContentFromListener(new ContentFromDialogFragment.ContentFromListener() {

                @Override
                public void onContentFromItemSelected(int contentFromItem) {
                    onContentFromChanged(contentFromItem);
                }
            });
            Context context = getContext();
            if (context instanceof MainActivity) {
                MainActivity activity = (MainActivity) context;
                dialog.show(activity.getSupportFragmentManager(), ContentFromDialogFragment.TAG);
            }
        }
    });
    discoverLink.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Helper.setViewEnabled(discoverLink, false);
            buildChannelIdsAndUrls();
            currentSuggestedPage = 1;
            discoverDialog = DiscoverDialogFragment.newInstance();
            discoverDialog.setAdapter(suggestedChannelAdapter);
            discoverDialog.setDialogActionsListener(new DiscoverDialogFragment.DiscoverDialogListener() {

                @Override
                public void onScrollEndReached() {
                    if (suggestedClaimSearchLoading) {
                        return;
                    }
                    currentSuggestedPage++;
                    fetchSuggestedChannels();
                }

                @Override
                public void onCancel() {
                    discoverDialog = null;
                    excludeChannelIdsForDiscover = null;
                    if (suggestedChannelAdapter != null) {
                        suggestedChannelAdapter.clearItems();
                    }
                    Helper.setViewEnabled(discoverLink, true);
                }

                @Override
                public void onResume() {
                    if (suggestedChannelAdapter == null || suggestedChannelAdapter.getItemCount() == 0) {
                        discoverDialog.setLoading(true);
                        fetchSuggestedChannels();
                    }
                }
            });
            Context context = getContext();
            if (context instanceof MainActivity) {
                MainActivity activity = (MainActivity) context;
                discoverDialog.show(activity.getSupportFragmentManager(), DiscoverDialogFragment.TAG);
            }
        }
    });
    return root;
}
Also used : Context(android.content.Context) SharedPreferences(android.content.SharedPreferences) MainActivity(com.odysee.app.MainActivity) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) ContentFromDialogFragment(com.odysee.app.dialog.ContentFromDialogFragment) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) RecyclerView(androidx.recyclerview.widget.RecyclerView) ContentSortDialogFragment(com.odysee.app.dialog.ContentSortDialogFragment)

Example 3 with ContentFromDialogFragment

use of com.odysee.app.dialog.ContentFromDialogFragment in project odysee-android by OdyseeTeam.

the class AllContentFragment method onCreateView.

public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_all_content, container, false);
    // All content page is sorted by trending by default, past week if sort is top
    currentSortBy = ContentSortDialogFragment.ITEM_SORT_BY_TRENDING;
    currentContentFrom = ContentFromDialogFragment.ITEM_FROM_PAST_WEEK;
    layoutFilterContainer = root.findViewById(R.id.all_content_filter_container);
    sortLink = root.findViewById(R.id.all_content_sort_link);
    contentFromLink = root.findViewById(R.id.all_content_time_link);
    customizeLink = root.findViewById(R.id.all_content_customize_link);
    fromPrefix = root.findViewById(R.id.all_content_from_prefix);
    sortLinkText = root.findViewById(R.id.all_content_sort_link_text);
    contentFromLinkText = root.findViewById(R.id.all_content_time_link_text);
    bigContentLoading = root.findViewById(R.id.all_content_main_progress);
    contentLoading = root.findViewById(R.id.all_content_load_progress);
    noContentView = root.findViewById(R.id.all_content_no_claim_search_content);
    categorySelection = root.findViewById(R.id.category_selection_chipgroup);
    categorySelection.setOnCheckedChangeListener(new ChipGroup.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(ChipGroup group, int checkedId) {
            Chip chip = group.findViewById(checkedId);
            if (chip != null && chip.isChecked()) {
                // Use child index, because getTag() doesn't work properly for some reason
                currentCategoryId = categorySelection.indexOfChild(chip);
                currentChannelIdList = dynamicCategories.get(currentCategoryId).getChannelIds();
                onCategoryChanged();
            }
        }
    });
    contentList = root.findViewById(R.id.all_content_list);
    LinearLayoutManager llm = new LinearLayoutManager(getContext());
    contentList.setLayoutManager(llm);
    contentList.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
            if (contentClaimSearchLoading) {
                return;
            }
            LinearLayoutManager lm = (LinearLayoutManager) recyclerView.getLayoutManager();
            if (lm != null) {
                int visibleItemCount = lm.getChildCount();
                int totalItemCount = lm.getItemCount();
                int pastVisibleItems = lm.findFirstVisibleItemPosition();
                if (pastVisibleItems + visibleItemCount >= totalItemCount) {
                    if (!contentHasReachedEnd) {
                        // load more
                        currentClaimSearchPage++;
                        fetchClaimSearchContent();
                    }
                }
            }
        }
    });
    sortLink.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            ContentSortDialogFragment dialog = ContentSortDialogFragment.newInstance();
            dialog.setCurrentSortByItem(currentSortBy);
            dialog.setSortByListener(new ContentSortDialogFragment.SortByListener() {

                @Override
                public void onSortByItemSelected(int sortBy) {
                    onSortByChanged(sortBy);
                }
            });
            Context context = getContext();
            if (context instanceof MainActivity) {
                MainActivity activity = (MainActivity) context;
                dialog.show(activity.getSupportFragmentManager(), ContentSortDialogFragment.TAG);
            }
        }
    });
    contentFromLink.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            ContentFromDialogFragment dialog = ContentFromDialogFragment.newInstance();
            dialog.setCurrentFromItem(currentContentFrom);
            dialog.setContentFromListener(new ContentFromDialogFragment.ContentFromListener() {

                @Override
                public void onContentFromItemSelected(int contentFromItem) {
                    onContentFromChanged(contentFromItem);
                }
            });
            Context context = getContext();
            if (context instanceof MainActivity) {
                MainActivity activity = (MainActivity) context;
                dialog.show(activity.getSupportFragmentManager(), ContentFromDialogFragment.TAG);
            }
        }
    });
    customizeLink.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            showCustomizeTagsDialog();
        }
    });
    checkParams(false);
    return root;
}
Also used : Context(android.content.Context) MainActivity(com.odysee.app.MainActivity) Chip(com.google.android.material.chip.Chip) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) ContentFromDialogFragment(com.odysee.app.dialog.ContentFromDialogFragment) RecyclerView(androidx.recyclerview.widget.RecyclerView) ContentSortDialogFragment(com.odysee.app.dialog.ContentSortDialogFragment) ChipGroup(com.google.android.material.chip.ChipGroup)

Aggregations

Context (android.content.Context)3 View (android.view.View)3 TextView (android.widget.TextView)3 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)3 RecyclerView (androidx.recyclerview.widget.RecyclerView)3 MainActivity (com.odysee.app.MainActivity)3 ContentFromDialogFragment (com.odysee.app.dialog.ContentFromDialogFragment)3 ContentSortDialogFragment (com.odysee.app.dialog.ContentSortDialogFragment)3 SharedPreferences (android.content.SharedPreferences)1 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)1 Chip (com.google.android.material.chip.Chip)1 ChipGroup (com.google.android.material.chip.ChipGroup)1