Skip to content
1 change: 1 addition & 0 deletions PixtusApp/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ dependencies {
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.airbnb.android:lottie:2.5.3'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation "org.jetbrains.anko:anko:0.10.8"
}
2 changes: 0 additions & 2 deletions PixtusApp/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
android:screenOrientation="portrait"/>
<activity android:name=".ui.view.WorkoutListActivity"
android:screenOrientation="portrait"/>
<activity android:name=".ui.MainActivity"
android:screenOrientation="portrait"/>
<activity android:name=".ui.ViewActivity"
android:screenOrientation="portrait">
</activity>
Expand Down
Empty file modified PixtusApp/app/src/main/assets/ic_check.json
100644 → 100755
Empty file.
Empty file modified PixtusApp/app/src/main/assets/pixtus_eat.json
100644 → 100755
Empty file.
Empty file modified PixtusApp/app/src/main/assets/pixtus_story_01.json
100644 → 100755
Empty file.
Empty file modified PixtusApp/app/src/main/assets/pixtus_story_02.json
100644 → 100755
Empty file.
Empty file modified PixtusApp/app/src/main/assets/pixtus_story_03.json
100644 → 100755
Empty file.
Empty file modified PixtusApp/app/src/main/assets/pixtus_story_04.json
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion PixtusApp/app/src/main/assets/pixtus_walk_junior.json
100644 → 100755

Large diffs are not rendered by default.

Empty file modified PixtusApp/app/src/main/assets/pixtus_walk_master.json
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion PixtusApp/app/src/main/assets/pixtus_walk_senior.json
100644 → 100755

Large diffs are not rendered by default.

Empty file modified PixtusApp/app/src/main/assets/pixtus_workout_bicycle.json
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions PixtusApp/app/src/main/assets/pixtus_workout_soccer.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion PixtusApp/app/src/main/assets/pixtus_workout_swim.json
100644 → 100755

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.content.Intent
import android.support.v7.view.menu.MenuAdapter
import android.support.v7.widget.RecyclerView
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand All @@ -30,7 +31,7 @@ class RecyclerViewAdapter(val list: List<Exercise>) : RecyclerView.Adapter<Recyc
}
// view.findViewById<ImageView>(R.id.img_workoutlist).setImageResource(WorkOut.image)
view.findViewById<TextView>(R.id.tv_workout_name).text = Exercise.name
view.findViewById<TextView>(R.id.tv_workout_kcal).text = (Exercise.kcal * 60).toString() + "kcal"
view.findViewById<TextView>(R.id.tv_workout_kcal).text = (Exercise.measure * 60).toString() + "kcal"
}
}

