-
Notifications
You must be signed in to change notification settings - Fork 1
/
CreateMeetingFragment.kt
123 lines (109 loc) · 5.56 KB
/
CreateMeetingFragment.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package live.videosdk.rtc.android.kotlin.Common.Fragment
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.*
import android.widget.AdapterView.OnItemClickListener
import androidx.core.content.res.ResourcesCompat
import androidx.fragment.app.Fragment
import com.google.android.material.snackbar.Snackbar
import live.videosdk.rtc.android.kotlin.Common.Activity.CreateOrJoinActivity
import live.videosdk.rtc.android.kotlin.Common.Listener.ResponseListener
import live.videosdk.rtc.android.kotlin.Common.Utils.HelperClass
import live.videosdk.rtc.android.kotlin.Common.Utils.NetworkUtils
import live.videosdk.rtc.android.kotlin.GroupCall.Activity.GroupCallActivity
import live.videosdk.rtc.android.kotlin.OneToOneCall.OneToOneCallActivity
import live.videosdk.rtc.android.kotlin.R
class CreateMeetingFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
val view = inflater.inflate(R.layout.fragment_create_meeting, container, false)
val etName = view.findViewById<EditText>(R.id.etName)
val btnJoin = view.findViewById<Button>(R.id.btnJoin)
val meetingType = requireContext().resources.getStringArray(R.array.meeting_options)
val selectedMeetingType = arrayOfNulls<String>(1)
val arrayAdapter: ArrayAdapter<*> =
ArrayAdapter<Any?>(requireContext(), R.layout.dropdown_item, meetingType)
val autocompleteTV =
view.findViewById<View>(R.id.autoCompleteTextView) as AutoCompleteTextView
autocompleteTV.setAdapter(arrayAdapter)
autocompleteTV.setDropDownBackgroundDrawable(
ResourcesCompat.getDrawable(
requireContext().resources,
R.drawable.et_style,
null
)
)
autocompleteTV.onItemClickListener =
OnItemClickListener { _, _, i, _ ->
selectedMeetingType[0] = meetingType[i]
}
btnJoin.setOnClickListener { v: View? ->
if ("" == etName.text.toString()) {
Toast.makeText(context, "Please Enter Name", Toast.LENGTH_SHORT).show()
} else {
val networkUtils = NetworkUtils(context)
if (networkUtils.isNetworkAvailable()) {
networkUtils.getToken(object : ResponseListener<String> {
override fun onResponse(token: String?) {
networkUtils.createMeeting(token, object : ResponseListener<String>{
override fun onResponse(meetingId: String?) {
var intent: Intent? = null
if (!TextUtils.isEmpty(selectedMeetingType[0])) {
intent =
if (selectedMeetingType[0] == "One to One Meeting") {
Intent(
activity as CreateOrJoinActivity?,
OneToOneCallActivity::class.java
)
} else {
Intent(
activity as CreateOrJoinActivity?,
GroupCallActivity::class.java
)
}
intent.putExtra("token", token)
intent.putExtra("meetingId", meetingId)
intent.putExtra(
"webcamEnabled",
(activity as CreateOrJoinActivity?)!!.isWebcamEnabled
)
intent.putExtra(
"micEnabled",
(activity as CreateOrJoinActivity?)!!.isMicEnabled
)
intent.putExtra(
"participantName",
etName.text.toString().trim { it <= ' ' })
startActivity(intent)
(activity as CreateOrJoinActivity?)!!.finish()
} else {
Toast.makeText(
context,
"Please Choose Meeting Type", Toast.LENGTH_SHORT
).show()
}
}
})
}
})
} else {
val snackbar = Snackbar.make(
view.findViewById(R.id.createMeetingLayout),
"No Internet Connection",
Snackbar.LENGTH_LONG
)
HelperClass.setSnackBarStyle(snackbar.view, 0)
snackbar.show()
}
}
}
return view
}
}