Search in sources :

Example 31 with MainActivity

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

the class FeedItemlistFragment method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    if (adapter == null) {
        return;
    }
    MainActivity activity = (MainActivity) getActivity();
    long[] ids = FeedItemUtil.getIds(feed.getItems());
    activity.loadChildFragment(ItemPagerFragment.newInstance(ids, position));
}
Also used : MainActivity(de.danoeh.antennapod.activity.MainActivity)

Example 32 with MainActivity

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

the class FeedItemlistFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.feed_item_list_fragment, container, false);
    toolbar = root.findViewById(R.id.toolbar);
    toolbar.inflateMenu(R.menu.feedlist);
    toolbar.setOnMenuItemClickListener(this);
    displayUpArrow = getParentFragmentManager().getBackStackEntryCount() != 0;
    if (savedInstanceState != null) {
        displayUpArrow = savedInstanceState.getBoolean(KEY_UP_ARROW);
    }
    ((MainActivity) getActivity()).setupToolbarToggle(toolbar, displayUpArrow);
    refreshToolbarState();
    recyclerView = root.findViewById(R.id.recyclerView);
    recyclerView.setRecycledViewPool(((MainActivity) getActivity()).getRecycledViewPool());
    progressBar = root.findViewById(R.id.progLoading);
    progressBar.setVisibility(View.VISIBLE);
    txtvTitle = root.findViewById(R.id.txtvTitle);
    txtvAuthor = root.findViewById(R.id.txtvAuthor);
    imgvBackground = root.findViewById(R.id.imgvBackground);
    imgvCover = root.findViewById(R.id.imgvCover);
    butShowInfo = root.findViewById(R.id.butShowInfo);
    butShowSettings = root.findViewById(R.id.butShowSettings);
    txtvInformation = root.findViewById(R.id.txtvInformation);
    txtvFailure = root.findViewById(R.id.txtvFailure);
    txtvUpdatesDisabled = root.findViewById(R.id.txtvUpdatesDisabled);
    header = root.findViewById(R.id.headerContainer);
    AppBarLayout appBar = root.findViewById(R.id.appBar);
    CollapsingToolbarLayout collapsingToolbar = root.findViewById(R.id.collapsing_toolbar);
    ToolbarIconTintManager iconTintManager = new ToolbarIconTintManager(getContext(), toolbar, collapsingToolbar) {

        @Override
        protected void doTint(Context themedContext) {
            toolbar.getMenu().findItem(R.id.sort_items).setIcon(AppCompatResources.getDrawable(themedContext, R.drawable.ic_sort));
            toolbar.getMenu().findItem(R.id.filter_items).setIcon(AppCompatResources.getDrawable(themedContext, R.drawable.ic_filter));
            toolbar.getMenu().findItem(R.id.refresh_item).setIcon(AppCompatResources.getDrawable(themedContext, R.drawable.ic_refresh));
            toolbar.getMenu().findItem(R.id.action_search).setIcon(AppCompatResources.getDrawable(themedContext, R.drawable.ic_search));
        }
    };
    iconTintManager.updateTint();
    appBar.addOnOffsetChangedListener(iconTintManager);
    nextPageLoader = new MoreContentListFooterUtil(root.findViewById(R.id.more_content_list_footer));
    nextPageLoader.setClickListener(() -> {
        if (feed != null) {
            DBTasks.loadNextPageOfFeed(getActivity(), feed, false);
        }
    });
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(@NonNull RecyclerView view, int deltaX, int deltaY) {
            super.onScrolled(view, deltaX, deltaY);
            boolean hasMorePages = feed != null && feed.isPaged() && feed.getNextPageLink() != null;
            nextPageLoader.getRoot().setVisibility((recyclerView.isScrolledToBottom() && hasMorePages) ? View.VISIBLE : View.GONE);
        }
    });
    EventBus.getDefault().register(this);
    SwipeRefreshLayout swipeRefreshLayout = root.findViewById(R.id.swipeRefresh);
    swipeRefreshLayout.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance));
    swipeRefreshLayout.setOnRefreshListener(() -> {
        DBTasks.forceRefreshFeed(requireContext(), feed, true);
        new Handler(Looper.getMainLooper()).postDelayed(() -> swipeRefreshLayout.setRefreshing(false), getResources().getInteger(R.integer.swipe_to_refresh_duration_in_ms));
    });
    loadItems();
    // Init action UI (via a FAB Speed Dial)
    speedDialView = root.findViewById(R.id.fabSD);
    speedDialView.setOverlayLayout(root.findViewById(R.id.fabSDOverlay));
    speedDialView.inflate(R.menu.episodes_apply_action_speeddial);
    speedDialView.setOnChangeListener(new SpeedDialView.OnChangeListener() {

        @Override
        public boolean onMainActionSelected() {
            return false;
        }

        @Override
        public void onToggleChanged(boolean open) {
            if (open && adapter.getSelectedCount() == 0) {
                ((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.no_items_selected, Snackbar.LENGTH_SHORT);
                speedDialView.close();
            }
        }
    });
    speedDialView.setOnActionSelectedListener(actionItem -> {
        new EpisodeMultiSelectActionHandler(((MainActivity) getActivity()), adapter.getSelectedItems()).handleAction(actionItem.getId());
        adapter.endSelectMode();
        return true;
    });
    return root;
}
Also used : Context(android.content.Context) FeedItemMenuHandler(de.danoeh.antennapod.menuhandler.FeedItemMenuHandler) Handler(android.os.Handler) FeedMenuHandler(de.danoeh.antennapod.menuhandler.FeedMenuHandler) EpisodeMultiSelectActionHandler(de.danoeh.antennapod.fragment.actions.EpisodeMultiSelectActionHandler) EpisodeMultiSelectActionHandler(de.danoeh.antennapod.fragment.actions.EpisodeMultiSelectActionHandler) MainActivity(de.danoeh.antennapod.activity.MainActivity) SpeedDialView(com.leinardi.android.speeddial.SpeedDialView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) EpisodeItemListRecyclerView(de.danoeh.antennapod.view.EpisodeItemListRecyclerView) IconTextView(com.joanzapata.iconify.widget.IconTextView) MoreContentListFooterUtil(de.danoeh.antennapod.core.util.gui.MoreContentListFooterUtil) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) CollapsingToolbarLayout(com.google.android.material.appbar.CollapsingToolbarLayout) RecyclerView(androidx.recyclerview.widget.RecyclerView) EpisodeItemListRecyclerView(de.danoeh.antennapod.view.EpisodeItemListRecyclerView) AppBarLayout(com.google.android.material.appbar.AppBarLayout) ToolbarIconTintManager(de.danoeh.antennapod.view.ToolbarIconTintManager) SpeedDialView(com.leinardi.android.speeddial.SpeedDialView) Nullable(androidx.annotation.Nullable)

