InputProfilSecondOneActivity.kt 4.26 KB
package com.example.vip

import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import android.widget.RatingBar
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import kotlinx.android.synthetic.main.activity_input_profil_second_one.*
import kotlinx.android.synthetic.main.family_member_dialog.*
import kotlinx.android.synthetic.main.family_member_dialog.view.*

class InputProfilSecondOneActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_input_profil_second_one)

        // 1. 툴바 사용 설정
        setSupportActionBar(toolbar)

        skipButton.setOnClickListener {
            var intent = Intent(this, InputProfilSecondOneActivity::class.java)
            startActivity(intent)
        }

        questionButton.setOnClickListener {
            val builder = AlertDialog.Builder(this)
            val dialogView = layoutInflater.inflate(R.layout.family_member_dialog, null)
            //val dialogText = dialogView.findViewById<EditText>(R.id.dialogEt)
            //val dialogRatingBar = dialogView.findViewById<RatingBar>(R.id.dialogRb)
            dialogView.findViewById<TextView>(R.id.dialogTitle).text="가족구성원이란?"
            dialogView.findViewById<TextView>(R.id.dialogContent).text="주민등록상 같은 거주지에 사는 사람"

            builder.setView(dialogView)
                .setPositiveButton("확인") { dialogInterface, i ->
                    //mainTv.text = dialogText.text.toString()
                    //mainRb.rating = dialogRatingBar.rating
                    /* 확인일 때 main의 View의 값에 dialog View에 있는 값을 적용 */

                }
                   /*
                .setNegativeButton("취소") { dialogInterface, i ->
                    /* 취소일 때 아무 액션이 없으므로 빈칸 */
                }
                */

                .show()

        }

        previousButton.setOnClickListener {
            var intent = Intent(this, InputProfilFirstFiveActivity::class.java)
            startActivity(intent)
        }

        val prof: SharedPreferences =getSharedPreferences("profdata", Context.MODE_PRIVATE)
        val editor: SharedPreferences.Editor=prof.edit()


        nextButton.setOnClickListener {

            if(baewoojaButton.isChecked){editor.putInt("c10_2",1); editor.commit()}
            if(baewoojaboomoButton.isChecked){editor.putInt("c10_3",1); editor.commit()}
            if(baewoojajoboomoButton.isChecked){editor.putInt("c10_4",1); editor.commit()}
            if(brotherButton.isChecked){editor.putInt("c10_5",1); editor.commit()
            editor.putString("with_brothersister","yes")}
            if(baewoojabrotherButton.isChecked){editor.putInt("c10_6",1); editor.commit()}
            if(donggeoButton.isChecked){editor.putInt("c10_7",1); editor.commit()}
            if(fatherButton.isChecked){editor.putInt("c10_8",1); editor.commit()}
            if(motherButton.isChecked){editor.putInt("c10_9",1); editor.commit()}
            if(grandsonbaewoojaButton.isChecked){editor.putInt("c10_10",1); editor.commit()}
            if(grandfatherButton.isChecked){editor.putInt("c10_11",1); editor.commit()}
            if(grandmotherButton.isChecked){editor.putInt("c10_12",1); editor.commit()}
            if(grandsonButton.isChecked){editor.putInt("c10_13",1); editor.commit()}
            if(janyeoButton.isChecked){editor.putInt("c10_14",1); editor.commit()
            editor.putString("with_child","yes")}
            if(janyeobaewoojaButton.isChecked){editor.putInt("c10_15",1); editor.commit()}
            if(nothingButton.isChecked){editor.putInt("c10_18",1); editor.commit()}

            if(janyeoButton.isChecked
                //prof.getString("with_child","none")=="yes"
            ){
                var intent = Intent(this, InputProfilSecondTwoActivity::class.java)
                startActivity(intent)
            }else{
                var intent = Intent(this, InputProfilThirdOneActivity::class.java)
                startActivity(intent)
            }
        }
    }
}