Search in sources :

Example 86 with NonNull

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

the class LocalFeedUpdaterTest method mockDocumentFolder.

/**
 *  Create a DocumentFile folder mock object with a list of files.
 */
@NonNull
private static DocumentFile mockDocumentFolder(DocumentFile... files) {
    DocumentFile documentFolder = mock(DocumentFile.class);
    when(documentFolder.listFiles()).thenReturn(files);
    return documentFolder;
}
Also used : DocumentFile(androidx.documentfile.provider.DocumentFile) AssetsDocumentFile(androidx.documentfile.provider.AssetsDocumentFile) NonNull(androidx.annotation.NonNull)

Example 87 with NonNull

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

the class GalleryAdapter method onCreateView.

@NonNull
@Override
public View onCreateView(@NonNull ViewGroup container, int position) {
    final View layout = ViewUtils.inflate(R.layout.gallery_item, container);
    final ViewHolder holder = new ViewHolder(layout);
    layout.setTag(holder);
    holder.image.setOnPhotoTapListener((view, x, y) -> {
        if (mListener != null) {
            mListener.onTap();
        }
    });
    holder.largeImage.setOnClickListener(view -> {
        if (mListener != null) {
            mListener.onTap();
        }
    });
    loadImageForPosition(position, holder);
    container.addView(layout);
    return layout;
}
Also used : BindView(butterknife.BindView) View(android.view.View) SaveStateSubsamplingScaleImageView(me.zhanghai.android.douya.ui.SaveStateSubsamplingScaleImageView) PhotoView(com.github.chrisbanes.photoview.PhotoView) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) TextView(android.widget.TextView) NonNull(androidx.annotation.NonNull)

Example 88 with NonNull

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

the class OnlineFeedViewActivity method showFeedInformation.

/**
 * Called when feed parsed successfully.
 * This method is executed on the GUI thread.
 */
private void showFeedInformation(final Feed feed, Map<String, String> alternateFeedUrls) {
    viewBinding.progressBar.setVisibility(View.GONE);
    viewBinding.feedDisplayContainer.setVisibility(View.VISIBLE);
    if (isFeedFoundBySearch) {
        int resId = R.string.no_feed_url_podcast_found_by_search;
        Snackbar.make(findViewById(android.R.id.content), resId, Snackbar.LENGTH_LONG).show();
    }
    this.feed = feed;
    this.selectedDownloadUrl = feed.getDownload_url();
    viewBinding.backgroundImage.setColorFilter(new LightingColorFilter(0xff828282, 0x000000));
    View header = View.inflate(this, R.layout.onlinefeedview_header, null);
    viewBinding.listView.addHeaderView(header);
    viewBinding.listView.setSelector(android.R.color.transparent);
    viewBinding.listView.setAdapter(new FeedItemlistDescriptionAdapter(this, 0, feed.getItems()));
    TextView description = header.findViewById(R.id.txtvDescription);
    if (StringUtils.isNotBlank(feed.getImageUrl())) {
        Glide.with(this).load(feed.getImageUrl()).apply(new RequestOptions().placeholder(R.color.light_gray).error(R.color.light_gray).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).fitCenter().dontAnimate()).into(viewBinding.coverImage);
        Glide.with(this).load(feed.getImageUrl()).apply(new RequestOptions().placeholder(R.color.image_readability_tint).error(R.color.image_readability_tint).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).transform(new FastBlurTransformation()).dontAnimate()).into(viewBinding.backgroundImage);
    }
    viewBinding.titleLabel.setText(feed.getTitle());
    viewBinding.authorLabel.setText(feed.getAuthor());
    description.setText(HtmlToPlainText.getPlainText(feed.getDescription()));
    viewBinding.subscribeButton.setOnClickListener(v -> {
        if (feedInFeedlist(feed)) {
            openFeed();
        } else {
            Feed f = new Feed(selectedDownloadUrl, null, feed.getTitle());
            f.setPreferences(feed.getPreferences());
            this.feed = f;
            DownloadService.download(this, false, DownloadRequestCreator.create(f).build());
            didPressSubscribe = true;
            handleUpdatedFeedStatus(feed);
        }
    });
    viewBinding.stopPreviewButton.setOnClickListener(v -> {
        PlaybackPreferences.writeNoMediaPlaying();
        IntentUtils.sendLocalBroadcast(this, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE);
    });
    if (UserPreferences.isEnableAutodownload()) {
        SharedPreferences preferences = getSharedPreferences(PREFS, MODE_PRIVATE);
        viewBinding.autoDownloadCheckBox.setChecked(preferences.getBoolean(PREF_LAST_AUTO_DOWNLOAD, true));
    }
    final int MAX_LINES_COLLAPSED = 10;
    description.setMaxLines(MAX_LINES_COLLAPSED);
    description.setOnClickListener(v -> {
        if (description.getMaxLines() > MAX_LINES_COLLAPSED) {
            description.setMaxLines(MAX_LINES_COLLAPSED);
        } else {
            description.setMaxLines(2000);
        }
    });
    if (alternateFeedUrls.isEmpty()) {
        viewBinding.alternateUrlsSpinner.setVisibility(View.GONE);
    } else {
        viewBinding.alternateUrlsSpinner.setVisibility(View.VISIBLE);
        final List<String> alternateUrlsList = new ArrayList<>();
        final List<String> alternateUrlsTitleList = new ArrayList<>();
        alternateUrlsList.add(feed.getDownload_url());
        alternateUrlsTitleList.add(feed.getTitle());
        alternateUrlsList.addAll(alternateFeedUrls.keySet());
        for (String url : alternateFeedUrls.keySet()) {
            alternateUrlsTitleList.add(alternateFeedUrls.get(url));
        }
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.alternate_urls_item, alternateUrlsTitleList) {

            @Override
            public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
                // reusing the old view causes a visual bug on Android <= 10
                return super.getDropDownView(position, null, parent);
            }
        };
        adapter.setDropDownViewResource(R.layout.alternate_urls_dropdown_item);
        viewBinding.alternateUrlsSpinner.setAdapter(adapter);
        viewBinding.alternateUrlsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                selectedDownloadUrl = alternateUrlsList.get(position);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {
            }
        });
    }
    handleUpdatedFeedStatus(feed);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) SharedPreferences(android.content.SharedPreferences) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) FastBlurTransformation(de.danoeh.antennapod.core.glide.FastBlurTransformation) FeedItemlistDescriptionAdapter(de.danoeh.antennapod.adapter.FeedItemlistDescriptionAdapter) NonNull(androidx.annotation.NonNull) LightingColorFilter(android.graphics.LightingColorFilter) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter) Nullable(androidx.annotation.Nullable) Feed(de.danoeh.antennapod.model.feed.Feed)

Example 89 with NonNull

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

the class MainActivity method getIntentToOpenFeed.

@NonNull
public static Intent getIntentToOpenFeed(@NonNull Context context, long feedId) {
    Intent intent = new Intent(context.getApplicationContext(), MainActivity.class);
    intent.putExtra(MainActivity.EXTRA_FEED_ID, feedId);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    return intent;
}
Also used : Intent(android.content.Intent) NonNull(androidx.annotation.NonNull)

Example 90 with NonNull

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

the class DataFolderAdapter method onCreateViewHolder.

@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    LayoutInflater inflater = LayoutInflater.from(parent.getContext());
    View entryView = inflater.inflate(R.layout.choose_data_folder_dialog_entry, parent, false);
    return new ViewHolder(entryView);
}
Also used : LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) 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