Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

into() : Applying a Phrase to a TextView #13

Closed
wants to merge 1 commit into from

Conversation

quinnjn
Copy link
Contributor

@quinnjn quinnjn commented Apr 9, 2015

Allows setting text directly from the Phrase chain, similar to how Picasso does it.

Before:

  CharSequence greeting = Phrase.from("Hello {user}!").put("user", "Quinn").format();
  greetingTextView.setText(greeting);

Now:

  Phrase.from("Hello {user}!")
      .put("user", "Quinn")
      .into(greetingTextView);

@quinnjn quinnjn changed the title Adding into to apply a Phrase right to a TextView into() : Applying a Phrase to a TextView Apr 9, 2015

@Test public void testIntoNullFailsFast() {
try {
Phrase.from("Hello {user}!").put("user", "Eric").into(null);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll also want to fail if the exception is not thrown at all.

Ideally, all these tests should use @Rule ExpectedException.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, adding this in.

commit cfb46a06bc78d0c5b1112fa1ff6f19e8b3ade622
Merge: 4fbd68b 4efb923
Author: Quinn Neumiiller <quinnjn@gmail.com>
Date:   Thu Apr 9 16:13:48 2015 -0600

    Better exception testing.

commit 4fbd68b
Author: Quinn Neumiiller <quinnjn@gmail.com>
Date:   Thu Apr 9 11:15:56 2015 -0600

    Squashed commit of the following:

    commit 4efb923
    Author: Quinn Neumiiller <quinnjn@gmail.com>
    Date:   Thu Apr 9 11:15:35 2015 -0600

        Adding usage to readme.

    commit 11f1039
    Author: Quinn Neumiiller <quinnjn@gmail.com>
    Date:   Thu Apr 9 10:50:04 2015 -0600

        Adding into and tests.

commit 4efb923
Author: Quinn Neumiiller <quinnjn@gmail.com>
Date:   Thu Apr 9 11:15:35 2015 -0600

    Adding usage to readme.

commit 11f1039
Author: Quinn Neumiiller <quinnjn@gmail.com>
Date:   Thu Apr 9 10:50:04 2015 -0600

    Adding into and tests.
@@ -166,4 +173,20 @@ public void formatFailsFastWhenKeysAreMissing() {
assertThat(formatted.toString()).isEqualTo("Hello Abe, you are 20 years old.");
assertThat(formatted).isInstanceOf(Spannable.class);
}

@Test public void testIntoSetsTargetText() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for test word prefix.

@loganj
Copy link
Collaborator

loganj commented Feb 16, 2016

Merged separately w/ feedback applied. Thanks!

@loganj loganj closed this Feb 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants