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;
}
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);
}
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();
}
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);
}
}
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);
}
});
}
});
}
}
Aggregations