Expand All @@ -47,6 +48,7 @@ class RecyclerViewAdapter(val list: List<Exercise>) : RecyclerView.Adapter<Recyc
holder.view.setOnClickListener {
val nextIntent = Intent(holder.view.context, WorkoutDetailActivity::class.java)
nextIntent.putExtra("workout_name", list.get(position).name)
nextIntent.putExtra("workout_id", list.get(position).exerciseId)
holder.view.context.startActivity(nextIntent)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.mash.up.pixtus_app.core

import com.mash.up.pixtus_app.ui.create.data.CreateAcoountRequest
import com.mash.up.pixtus_app.ui.login.PostLoginRequest
import com.mash.up.pixtus_app.ui.login.data.PostLoginResponse
import io.reactivex.Completable
import io.reactivex.Observable
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.Header
import retrofit2.http.POST


/**
* Created by TakHyeongMin on 2019-08-23.
*/

interface CreateAcountApi{

@POST("/user/sign-up") // 리턴타입
fun postCreateAccount(
@Header("Content-Type") contentType: String,
@Body body: CreateAcoountRequest
) : Completable

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.mash.up.pixtus_app.core

import com.mash.up.pixtus_app.ui.history.data.HistoryResponse
import io.reactivex.Single
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Query


/**
* Created by TakHyeongMin on 2019-08-23.
*/
interface HistoryApi {
@GET("/history")
fun getHistory(
@Header("Authorization") authorization: String,
@Query("prevWeek") prevWeek: Int?
): Single<HistoryResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ object NetworkCore {
init {
var okHttpClient = OkHttpClient()
.newBuilder()
.addInterceptor(AuthInterceptor())
.addInterceptor(HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BODY })
.build()

Expand All @@ -32,9 +31,9 @@ object NetworkCore {
inline fun <reified T> getNetworkCore() = api.create(T::class.java)
}

class AuthInterceptor : Interceptor{
override fun intercept(chain: Interceptor.Chain): Response {
var request = chain.request().newBuilder().addHeader("Authorization", "1").build()
return chain.proceed(request)
}
}
//class AuthInterceptor : Interceptor{
// override fun intercept(chain: Interceptor.Chain): Response {
// var request = chain.request().newBuilder().addHeader("Authorization", "1").build()
// return chain.proceed(request)
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ package com.mash.up.pixtus_app.core
import com.mash.up.pixtus_app.data.Exercise
import com.mash.up.pixtus_app.data.StepData
import com.mash.up.pixtus_app.Meal
import com.mash.up.pixtus_app.data.ResponseExercise
import com.mash.up.pixtus_app.ui.login.PostLoginRequest
import com.mash.up.pixtus_app.ui.login.data.PostLoginResponse
import io.reactivex.Completable
import io.reactivex.Observable
import io.reactivex.Single
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
Expand All @@ -31,6 +36,15 @@ interface PixtusApi {
@Header("Authorization") authorization: String,
@Body body: StepData
) : Completable


@POST("/workout")
fun sendExercise(
@Header("Authorization") authorization: String,
@Body body: StepData
) : Single<ResponseExercise>


/*
* {
* "amount": 0,
Expand All @@ -49,4 +63,10 @@ interface PixtusApi {
fun getMain(
@Header("Authorization") authorization: String
) : Single<MainResponse>

@POST("/user/sign-in") // 리턴타입
fun postLogin(
@Header("Content-Type") contentType: String,
@Body body: PostLoginRequest
) : Observable<Response<PostLoginResponse>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package com.mash.up.pixtus_app.data

data class Exercise(
val exerciseId: Int,
val kcal: Int,
val measure: Int,
val name: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.mash.up.pixtus_app.data

data class ResponseExercise(
val exp: Int,
val currExp: Int,
val nextExp: Int
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package com.mash.up.pixtus_app.ui

import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.util.Log
import android.view.View
import com.bumptech.glide.Glide
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.auth.api.signin.GoogleSignIn
Expand All @@ -13,13 +11,22 @@ import com.google.android.gms.common.api.ApiException
import com.google.android.gms.tasks.Task
import com.mash.up.pixtus_app.R
import com.mash.up.pixtus_app.base.BaseActivity
import com.mash.up.pixtus_app.core.NetworkCore
import com.mash.up.pixtus_app.core.PixtusApi
import com.mash.up.pixtus_app.ui.create.CreateStep1Activity
import com.mash.up.pixtus_app.ui.login.PostLoginRequest
import com.mash.up.pixtus_app.ui.login.data.PostLoginResponse
import com.mash.up.pixtus_app.utils.SharedPreferenceController
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.activity_login.*
import org.jetbrains.anko.startActivity
import org.json.JSONObject


class LoginActivity : BaseActivity() {
private var RC_SIGN_IN= 1111
lateinit var gso : GoogleSignInOptions
class LoginActivity : BaseActivity() {
private var RC_SIGN_IN = 1111
lateinit var gso: GoogleSignInOptions
val mGoogleSignInClient by lazy {
GoogleSignIn.getClient(this, gso)
}
Expand All @@ -31,7 +38,7 @@ class LoginActivity : BaseActivity() {
.requestEmail()
.build()

sign_in_button.setOnClickListener{
sign_in_button.setOnClickListener {
signIn()
}

Expand All @@ -45,7 +52,7 @@ class LoginActivity : BaseActivity() {
updateUI(account)
}

private fun signIn(){
private fun signIn() {
val signIntent = mGoogleSignInClient.signInIntent
startActivityForResult(signIntent, RC_SIGN_IN)
}
Expand All @@ -54,9 +61,9 @@ class LoginActivity : BaseActivity() {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == RC_SIGN_IN) {
//val intent = Intent(this, CreateStep1Activity::class.java)
val intent = Intent(this, StoryActivity::class.java)
startActivity(intent)
finish()
// val intent = Intent(this, StoryActivity::class.java)
// startActivity(intent)
// finish()
var task: Task<GoogleSignInAccount> = GoogleSignIn.getSignedInAccountFromIntent(data)
handleSignInResult(task)
}
Expand All @@ -65,14 +72,56 @@ class LoginActivity : BaseActivity() {
private fun handleSignInResult(completedTask: Task<GoogleSignInAccount>) {
try {
val account = completedTask.getResult(ApiException::class.java)
Log.e("이것이여~", account!!.account.toString() + account.displayName + account.email + account.id + " ")
updateUI(account)
} catch (e: ApiException) {
updateUI(null)
Log.e("이것이여~", Log.getStackTraceString(e))
}

}

fun updateUI(acct : GoogleSignInAccount?){
fun updateUI(acct: GoogleSignInAccount?) {
if (acct != null) {
postLogin(acct.id, acct.email, acct.displayName.toString())
Log.e("요놈요놈요놈", acct.id.toString())
}
}

private fun postLogin(uid: String?, email: String?, name: String) {

// val paramObject = JSONObject()
// println("uid : " + uid.toString())
// println("email : " + email.toString())
// paramObject.put("uid", uid)
// paramObject.put("email", email)

NetworkCore.getNetworkCore<PixtusApi>()
.postLogin(
"application/json",
PostLoginRequest(email, uid)
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
// 등록된 ID 존재 X, 회원가입
if (it.code() == 204) {
startActivity<CreateStep1Activity>("uid" to uid, "email" to email, "name" to name)
finish()
}// 등록된 ID 존재
else if (it.code() == 200) {
// 헤더 받아서 SharedPreference에 저장
Log.e("여재가", it.headers().get("Authorization"))
SharedPreferenceController.setAuthorization(this@LoginActivity, it.headers().get("Authorization"))
SharedPreferenceController.setUid(this@LoginActivity, uid)
startActivity<ViewActivity>()
finish()
} else
Log.e("Login Act err", "error code : " + it.code().toString())

// saveUserInfoToDevice(it.body()!!)
}, {
Log.e("LoginAct Error", Log.getStackTraceString(it))
})
}
}
Loading