Navigation Menu

Skip to content

Commit

Permalink
Modernize project (#65)
Browse files Browse the repository at this point in the history
* Modernize project

* Fix travis
  • Loading branch information
felipecsl committed Nov 27, 2017
1 parent 95681ef commit 7992e55
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 66 deletions.
19 changes: 9 additions & 10 deletions .travis.yml
@@ -1,23 +1,22 @@
language: android
android:
components:
- tools
- platform-tools
- build-tools-25.0.2
- android-25
- extra-android-m2repository
- extra-android-support
- extra-google-m2repository
- tools
- platform-tools
- build-tools-27.0.1
- android-27
- extra-android-m2repository
- extra-android-support
- extra-google-m2repository
after_success:
- ".buildscript/deploy_snapshot.sh"
- ".buildscript/deploy_snapshot.sh"
jdk:
- oraclejdk8
- oraclejdk8
branches:
except:
- gh-pages
notifications:
email: false
script: "./gradlew clean check"
sudo: false
cache:
directories:
Expand Down
14 changes: 7 additions & 7 deletions app/build.gradle
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion 27
buildToolsVersion "27.0.1"

defaultConfig {
minSdkVersion 9
targetSdkVersion 25
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"

Expand All @@ -29,8 +29,8 @@ android {
}

dependencies {
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.squareup.okhttp:okhttp:2.7.4'
compile 'commons-io:commons-io:2.4'
compile 'com.android.support:appcompat-v7:27.0.1'
compile 'com.squareup.okhttp3:okhttp:3.9.1'
compile 'commons-io:commons-io:2.5'
compile project(':library')
}
Expand Up @@ -2,10 +2,6 @@

import android.util.Log;

import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;

import org.apache.commons.io.IOUtils;

import java.io.IOException;
Expand All @@ -15,35 +11,39 @@
import java.net.URL;
import java.net.URLDecoder;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class ByteArrayHttpClient {
private static final String TAG = "ByteArrayHttpClient";
private static OkHttpClient client = new OkHttpClient();
private static final String TAG = "ByteArrayHttpClient";
private static final OkHttpClient CLIENT = new OkHttpClient();

public static byte[] get(final String urlString) {
InputStream in = null;
public static byte[] get(final String urlString) {
InputStream in = null;
try {
final String decodedUrl = URLDecoder.decode(urlString, "UTF-8");
final URL url = new URL(decodedUrl);
final Request request = new Request.Builder().url(url).build();
final Response response = CLIENT.newCall(request).execute();
in = response.body().byteStream();
return IOUtils.toByteArray(in);
} catch (final MalformedURLException e) {
Log.d(TAG, "Malformed URL", e);
} catch (final OutOfMemoryError e) {
Log.d(TAG, "Out of memory", e);
} catch (final UnsupportedEncodingException e) {
Log.d(TAG, "Unsupported encoding", e);
} catch (final IOException e) {
Log.d(TAG, "IO exception", e);
} finally {
if (in != null) {
try {
final String decodedUrl = URLDecoder.decode(urlString, "UTF-8");
final URL url = new URL(decodedUrl);
final Request request = new Request.Builder().url(url).build();
final Response response = client.newCall(request).execute();
in = response.body().byteStream();
return IOUtils.toByteArray(in);
} catch (final MalformedURLException e) {
Log.d(TAG, "Malformed URL", e);
} catch (final OutOfMemoryError e) {
Log.d(TAG, "Out of memory", e);
} catch (final UnsupportedEncodingException e) {
Log.d(TAG, "Unsupported encoding", e);
} catch (final IOException e) {
Log.d(TAG, "IO exception", e);
} finally {
if (in != null) {
try {
in.close();
} catch (final IOException ignored) {
}
}
in.close();
} catch (final IOException ignored) {
}
return null;
}
}
return null;
}
}
Expand Up @@ -13,9 +13,8 @@
import java.util.List;

public class GifGridAdapter extends BaseAdapter {

private Context context;
private List<String> imageUrls;
private final Context context;
private final List<String> imageUrls;

public GifGridAdapter(Context context, List<String> imageUrls) {
this.context = context;
Expand Down Expand Up @@ -60,5 +59,4 @@ protected void onPostExecute(final byte[] bytes) {
}.execute(imageUrls.get(position));
return imageView;
}

}
Expand Up @@ -8,23 +8,20 @@
import java.util.List;

public class GridViewActivity extends AppCompatActivity {

private static final int NUMBER_CELLS = 50;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_grid);

List<String> imageUrls = new ArrayList<>();
List<String> imageUrls = new ArrayList<>(NUMBER_CELLS);
for (int i = 0; i < NUMBER_CELLS; i++) {
imageUrls.add("https://cloud.githubusercontent.com/assets/4410820/11539468/c4d62a9c-9959-11e5-908e-cf50a21ac0e9.gif");
}

GifGridAdapter adapter = new GifGridAdapter(this, imageUrls);
GridView gridView = (GridView) findViewById(R.id.gridView);
GridView gridView = findViewById(R.id.gridView);
gridView.setAdapter(adapter);
}

}
Expand Up @@ -25,10 +25,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

gifImageView = (GifImageView) findViewById(R.id.gifImageView);
btnToggle = (Button) findViewById(R.id.btnToggle);
btnBlur = (Button) findViewById(R.id.btnBlur);
final Button btnClear = (Button) findViewById(R.id.btnClear);
gifImageView = findViewById(R.id.gifImageView);
btnToggle = findViewById(R.id.btnToggle);
btnBlur = findViewById(R.id.btnBlur);
final Button btnClear = findViewById(R.id.btnClear);

blur = Blur.newInstance(this);
gifImageView.setOnFrameAvailable(new GifImageView.OnFrameAvailable() {
Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Expand Up @@ -3,14 +3,16 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:3.0.1'
}
}

allprojects {
repositories {
jcenter()
google()
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
8 changes: 4 additions & 4 deletions library/build.gradle
Expand Up @@ -2,11 +2,11 @@ apply plugin: 'com.android.library'
apply from: 'gradle-mvn-push.gradle'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion 27
buildToolsVersion "27.0.1"

defaultConfig {
minSdkVersion 9
minSdkVersion 14
}

compileOptions {
Expand All @@ -16,5 +16,5 @@ android {
}

dependencies {
compile 'com.android.support:support-annotations:25.1.0'
compile 'com.android.support:support-annotations:27.0.1'
}

0 comments on commit 7992e55

Please sign in to comment.