Skip to content

Commit

Permalink
Updated okhttp to 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Alladin El Akhrass committed Jan 9, 2016
1 parent e4825dd commit 8f5f4c1
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ repositories {
dependencies {
// ... other dependencies here
compile'com.github.Alelak:materialup:1.1.2'
compile'com.github.Alelak:materialup:1.1.3'
}
```
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.alelak.materialupsample"
minSdkVersion 14
targetSdkVersion 23
versionCode 4
versionName "1.0.3"
versionCode 5
versionName "1.0.4"
}
buildTypes {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
import com.alelak.materialup.MaterialUp;
import com.alelak.materialup.callbacks.MaterialUpCallback;
import com.alelak.materialup.models.Post;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import okhttp3.Request;
import okhttp3.Response;

public class LatestPostsFragment extends Fragment {
private SwipeRefreshLayout mSwipeRefreshLayout;
private RecyclerView mRecyclerView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
import com.alelak.materialup.MaterialUp;
import com.alelak.materialup.callbacks.MaterialUpCallback;
import com.alelak.materialup.models.Post;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import okhttp3.Request;
import okhttp3.Response;

public class PopularPostsFragment extends Fragment {
private SwipeRefreshLayout mSwipeRefreshLayout;
private RecyclerView mRecyclerView;
Expand Down
6 changes: 3 additions & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 4
versionName "1.1.2"
versionCode 5
versionName "1.1.3"
}
}

dependencies {
compile 'org.jsoup:jsoup:1.8.3'
compile 'com.squareup.okhttp:okhttp:2.7.0'
compile 'com.squareup.okhttp3:okhttp:3.0.0-RC1'
compile 'com.google.code.gson:gson:2.5'
}
// build a jar with source files
Expand Down
11 changes: 6 additions & 5 deletions library/src/main/java/com/alelak/materialup/MaterialUp.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
import com.alelak.materialup.models.MaterialUpResponse;
import com.alelak.materialup.models.Post;
import com.google.gson.Gson;
import com.squareup.okhttp.Callback;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
Expand All @@ -20,6 +16,11 @@
import java.util.ArrayList;
import java.util.List;

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

public class MaterialUp {
public enum SORT {
LATEST, POPULAR
Expand Down Expand Up @@ -66,7 +67,7 @@ public void run() {

@Override
public void onResponse(final Response response) throws IOException {
final MaterialUpResponse materialUpResponse = GSON.fromJson(response.body().string(), MaterialUpResponse.class);
final MaterialUpResponse materialUpResponse = GSON.fromJson(response.body().charStream(), MaterialUpResponse.class);
final Element document = Jsoup.parse(materialUpResponse.content);
final Elements elements = document.select(".post-list-items .post-list-item");
for (Element element : elements) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.alelak.materialup.callbacks;

import com.alelak.materialup.models.Post;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;

import java.io.IOException;
import java.util.List;

import okhttp3.Request;
import okhttp3.Response;

public interface MaterialUpCallback {
void onSuccess(List<Post> posts, Response response);

Expand Down

0 comments on commit 8f5f4c1

Please sign in to comment.