Search in sources :

Example 11 with RxUtils

use of com.gh4a.utils.RxUtils in project gh4a by slapperwan.

the class IssueEditActivity method loadPotentialAssignees.

private void loadPotentialAssignees() {
    final RepositoryCollaboratorService service = ServiceFactory.get(RepositoryCollaboratorService.class, false);
    registerTemporarySubscription(ApiHelpers.PageIterator.toSingle(page -> service.getCollaborators(mRepoOwner, mRepoName, page)).compose(RxUtils::doInBackground).compose(RxUtils.wrapWithProgressDialog(this, R.string.loading_msg)).subscribe(result -> {
        mAllAssignee = result;
        User creator = mEditIssue.user();
        if (creator != null && !mAllAssignee.contains(creator)) {
            mAllAssignee.add(creator);
        }
        showAssigneesDialog();
    }, this::handleLoadFailure));
}
Also used : HttpURLConnection(java.net.HttpURLConnection) Bundle(android.os.Bundle) ImageView(android.widget.ImageView) IssueMilestoneService(com.meisolsson.githubsdk.service.issues.IssueMilestoneService) TextInputLayout(android.support.design.widget.TextInputLayout) MarkdownPreviewWebView(com.gh4a.widget.MarkdownPreviewWebView) IssueState(com.meisolsson.githubsdk.model.IssueState) Label(com.meisolsson.githubsdk.model.Label) Locale(java.util.Locale) ContentType(com.meisolsson.githubsdk.model.ContentType) Issue(com.meisolsson.githubsdk.model.Issue) View(android.view.View) StringUtils(com.gh4a.utils.StringUtils) FloatingActionButton(android.support.design.widget.FloatingActionButton) ContextCompat(android.support.v4.content.ContextCompat) IssueLabelService(com.meisolsson.githubsdk.service.issues.IssueLabelService) ViewGroup(android.view.ViewGroup) RepositoryContentService(com.meisolsson.githubsdk.service.repositories.RepositoryContentService) List(java.util.List) TextView(android.widget.TextView) RxUtils(com.gh4a.utils.RxUtils) Optional(com.gh4a.utils.Optional) Nullable(android.support.annotation.Nullable) Typeface(android.graphics.Typeface) Context(android.content.Context) AppBarLayout(android.support.design.widget.AppBarLayout) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) MarkdownButtonsBar(com.gh4a.widget.MarkdownButtonsBar) BasePagerActivity(com.gh4a.BasePagerActivity) Intent(android.content.Intent) Response(retrofit2.Response) Single(io.reactivex.Single) UiUtils(com.gh4a.utils.UiUtils) ArrayList(java.util.ArrayList) User(com.meisolsson.githubsdk.model.User) AvatarHandler(com.gh4a.utils.AvatarHandler) Milestone(com.meisolsson.githubsdk.model.Milestone) Content(com.meisolsson.githubsdk.model.Content) R(com.gh4a.R) IssueRequest(com.meisolsson.githubsdk.model.request.issue.IssueRequest) IssueService(com.meisolsson.githubsdk.service.issues.IssueService) RepositoryCollaboratorService(com.meisolsson.githubsdk.service.repositories.RepositoryCollaboratorService) DialogInterface(android.content.DialogInterface) ApiHelpers(com.gh4a.utils.ApiHelpers) LayoutInflater(android.view.LayoutInflater) PagerAdapter(android.support.v4.view.PagerAdapter) IdRes(android.support.annotation.IdRes) AlertDialog(android.support.v7.app.AlertDialog) Gh4Application(com.gh4a.Gh4Application) ObjectsCompat(android.support.v4.util.ObjectsCompat) SingleFactory(com.gh4a.utils.SingleFactory) ServiceFactory(com.gh4a.ServiceFactory) EditText(android.widget.EditText) RepositoryCollaboratorService(com.meisolsson.githubsdk.service.repositories.RepositoryCollaboratorService) User(com.meisolsson.githubsdk.model.User)

Example 12 with RxUtils

use of com.gh4a.utils.RxUtils in project gh4a by slapperwan.

the class IssueEditActivity method loadIssueTemplate.

