-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
154 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package com.footstep.dangbal.kotlin.src.main.map | ||
|
||
import android.util.Log | ||
import com.naver.maps.map.overlay.Marker | ||
import com.footstep.dangbal.kotlin.config.ApplicationClass | ||
import com.footstep.dangbal.kotlin.src.main.map.model.AllResponse | ||
import com.footstep.dangbal.kotlin.src.main.map.model.CityResponse | ||
import com.footstep.dangbal.kotlin.src.main.map.model.PopupResponse | ||
import com.footstep.dangbal.kotlin.src.main.map.model.SpecificFstResponse | ||
|
||
class ApiService(val mapFragmentInterface: MapFragment) { | ||
//val accessToken="Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImZvb3RzdGVwQG5hdmVyLmNvbSIsImlhdCI6MTY3NDkxNDc2NiwiZXhwIjoxNjc1MjE3MTY2fQ.KxwX1Q0o-omU1rRIiUJBd9gLPbTRVciP_9g_sklW1Bk" | ||
suspend fun tryGetMapFootStepList(){ | ||
var return_map=HashMap<Int,Marker>() | ||
// ApplicationClass.sSharedPreferences.edit().putString(X_ACCESS_TOKEN, accessToken).apply() | ||
|
||
val mapRetrofitInterface=ApplicationClass.sRetrofit.create(RetrofitInterface::class.java) | ||
|
||
try{ | ||
val response=mapRetrofitInterface.getMapFootStepList() | ||
Log.d("FootStepList", "tryGetMapFootStepList 되긴하니?") | ||
|
||
if(response!=null) | ||
mapFragmentInterface.onGetMapFootStepListSuccess(response as AllResponse) | ||
else | ||
Log.d("FootStepList", "맵 서비스 List에서의 결과 : ${response.toString()}") | ||
} | ||
catch (e: Exception) { | ||
Log.d("FootStepList", "onGetMapFootStepListFailure "+e.message.toString()) | ||
|
||
mapFragmentInterface.onGetMapFootStepListFailure(e.message ?: "통신 오류") | ||
} | ||
} | ||
|
||
suspend fun tryGetMapFootStepPopup(place_id:Int){ | ||
// Log.d("FootStepList", "tryGetMapFootStepPopup 진입") | ||
|
||
// ApplicationClass.sSharedPreferences.edit().putString(X_ACCESS_TOKEN, accessToken).apply() | ||
|
||
val mapRetrofitInterface=ApplicationClass.sRetrofit.create(RetrofitInterface::class.java) | ||
Log.d("FootStepList", "tryGetMapFootStepPopup 안쪽직전진입") | ||
|
||
try{ | ||
val response=mapRetrofitInterface.getMapFootStepPopup(place_id) | ||
Log.d("FootStepList", "tryGetMapFootStepPopup 되긴하니?") | ||
|
||
if(response!=null) { | ||
mapFragmentInterface.onGetMapFootStepPopupSuccess( | ||
response as PopupResponse, | ||
place_id | ||
) | ||
} | ||
else | ||
Log.d("FootStepList", "맵 서비스 Popup에서의 결과 : ${response.toString()}") | ||
} | ||
catch (e: Exception) { | ||
Log.d("FootStepList", "onGetMapFootStepPopupFailure api"+e.message.toString()) | ||
|
||
mapFragmentInterface.onGetMapFootStepPopupFailure(e.message ?: "통신 오류") | ||
} | ||
} | ||
|
||
suspend fun tryGetMapFootStepSpecific(start_date :String,ene_date:String){ | ||
val mapRetrofitInterface=ApplicationClass.sRetrofit.create(RetrofitInterface::class.java) | ||
Log.d("FootStepList2", "tryGetMapFootStepSpecific 안쪽직전진입") | ||
|
||
try{ | ||
val response=mapRetrofitInterface.getMapFootStepSpecific(start_date,ene_date) | ||
Log.d("FootStepList", "tryGetMapFootStepPopup 되긴하니?") | ||
|
||
if(response!=null) { | ||
mapFragmentInterface.onGetMapFootStepSpecificSuccess(response as SpecificFstResponse) | ||
} | ||
else | ||
Log.d("FootStepList", "맵 서비스 Specific에서의 결과 : ${response.toString()}") | ||
} | ||
catch (e: Exception) { | ||
Log.d("FootStepList", "onGetMapFootStepSpecificFailure"+e.message.toString()) | ||
|
||
mapFragmentInterface.onGetMapFootStepSpecificFailure(e.message ?: "통신 오류") | ||
} | ||
} | ||
|
||
suspend fun tryGetMapFootStepCity(city :String){ | ||
// ApplicationClass.sSharedPreferences.edit().putString(X_ACCESS_TOKEN, accessToken).apply() | ||
|
||
val mapRetrofitInterface=ApplicationClass.sRetrofit.create(RetrofitInterface::class.java) | ||
|
||
try{ | ||
val response=mapRetrofitInterface.getMapFootStepCity(city) | ||
Log.d("FootStepList", "tryGetMapFootStepCity 되긴하니?") | ||
|
||
if(response!=null) | ||
mapFragmentInterface.onGetMapFootStepCitySuccess(response as CityResponse) | ||
else | ||
Log.d("FootStepList", "맵 서비스 City에서의 결과 : ${response.toString()}") | ||
} | ||
catch (e: Exception) { | ||
Log.d("FootStepList", "tryGetMapFootStepCity onGetMapFootStepListFailure "+e.message.toString()) | ||
|
||
mapFragmentInterface.onGetMapFootStepCityFailure(e.message ?: "통신 오류") | ||
} | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
app/src/main/java/com/nbit/Idear/home/RetrofitInterface.kt
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,35 @@ | ||
package com.footstep.dangbal.kotlin.src.main.map | ||
|
||
import com.footstep.dangbal.kotlin.src.main.map.model.* | ||
import retrofit2.Retrofit | ||
import retrofit2.converter.gson.GsonConverterFactory | ||
import retrofit2.http.* | ||
|
||
interface RetrofitInterface { | ||
|
||
@GET("/footstep/all") | ||
suspend fun getMapFootStepList() : AllResponse | ||
|
||
@GET("/footstep/{place-id}") | ||
suspend fun getMapFootStepPopup(@Path("place-id") place_id : Int) : PopupResponse | ||
|
||
@GET("/footstep/specific/{start-date}/{end-date}") | ||
suspend fun getMapFootStepSpecific(@Path("start-date") start_date : String, @Path("end-date") end_date:String) : SpecificFstResponse | ||
|
||
@GET("/footstep/city/{city-name}") | ||
suspend fun getMapFootStepCity(@Path("city-name")city: String) : CityResponse | ||
|
||
@GET("users/{user}") | ||
fun getUser(@Path("user") username: String): Call<User> | ||
|
||
companion object { | ||
fun create(): ApiService { | ||
val retrofit = Retrofit.Builder() | ||
.baseUrl("https://api.example.com/") | ||
.addConverterFactory(GsonConverterFactory.create()) | ||
.build() | ||
|
||
return retrofit.create(ApiService::class.java) | ||
} | ||
} | ||
} |