Example 33 with MainActivity

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

the class DownloadLogFragment method onListItemClick.

@Override
public void onListItemClick(@NonNull ListView l, @NonNull View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    Object item = adapter.getItem(position);
    if (item instanceof Downloader) {
        DownloadRequest downloadRequest = ((Downloader) item).getDownloadRequest();
        DownloadService.cancel(getContext(), downloadRequest.getSource());
        if (downloadRequest.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
            FeedMedia media = DBReader.getFeedMedia(downloadRequest.getFeedfileId());
            FeedItem feedItem = media.getItem();
            feedItem.disableAutoDownload();
            DBWriter.setFeedItem(feedItem);
        }
    } else if (item instanceof DownloadStatus) {
        DownloadStatus status = (DownloadStatus) item;
        String url = "unknown";
        String message = getString(R.string.download_successful);
        if (status.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
            FeedMedia media = DBReader.getFeedMedia(status.getFeedfileId());
            if (media != null) {
                url = media.getDownload_url();
            }
        } else if (status.getFeedfileType() == Feed.FEEDFILETYPE_FEED) {
            Feed feed = DBReader.getFeed(status.getFeedfileId());
            if (feed != null) {
                url = feed.getDownload_url();
            }
        }
        if (!status.isSuccessful()) {
            message = status.getReasonDetailed();
        }
        String messageFull = getString(R.string.download_error_details_message, message, url);
        AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
        builder.setTitle(R.string.download_error_details);
        builder.setMessage(messageFull);
        builder.setPositiveButton(android.R.string.ok, null);
        builder.setNeutralButton(R.string.copy_to_clipboard, (dialog, which) -> {
            ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText(getString(R.string.download_error_details), messageFull);
            clipboard.setPrimaryClip(clip);
            ((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.copied_to_clipboard, Snackbar.LENGTH_SHORT);
        });
        Dialog dialog = builder.show();
        ((TextView) dialog.findViewById(android.R.id.message)).setTextIsSelectable(true);
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Context(android.content.Context) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) AutoUpdateManager(de.danoeh.antennapod.core.util.download.AutoUpdateManager) NonNull(androidx.annotation.NonNull) Dialog(android.app.Dialog) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) ClipData(android.content.ClipData) DownloadRequest(de.danoeh.antennapod.core.service.download.DownloadRequest) DownloadLogEvent(de.danoeh.antennapod.core.event.DownloadLogEvent) EventBus(org.greenrobot.eventbus.EventBus) Menu(android.view.Menu) ClipboardManager(android.content.ClipboardManager) View(android.view.View) DownloaderUpdate(de.danoeh.antennapod.core.event.DownloaderUpdate) Observable(io.reactivex.Observable) Schedulers(io.reactivex.schedulers.Schedulers) DownloadStatus(de.danoeh.antennapod.core.service.download.DownloadStatus) Log(android.util.Log) Feed(de.danoeh.antennapod.model.feed.Feed) Downloader(de.danoeh.antennapod.core.service.download.Downloader) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) R(de.danoeh.antennapod.R) EmptyViewHandler(de.danoeh.antennapod.view.EmptyViewHandler) FeedItem(de.danoeh.antennapod.model.feed.FeedItem) ThreadMode(org.greenrobot.eventbus.ThreadMode) MenuItemUtils(de.danoeh.antennapod.core.menuhandler.MenuItemUtils) MainActivity(de.danoeh.antennapod.activity.MainActivity) Disposable(io.reactivex.disposables.Disposable) List(java.util.List) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) Subscribe(org.greenrobot.eventbus.Subscribe) DownloadLogAdapter(de.danoeh.antennapod.adapter.DownloadLogAdapter) DownloadEvent(de.danoeh.antennapod.core.event.DownloadEvent) DBWriter(de.danoeh.antennapod.core.storage.DBWriter) DBReader(de.danoeh.antennapod.core.storage.DBReader) ListFragment(androidx.fragment.app.ListFragment) ListView(android.widget.ListView) Snackbar(com.google.android.material.snackbar.Snackbar) DownloadService(de.danoeh.antennapod.core.service.download.DownloadService) ClipboardManager(android.content.ClipboardManager) Downloader(de.danoeh.antennapod.core.service.download.Downloader) DownloadRequest(de.danoeh.antennapod.core.service.download.DownloadRequest) FeedItem(de.danoeh.antennapod.model.feed.FeedItem) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) AlertDialog(androidx.appcompat.app.AlertDialog) Dialog(android.app.Dialog) DownloadStatus(de.danoeh.antennapod.core.service.download.DownloadStatus) ClipData(android.content.ClipData) Feed(de.danoeh.antennapod.model.feed.Feed)

