Search in sources :

Example 1 with IssueLabelService

use of com.meisolsson.githubsdk.service.issues.IssueLabelService in project gh4a by slapperwan.

the class IssueLabelListActivity method addLabel.

private void addLabel(IssueLabelAdapter.EditableLabel label) {
    String errorMessage = getString(R.string.issue_error_create_label, label.name());
    IssueLabelService service = ServiceFactory.get(IssueLabelService.class, false);
    Label newLabel = Label.builder().name(label.name()).color(label.color()).build();
    service.createLabel(mRepoOwner, mRepoName, newLabel).map(ApiHelpers::throwOnFailure).compose(RxUtils.wrapForBackgroundTask(this, R.string.saving_msg, errorMessage)).subscribe(result -> {
        mAddedLabel = null;
        loadLabels(true);
        setResult(RESULT_OK);
    }, error -> handleActionFailure("Adding label failed", error));
}
Also used : Label(com.meisolsson.githubsdk.model.Label) IssueLabelService(com.meisolsson.githubsdk.service.issues.IssueLabelService) ApiHelpers(com.gh4a.utils.ApiHelpers)

Example 2 with IssueLabelService

use of com.meisolsson.githubsdk.service.issues.IssueLabelService in project gh4a by slapperwan.

the class IssueLabelListActivity method deleteLabel.

private void deleteLabel(IssueLabelAdapter.EditableLabel label) {
    String errorMessage = getString(R.string.issue_error_delete_label, label.base().name());
    IssueLabelService service = ServiceFactory.get(IssueLabelService.class, false);
    service.deleteLabel(mRepoOwner, mRepoName, label.base().name()).map(ApiHelpers::throwOnFailure).compose(RxUtils.wrapForBackgroundTask(this, R.string.deleting_msg, errorMessage)).subscribe(result -> {
        loadLabels(true);
        setResult(RESULT_OK);
    }, error -> handleActionFailure("Deleting label failed", error));
}
Also used : IssueLabelService(com.meisolsson.githubsdk.service.issues.IssueLabelService) ApiHelpers(com.gh4a.utils.ApiHelpers)

Example 3 with IssueLabelService

use of com.meisolsson.githubsdk.service.issues.IssueLabelService in project gh4a by slapperwan.

the class IssueListActivity method filterLabel.

private void filterLabel() {
    if (mLabels != null) {
        showLabelsDialog();
    } else {
        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(labels -> {
            mLabels = labels;
            showLabelsDialog();
        }, this::handleLoadFailure));
    }
}
Also used : Context(android.content.Context) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) Bundle(android.os.Bundle) SearchView(android.support.v7.widget.SearchView) IssueMilestoneService(com.meisolsson.githubsdk.service.issues.IssueMilestoneService) Intent(android.content.Intent) StringRes(android.support.annotation.StringRes) NonNull(android.support.annotation.NonNull) MenuItem(android.view.MenuItem) UiUtils(com.gh4a.utils.UiUtils) User(com.meisolsson.githubsdk.model.User) IssueListFragment(com.gh4a.fragment.IssueListFragment) IssueState(com.meisolsson.githubsdk.model.IssueState) Milestone(com.meisolsson.githubsdk.model.Milestone) Label(com.meisolsson.githubsdk.model.Label) Locale(java.util.Locale) Menu(android.view.Menu) R(com.gh4a.R) Issue(com.meisolsson.githubsdk.model.Issue) View(android.view.View) IssueAssigneeService(com.meisolsson.githubsdk.service.issues.IssueAssigneeService) DialogInterface(android.content.DialogInterface) FloatingActionButton(android.support.design.widget.FloatingActionButton) ApiHelpers(com.gh4a.utils.ApiHelpers) BaseFragmentPagerActivity(com.gh4a.BaseFragmentPagerActivity) Fragment(android.support.v4.app.Fragment) IssueLabelService(com.meisolsson.githubsdk.service.issues.IssueLabelService) TextUtils(android.text.TextUtils) LoadingListFragmentBase(com.gh4a.fragment.LoadingListFragmentBase) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) AlertDialog(android.support.v7.app.AlertDialog) RxUtils(com.gh4a.utils.RxUtils) Gh4Application(com.gh4a.Gh4Application) SingleFactory(com.gh4a.utils.SingleFactory) Nullable(android.support.annotation.Nullable) ServiceFactory(com.gh4a.ServiceFactory) Activity(android.app.Activity) IssueLabelService(com.meisolsson.githubsdk.service.issues.IssueLabelService)

