Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/square/picasso
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnWowUs committed Jul 1, 2016
2 parents a679b53 + 0230ba0 commit 3d44f27
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ android:
components:
- tools
- platform-tools
- build-tools-23.0.3
- build-tools-24.0.0
- extra-android-m2repository
- android-23
- android-24

jdk:
- oraclejdk8
Expand Down
11 changes: 6 additions & 5 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
ext {
compileSdkVersion = 23
buildToolsVersion = '23.0.3'
compileSdkVersion = 24
buildToolsVersion = '24.0.0'
minSdkVersion = 14
targetSdkVersion = 23
targetSdkVersion = 24
sourceCompatibilityVersion = JavaVersion.VERSION_1_7
targetCompatibilityVersion = JavaVersion.VERSION_1_7
okhttp3Version = '3.0.1'
supportLibrariesVersion = '24.0.0'

dep = [
androidPlugin : 'com.android.tools.build:gradle:2.1.2',
okhttp : 'com.squareup.okhttp:okhttp:2.7.1',
okhttp3 : "com.squareup.okhttp3:okhttp:$okhttp3Version",
mockWebServer : "com.squareup.okhttp3:mockwebserver:$okhttp3Version",
pollexor : 'com.squareup:pollexor:2.0.0',
supportV4 : 'com.android.support:support-v4:23.4.0',
supportAnnotations : 'com.android.support:support-annotations:23.4.0',
supportV4 : "com.android.support:support-v4:$supportLibrariesVersion",
supportAnnotations : "com.android.support:support-annotations:$supportLibrariesVersion",
junit : 'junit:junit:4.10',
fest : 'org.easytesting:fest-assert-core:2.0M10',
festAndroid : 'com.squareup:fest-android:1.0.6',
Expand Down
2 changes: 1 addition & 1 deletion picasso-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ android {

defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
minSdkVersion rootProject.ext.targetSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
applicationId 'com.example.picasso'

versionCode 1
Expand Down
2 changes: 1 addition & 1 deletion picasso-sample/lint.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

<lint>
<issue id="NewApi">
<ignore path="res/values/styles.xml" />
<ignore path="src/main/res/values/styles.xml" />
</issue>
</lint>
5 changes: 0 additions & 5 deletions picasso/src/main/java/com/squareup/picasso/LruCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ public final void evictAll() {
}

@Override public final synchronized void clearKeyUri(String uri) {
boolean sizeChanged = false;
int uriLength = uri.length();
for (Iterator<Map.Entry<String, Bitmap>> i = map.entrySet().iterator(); i.hasNext();) {
Map.Entry<String, Bitmap> entry = i.next();
Expand All @@ -142,12 +141,8 @@ public final void evictAll() {
if (newlineIndex == uriLength && key.substring(0, newlineIndex).equals(uri)) {
i.remove();
size -= Utils.getBitmapBytes(value);
sizeChanged = true;
}
}
if (sizeChanged) {
trimToSize(maxSize);
}
}

/** Returns the number of times {@link #get} returned a value. */
Expand Down
3 changes: 2 additions & 1 deletion picasso/src/main/java/com/squareup/picasso/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import android.support.annotation.Px;
import com.squareup.picasso.Picasso.Priority;

import java.util.ArrayList;
Expand Down Expand Up @@ -307,7 +308,7 @@ public Builder stableKey(@Nullable String stableKey) {
* Resize the image to the specified size in pixels.
* Use 0 as desired dimension to resize keeping aspect ratio.
*/
public Builder resize(int targetWidth, int targetHeight) {
public Builder resize(@Px int targetWidth, @Px int targetHeight) {
if (targetWidth < 0) {
throw new IllegalArgumentException("Width must be positive number or 0.");
}
Expand Down
15 changes: 5 additions & 10 deletions picasso/src/main/java/com/squareup/picasso/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,11 @@ static int calculateMemoryCacheSize(Context context) {
static boolean isAirplaneModeOn(Context context) {
ContentResolver contentResolver = context.getContentResolver();
try {
return airplaneModeSetting(contentResolver);
if (SDK_INT < JELLY_BEAN_MR1) {
//noinspection deprecation
return Settings.System.getInt(contentResolver, Settings.System.AIRPLANE_MODE_ON, 0) != 0;
}
return Settings.Global.getInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0) != 0;
} catch (NullPointerException e) {
// https://github.com/square/picasso/issues/761, some devices might crash here, assume that
// airplane mode is off.
Expand Down Expand Up @@ -441,15 +445,6 @@ static int getByteCount(Bitmap bitmap) {
}
}

@TargetApi(JELLY_BEAN_MR1)
private static boolean airplaneModeSetting(ContentResolver contentResolver) {
if (SDK_INT < JELLY_BEAN_MR1) {
//noinspection deprecation
return Settings.System.getInt(contentResolver, Settings.System.AIRPLANE_MODE_ON, 0) != 0;
}
return Settings.Global.getInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0) != 0;
}

private static class OkHttpDownloaderCreator {
static Downloader create(Context context) {
return new OkHttpDownloader(context);
Expand Down

0 comments on commit 3d44f27

Please sign in to comment.