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);
}
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);
}
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;
}
Aggregations