-
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 pull request #67 from maximzhemerenko/develop
merge develop to master
- Loading branch information
Showing
154 changed files
with
8,854 additions
and
264 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
language: android | ||
android: | ||
components: | ||
- build-tools-27.0.3 | ||
- tools | ||
- platform-tools | ||
- android-27 | ||
licenses: | ||
- 'android-sdk-license-.+' | ||
- 'google-gdk-license-.+' | ||
- 'google-gdk-license-.+' | ||
|
||
before_install: | ||
- cd Android | ||
- chmod +x gradlew | ||
|
||
script: | ||
- ./gradlew assemble |
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
25 changes: 22 additions & 3 deletions
25
Android/app/src/main/java/com/khsm/app/data/api/ApiFactory.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 |
---|---|---|
@@ -1,22 +1,41 @@ | ||
package com.khsm.app.data.api; | ||
|
||
import android.content.Context; | ||
import android.support.annotation.NonNull; | ||
|
||
import com.khsm.app.BuildConfig; | ||
import com.khsm.app.data.api.base.ApiBase; | ||
import com.khsm.app.data.api.core.ApiBuilderHelper; | ||
import com.khsm.app.data.entities.Session; | ||
import com.khsm.app.data.preferences.SessionStore; | ||
|
||
import okhttp3.logging.HttpLoggingInterceptor; | ||
|
||
public abstract class ApiFactory { | ||
public static Api createApi() { | ||
public static Api createApi(@NonNull Context context) { | ||
ApiBuilderHelper apiBuilderHelper = new ApiBuilderHelper(); | ||
|
||
ApiBase.AuthInterceptor authInterceptor = new ApiBase.AuthInterceptor(); | ||
|
||
apiBuilderHelper.addInterceptor(authInterceptor); | ||
|
||
if (BuildConfig.DEBUG) { | ||
apiBuilderHelper.addLoggingInterceptor(HttpLoggingInterceptor.Level.BODY); | ||
} | ||
|
||
String serviceUrl = "http://10.0.2.2:5000/"; | ||
String serviceUrl = "http://10.0.2.2:5000/api/"; | ||
|
||
RestApi restApi = apiBuilderHelper.createRetrofitApi(serviceUrl, RestApi.class); | ||
|
||
return new Api(restApi); | ||
Api api = new Api(restApi, authInterceptor); | ||
|
||
SessionStore sessionStore = new SessionStore(context); | ||
|
||
Session session = sessionStore.getSession(); | ||
if (session != null) { | ||
api.setSessionToken(session.token); | ||
} | ||
|
||
return api; | ||
} | ||
} |
68 changes: 66 additions & 2 deletions
68
Android/app/src/main/java/com/khsm/app/data/api/RestApi.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 |
---|---|---|
@@ -1,13 +1,77 @@ | ||
package com.khsm.app.data.api; | ||
|
||
import com.khsm.app.data.api.entities.User; | ||
import com.khsm.app.data.api.entities.RankingsFilterInfo; | ||
import com.khsm.app.data.entities.CreateSessionRequest; | ||
import com.khsm.app.data.entities.CreateUserRequest; | ||
import com.khsm.app.data.entities.Discipline; | ||
import com.khsm.app.data.entities.DisciplineRecord; | ||
import com.khsm.app.data.entities.DisciplineResults; | ||
import com.khsm.app.data.entities.Gender; | ||
import com.khsm.app.data.entities.Meeting; | ||
import com.khsm.app.data.entities.News; | ||
import com.khsm.app.data.entities.Result; | ||
import com.khsm.app.data.entities.Session; | ||
import com.khsm.app.data.entities.User; | ||
|
||
import java.util.List; | ||
|
||
import io.reactivex.Single; | ||
import retrofit2.http.Body; | ||
import retrofit2.http.GET; | ||
import retrofit2.http.POST; | ||
import retrofit2.http.PUT; | ||
import retrofit2.http.Path; | ||
import retrofit2.http.Query; | ||
|
||
interface RestApi { | ||
@GET("api/users") | ||
@GET("meetings") | ||
Single<List<Meeting>> getMeetings(); | ||
|
||
@GET("meetings/last") | ||
Single<Meeting> getLastMeeting(); | ||
|
||
@GET("disciplines") | ||
Single<List<Discipline>> getDisciplines(); | ||
|
||
@GET("meetings/{id}/results") | ||
Single<List<DisciplineResults>> getMeetingResults(@Path("id") int id); | ||
|
||
@POST("sessions") | ||
Single<Session> login(@Body CreateSessionRequest createSessionRequest); | ||
|
||
@POST("users") | ||
Single<Session> register(@Body CreateUserRequest createUserRequest); | ||
|
||
@POST("meetings") | ||
Single<Meeting> createMeeting(@Body Meeting meeting); | ||
|
||
@POST("meetings/results") | ||
Single<Result> createResult(@Body Result result); | ||
|
||
@PUT("users/me") | ||
Single<User> updateUser(@Body User user); | ||
|
||
@GET("users/me/results") | ||
Single<List<DisciplineResults>> getMyResults(); | ||
|
||
@GET("users/me/records") | ||
Single<List<DisciplineRecord>> getMyRecords(); | ||
|
||
@GET("rankings") | ||
Single<List<DisciplineResults>> getRankings(@Query("type") RankingsFilterInfo.FilterType type, @Query("sort") RankingsFilterInfo.SortType sort, @Query("gender") Gender gender); | ||
|
||
@GET("news") | ||
Single<List<News>> getNews(); | ||
|
||
@GET("news/last") | ||
Single<News> getLastNews(); | ||
|
||
@GET("news/{id}/results") | ||
Single<List<DisciplineResults>> getNewsResults(@Path("id") int id); | ||
|
||
@POST("news") | ||
Single<News> addNews(@Body News news); | ||
|
||
@GET("users") | ||
Single<List<User>> getUsers(); | ||
} |
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
Oops, something went wrong.