private void loadIssueTemplate() {
    RepositoryContentService service = ServiceFactory.get(RepositoryContentService.class, false);
    registerTemporarySubscription(getIssueTemplateContentSingle("/.github").flatMap(opt -> opt.orOptionalSingle(() -> getIssueTemplateContentSingle(""))).flatMap(opt -> opt.orOptionalSingle(() -> getIssueTemplateContentSingle("/docs"))).flatMap(opt -> opt.flatMap(c -> {
        // noinspection CodeBlock2Expr
        return service.getContents(mRepoOwner, mRepoName, c.path(), null).map(ApiHelpers::throwOnFailure).compose(RxUtils::doInBackground);
    })).map(opt -> opt.map(c -> StringUtils.fromBase64(c.content()))).compose(RxUtils.wrapWithProgressDialog(this, R.string.loading_msg)).subscribe(result -> {
        mDescView.setHint(null);
        mDescView.setEnabled(true);
        mDescView.setText(result.orNull());
    }, this::handleLoadFailure));
}
Also used : HttpURLConnection(java.net.HttpURLConnection) Bundle(android.os.Bundle) ImageView(android.widget.ImageView) IssueMilestoneService(com.meisolsson.githubsdk.service.issues.IssueMilestoneService) TextInputLayout(android.support.design.widget.TextInputLayout) MarkdownPreviewWebView(com.gh4a.widget.MarkdownPreviewWebView) IssueState(com.meisolsson.githubsdk.model.IssueState) Label(com.meisolsson.githubsdk.model.Label) Locale(java.util.Locale) ContentType(com.meisolsson.githubsdk.model.ContentType) Issue(com.meisolsson.githubsdk.model.Issue) View(android.view.View) StringUtils(com.gh4a.utils.StringUtils) FloatingActionButton(android.support.design.widget.FloatingActionButton) ContextCompat(android.support.v4.content.ContextCompat) IssueLabelService(com.meisolsson.githubsdk.service.issues.IssueLabelService) ViewGroup(android.view.ViewGroup) RepositoryContentService(com.meisolsson.githubsdk.service.repositories.RepositoryContentService) List(java.util.List) TextView(android.widget.TextView) RxUtils(com.gh4a.utils.RxUtils) Optional(com.gh4a.utils.Optional) Nullable(android.support.annotation.Nullable) Typeface(android.graphics.Typeface) Context(android.content.Context) AppBarLayout(android.support.design.widget.AppBarLayout) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) MarkdownButtonsBar(com.gh4a.widget.MarkdownButtonsBar) BasePagerActivity(com.gh4a.BasePagerActivity) Intent(android.content.Intent) Response(retrofit2.Response) Single(io.reactivex.Single) UiUtils(com.gh4a.utils.UiUtils) ArrayList(java.util.ArrayList) User(com.meisolsson.githubsdk.model.User) AvatarHandler(com.gh4a.utils.AvatarHandler) Milestone(com.meisolsson.githubsdk.model.Milestone) Content(com.meisolsson.githubsdk.model.Content) R(com.gh4a.R) IssueRequest(com.meisolsson.githubsdk.model.request.issue.IssueRequest) IssueService(com.meisolsson.githubsdk.service.issues.IssueService) RepositoryCollaboratorService(com.meisolsson.githubsdk.service.repositories.RepositoryCollaboratorService) DialogInterface(android.content.DialogInterface) ApiHelpers(com.gh4a.utils.ApiHelpers) LayoutInflater(android.view.LayoutInflater) PagerAdapter(android.support.v4.view.PagerAdapter) IdRes(android.support.annotation.IdRes) AlertDialog(android.support.v7.app.AlertDialog) Gh4Application(com.gh4a.Gh4Application) ObjectsCompat(android.support.v4.util.ObjectsCompat) SingleFactory(com.gh4a.utils.SingleFactory) ServiceFactory(com.gh4a.ServiceFactory) EditText(android.widget.EditText) RepositoryContentService(com.meisolsson.githubsdk.service.repositories.RepositoryContentService) ApiHelpers(com.gh4a.utils.ApiHelpers)

Example 13 with RxUtils

use of com.gh4a.utils.RxUtils in project gh4a by slapperwan.

the class IssueEditActivity method loadLabels.

