Search in sources :

Example 71 with NonNull

use of androidx.annotation.NonNull in project AntennaPod by AntennaPod.

the class FeedItemCursorMapper method convert.

/**
 * Create a {@link FeedItem} instance from a database row (cursor).
 */
@NonNull
public static FeedItem convert(@NonNull Cursor cursor) {
    int indexId = cursor.getColumnIndexOrThrow(PodDBAdapter.SELECT_KEY_ITEM_ID);
    int indexTitle = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_TITLE);
    int indexLink = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_LINK);
    int indexPubDate = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_PUBDATE);
    int indexPaymentLink = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_PAYMENT_LINK);
    int indexFeedId = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_FEED);
    int indexHasChapters = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_HAS_CHAPTERS);
    int indexRead = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_READ);
    int indexItemIdentifier = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_ITEM_IDENTIFIER);
    int indexAutoDownload = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_AUTO_DOWNLOAD_ATTEMPTS);
    int indexImageUrl = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_IMAGE_URL);
    long id = cursor.getInt(indexId);
    String title = cursor.getString(indexTitle);
    String link = cursor.getString(indexLink);
    Date pubDate = new Date(cursor.getLong(indexPubDate));
    String paymentLink = cursor.getString(indexPaymentLink);
    long feedId = cursor.getLong(indexFeedId);
    boolean hasChapters = cursor.getInt(indexHasChapters) > 0;
    int state = cursor.getInt(indexRead);
    String itemIdentifier = cursor.getString(indexItemIdentifier);
    long autoDownload = cursor.getLong(indexAutoDownload);
    String imageUrl = cursor.getString(indexImageUrl);
    return new FeedItem(id, title, link, pubDate, paymentLink, feedId, hasChapters, imageUrl, state, itemIdentifier, autoDownload);
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) Date(java.util.Date) NonNull(androidx.annotation.NonNull)

Example 72 with NonNull

use of androidx.annotation.NonNull in project AntennaPod by AntennaPod.

the class APCleanupAlgorithm method getCandidates.

@NonNull
private List<FeedItem> getCandidates() {
    List<FeedItem> candidates = new ArrayList<>();
    List<FeedItem> downloadedItems = DBReader.getDownloadedItems();
    Date mostRecentDateForDeletion = calcMostRecentDateForDeletion(new Date());
    for (FeedItem item : downloadedItems) {
        if (item.hasMedia() && item.getMedia().isDownloaded() && !item.isTagged(FeedItem.TAG_QUEUE) && item.isPlayed() && !item.isTagged(FeedItem.TAG_FAVORITE)) {
            FeedMedia media = item.getMedia();
            // to now
            if (media != null && media.getPlaybackCompletionDate() != null && media.getPlaybackCompletionDate().before(mostRecentDateForDeletion)) {
                candidates.add(item);
            }
        }
    }
    return candidates;
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) ArrayList(java.util.ArrayList) Date(java.util.Date) NonNull(androidx.annotation.NonNull)

Example 73 with NonNull

use of androidx.annotation.NonNull in project Douya by DreaminginCodeZH.

the class ViewUtils method fadeOut.

public static void fadeOut(@NonNull View view, int duration, boolean gone, @Nullable Runnable nextRunnable) {
    if (view.getVisibility() != View.VISIBLE || view.getAlpha() == 0) {
        // Cancel any starting animation.
        view.animate().alpha(0).setDuration(0).start();
        view.setVisibility(gone ? View.GONE : View.INVISIBLE);
        if (nextRunnable != null) {
            nextRunnable.run();
        }
        return;
    }
    view.animate().alpha(0).setDuration(duration).setInterpolator(new FastOutLinearInInterpolator()).setListener(new AnimatorListenerAdapter() {

        private boolean mCanceled = false;

        @Override
        public void onAnimationCancel(@NonNull Animator animator) {
            mCanceled = true;
        }

        @Override
        public void onAnimationEnd(@NonNull Animator animator) {
            if (!mCanceled) {
                view.setVisibility(gone ? View.GONE : View.INVISIBLE);
                if (nextRunnable != null) {
                    nextRunnable.run();
                }
            }
        }
    }).start();
}
Also used : Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) NonNull(androidx.annotation.NonNull) FastOutLinearInInterpolator(androidx.interpolator.view.animation.FastOutLinearInInterpolator)

Example 74 with NonNull

use of androidx.annotation.NonNull in project Douya by DreaminginCodeZH.

the class FragmentUtils method getArgumentsBuilder.

@NonNull
public static BundleBuilder getArgumentsBuilder(@NonNull Fragment fragment) {
    Bundle arguments = fragment.getArguments();
    if (arguments == null) {
        arguments = new Bundle();
        fragment.setArguments(arguments);
    }
    return BundleBuilder.buildUpon(arguments);
}
Also used : Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull)

Example 75 with NonNull

use of androidx.annotation.NonNull in project Douya by DreaminginCodeZH.

the class SimpleDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder alertDialogBuilder;
    Bundle arguments = getArguments();
    int theme = arguments.getInt(ARGUMENT_THEME);
    if (theme == 0) {
        alertDialogBuilder = new AlertDialog.Builder(getActivity());
    } else {
        alertDialogBuilder = new AlertDialog.Builder(getActivity(), theme);
    }
    alertDialogBuilder.setIcon(arguments.getInt(ARGUMENT_ICON_ID)).setTitle(arguments.getCharSequence(ARGUMENT_TITLE)).setMessage(arguments.getCharSequence(ARGUMENT_MESSAGE));
    CharSequence[] items = arguments.getCharSequenceArray(ARGUMENT_ITEMS);
    if (items != null) {
        alertDialogBuilder.setItems(items, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialogInterface, int which) {
                if (mListener != null) {
                    mListener.onListItemClicked(mRequestCode, which);
                }
            }
        });
    } else if (arguments.getBoolean(ARGUMENT_IS_SINGLE_CHOICE)) {
        alertDialogBuilder.setSingleChoiceItems(arguments.getCharSequenceArray(ARGUMENT_CHOICE_ITEMS), arguments.getInt(ARGUMENT_CHOICE_CHECKED_ITEM), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (mListener != null) {
                    mListener.onSingleChoiceItemClicked(mRequestCode, which);
                }
            }
        });
    }
    alertDialogBuilder.setPositiveButton(arguments.getCharSequence(ARGUMENT_POSITIVE_BUTTON_TEXT), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (mListener != null) {
                mListener.onPositiveButtonClicked(mRequestCode);
            }
        }
    }).setNeutralButton(arguments.getCharSequence(ARGUMENT_NEUTRAL_BUTTON_TEXT), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (mListener != null) {
                mListener.onNeutralButtonClicked(mRequestCode);
            }
        }
    }).setNegativeButton(arguments.getCharSequence(ARGUMENT_NEGATIVE_BUTTON_TEXT), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (mListener != null) {
                mListener.onNegativeButtonClicked(mRequestCode);
            }
        }
    }).setOnKeyListener(new DialogInterface.OnKeyListener() {

        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent keyEvent) {
            // noinspection SimplifiableIfStatement
            if (mListener != null) {
                return mListener.onKey(mRequestCode, keyCode, keyEvent);
            } else {
                return false;
            }
        }
    }).setCancelable(arguments.getBoolean(ARGUMENT_CANCELABLE));
    return alertDialogBuilder.create();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) KeyEvent(android.view.KeyEvent) DialogInterface(android.content.DialogInterface) Bundle(android.os.Bundle) 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