soonmyeong2

Create topic subscription template

......@@ -13,6 +13,7 @@ import com.google.android.gms.tasks.OnCompleteListener
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.iid.FirebaseInstanceId
import com.google.firebase.messaging.FirebaseMessaging
import com.marcinmoskala.math.combinations
import kotlinx.android.synthetic.main.activity_input_profil_second_one.*
......@@ -67,7 +68,8 @@ class InputProfilSecondOneActivity : AppCompatActivity() {
skipButton.setOnClickListener {
sendToken()
val user=firebaseAuth?.currentUser
val user=firebaseAuth?.currentUser!!.uid
Log.d("test:", user.toString())
val cat_1=listOf("c1_1","c1_2","c1_3")
val cat_2=listOf("c2_1","c2_2","c2_3","c2_4","c2_5","c2_6","c2_7")
val cat_3=listOf("c3_1","c3_2","c3_3")
......@@ -85,25 +87,25 @@ class InputProfilSecondOneActivity : AppCompatActivity() {
val cat_15=listOf("c15_1","c15_2","c15_3")
val cat_16=listOf("c16_1","c16_2","c16_3","c16_4","c16_5","c16_6","c16_7")
val policy_string_list= listOf("c1_1c2_1c3_1c4_1c5_1c6_1c7_1c8_1c9_1c10_1c11_1c12_1c13_1c14_1c15_1c16_1")
var policy_string=""
var user_cat_1= mutableListOf<String>()
var user_cat_2= mutableListOf<String>()
var user_cat_3= mutableListOf<String>()
var user_cat_4= mutableListOf<String>()
var user_cat_5= mutableListOf<String>()
var user_cat_6= mutableListOf<String>()
var user_cat_7= mutableListOf<String>()
var user_cat_8= mutableListOf<String>()
var user_cat_9= mutableListOf<String>()
var user_cat_10=mutableListOf<String>()
var user_cat_11=mutableListOf<String>()
var user_cat_12=mutableListOf<String>()
var user_cat_13=mutableListOf<String>()
var user_cat_14=mutableListOf<String>()
var user_cat_15=mutableListOf<String>()
var user_cat_16=mutableListOf<String>()
//val policy_string_list= listOf("c1_1c2_1c3_1c4_1c5_1c6_1c7_1c8_1c9_1c10_1c11_1c12_1c13_1c14_1c15_1c16_1")
//var policy_string=""
var user_cat_1 = mutableListOf("c1_1")
var user_cat_2 = mutableListOf("c2_1")
var user_cat_3 = mutableListOf("c3_1")
var user_cat_4 = mutableListOf("c4_1")
var user_cat_5 = mutableListOf("c5_1")
var user_cat_6 = mutableListOf("c6_1")
var user_cat_7 = mutableListOf("c7_1")
var user_cat_8 = mutableListOf("c8_1")
var user_cat_9 = mutableListOf("c9_1")
var user_cat_10 = mutableListOf("c10_1")
var user_cat_11 = mutableListOf("c11_1")
var user_cat_12 = mutableListOf("c12_1")
var user_cat_13 = mutableListOf("c13_1")
var user_cat_14 = mutableListOf("c14_1")
var user_cat_15 = mutableListOf("c15_1")
var user_cat_16 = mutableListOf("c16_1")
for(item in cat_1){if(prof.getInt(item,3)==1){user_cat_1.add(item)}}
for(item in cat_2){if(prof.getInt(item,3)==1){user_cat_2.add(item)}}
......@@ -122,10 +124,105 @@ class InputProfilSecondOneActivity : AppCompatActivity() {
for(item in cat_15){if(prof.getInt(item,3)==1){user_cat_15.add(item)}}
for(item in cat_16){if(prof.getInt(item,3)==1){user_cat_16.add(item)}}
var topic = ""
var user_topic = ""
Log.d("hell gate1 : ", user_cat_1.toString())
Log.d("hell gate2 : ", user_cat_2.toString())
Log.d("hell gate3 : ", user_cat_3.toString())
Log.d("hell gate4 : ", user_cat_4.toString())
Log.d("hell gate5 : ", user_cat_5.toString())
Log.d("hell gate6 : ", user_cat_6.toString())
Log.d("hell gate7 : ", user_cat_7.toString())
Log.d("hell gate8 : ", user_cat_8.toString())
Log.d("hell gate9 : ", user_cat_9.toString())
Log.d("hell gate10 : ", user_cat_10.toString())
Log.d("hell gate11 : ", user_cat_11.toString())
Log.d("hell gate12 : ", user_cat_12.toString())
Log.d("hell gate13 : ", user_cat_13.toString())
Log.d("hell gate14 : ", user_cat_14.toString())
Log.d("hell gate15 : ", user_cat_15.toString())
Log.d("hell gate16 : ", user_cat_16.toString())
for(c1 in user_cat_1) {
topic += c1
for (c2 in user_cat_2) {
topic += c2
for (c3 in user_cat_3) {
topic += c3
for (c4 in user_cat_4) {
topic += c4
for (c5 in user_cat_5) {
topic += c5
for (c6 in user_cat_6) {
topic += c6
for (c7 in user_cat_7) {
topic += c7
for (c8 in user_cat_8) {
topic += c8
for (c9 in user_cat_9) {
topic += c9
for (c10 in user_cat_10) {
topic += c10
for (c11 in user_cat_11) {
topic += c11
for (c12 in user_cat_12) {
topic += c12
for (c13 in user_cat_13) {
topic += c13
for (c14 in user_cat_14) {
topic += c14
for (c15 in user_cat_15) {
topic += c15
for (c16 in user_cat_16) {
topic += c16
user_topic += (topic + "/")
// debug
// Log.d("topic : ", topic)
/* topic 구독 코드
FirebaseMessaging.getInstance().subscribeToTopic(topic).addOnCompleteListener { task ->
if (!task.isSuccessful) { } // 성공
}
*/
topic = topic.substring(0, topic.length - c16.length)
}
topic = topic.substring(0, topic.length - c15.length)
}
topic = topic.substring(0, topic.length - c14.length)
}
topic = topic.substring(0, topic.length - c13.length)
}
topic = topic.substring(0, topic.length - c12.length)
}
topic = topic.substring(0, topic.length - c11.length)
}
topic = topic.substring(0, topic.length - c10.length)
}
topic = topic.substring(0, topic.length - c9.length)
}
topic = topic.substring(0, topic.length - c8.length)
}
topic = topic.substring(0, topic.length - c7.length)
}
topic = topic.substring(0, topic.length - c6.length)
}
topic = topic.substring(0, topic.length - c5.length)
}
topic = topic.substring(0, topic.length - c4.length)
}
topic = topic.substring(0, topic.length - c3.length)
}
topic = topic.substring(0, topic.length - c2.length)
}
topic = topic.substring(0, topic.length-c1.length)
}
user_cat_1.toSet().combinations(2)
//Log.d("re:", user_topic)
writeNewUser(user, "null", user_topic) // db에 쓰기
writeNewUser(user!!.uid,"$tkn",policy_string)
var intent = Intent(this, SignInActivity::class.java)
startActivity(intent)
......@@ -151,9 +248,7 @@ user_cat_1.toSet().combinations(2)
/* 취소일 때 아무 액션이 없으므로 빈칸 */
}
*/
.show()
}
previousButton.setOnClickListener {
......