Skip to content

Commit

Permalink
Cleanup Code
Browse files Browse the repository at this point in the history
  • Loading branch information
briceln committed Jan 1, 2019
1 parent 6612b88 commit 5fccd74
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ dependencies {

implementation 'com.google.android.exoplayer:exoplayer:2.9.3'

implementation 'net.gotev:uploadservice:3.4.2'

testImplementation 'junit:junit:4.12'
implementation 'com.android.support:design:28.0.0'
}
17 changes: 10 additions & 7 deletions app/src/main/java/brice_bastien/epicture/ImgurApi/ImgurApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;

import net.gotev.uploadservice.MultipartUploadRequest;
import net.gotev.uploadservice.UploadNotificationConfig;
import net.gotev.uploadservice.UploadService;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -123,7 +127,7 @@ public void onResponse(NetworkResponse response) {
request.addPart(new MultipartRequest.FormPart("comment", comment));
Log.i("post a comment", new String(request.getBody()));
requestQueue.add(request);
}catch (Exception e) {
} catch (Exception e) {
Log.w("post a comment:", "failed");
}
}
Expand All @@ -132,7 +136,7 @@ public void getComment(String id, CommentAdapter adapter) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
Boolean switchPref = sharedPrefs.getBoolean(SettingsActivity.KEY_PREF_COMMENTARY_NEW, false);

String url = host + "gallery/" + id + "/comments/" + (switchPref ? "new" : "best" );
String url = host + "gallery/" + id + "/comments/" + (switchPref ? "new" : "best");
JsonObjectRequest request = new JsonRequest(Request.Method.GET, url, null, new ResponseCommentListener(adapter), new ErrorListener(adapter.statesRecyclerViewAdapter), clientId, token);

requestQueue.add(request);
Expand Down Expand Up @@ -201,7 +205,7 @@ public void getRecentImg(PostsFragment fragment, String section) {

public void getUsrAvatar(ImageView img, String username) {
String url = host + "account/" + username + "/avatar";
JsonObjectRequest request = new JsonRequest(Request.Method.GET, url, null, new ResponseAvatarListener(context, img) , new ErrorListener(), clientId, token);
JsonObjectRequest request = new JsonRequest(Request.Method.GET, url, null, new ResponseAvatarListener(context, img), new ErrorListener(), clientId, token);

requestQueue.add(request);
}
Expand All @@ -214,7 +218,7 @@ public void getUsrSetting(AccountSetting view) {
}

public void putUsrSetting(SettingItem settingItem) {
String url = host + "account/" + username +"/settings";
String url = host + "account/" + username + "/settings";
HashMap<String, String> headers = new HashMap<>();
headers.put("Authorization", "Bearer " + token);
MultipartRequest request = new MultipartRequest(Request.Method.POST, url, headers, new Response.Listener<NetworkResponse>() {
Expand All @@ -231,13 +235,13 @@ public void onResponse(NetworkResponse response) {
request.addPart(new MultipartRequest.FormPart("newsletter_subscribed", Boolean.toString(settingItem.isNewsletter())));
Log.i("saveSetting", new String(request.getBody()));
requestQueue.add(request);
}catch (Exception e) {
} catch (Exception e) {
Log.w("saveSetting:", e.toString());
}
}

public void editImage(boolean isAlbum, String id, String title, String description) {
String url = host + (isAlbum ? "album/" : "image/") + id;
String url = host + (isAlbum ? "album/" : "image/") + id;
HashMap<String, String> headers = new HashMap<>();
headers.put("Authorization", "Bearer " + token);

Expand Down Expand Up @@ -284,7 +288,6 @@ public void onResponse(NetworkResponse response) {
requestQueue.add(request);
} catch (Exception e) {
e.printStackTrace();
Log.w("Upload", e.toString());
}
}

Expand Down

0 comments on commit 5fccd74

Please sign in to comment.