Example 34 with MainActivity

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

the class ExternalPlayerFragment method updateUi.

private void updateUi(Playable media) {
    if (media == null) {
        return;
    }
    ((MainActivity) getActivity()).setPlayerVisible(true);
    txtvTitle.setText(media.getEpisodeTitle());
    feedName.setText(media.getFeedTitle());
    onPositionObserverUpdate(new PlaybackPositionEvent(media.getPosition(), media.getDuration()));
    RequestOptions options = new RequestOptions().placeholder(R.color.light_gray).error(R.color.light_gray).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).fitCenter().dontAnimate();
    Glide.with(getActivity()).load(ImageResourceUtils.getEpisodeListImageLocation(media)).error(Glide.with(getActivity()).load(ImageResourceUtils.getFallbackImageLocation(media)).apply(options)).apply(options).into(imgvCover);
    if (controller != null && controller.isPlayingVideoLocally()) {
        ((MainActivity) getActivity()).getBottomSheet().setLocked(true);
        ((MainActivity) getActivity()).getBottomSheet().setState(BottomSheetBehavior.STATE_COLLAPSED);
    } else {
        butPlay.setVisibility(View.VISIBLE);
        ((MainActivity) getActivity()).getBottomSheet().setLocked(false);
    }
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) MainActivity(de.danoeh.antennapod.activity.MainActivity) PlaybackPositionEvent(de.danoeh.antennapod.event.playback.PlaybackPositionEvent)

Example 35 with MainActivity

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

the class PlaybackHistoryFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.simple_list_fragment, container, false);
    toolbar = root.findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.playback_history_label);
    toolbar.setOnMenuItemClickListener(this);
    displayUpArrow = getParentFragmentManager().getBackStackEntryCount() != 0;
    if (savedInstanceState != null) {
        displayUpArrow = savedInstanceState.getBoolean(KEY_UP_ARROW);
    }
    ((MainActivity) getActivity()).setupToolbarToggle(toolbar, displayUpArrow);
    toolbar.inflateMenu(R.menu.playback_history);
    refreshToolbarState();
    recyclerView = root.findViewById(R.id.recyclerView);
    recyclerView.setRecycledViewPool(((MainActivity) getActivity()).getRecycledViewPool());
    adapter = new PlaybackHistoryListAdapter((MainActivity) getActivity());
    recyclerView.setAdapter(adapter);
    progressBar = root.findViewById(R.id.progLoading);
    emptyView = new EmptyViewHandler(getActivity());
    emptyView.setIcon(R.drawable.ic_history);
    emptyView.setTitle(R.string.no_history_head_label);
    emptyView.setMessage(R.string.no_history_label);
    emptyView.attachToRecyclerView(recyclerView);
    return root;
}
Also used : EmptyViewHandler(de.danoeh.antennapod.view.EmptyViewHandler) MainActivity(de.danoeh.antennapod.activity.MainActivity) EpisodeItemListRecyclerView(de.danoeh.antennapod.view.EpisodeItemListRecyclerView) View(android.view.View)

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