Search in sources :

Example 1 with DefaultActionButtonCallback

use of de.danoeh.antennapod.adapter.DefaultActionButtonCallback in project AntennaPod by AntennaPod.

the class ItemFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View layout = inflater.inflate(R.layout.feeditem_fragment, container, false);
    root = (ViewGroup) layout.findViewById(R.id.content_root);
    LinearLayout header = (LinearLayout) root.findViewById(R.id.header);
    if (feedItems.length > 0) {
        header.setOnTouchListener((v, event) -> headerGestureDetector.onTouchEvent(event));
    }
    txtvPodcast = (TextView) layout.findViewById(R.id.txtvPodcast);
    txtvPodcast.setOnClickListener(v -> openPodcast());
    txtvTitle = (TextView) layout.findViewById(R.id.txtvTitle);
    if (Build.VERSION.SDK_INT >= 23) {
        txtvTitle.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL);
    }
    txtvDuration = (TextView) layout.findViewById(R.id.txtvDuration);
    txtvPublished = (TextView) layout.findViewById(R.id.txtvPublished);
    if (Build.VERSION.SDK_INT >= 14) {
        // ellipsize is causing problems on old versions, see #448
        txtvTitle.setEllipsize(TextUtils.TruncateAt.END);
    }
    webvDescription = (WebView) layout.findViewById(R.id.webvDescription);
    if (UserPreferences.getTheme() == R.style.Theme_AntennaPod_Dark) {
        if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
            webvDescription.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        }
        webvDescription.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.black));
    }
    webvDescription.getSettings().setUseWideViewPort(false);
    webvDescription.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
    webvDescription.getSettings().setLoadWithOverviewMode(true);
    if (feedItems.length > 0) {
        webvDescription.setOnLongClickListener(webViewLongClickListener);
    }
    webvDescription.setOnTouchListener((v, event) -> webviewGestureDetector.onTouchEvent(event));
    webvDescription.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            if (IntentUtils.isCallable(getActivity(), intent)) {
                startActivity(intent);
            }
            return true;
        }
    });
    registerForContextMenu(webvDescription);
    imgvCover = (ImageView) layout.findViewById(R.id.imgvCover);
    imgvCover.setOnClickListener(v -> openPodcast());
    progbarDownload = (ProgressBar) layout.findViewById(R.id.progbarDownload);
    progbarLoading = (ProgressBar) layout.findViewById(R.id.progbarLoading);
    butAction1 = (IconButton) layout.findViewById(R.id.butAction1);
    butAction2 = (IconButton) layout.findViewById(R.id.butAction2);
    butAction1.setOnClickListener(v -> {
        if (item == null) {
            return;
        }
        DefaultActionButtonCallback actionButtonCallback = new DefaultActionButtonCallback(getActivity());
        actionButtonCallback.onActionButtonPressed(item, item.isTagged(FeedItem.TAG_QUEUE) ? LongList.of(item.getId()) : new LongList(0));
        FeedMedia media = item.getMedia();
        if (media != null && media.isDownloaded()) {
            ((MainActivity) getActivity()).dismissChildFragment();
        }
    });
    butAction2.setOnClickListener(v -> {
        if (item == null) {
            return;
        }
        if (item.hasMedia()) {
            FeedMedia media = item.getMedia();
            if (!media.isDownloaded()) {
                DBTasks.playMedia(getActivity(), media, true, true, true);
                ((MainActivity) getActivity()).dismissChildFragment();
            } else {
                DBWriter.deleteFeedMediaOfItem(getActivity(), media.getId());
            }
        } else if (item.getLink() != null) {
            Uri uri = Uri.parse(item.getLink());
            getActivity().startActivity(new Intent(Intent.ACTION_VIEW, uri));
        }
    });
    return layout;
}
Also used : DefaultActionButtonCallback(de.danoeh.antennapod.adapter.DefaultActionButtonCallback) FeedMedia(de.danoeh.antennapod.core.feed.FeedMedia) Intent(android.content.Intent) LongList(de.danoeh.antennapod.core.util.LongList) MainActivity(de.danoeh.antennapod.activity.MainActivity) WebView(android.webkit.WebView) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) Uri(android.net.Uri) LinearLayout(android.widget.LinearLayout) WebViewClient(android.webkit.WebViewClient)

Example 2 with DefaultActionButtonCallback

use of de.danoeh.antennapod.adapter.DefaultActionButtonCallback in project AntennaPod by AntennaPod.

the class PlaybackHistoryFragment method onFragmentLoaded.

private void onFragmentLoaded() {
    if (adapter == null) {
        // played items shoudln't be transparent for this fragment since, *all* items
        // in this fragment will, by definition, be played. So it serves no purpose and can make
        // it harder to read.
        adapter = new FeedItemlistAdapter(getActivity(), itemAccess, new DefaultActionButtonCallback(getActivity()), true, false);
        setListAdapter(adapter);
    }
    setListShown(true);
    adapter.notifyDataSetChanged();
    getActivity().supportInvalidateOptionsMenu();
}
Also used : FeedItemlistAdapter(de.danoeh.antennapod.adapter.FeedItemlistAdapter) DefaultActionButtonCallback(de.danoeh.antennapod.adapter.DefaultActionButtonCallback)

