Search in sources :

Example 6 with Repo

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

the class RepoPagerActivity method onPrepareOptionsMenu.

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    Repo repoModel = getPresenter().getRepo();
    if (repoModel != null && repoModel.isFork() && repoModel.getParent() != null) {
        MenuItem menuItem = menu.findItem(R.id.originalRepo);
        menuItem.setVisible(true);
        menuItem.setTitle(repoModel.getParent().getFullName());
    }
    // removing delete permission.
    if (menu.findItem(R.id.deleteRepo) != null)
        menu.findItem(R.id.deleteRepo).setVisible(false);
    return super.onPrepareOptionsMenu(menu);
}
Also used : Repo(com.fastaccess.data.dao.model.Repo) MenuItem(android.view.MenuItem)

Example 7 with Repo

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

the class RepoPagerActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        startActivity(new Intent(this, MainActivity.class));
        finish();
    } else if (item.getItemId() == R.id.share) {
        if (getPresenter().getRepo() != null)
            ActivityHelper.shareUrl(this, getPresenter().getRepo().getHtmlUrl());
        return true;
    } else if (item.getItemId() == R.id.browser) {
        if (getPresenter().getRepo() != null)
            ActivityHelper.startCustomTab(this, getPresenter().getRepo().getHtmlUrl());
        return true;
    } else if (item.getItemId() == R.id.copy) {
        if (getPresenter().getRepo() != null)
            AppHelper.copyToClipboard(this, getPresenter().getRepo().getHtmlUrl());
        return true;
    } else if (item.getItemId() == R.id.originalRepo) {
        if (getPresenter().getRepo() != null && getPresenter().getRepo().getParent() != null) {
            Repo parent = getPresenter().getRepo().getParent();
            SchemeParser.launchUri(this, parent.getHtmlUrl());
        }
        return true;
    } else if (item.getItemId() == R.id.deleteRepo) {
        MessageDialogView.newInstance(getString(R.string.delete_repo), getString(R.string.delete_repo_warning), Bundler.start().put(BundleConstant.EXTRA_TWO, true).put(BundleConstant.YES_NO_EXTRA, true).end()).show(getSupportFragmentManager(), MessageDialogView.TAG);
        return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : Repo(com.fastaccess.data.dao.model.Repo) Intent(android.content.Intent) MainActivity(com.fastaccess.ui.modules.main.MainActivity)

Example 8 with Repo

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

the class GroupedNotificationModel method construct.

@NonNull
public static List<GroupedNotificationModel> construct(@Nullable List<Notification> items) {
    List<GroupedNotificationModel> models = new ArrayList<>();
    if (items == null || items.isEmpty())
        return models;
    Map<Repo, List<Notification>> grouped = Stream.of(items).filter(value -> !value.isUnread()).collect(Collectors.groupingBy(Notification::getRepository, LinkedHashMap::new, Collectors.mapping(o -> o, toList())));
    Stream.of(grouped).filter(repoListEntry -> repoListEntry.getValue() != null && !repoListEntry.getValue().isEmpty()).forEach(repoListEntry -> {
        Repo repo = repoListEntry.getKey();
        List<Notification> notifications = repoListEntry.getValue();
        models.add(new GroupedNotificationModel(repo));
        Stream.of(notifications).sorted((o1, o2) -> o2.getUpdatedAt().compareTo(o1.getUpdatedAt())).forEach(notification -> models.add(new GroupedNotificationModel(notification)));
    });
    return models;
}
Also used : Notification(com.fastaccess.data.dao.model.Notification) Setter(lombok.Setter) Collectors(com.annimon.stream.Collectors) Stream(com.annimon.stream.Stream) Getter(lombok.Getter) Repo(com.fastaccess.data.dao.model.Repo) Date(java.util.Date) NonNull(lombok.NonNull) InputHelper(com.fastaccess.helper.InputHelper) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) List(java.util.List) Collectors.toList(com.annimon.stream.Collectors.toList) Map(java.util.Map) Nullable(android.support.annotation.Nullable) Repo(com.fastaccess.data.dao.model.Repo) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Collectors.toList(com.annimon.stream.Collectors.toList) Notification(com.fastaccess.data.dao.model.Notification) NonNull(lombok.NonNull)

Aggregations

Repo (com.fastaccess.data.dao.model.Repo)8 Intent (android.content.Intent)3 NameParser (com.fastaccess.data.dao.NameParser)3 ArrayList (java.util.ArrayList)2 Uri (android.net.Uri)1 Nullable (android.support.annotation.Nullable)1 MenuItem (android.view.MenuItem)1 BindString (butterknife.BindString)1 Collectors (com.annimon.stream.Collectors)1 Collectors.toList (com.annimon.stream.Collectors.toList)1 Stream (com.annimon.stream.Stream)1 LicenseModel (com.fastaccess.data.dao.LicenseModel)1 PayloadModel (com.fastaccess.data.dao.PayloadModel)1 SimpleUrlsModel (com.fastaccess.data.dao.SimpleUrlsModel)1 AbstractRepo (com.fastaccess.data.dao.model.AbstractRepo)1 Notification (com.fastaccess.data.dao.model.Notification)1 InputHelper (com.fastaccess.helper.InputHelper)1 TopicsAdapter (com.fastaccess.ui.adapter.TopicsAdapter)1 MainActivity (com.fastaccess.ui.modules.main.MainActivity)1 LabelSpan (com.fastaccess.ui.widgets.LabelSpan)1