Skip to content

Commit 641ab88

Browse files
committed
Code format and fix for lookup uri.
1 parent 121d5b3 commit 641ab88

File tree

2 files changed

+20
-23
lines changed

2 files changed

+20
-23
lines changed

picasso/src/main/java/com/squareup/picasso/ContactsPhotoBitmapHunter.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,23 @@
3333
import static com.squareup.picasso.Picasso.LoadedFrom.DISK;
3434

3535
class ContactsPhotoBitmapHunter extends BitmapHunter {
36-
/**
37-
a lookup uri (e.g. content://com.android.contacts/contacts/lookup/3570i61d948d30808e537 )
38-
*/
36+
/** A lookup uri (e.g. content://com.android.contacts/contacts/lookup/3570i61d948d30808e537) */
3937
private static final int ID_LOOKUP = 1;
40-
/**
41-
a contact thumbnail uri (e.g. content://com.android.contacts/contacts/38/photo)
42-
*/
38+
/** A contact thumbnail uri (e.g. content://com.android.contacts/contacts/38/photo) */
4339
private static final int ID_THUMBNAIL = 2;
44-
/**
45-
a contact uri (e.g. content://com.android.contacts/contacts/38)
46-
*/
40+
/** A contact uri (e.g. content://com.android.contacts/contacts/38) */
4741
private static final int ID_CONTACT = 3;
4842
/**
49-
a contact display photo (high resolution) uri
50-
(e.g. content://com.android.contacts/display_photo/5)
43+
* A contact display photo (high resolution) uri
44+
* (e.g. content://com.android.contacts/display_photo/5)
5145
*/
5246
private static final int ID_DISPLAY_PHOTO = 4;
5347

54-
static final UriMatcher matcher;
48+
private static final UriMatcher matcher;
5549

5650
static {
5751
matcher = new UriMatcher(UriMatcher.NO_MATCH);
52+
matcher.addURI(ContactsContract.AUTHORITY, "contacts/lookup/*/#", ID_LOOKUP);
5853
matcher.addURI(ContactsContract.AUTHORITY, "contacts/lookup/*", ID_LOOKUP);
5954
matcher.addURI(ContactsContract.AUTHORITY, "contacts/#/photo", ID_THUMBNAIL);
6055
matcher.addURI(ContactsContract.AUTHORITY, "contacts/#", ID_CONTACT);
@@ -69,8 +64,7 @@ a contact display photo (high resolution) uri
6964
this.context = context;
7065
}
7166

72-
@Override Bitmap decode(Request data)
73-
throws IOException {
67+
@Override Bitmap decode(Request data) throws IOException {
7468
InputStream is = null;
7569
try {
7670
is = getInputStream();
@@ -90,7 +84,7 @@ private InputStream getInputStream() throws IOException {
9084
switch (matcher.match(uri)) {
9185
case ID_LOOKUP:
9286
uri = ContactsContract.Contacts.lookupContact(contentResolver, uri);
93-
if (null == uri) {
87+
if (uri == null) {
9488
return null;
9589
}
9690
// Resolved the uri to a contact uri, intentionally fall through to process the resolved uri

picasso/src/test/java/com/squareup/picasso/UtilsTest.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323

2424
import static com.squareup.picasso.TestUtils.URI_1;
2525
import static com.squareup.picasso.Utils.createKey;
26+
import static com.squareup.picasso.Utils.isWebPFile;
2627
import static com.squareup.picasso.Utils.parseResponseSourceHeader;
2728
import static org.fest.assertions.api.Assertions.assertThat;
2829

29-
@RunWith(RobolectricTestRunner.class) @Config(manifest = Config.NONE)
30+
@RunWith(RobolectricTestRunner.class)
31+
@Config(manifest = Config.NONE)
3032
public class UtilsTest {
3133

32-
@Test public void matchingRequestsHaveSameKey() {
34+
@Test public void matchingRequestsHaveSameKey() throws Exception {
3335
Request request = new Request.Builder(URI_1).build();
3436
String key1 = createKey(request);
3537
String key2 = createKey(request);
@@ -66,7 +68,7 @@ public class UtilsTest {
6668
assertThat(order1).isNotEqualTo(order2);
6769
}
6870

69-
@Test public void loadedFromCache() {
71+
@Test public void loadedFromCache() throws Exception {
7072
assertThat(parseResponseSourceHeader(null)).isFalse();
7173
assertThat(parseResponseSourceHeader("CACHE 200")).isTrue();
7274
assertThat(parseResponseSourceHeader("STREAM 200")).isFalse();
@@ -78,10 +80,11 @@ public class UtilsTest {
7880
}
7981

8082
@Test public void detectedWebPFile() throws Exception {
81-
assertThat(Utils.isWebPFile(new ByteArrayInputStream("RIFFxxxxWEBP".getBytes("US-ASCII")))).isTrue();
82-
assertThat(Utils.isWebPFile(new ByteArrayInputStream("RIFFxxxxxWEBP".getBytes("US-ASCII")))).isFalse();
83-
assertThat(Utils.isWebPFile(new ByteArrayInputStream("ABCDxxxxWEBP".getBytes("US-ASCII")))).isFalse();
84-
assertThat(Utils.isWebPFile(new ByteArrayInputStream("RIFFxxxxABCD".getBytes("US-ASCII")))).isFalse();
85-
assertThat(Utils.isWebPFile(new ByteArrayInputStream("RIFFxxWEBP".getBytes("US-ASCII")))).isFalse();
83+
assertThat(isWebPFile(new ByteArrayInputStream("RIFFxxxxWEBP".getBytes("US-ASCII")))).isTrue();
84+
assertThat(
85+
isWebPFile(new ByteArrayInputStream("RIFFxxxxxWEBP".getBytes("US-ASCII")))).isFalse();
86+
assertThat(isWebPFile(new ByteArrayInputStream("ABCDxxxxWEBP".getBytes("US-ASCII")))).isFalse();
87+
assertThat(isWebPFile(new ByteArrayInputStream("RIFFxxxxABCD".getBytes("US-ASCII")))).isFalse();
88+
assertThat(isWebPFile(new ByteArrayInputStream("RIFFxxWEBP".getBytes("US-ASCII")))).isFalse();
8689
}
8790
}

0 commit comments

Comments
 (0)