Пример #1
0
 @Override
 public void doLoadInBackground(HashMap<Integer, Object> result) throws IOException {
   Gh4Application app = (Gh4Application) getContext().getApplicationContext();
   GitHubClient client = new GitHubClient();
   client.setOAuth2Token(app.getAuthToken());
   RepositoryService repoService = new RepositoryService(client);
   result.put(LoaderResult.DATA, repoService.getRepository(mRepoOwner, mRepoName));
 }
Пример #2
0
 @Override
 public void doLoadInBackground(HashMap<Integer, Object> result) throws IOException {
   Gh4Application app = (Gh4Application) getContext().getApplicationContext();
   GitHubClient client = new DefaultClient();
   client.setOAuth2Token(app.getAuthToken());
   IssueService issueService = new IssueService(client);
   result.put(LoaderResult.DATA, issueService.getComments(mRepoOwner, mRepoName, mIssueNumber));
 }
Пример #3
0
 @Override
 public Collection<Repository> doLoadInBackground() throws IOException {
   Gh4Application app = Gh4Application.get();
   RepositoryService repoService = (RepositoryService) app.getService(Gh4Application.REPO_SERVICE);
   if (ApiHelpers.loginEquals(mLogin, app.getAuthLogin())) {
     if (mSize > 0) {
       return repoService.pageRepositories(mFilterData, mSize).next();
     } else {
       return repoService.getRepositories(mFilterData);
     }
   } else if (Constants.User.TYPE_ORG.equals(mUserType)) {
     if (mSize > 0) {
       return repoService.pageOrgRepositories(mLogin, mFilterData, mSize).next();
     } else {
       return repoService.getOrgRepositories(mLogin, mFilterData);
     }
   } else {
     if (mSize > 0) {
       return repoService.pageRepositories(mLogin, mFilterData, mSize).next();
     } else {
       return repoService.getRepositories(mLogin, mFilterData);
     }
   }
 }
Пример #4
0
  public static void enqueueDownload(
      final Context context,
      String url,
      final String mimeType,
      final String fileName,
      final String description,
      final String mediaType) {
    if (url == null) {
      return;
    }

    final Uri uri =
        Uri.parse(url)
            .buildUpon()
            .appendQueryParameter("access_token", Gh4Application.get().getAuthToken())
            .build();
    final Uri destinationUri = buildDownloadDestinationUri(fileName);
    if (destinationUri == null) {
      ToastUtils.showMessage(context, R.string.download_fail_no_storage_toast);
      return;
    }

    if (!downloadNeedsWarning(context)) {
      enqueueDownload(context, uri, destinationUri, description, mimeType, mediaType, false);
      return;
    }

    DialogInterface.OnClickListener buttonListener =
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            boolean wifiOnly = which == DialogInterface.BUTTON_NEUTRAL;
            enqueueDownload(
                context, uri, destinationUri, description, mimeType, mediaType, wifiOnly);
          }
        };

    new AlertDialog.Builder(context)
        .setTitle(R.string.download_mobile_warning_title)
        .setMessage(R.string.download_mobile_warning_message)
        .setPositiveButton(R.string.download_now_button, buttonListener)
        .setNeutralButton(R.string.download_wifi_button, buttonListener)
        .setNegativeButton(R.string.cancel, null)
        .show();
  }
Пример #5
0
  @Override
  protected View createView(LayoutInflater inflater, ViewGroup parent) {
    View v = inflater.inflate(R.layout.row_simple_3, null);
    ViewHolder viewHolder = new ViewHolder();

    Typeface boldCondensed = Gh4Application.get(mContext).boldCondensed;

    viewHolder.tvTitle = (TextView) v.findViewById(R.id.tv_title);
    viewHolder.tvTitle.setTypeface(boldCondensed);

    viewHolder.tvDesc = (TextView) v.findViewById(R.id.tv_desc);

    viewHolder.tvExtra = (TextView) v.findViewById(R.id.tv_extra);
    viewHolder.tvExtra.setTextAppearance(mContext, R.style.default_text_micro);

    v.setTag(viewHolder);
    return v;
  }
 @Override
 public Integer doLoadInBackground() throws IOException {
   PullRequestService pullRequestService =
       (PullRequestService) Gh4Application.get().getService(Gh4Application.PULL_SERVICE);
   return pullRequestService.getPullRequests(mRepository, mState).size();
 }