Search in sources :

Example 6 with LabelModel

use of com.fastaccess.data.dao.LabelModel in project FastHub by k0shk0sh.

the class LabelsViewHolder method onClick.

@Override
public void onClick(View v) {
    if (onSelectLabel != null) {
        int position = getAdapterPosition();
        if (adapter != null) {
            LabelModel labelModel = (LabelModel) adapter.getItem(position);
            onSelectLabel.onToggleSelection(labelModel, !onSelectLabel.isLabelSelected(labelModel));
        }
    } else {
        super.onClick(v);
    }
}
Also used : LabelModel(com.fastaccess.data.dao.LabelModel)

Example 7 with LabelModel

use of com.fastaccess.data.dao.LabelModel in project FastHub by k0shk0sh.

the class CreateLabelPresenter method onSubmitLabel.

@Override
public void onSubmitLabel(@NonNull String name, @NonNull String color, @NonNull String repo, @NonNull String login) {
    LabelModel labelModel = new LabelModel();
    labelModel.setColor(color.replaceAll("#", ""));
    labelModel.setName(name);
    makeRestCall(RestProvider.getRepoService(isEnterprise()).addLabel(login, repo, labelModel), labelModel1 -> sendToView(view -> view.onSuccessfullyCreated(labelModel1)));
}
Also used : RestProvider(com.fastaccess.provider.rest.RestProvider) View(android.view.View) LabelModel(com.fastaccess.data.dao.LabelModel) NonNull(android.support.annotation.NonNull) BasePresenter(com.fastaccess.ui.base.mvp.presenter.BasePresenter) LabelModel(com.fastaccess.data.dao.LabelModel)

Example 8 with LabelModel

use of com.fastaccess.data.dao.LabelModel in project FastHub by k0shk0sh.

the class CreateIssueActivity method onSelectedLabels.

@Override
public void onSelectedLabels(@NonNull ArrayList<LabelModel> labelModels) {
    this.labelModels.clear();
    this.labelModels.addAll(labelModels);
    SpannableBuilder builder = SpannableBuilder.builder();
    for (int i = 0; i < labelModels.size(); i++) {
        LabelModel labelModel = labelModels.get(i);
        int color = Color.parseColor("#" + labelModel.getColor());
        if (i > 0) {
            builder.append(" ").append(" " + labelModel.getName() + " ", new LabelSpan(color));
        } else {
            builder.append(labelModel.getName() + " ", new LabelSpan(color));
        }
    }
    this.labels.setText(builder);
}
Also used : LabelModel(com.fastaccess.data.dao.LabelModel) SpannableBuilder(com.fastaccess.ui.widgets.SpannableBuilder) LabelSpan(com.fastaccess.ui.widgets.LabelSpan)

Example 9 with LabelModel

use of com.fastaccess.data.dao.LabelModel in project FastHub by k0shk0sh.

the class FeedsViewHolder method appendIssueEvent.

private void appendIssueEvent(SpannableBuilder spannableBuilder, Event eventsModel) {
    Issue issue = eventsModel.getPayload().getIssue();
    boolean isLabel = "label".equals(eventsModel.getPayload().getAction());
    LabelModel label = isLabel ? issue.getLabels() != null && !issue.getLabels().isEmpty() ? issue.getLabels().get(issue.getLabels().size() - 1) : null : null;
    spannableBuilder.bold(isLabel && label != null ? ("Labeled " + label.getName()) : eventsModel.getPayload().getAction()).append(" ").bold("issue").append(" ").append(eventsModel.getRepo().getName()).bold("#").bold(String.valueOf(issue.getNumber()));
    if (issue.getTitle() != null) {
        MarkDownProvider.stripMdText(description, issue.getTitle().replaceAll("\\r?\\n|\\r", " "));
        description.setVisibility(View.VISIBLE);
    } else {
        description.setText("");
        description.setVisibility(View.GONE);
    }
}
Also used : Issue(com.fastaccess.data.dao.model.Issue) LabelModel(com.fastaccess.data.dao.LabelModel)

Aggregations

LabelModel (com.fastaccess.data.dao.LabelModel)9 SpannableBuilder (com.fastaccess.ui.widgets.SpannableBuilder)4 NonNull (android.support.annotation.NonNull)3 User (com.fastaccess.data.dao.model.User)3 LabelSpan (com.fastaccess.ui.widgets.LabelSpan)3 View (android.view.View)2 MilestoneModel (com.fastaccess.data.dao.MilestoneModel)2 Issue (com.fastaccess.data.dao.model.Issue)2 RestProvider (com.fastaccess.provider.rest.RestProvider)2 BasePresenter (com.fastaccess.ui.base.mvp.presenter.BasePresenter)2 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 Nullable (android.support.annotation.Nullable)1 BackgroundColorSpan (android.text.style.BackgroundColorSpan)1 BindView (butterknife.BindView)1 Collectors (com.annimon.stream.Collectors)1 Stream (com.annimon.stream.Stream)1 BuildConfig (com.fastaccess.BuildConfig)1