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