Search in sources :

Example 81 with NonNull

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;
}
Also used : SimpleItemAnimator(androidx.recyclerview.widget.SimpleItemAnimator) EmptyViewHandler(de.danoeh.antennapod.view.EmptyViewHandler) FeedItemMenuHandler(de.danoeh.antennapod.menuhandler.FeedItemMenuHandler) Handler(android.os.Handler) EmptyViewHandler(de.danoeh.antennapod.view.EmptyViewHandler) RecyclerView(androidx.recyclerview.widget.RecyclerView) EpisodeItemListRecyclerView(de.danoeh.antennapod.view.EpisodeItemListRecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) EpisodeItemListRecyclerView(de.danoeh.antennapod.view.EpisodeItemListRecyclerView) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) NonNull(androidx.annotation.NonNull)

Example 82 with NonNull

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;
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) FitCenter(com.bumptech.glide.load.resource.bitmap.FitCenter) MainActivity(de.danoeh.antennapod.activity.MainActivity) RoundedCorners(com.bumptech.glide.load.resource.bitmap.RoundedCorners) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) PodcastSearchResult(de.danoeh.antennapod.discovery.PodcastSearchResult) NonNull(androidx.annotation.NonNull)

Example 83 with NonNull

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();
}
Also used : Document(org.jsoup.nodes.Document) NonNull(androidx.annotation.NonNull)

Example 84 with NonNull

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);
    }
}
Also used : SyncServiceException(de.danoeh.antennapod.net.sync.model.SyncServiceException) SyncServiceEvent(de.danoeh.antennapod.event.SyncServiceEvent) ISyncService(de.danoeh.antennapod.net.sync.model.ISyncService) SyncServiceException(de.danoeh.antennapod.net.sync.model.SyncServiceException) NonNull(androidx.annotation.NonNull)

Example 85 with NonNull

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;
}
Also used : DocumentFile(androidx.documentfile.provider.DocumentFile) AssetsDocumentFile(androidx.documentfile.provider.AssetsDocumentFile) NonNull(androidx.annotation.NonNull)

Aggregations

NonNull (androidx.annotation.NonNull)1197 View (android.view.View)191 ArrayList (java.util.ArrayList)154 Context (android.content.Context)128 Nullable (androidx.annotation.Nullable)128 TextView (android.widget.TextView)117 Intent (android.content.Intent)115 List (java.util.List)110 Recipient (org.thoughtcrime.securesms.recipients.Recipient)109 IOException (java.io.IOException)103 Bundle (android.os.Bundle)102 WorkerThread (androidx.annotation.WorkerThread)94 LayoutInflater (android.view.LayoutInflater)89 RecipientId (org.thoughtcrime.securesms.recipients.RecipientId)82 AlertDialog (androidx.appcompat.app.AlertDialog)76 Log (org.signal.core.util.logging.Log)76 Cursor (android.database.Cursor)68 ViewGroup (android.view.ViewGroup)65 LinkedList (java.util.LinkedList)64 Stream (com.annimon.stream.Stream)62