Search in sources :

Example 1 with SimpleUrlsModel

use of com.fastaccess.data.dao.SimpleUrlsModel in project FastHub by k0shk0sh.

the class RepoReleasesFragment method onDownload.

@Override
public void onDownload(@NonNull Release item) {
    ArrayList<SimpleUrlsModel> models = new ArrayList<>();
    if (!InputHelper.isEmpty(item.getZipBallUrl())) {
        String url = item.getZipBallUrl();
        if (!url.endsWith(".tar.gz")) {
            url = url + ".tar.gz";
        }
        models.add(new SimpleUrlsModel(getString(R.string.download_as_zip), url));
    }
    if (!InputHelper.isEmpty(item.getTarballUrl())) {
        models.add(new SimpleUrlsModel(getString(R.string.download_as_tar), item.getTarballUrl()));
    }
    if (item.getAssets() != null && !item.getAssets().isEmpty()) {
        ArrayList<SimpleUrlsModel> mapped = Stream.of(item.getAssets()).filter(value -> value != null && value.getBrowserDownloadUrl() != null).map(assetsModel -> new SimpleUrlsModel(String.format("%s (%s)", assetsModel.getName(), assetsModel.getDownloadCount()), assetsModel.getBrowserDownloadUrl())).collect(Collectors.toCollection(ArrayList::new));
        if (mapped != null && !mapped.isEmpty()) {
            models.addAll(mapped);
        }
    }
    ListDialogView<SimpleUrlsModel> dialogView = new ListDialogView<>();
    dialogView.initArguments(getString(R.string.releases), models);
    dialogView.show(getChildFragmentManager(), "ListDialogView");
}
Also used : Bundle(android.os.Bundle) Stream(com.annimon.stream.Stream) ActivityHelper(com.fastaccess.helper.ActivityHelper) InputHelper(com.fastaccess.helper.InputHelper) StringRes(android.support.annotation.StringRes) NonNull(android.support.annotation.NonNull) SimpleUrlsModel(com.fastaccess.data.dao.SimpleUrlsModel) ArrayList(java.util.ArrayList) BindView(butterknife.BindView) StateLayout(com.fastaccess.ui.widgets.StateLayout) Bundler(com.fastaccess.helper.Bundler) OnLoadMore(com.fastaccess.provider.rest.loadmore.OnLoadMore) ReleasesAdapter(com.fastaccess.ui.adapter.ReleasesAdapter) View(android.view.View) ListDialogView(com.fastaccess.ui.widgets.dialog.ListDialogView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) BundleConstant(com.fastaccess.helper.BundleConstant) DynamicRecyclerView(com.fastaccess.ui.widgets.recyclerview.DynamicRecyclerView) RestProvider(com.fastaccess.provider.rest.RestProvider) Collectors(com.annimon.stream.Collectors) MessageDialogView(com.fastaccess.ui.widgets.dialog.MessageDialogView) RecyclerViewFastScroller(com.fastaccess.ui.widgets.recyclerview.scroll.RecyclerViewFastScroller) List(java.util.List) R(com.fastaccess.R) Release(com.fastaccess.data.dao.model.Release) BaseFragment(com.fastaccess.ui.base.BaseFragment) Nullable(android.support.annotation.Nullable) SimpleUrlsModel(com.fastaccess.data.dao.SimpleUrlsModel) ListDialogView(com.fastaccess.ui.widgets.dialog.ListDialogView) ArrayList(java.util.ArrayList)

Example 2 with SimpleUrlsModel

use of com.fastaccess.data.dao.SimpleUrlsModel in project FastHub by k0shk0sh.

the class FeedsPresenter method onItemLongClick.

@Override
public void onItemLongClick(int position, View v, Event item) {
    if (item.getType() == EventsType.ForkEvent) {
        if (getView() != null) {
            getView().onOpenRepoChooser(Stream.of(new SimpleUrlsModel(item.getRepo().getName(), item.getRepo().getUrl()), new SimpleUrlsModel(item.getPayload().getForkee().getFullName(), item.getPayload().getForkee().getHtmlUrl())).collect(Collectors.toCollection(ArrayList::new)));
        }
    } else {
        Repo repo = item.getRepo();
        if (repo != null) {
            NameParser parser = new NameParser(repo.getUrl());
            RepoPagerActivity.startRepoPager(v.getContext(), parser);
        }
    }
}
Also used : SimpleUrlsModel(com.fastaccess.data.dao.SimpleUrlsModel) Repo(com.fastaccess.data.dao.model.Repo) ArrayList(java.util.ArrayList) NameParser(com.fastaccess.data.dao.NameParser)

Aggregations

SimpleUrlsModel (com.fastaccess.data.dao.SimpleUrlsModel)2 ArrayList (java.util.ArrayList)2 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 StringRes (android.support.annotation.StringRes)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 View (android.view.View)1 BindView (butterknife.BindView)1 Collectors (com.annimon.stream.Collectors)1 Stream (com.annimon.stream.Stream)1 R (com.fastaccess.R)1 NameParser (com.fastaccess.data.dao.NameParser)1 Release (com.fastaccess.data.dao.model.Release)1 Repo (com.fastaccess.data.dao.model.Repo)1 ActivityHelper (com.fastaccess.helper.ActivityHelper)1 BundleConstant (com.fastaccess.helper.BundleConstant)1 Bundler (com.fastaccess.helper.Bundler)1 InputHelper (com.fastaccess.helper.InputHelper)1 RestProvider (com.fastaccess.provider.rest.RestProvider)1