private void loadLabels() {
    final IssueLabelService service = ServiceFactory.get(IssueLabelService.class, false);
    registerTemporarySubscription(ApiHelpers.PageIterator.toSingle(page -> service.getRepositoryLabels(mRepoOwner, mRepoName, page)).compose(RxUtils::doInBackground).compose(RxUtils.wrapWithProgressDialog(this, R.string.loading_msg)).subscribe(result -> {
        mAllLabels = result;
        showLabelDialog();
    }, this::handleLoadFailure));
}
Also used : HttpURLConnection(java.net.HttpURLConnection) Bundle(android.os.Bundle) ImageView(android.widget.ImageView) IssueMilestoneService(com.meisolsson.githubsdk.service.issues.IssueMilestoneService) TextInputLayout(android.support.design.widget.TextInputLayout) MarkdownPreviewWebView(com.gh4a.widget.MarkdownPreviewWebView) IssueState(com.meisolsson.githubsdk.model.IssueState) Label(com.meisolsson.githubsdk.model.Label) Locale(java.util.Locale) ContentType(com.meisolsson.githubsdk.model.ContentType) Issue(com.meisolsson.githubsdk.model.Issue) View(android.view.View) StringUtils(com.gh4a.utils.StringUtils) FloatingActionButton(android.support.design.widget.FloatingActionButton) ContextCompat(android.support.v4.content.ContextCompat) IssueLabelService(com.meisolsson.githubsdk.service.issues.IssueLabelService) ViewGroup(android.view.ViewGroup) RepositoryContentService(com.meisolsson.githubsdk.service.repositories.RepositoryContentService) List(java.util.List) TextView(android.widget.TextView) RxUtils(com.gh4a.utils.RxUtils) Optional(com.gh4a.utils.Optional) Nullable(android.support.annotation.Nullable) Typeface(android.graphics.Typeface) Context(android.content.Context) AppBarLayout(android.support.design.widget.AppBarLayout) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) MarkdownButtonsBar(com.gh4a.widget.MarkdownButtonsBar) BasePagerActivity(com.gh4a.BasePagerActivity) Intent(android.content.Intent) Response(retrofit2.Response) Single(io.reactivex.Single) UiUtils(com.gh4a.utils.UiUtils) ArrayList(java.util.ArrayList) User(com.meisolsson.githubsdk.model.User) AvatarHandler(com.gh4a.utils.AvatarHandler) Milestone(com.meisolsson.githubsdk.model.Milestone) Content(com.meisolsson.githubsdk.model.Content) R(com.gh4a.R) IssueRequest(com.meisolsson.githubsdk.model.request.issue.IssueRequest) IssueService(com.meisolsson.githubsdk.service.issues.IssueService) RepositoryCollaboratorService(com.meisolsson.githubsdk.service.repositories.RepositoryCollaboratorService) DialogInterface(android.content.DialogInterface) ApiHelpers(com.gh4a.utils.ApiHelpers) LayoutInflater(android.view.LayoutInflater) PagerAdapter(android.support.v4.view.PagerAdapter) IdRes(android.support.annotation.IdRes) AlertDialog(android.support.v7.app.AlertDialog) Gh4Application(com.gh4a.Gh4Application) ObjectsCompat(android.support.v4.util.ObjectsCompat) SingleFactory(com.gh4a.utils.SingleFactory) ServiceFactory(com.gh4a.ServiceFactory) EditText(android.widget.EditText) IssueLabelService(com.meisolsson.githubsdk.service.issues.IssueLabelService)

Aggregations

RxUtils (com.gh4a.utils.RxUtils)13 View (android.view.View)12 R (com.gh4a.R)12 ApiHelpers (com.gh4a.utils.ApiHelpers)12 User (com.meisolsson.githubsdk.model.User)12 Context (android.content.Context)11 ServiceFactory (com.gh4a.ServiceFactory)11 UiUtils (com.gh4a.utils.UiUtils)11 Bundle (android.os.Bundle)10 Gh4Application (com.gh4a.Gh4Application)10 List (java.util.List)10 Intent (android.content.Intent)9 Nullable (android.support.annotation.Nullable)9 AlertDialog (android.support.v7.app.AlertDialog)9 LayoutInflater (android.view.LayoutInflater)9 Single (io.reactivex.Single)9 DialogInterface (android.content.DialogInterface)8 Issue (com.meisolsson.githubsdk.model.Issue)8 Locale (java.util.Locale)8 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)7