-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from ApplETS/dev
Mise en production ÉTSMobile 2.20
- Loading branch information
Showing
139 changed files
with
5,785 additions
and
1,454 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
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
60 changes: 60 additions & 0 deletions
60
app/src/main/java/ca/etsmtl/applets/etsmobile/http/AppletsApiEvenementsRequest.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,60 @@ | ||
package ca.etsmtl.applets.etsmobile.http; | ||
|
||
import android.content.Context; | ||
|
||
import com.google.gson.Gson; | ||
import com.octo.android.robospice.request.springandroid.SpringAndroidSpiceRequest; | ||
import com.squareup.okhttp.OkHttpClient; | ||
import com.squareup.okhttp.Request; | ||
import com.squareup.okhttp.Response; | ||
|
||
import ca.etsmtl.applets.etsmobile.model.applets_events.EvenementCommunaute; | ||
import ca.etsmtl.applets.etsmobile.model.applets_events.EvenementCommunauteList; | ||
import ca.etsmtl.applets.etsmobile.model.applets_events.SourceEvenement; | ||
import ca.etsmtl.applets.etsmobile.model.applets_events.SourceEvenementList; | ||
import ca.etsmtl.applets.etsmobile2.R; | ||
|
||
public class AppletsApiEvenementsRequest extends SpringAndroidSpiceRequest<EvenementCommunauteList> { | ||
|
||
private Context context; | ||
private SourceEvenement source; | ||
|
||
public AppletsApiEvenementsRequest(Context context, SourceEvenement source) { | ||
super(EvenementCommunauteList.class); | ||
this.context = context; | ||
this.source = source; | ||
} | ||
|
||
@Override | ||
public EvenementCommunauteList loadDataFromNetwork() throws Exception { | ||
|
||
String eventsAddress = context.getString(R.string.applets_api_events, source.getKey()); | ||
|
||
OkHttpClient client = new OkHttpClient(); | ||
|
||
Request request = new Request.Builder() | ||
.url(eventsAddress) | ||
.get() | ||
.build(); | ||
|
||
Response response = client.newCall(request).execute(); | ||
|
||
String result = response.body().string(); | ||
EvenementCommunauteList evenementList = new Gson().fromJson(result, EvenementCommunauteList.class); | ||
|
||
for(EvenementCommunaute event : evenementList) { | ||
event.setSourceEvenement(source); | ||
} | ||
|
||
return evenementList; | ||
} | ||
|
||
/** | ||
* This method generates a unique cache key for this request. In this case | ||
* our cache key depends just on the keyword. | ||
* @return | ||
*/ | ||
public String createCacheKey() { | ||
return "events_"+source.getKey(); | ||
} | ||
} |
Oops, something went wrong.