use of androidx.annotation.NonNull in project AntennaPod by AntennaPod.
the class EpisodesListFragment method onCreateView.
@NonNull
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View root = inflater.inflate(R.layout.all_episodes_fragment, container, false);
txtvInformation = root.findViewById(R.id.txtvInformation);
recyclerView = root.findViewById(android.R.id.list);
recyclerView.setRecycledViewPool(((MainActivity) getActivity()).getRecycledViewPool());
setupLoadMoreScrollListener();
RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator();
if (animator instanceof SimpleItemAnimator) {
((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
}
SwipeRefreshLayout swipeRefreshLayout = root.findViewById(R.id.swipeRefresh);
swipeRefreshLayout.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance));
swipeRefreshLayout.setOnRefreshListener(() -> {
AutoUpdateManager.runImmediate(requireContext());
new Handler(Looper.getMainLooper()).postDelayed(() -> swipeRefreshLayout.setRefreshing(false), getResources().getInteger(R.integer.swipe_to_refresh_duration_in_ms));
});
progLoading = root.findViewById(R.id.progLoading);
progLoading.setVisibility(View.VISIBLE);
loadingMoreView = root.findViewById(R.id.loadingMore);
emptyView = new EmptyViewHandler(getContext());
emptyView.attachToRecyclerView(recyclerView);
emptyView.setIcon(R.drawable.ic_feed);
emptyView.setTitle(R.string.no_all_episodes_head_label);
emptyView.setMessage(R.string.no_all_episodes_label);
createRecycleAdapter(recyclerView, emptyView);
emptyView.hide();
return root;
}
use of androidx.annotation.NonNull in project AntennaPod by AntennaPod.
the class ItunesAdapter method getView.
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
// Current podcast
PodcastSearchResult podcast = data.get(position);
// ViewHolder
PodcastViewHolder viewHolder;
// Resulting view
View view;
// Handle view holder stuff
if (convertView == null) {
view = ((MainActivity) context).getLayoutInflater().inflate(R.layout.itunes_podcast_listitem, parent, false);
viewHolder = new PodcastViewHolder(view);
view.setTag(viewHolder);
} else {
view = convertView;
viewHolder = (PodcastViewHolder) view.getTag();
}
// Set the title
viewHolder.titleView.setText(podcast.title);
if (podcast.author != null && !podcast.author.trim().isEmpty()) {
viewHolder.authorView.setText(podcast.author);
viewHolder.authorView.setVisibility(View.VISIBLE);
} else if (podcast.feedUrl != null && !podcast.feedUrl.contains("itunes.apple.com")) {
viewHolder.authorView.setText(podcast.feedUrl);
viewHolder.authorView.setVisibility(View.VISIBLE);
} else {
viewHolder.authorView.setVisibility(View.GONE);
}
// Update the empty imageView with the image from the feed
Glide.with(context).load(podcast.imageUrl).apply(new RequestOptions().placeholder(R.color.light_gray).diskCacheStrategy(DiskCacheStrategy.NONE).transforms(new FitCenter(), new RoundedCorners((int) (4 * context.getResources().getDisplayMetrics().density))).dontAnimate()).into(viewHolder.coverView);
// Feed the grid view
return view;
}
use of androidx.annotation.NonNull in project AntennaPod by AntennaPod.
the class Timeline method processShownotes.
/**
* Applies an app-specific CSS stylesheet and adds timecode links (optional).
* <p/>
* This method does NOT change the original shownotes string of the shownotesProvider object and it should
* also not be changed by the caller.
*
* @return The processed HTML string.
*/
@NonNull
public String processShownotes() {
String shownotes = rawShownotes;
if (TextUtils.isEmpty(shownotes)) {
Log.d(TAG, "shownotesProvider contained no shownotes. Returning 'no shownotes' message");
shownotes = "<html><head></head><body><p id='apNoShownotes'>" + noShownotesLabel + "</p></body></html>";
}
// replace ASCII line breaks with HTML ones if shownotes don't contain HTML line breaks already
if (!LINE_BREAK_REGEX.matcher(shownotes).find() && !shownotes.contains("<p>")) {
shownotes = shownotes.replace("\n", "<br />");
}
Document document = Jsoup.parse(shownotes);
document.head().appendElement("style").attr("type", "text/css").text(webviewStyle);
// apply timecode links
addTimecodes(document);
return document.toString();
}
use of androidx.annotation.NonNull in project AntennaPod by AntennaPod.
the class SyncService method doWork.
@Override
@NonNull
public Result doWork() {
ISyncService activeSyncProvider = getActiveSyncProvider();
if (activeSyncProvider == null) {
return Result.success();
}
SynchronizationSettings.updateLastSynchronizationAttempt();
setCurrentlyActive(true);
try {
activeSyncProvider.login();
syncSubscriptions(activeSyncProvider);
waitForDownloadServiceCompleted();
syncEpisodeActions(activeSyncProvider);
activeSyncProvider.logout();
clearErrorNotifications();
EventBus.getDefault().postSticky(new SyncServiceEvent(R.string.sync_status_success));
SynchronizationSettings.setLastSynchronizationAttemptSuccess(true);
return Result.success();
} catch (Exception e) {
EventBus.getDefault().postSticky(new SyncServiceEvent(R.string.sync_status_error));
SynchronizationSettings.setLastSynchronizationAttemptSuccess(false);
Log.e(TAG, Log.getStackTraceString(e));
if (e instanceof SyncServiceException) {
if (getRunAttemptCount() % 3 == 2) {
// Do not spam users with notification and retry before notifying
updateErrorNotification(e);
}
return Result.retry();
} else {
updateErrorNotification(e);
return Result.failure();
}
} finally {
setCurrentlyActive(false);
}
}
use of androidx.annotation.NonNull in project AntennaPod by AntennaPod.
the class LocalFeedUpdaterTest method mockDocumentFile.
/**
* Create a DocumentFile mock object.
*/
@NonNull
private static DocumentFile mockDocumentFile(@NonNull String fileName, @NonNull String mimeType) {
DocumentFile file = mock(DocumentFile.class);
when(file.getName()).thenReturn(fileName);
when(file.getUri()).thenReturn(Uri.parse("file:///path/" + fileName));
when(file.getType()).thenReturn(mimeType);
return file;
}
Aggregations