Example 4 with IssueLabelService

use of com.meisolsson.githubsdk.service.issues.IssueLabelService 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)

Example 5 with IssueLabelService

use of com.meisolsson.githubsdk.service.issues.IssueLabelService in project gh4a by slapperwan.

the class IssueLabelListActivity method loadLabels.

private void loadLabels(boolean force) {
    final IssueLabelService service = ServiceFactory.get(IssueLabelService.class, false);
    ApiHelpers.PageIterator.toSingle(page -> service.getRepositoryLabels(mRepoOwner, mRepoName, page)).compose(RxUtils.mapList(IssueLabelAdapter.EditableLabel::new)).compose(makeLoaderSingle(ID_LOADER_LABELS, force)).subscribe(result -> {
        UiUtils.hideImeForView(getCurrentFocus());
        mAdapter.clear();
        mAdapter.addAll(result);
        setContentShown(true);
    }, this::handleLoadFailure);
}
Also used : Context(android.content.Context) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) Bundle(android.os.Bundle) Intent(android.content.Intent) MenuItem(android.view.MenuItem) UiUtils(com.gh4a.utils.UiUtils) Label(com.meisolsson.githubsdk.model.Label) Menu(android.view.Menu) R(com.gh4a.R) View(android.view.View) FloatingActionButton(android.support.design.widget.FloatingActionButton) ApiHelpers(com.gh4a.utils.ApiHelpers) ActionMode(android.support.v7.view.ActionMode) IssueLabelAdapter(com.gh4a.adapter.IssueLabelAdapter) IssueLabelService(com.meisolsson.githubsdk.service.issues.IssueLabelService) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) RootAdapter(com.gh4a.adapter.RootAdapter) AlertDialog(android.support.v7.app.AlertDialog) RxUtils(com.gh4a.utils.RxUtils) Gh4Application(com.gh4a.Gh4Application) DividerItemDecoration(com.gh4a.widget.DividerItemDecoration) Nullable(android.support.annotation.Nullable) ServiceFactory(com.gh4a.ServiceFactory) BaseActivity(com.gh4a.BaseActivity) IssueLabelAdapter(com.gh4a.adapter.IssueLabelAdapter) IssueLabelService(com.meisolsson.githubsdk.service.issues.IssueLabelService)

Aggregations

ApiHelpers (com.gh4a.utils.ApiHelpers)6 IssueLabelService (com.meisolsson.githubsdk.service.issues.IssueLabelService)6 Label (com.meisolsson.githubsdk.model.Label)5 Context (android.content.Context)3 Intent (android.content.Intent)3 Bundle (android.os.Bundle)3 Nullable (android.support.annotation.Nullable)3 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)3 FloatingActionButton (android.support.design.widget.FloatingActionButton)3 AlertDialog (android.support.v7.app.AlertDialog)3 View (android.view.View)3 Gh4Application (com.gh4a.Gh4Application)3 R (com.gh4a.R)3 ServiceFactory (com.gh4a.ServiceFactory)3 RxUtils (com.gh4a.utils.RxUtils)3 UiUtils (com.gh4a.utils.UiUtils)3 DialogInterface (android.content.DialogInterface)2 RecyclerView (android.support.v7.widget.RecyclerView)2 Menu (android.view.Menu)2 MenuItem (android.view.MenuItem)2