package com.gh4a.loader;

import java.io.IOException;
import java.util.List;

import org.eclipse.egit.github.core.Release;
import org.eclipse.egit.github.core.RepositoryId;
import org.eclipse.egit.github.core.service.RepositoryService;

import android.content.Context;

import com.gh4a.Gh4Application;

public class ReleaseLoader extends BaseLoader<List<Release>> {

    private String mRepoOwner;
    private String mRepoName;

    public ReleaseLoader(Context context, String repoOwner, String repoName) {
        super(context);
        mRepoOwner = repoOwner;
        mRepoName = repoName;
    }

    @Override
    public List<Release> doLoadInBackground() throws IOException {
        RepositoryService repoService = (RepositoryService)
                Gh4Application.get(getContext()).getService(Gh4Application.REPO_SERVICE);
        return repoService.getReleases(new RepositoryId(mRepoOwner, mRepoName));
    }
}

@@ -47,16 +47,75 @@
 eption;%0A
+import java.util.Collections;%0Aimport java.util.Comparator;%0A
 import j
@@ -896,14 +896,32 @@
     
-return
+List%3CRelease%3E releases =
  rep
@@ -983,16 +983,298 @@
 Name));%0A
+        Collections.sort(releases, new Comparator%3CRelease%3E() %7B%0A%0A            @Override%0A            public int compare(Release lhs, Release rhs) %7B%0A                return rhs.getCreatedAt().compareTo(lhs.getCreatedAt());%0A            %7D%0A            %0A        %7D);%0A        return releases;%0A
     %7D%0A%7D%0A

Fix #171. Sort releases by latest.