Search in sources :

Example 1 with Page

use of com.meisolsson.githubsdk.model.Page in project PocketHub by pockethub.

the class AssigneeDialog method load.

private void load(final User selectedAssignee) {
    getPageAndNext(1).subscribe(new ProgressObserverAdapter<Page<User>>(activity, R.string.loading_collaborators) {

        List<User> users = new ArrayList<>();

        @Override
        public void onError(Throwable error) {
            dismissProgress();
            Log.d(TAG, "Exception loading collaborators", error);
            ToastUtils.show(activity, error, R.string.error_collaborators_load);
        }

        @Override
        public void onComplete() {
            super.onComplete();
            Map<String, User> loadedCollaborators = new TreeMap<>(CASE_INSENSITIVE_ORDER);
            for (User user : users) {
                loadedCollaborators.put(user.login(), user);
            }
            collaborators = loadedCollaborators;
            dismissProgress();
            show(selectedAssignee);
        }

        @Override
        public void onNext(Page<User> page) {
            users.addAll(page.items());
        }
    }.start());
}
Also used : User(com.meisolsson.githubsdk.model.User) ProgressObserverAdapter(com.github.pockethub.android.rx.ProgressObserverAdapter) ArrayList(java.util.ArrayList) List(java.util.List) Page(com.meisolsson.githubsdk.model.Page) TreeMap(java.util.TreeMap)

Example 2 with Page

use of com.meisolsson.githubsdk.model.Page in project PocketHub by pockethub.

the class RefDialog method load.

private void load(final GitReference selectedRef) {
    getPageAndNext(1).subscribe(new ProgressObserverAdapter<Page<GitReference>>(activity, R.string.loading_refs) {

        List<GitReference> allRefs = new ArrayList<>();

        @Override
        public void onNext(Page<GitReference> page) {
            super.onNext(page);
            allRefs.addAll(page.items());
        }

        @Override
        public void onComplete() {
            super.onComplete();
            Map<String, GitReference> loadedRefs = new TreeMap<>(CASE_INSENSITIVE_ORDER);
            for (GitReference ref : allRefs) {
                if (RefUtils.isValid(ref)) {
                    loadedRefs.put(ref.ref(), ref);
                }
            }
            refs = loadedRefs;
            show(selectedRef);
        }

        @Override
        public void onError(Throwable e) {
            super.onError(e);
            Log.d(TAG, "Exception loading references", e);
            ToastUtils.show(activity, e, R.string.error_refs_load);
        }
    }.start());
}
Also used : ProgressObserverAdapter(com.github.pockethub.android.rx.ProgressObserverAdapter) ArrayList(java.util.ArrayList) List(java.util.List) Page(com.meisolsson.githubsdk.model.Page) TreeMap(java.util.TreeMap) GitReference(com.meisolsson.githubsdk.model.git.GitReference)

Example 3 with Page

use of com.meisolsson.githubsdk.model.Page in project PocketHub by pockethub.

the class LabelsDialog method load.

private void load(final Collection<Label> selectedLabels) {
    getPageAndNext(1).subscribe(new ProgressObserverAdapter<Page<Label>>(activity, R.string.loading_labels) {

        List<Label> repositoryLabels = new ArrayList<>();

        @Override
        public void onNext(Page<Label> page) {
            repositoryLabels.addAll(page.items());
        }

        @Override
        public void onComplete() {
            super.onComplete();
            Map<String, Label> loadedLabels = new TreeMap<>(CASE_INSENSITIVE_ORDER);
            for (Label label : repositoryLabels) {
                loadedLabels.put(label.name(), label);
            }
            labels = loadedLabels;
            dismissProgress();
            show(selectedLabels);
        }

        @Override
        public void onError(Throwable error) {
            dismissProgress();
            Log.e(TAG, "Exception loading labels", error);
            ToastUtils.show(activity, error, R.string.error_labels_load);
        }
    }.start());
}
Also used : ProgressObserverAdapter(com.github.pockethub.android.rx.ProgressObserverAdapter) Label(com.meisolsson.githubsdk.model.Label) ArrayList(java.util.ArrayList) List(java.util.List) Page(com.meisolsson.githubsdk.model.Page) TreeMap(java.util.TreeMap)

Aggregations

ProgressObserverAdapter (com.github.pockethub.android.rx.ProgressObserverAdapter)3 Page (com.meisolsson.githubsdk.model.Page)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 TreeMap (java.util.TreeMap)3 Label (com.meisolsson.githubsdk.model.Label)1 User (com.meisolsson.githubsdk.model.User)1 GitReference (com.meisolsson.githubsdk.model.git.GitReference)1