Search in sources :

Example 21 with MainActivity

use of de.danoeh.antennapod.activity.MainActivity in project AntennaPod by AntennaPod.

the class FeedItemlistFragment method setupHeaderView.

private void setupHeaderView() {
    if (feed == null || headerCreated) {
        return;
    }
    // https://github.com/bumptech/glide/issues/529
    imgvBackground.setColorFilter(new LightingColorFilter(0xff666666, 0x000000));
    butShowInfo.setVisibility(View.VISIBLE);
    butShowInfo.setOnClickListener(v -> showFeedInfo());
    imgvCover.setOnClickListener(v -> showFeedInfo());
    butShowSettings.setVisibility(View.VISIBLE);
    butShowSettings.setOnClickListener(v -> {
        if (feed != null) {
            FeedSettingsFragment fragment = FeedSettingsFragment.newInstance(feed);
            ((MainActivity) getActivity()).loadChildFragment(fragment, TransitionEffect.SLIDE);
        }
    });
    txtvFailure.setOnClickListener(v -> {
        Intent intent = new Intent(getContext(), MainActivity.class);
        intent.putExtra(MainActivity.EXTRA_FRAGMENT_TAG, DownloadsFragment.TAG);
        Bundle args = new Bundle();
        args.putInt(DownloadsFragment.ARG_SELECTED_TAB, DownloadsFragment.POS_LOG);
        intent.putExtra(MainActivity.EXTRA_FRAGMENT_ARGS, args);
        startActivity(intent);
    });
    headerCreated = true;
}
Also used : Bundle(android.os.Bundle) LightingColorFilter(android.graphics.LightingColorFilter) Intent(android.content.Intent) MainActivity(de.danoeh.antennapod.activity.MainActivity)

Example 22 with MainActivity

use of de.danoeh.antennapod.activity.MainActivity in project AntennaPod by AntennaPod.

the class FeedItemlistFragment method onMenuItemClick.

@Override
public boolean onMenuItemClick(MenuItem item) {
    if (feed == null) {
        ((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.please_wait_for_data, Toast.LENGTH_LONG);
        return true;
    }
    boolean feedMenuHandled = FeedMenuHandler.onOptionsItemClicked(getActivity(), item, feed);
    if (feedMenuHandled) {
        return true;
    }
    final int itemId = item.getItemId();
    if (itemId == R.id.rename_item) {
        new RenameItemDialog(getActivity(), feed).show();
        return true;
    } else if (itemId == R.id.remove_feed) {
        ((MainActivity) getActivity()).loadFragment(EpisodesFragment.TAG, null);
        RemoveFeedDialog.show(getContext(), feed);
        return true;
    } else if (itemId == R.id.action_search) {
        ((MainActivity) getActivity()).loadChildFragment(SearchFragment.newInstance(feed.getId(), feed.getTitle()));
        return true;
    }
    return false;
}
Also used : RenameItemDialog(de.danoeh.antennapod.dialog.RenameItemDialog) MainActivity(de.danoeh.antennapod.activity.MainActivity)

Example 23 with MainActivity

use of de.danoeh.antennapod.activity.MainActivity 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 24 with MainActivity

use of de.danoeh.antennapod.activity.MainActivity in project AntennaPod by AntennaPod.

the class CoverTarget method onLoadFailed.

@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
    String fallbackUri = fallback.get();
    TextView txtvPlaceholder = placeholder.get();
    ImageView imgvCover = cover.get();
    if (fallbackUri != null && txtvPlaceholder != null && imgvCover != null) {
        MainActivity activity = mainActivity.get();
        Glide.with(activity).load(fallbackUri).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).fitCenter().dontAnimate().into(new CoverTarget(null, txtvPlaceholder, imgvCover, activity));
    }
}
Also used : TextView(android.widget.TextView) ImageView(android.widget.ImageView) MainActivity(de.danoeh.antennapod.activity.MainActivity)

Example 25 with MainActivity

use of de.danoeh.antennapod.activity.MainActivity in project AntennaPod by AntennaPod.

the class SearchFragment method onListItemClick.

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    SearchResult result = (SearchResult) l.getAdapter().getItem(position);
    FeedComponent comp = result.getComponent();
    if (comp.getClass() == Feed.class) {
        ((MainActivity) getActivity()).loadFeedFragmentById(comp.getId(), null);
    } else {
        if (comp.getClass() == FeedItem.class) {
            FeedItem item = (FeedItem) comp;
            ((MainActivity) getActivity()).loadChildFragment(ItemFragment.newInstance(item.getId()));
        }
    }
}
Also used : FeedItem(de.danoeh.antennapod.core.feed.FeedItem) SearchResult(de.danoeh.antennapod.core.feed.SearchResult) FeedComponent(de.danoeh.antennapod.core.feed.FeedComponent) MainActivity(de.danoeh.antennapod.activity.MainActivity)

Aggregations

MainActivity (de.danoeh.antennapod.activity.MainActivity)43 View (android.view.View)15 TextView (android.widget.TextView)11 Nullable (androidx.annotation.Nullable)6 Context (android.content.Context)5 ImageView (android.widget.ImageView)5 Fragment (androidx.fragment.app.Fragment)5 EpisodeItemListRecyclerView (de.danoeh.antennapod.view.EpisodeItemListRecyclerView)5 DialogInterface (android.content.DialogInterface)4 Bundle (android.os.Bundle)4 MenuItem (android.view.MenuItem)4 NonNull (androidx.annotation.NonNull)4 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 ConfirmationDialog (de.danoeh.antennapod.core.dialog.ConfirmationDialog)4 EmptyViewHandler (de.danoeh.antennapod.view.EmptyViewHandler)4 Activity (android.app.Activity)3 Handler (android.os.Handler)3 ViewGroup (android.view.ViewGroup)3 Toolbar (androidx.appcompat.widget.Toolbar)3 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)3