Search in sources :

Example 1 with StyleableTextView

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);
    }
}
Also used : ReleaseAssetAdapter(com.gh4a.adapter.ReleaseAssetAdapter) StyleableTextView(com.gh4a.widget.StyleableTextView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) ImageView(android.widget.ImageView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) StyleableTextView(com.gh4a.widget.StyleableTextView)

Example 2 with StyleableTextView

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);
}
Also used : Bundle(android.os.Bundle) StyleableTextView(com.gh4a.widget.StyleableTextView) View(android.view.View) StyleableTextView(com.gh4a.widget.StyleableTextView)

Example 3 with StyleableTextView

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);
    }
}
Also used : User(com.meisolsson.githubsdk.model.User) GitUser(com.meisolsson.githubsdk.model.git.GitUser) GitCommit(com.meisolsson.githubsdk.model.git.GitCommit) CommitDiffViewerActivity(com.gh4a.activities.CommitDiffViewerActivity) FileViewerActivity(com.gh4a.activities.FileViewerActivity) UserActivity(com.gh4a.activities.UserActivity) Activity(android.app.Activity) ImageView(android.widget.ImageView) View(android.view.View) StyleableTextView(com.gh4a.widget.StyleableTextView) TextView(android.widget.TextView) GitUser(com.meisolsson.githubsdk.model.git.GitUser) StyleableTextView(com.gh4a.widget.StyleableTextView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) AvatarHandler(com.gh4a.utils.AvatarHandler) Gh4Application(com.gh4a.Gh4Application) StyleableTextView(com.gh4a.widget.StyleableTextView)

Aggregations

StyleableTextView (com.gh4a.widget.StyleableTextView)3 View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 Activity (android.app.Activity)1 Bundle (android.os.Bundle)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 Gh4Application (com.gh4a.Gh4Application)1 CommitDiffViewerActivity (com.gh4a.activities.CommitDiffViewerActivity)1 FileViewerActivity (com.gh4a.activities.FileViewerActivity)1 UserActivity (com.gh4a.activities.UserActivity)1 ReleaseAssetAdapter (com.gh4a.adapter.ReleaseAssetAdapter)1 AvatarHandler (com.gh4a.utils.AvatarHandler)1 User (com.meisolsson.githubsdk.model.User)1 GitCommit (com.meisolsson.githubsdk.model.git.GitCommit)1 GitUser (com.meisolsson.githubsdk.model.git.GitUser)1