use of com.odysee.app.MainActivity in project odysee-android by OdyseeTeam.
the class ChannelFragment method renderClaim.
private void renderClaim() {
if (claim == null) {
renderNothingAtLocation();
return;
}
loadSubCount();
checkIsFollowing();
layoutLoadingState.setVisibility(View.GONE);
layoutDisplayArea.setVisibility(View.VISIBLE);
if (claim.getTags().contains("disable-support"))
buttonTip.setVisibility(View.GONE);
else
buttonTip.setVisibility(View.VISIBLE);
String thumbnailUrl = "";
String coverUrl = claim.getCoverUrl();
textTitle.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle());
Context context = getContext();
if (context != null) {
thumbnailUrl = claim.getThumbnailUrl(imageThumbnail.getLayoutParams().width, imageThumbnail.getLayoutParams().height, 85);
}
if (context != null && !Helper.isNullOrEmpty(coverUrl)) {
Glide.with(context.getApplicationContext()).load(coverUrl).centerCrop().into(imageCover);
}
if (context != null && !Helper.isNullOrEmpty(thumbnailUrl)) {
Glide.with(context.getApplicationContext()).load(thumbnailUrl).apply(RequestOptions.circleCropTransform()).into(imageThumbnail);
noThumbnailView.setVisibility(View.GONE);
} else {
imageThumbnail.setVisibility(View.GONE);
int bgColor = Helper.generateRandomColorForValue(claim.getClaimId());
Helper.setIconViewBackgroundColor(noThumbnailView, bgColor, false, getContext());
noThumbnailView.setVisibility(View.VISIBLE);
if (claim.getName() != null) {
textAlpha.setText(claim.getName().substring(1, 2));
}
}
try {
if (tabPager.getAdapter() == null && context instanceof MainActivity) {
tabPager.setAdapter(new ChannelPagerAdapter(claim, commentHash, (MainActivity) context));
if (!Helper.isNullOrEmpty(commentHash)) {
// set the Comments tab active if a comment hash is set
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
tabPager.setCurrentItem(3);
}
}, 500);
}
}
new TabLayoutMediator(tabLayout, tabPager, new TabLayoutMediator.TabConfigurationStrategy() {
@Override
public void onConfigureTab(@NonNull TabLayout.Tab tab, int position) {
switch(position) {
case 0:
tab.setText(R.string.content);
break;
case 1:
tab.setText(R.string.playlists);
break;
case 2:
tab.setText(R.string.about);
break;
case 3:
tab.setText(R.string.comments);
break;
}
}
}).attach();
} catch (IllegalStateException ex) {
// TODO: Fix why this is happening
// pass
}
}
use of com.odysee.app.MainActivity in project odysee-android by OdyseeTeam.
the class ChannelManagerFragment method onActionItemClicked.
@Override
public boolean onActionItemClicked(androidx.appcompat.view.ActionMode actionMode, MenuItem menuItem) {
if (R.id.action_edit == menuItem.getItemId()) {
if (adapter != null && adapter.getSelectedCount() > 0) {
Claim claim = adapter.getSelectedItems().get(0);
// start channel editor with the claim
Context context = getContext();
if (context instanceof MainActivity) {
Map<String, Object> params = new HashMap<>();
params.put("claim", claim);
((MainActivity) context).openFragment(ChannelFormFragment.class, true, params);
}
actionMode.finish();
return true;
}
}
if (R.id.action_delete == menuItem.getItemId()) {
if (adapter != null && adapter.getSelectedCount() > 0) {
final List<Claim> selectedClaims = new ArrayList<>(adapter.getSelectedItems());
String message = getResources().getQuantityString(R.plurals.confirm_delete_channels, selectedClaims.size());
Context c = getContext();
if (c != null) {
AlertDialog.Builder builder = new AlertDialog.Builder(c).setTitle(R.string.delete_selection).setMessage(message).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
handleDeleteSelectedClaims(selectedClaims);
}
}).setNegativeButton(R.string.no, null);
builder.show();
}
return true;
}
}
return false;
}
use of com.odysee.app.MainActivity in project odysee-android by OdyseeTeam.
the class ChannelManagerFragment 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 ChannelContentFragment method onPause.
public void onPause() {
Context context = getContext();
if (context != null) {
((MainActivity) context).removeDownloadActionListener(this);
}
PreferenceManager.getDefaultSharedPreferences(context).registerOnSharedPreferenceChangeListener(this);
super.onPause();
}
use of com.odysee.app.MainActivity 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;
}
Aggregations