use of com.gh4a.widget.StyleableTextView in project gh4a by slapperwan.
the class ReleaseInfoActivity method fillData.
private void fillData() {
ImageView gravatar = findViewById(R.id.iv_gravatar);
AvatarHandler.assignAvatar(gravatar, mRelease.author());
gravatar.setOnClickListener(this);
StyleableTextView details = findViewById(R.id.tv_releaseinfo);
String detailsText = getString(R.string.release_details, ApiHelpers.getUserLogin(this, mRelease.author()), StringUtils.formatRelativeTime(this, mRelease.createdAt(), true));
StringUtils.applyBoldTagsAndSetText(details, detailsText);
TextView releaseType = findViewById(R.id.tv_releasetype);
if (mRelease.draft()) {
releaseType.setText(R.string.release_type_draft);
} else if (mRelease.prerelease()) {
releaseType.setText(R.string.release_type_prerelease);
} else {
releaseType.setText(R.string.release_type_final);
}
TextView tag = findViewById(R.id.tv_releasetag);
tag.setText(getString(R.string.release_tag, mRelease.tagName()));
tag.setOnClickListener(this);
if (mRelease.assets() != null && !mRelease.assets().isEmpty()) {
RecyclerView downloadsList = findViewById(R.id.download_list);
ReleaseAssetAdapter adapter = new ReleaseAssetAdapter(this);
adapter.addAll(mRelease.assets());
adapter.setOnItemClickListener(this);
downloadsList.setLayoutManager(new LinearLayoutManager(this));
downloadsList.setNestedScrollingEnabled(false);
downloadsList.setAdapter(adapter);
} else {
findViewById(R.id.downloads).setVisibility(View.GONE);
}
}
use of com.gh4a.widget.StyleableTextView in project gh4a by slapperwan.
the class CreateReviewActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme(Gh4Application.THEME == R.style.DarkTheme ? R.style.BottomSheetDarkTheme : R.style.BottomSheetLightTheme);
super.onCreate(savedInstanceState);
setContentView(R.layout.comment_editor);
Bundle extras = getIntent().getExtras();
mRepoOwner = extras.getString(EXTRA_OWNER);
mRepoName = extras.getString(EXTRA_REPO);
mPullRequestNumber = extras.getInt(EXTRA_PR_NUMBER);
mPendingReview = (Review) extras.getSerializable(EXTRA_PENDING_REVIEW);
mRootLayout = findViewById(R.id.coordinator_layout);
mEditorSheet = findViewById(R.id.bottom_sheet);
View header = getLayoutInflater().inflate(R.layout.create_review_header, null);
mEditorSheet.addHeaderView(header);
mReviewEventAdapter = new ArrayAdapter<>(this, R.layout.spinner_item);
mReviewEventAdapter.add(new ReviewEventDesc(R.string.pull_request_review_event_comment, CreateReview.Event.Comment, SubmitReview.Event.Comment));
mReviewEventAdapter.add(new ReviewEventDesc(R.string.pull_request_review_event_approve, CreateReview.Event.Approve, SubmitReview.Event.Approve));
mReviewEventAdapter.add(new ReviewEventDesc(R.string.pull_request_review_event_request_changes, CreateReview.Event.RequestChanges, SubmitReview.Event.RequestChanges));
mReviewEventSpinner = header.findViewById(R.id.pull_request_review_event);
mReviewEventSpinner.setAdapter(mReviewEventAdapter);
StyleableTextView titleView = header.findViewById(R.id.review_dialog_title);
titleView.setText(getString(R.string.pull_request_review_dialog_title, mPullRequestNumber));
mEditorSheet.setCallback(this);
if (mPendingReview != null && savedInstanceState == null) {
mEditorSheet.setCommentText(mPendingReview.body(), false);
}
setResult(RESULT_CANCELED);
}
use of com.gh4a.widget.StyleableTextView in project gh4a by slapperwan.
the class CommitFragment method fillHeader.
private void fillHeader() {
final Activity activity = getActivity();
final Gh4Application app = Gh4Application.get();
ImageView ivGravatar = mContentView.findViewById(R.id.iv_gravatar);
User author = mCommit.author();
if (author != null) {
AvatarHandler.assignAvatar(ivGravatar, author);
} else {
GitUser commitAuthor = mCommit.commit().author();
String email = commitAuthor != null ? commitAuthor.email() : null;
ivGravatar.setImageDrawable(new AvatarHandler.DefaultAvatarDrawable(null, email));
}
String login = ApiHelpers.getAuthorLogin(mCommit);
if (login != null) {
ivGravatar.setOnClickListener(this);
ivGravatar.setTag(login);
}
TextView tvMessage = mContentView.findViewById(R.id.tv_message);
TextView tvTitle = mContentView.findViewById(R.id.tv_title);
String message = mCommit.commit().message();
int pos = message.indexOf('\n');
String title = pos > 0 ? message.substring(0, pos) : message;
title = EmojiParser.parseToUnicode(title);
int length = message.length();
while (pos > 0 && pos < length && Character.isWhitespace(message.charAt(pos))) {
pos++;
}
message = pos > 0 && pos < length ? message.substring(pos) : null;
if (message != null) {
message = EmojiParser.parseToUnicode(message);
}
tvTitle.setText(title);
tvMessage.setText(message);
tvTitle.setVisibility(StringUtils.isBlank(title) ? View.GONE : View.VISIBLE);
tvMessage.setVisibility(StringUtils.isBlank(message) ? View.GONE : View.VISIBLE);
tvMessage.setMovementMethod(UiUtils.CHECKING_LINK_METHOD);
GitCommit commit = mCommit.commit();
TextView tvAuthor = mContentView.findViewById(R.id.tv_author);
tvAuthor.setText(ApiHelpers.getAuthorName(app, mCommit));
TextView tvTimestamp = mContentView.findViewById(R.id.tv_timestamp);
tvTimestamp.setText(StringUtils.formatRelativeTime(activity, commit.author().date(), true));
View committerContainer = mContentView.findViewById(R.id.committer);
if (!ApiHelpers.authorEqualsCommitter(mCommit)) {
ImageView commitGravatar = mContentView.findViewById(R.id.iv_commit_gravatar);
StyleableTextView commitExtra = mContentView.findViewById(R.id.tv_commit_extra);
AvatarHandler.assignAvatar(commitGravatar, mCommit.committer());
String committerText = getString(R.string.commit_details, ApiHelpers.getCommitterName(app, mCommit), StringUtils.formatRelativeTime(activity, commit.committer().date(), true));
StringUtils.applyBoldTagsAndSetText(commitExtra, committerText);
committerContainer.setVisibility(View.VISIBLE);
} else {
committerContainer.setVisibility(View.GONE);
}
}
Aggregations