Search in sources :

Example 66 with MainActivity

use of com.odysee.app.MainActivity 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)

Example 67 with MainActivity

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

the class LibraryFragment method onPlaylistsLoaded.

private void onPlaylistsLoaded(List<OdyseeCollection> collections) {
    PlaylistCollectionListAdapter adapter = new PlaylistCollectionListAdapter(collections, getContext());
    adapter.setListener(new PlaylistCollectionListAdapter.ClickListener() {

        @Override
        public void onClick(OdyseeCollection collection, int position) {
            if (OdyseeCollection.PLACEHOLDER_ID_NEW.equalsIgnoreCase(collection.getId())) {
                // new playlist
                return;
            }
            // open the playlist
            Context context = getContext();
            if (context instanceof MainActivity) {
                MainActivity activity = (MainActivity) context;
                activity.openPlaylistFragment(collection.getId());
            }
        }
    });
    if (playlistsList != null) {
        playlistsList.setAdapter(adapter);
    }
    Helper.setViewVisibility(playlistsLoading, View.INVISIBLE);
}
Also used : PlaylistCollectionListAdapter(com.odysee.app.adapter.PlaylistCollectionListAdapter) Context(android.content.Context) MainActivity(com.odysee.app.MainActivity) OdyseeCollection(com.odysee.app.model.OdyseeCollection)

Example 68 with MainActivity

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

the class LibraryFragment method onResume.

public void onResume() {
    super.onResume();
    Context context = getContext();
    Helper.setWunderbarValue(null, context);
    if (context instanceof MainActivity) {
        MainActivity activity = (MainActivity) context;
        LbryAnalytics.setCurrentScreen(activity, "Library", "Library");
    // activity.addDownloadActionListener(this);
    }
    // renderFilter(); // Show tab according to selected filter
    showRecent();
    loadPlaylists();
}
Also used : Context(android.content.Context) MainActivity(com.odysee.app.MainActivity)

Example 69 with MainActivity

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

the class LibraryFragment method onEnterSelectionMode.

public void onEnterSelectionMode() {
    Context context = getContext();
    if (context instanceof MainActivity) {
        MainActivity activity = (MainActivity) context;
        activity.startSupportActionMode(this);
    }
}
Also used : Context(android.content.Context) MainActivity(com.odysee.app.MainActivity)

Example 70 with MainActivity

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

the class AddToListsDialogFragment method loadPlaylists.

private void loadPlaylists() {
    Context context = getContext();
    if (context instanceof MainActivity) {
        MainActivity activity = (MainActivity) context;
        Helper.setViewVisibility(loadProgress, View.VISIBLE);
        Executors.newSingleThreadExecutor().execute(new Runnable() {

            @Override
            public void run() {
                SQLiteDatabase db = activity.getDbHelper().getReadableDatabase();
                List<OdyseeCollection> privateCollections = DatabaseHelper.getSimpleCollections(db);
                List<OdyseeCollection> publicCollections = new ArrayList<>();
                try {
                    publicCollections = Lbry.loadOwnCollections(Lbryio.AUTH_TOKEN);
                } catch (ApiCallException | JSONException ex) {
                // pass
                }
                // Also need to load published / public lists at this point
                List<OdyseeCollection> collections = new ArrayList<>(privateCollections);
                collections.addAll(publicCollections);
                new Handler(Looper.getMainLooper()).post(new Runnable() {

                    @Override
                    public void run() {
                        onPlaylistsLoaded(collections);
                    }
                });
            }
        });
    }
}
Also used : Context(android.content.Context) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Handler(android.os.Handler) ArrayList(java.util.ArrayList) List(java.util.List) MainActivity(com.odysee.app.MainActivity)

Aggregations

MainActivity (com.odysee.app.MainActivity)138 Context (android.content.Context)119 Claim (com.odysee.app.model.Claim)39 View (android.view.View)31 TextView (android.widget.TextView)30 RecyclerView (androidx.recyclerview.widget.RecyclerView)26 AttributeProviderContext (org.commonmark.renderer.html.AttributeProviderContext)25 ArrayList (java.util.ArrayList)21 TrackSelectionOverride (com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride)19 ImageView (android.widget.ImageView)18 SuppressLint (android.annotation.SuppressLint)15 AdapterView (android.widget.AdapterView)14 NestedScrollView (androidx.core.widget.NestedScrollView)14 JSONException (org.json.JSONException)13 JSONObject (org.json.JSONObject)13 SolidIconView (com.odysee.app.ui.controls.SolidIconView)12 HashMap (java.util.HashMap)12 ClaimListAdapter (com.odysee.app.adapter.ClaimListAdapter)11 ApiCallException (com.odysee.app.exceptions.ApiCallException)11 WebView (android.webkit.WebView)10