-
Notifications
You must be signed in to change notification settings - Fork 919
feat: Removed volley and shifted api calls to retrofit #2896
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
app/src/main/java/org/fossasia/phimpme/share/imgur/ImgurPicUploadReq.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.fossasia.phimpme.share.imgur; | ||
|
||
public class ImgurPicUploadReq { | ||
String image; | ||
String caption; | ||
|
||
public String getImage() { | ||
return image; | ||
} | ||
|
||
public void setImage(String image) { | ||
this.image = image; | ||
} | ||
|
||
public String getCaption() { | ||
return caption; | ||
} | ||
|
||
public void setCaption(String caption) { | ||
this.caption = caption; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
app/src/main/java/org/fossasia/phimpme/share/imgur/ImgurPicUploadResp.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.fossasia.phimpme.share.imgur; | ||
|
||
public class ImgurPicUploadResp { | ||
private boolean success; | ||
private Data data; | ||
|
||
public boolean isSuccess() { | ||
return success; | ||
} | ||
|
||
public void setSuccess(boolean success) { | ||
this.success = success; | ||
} | ||
|
||
public Data getData() { | ||
return data; | ||
} | ||
|
||
public void setData(Data data) { | ||
this.data = data; | ||
} | ||
|
||
public static class Data { | ||
private String id; | ||
private String title; | ||
private String link; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
|
||
public String getLink() { | ||
return link; | ||
} | ||
|
||
public void setLink(String link) { | ||
this.link = link; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
app/src/main/java/org/fossasia/phimpme/utilities/ImgurApi.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.fossasia.phimpme.utilities; | ||
|
||
import org.fossasia.phimpme.share.imgur.ImgurPicUploadReq; | ||
import org.fossasia.phimpme.share.imgur.ImgurPicUploadResp; | ||
import retrofit2.Call; | ||
import retrofit2.http.Body; | ||
import retrofit2.http.Header; | ||
import retrofit2.http.POST; | ||
|
||
public interface ImgurApi { | ||
|
||
@POST("/image") | ||
Call<ImgurPicUploadResp> uploadImageToImgur( | ||
@Header("Authorization") String authorization, @Body ImgurPicUploadReq body); | ||
} |
35 changes: 35 additions & 0 deletions
35
app/src/main/java/org/fossasia/phimpme/utilities/RetrofitClient.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.fossasia.phimpme.utilities; | ||
|
||
import okhttp3.OkHttpClient; | ||
import okhttp3.logging.HttpLoggingInterceptor; | ||
import org.fossasia.phimpme.BuildConfig; | ||
import retrofit2.Retrofit; | ||
import retrofit2.converter.gson.GsonConverterFactory; | ||
|
||
// Retrofit client used for API Calls | ||
public class RetrofitClient { | ||
|
||
private static OkHttpClient.Builder httpClientBuilder = null; | ||
|
||
private static OkHttpClient.Builder httpClient() { | ||
if (httpClientBuilder == null) { | ||
httpClientBuilder = new OkHttpClient.Builder(); | ||
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); | ||
if (BuildConfig.DEBUG) { | ||
interceptor.level(HttpLoggingInterceptor.Level.BASIC); | ||
} else { | ||
interceptor.level(HttpLoggingInterceptor.Level.NONE); | ||
} | ||
httpClientBuilder.interceptors().add(interceptor); | ||
} | ||
return httpClientBuilder; | ||
} | ||
|
||
public static Retrofit getRetrofitClient(String baseUrl) { | ||
return new Retrofit.Builder() | ||
.baseUrl(baseUrl) | ||
.client(httpClient().build()) | ||
.addConverterFactory(GsonConverterFactory.create()) | ||
.build(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,5 +54,6 @@ ext { | |
nextCloudVersion = "1.5.0" | ||
lifecycleVersion = "2.1.0" | ||
glideVersion = "4.10.0" | ||
retrofitVersion = "2.6.2" | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.