Skip to content

Commit

Permalink
Merge pull request #16 from seoulsanta/eumiing
Browse files Browse the repository at this point in the history
Eumiing
  • Loading branch information
Eumiing authored Sep 29, 2019
2 parents bf39975 + 19a1798 commit 007cde2
Show file tree
Hide file tree
Showing 29 changed files with 286 additions and 69 deletions.
2 changes: 1 addition & 1 deletion SeoulSantaAndroid/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions SeoulSantaAndroid/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ dependencies {
implementation 'com.ryanjeffreybrooks:indefinitepagerindicator:1.0.10'
implementation 'com.tbuonomo.andrui:viewpagerdotsindicator:4.1.2'

//permission
implementation "gun0912.ted:tedpermission:2.1.0"

implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation files('libs/libDaumMapAndroid.jar')
Expand Down
4 changes: 3 additions & 1 deletion SeoulSantaAndroid/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

Expand All @@ -25,7 +27,7 @@
</intent-filter>
</activity>

<activity android:name=".ui.MyActivity">
<activity android:name=".ui.my.MyActivity">

</activity>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.yamgang.seoulsantaandroid.model.get

data class GetMypageResponse (
val message: String,
val data: MyData
)

data class MyData (
val name: String,
val img: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.yamgang.seoulsantaandroid.model.put

data class PutMypageEditResponse (
val message: String
)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ class BadgeCurrentRecyclerViewAdapter(val ctx: Context, var dataList: ArrayList<
.load(R.drawable.badge_get)
.into(holder.img)
//뱃지 클릭할 시,
val date_split = dataList[position].date
holder.img.setOnClickListener {
val dialog = BadgeCurrentDialogFragment()
dialog.show((ctx as MainActivity).supportFragmentManager,dialog.tag)
BadgeCurrentFragment.instance.course_name = dataList[position].course_name
BadgeCurrentFragment.instance.date = dataList[position].date
BadgeCurrentFragment.instance.date = date_split.substring(0,4)+""+date_split.substring(5,7)+""+date_split.substring(8,10)+""
Log.e("BadgeCurrentRV", "Badge")
}
} else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class BadgeFinishRecyclerViewAdapter(val ctx: Context, var dataList: ArrayList<B
override fun onBindViewHolder(holder: Holder, position: Int) {
holder.name.text = dataList[position].course_name
//나중에 나누기
holder.date.text = dataList[position].date
val date_split = dataList[position].date
holder.date.text=date_split.substring(0,4)+"."+date_split.substring(5,7)+"."+date_split.substring(8,10)+" "+date_split.substring(11,13)+":"+date_split.substring(14,16)
holder.view.setOnClickListener {
//완주한 fragment 띄우기
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.yamgang.seoulsantaandroid.R
import com.yamgang.seoulsantaandroid.model.get.GetHomeResponse
import com.yamgang.seoulsantaandroid.model.get.HomeData
import com.yamgang.seoulsantaandroid.model.get.HomeThemeData
import com.yamgang.seoulsantaandroid.ui.MyActivity
import com.yamgang.seoulsantaandroid.ui.my.MyActivity
import com.yamgang.seoulsantaandroid.util.ApplicationController
import kotlinx.android.synthetic.main.fragment_home.*
import retrofit2.Call
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
package com.yamgang.seoulsantaandroid.ui.my

import android.content.Intent
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.net.Uri
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Toast
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.yamgang.seoulsantaandroid.R
import com.yamgang.seoulsantaandroid.model.put.PutMypageEditResponse
import com.yamgang.seoulsantaandroid.model.get.GetMypageResponse
import com.yamgang.seoulsantaandroid.ui.MainActivity
import com.yamgang.seoulsantaandroid.ui.login.LoginActivity
import com.yamgang.seoulsantaandroid.util.ApplicationController
import com.yamgang.seoulsantaandroid.util.User
import kotlinx.android.synthetic.main.activity_my.*
import okhttp3.MediaType
import okhttp3.MultipartBody
import okhttp3.RequestBody
import org.jetbrains.anko.startActivity
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.InputStream
import java.lang.Exception

class MyActivity : AppCompatActivity() {

private val PICK_IMAGE_REQUEST: Int = 1
val networkService = ApplicationController.networkService
companion object{
var instance: MyActivity = MyActivity()
}
lateinit var img: String
var input_profile_img: MultipartBody.Part? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_my)
getMypageResponse()
setOnClickListener()
}

private fun setOnClickListener() {
btn_act_my_profile_modify.setOnClickListener {
btn_act_my_edit_profile.visibility = View.VISIBLE
tv_act_my_name.visibility = View.GONE
et_act_my_name_edit.visibility = View.VISIBLE
btn_act_my_profile_modify_complete.visibility = View.VISIBLE
btn_act_my_profile_modify.visibility = View.GONE
}
btn_act_my_edit_profile.setOnClickListener{
openGallery()
}

btn_act_my_profile_modify_complete.setOnClickListener {
val input_profile_name = RequestBody.create(MediaType.parse("text/plain"), et_act_my_name_edit.text.toString())
tv_act_my_name.text = et_act_my_name_edit.text.toString()
putMypageEditResponse(input_profile_name, input_profile_img)
btn_act_my_edit_profile.visibility = View.GONE
tv_act_my_name.visibility = View.VISIBLE
et_act_my_name_edit.visibility = View.GONE
btn_act_my_profile_modify_complete.visibility = View.GONE
btn_act_my_profile_modify.visibility = View.VISIBLE
}
btn_act_my_logout.setOnClickListener {
User.authorization = null
User.refreshtoken = null
startActivity<LoginActivity>()
finish()
val mainActivity = MainActivity()
mainActivity.finish()
}
btn_act_my_setting.setOnClickListener {
//설정
}
btn_act_my_notice.setOnClickListener {
//공지사항
}
btn_act_my_help.setOnClickListener {
//도움말
}
}

fun openGallery() {
var intent = Intent(Intent.ACTION_GET_CONTENT)
//intent.setType("image/*")
intent.type = android.provider.MediaStore.Images.Media.CONTENT_TYPE
intent.data = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI
startActivityForResult(intent, PICK_IMAGE_REQUEST)
}

private fun getMypageResponse(){
val getMypageResponse = networkService.getMypageResponse("application/json", User.authorization)
getMypageResponse.enqueue(object :Callback<GetMypageResponse> {
override fun onFailure(call: Call<GetMypageResponse>, t: Throwable) {
Log.e("MyActivity-checkfail", t.toString())
}

override fun onResponse(call: Call<GetMypageResponse>, response: Response<GetMypageResponse>) {
if(response.isSuccessful) {
try{
var option: RequestOptions = RequestOptions().circleCrop()
Glide.with(this@MyActivity)
.load(response.body()!!.data.img)
.apply(option)
.into(iv_act_my_profile)
tv_act_my_name.text = response.body()!!.data.name
tv_act_my_version.text = "최신 "+"1.0.0"+" 사용중"

} catch (e:Exception) {}
}
}
})
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
try {
if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && null != data) {
//data에서 절대경로로 이미지를 가져옴
var selectedPictureUri: Uri = data.data!!
val options = BitmapFactory.Options()
val inputStream: InputStream? = contentResolver!!.openInputStream(selectedPictureUri)
val bitmap = BitmapFactory.decodeStream(inputStream, null, options)
val byteArrayOutputStream = ByteArrayOutputStream()
bitmap!!.compress(Bitmap.CompressFormat.JPEG, 20, byteArrayOutputStream)
val photoBody = RequestBody.create(MediaType.parse("image/jpg"), byteArrayOutputStream.toByteArray())

input_profile_img = MultipartBody.Part.createFormData(
"img",
File(selectedPictureUri.toString()).name + ".jpg",
photoBody
)

Glide.with(this@MyActivity)
.load(selectedPictureUri)
.circleCrop()
.into(iv_act_my_profile)

} else {
Toast.makeText(this, "취소 되었습니다.", Toast.LENGTH_LONG).show()
}
} catch (e: Exception) {
Toast.makeText(this, "사진 로딩에 오류가 있습니다.", Toast.LENGTH_LONG).show()
e.printStackTrace()
}

}

private fun putMypageEditResponse(name: RequestBody, img: MultipartBody.Part?) {
val putMypageEditResponse = networkService.putMypageEditResponse(User.authorization, name, img)
Log.e("MyActivity-editfail", "in")
putMypageEditResponse.enqueue(object : Callback<PutMypageEditResponse> {
override fun onFailure(call: Call<PutMypageEditResponse>, t: Throwable) {
Log.e("MyActivity-editfail", t.toString())
}

override fun onResponse(call: Call<PutMypageEditResponse>, response: Response<PutMypageEditResponse>) {
if(response.isSuccessful) {
try{
Log.e("MyActivity-editResponse", "success")
}catch (e: Exception) {
Log.e("MyActivity-editResponse", "fail")
}
}
}
})
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.yamgang.seoulsantaandroid.util

import com.yamgang.seoulsantaandroid.model.BadgeRegister
import com.yamgang.seoulsantaandroid.model.put.PutMypageEditResponse
import com.yamgang.seoulsantaandroid.model.get.*
import com.yamgang.seoulsantaandroid.model.get.GetBadgeResponse
import com.yamgang.seoulsantaandroid.model.get.GetHomeResponse
import com.yamgang.seoulsantaandroid.model.get.GetCourse
import com.yamgang.seoulsantaandroid.model.get.GetCourseDetail
import com.yamgang.seoulsantaandroid.model.get.GetMountain
import com.yamgang.seoulsantaandroid.model.post.PostBadgeRegister
import com.yamgang.seoulsantaandroid.model.post.PostKakaoLoginResponse
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.Call
import retrofit2.http.*

Expand Down Expand Up @@ -70,4 +68,20 @@ interface NetworkService {
fun getMountainRecommend(
@Header("Content-Type") contentType: String = "application/json"
):Call<GetMountainRecommend>

//마이페이지 조회
@GET("/user/mypage")
fun getMypageResponse(
@Header("Content-Type") content_type: String,
@Header("Authorization") token: String?
):Call<GetMypageResponse>

//마이페이지 수정
@Multipart
@PUT("/user/mypage")
fun putMypageEditResponse(
@Header("Authorization") token: String?,
@Part("name") name: RequestBody,
@Part img: MultipartBody.Part?
):Call<PutMypageEditResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.kakao.usermgmt.response.model.UserProfile
import com.kakao.util.exception.KakaoException
import com.yamgang.seoulsantaandroid.model.post.PostKakaoLoginResponse
import com.yamgang.seoulsantaandroid.ui.MainActivity
import com.yamgang.seoulsantaandroid.ui.login.LoginActivity
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
Expand Down Expand Up @@ -75,6 +76,8 @@ class SessionCallback (mContext: Context) : ISessionCallback {

val intent = Intent(mContext,MainActivity::class.java)
mContext.startActivity(intent)
val loginAct = LoginActivity()
loginAct.finish()
} else {
Log.e("*****KakaoLogin Response","실패")
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 007cde2

Please sign in to comment.