-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'developer' of https://github.com/eluchsinger/After-Hour…
…-Android into developer Updated Ticket.class
- Loading branch information
Showing
5 changed files
with
65 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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 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 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
31 changes: 31 additions & 0 deletions
31
app/src/main/java/ch/hsr/afterhour/service/server/CustomGsonParser.java
This file contains 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,31 @@ | ||
package ch.hsr.afterhour.service.server; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
|
||
import java.io.Serializable; | ||
|
||
import ch.viascom.groundwork.foxhttp.parser.FoxHttpParser; | ||
|
||
/** | ||
* Created by eluch on 26.05.2017. | ||
*/ | ||
|
||
public class CustomGsonParser implements FoxHttpParser { | ||
|
||
private final Gson gson; | ||
|
||
public CustomGsonParser(final Gson gson) { | ||
this.gson = gson; | ||
} | ||
|
||
@Override | ||
public Serializable serializedToObject(String json, Class<Serializable> type) { | ||
return gson.fromJson(json, type); | ||
} | ||
|
||
@Override | ||
public String objectToSerialized(Serializable o) { | ||
return gson.toJson(o); | ||
} | ||
} |
This file contains 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 |
---|---|---|
|
@@ -3,7 +3,11 @@ | |
import android.graphics.Bitmap; | ||
import android.graphics.BitmapFactory; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
|
||
import java.net.MalformedURLException; | ||
import java.text.DateFormat; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
@@ -36,10 +40,13 @@ public class FoxHttpAPI { | |
|
||
public FoxHttpAPI() throws FoxHttpException { | ||
|
||
final Gson gson = new GsonBuilder() | ||
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create(); | ||
|
||
// Non-encrypted Client / Requests | ||
FoxHttpClientBuilder builder = new FoxHttpClientBuilder(); | ||
builder.setFoxHttpResponseParser(new GsonParser()) | ||
.setFoxHttpRequestParser(new GsonParser()) | ||
builder.setFoxHttpResponseParser(new CustomGsonParser(gson)) | ||
.setFoxHttpRequestParser(new CustomGsonParser(gson)) | ||
.registerFoxHttpInterceptor(FoxHttpInterceptorType.RESPONSE, new DefaultServiceResultFaultInterceptor()) | ||
.addFoxHttpPlaceholderEntry("host", SERVER_PATH) | ||
.setFoxHttpLogger(new SystemOutFoxHttpLogger(true, LOGGER_NAME)) | ||
|
@@ -73,11 +80,7 @@ public User authenticateUser(String qrCode) throws FoxHttpException, MalformedUR | |
} | ||
|
||
public User login(String email, String password) throws FoxHttpException, MalformedURLException { | ||
//Todo: Delete Temporary Login and Return requests.login | ||
return requests.login(email, password); | ||
// User user = new User("Muster", "Max", "[email protected]", "+41791234567", "2017-02-02", true); | ||
// user.setId("1"); | ||
// return user; | ||
} | ||
|
||
public Event[] downloadEvents() throws FoxHttpException , MalformedURLException { | ||
|