Example 3 with DefaultActionButtonCallback

use of de.danoeh.antennapod.adapter.DefaultActionButtonCallback in project AntennaPod by AntennaPod.

the class QueueFragment method onFragmentLoaded.

private void onFragmentLoaded(final boolean restoreScrollPosition) {
    if (recyclerAdapter == null) {
        MainActivity activity = (MainActivity) getActivity();
        recyclerAdapter = new QueueRecyclerAdapter(activity, itemAccess, new DefaultActionButtonCallback(activity), itemTouchHelper);
        recyclerAdapter.setHasStableIds(true);
        recyclerView.setAdapter(recyclerAdapter);
    }
    if (queue == null || queue.size() == 0) {
        recyclerView.setVisibility(View.GONE);
        txtvEmpty.setVisibility(View.VISIBLE);
    } else {
        txtvEmpty.setVisibility(View.GONE);
        recyclerView.setVisibility(View.VISIBLE);
    }
    if (restoreScrollPosition) {
        restoreScrollPosition();
    }
    // we need to refresh the options menu because it sometimes
    // needs data that may have just been loaded.
    getActivity().supportInvalidateOptionsMenu();
    refreshInfoBar();
}
Also used : DefaultActionButtonCallback(de.danoeh.antennapod.adapter.DefaultActionButtonCallback) MainActivity(de.danoeh.antennapod.activity.MainActivity) QueueRecyclerAdapter(de.danoeh.antennapod.adapter.QueueRecyclerAdapter)

Example 4 with DefaultActionButtonCallback

use of de.danoeh.antennapod.adapter.DefaultActionButtonCallback in project AntennaPod by AntennaPod.

the class AllEpisodesFragment method onFragmentLoaded.

private void onFragmentLoaded() {
    if (listAdapter == null) {
        MainActivity mainActivity = (MainActivity) getActivity();
        listAdapter = new AllEpisodesRecycleAdapter(mainActivity, itemAccess, new DefaultActionButtonCallback(mainActivity), showOnlyNewEpisodes());
        listAdapter.setHasStableIds(true);
        recyclerView.setAdapter(listAdapter);
    }
    listAdapter.notifyDataSetChanged();
    restoreScrollPosition();
    getActivity().supportInvalidateOptionsMenu();
    updateShowOnlyEpisodesListViewState();
}
Also used : DefaultActionButtonCallback(de.danoeh.antennapod.adapter.DefaultActionButtonCallback) AllEpisodesRecycleAdapter(de.danoeh.antennapod.adapter.AllEpisodesRecycleAdapter) MainActivity(de.danoeh.antennapod.activity.MainActivity)

Example 5 with DefaultActionButtonCallback

use of de.danoeh.antennapod.adapter.DefaultActionButtonCallback in project AntennaPod by AntennaPod.

the class ItemlistFragment method onFragmentLoaded.

private void onFragmentLoaded() {
    if (!isVisible()) {
        return;
    }
    insideOnFragmentLoaded = true;
    if (adapter == null) {
        setListAdapter(null);
        setupHeaderView();
        setupFooterView();
        adapter = new FeedItemlistAdapter(getActivity(), itemAccess, new DefaultActionButtonCallback(getActivity()), false, true);
        setListAdapter(adapter);
    }
    refreshHeaderView();
    setListShown(true);
    adapter.notifyDataSetChanged();
    getActivity().supportInvalidateOptionsMenu();
    if (feed != null && feed.getNextPageLink() == null && listFooter != null) {
        getListView().removeFooterView(listFooter.getRoot());
    }
    insideOnFragmentLoaded = false;
}
Also used : FeedItemlistAdapter(de.danoeh.antennapod.adapter.FeedItemlistAdapter) DefaultActionButtonCallback(de.danoeh.antennapod.adapter.DefaultActionButtonCallback)

Aggregations

DefaultActionButtonCallback (de.danoeh.antennapod.adapter.DefaultActionButtonCallback)5 MainActivity (de.danoeh.antennapod.activity.MainActivity)3 FeedItemlistAdapter (de.danoeh.antennapod.adapter.FeedItemlistAdapter)2 Intent (android.content.Intent)1 Uri (android.net.Uri)1 View (android.view.View)1 WebView (android.webkit.WebView)1 WebViewClient (android.webkit.WebViewClient)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 AllEpisodesRecycleAdapter (de.danoeh.antennapod.adapter.AllEpisodesRecycleAdapter)1 QueueRecyclerAdapter (de.danoeh.antennapod.adapter.QueueRecyclerAdapter)1 FeedMedia (de.danoeh.antennapod.core.feed.FeedMedia)1 LongList (de.danoeh.antennapod.core.util.LongList)1