diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml
new file mode 100644
index 0000000..f60ae34
--- /dev/null
+++ b/.idea/deploymentTargetDropDown.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..053b7aa
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index a700852..e27a301 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -90,7 +90,13 @@ dependencies {
//Свайп
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
+ implementation "androidx.work:work-runtime-ktx:2.8.1"
+// // Kotlin
+// implementation "androidx.navigation:navigation-fragment-ktx:2.5.2"
+// implementation "androidx.navigation:navigation-ui-ktx:2.5.2"
+
+
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 4acd25a..7c659b1 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,13 +1,19 @@
-
+ xmlns:tools="http://schemas.android.com/tools" >
+
+
+
+
+
+
+ android:usesCleartextTraffic="true"
+ tools:targetApi="31" >
+
+
+
+
+
+
+
+ android:windowSoftInputMode="adjustPan|stateAlwaysHidden" >
diff --git a/app/src/main/java/com/example/doctor/Adapter/VpAdapterPatientList.kt b/app/src/main/java/com/example/doctor/Adapter/VpAdapterPatientList.kt
new file mode 100644
index 0000000..d9c6f2f
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Adapter/VpAdapterPatientList.kt
@@ -0,0 +1,17 @@
+package com.example.doctor.Adapter
+
+import androidx.fragment.app.Fragment
+import androidx.fragment.app.FragmentActivity
+import androidx.viewpager2.adapter.FragmentStateAdapter
+
+class VpAdapterPatientList(fr_act:FragmentActivity, private val list:List):FragmentStateAdapter(fr_act) {//private val list:List - список с фрагментами сюда передастся, тоесть с двумя фрагментами
+ //Возврощаем для createFragment количество элементов(фрагментов) в листе(List)
+ override fun getItemCount(): Int {
+ return list.size//возврощаем количество фрагметов
+ }
+
+ //Позиция фрагмента или 1 или 2, то есть 0 или 1. И по позиции будут выводится фрагмент.
+ override fun createFragment(position: Int): Fragment {
+ return list[position]//Возврощаем фрагмент из листа по позиции
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/AddSportPatientModel.kt b/app/src/main/java/com/example/doctor/AddSportPatientModel.kt
new file mode 100644
index 0000000..065d225
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/AddSportPatientModel.kt
@@ -0,0 +1,19 @@
+package com.example.doctor
+
+data class AddSportPatientModel(
+ val id: Int,
+ val status: String,
+ val one: Int,
+ val two: Int,
+ val three: Int,
+ val four: Int,
+ val five: Int,
+ val six: Int,
+ val seven: Int,
+ val eight: Int,
+ val nine: Int,
+ val ten: Int,
+ val eleven: Int,
+ val twelve: Int,
+ )
+
diff --git a/app/src/main/java/com/example/doctor/Appeals/AppealsCreateMessageActivity.kt b/app/src/main/java/com/example/doctor/Appeals/AppealsCreateMessageActivity.kt
new file mode 100644
index 0000000..3323a12
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Appeals/AppealsCreateMessageActivity.kt
@@ -0,0 +1,17 @@
+package com.example.doctor.Appeals
+
+import androidx.appcompat.app.AppCompatActivity
+import android.os.Bundle
+import com.example.doctor.R
+import com.example.doctor.databinding.ActivityAppealsBinding
+
+class AppealsCreateMessageActivity : AppCompatActivity() {
+ private lateinit var binding: ActivityAppealsBinding
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ binding = ActivityAppealsBinding.inflate(layoutInflater)
+ setContentView(binding.root)
+ supportFragmentManager.beginTransaction().replace(R.id.CLAppealsActivity, CreateMessageFragment.newInstance()).commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Appeals/AppealsFragment.kt b/app/src/main/java/com/example/doctor/Appeals/AppealsFragment.kt
index a9ad849..104dc31 100644
--- a/app/src/main/java/com/example/doctor/Appeals/AppealsFragment.kt
+++ b/app/src/main/java/com/example/doctor/Appeals/AppealsFragment.kt
@@ -1,21 +1,58 @@
package com.example.doctor.Appeals
+import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.Toast
import androidx.fragment.app.FragmentActivity
+import androidx.fragment.app.activityViewModels
import com.example.doctor.Adapter.VpAdapter
import com.example.doctor.R
import com.example.doctor.Appeals.TabLayout.OldAppealsFragment
import com.example.doctor.Appeals.TabLayout.NewAppealsFragment
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
+import com.example.doctor.DataModel
+import com.example.doctor.DoctorViewModel
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
+import com.example.doctor.Pref.ClearPref
+import com.example.doctor.Pref.ConclusionPref
+import com.example.doctor.Pref.SavePref
+import com.example.doctor.Retrofit.DoctorApi
+import com.example.doctor.Toast.showCustomInfoToast
import com.example.doctor.databinding.FragmentAppealsBinding
import com.google.android.material.tabs.TabLayoutMediator
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import java.util.Timer
+import kotlin.concurrent.fixedRateTimer
class AppealsFragment : Fragment() {
- private lateinit var binding:FragmentAppealsBinding
+ private lateinit var binding: FragmentAppealsBinding
+ private lateinit var doctorApi: DoctorApi
+ private lateinit var timer: Timer
+
+
+ private val model: DoctorViewModel by activityViewModels()
+
+ val prefDoctorConclusion = ConclusionPref()
+ private val dataModel: DataModel by activityViewModels()//Для передачи данных
+ val prefDoctorClear = ClearPref()
+ val prefDoctorSave = SavePref()
+
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
private val tList = listOf(
"новые",
@@ -40,6 +77,138 @@ class AppealsFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)
init()
+ binding.btnAddMessage.setOnClickListener {
+ val intetn = Intent(requireContext(), AppealsCreateMessageActivity::class.java)
+ startActivity(intetn)
+// activity?.supportFragmentManager?.beginTransaction()
+// ?.replace(R.id.CLAppeals, CreateMessageFragment.newInstance())?.commit()
+// binding.ConstrainLayoutProductEdit.visibility = View.GONE
+// binding.CLAppeals.visibility = View.VISIBLE
+ }
+
+// dataModel.patientAppeal.observe(viewLifecycleOwner, Observer {
+// requireActivity().runOnUiThread {
+// val viewPatient = prefDoctorConclusion.conclusionViewPatient(requireContext())
+// val idPatient = prefDoctorConclusion.conclusionIdPatient(requireContext())
+// if (viewPatient == 1 && idPatient != 0) {
+//
+// prefDoctorClear.clearIdPatient(requireContext())
+// prefDoctorClear.clearViewPatient(requireContext())
+// GetPatientID(it)
+// }
+// }
+// })
+
+// dataModel.patientAppeal.observe(viewLifecycleOwner, Observer {
+// binding.btnExit.visibility = View.GONE
+// binding.CLMainPatientAppeals.visibility = View.GONE
+//
+// })
+
+// fixedRateTimer("timer", false, 0, 10000) {
+// activity?.runOnUiThread {
+//
+// }
+// }
+ }
+
+
+ private fun getOldAppeals() {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listAppeals = doctorApi.GetAppealsDoctorOld("Bearer $Tokens")
+ requireActivity().runOnUiThread {
+
+ //Фиксируем полученные данные
+ val List = listAppeals.body()
+ val Nice = listAppeals.isSuccessful
+ val Code = listAppeals.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ if (List?.appeals_old != null) {
+ model.appealsOldList.value = List.appeals_old
+ }
+ }
+ }
+
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ //Получение необработанных сообщений
+ private fun getNewAppeals() {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listAppeals = doctorApi.GetAppealsDoctorNew("Bearer $Tokens")
+ requireActivity().runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = listAppeals.body()
+ val Nice = listAppeals.isSuccessful
+ val Code = listAppeals.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ if(List.appeals_new != null){
+ model.appealsNewList.value = List.appeals_new
+ }
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ }
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
}
//Функция подключения переключения
@@ -54,12 +223,121 @@ class AppealsFragment : Fragment() {
}.attach()// attach() - чтобы все переключалось, а не вывадило постоянно один экран
//Изменения цвета в зависомости на каком из tabLayout вы находитесь
- binding.tabLayoutProduct.setTabTextColors(getResources().getColor(R.color.black),
- getResources().getColor(R.color.white));
+ binding.tabLayoutProduct.setTabTextColors(
+ getResources().getColor(R.color.black),
+ getResources().getColor(R.color.white)
+ );
+
+
}
+
+// //Получение необработанных сообщений
+// private fun addCheckAppeals(id: Int, id_patient: Int) {
+// if (enternetCheck.isOnline(requireContext())) {
+// initRetrofit()
+// val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+// CoroutineScope(Dispatchers.IO).launch {
+// val listAppeals = doctorApi.UpdateMessageDoctor("Bearer $Tokens", id, id_patient)
+// requireActivity().runOnUiThread {
+//
+// //Фиксируем полученные данные
+// val AppealsMes = listAppeals.body()
+//
+// //Если нету ошибок
+// if (AppealsMes != null) {
+// Toast(requireContext()).showCustomInfoToast(
+// AppealsMes.message,
+// requireActivity()
+// )
+// }
+//
+// }
+//
+// }
+// } else {
+// val intetn = Intent(requireContext(), EnternetActivity::class.java)
+// activity?.finish()
+// startActivity(intetn)
+// }
+//
+// }
+
+ //Инициализируем Retrofit
+ private fun initRetrofit() {
+ val interceptor = HttpLoggingInterceptor()
+ interceptor.level = HttpLoggingInterceptor.Level.BODY
+
+ val client = OkHttpClient
+ .Builder()
+ .addInterceptor(interceptor)
+ .build()
+
+ val retrofit = Retrofit.Builder()
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
+ .client(client)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+
+ doctorApi = retrofit.create(DoctorApi::class.java)
+
+ }
+
+// private fun GetPatientID(idPatient: Int) {
+// if (enternetCheck.isOnline(requireContext())) {
+// initRetrofit()
+// val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+// CoroutineScope(Dispatchers.IO).launch {
+// val listPatient = doctorApi.GetPatientID("Bearer $Tokens", idPatient)
+// requireActivity().runOnUiThread {
+//
+// //Фиксируем полученные данные
+// val patientId = listPatient.body()
+//
+// //Если нету ошибок
+// if (patientId != null) {
+// //Вывод фрагмента на активити при первоначальной загрузке
+//// activity?.supportFragmentManager?.beginTransaction()
+//// ?.replace(R.id.CLMainPatientAppeals, PatientFragment.newInstance())
+//// ?.commit()
+// model.patientCurrent.value = patientId
+//
+// }
+// }
+//
+// }
+// } else {
+// val intetn = Intent(requireContext(), EnternetActivity::class.java)
+// activity?.finish()
+// startActivity(intetn)
+// }
+//
+// }
+
companion object {
-
fun newInstance() = AppealsFragment()
}
+
+
+ override fun onStart() {
+ super.onStart()
+ checkForUpdates(true)
+ }
+
+ override fun onStop() {
+ super.onStop()
+ timer.cancel()
+ timer.purge()
+ }
+
+ private fun checkForUpdates(daemonIsTrue: Boolean) {
+
+ timer = fixedRateTimer("default", daemonIsTrue, 0, 10000) {
+ activity?.runOnUiThread {
+ getOldAppeals()
+ getNewAppeals()
+ }
+ }
+
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Appeals/AppealsNewAdapter.kt b/app/src/main/java/com/example/doctor/Appeals/AppealsNewAdapter.kt
index bc43850..59afe2e 100644
--- a/app/src/main/java/com/example/doctor/Appeals/AppealsNewAdapter.kt
+++ b/app/src/main/java/com/example/doctor/Appeals/AppealsNewAdapter.kt
@@ -1,26 +1,26 @@
package com.example.doctor.Appeals
import android.annotation.SuppressLint
-import android.os.Handler
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
+import com.example.doctor.Appeals.TabLayout.Model.AppealsNewModel
+import com.example.doctor.Appeals.TabLayout.Model.AppealsOldModel
import com.example.doctor.R
-import com.example.doctor.databinding.ItemAppealsBinding
import com.example.doctor.databinding.ItemAppealsNewBinding
-class AppealsNewAdapter(val listener_zakaz: Listener) :
+class AppealsNewAdapter(val listener_check_apeals: Listener, val listener_patient_apeals: Listener2) :
ListAdapter(
Comparator()
) {//Productitem - по этой форме будем заполнять.//ProductAdapter.holder - это создаваемый holder который хранит логику как нужно заполнять карточку
//В holder создаетс код с помошью которого мы будем заполнять и сохронять разметку
- class Holder(view: View, val listener_zakaz: Listener) :
+ class Holder(view: View, val listener_check_apeals: Listener, val listener_patient_apeals: Listener2) :
RecyclerView.ViewHolder(view) {//Класс который будет хранить сссылки на элементы, и отвечает за один элемент за 1 раз, то есть сначсало нулевой элемент заполнит, потом первый, потом второй и т.д.
//Для передачи данных
@@ -32,23 +32,26 @@ class AppealsNewAdapter(val listener_zakaz: Listener) :
//init - дает возможность внутри адаптера обращаться к элементам экрана
init {
- itemView.setOnClickListener {//Нажатие на ячейку//itemView - это весь элемент карточки из списка
- itemView.setEnabled(false)
- itemTemp?.let { it1 -> listener_zakaz.onClickAppeals(it1) }
-
+ binding.btnAdd.setOnClickListener {//Нажатие на ячейку//itemView - это весь элемент карточки из списка
+ //itemView.setEnabled(false)
+ itemTemp?.let { it1 -> listener_check_apeals.onClickAppeals(it1) }
+ }
+ binding.btnPatient.setOnClickListener {//Нажатие на ячейку//itemView - это весь элемент карточки из списка
+ //itemView.setEnabled(false)
+ itemTemp?.let { it2 -> listener_patient_apeals.onClickAppealsPatient(it2) }
}
}
@SuppressLint("SuspiciousIndentation")
fun bind(item: AppealsNewModel) = with(binding) {//Productitem - перпедаем данные
itemTemp = item
- txtNumber.text = item.id.toString()+"."
+ txtNumber.text = item.number.toString()+"."
txtAppeals.text = item.text
txtLoginPatient.text = item.login
if (item.expand) {
- txtAppeals.maxLines = 100
+ txtAppeals.maxLines = 30
} else {
txtAppeals.maxLines = 1
}
@@ -64,9 +67,7 @@ class AppealsNewAdapter(val listener_zakaz: Listener) :
}
}
- btnAdd.setOnClickListener{
- CardViewNew.visibility = View.GONE
- }
+
}
}
@@ -74,7 +75,7 @@ class AppealsNewAdapter(val listener_zakaz: Listener) :
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.item_appeals_new, parent, false)//Создаем(надуваем) list_item
- return Holder(view, listener_zakaz)//Через Holder возврощаем view
+ return Holder(view, listener_check_apeals,listener_patient_apeals)//Через Holder возврощаем view
}
override fun onBindViewHolder(holder: Holder, position: Int) {
@@ -99,12 +100,17 @@ class AppealsNewAdapter(val listener_zakaz: Listener) :
}
}
- //Интерфейс нажатия на кнопку удалить товар из корзины
+
interface Listener {
fun onClickAppeals(item: AppealsNewModel)
}
+ interface Listener2 {
+ fun onClickAppealsPatient(item: AppealsNewModel)
+ }
+
+
}
diff --git a/app/src/main/java/com/example/doctor/Appeals/AppealsNewModel.kt b/app/src/main/java/com/example/doctor/Appeals/AppealsNewModel.kt
deleted file mode 100644
index 136e6f0..0000000
--- a/app/src/main/java/com/example/doctor/Appeals/AppealsNewModel.kt
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.example.doctor.Appeals
-
-data class AppealsNewModel(
- val id: Int,
- val login: String,
- val text: String,
- val id_user:Int,
- var expand : Boolean = false
-)
-
diff --git a/app/src/main/java/com/example/doctor/Appeals/AppealsOldAdapter.kt b/app/src/main/java/com/example/doctor/Appeals/AppealsOldAdapter.kt
index f49a328..b666a0e 100644
--- a/app/src/main/java/com/example/doctor/Appeals/AppealsOldAdapter.kt
+++ b/app/src/main/java/com/example/doctor/Appeals/AppealsOldAdapter.kt
@@ -1,25 +1,26 @@
package com.example.doctor.Appeals
import android.annotation.SuppressLint
-import android.opengl.Visibility
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
+import com.example.doctor.Appeals.TabLayout.Model.AppealsOldModel
+import com.example.doctor.Appeals.TabLayout.OldAppealsFragment
import com.example.doctor.R
import com.example.doctor.databinding.ItemAppealsOldBinding
-class AppealsOldAdapter(val listener_zakaz: Listener) :
+class AppealsOldAdapter(val listener_appeal: Listener, val listener_patient_apeals: OldAppealsFragment) :
ListAdapter(
Comparator()
) {//Productitem - по этой форме будем заполнять.//ProductAdapter.holder - это создаваемый holder который хранит логику как нужно заполнять карточку
//В holder создаетс код с помошью которого мы будем заполнять и сохронять разметку
- class Holder(view: View, val listener_zakaz: Listener) :
+ class Holder(view: View, val listener_appeal: Listener, val listener_patient_apeals: OldAppealsFragment) :
RecyclerView.ViewHolder(view) {//Класс который будет хранить сссылки на элементы, и отвечает за один элемент за 1 раз, то есть сначсало нулевой элемент заполнит, потом первый, потом второй и т.д.
//Для передачи данных
@@ -32,15 +33,18 @@ class AppealsOldAdapter(val listener_zakaz: Listener) :
//init - дает возможность внутри адаптера обращаться к элементам экрана
init {
itemView.setOnClickListener {//Нажатие на ячейку//itemView - это весь элемент карточки из списка
- itemView.setEnabled(false)
- itemTemp?.let { it1 -> listener_zakaz.onClickAppeals(it1) }
+ itemTemp?.let { it1 -> listener_appeal.onClickAppeals(it1) }
+ }
+ binding.btnPatient.setOnClickListener {//Нажатие на ячейку//itemView - это весь элемент карточки из списка
+ //itemView.setEnabled(false)
+ itemTemp?.let { it2 -> listener_patient_apeals.onClickAppealsPatient(it2) }
}
}
@SuppressLint("SuspiciousIndentation")
fun bind(item: AppealsOldModel) = with(binding) {//Productitem - перпедаем данные
itemTemp = item
- txtNumber.text = item.id.toString()+"."
+ txtNumber.text = item.number.toString()+"."
txtAppeals.text = item.text
txtLoginPatient.text = item.login
@@ -71,7 +75,7 @@ class AppealsOldAdapter(val listener_zakaz: Listener) :
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.item_appeals_old, parent, false)//Создаем(надуваем) list_item
- return Holder(view, listener_zakaz)//Через Holder возврощаем view
+ return Holder(view, listener_appeal,listener_patient_apeals)//Через Holder возврощаем view
}
override fun onBindViewHolder(holder: Holder, position: Int) {
@@ -100,6 +104,9 @@ class AppealsOldAdapter(val listener_zakaz: Listener) :
interface Listener {
fun onClickAppeals(item: AppealsOldModel)
}
+ interface Listener2 {
+ fun onClickAppealsPatient(item: AppealsOldModel)
+ }
}
diff --git a/app/src/main/java/com/example/doctor/Appeals/AppealsOldModel.kt b/app/src/main/java/com/example/doctor/Appeals/AppealsOldModel.kt
deleted file mode 100644
index cf7b5a1..0000000
--- a/app/src/main/java/com/example/doctor/Appeals/AppealsOldModel.kt
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.example.doctor.Appeals
-
-data class AppealsOldModel(
- val id: Int,
- val login: String,
- val text: String,
- val id_user:Int,
- var expand : Boolean = false
-)
-
diff --git a/app/src/main/java/com/example/doctor/Appeals/CreateMessageFragment.kt b/app/src/main/java/com/example/doctor/Appeals/CreateMessageFragment.kt
new file mode 100644
index 0000000..dd1c68a
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Appeals/CreateMessageFragment.kt
@@ -0,0 +1,275 @@
+package com.example.doctor.Appeals
+
+import android.content.Intent
+import android.os.Bundle
+import android.transition.TransitionInflater
+import androidx.fragment.app.Fragment
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ArrayAdapter
+import android.widget.Toast
+import androidx.fragment.app.activityViewModels
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
+import com.example.doctor.DataModel
+import com.example.doctor.DoctorViewModel
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
+import com.example.doctor.Patients.Model.PatientAllModel
+import com.example.doctor.Patients.Reports.PatientFragment
+import com.example.doctor.Pref.ClearPref
+import com.example.doctor.Pref.ConclusionPref
+import com.example.doctor.R
+import com.example.doctor.Retrofit.DoctorApi
+import com.example.doctor.Toast.showCustomInfoToast
+import com.example.doctor.databinding.FragmentCreateMessageBinding
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import java.util.Timer
+import kotlin.concurrent.fixedRateTimer
+
+
+class CreateMessageFragment : Fragment() {
+ private lateinit var binding: FragmentCreateMessageBinding
+ private val dataModel: DataModel by activityViewModels()//Для передачи данных
+ private val modelDoctor: DoctorViewModel by activityViewModels()
+
+ private lateinit var doctorApi: DoctorApi
+ private lateinit var timer: Timer
+
+
+ val prefDoctorConclusion = ConclusionPref()
+ val prefDoctorClear = ClearPref()
+
+ var patientList:List?=null
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ binding = FragmentCreateMessageBinding.inflate(layoutInflater,container,false)
+ return binding.root
+
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ val inflater = TransitionInflater.from(requireContext())
+ enterTransition = inflater.inflateTransition(R.transition.slide_right)
+ exitTransition = inflater.inflateTransition(R.transition.slide_right)
+
+ GetPatientList()
+
+ binding.btnAddMessagePatient.setOnClickListener{
+ val login = binding.searchPatient.text.toString()
+ val text = binding.edTextMessagePatient.text.toString()
+ if(login!="" && text!=""){
+ AddMessageDoctor()
+ }
+ else{
+ Toast(requireContext()).showCustomInfoToast("Не все данные заполнены", requireActivity())
+
+ }
+ }
+
+// binding.btnExit.setOnClickListener{
+// dataModel.patientAppeal.value = 1
+// }
+
+ binding.btnExit.setOnClickListener{
+ activity?.finish()
+ }
+
+ modelDoctor.patientListSearch.observe(viewLifecycleOwner){
+ if(patientList!=it){
+ patientList =it
+ addPatientLogin(it)
+ }
+ }
+
+// fixedRateTimer("timer", false, 0, 10000) {
+// activity?.runOnUiThread {
+//
+// }
+// }
+ }
+
+ private fun addPatientLogin(patient: List) {
+ val listPatient = arrayListOf("")
+ for(i in 0 .. patient.count()-1){
+ listPatient.add(patient[i].login.toString())
+ }
+
+ val adapter = ArrayAdapter(requireContext(), android.R.layout.simple_list_item_1, listPatient)
+
+ binding.searchPatient.threshold = 1
+ binding.searchPatient.setAdapter(adapter)
+
+ binding.searchPatient.setOnItemClickListener { parent, arg1, pos, id ->
+ //val list = ArrayList()
+ val serpat = binding.searchPatient.text.toString()
+ binding.searchPatient.setText(serpat)
+
+ }
+ }
+
+
+ //Получения списка пациентов
+ fun GetPatientList() {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listProduct = doctorApi.GetPatientAll("Bearer $Tokens")
+ requireActivity().runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = listProduct.body()
+ val Nice = listProduct.isSuccessful
+ val Code = listProduct.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ //Если нету ошибок
+ if (List != null) {
+ modelDoctor.patientListSearch.value = List.patient
+ }
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ //Отправка сообщения
+ fun AddMessageDoctor() {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listProduct = doctorApi.AddMessageDoctor("Bearer $Tokens",binding.searchPatient.text.toString(),binding.edTextMessagePatient.text.toString())
+ requireActivity().runOnUiThread {
+
+ //Фиксируем полученные данные
+ val List = listProduct.body()
+ val Nice = listProduct.isSuccessful
+ val Code = listProduct.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+
+ if (Nice) {
+ if (List != null) {
+ //Если нету ошибок
+ if (List != null) {
+ Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
+ binding.edTextMessagePatient.setText("")
+ }
+
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+
+ //Инициализируем Retrofit
+ private fun initRetrofit() {
+ val interceptor = HttpLoggingInterceptor()
+ interceptor.level = HttpLoggingInterceptor.Level.BODY
+
+ val client = OkHttpClient
+ .Builder()
+ .addInterceptor(interceptor)
+ .build()
+
+ val retrofit = Retrofit.Builder()
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
+ .client(client)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+
+ doctorApi = retrofit.create(DoctorApi::class.java)
+
+ }
+
+ companion object {
+
+ fun newInstance() = CreateMessageFragment()
+ }
+
+
+ override fun onResume() {
+ super.onResume()
+ checkForUpdates(true)
+ }
+
+ override fun onStop() {
+ super.onStop()
+ timer.cancel()
+ timer.purge()
+ }
+
+ private fun checkForUpdates(daemonIsTrue: Boolean) {
+
+ timer = fixedRateTimer("default", daemonIsTrue, 0, 10000) {
+ activity?.runOnUiThread {
+ GetPatientList()
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Appeals/TabLayout/Model/AppealsNewListModel.kt b/app/src/main/java/com/example/doctor/Appeals/TabLayout/Model/AppealsNewListModel.kt
new file mode 100644
index 0000000..b42669c
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Appeals/TabLayout/Model/AppealsNewListModel.kt
@@ -0,0 +1,6 @@
+package com.example.doctor.Appeals.TabLayout.Model
+
+data class AppealsNewListModel(
+ val appeals_new: List
+)
+
diff --git a/app/src/main/java/com/example/doctor/Appeals/TabLayout/Model/AppealsNewModel.kt b/app/src/main/java/com/example/doctor/Appeals/TabLayout/Model/AppealsNewModel.kt
new file mode 100644
index 0000000..ae76119
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Appeals/TabLayout/Model/AppealsNewModel.kt
@@ -0,0 +1,16 @@
+package com.example.doctor.Appeals.TabLayout.Model
+
+data class AppealsNewModel(
+ val id: Int,
+ val number: Int,
+ val text: String,
+ val id_patient: Int,
+ val id_doctor: Int,
+ val check: Int,
+ val login: String,
+ val created_at: String,
+ val updated_at: String,
+ var expand : Boolean = false,
+
+ )
+
diff --git a/app/src/main/java/com/example/doctor/Appeals/TabLayout/Model/AppealsOldListModel.kt b/app/src/main/java/com/example/doctor/Appeals/TabLayout/Model/AppealsOldListModel.kt
new file mode 100644
index 0000000..e6c2c12
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Appeals/TabLayout/Model/AppealsOldListModel.kt
@@ -0,0 +1,6 @@
+package com.example.doctor.Appeals.TabLayout.Model
+
+data class AppealsOldListModel(
+ val appeals_old: List
+)
+
diff --git a/app/src/main/java/com/example/doctor/Appeals/TabLayout/Model/AppealsOldModel.kt b/app/src/main/java/com/example/doctor/Appeals/TabLayout/Model/AppealsOldModel.kt
new file mode 100644
index 0000000..0c2da4d
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Appeals/TabLayout/Model/AppealsOldModel.kt
@@ -0,0 +1,16 @@
+package com.example.doctor.Appeals.TabLayout.Model
+
+data class AppealsOldModel(
+ val id: Int,
+ val number: Int,
+ val text: String,
+ val id_patient: Int,
+ val id_doctor: Int,
+ val check: Int,
+ val login: String,
+ val created_at: String,
+ val updated_at: String,
+ var expand : Boolean = false,
+
+ )
+
diff --git a/app/src/main/java/com/example/doctor/Appeals/TabLayout/NewAppealsFragment.kt b/app/src/main/java/com/example/doctor/Appeals/TabLayout/NewAppealsFragment.kt
index 09d1a7d..e1a5d5a 100644
--- a/app/src/main/java/com/example/doctor/Appeals/TabLayout/NewAppealsFragment.kt
+++ b/app/src/main/java/com/example/doctor/Appeals/TabLayout/NewAppealsFragment.kt
@@ -1,25 +1,56 @@
package com.example.doctor.Appeals.TabLayout
+import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.Toast
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.GridLayoutManager
import com.example.doctor.Appeals.AppealsNewAdapter
-import com.example.doctor.Appeals.AppealsNewModel
+import com.example.doctor.Appeals.TabLayout.Model.AppealsNewModel
+import com.example.doctor.Appeals.TabLayout.Model.AppealsOldModel
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
+import com.example.doctor.DataModel
import com.example.doctor.DoctorViewModel
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
+import com.example.doctor.Patients.Model.PatientIdModel
+import com.example.doctor.Patients.PatientActivity
+import com.example.doctor.Patients.PatientsListFragment
+import com.example.doctor.Pref.ConclusionPref
+import com.example.doctor.Pref.SavePref
+import com.example.doctor.R
+import com.example.doctor.Retrofit.DoctorApi
+import com.example.doctor.Toast.showCustomInfoToast
import com.example.doctor.databinding.FragmentNewAppealsBinding
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
-class NewAppealsFragment : Fragment(), AppealsNewAdapter.Listener {
+class NewAppealsFragment : Fragment(), AppealsNewAdapter.Listener,AppealsNewAdapter.Listener2 {
private lateinit var binding:FragmentNewAppealsBinding
private val model: DoctorViewModel by activityViewModels()
+ private val dataModel: DataModel by activityViewModels()//Для передачи данных
lateinit var adapter: AppealsNewAdapter
+ private lateinit var doctorApi: DoctorApi
+ val prefDoctorConclusion = ConclusionPref()
+ val prefDoctorSave = SavePref()
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
-
+ //Список новых соощений
+ var newAppeals: List? = null
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
@@ -30,29 +61,200 @@ class NewAppealsFragment : Fragment(), AppealsNewAdapter.Listener {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
-
+ //binding.CLNull.visibility = View.VISIBLE
initRcViewAppeals()
patientListCurrent()
model.appealsNewList.observe(viewLifecycleOwner) {//viewLifecycleOwner - следит за циклом жизни fragment
- adapter.submitList(it)//Напрямую переадем созданный список в adapter(ProductAdapter)
+ if(newAppeals != it){
+ newAppeals = it
+ adapter.submitList(it)//Напрямую переадем созданный список в adapter(ProductAdapter)
+ if(newAppeals !=null){
+ binding.CLNull.visibility = View.GONE
+ binding.txtNull.visibility = View.GONE
+ }
+
+ }
}
- addNewAppeals()
+ getNewAppeals()
}
- private fun addNewAppeals() {
- val list = ArrayList()
+ //Получение необработанных сообщений
+ private fun getNewAppeals() {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listAppeals = doctorApi.GetAppealsDoctorNew("Bearer $Tokens")
+ requireActivity().runOnUiThread {
- for (i in 1..5){
- val itemPatient = AppealsNewModel(
- i,
- "Patient_$i",
- "asdasds adnas kjhdkl ashdlkashdkjalks hdjlkasjdlk ajldkhas j djask hsfldksjfksdf",
- i,
- )
- list.add(itemPatient)//Передали заполненый список
+
+ //Фиксируем полученные данные
+ val List = listAppeals.body()
+ val Nice = listAppeals.isSuccessful
+ val Code = listAppeals.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if(List?.appeals_new != null){
+
+ // binding.CLNull.visibility = View.GONE
+ binding.txtNull.visibility = View.GONE
+ model.appealsNewList.value = List.appeals_new
+ }
+ else{
+ // binding.CLNull.visibility = View.VISIBLE
+ binding.txtNull.visibility = View.VISIBLE
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
}
- model.appealsNewList.value = list
+
+ }
+
+ private fun getOldAppeals() {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listAppeals = doctorApi.GetAppealsDoctorOld("Bearer $Tokens")
+ requireActivity().runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = listAppeals.body()
+ val Nice = listAppeals.isSuccessful
+ val Code = listAppeals.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if(List?.appeals_old != null){
+ // binding.txtNull.visibility = View.GONE
+ model.appealsOldList.value = List.appeals_old
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ //Получение необработанных сообщений
+ private fun addCheckAppeals(id:Int,id_patient:Int) {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listAppeals = doctorApi.UpdateMessageDoctor("Bearer $Tokens",id,id_patient)
+ requireActivity().runOnUiThread {
+
+ //Фиксируем полученные данные
+ val List = listAppeals.body()
+ val Nice = listAppeals.isSuccessful
+ val Code = listAppeals.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
+
+ }
+ }
+ getNewAppeals()
+ getOldAppeals()
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+
+
+ //Инициализируем Retrofit
+ private fun initRetrofit() {
+ val interceptor = HttpLoggingInterceptor()
+ interceptor.level = HttpLoggingInterceptor.Level.BODY
+
+ val client = OkHttpClient
+ .Builder()
+ .addInterceptor(interceptor)
+ .build()
+
+ val retrofit = Retrofit.Builder()
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
+ .client(client)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+
+ doctorApi = retrofit.create(DoctorApi::class.java)
+
}
//Вывод прогресса на один день
@@ -66,7 +268,7 @@ class NewAppealsFragment : Fragment(), AppealsNewAdapter.Listener {
//Инициализация списка
private fun initRcViewAppeals() = with(binding) {
rcView.layoutManager = GridLayoutManager(requireContext(),1)//По вертикали будет выводить по умолчанию
- adapter = AppealsNewAdapter(this@NewAppealsFragment)
+ adapter = AppealsNewAdapter(this@NewAppealsFragment,this@NewAppealsFragment)
rcView.adapter = adapter
}
@@ -76,6 +278,15 @@ class NewAppealsFragment : Fragment(), AppealsNewAdapter.Listener {
}
override fun onClickAppeals(item: AppealsNewModel) {
+ addCheckAppeals(item.id,item.id_patient)
+ }
+ override fun onClickAppealsPatient(item: AppealsNewModel) {
+ prefDoctorSave.saveIdPatient(requireContext(),item.id_patient)
+ prefDoctorSave.saveViewPatient(requireContext(),1)
+ model.patientId.value = PatientIdModel(item.id)
+ //dataModel.patientAppeal.value = item.id_patient
+ val intetn = Intent(requireContext(), PatientActivity::class.java)
+ startActivity(intetn)
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Appeals/TabLayout/OldAppealsFragment.kt b/app/src/main/java/com/example/doctor/Appeals/TabLayout/OldAppealsFragment.kt
index 1c0bb62..7f5e09b 100644
--- a/app/src/main/java/com/example/doctor/Appeals/TabLayout/OldAppealsFragment.kt
+++ b/app/src/main/java/com/example/doctor/Appeals/TabLayout/OldAppealsFragment.kt
@@ -1,5 +1,6 @@
package com.example.doctor.Appeals.TabLayout
+import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
@@ -8,15 +9,48 @@ import android.view.ViewGroup
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.GridLayoutManager
import com.example.doctor.Appeals.AppealsOldAdapter
-import com.example.doctor.Appeals.AppealsOldModel
+import com.example.doctor.Appeals.TabLayout.Model.AppealsNewModel
+import com.example.doctor.Appeals.TabLayout.Model.AppealsOldModel
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
+import com.example.doctor.DataModel
import com.example.doctor.DoctorViewModel
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
+import com.example.doctor.Patients.Model.PatientIdModel
+import com.example.doctor.Patients.PatientActivity
+import com.example.doctor.Patients.PatientsListFragment
+import com.example.doctor.Pref.ConclusionPref
+import com.example.doctor.Pref.SavePref
+import com.example.doctor.R
+import com.example.doctor.Retrofit.DoctorApi
import com.example.doctor.databinding.FragmentOldAppealsBinding
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import kotlin.concurrent.fixedRateTimer
-class OldAppealsFragment : Fragment(), AppealsOldAdapter.Listener {
+class OldAppealsFragment : Fragment(), AppealsOldAdapter.Listener,AppealsOldAdapter.Listener2 {
private lateinit var binding:FragmentOldAppealsBinding
private val model: DoctorViewModel by activityViewModels()
+ private val dataModel: DataModel by activityViewModels()//Для передачи данных
+
lateinit var adapter: AppealsOldAdapter
+ private lateinit var doctorApi: DoctorApi
+ val prefDoctorConclusion = ConclusionPref()
+ val prefDoctorSave = SavePref()
+
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
+
+ //Список прочитанных соощений
+ var oldAppeals: List? = null
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
@@ -28,29 +62,105 @@ class OldAppealsFragment : Fragment(), AppealsOldAdapter.Listener {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
+ //binding.CLNull.visibility = View.VISIBLE
initRcViewAppeals()
appealsAllCurrent()
- model.appealsAllList.observe(viewLifecycleOwner) {//viewLifecycleOwner - следит за циклом жизни fragment
- adapter.submitList(it)//Напрямую переадем созданный список в adapter(ProductAdapter)
+ model.appealsOldList.observe(viewLifecycleOwner) {//viewLifecycleOwner - следит за циклом жизни fragment
+ if(oldAppeals != it){
+
+ oldAppeals = it
+ adapter.submitList(it)//Напрямую переадем созданный список в adapter(ProductAdapter)
+ if(oldAppeals !=null){
+ binding.CLNull.visibility = View.GONE
+ binding.txtNull.visibility = View.GONE
+ }
+ }
}
- addAllAppeals()
+ getOldAppeals()
+
+// fixedRateTimer("timer", false, 0, 10000) {
+// activity?.runOnUiThread {
+//
+// }
+// }
}
- private fun addAllAppeals() {
- val list = ArrayList()
+ private fun getOldAppeals() {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listAppeals = doctorApi.GetAppealsDoctorOld("Bearer $Tokens")
+ requireActivity().runOnUiThread {
- for (i in 1..7){
- val itemPatient = AppealsOldModel(
- i,
- "Patient_$i",
- " 81 23891 23812 37817411 sdasds adnas kjhdkl ashdlk ashdkjalks ashdlkashdkjalks hdjlkasjdlk ajldkhas hdjlkasjdlk ajldkhasas hdlkashdkjalks hdjlkasjdlk ajldkhasashdlkashdkjalks hdjlkasjdlk ajldkhas j djask hsfldksjfksdf",
- i,
- )
- list.add(itemPatient)//Передали заполненый список
+ //Фиксируем полученные данные
+ val List = listAppeals.body()
+ val Nice = listAppeals.isSuccessful
+ val Code = listAppeals.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ //Если нету ошибок
+ if (List != null) {
+ if(List.appeals_old != null){
+ //binding.CLNull.visibility = View.GONE
+ binding.txtNull.visibility = View.GONE
+ model.appealsOldList.value = List.appeals_old
+ }
+ else{
+ //binding.CLNull.visibility = View.VISIBLE
+ binding.txtNull.visibility = View.VISIBLE
+ }
+ }else{
+ // binding.CLNull.visibility = View.VISIBLE
+ binding.txtNull.visibility = View.VISIBLE
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
}
- model.appealsAllList.value = list
+
+ }
+
+ //Инициализируем Retrofit
+ private fun initRetrofit() {
+ val interceptor = HttpLoggingInterceptor()
+ interceptor.level = HttpLoggingInterceptor.Level.BODY
+
+ val client = OkHttpClient
+ .Builder()
+ .addInterceptor(interceptor)
+ .build()
+
+ val retrofit = Retrofit.Builder()
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
+ .client(client)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+
+ doctorApi = retrofit.create(DoctorApi::class.java)
+
}
//Вывод прогресса на один день
@@ -64,7 +174,7 @@ class OldAppealsFragment : Fragment(), AppealsOldAdapter.Listener {
//Инициализация списка
private fun initRcViewAppeals() = with(binding) {
rcView.layoutManager = GridLayoutManager(requireContext(),1)//По вертикали будет выводить по умолчанию
- adapter = AppealsOldAdapter(this@OldAppealsFragment)
+ adapter = AppealsOldAdapter(this@OldAppealsFragment,this@OldAppealsFragment)
rcView.adapter = adapter
}
companion object {
@@ -75,4 +185,13 @@ class OldAppealsFragment : Fragment(), AppealsOldAdapter.Listener {
override fun onClickAppeals(item: AppealsOldModel) {
}
+
+ override fun onClickAppealsPatient(item: AppealsOldModel) {
+// prefDoctorSave.saveIdPatient(requireContext(),item.id_patient)
+// prefDoctorSave.saveViewPatient(requireContext(),1)
+ model.patientId.value = PatientIdModel(item.id)
+ // dataModel.patientAppeal.value = item.id_patient
+ val intetn = Intent(requireContext(), PatientActivity::class.java)
+ startActivity(intetn)
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Auth/AuthFragment.kt b/app/src/main/java/com/example/doctor/Auth/AuthFragment.kt
index 8312813..f51e181 100644
--- a/app/src/main/java/com/example/doctor/Auth/AuthFragment.kt
+++ b/app/src/main/java/com/example/doctor/Auth/AuthFragment.kt
@@ -12,8 +12,13 @@ import android.widget.Toast
import androidx.fragment.app.activityViewModels
import com.example.doctor.Auth.Model.AuthModel
import com.example.doctor.Auth.Model.UserModel
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
import com.example.doctor.DoctorViewModel
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
import com.example.doctor.MainActivity
+import com.example.doctor.Pref.ClearPref
import com.example.doctor.Pref.ConclusionPref
import com.example.doctor.R
import com.example.doctor.Retrofit.DoctorApi
@@ -43,6 +48,10 @@ class AuthFragment : Fragment() {
private var Token = ""
val prefDoctorSave = SavePref()
val prefDoctorConclusion = ConclusionPref()
+ val prefDoctorClear = ClearPref()
+
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
@@ -56,6 +65,7 @@ class AuthFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)
initRetrofit()
+ prefDoctorClear.clearToken(requireContext())
Token = prefDoctorConclusion.conclusionToken(requireContext())
binding.apply {
@@ -81,67 +91,65 @@ class AuthFragment : Fragment() {
}
}
-// private fun Auth(authModel: AuthModel) {
-// CoroutineScope(Dispatchers.IO).launch {
-// val response = doctorApi.Auth(authModel)
-// val errorMessage = response.errorBody()?.string()
-// ?.let { JSONObject(it).getString("message") }//JSONObject(response.errorBody()?.string())
-// requireActivity().runOnUiThread {
-// binding.textError.text = errorMessage
-// val user = response.body()
-//
-// //Если есть такой пользователь
-// if (user != null) {
-// DoctorviewModel.token.value = user.token
-// prefDoctor.saveToken(user.token)
-// val intetn = Intent(requireContext(), MainActivity::class.java)
-// startActivity(intetn)
-// activity?.finish()
-// }
-// }
-// }
-//
-// }
-//
-// private fun Auth(authModel: AuthModel) {
-// //Если есть такой пользователь
-// if (authModel.login == "asd" && authModel.password == "asd" ) {
-// DoctorviewModel.token.value = "sdadssdasdaasdad434fk3ioj9"
-// prefDoctorSave.saveToken(requireContext(),"sdadssdasdaasdad434fk3ioj9")
-// val intetn = Intent(requireContext(), MainActivity::class.java)
-// startActivity(intetn)
-// activity?.finish()
-// }
-//
-// }
private fun Auth(authModel: AuthModel) {
- CoroutineScope(Dispatchers.IO).launch {
- val response = doctorApi.LoginDoctor(authModel)
- val errorMessage = response.errorBody()?.string()
- ?.let { JSONObject(it).getString("error") }//JSONObject(response.errorBody()?.string())
- requireActivity().runOnUiThread {
- Log.i("errorMessage",errorMessage.toString())
- val user = response.body()
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ CoroutineScope(Dispatchers.IO).launch {
+ val response = doctorApi.LoginDoctor(authModel)
+ val errorMessage = response.errorBody()?.string()
+ ?.let { JSONObject(it).getString("error") }//JSONObject(response.errorBody()?.string())
+ requireActivity().runOnUiThread {
+
+ //Фиксируем полученные данные
+ val List = response.body()
+ val Nice = response.isSuccessful
+ val Code = response.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ DoctorviewModel.token.value = List.token
+ prefDoctorSave.saveToken(requireContext(), List.token)
+
+ val intetn = Intent(requireContext(), MainActivity::class.java)
+ startActivity(intetn)
+ activity?.finish()
+ }
+ else{
+ Toast(requireContext()).showCustomInfoToast(
+ "Такого пользователя нету",
+ requireActivity()
+ )
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
- //Если есть такой пользователь
- if (user != null) {
- DoctorviewModel.token.value = user.token
- prefDoctorSave.saveToken(requireContext(), user.token)
- val intetn = Intent(requireContext(), MainActivity::class.java)
- startActivity(intetn)
- activity?.finish()
- }
- else{
- Toast(requireContext()).showCustomInfoToast(
- "Такого пользователя нету",
- requireActivity()
- )
}
}
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
}
+
}
@@ -156,7 +164,7 @@ class AuthFragment : Fragment() {
.build()
val retrofit = Retrofit.Builder()
- .baseUrl("http://mobileapp.vmeda.org/api/")
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build()
diff --git a/app/src/main/java/com/example/doctor/CodeError/Code429Activity.kt b/app/src/main/java/com/example/doctor/CodeError/Code429Activity.kt
new file mode 100644
index 0000000..afe69f1
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/CodeError/Code429Activity.kt
@@ -0,0 +1,136 @@
+package com.example.doctor.CodeError
+
+import android.annotation.SuppressLint
+import android.content.Intent
+import androidx.appcompat.app.AppCompatActivity
+import android.os.Bundle
+import android.os.CountDownTimer
+import android.util.Log
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
+import com.example.doctor.MainActivity
+import com.example.doctor.Pref.ClearPref
+import com.example.doctor.Pref.ConclusionPref
+import com.example.doctor.Pref.SavePref
+import com.example.doctor.R
+import com.example.doctor.Retrofit.DoctorApi
+import com.example.doctor.databinding.ActivityCode429Binding
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import java.util.Timer
+import kotlin.concurrent.fixedRateTimer
+
+class Code429Activity : AppCompatActivity() {
+ private lateinit var binding:ActivityCode429Binding
+ private lateinit var doctorApi: DoctorApi
+ private lateinit var timer: Timer
+
+
+ val prefDoctorConclusion = ConclusionPref()
+ val prefDoctorClear = ClearPref()
+ val prefDoctorSave = SavePref()
+
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ binding = ActivityCode429Binding.inflate(layoutInflater)
+ setContentView(binding.root)
+ }
+
+ fun CheckToken(){
+ if (enternetCheck.isOnline(this@Code429Activity)) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(this@Code429Activity)
+ CoroutineScope(Dispatchers.IO).launch {
+ val list = doctorApi.CheckToken("Bearer $Tokens")
+ runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = list.body()
+ val Nice = list.isSuccessful
+ val Code = list.code()
+ if(Code==500){
+ val intetn = Intent(this@Code429Activity, Code500Activity::class.java)
+ finish()
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ //Если нету ошибок
+ if (List != null) {
+
+ Log.i("clogon1231111","clogon1231111")
+ finish()
+ }
+
+ }
+ }
+ else if (Code == 401) {
+ val intetn = Intent(this@Code429Activity, AuthActivity::class.java)
+ finish()
+ startActivity(intetn)
+ }
+ }
+ }
+ } else {
+
+ val intetn = Intent(this, EnternetActivity::class.java)
+ finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ //Инициализируем Retrofit
+ private fun initRetrofit() {
+ val interceptor = HttpLoggingInterceptor()
+ interceptor.level = HttpLoggingInterceptor.Level.BODY
+
+ val client = OkHttpClient
+ .Builder()
+ .addInterceptor(interceptor)
+ .build()
+
+ val retrofit = Retrofit.Builder()
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
+ .client(client)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+
+ doctorApi = retrofit.create(DoctorApi::class.java)
+
+ }
+
+
+ override fun onResume() {
+ super.onResume()
+ checkForUpdates(true)
+ }
+
+ override fun onStop() {
+ super.onStop()
+ timer.cancel()
+ timer.purge()
+ }
+
+ private fun checkForUpdates(daemonIsTrue: Boolean) {
+
+ timer = fixedRateTimer("default", daemonIsTrue, 0, 15000) {
+ this@Code429Activity.runOnUiThread {
+ CheckToken()
+ }
+ }
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/CodeError/Code500Activity.kt b/app/src/main/java/com/example/doctor/CodeError/Code500Activity.kt
new file mode 100644
index 0000000..d787358
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/CodeError/Code500Activity.kt
@@ -0,0 +1,178 @@
+package com.example.doctor.CodeError
+
+import android.annotation.SuppressLint
+import android.content.Intent
+import androidx.appcompat.app.AppCompatActivity
+import android.os.Bundle
+import android.os.CountDownTimer
+import android.util.Log
+import android.view.View
+import android.widget.Toast
+import androidx.core.content.ContentProviderCompat.requireContext
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
+import com.example.doctor.MainActivity
+import com.example.doctor.Pref.ClearPref
+import com.example.doctor.Pref.ConclusionPref
+import com.example.doctor.Pref.SavePref
+import com.example.doctor.R
+import com.example.doctor.Retrofit.DoctorApi
+import com.example.doctor.Toast.showCustomInfoToast
+import com.example.doctor.databinding.ActivityCode500Binding
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import java.util.Timer
+import kotlin.concurrent.fixedRateTimer
+
+class Code500Activity : AppCompatActivity() {
+ private lateinit var binding: ActivityCode500Binding
+ private lateinit var doctorApi: DoctorApi
+ private lateinit var timer: Timer
+
+
+ val prefDoctorConclusion = ConclusionPref()
+ val prefDoctorClear = ClearPref()
+ val prefDoctorSave = SavePref()
+
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
+
+ var checkClose = false
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ binding = ActivityCode500Binding.inflate(layoutInflater)
+ setContentView(binding.root)
+
+
+// val fixedRateTimer = fixedRateTimer("hello-timer",
+// false,0,5000) {
+//
+// }
+// try {
+// this@Code500Activity.runOnUiThread {
+// CheckToken()
+// }
+// }
+// finally {
+// fixedRateTimer.cancel();
+// }
+//ПОСТОЯННО ВЫЗЫВАЕТСЯ НУЖНО КАК-ТО ОТКЛЮЧАТЬ
+// fixedRateTimer("timer", false, 0, 10000) {
+// this@Code500Activity?.runOnUiThread {
+// }
+// }
+
+ binding.apply {
+
+ val timer = object: CountDownTimer(30000, 1000) {
+ override fun onTick(millisUntilFinished: Long) {
+
+ }
+
+ override fun onFinish() {
+ val intetn = Intent(this@Code500Activity, AuthActivity::class.java)
+ finish()
+ startActivity(intetn)
+ }
+ }
+ timer.start()
+
+ }
+
+ }
+
+
+ fun CheckToken(){
+ if (enternetCheck.isOnline(this@Code500Activity)) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(this@Code500Activity)
+ CoroutineScope(Dispatchers.IO).launch {
+ val list = doctorApi.CheckToken("Bearer $Tokens")
+ runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = list.body()
+ val Nice = list.isSuccessful
+ val Code = list.code()
+ if(Code==429){
+ val intetn = Intent(this@Code500Activity, Code429Activity::class.java)
+ finish()
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ //Если нету ошибок
+ if (List != null) {
+
+ Log.i("clogon1231111","clogon1231111")
+ finish()
+ }
+
+ }
+ }
+ else if (Code == 401) {
+ val intetn = Intent(this@Code500Activity, AuthActivity::class.java)
+ finish()
+ startActivity(intetn)
+ }
+ }
+ }
+ } else {
+ val intetn = Intent(this, EnternetActivity::class.java)
+ finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ //Инициализируем Retrofit
+ private fun initRetrofit() {
+ val interceptor = HttpLoggingInterceptor()
+ interceptor.level = HttpLoggingInterceptor.Level.BODY
+
+ val client = OkHttpClient
+ .Builder()
+ .addInterceptor(interceptor)
+ .build()
+
+ val retrofit = Retrofit.Builder()
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
+ .client(client)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+
+ doctorApi = retrofit.create(DoctorApi::class.java)
+
+ }
+
+
+ override fun onResume() {
+ super.onResume()
+ checkForUpdates(true)
+ }
+
+ override fun onStop() {
+ super.onStop()
+ timer.cancel()
+ timer.purge()
+ }
+
+ private fun checkForUpdates(daemonIsTrue: Boolean) {
+
+ timer = fixedRateTimer("default", daemonIsTrue, 0, 15000) {
+ this@Code500Activity.runOnUiThread {
+ CheckToken()
+ }
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/DataModel.kt b/app/src/main/java/com/example/doctor/DataModel.kt
new file mode 100644
index 0000000..b5b9afd
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/DataModel.kt
@@ -0,0 +1,30 @@
+package com.example.doctor
+
+import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.ViewModel
+
+//Ослеживание за обновлением подробной продуктовой карточкой
+open class DataModel: ViewModel() {
+ /*//Для отлеживания обновлений активити
+ val messageForActivity: MutableLiveData by lazy{//by lazy - чтобы каждый раз не создавался MutableLiveData(MutableLiveData()), а он один раз при загрузке создаться и дальше будет пользоваться уже созданным
+ MutableLiveData()//LiveData - означает что будет обновляться в нужынй момент, не постоянна, а в зависимоти от жизни активити
+ }*/
+ //Для отлеживания обновлений фрагммента 1
+ val messageForFrag1: MutableLiveData by lazy{//by lazy - чтобы каждый раз не создавался MutableLiveData(MutableLiveData()), а он один раз при загрузке создаться и дальше будет пользоваться уже созданным
+ MutableLiveData()//LiveData - означает что будет обновляться в нужынй момент, не постоянна, а в зависимоти от жизни активити
+ }
+
+ val fragmentMenu: MutableLiveData by lazy{//by lazy - чтобы каждый раз не создавался MutableLiveData(MutableLiveData()), а он один раз при загрузке создаться и дальше будет пользоваться уже созданным
+ MutableLiveData()//LiveData - означает что будет обновляться в нужынй момент, не постоянна, а в зависимоти от жизни активити
+ }
+ val patientList: MutableLiveData by lazy{//by lazy - чтобы каждый раз не создавался MutableLiveData(MutableLiveData()), а он один раз при загрузке создаться и дальше будет пользоваться уже созданным
+ MutableLiveData()//LiveData - означает что будет обновляться в нужынй момент, не постоянна, а в зависимоти от жизни активити
+ }
+ val patientAppeal: MutableLiveData by lazy{//by lazy - чтобы каждый раз не создавался MutableLiveData(MutableLiveData()), а он один раз при загрузке создаться и дальше будет пользоваться уже созданным
+ MutableLiveData()//LiveData - означает что будет обновляться в нужынй момент, не постоянна, а в зависимоти от жизни активити
+ }
+ /*//Для отлеживания обновлений фрагммента 2
+ val messageForFrag2: MutableLiveData by lazy{//by lazy - чтобы каждый раз не создавался MutableLiveData(MutableLiveData()), а он один раз при загрузке создаться и дальше будет пользоваться уже созданным
+ MutableLiveData()//LiveData - означает что будет обновляться в нужынй момент, не постоянна, а в зависимоти от жизни активити
+ }*/
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/DoctorViewModel.kt b/app/src/main/java/com/example/doctor/DoctorViewModel.kt
index 334ae00..6ce7381 100644
--- a/app/src/main/java/com/example/doctor/DoctorViewModel.kt
+++ b/app/src/main/java/com/example/doctor/DoctorViewModel.kt
@@ -2,15 +2,17 @@ package com.example.doctor
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
-import com.example.doctor.Appeals.AppealsOldModel
-import com.example.doctor.Appeals.AppealsNewModel
+import com.example.doctor.Appeals.TabLayout.Model.AppealsNewModel
+import com.example.doctor.Appeals.TabLayout.Model.AppealsOldModel
import com.example.doctor.Patients.Model.PatientAllModel
+import com.example.doctor.Patients.Model.PatientIdModel
import com.example.doctor.Patients.Model.PatientModel
-import com.example.doctor.Patients.Reports.Edit.EditSportListNoModel
-import com.example.doctor.Patients.Reports.Edit.EditSportListYesModel
+import com.example.doctor.Patients.Reports.Courses.SportCoursModel
import com.example.doctor.Patients.Reports.Edit.EditSportModel
import com.example.doctor.Patients.Reports.QBAModel
-import com.example.doctor.Patients.Reports.SportCoursModel
+import com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Model.EditCoursesDoctorModel
+import com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Model.CoursesDoctorCA
+import com.example.doctor.Setting.Courses.Model.CoursesDoctorModel
//import com.example.retrofit.model.Product
@@ -20,16 +22,17 @@ class DoctorViewModel: ViewModel() {
val token = MutableLiveData()
//Пациенты
+ val patientId = MutableLiveData()
val patientCurrent = MutableLiveData()
val patientListList= MutableLiveData()
- //Обращения новые
+ //Обращения необработанные
val appealsNewCurrent = MutableLiveData()
val appealsNewList= MutableLiveData>()
- //Обращения все
- val appealsAllCurrent = MutableLiveData()
- val appealsAllList= MutableLiveData>()
+ //Обращения обработанные
+ val appealsOldCurrent = MutableLiveData()
+ val appealsOldList= MutableLiveData>()
//val productList = MutableLiveData>()
val patientOneCurrent = MutableLiveData()
@@ -41,6 +44,9 @@ class DoctorViewModel: ViewModel() {
//КУрсы
val SportCoursCurrent = MutableLiveData()
val SportCoursList= MutableLiveData>()
+ val SportCoursDoctorList= MutableLiveData>()
+
+ val BtnSportCoursDoctorCurrent = MutableLiveData()
//Редактирование занятий
val EditSportCurrentYes = MutableLiveData()
@@ -50,7 +56,38 @@ class DoctorViewModel: ViewModel() {
val EditSportCurrentNO = MutableLiveData()
val EditSportListNo= MutableLiveData>()
+ //Список пациентов
+ val PatientActiveCurrent = MutableLiveData()
+ val PatientActiveList= MutableLiveData>()
+ val PatientNotCurrent = MutableLiveData()
+ val PatientNotList= MutableLiveData>()
+
+ //Список со всеми пациентами
+ val PatientAllModel= MutableLiveData>()
//id пациента
val id_patient = MutableLiveData()
+
+ //Курсы созданный доктором
+ val CoursesDoctorCurrent = MutableLiveData()
+ val CoursesDoctorList= MutableLiveData>()
+
+
+ //Упражнения не входяшие в курс доктора
+ val EditCoursesDoctorAllCurrent = MutableLiveData()
+ val EditCoursesDoctorAllList= MutableLiveData>()
+
+ //Упражнения входяшие в курс доктора
+ val EditCoursesDoctorYourCurrent = MutableLiveData()
+ val EditCoursesDoctorYourList= MutableLiveData>()
+
+ val CoursesDoctorCA = MutableLiveData()
+
+
+ //Список пациентов для поисковой строки
+ val patientListSearch= MutableLiveData>()
+
+ //Для передачи данных редактируемого курса
+ val CoursesCustomDoctor = MutableLiveData()
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Enternet/EnternetActivity.kt b/app/src/main/java/com/example/doctor/Enternet/EnternetActivity.kt
new file mode 100644
index 0000000..09674f4
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Enternet/EnternetActivity.kt
@@ -0,0 +1,23 @@
+package com.example.doctor.Enternet
+
+import androidx.appcompat.app.AppCompatActivity
+import android.os.Bundle
+import com.example.doctor.R
+import com.example.doctor.databinding.ActivityEnternetBinding
+import com.example.doctor.databinding.FragmentEnternetBinding
+
+class EnternetActivity : AppCompatActivity() {
+ private lateinit var binding: ActivityEnternetBinding
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ binding = ActivityEnternetBinding.inflate(layoutInflater)
+ setContentView(binding.root)
+
+ supportFragmentManager.beginTransaction()
+ .replace(R.id.CLEnternet, EnternetFragment.newInstance())
+ .commit()
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Enternet/EnternetCheck.kt b/app/src/main/java/com/example/doctor/Enternet/EnternetCheck.kt
new file mode 100644
index 0000000..a2ec595
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Enternet/EnternetCheck.kt
@@ -0,0 +1,41 @@
+package com.example.doctor.Enternet
+
+import android.content.Context
+import android.net.ConnectivityManager
+import android.net.NetworkCapabilities
+import android.os.Build
+
+class EnternetCheck() {
+
+ //Проверка интернета
+ fun isOnline(context: Context): Boolean {
+ if (context == null) return false
+ val connectivityManager =
+ context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ val capabilities =
+ connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)
+ if (capabilities != null) {
+ when {
+ capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> {
+ return true
+ }
+
+ capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> {
+ return true
+ }
+
+ capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> {
+ return true
+ }
+ }
+ }
+ } else {
+ val activeNetworkInfo = connectivityManager.activeNetworkInfo
+ if (activeNetworkInfo != null && activeNetworkInfo.isConnected) {
+ return true
+ }
+ }
+ return false
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Enternet/EnternetFragment.kt b/app/src/main/java/com/example/doctor/Enternet/EnternetFragment.kt
new file mode 100644
index 0000000..0062d72
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Enternet/EnternetFragment.kt
@@ -0,0 +1,38 @@
+package com.example.doctor.Enternet
+
+import android.content.Intent
+import android.os.Bundle
+import androidx.fragment.app.Fragment
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import com.example.doctor.MainActivity
+import com.example.doctor.databinding.FragmentEnternetBinding
+
+
+class EnternetFragment : Fragment() {
+ private lateinit var binding: FragmentEnternetBinding
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ binding = FragmentEnternetBinding.inflate(layoutInflater,container,false)
+ return binding.root
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+
+ binding.btnEnternet.setOnClickListener{
+ val intetn = Intent(requireContext(), MainActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ companion object {
+
+ fun newInstance() = EnternetFragment()
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Home/HomeFragment.kt b/app/src/main/java/com/example/doctor/Home/HomeFragment.kt
index e5c64dc..27c61c4 100644
--- a/app/src/main/java/com/example/doctor/Home/HomeFragment.kt
+++ b/app/src/main/java/com/example/doctor/Home/HomeFragment.kt
@@ -1,15 +1,45 @@
package com.example.doctor.Home
+import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.fragment.app.activityViewModels
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
+import com.example.doctor.DataModel
+import com.example.doctor.DoctorViewModel
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
+import com.example.doctor.Pref.ClearPref
+import com.example.doctor.Pref.ConclusionPref
+import com.example.doctor.R
+import com.example.doctor.Retrofit.DoctorApi
import com.example.doctor.databinding.FragmentHomeBinding
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
class HomeFragment : Fragment() {
private lateinit var binding: FragmentHomeBinding
+ private val dataModel: DataModel by activityViewModels()//Для передачи данных
+
+ private var Token = ""
+ val prefDoctorClear= ClearPref()
+ private lateinit var doctorApi: DoctorApi
+ val prefDoctorConclusion = ConclusionPref()
+ private val modelDoctor: DoctorViewModel by activityViewModels()
+
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
@@ -22,6 +52,87 @@ class HomeFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
+ binding.CVPatinet.setOnClickListener {
+ dataModel.fragmentMenu.value = R.id.patient
+ }
+
+ binding.CVAppeals.setOnClickListener {
+ dataModel.fragmentMenu.value = R.id.list_check
+ }
+
+ CountPatientAndAppeals()
+ }
+
+ //Получение данных для главной страницы
+ fun CountPatientAndAppeals() = with(binding) {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listHomeView = doctorApi.CountPatientAndAppeals("Bearer $Tokens")
+
+ requireActivity().runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = listHomeView.body()
+ val Nice = listHomeView.isSuccessful
+ val Code = listHomeView.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ txtCountPatient.text = List?.patient.toString()
+ txtCountAppealsNew.text = List?.appeals_check.toString()
+ txtCountAppealsAll.text = List?.appeals_all.toString()
+ CLLoad.visibility = View.GONE
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ //Инициализируем Retrofit
+ private fun initRetrofit() {
+ val interceptor = HttpLoggingInterceptor()
+ interceptor.level = HttpLoggingInterceptor.Level.BODY
+
+ val client = OkHttpClient
+ .Builder()
+ .addInterceptor(interceptor)
+ .build()
+
+ val retrofit = Retrofit.Builder()
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
+ .client(client)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+
+ doctorApi = retrofit.create(DoctorApi::class.java)
+
}
companion object {
diff --git a/app/src/main/java/com/example/doctor/Home/HomeInfoModel.kt b/app/src/main/java/com/example/doctor/Home/HomeInfoModel.kt
new file mode 100644
index 0000000..5e7fc1f
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Home/HomeInfoModel.kt
@@ -0,0 +1,8 @@
+package com.example.doctor.Home
+
+data class HomeInfoModel(
+ val patient: Int,
+ val appeals_check: Int,
+ val appeals_all: Int,
+)
+
diff --git a/app/src/main/java/com/example/doctor/MainActivity.kt b/app/src/main/java/com/example/doctor/MainActivity.kt
index d7e78b3..37fe284 100644
--- a/app/src/main/java/com/example/doctor/MainActivity.kt
+++ b/app/src/main/java/com/example/doctor/MainActivity.kt
@@ -1,15 +1,31 @@
package com.example.doctor
import android.annotation.SuppressLint
+import android.app.Notification
+import android.app.NotificationChannel
+import android.app.NotificationManager
+import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
+import android.graphics.BitmapFactory
+import android.graphics.Color
+import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.ArrayAdapter
+import android.widget.RemoteViews
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
+import androidx.constraintlayout.widget.ConstraintSet.Constraint
+import androidx.work.Constraints
+import androidx.work.ExistingPeriodicWorkPolicy
+import androidx.work.NetworkType
+import androidx.work.OneTimeWorkRequest
+import androidx.work.PeriodicWorkRequest
+import androidx.work.WorkManager
+import androidx.work.WorkRequest
import com.example.doctor.Auth.AuthActivity
import com.example.doctor.Auth.AuthFragment
import com.example.doctor.Auth.Model.AuthModel
@@ -17,6 +33,7 @@ import com.example.doctor.Pref.ConclusionPref
import com.example.doctor.Pref.SavePref
import com.example.doctor.Retrofit.DoctorApi
import com.example.doctor.Toast.showCustomInfoToast
+import com.example.doctor.Worker.MyWorker
import com.example.doctor.databinding.ActivityMainBinding
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -26,32 +43,258 @@ import okhttp3.logging.HttpLoggingInterceptor
import org.json.JSONObject
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
+import java.util.concurrent.TimeUnit
+import android.app.TaskStackBuilder
+import android.net.ConnectivityManager
+import android.net.NetworkCapabilities
+import android.view.View
+import androidx.activity.viewModels
+import androidx.core.app.NotificationCompat
+import androidx.core.app.NotificationManagerCompat
+import androidx.core.content.ContentProviderCompat.requireContext
+import androidx.test.core.app.ActivityScenario.launch
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
+import com.example.doctor.Enternet.EnternetFragment
+import kotlinx.coroutines.Job
+import java.util.Timer
+import kotlin.concurrent.fixedRateTimer
+
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
private lateinit var doctorApi: DoctorApi
-
+ private lateinit var timer: Timer
//Токен
private var Token = ""
val prefDoctorSave = SavePref()
val prefDoctorConclusion = ConclusionPref()
var backPressedTime: Long = 0
+
+ lateinit var notificationManager: NotificationManager
+ lateinit var notificationChannel: NotificationChannel
+ lateinit var builder: Notification.Builder
+ private val channelId = "i.apps.notifications"
+ private val description = "Test notification"
+
+
+ val CHANNEL_ID = "channelID"
+ val CHANNEL_NAME = "channelName"
+ val NOTIF_ID = 0
+
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
+
+ private val modelDoctor: DoctorViewModel by viewModels()//Инициализировали класс
+
+ @SuppressLint("RemoteViewLayout", "MissingPermission")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
- initRetrofit()
-
MainAndAuth()
}
+
+
+ //Получение необработанных сообщений
+ private fun getNewAppeals() {
+ if (enternetCheck.isOnline(this)) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(this)
+ CoroutineScope(Dispatchers.IO).launch {
+ val listAppeals = doctorApi.GetAppealsDoctorNew("Bearer $Tokens")
+ runOnUiThread {
+
+ //Фиксируем полученные данные
+ val AppealsMes = listAppeals.body()
+
+ //Если нету ошибок
+ if (AppealsMes != null) {
+ if (AppealsMes.appeals_new != null) {
+ modelDoctor.appealsNewList.value = AppealsMes.appeals_new
+ }
+ }
+ }
+ }
+ } else {
+// finish()
+// val intetn = Intent(this, EnternetActivity::class.java)
+// startActivity(intetn)
+ }
+ }
+
+ //Получение обработанных сообщений
+ private fun getOldAppeals() {
+ if (enternetCheck.isOnline(this)) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(this)
+ CoroutineScope(Dispatchers.IO).launch {
+ val listAppeals = doctorApi.GetAppealsDoctorOld("Bearer $Tokens")
+ runOnUiThread {
+
+ //Фиксируем полученные данные
+ val AppealsMes = listAppeals.body()
+
+ //Если нету ошибок
+ if (AppealsMes != null) {
+ if (AppealsMes.appeals_old != null) {
+ modelDoctor.appealsOldList.value = AppealsMes.appeals_old
+ }
+ }
+ }
+ }
+ } else {
+// finish()
+// val intetn = Intent(this, EnternetActivity::class.java)
+// startActivity(intetn)
+ }
+ }
+
+ //Получения списка пациентов для поиска
+ fun GetPatientListSearch() {
+ if (enternetCheck.isOnline(this)) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(this)
+ CoroutineScope(Dispatchers.IO).launch {
+ val listPatientList = doctorApi.GetPatientAll("Bearer $Tokens")
+
+ runOnUiThread {
+ //Фиксируем полученные данные
+ val patientList = listPatientList.body()
+ //Если нету ошибок
+ if (patientList != null) {
+ modelDoctor.patientListSearch.value = patientList.patient
+ }
+ }
+
+ }
+ } else {
+// finish()
+// val intetn = Intent(this, EnternetActivity::class.java)
+// startActivity(intetn)
+ }
+ }
+
+ //Получения списка пациентов
+ fun GetPatientListYes() {
+ if (enternetCheck.isOnline(this)) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(this)
+ CoroutineScope(Dispatchers.IO).launch {
+ val listProduct = doctorApi.GetPatientAllActive("Bearer $Tokens")
+ runOnUiThread {
+
+ //Фиксируем полученные данные
+ val patientList = listProduct.body()
+
+ //Если нету ошибок
+ if (patientList != null) {
+ modelDoctor.PatientActiveList.value = patientList.patient
+ }
+ }
+
+ }
+ } else {
+// finish()
+// val intetn = Intent(this, EnternetActivity::class.java)
+// startActivity(intetn)
+ }
+ }
+
+ //Получения списка пациентов
+ fun GetPatientListNo() {
+
+ if (enternetCheck.isOnline(this)) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(this)
+ CoroutineScope(Dispatchers.IO).launch {
+ val listProduct = doctorApi.GetPatientAllNotActive("Bearer $Tokens")
+ runOnUiThread {
+
+ //Фиксируем полученные данные
+ val patientList = listProduct.body()
+
+ //Если нету ошибок
+ if (patientList != null) {
+ modelDoctor.PatientNotList.value = patientList.patient
+ }
+ }
+
+ }
+
+ } else {
+// finish()
+// val intetn = Intent(this, EnternetActivity::class.java)
+// startActivity(intetn)
+ }
+ }
+
+// private fun createNotifChannel() {
+// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+// val channel = NotificationChannel(
+// CHANNEL_ID,
+// CHANNEL_NAME,
+// NotificationManager.IMPORTANCE_DEFAULT
+// ).apply {
+// lightColor = Color.BLUE
+// enableLights(true)
+// }
+// val manager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
+// manager.createNotificationChannel(channel)
+// }
+// }
+
+// //Одинарный
+// fun myOneTimeWork() {
+// val constraints = Constraints.Builder()
+// .setRequiredNetworkType(NetworkType.NOT_REQUIRED)//Тут мы указыаем что сработает при наличие интернета
+// .setRequiresCharging(true)
+// .build()
+//
+// //Ограничение
+// val myWorkRequest: WorkRequest =
+// OneTimeWorkRequest.Builder(MyWorker::class.java)//OneTimeWorkRequest - разовая
+// .setConstraints(constraints)
+// .build()
+//
+// WorkManager.getInstance(this@MainActivity).enqueue(myWorkRequest)//Отправка запроса
+// }
+
+// //Повторяющийся
+// fun myPriodicTimeWork() {
+// val constraints = Constraints.Builder()
+// .setRequiredNetworkType(NetworkType.NOT_REQUIRED)//Тут мы указыаем что сработает при наличие интернета
+// .setRequiresCharging(true)
+// .build()
+//
+// //Ограничение
+// val myWorkRequest = PeriodicWorkRequest.Builder(
+// MyWorker::class.java,
+// 15,
+// TimeUnit.MINUTES
+// )//PeriodicWorkRequest - переодически, 15 - время интервала(минимальное 15 минут)
+// .setConstraints(constraints)
+// .addTag("my_id")//Уникальный индификатор для уведомления, для того чтобы можно было кпримеру обратиться и остановать данный менеджер
+// .build()
+//
+// WorkManager.getInstance(this@MainActivity).enqueueUniquePeriodicWork(
+// "my_id",
+// ExistingPeriodicWorkPolicy.KEEP,
+// myWorkRequest
+// )//Отправка запроса
+// }
+
+
fun MainAndAuth() {
- Token = prefDoctorConclusion.conclusionToken(this)
+ Token = prefDoctorConclusion.conclusionToken(this@MainActivity)
//CheckTokenAuth(Token)
if (Token == "") {
Auth()
@@ -61,31 +304,107 @@ class MainActivity : AppCompatActivity() {
}
fun Auth() {
+ binding.CLLoad.visibility = View.GONE
supportFragmentManager.beginTransaction()
.replace(R.id.CLMain, AuthFragment.newInstance())
.commit()
}
fun Main() {
+ binding.CLLoad.visibility = View.GONE
fragment_inicializ()
+
+// fixedRateTimer("timer", false, 0, 10000) {
+// this@MainActivity.runOnUiThread {
+// getNewAppeals()
+// getOldAppeals()
+// GetPatientListSearch()
+// GetPatientListYes()
+// GetPatientListNo()
+// }
+// }
}
- @SuppressLint("SuspiciousIndentation")
- private fun CheckTokenAuth(token: String) {
- CoroutineScope(Dispatchers.IO).launch {
- val response = doctorApi.CheckToken("Bearer $token")
- runOnUiThread {
- val checkToken = response.body()
- val user1 = response.code()
- Log.i("12213213213", user1.toString())
+ @SuppressLint("MissingPermission")
+ private fun main() = with(binding) {
- if (user1.toString() == "200") {
- Main()
- } else {
- Auth()
+// btn11.setOnClickListener {
+// myOneTimeWork()
+// }
+// btn22.setOnClickListener {
+// myPriodicTimeWork()
+// }
+// createNotifChannel()
+// notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
+// val intent = Intent(this@MainActivity, MainActivity::class.java)
+// val pendingIntent = TaskStackBuilder.create(this@MainActivity).run {
+// addNextIntentWithParentStack(intent)
+// getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)
+// }
+//
+// val notif = NotificationCompat.Builder(this@MainActivity, CHANNEL_ID)
+// .setContentTitle("Sample Title")
+// .setContentText("This is sample body notif")
+// .setSmallIcon(R.drawable.door)
+// .setPriority(NotificationCompat.PRIORITY_HIGH)
+// .setContentIntent(pendingIntent)
+// .build()
+//
+//
+// val notifManger = NotificationManagerCompat.from(this@MainActivity)
+// button3.setOnClickListener {
+//
+// notifManger.notify(NOTIF_ID, notif)
+// }
+//
+//
+
+ }
+
+
+ private fun CheckTokenAuth(token: String) {
+ if (enternetCheck.isOnline(this)) {
+ initRetrofit()
+ CoroutineScope(Dispatchers.IO).launch {
+ val response = doctorApi.CheckToken("Bearer $token")
+ runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = response.body()
+ val Nice = response.isSuccessful
+ val Code = response.code()
+ if(Code==429){
+ val intetn = Intent(this@MainActivity, Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (Code.toString() == "200") {
+ Main()
+ } else {
+ Auth()
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(this@MainActivity, Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(this@MainActivity, AuthActivity::class.java)
+ finish()
+ startActivity(intetn)
+ }
}
}
-
+ } else {
+ val intetn = Intent(this, EnternetActivity::class.java)
+ finish()
+ startActivity(intetn)
}
}
@@ -93,6 +412,7 @@ class MainActivity : AppCompatActivity() {
//Инициализируем Retrofit
private fun initRetrofit() {
+
val interceptor = HttpLoggingInterceptor()
interceptor.level = HttpLoggingInterceptor.Level.BODY
@@ -102,7 +422,7 @@ class MainActivity : AppCompatActivity() {
.build()
val retrofit = Retrofit.Builder()
- .baseUrl("http://mobileapp.vmeda.org/api/")
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build()
@@ -137,10 +457,28 @@ class MainActivity : AppCompatActivity() {
// backPressedTime = System.currentTimeMillis()
// }
- override fun onResume() {
- super.onResume()
-
- }
+// override fun onResume() {
+// super.onResume()
+// checkForUpdates(true)
+// }
+//
+//
+// override fun onStop() {
+// super.onStop()
+// timer.cancel()
+// timer.purge()
+// }
+//
+// private fun checkForUpdates(daemonIsTrue: Boolean) {
+// Token = prefDoctorConclusion.conclusionToken(this@MainActivity)
+// timer = fixedRateTimer("default", daemonIsTrue, 0, 5000) {
+// this@MainActivity?.runOnUiThread {
+//
+// CheckTokenAuth(Token)
+// }
+// }
+//
+//}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/MainFragment.kt b/app/src/main/java/com/example/doctor/MainFragment.kt
index 17bee90..aabd73e 100644
--- a/app/src/main/java/com/example/doctor/MainFragment.kt
+++ b/app/src/main/java/com/example/doctor/MainFragment.kt
@@ -2,11 +2,17 @@ package com.example.doctor
import android.annotation.SuppressLint
+import android.icu.text.SimpleDateFormat
+import android.icu.util.Calendar
import android.os.Bundle
+import android.os.SystemClock
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
+import androidx.fragment.app.activityViewModels
+import androidx.lifecycle.Observer
+//import androidx.navigation.fragment.findNavController
import com.example.doctor.Appeals.AppealsFragment
import com.example.doctor.Home.HomeFragment
import com.example.doctor.Patients.PatientsListFragment
@@ -14,20 +20,24 @@ import com.example.doctor.Pref.ConclusionPref
import com.example.doctor.Pref.SavePref
import com.example.doctor.Setting.SettingFragment
import com.example.doctor.databinding.FragmentMainBinding
+import java.util.Date
class MainFragment : Fragment() {
private lateinit var binding: FragmentMainBinding
-
+ private val dataModel: DataModel by activityViewModels()//Для передачи данных
val prefDoctorSave = SavePref()
val prefDoctorConclusion = ConclusionPref()
private var Token = ""
+ var sdf: SimpleDateFormat = SimpleDateFormat("EEEE")
+ var d: Date = Date()
+ var dayOfTheWeek: String = sdf.format(d)
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
- binding = FragmentMainBinding.inflate(layoutInflater,container,false)
+ binding = FragmentMainBinding.inflate(layoutInflater, container, false)
return binding.root
}
@@ -36,7 +46,68 @@ class MainFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)
//MainAndAuth()
+ dataModel.fragmentMenu.observe(viewLifecycleOwner, Observer {
+ binding.buttonNavigation.selectedItemId = it
+ })
+
+ addDate()
+
fragment_inicializ()
+
+
+ }
+
+ private fun addDate() {
+ val calendar: Calendar = Calendar.getInstance()
+ val sdf: SimpleDateFormat = SimpleDateFormat("EEEE")
+ val d: Date = Date()
+ val DayOfTheWeek: String = sdf.format(d)
+ val Day = calendar.get(Calendar.DATE)
+ val Month = calendar.get(Calendar.MONTH).plus(1)
+ var day = Day.toString()
+ var month = ""
+ var date_of_the_week = ""
+
+ when (Month) {
+ 1 -> month = "Январь"
+ 2 -> month = "Февраль"
+ 3 -> month = "Март"
+ 4 -> month = "Апрель"
+ 5 -> month = "Май"
+ 6 -> month = "Июнь"
+ 7 -> month = "Июль"
+ 8 -> month = "Август"
+ 9 -> month = "Сентябрь"
+ 10 -> month = "Октябрь"
+ 11 -> month = "Ноябрь"
+ 12 -> month = "Декабрь"
+ else -> { // обратите внимание на блок
+ month = ""
+ }
+ }
+
+ when (dayOfTheWeek) {
+ "Monday" -> date_of_the_week = "Пн"
+ "Tuesday" -> date_of_the_week = "Вт"
+ "Wednesday" -> date_of_the_week = "Ср"
+ "Thursday" -> date_of_the_week = "Чт"
+ "Friday" -> date_of_the_week = "Пт"
+ "Saturday" -> date_of_the_week = "Сб"
+ "Sunday" -> date_of_the_week = "Вс"
+ "Понедельник" -> date_of_the_week = "Пн"
+ "Вторник" -> date_of_the_week = "Вт"
+ "Стреда" -> date_of_the_week = "Ср"
+ "Четверг" -> date_of_the_week = "Чт"
+ "Пятница" -> date_of_the_week = "Пт"
+ "Суббота" -> date_of_the_week = "Сб"
+ "Воскресенье" -> date_of_the_week = "Вс"
+ else -> {
+ date_of_the_week = ""
+ }
+ }
+
+ System.out.println(calendar.get(Calendar.DATE))
+ binding.txtDate.setText("${day}" + " " + "${month}")
}
// fun MainAndAuth(){
@@ -60,9 +131,9 @@ class MainFragment : Fragment() {
// }
-
//Инициализация фрагментов
fun fragment_inicializ() {
+
Token = prefDoctorConclusion.conclusionToken(requireContext())
//Вывод фрагмента на активити при первоначальной загрузке
activity?.supportFragmentManager?.beginTransaction()
@@ -71,29 +142,43 @@ class MainFragment : Fragment() {
//Эран который будет выбран по умолчанию(кнопка которая будет прожата по умолчанию)
- binding.buttonNavigation.selectedItemId = R.id.home//По умолчанию и так первая, но на всякий случай выберу еще програмным путем первую ячейку
+ binding.buttonNavigation.selectedItemId =
+ R.id.home//По умолчанию и так первая, но на всякий случай выберу еще програмным путем первую ячейку
//Нажатие на bottom navigation
binding.buttonNavigation.setOnItemSelectedListener {
when (it.itemId) {//it.itemId - это id нажатого элемента
R.id.home -> {
- activity?.supportFragmentManager?.beginTransaction()
- ?.replace(R.id.CLMainFragment, HomeFragment.newInstance())?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
- }
- R.id.patient -> {
- activity?.supportFragmentManager?.beginTransaction()
- ?.replace(R.id.CLMainFragment, PatientsListFragment.newInstance())?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
+ if (!isClickRecently()) {
+ activity?.supportFragmentManager?.beginTransaction()
+ ?.replace(R.id.CLMainFragment, HomeFragment.newInstance())
+ ?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
+ }
}
+ R.id.patient -> {
+ if (!isClickRecently()) {
+ activity?.supportFragmentManager?.beginTransaction()
+ ?.replace(R.id.CLMainFragment, PatientsListFragment.newInstance())
+ ?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
+ }
+ }
R.id.list_check -> {//Если вы не авторизованный пользваотель то вам не будет доступен доступ к данном фрагменту
- activity?.supportFragmentManager?.beginTransaction()
- ?.replace(R.id.CLMainFragment, AppealsFragment.newInstance())?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
+ if (!isClickRecently()) {
+ activity?.supportFragmentManager?.beginTransaction()
+ ?.replace(R.id.CLMainFragment, AppealsFragment.newInstance())
+ ?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
+ }
}
+
R.id.setting -> {//Если вы не авторизованный пользваотель то вам не будет доступен доступ к данном фрагменту
- activity?.supportFragmentManager?.beginTransaction()
- ?.replace(R.id.CLMainFragment, SettingFragment.newInstance())?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
+ if (!isClickRecently()) {
+ activity?.supportFragmentManager?.beginTransaction()
+ ?.replace(R.id.CLMainFragment, SettingFragment.newInstance())
+ ?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
+ }
}
}
@@ -101,6 +186,19 @@ class MainFragment : Fragment() {
}
}
+ var mLastClickTime = 0L
+ fun isClickRecently(): Boolean {
+ if (SystemClock.elapsedRealtime() - mLastClickTime < 500) {
+ return true
+ }
+ mLastClickTime = SystemClock.elapsedRealtime()
+ return false
+ }
+
+
+
+
+
companion object {
fun newInstance() = MainFragment()
diff --git a/app/src/main/java/com/example/doctor/Patients/Adapter/PatientListAdapter.kt b/app/src/main/java/com/example/doctor/Patients/Adapter/PatientListAdapter.kt
index 5f2e15f..f611296 100644
--- a/app/src/main/java/com/example/doctor/Patients/Adapter/PatientListAdapter.kt
+++ b/app/src/main/java/com/example/doctor/Patients/Adapter/PatientListAdapter.kt
@@ -43,7 +43,7 @@ class PatientListAdapter(val listener_patient: Listener) :
@SuppressLint("SuspiciousIndentation", "SetTextI18n")
fun bind(item: PatientAllModel) = with(binding) {//Productitem - перпедаем данные
itemTemp = item
- txtNumberCurds.text = item.id.toString() + "."
+ txtNumberCurds.text = item.number.toString() + "."
txtLoginPatient.text = item.login
}
diff --git a/app/src/main/java/com/example/doctor/Patients/Model/PatientAllModel.kt b/app/src/main/java/com/example/doctor/Patients/Model/PatientAllModel.kt
index 65328f9..823d5cb 100644
--- a/app/src/main/java/com/example/doctor/Patients/Model/PatientAllModel.kt
+++ b/app/src/main/java/com/example/doctor/Patients/Model/PatientAllModel.kt
@@ -3,6 +3,7 @@ package com.example.doctor.Patients.Model
import java.util.Date
data class PatientAllModel(
+ val number: Int? = null,
val id: Int? = null,
val login: String? = null,
val email: String? = null,
diff --git a/app/src/main/java/com/example/doctor/Patients/Model/PatientIdModel.kt b/app/src/main/java/com/example/doctor/Patients/Model/PatientIdModel.kt
new file mode 100644
index 0000000..f3d77a6
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Patients/Model/PatientIdModel.kt
@@ -0,0 +1,9 @@
+package com.example.doctor.Patients.Model
+
+import java.util.Date
+
+data class PatientIdModel(
+ val id: Int
+
+)
+
diff --git a/app/src/main/java/com/example/doctor/Patients/PatientActivity.kt b/app/src/main/java/com/example/doctor/Patients/PatientActivity.kt
new file mode 100644
index 0000000..e86ac5f
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Patients/PatientActivity.kt
@@ -0,0 +1,421 @@
+package com.example.doctor.Patients
+
+import android.content.Context
+import android.content.Intent
+import android.net.ConnectivityManager
+import android.net.NetworkCapabilities
+import android.os.Build
+import androidx.appcompat.app.AppCompatActivity
+import android.os.Bundle
+import android.util.Log
+import android.view.View
+import androidx.activity.viewModels
+import androidx.core.content.ContentProviderCompat.requireContext
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
+import com.example.doctor.DoctorViewModel
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
+import com.example.doctor.Patients.Reports.PatientFragment
+import com.example.doctor.Pref.ClearPref
+import com.example.doctor.Pref.ConclusionPref
+import com.example.doctor.Pref.SavePref
+import com.example.doctor.R
+import com.example.doctor.Retrofit.DoctorApi
+import com.example.doctor.databinding.ActivityPatientBinding
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import java.util.Timer
+import kotlin.concurrent.fixedRateTimer
+
+class PatientActivity : AppCompatActivity() {
+ private lateinit var binding: ActivityPatientBinding
+ private lateinit var doctorApi: DoctorApi
+ private lateinit var timer: Timer
+
+
+ val prefDoctorConclusion = ConclusionPref()
+ val prefDoctorClear = ClearPref()
+ val prefDoctorSave = SavePref()
+ private val modelDoctor: DoctorViewModel by viewModels()//Инициализировали класс
+ var idPatient = 0
+
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ binding = ActivityPatientBinding.inflate(layoutInflater)
+ setContentView(binding.root)
+ supportFragmentManager.beginTransaction().replace(R.id.CLPatientActivity, PatientFragment.newInstance()).commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
+ idPatient = prefDoctorConclusion.conclusionIdPatient(this)
+
+
+ }
+
+
+ //Получения списка анкет ДО и ПОСЛЕ для пациента
+ fun QBAPatientList(id:Int){
+ if (enternetCheck.isOnline(this@PatientActivity)) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(this@PatientActivity)
+ CoroutineScope(Dispatchers.IO).launch {
+ val list = doctorApi.GetPatientBAQiestionar("Bearer $Tokens",id)
+ runOnUiThread {
+
+ //Фиксируем полученные данные
+ val List = list.body()
+ val Nice = list.isSuccessful
+ val Code = list.code()
+ if(Code==429){
+ val intetn = Intent(this@PatientActivity, Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ if(List?.questionnaire !=null){
+ modelDoctor.qbaList.value = List.questionnaire
+ }
+ }
+ }
+
+ //2
+ GetPatientID(idPatient)
+
+ }
+ else if (Code == 500) {
+ val intetn = Intent(this@PatientActivity, Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(this@PatientActivity, AuthActivity::class.java)
+ finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ }
+ } else {
+ finish()
+ val intetn = Intent(this, EnternetActivity::class.java)
+ startActivity(intetn)
+ }
+
+ }
+
+ private fun GetPatientID(idPatient: Int) {
+ if (enternetCheck.isOnline(this)) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(this)
+ CoroutineScope(Dispatchers.IO).launch {
+ val listPatient = doctorApi.GetPatientID("Bearer $Tokens", idPatient)
+ runOnUiThread {
+
+ //Фиксируем полученные данные
+ val List = listPatient.body()
+ val Nice = listPatient.isSuccessful
+ val Code = listPatient.code()
+ if(Code==429){
+ val intetn = Intent(this@PatientActivity, Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ modelDoctor.patientCurrent.value = List
+
+ }
+ }
+
+ //3
+ GetCoursesAllSport(idPatient)
+
+ }
+ else if (Code == 500) {
+ val intetn = Intent(this@PatientActivity,Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(this@PatientActivity, AuthActivity::class.java)
+ finish()
+ startActivity(intetn)
+ }
+ }
+
+ }
+ } else {
+ val intetn = Intent(this, EnternetActivity::class.java)
+
+ finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ //Вывод всех курсов
+ fun GetCoursesAllSport(idPatient: Int){
+ if (enternetCheck.isOnline(this)) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(this)
+ CoroutineScope(Dispatchers.IO).launch {
+ val listProduct = doctorApi.GetCoursAllPatient("Bearer $Tokens",idPatient)
+ runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = listProduct.body()
+ val Nice = listProduct.isSuccessful
+ val Code = listProduct.code()
+ if(Code==429){
+ val intetn = Intent(this@PatientActivity, Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ modelDoctor.SportCoursList.value = List.courses
+
+ }
+ }
+
+ //4
+ GetCoursesYouSport(idPatient)
+
+ }
+ else if (Code == 500) {
+ val intetn = Intent(this@PatientActivity, Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(this@PatientActivity, AuthActivity::class.java)
+ finish()
+ startActivity(intetn)
+ }
+ }
+ }
+ } else {
+ val intetn = Intent(this@PatientActivity, EnternetActivity::class.java)
+
+ finish()
+ startActivity(intetn)
+ }
+
+ }
+
+
+ //Получения списка курсов созданных доктором
+ fun GetCoursesYouSport(idPatient:Int) {
+ if (enternetCheck.isOnline(this)) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(this)
+ CoroutineScope(Dispatchers.IO).launch {
+ val listCoursesDoctor = doctorApi.GetCoursesDoctorPatient("Bearer $Tokens",idPatient)
+
+ runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = listCoursesDoctor.body()
+ val Nice = listCoursesDoctor.isSuccessful
+ val Code = listCoursesDoctor.code()
+ if(Code==429){
+ val intetn = Intent(this@PatientActivity, Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ modelDoctor.SportCoursDoctorList.value = List.courses_doctor
+
+ }
+ }
+
+ //5
+ GetCoursesSportYes(idPatient)
+
+ }
+ else if (Code == 500) {
+ val intetn = Intent(this@PatientActivity, Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(this@PatientActivity, AuthActivity::class.java)
+ finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ }
+ } else {
+ val intetn = Intent(this, EnternetActivity::class.java)
+
+ finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ //Получения списка пациентов
+ fun GetCoursesSportYes(id_patient:Int) {
+ if (enternetCheck.isOnline(this)) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(this)
+ CoroutineScope(Dispatchers.IO).launch {
+ val sportEdit = doctorApi.GetCoursesSportYes("Bearer $Tokens", id_patient)
+ runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = sportEdit.body()
+ val Nice = sportEdit.isSuccessful
+ val Code = sportEdit.code()
+ if(Code==429){
+ val intetn = Intent(this@PatientActivity, Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ modelDoctor.EditSportListYes.value = List.set_of_sports_exercises_yes
+
+ }
+ }
+ //6
+ GetCoursesSportNo(idPatient)
+ }
+ else if (Code == 500) {
+ val intetn = Intent(this@PatientActivity, Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(this@PatientActivity, AuthActivity::class.java)
+ finish()
+ startActivity(intetn)
+ }
+ }
+
+ }
+ } else {
+ val intetn = Intent(this, EnternetActivity::class.java)
+
+ finish()
+ startActivity(intetn)
+ }
+
+ }
+ //Получения списка пациентов
+ fun GetCoursesSportNo(id_patient:Int) {
+ if (enternetCheck.isOnline(this)) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(this)
+ CoroutineScope(Dispatchers.IO).launch {
+ val sportEdit = doctorApi.GetCoursesSportNo("Bearer $Tokens",id_patient)
+ runOnUiThread {
+
+ //Фиксируем полученные данные
+ val List = sportEdit.body()
+ val Nice = sportEdit.isSuccessful
+ val Code = sportEdit.code()
+ if(Code==429){
+ val intetn = Intent(this@PatientActivity, Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ modelDoctor.EditSportListNo.value = List.set_of_sports_exercises_no
+
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(this@PatientActivity, Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(this@PatientActivity, AuthActivity::class.java)
+ finish()
+ startActivity(intetn)
+ }
+ }
+
+ }
+ } else {
+ val intetn = Intent(this, EnternetActivity::class.java)
+ finish()
+
+ startActivity(intetn)
+ }
+
+ }
+
+ //Инициализируем Retrofit
+ private fun initRetrofit() {
+ val interceptor = HttpLoggingInterceptor()
+ interceptor.level = HttpLoggingInterceptor.Level.BODY
+
+ val client = OkHttpClient
+ .Builder()
+ .addInterceptor(interceptor)
+ .build()
+
+ val retrofit = Retrofit.Builder()
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
+ .client(client)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+
+ doctorApi = retrofit.create(DoctorApi::class.java)
+
+ }
+
+ override fun onResume() {
+ super.onResume()
+ checkForUpdates(true)
+ }
+
+ override fun onStop() {
+ super.onStop()
+ timer.cancel()
+ timer.purge()
+ }
+
+ private fun checkForUpdates(daemonIsTrue: Boolean) {
+
+ timer = fixedRateTimer("default", daemonIsTrue, 0, 10000) {
+ this@PatientActivity?.runOnUiThread {
+ QBAPatientList(idPatient)
+
+ }
+ }
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Patients/PatientsListFragment.kt b/app/src/main/java/com/example/doctor/Patients/PatientsListFragment.kt
index a7c044d..1c9934e 100644
--- a/app/src/main/java/com/example/doctor/Patients/PatientsListFragment.kt
+++ b/app/src/main/java/com/example/doctor/Patients/PatientsListFragment.kt
@@ -1,7 +1,5 @@
package com.example.doctor.Patients
-//noinspection SuspiciousImport
-import android.R
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
@@ -9,16 +7,38 @@ import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import androidx.fragment.app.activityViewModels
-import androidx.recyclerview.widget.GridLayoutManager
import com.example.doctor.DoctorViewModel
-import com.example.doctor.Patients.Adapter.PatientListAdapter
import com.example.doctor.Patients.Model.PatientAllModel
-import com.example.doctor.Patients.Model.PatientModel
import com.example.doctor.Patients.Reports.PatientFragment
import com.example.doctor.Pref.ConclusionPref
+import android.R
+import android.content.Context
+import android.content.Intent
+import android.net.ConnectivityManager
+import android.net.NetworkCapabilities
+import android.os.Build
+import android.os.Handler
+import android.util.Log
+import androidx.fragment.app.FragmentActivity
+import androidx.lifecycle.Observer
+//import androidx.navigation.fragment.findNavController
+
+import com.example.doctor.Adapter.VpAdapterPatientList
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
+import com.example.doctor.DataModel
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
+import com.example.doctor.MainActivity
+import com.example.doctor.Patients.TabLayoutPatient.ActiveCoursesPatientFragment
+import com.example.doctor.Patients.TabLayoutPatient.NotActiveCoursesPatientFragment
+import com.example.doctor.Pref.ClearPref
+import com.example.doctor.Pref.SavePref
import com.example.doctor.Retrofit.DoctorApi
import com.example.doctor.databinding.FragmentPatientsListBinding
import com.example.user.BottomSheetMenu.NoteBottomSheetMenu
+import com.google.android.material.tabs.TabLayoutMediator
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -26,17 +46,37 @@ import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
+import java.util.Timer
+import kotlin.concurrent.fixedRateTimer
-class PatientsListFragment : Fragment(), PatientListAdapter.Listener {
+class PatientsListFragment : Fragment(){
private lateinit var binding: FragmentPatientsListBinding
- private val model: DoctorViewModel by activityViewModels()
- lateinit var adapterPatient: PatientListAdapter
+ private val modelDoctor: DoctorViewModel by activityViewModels()
+ private val dataModel: DataModel by activityViewModels()//Для передачи данных
private lateinit var doctorApi: DoctorApi
+ private lateinit var timer: Timer
+
+
val prefDoctorConclusion = ConclusionPref()
+ val prefDoctorClear = ClearPref()
+ val prefDoctorSave = SavePref()
+ var viewListPAtient = true
+ var patientListSearch:List?=null
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
+ private val tList = listOf(
+ "Активные",
+ "Без курса",
+ )
+ //Список с фрагментами для переключения
+ private val flist = listOf(
+ ActiveCoursesPatientFragment.newInstance(),
+ NotActiveCoursesPatientFragment.newInstance(),
+ )
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
@@ -47,54 +87,116 @@ class PatientsListFragment : Fragment(), PatientListAdapter.Listener {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- initRcViewDay()
- patientListCurrent()
- GetPatientList()
+ //Чтобы срабатывала команда 1 раз
+ if(viewListPAtient){
+ GetPatientList()
+ init()
+
+ //Нажатие на кнопку для добавления пациента
+ binding.btnAddPatient.setOnClickListener {
+ val noteBottomSheetMenu = NoteBottomSheetMenu.newInstance()
+ noteBottomSheetMenu.show(
+ requireActivity().supportFragmentManager,
+ "Note Bottom Sheet Fragment"
+ )
+ }
-
-
-// //Swipe down
-// binding.refreshLayout.setOnRefreshListener{
-// GetPatientList()
-// binding.refreshLayout.isRefreshing = false
-// }
-
-
- //Нажатие на кнопку заказать заказ
- binding.btnAddPatient.setOnClickListener {
- val noteBottomSheetMenu = NoteBottomSheetMenu.newInstance()
- noteBottomSheetMenu.show(
- requireActivity().supportFragmentManager,
- "Note Bottom Sheet Fragment"
- )
+ }
+ modelDoctor.patientListSearch.observe(viewLifecycleOwner){
+ if(patientListSearch!=it){
+ patientListSearch = it
+ addListSerchPatient(it)
+ }
}
}
+ //Функция подключения переключения
+ private fun init() = with(binding) {
+ val adapter = VpAdapterPatientList(activity as FragmentActivity, flist as List)
+ vpPatient.adapter = adapter
+
+ //Переключения (связываем таблаяут(переключатель) с viewpager, чтобы переключать фрагменты)
+ TabLayoutMediator(tabLayoutPatient, vpPatient) { tab, pos ->
+ tab.text =
+ tList[pos]//tab - нажатая кнопка, pos - позиция кнопки, tList[pos] - передаем название по полученной позиции
+ }.attach()// attach() - чтобы все переключалось, а не вывадило постоянно один экран
+
+ //Изменения цвета в зависомости на каком из tabLayout вы находитесь
+ binding.tabLayoutPatient.setTabTextColors(getResources().getColor(com.example.doctor.R.color.black),
+ getResources().getColor(com.example.doctor.R.color.white));
+
+
+ }
+
+// private fun viewPatient() {
+// val viewPatient = prefDoctorConclusion.conclusionViewPatient(requireContext())
+// val idPatient = prefDoctorConclusion.conclusionIdPatient(requireContext())
+// Log.i("viewPatient1",viewPatient.toString())
+// Log.i("idPatient1",viewPatient.toString())
+// if(viewPatient ==1 && idPatient !=0){
+// GetPatientID(idPatient)
+// prefDoctorClear.clearIdPatient(requireContext())
+// prefDoctorClear.clearViewPatient(requireContext())
+// Log.i("viewPatient2",viewPatient.toString())
+// Log.i("idPatient2",viewPatient.toString())
+// }
+// }
+
//Получения списка пациентов
fun GetPatientList() {
- initRetrofit()
- val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
- CoroutineScope(Dispatchers.IO).launch {
- val listProduct = doctorApi.GetPatientAll("Bearer $Tokens")
- requireActivity().runOnUiThread {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listPatientList = doctorApi.GetPatientAll("Bearer $Tokens")
- //Фиксируем полученные данные
- val patientList = listProduct.body()
+ requireActivity().runOnUiThread {
- //Если нету ошибок
- if (patientList != null) {
- adapterPatient.submitList(patientList.patient)
- //model.patientListList.value = patientList.PatientList
- addListSerchPatient(patientList.patient)
+ //Фиксируем полученные данные
+ val List = listPatientList.body()
+ val Nice = listPatientList.isSuccessful
+ val Code = listPatientList.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ modelDoctor.patientListSearch.value = List?.patient
+
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
}
- }
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
}
+
}
+
+
+
private fun addListSerchPatient(patient: List) {
val listPatient = arrayListOf("")
for(i in 0 .. patient.count()-1){
@@ -110,31 +212,31 @@ class PatientsListFragment : Fragment(), PatientListAdapter.Listener {
val serpat = binding.searchPatient.text.toString()
//Вывод фрагмента на активити при первоначальной загрузке
- activity?.supportFragmentManager?.beginTransaction()
- ?.replace(com.example.doctor.R.id.CLMainListPatient, PatientFragment.newInstance())
- ?.commit()
+
+// ///////// activity?.supportFragmentManager?.beginTransaction()
+// ///////// ?.replace(com.example.doctor.R.id.CLMainPatient, PatientFragment.newInstance())
+// ///////////// ?.addToBackStack(null)
+// /////////// ?.commit()
- binding.CLMainListPatient2.visibility = View.GONE
+
+ //binding.CLMainListPatient2.visibility = View.GONE
//Ищем пациента по логину
for(i in 0 ..patient.count()-1) {
if(patient[i].login == serpat){
- model.patientCurrent.value = patient[i]
+ modelDoctor.patientCurrent.value = patient[i]
+ prefDoctorSave.saveIdPatient(requireContext(),patient[i].id!!)
+ prefDoctorSave.saveViewPatient(requireContext(),1)
+ val intetn = Intent(requireContext(), PatientActivity::class.java)
+ startActivity(intetn)
}
}
}
-
}
- //Вывод прогресса на один день
- private fun patientListCurrent() = with(binding) {
-// model.patientListCurrent.observe(viewLifecycleOwner) {//viewLifecycleOwner - следит за циклом жизни fragment
-//
-// }
- }
//Инициализируем Retrofit
private fun initRetrofit() {
@@ -147,7 +249,7 @@ class PatientsListFragment : Fragment(), PatientListAdapter.Listener {
.build()
val retrofit = Retrofit.Builder()
- .baseUrl("http://mobileapp.vmeda.org/api/")
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build()
@@ -156,27 +258,33 @@ class PatientsListFragment : Fragment(), PatientListAdapter.Listener {
}
- //Инициализация списка
- private fun initRcViewDay() = with(binding) {
- rcView.layoutManager =
- GridLayoutManager(requireContext(), 1)//По вертикали будет выводить по умолчанию
- adapterPatient = PatientListAdapter(this@PatientsListFragment)
- rcView.adapter = adapterPatient
- }
companion object {
fun newInstance() = PatientsListFragment()
}
- override fun onClickPatient(item: PatientAllModel) {
- //Вывод фрагмента на активити при первоначальной загрузке
- activity?.supportFragmentManager?.beginTransaction()
- ?.replace(com.example.doctor.R.id.CLMainListPatient, PatientFragment.newInstance())
- ?.commit()
- //binding.rcView.visibility = View.GONE
- binding.CLMainListPatient2.visibility = View.GONE
- model.patientCurrent.value = item
+ override fun onResume() {
+ super.onResume()
+ checkForUpdates(true)
+ }
+
+ override fun onStop() {
+ super.onStop()
+ timer.cancel()
+ timer.purge()
+ }
+
+ private fun checkForUpdates(daemonIsTrue: Boolean) {
+
+ timer = fixedRateTimer("default", daemonIsTrue, 0, 10000) {
+ activity?.runOnUiThread {
+ GetPatientList()
+ }
+ }
}
+
+
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Patients/Reports/Courses/CoursesAllAdapter.kt b/app/src/main/java/com/example/doctor/Patients/Reports/Courses/CoursesAllAdapter.kt
new file mode 100644
index 0000000..a11ed2f
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Patients/Reports/Courses/CoursesAllAdapter.kt
@@ -0,0 +1,90 @@
+package com.example.doctor.Patients.Reports.Courses
+
+import android.annotation.SuppressLint
+import android.graphics.Color
+import android.util.Log
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.recyclerview.widget.DiffUtil
+import androidx.recyclerview.widget.ListAdapter
+import androidx.recyclerview.widget.RecyclerView
+import com.example.doctor.R
+import com.example.doctor.databinding.ItemCardCoursesDoctorBinding
+import com.example.doctor.databinding.ItemSportCourseBinding
+
+
+class CoursesAllAdapter(val listener_courses: Listener) : ListAdapter(
+ Comparator()
+) {//Productitem - по этой форме будем заполнять.//ProductAdapter.holder - это создаваемый holder который хранит логику как нужно заполнять карточку
+
+
+ //В holder создаетс код с помошью которого мы будем заполнять и сохронять разметку
+ class Holder(view: View, val listener_courses: Listener): RecyclerView.ViewHolder(view) {//Класс который будет хранить сссылки на элементы, и отвечает за один элемент за 1 раз, то есть сначсало нулевой элемент заполнит, потом первый, потом второй и т.д.
+ //Для передачи данных
+
+ val binding = ItemCardCoursesDoctorBinding.bind(view)//view - здесь храянтся элементы и мы их bind заполним в ListItemBinding//ListItemBinding - это клласс даннйо разметки(карточки) которую мы будем заполнять, а нужна дання переменная(binding), чтобы мжно было при заполнение обращатся к элементам карточки
+
+ var itemTemp: SportCoursModel? =
+ null//Глобальная переменная для нашего item, чтобы можно было передать данные для нажатия
+
+ //init - дает возможность внутри адаптера обращаться к элементам экрана
+ init {
+ itemView.setOnClickListener {//Нажатие на ячейку//itemView - это весь элемент карточки из списка
+ //itemView.setEnabled(false)
+ //timerButtonDoubleButton(itemView)
+ itemTemp?.let { it1 -> listener_courses.onClickSportCourses(it1) }
+
+ }
+ }
+
+
+ @SuppressLint("SuspiciousIndentation")
+ fun bind(item: SportCoursModel) = with(binding) {//Productitem - перпедаем данные
+ itemTemp = item
+ txtNumberCurds.text = item.number.toString() + "."
+ txtNameCoursesDoctor.text = item.name
+ if (item.visibility == 100000) {
+ CVCours.setCardBackgroundColor(Color.parseColor("#83da83"))
+ Log.i("11111111111","sasdasdasdasdasadsdasda")
+ } else {
+ CVCours.setCardBackgroundColor(Color.parseColor("#b6b6b6"))
+ Log.i("2222222222222","sasdasdasdasdasadsdasda")
+ }
+ }
+ }
+
+
+
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
+ val view = LayoutInflater.from(parent.context).inflate(R.layout.item_card_courses_doctor, parent, false)//Создаем(надуваем) list_item
+ return Holder(view, listener_courses)//Через Holder возврощаем view
+ }
+
+ override fun onBindViewHolder(holder: Holder, position: Int) {
+ val view = holder.bind(getItem(position))//Заполняем по позиции карточку
+ }
+
+
+ //Comparator - сравнивает старый список и новый и если что-то изменилось, то работает с конкретным изменением списке, а не весь список переписывает
+ class Comparator : DiffUtil.ItemCallback() {
+ override fun areItemsTheSame(oldItem: SportCoursModel, newItem: SportCoursModel): Boolean {//Тут лучше всего сравнивать по id//oldItem - элементы старого списка, newItem - элементы нового списка//Возврощает Boolean, тоесть есть изменения или нет
+ return oldItem.id == newItem.id//Сравниваем полностью весь список новы и старый, по очередно по одной карточке и по элементно, то есть нулевой элемент, первый, второй и т.д.. Но лучше сравнивать по id списки, а не просто весь список, так как это эфективнее, так как id уникальный(oldItem.id == newItem.id)
+ }
+
+ override fun areContentsTheSame(oldItem: SportCoursModel, newItem: SportCoursModel): Boolean {//Утут нужно сравнивать весь спсок старых элементов и новых
+ return oldItem == newItem//Сравниваем полностью весь список новы и старый
+ }
+ }
+
+ //Интерфейс нажатия на кнопку удалить товар из корзины
+ interface Listener {
+ fun onClickSportCourses(item: SportCoursModel)
+ }
+
+
+}
+
+
+
+
diff --git a/app/src/main/java/com/example/doctor/Patients/Reports/Courses/CoursesYouAdapter.kt b/app/src/main/java/com/example/doctor/Patients/Reports/Courses/CoursesYouAdapter.kt
new file mode 100644
index 0000000..47df774
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Patients/Reports/Courses/CoursesYouAdapter.kt
@@ -0,0 +1,99 @@
+package com.example.doctor.Patients.Reports.Courses
+
+import android.annotation.SuppressLint
+import android.graphics.Color
+import android.util.Log
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.recyclerview.widget.DiffUtil
+import androidx.recyclerview.widget.ListAdapter
+import androidx.recyclerview.widget.RecyclerView
+
+import com.example.doctor.R
+import com.example.doctor.Setting.Courses.Model.CoursesDoctorModel
+import com.example.doctor.databinding.ItemCardCoursesDoctorBinding
+
+
+class CoursesYouAdapter(val listener: Listener) :
+ ListAdapter(
+ Comparator()
+ ) {//Productitem - по этой форме будем заполнять.//ProductAdapter.holder - это создаваемый holder который хранит логику как нужно заполнять карточку
+
+
+ //В holder создаетс код с помошью которого мы будем заполнять и сохронять разметку
+ class Holder(view: View, val listener: Listener) :
+ RecyclerView.ViewHolder(view) {//Класс который будет хранить сссылки на элементы, и отвечает за один элемент за 1 раз, то есть сначсало нулевой элемент заполнит, потом первый, потом второй и т.д.
+ //Для передачи данных
+
+ val binding = ItemCardCoursesDoctorBinding.bind(view)//view - здесь храянтся элементы и мы их bind заполним в ListItemBinding//ListItemBinding - это клласс даннйо разметки(карточки) которую мы будем заполнять, а нужна дання переменная(binding), чтобы мжно было при заполнение обращатся к элементам карточки
+
+ var itemTemp: SportCoursModel? =
+ null//Глобальная переменная для нашего item, чтобы можно было передать данные для нажатия
+
+ //init - дает возможность внутри адаптера обращаться к элементам экрана
+ init {
+ itemView.setOnClickListener {//Нажатие на ячейку//itemView - это весь элемент карточки из списка
+ //itemView.setEnabled(false)
+ itemTemp?.let { it1 -> listener.onClickCourses(it1) }
+
+ }
+ }
+
+ @SuppressLint("SuspiciousIndentation", "SetTextI18n")
+ fun bind(item: SportCoursModel) = with(binding) {//Productitem - перпедаем данные
+ itemTemp = item
+ txtNumberCurds.text = item.number.toString() + "."
+ txtNameCoursesDoctor.text = item.name
+ if (item.visibility == 100000) {
+ CVCours.setCardBackgroundColor(Color.parseColor("#83da83"))
+ Log.i("11111111111","sasdasdasdasdasadsdasda")
+ } else {
+ CVCours.setCardBackgroundColor(Color.parseColor("#b6b6b6"))
+ Log.i("2222222222222","sasdasdasdasdasadsdasda")
+ }
+ }
+
+
+ }
+
+
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
+ val view = LayoutInflater.from(parent.context)
+ .inflate(R.layout.item_card_courses_doctor, parent, false)//Создаем(надуваем) list_item
+ return Holder(view, listener)//Через Holder возврощаем view
+ }
+
+ override fun onBindViewHolder(holder: Holder, position: Int) {
+ val view = holder.bind(getItem(position))//Заполняем по позиции карточку
+ }
+
+
+ //Comparator - сравнивает старый список и новый и если что-то изменилось, то работает с конкретным изменением списке, а не весь список переписывает
+ class Comparator : DiffUtil.ItemCallback() {
+ override fun areItemsTheSame(
+ oldItem: SportCoursModel,
+ newItem: SportCoursModel
+ ): Boolean {//Тут лучше всего сравнивать по id//oldItem - элементы старого списка, newItem - элементы нового списка//Возврощает Boolean, тоесть есть изменения или нет
+ return oldItem.id == newItem.id//Сравниваем полностью весь список новы и старый, по очередно по одной карточке и по элементно, то есть нулевой элемент, первый, второй и т.д.. Но лучше сравнивать по id списки, а не просто весь список, так как это эфективнее, так как id уникальный(oldItem.id == newItem.id)
+ }
+
+ override fun areContentsTheSame(
+ oldItem: SportCoursModel,
+ newItem: SportCoursModel
+ ): Boolean {//Утут нужно сравнивать весь спсок старых элементов и новых
+ return oldItem == newItem//Сравниваем полностью весь список новы и старый
+ }
+ }
+
+ //Интерфейс нажатия на кнопку удалить товар из корзины
+ interface Listener {
+ fun onClickCourses(item: SportCoursModel)
+ }
+
+
+}
+
+
+
+
diff --git a/app/src/main/java/com/example/doctor/Patients/Reports/Courses/SportCoursDoctorListModel.kt b/app/src/main/java/com/example/doctor/Patients/Reports/Courses/SportCoursDoctorListModel.kt
new file mode 100644
index 0000000..b22c6af
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Patients/Reports/Courses/SportCoursDoctorListModel.kt
@@ -0,0 +1,6 @@
+package com.example.doctor.Patients.Reports.Courses
+
+data class SportCoursDoctorListModel(
+ val courses_doctor: List
+ )
+
diff --git a/app/src/main/java/com/example/doctor/Patients/Reports/SportCoursListModel.kt b/app/src/main/java/com/example/doctor/Patients/Reports/Courses/SportCoursListModel.kt
similarity index 60%
rename from app/src/main/java/com/example/doctor/Patients/Reports/SportCoursListModel.kt
rename to app/src/main/java/com/example/doctor/Patients/Reports/Courses/SportCoursListModel.kt
index 6e1c7c3..15a4de1 100644
--- a/app/src/main/java/com/example/doctor/Patients/Reports/SportCoursListModel.kt
+++ b/app/src/main/java/com/example/doctor/Patients/Reports/Courses/SportCoursListModel.kt
@@ -1,4 +1,4 @@
-package com.example.doctor.Patients.Reports
+package com.example.doctor.Patients.Reports.Courses
data class SportCoursListModel(
val courses: List
diff --git a/app/src/main/java/com/example/doctor/Patients/Reports/SportCoursModel.kt b/app/src/main/java/com/example/doctor/Patients/Reports/Courses/SportCoursModel.kt
similarity index 70%
rename from app/src/main/java/com/example/doctor/Patients/Reports/SportCoursModel.kt
rename to app/src/main/java/com/example/doctor/Patients/Reports/Courses/SportCoursModel.kt
index 3f5c927..3bd8b3c 100644
--- a/app/src/main/java/com/example/doctor/Patients/Reports/SportCoursModel.kt
+++ b/app/src/main/java/com/example/doctor/Patients/Reports/Courses/SportCoursModel.kt
@@ -1,11 +1,11 @@
-package com.example.doctor.Patients.Reports
+package com.example.doctor.Patients.Reports.Courses
data class SportCoursModel(
+ val number: Int,
val id: Int,
val name: String,
val description: String,
val visibility: Int,
val created_at: String,
val updated_at: String,
- )
-
+)
diff --git a/app/src/main/java/com/example/doctor/Patients/Reports/Courses/TabLayout/CoursesAllFragment.kt b/app/src/main/java/com/example/doctor/Patients/Reports/Courses/TabLayout/CoursesAllFragment.kt
new file mode 100644
index 0000000..2a99427
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Patients/Reports/Courses/TabLayout/CoursesAllFragment.kt
@@ -0,0 +1,204 @@
+package com.example.doctor.Patients.Reports.Courses.TabLayout
+
+import android.content.Intent
+import android.os.Bundle
+import androidx.fragment.app.Fragment
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.Toast
+import androidx.fragment.app.activityViewModels
+import androidx.recyclerview.widget.GridLayoutManager
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
+import com.example.doctor.DoctorViewModel
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
+import com.example.doctor.Patients.Reports.Courses.CoursesAllAdapter
+import com.example.doctor.Patients.Reports.Courses.SportCoursModel
+import com.example.doctor.Patients.Reports.CoursesListAdapter
+import com.example.doctor.Pref.ClearPref
+import com.example.doctor.Pref.ConclusionPref
+import com.example.doctor.Pref.SavePref
+import com.example.doctor.R
+import com.example.doctor.Retrofit.DoctorApi
+import com.example.doctor.Toast.showCustomInfoToast
+import com.example.doctor.databinding.FragmentCoursesAllBinding
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+
+class CoursesAllFragment : Fragment(),CoursesAllAdapter.Listener {
+ private lateinit var binding: FragmentCoursesAllBinding
+ private val modelDoctor: DoctorViewModel by activityViewModels()
+ lateinit var adapterCours: CoursesAllAdapter
+ private lateinit var doctorApi: DoctorApi
+ val prefDoctorConclusion = ConclusionPref()
+ val prefDoctorClear = ClearPref()
+ val prefDoctorSave = SavePref()
+ var sportCourses:List?=null
+ var id: Int? = null
+
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ binding = FragmentCoursesAllBinding.inflate(layoutInflater,container,false)
+ return binding.root
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ initRcViewCours()
+ modelDoctor.id_patient.observe(viewLifecycleOwner){
+ id = it
+ GetAllCoursesSport()
+ }
+
+ modelDoctor.SportCoursList.observe(viewLifecycleOwner) {//viewLifecycleOwner - следит за циклом жизни fragment
+ if(sportCourses != it){
+ sportCourses = it
+ adapterCours.submitList(it)//Напрямую переадем созданный список в adapter(ProductAdapter)
+ binding.txtNull.visibility = View.GONE
+ }
+ }
+ }
+
+ //Вывод всех курсов
+ fun GetAllCoursesSport(){
+ if (enternetCheck.isOnline(requireContext())) {
+ binding.txtNull.visibility = View.VISIBLE
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listProduct = doctorApi.GetCoursAllPatient("Bearer $Tokens",id!!)
+ requireActivity().runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = listProduct.body()
+ val Nice = listProduct.isSuccessful
+ val Code = listProduct.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ modelDoctor.SportCoursList.value = List.courses
+ binding.txtNull.visibility = View.GONE
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ }
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ //Инициализируем Retrofit
+ private fun initRetrofit() {
+ val interceptor = HttpLoggingInterceptor()
+ interceptor.level = HttpLoggingInterceptor.Level.BODY
+
+ val client = OkHttpClient
+ .Builder()
+ .addInterceptor(interceptor)
+ .build()
+
+ val retrofit = Retrofit.Builder()
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
+ .client(client)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+
+ doctorApi = retrofit.create(DoctorApi::class.java)
+
+ }
+
+ //Инициализация списка
+ private fun initRcViewCours() = with(binding) {
+ rcView.layoutManager = GridLayoutManager(requireContext(), 1)//По вертикали будет выводить по умолчанию
+ adapterCours = CoursesAllAdapter(this@CoursesAllFragment)
+ rcView.adapter = adapterCours
+ }
+
+ companion object {
+ fun newInstance() = CoursesAllFragment()
+ }
+
+ override fun onClickSportCourses(item: SportCoursModel) {
+ AddSportPatient(id!!,item.id,14)
+ GetAllCoursesSport()
+ }
+
+ fun AddSportPatient(id_patient:Int,id_course:Int,all_day:Int){
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val updatePassword= doctorApi.AddSportPatient("Bearer $Tokens",id_patient,id_course,all_day)
+ requireActivity().runOnUiThread {
+ //Фиксируем полученные данные
+ val List = updatePassword.body()
+ val Nice = updatePassword.isSuccessful
+ val Code = updatePassword.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
+ GetAllCoursesSport()
+ modelDoctor.BtnSportCoursDoctorCurrent.value = 2
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ }
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Patients/Reports/Courses/TabLayout/CoursesYouFragment.kt b/app/src/main/java/com/example/doctor/Patients/Reports/Courses/TabLayout/CoursesYouFragment.kt
new file mode 100644
index 0000000..f955a65
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Patients/Reports/Courses/TabLayout/CoursesYouFragment.kt
@@ -0,0 +1,208 @@
+package com.example.doctor.Patients.Reports.Courses.TabLayout
+
+import android.content.Intent
+import android.os.Bundle
+import androidx.fragment.app.Fragment
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.Toast
+import androidx.fragment.app.activityViewModels
+import androidx.recyclerview.widget.GridLayoutManager
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
+import com.example.doctor.DoctorViewModel
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
+import com.example.doctor.Patients.Reports.Courses.CoursesYouAdapter
+import com.example.doctor.Patients.Reports.Courses.SportCoursModel
+import com.example.doctor.Pref.ClearPref
+import com.example.doctor.Pref.ConclusionPref
+import com.example.doctor.Pref.SavePref
+import com.example.doctor.Retrofit.DoctorApi
+import com.example.doctor.Setting.Courses.Model.CoursesDoctorModel
+import com.example.doctor.Toast.showCustomInfoToast
+import com.example.doctor.databinding.FragmentCoursesYouBinding
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+
+class CoursesYouFragment : Fragment(),CoursesYouAdapter.Listener {
+ private lateinit var binding:FragmentCoursesYouBinding
+ private val modelDoctor: DoctorViewModel by activityViewModels()
+ lateinit var adapterCours: CoursesYouAdapter
+ private lateinit var doctorApi: DoctorApi
+ val prefDoctorConclusion = ConclusionPref()
+ val prefDoctorClear = ClearPref()
+ val prefDoctorSave = SavePref()
+ var sportCoursesDoctor:List?=null
+ var id: Int? = null
+
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ binding = FragmentCoursesYouBinding.inflate(layoutInflater,container,false)
+ return binding.root
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ initRcViewCours()
+
+ modelDoctor.id_patient.observe(viewLifecycleOwner){
+ id = it
+ GetCoursesDoctor()
+ }
+
+ modelDoctor.SportCoursDoctorList.observe(viewLifecycleOwner){
+ if(sportCoursesDoctor!=it){
+ sportCoursesDoctor = it
+ adapterCours.submitList(it)
+ binding.txtNull.visibility = View.GONE
+ }
+ }
+ }
+
+ //Получения списка курсов созданных доктором
+ fun GetCoursesDoctor() {
+ if (enternetCheck.isOnline(requireContext())) {
+ binding.txtNull.visibility = View.VISIBLE
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listCoursesDoctor = doctorApi.GetCoursesDoctorPatient("Bearer $Tokens",id!!)
+
+ requireActivity().runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = listCoursesDoctor.body()
+ val Nice = listCoursesDoctor.isSuccessful
+ val Code = listCoursesDoctor.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ modelDoctor.SportCoursDoctorList.value = List.courses_doctor
+ binding.txtNull.visibility = View.GONE
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+ //Инициализируем Retrofit
+ private fun initRetrofit() {
+ val interceptor = HttpLoggingInterceptor()
+ interceptor.level = HttpLoggingInterceptor.Level.BODY
+
+ val client = OkHttpClient
+ .Builder()
+ .addInterceptor(interceptor)
+ .build()
+
+ val retrofit = Retrofit.Builder()
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
+ .client(client)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+
+ doctorApi = retrofit.create(DoctorApi::class.java)
+
+ }
+ //Инициализация списка
+ private fun initRcViewCours() = with(binding) {
+ rcView.layoutManager = GridLayoutManager(requireContext(), 1)//По вертикали будет выводить по умолчанию
+ adapterCours = CoursesYouAdapter(this@CoursesYouFragment)
+ rcView.adapter = adapterCours
+ }
+
+ companion object {
+ fun newInstance() = CoursesYouFragment()
+ }
+
+
+
+ override fun onClickCourses(item: SportCoursModel) {
+ AddSportPatient(id!!,item.id,14)
+ GetCoursesDoctor()
+ }
+
+ fun AddSportPatient(id_patient:Int,id_course:Int,all_day:Int){
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val updatePassword= doctorApi.AddSportPatient("Bearer $Tokens",id_patient,id_course,all_day)
+ requireActivity().runOnUiThread {
+
+ //Фиксируем полученные данные
+ val List = updatePassword.body()
+ val Nice = updatePassword.isSuccessful
+ val Code = updatePassword.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
+ GetCoursesDoctor()
+ modelDoctor.BtnSportCoursDoctorCurrent.value = 2
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ }
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Patients/Reports/CoursesAdapter.kt b/app/src/main/java/com/example/doctor/Patients/Reports/CoursesAdapter.kt
deleted file mode 100644
index 98d641c..0000000
--- a/app/src/main/java/com/example/doctor/Patients/Reports/CoursesAdapter.kt
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.example.doctor.Patients.Reports
-
-import android.annotation.SuppressLint
-import android.graphics.Color
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import androidx.recyclerview.widget.DiffUtil
-import androidx.recyclerview.widget.ListAdapter
-import androidx.recyclerview.widget.RecyclerView
-import com.example.doctor.Patients.Reports.Edit.EditSportModel
-import com.example.doctor.Patients.Reports.Edit.EditSportNoAdapter
-import com.example.doctor.R
-import com.example.doctor.databinding.ItemQbaBinding
-import com.example.doctor.databinding.ItemSportCourseBinding
-
-
-class CoursesAdapter(val listener_cours: CoursesAdapter.Listener) : ListAdapter(Comparator()) {
- class Holder(view: View,val listener_cours: CoursesAdapter.Listener) :
- RecyclerView.ViewHolder(view) {
-
- val binding = ItemSportCourseBinding.bind(view)
-
- var itemTemp: SportCoursModel? =
- null//Глобальная переменная для нашего item, чтобы можно было передать данные для нажатия
-
- //init - дает возможность внутри адаптера обращаться к элементам экрана
- init {
- itemView.setOnClickListener {//Нажатие на ячейку//itemView - это весь элемент карточки из списка
- itemTemp?.let { it1 -> listener_cours.onClickCoursAdd(it1) }
- }
- }
-
- @SuppressLint("SuspiciousIndentation")
- fun bind(item: SportCoursModel) = with(binding) {
- txtCoursesSport.text = item.name
- if(item.visibility == 1){
- CVCours.setCardBackgroundColor(Color.parseColor("#83da83"))
- }
- else{
- CVCours.setCardBackgroundColor(Color.parseColor("#b6b6b6"))
- }
-
- }
- }
-
-
- override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
- val view = LayoutInflater.from(parent.context).inflate(R.layout.item_sport_course, parent, false)
- return Holder(view,listener_cours)
- }
-
- override fun onBindViewHolder(holder: Holder, position: Int) {
- val view = holder.bind(getItem(position))
- }
-
- class Comparator : DiffUtil.ItemCallback() {
- override fun areItemsTheSame(oldItem: SportCoursModel, newItem: SportCoursModel): Boolean {
- return oldItem.id == newItem.id
- }
-
- override fun areContentsTheSame(oldItem: SportCoursModel, newItem: SportCoursModel): Boolean {
- return oldItem == newItem
- }
- }
-
- //Интерфейс нажатия на кнопку удалить товар из корзины
- interface Listener {
- fun onClickCoursAdd(item: SportCoursModel)
- }
-
-}
-
-
-
-
diff --git a/app/src/main/java/com/example/doctor/Patients/Reports/CoursesListAdapter.kt b/app/src/main/java/com/example/doctor/Patients/Reports/CoursesListAdapter.kt
new file mode 100644
index 0000000..3544801
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Patients/Reports/CoursesListAdapter.kt
@@ -0,0 +1,90 @@
+package com.example.doctor.Patients.Reports
+
+import android.annotation.SuppressLint
+import android.graphics.Color
+import android.util.Log
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.recyclerview.widget.DiffUtil
+import androidx.recyclerview.widget.ListAdapter
+import androidx.recyclerview.widget.RecyclerView
+import com.example.doctor.Patients.Reports.Courses.SportCoursModel
+import com.example.doctor.R
+import com.example.doctor.databinding.ItemSportCourseBinding
+
+
+class CoursesListAdapter(val listener_courses: Listener) : ListAdapter(
+ Comparator()
+) {//Productitem - по этой форме будем заполнять.//ProductAdapter.holder - это создаваемый holder который хранит логику как нужно заполнять карточку
+
+
+ //В holder создаетс код с помошью которого мы будем заполнять и сохронять разметку
+ class Holder(view: View, val listener_courses: Listener): RecyclerView.ViewHolder(view) {//Класс который будет хранить сссылки на элементы, и отвечает за один элемент за 1 раз, то есть сначсало нулевой элемент заполнит, потом первый, потом второй и т.д.
+ //Для передачи данных
+
+ val binding = ItemSportCourseBinding.bind(view)//view - здесь храянтся элементы и мы их bind заполним в ListItemBinding//ListItemBinding - это клласс даннйо разметки(карточки) которую мы будем заполнять, а нужна дання переменная(binding), чтобы мжно было при заполнение обращатся к элементам карточки
+
+ var itemTemp: SportCoursModel? =
+ null//Глобальная переменная для нашего item, чтобы можно было передать данные для нажатия
+
+ //init - дает возможность внутри адаптера обращаться к элементам экрана
+ init {
+ binding.CardViewCourses.setOnClickListener {//Нажатие на ячейку//itemView - это весь элемент карточки из списка
+ //itemView.setEnabled(false)
+ //timerButtonDoubleButton(itemView)
+ itemTemp?.let { it1 -> listener_courses.onClickSportCourses(it1) }
+
+ }
+ }
+
+
+ @SuppressLint("SuspiciousIndentation")
+ fun bind(item: SportCoursModel) = with(binding) {//Productitem - перпедаем данные
+ itemTemp = item
+ txtCoursesSport.text = item.name
+ if (item.visibility == 1) {
+ CVCours.setCardBackgroundColor(Color.parseColor("#83da83"))
+ Log.i("11111111111","sasdasdasdasdasadsdasda")
+ } else {
+ CVCours.setCardBackgroundColor(Color.parseColor("#b6b6b6"))
+ Log.i("2222222222222","sasdasdasdasdasadsdasda")
+ }
+ Log.i("ssadsdasda","sasdasdasdasdasadsdasda")
+ }
+ }
+
+
+
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
+ val view = LayoutInflater.from(parent.context).inflate(R.layout.item_sport_course, parent, false)//Создаем(надуваем) list_item
+ return Holder(view, listener_courses)//Через Holder возврощаем view
+ }
+
+ override fun onBindViewHolder(holder: Holder, position: Int) {
+ val view = holder.bind(getItem(position))//Заполняем по позиции карточку
+ }
+
+
+ //Comparator - сравнивает старый список и новый и если что-то изменилось, то работает с конкретным изменением списке, а не весь список переписывает
+ class Comparator : DiffUtil.ItemCallback() {
+ override fun areItemsTheSame(oldItem: SportCoursModel, newItem: SportCoursModel): Boolean {//Тут лучше всего сравнивать по id//oldItem - элементы старого списка, newItem - элементы нового списка//Возврощает Boolean, тоесть есть изменения или нет
+ return oldItem.id == newItem.id//Сравниваем полностью весь список новы и старый, по очередно по одной карточке и по элементно, то есть нулевой элемент, первый, второй и т.д.. Но лучше сравнивать по id списки, а не просто весь список, так как это эфективнее, так как id уникальный(oldItem.id == newItem.id)
+ }
+
+ override fun areContentsTheSame(oldItem: SportCoursModel, newItem: SportCoursModel): Boolean {//Утут нужно сравнивать весь спсок старых элементов и новых
+ return oldItem == newItem//Сравниваем полностью весь список новы и старый
+ }
+ }
+
+ //Интерфейс нажатия на кнопку удалить товар из корзины
+ interface Listener {
+ fun onClickSportCourses(item: SportCoursModel)
+ }
+
+
+}
+
+
+
+
diff --git a/app/src/main/java/com/example/doctor/Patients/Reports/Edit/EditSportNoAdapter.kt b/app/src/main/java/com/example/doctor/Patients/Reports/Edit/EditSportNoAdapter.kt
index 77d1744..6973b59 100644
--- a/app/src/main/java/com/example/doctor/Patients/Reports/Edit/EditSportNoAdapter.kt
+++ b/app/src/main/java/com/example/doctor/Patients/Reports/Edit/EditSportNoAdapter.kt
@@ -30,7 +30,7 @@ class EditSportNoAdapter(val listener_sport: Listener) :
//init - дает возможность внутри адаптера обращаться к элементам экрана
init {
- itemView.setOnClickListener {//Нажатие на ячейку//itemView - это весь элемент карточки из списка
+ binding.btnYeyNo.setOnClickListener {//Нажатие на ячейку//itemView - это весь элемент карточки из списка
itemTemp?.let { it1 -> listener_sport.onClickAppeals(it1) }
}
}
diff --git a/app/src/main/java/com/example/doctor/Patients/Reports/Edit/TabLayout/EditSportNoFragment.kt b/app/src/main/java/com/example/doctor/Patients/Reports/Edit/TabLayout/EditSportNoFragment.kt
index d1dcadb..9086db8 100644
--- a/app/src/main/java/com/example/doctor/Patients/Reports/Edit/TabLayout/EditSportNoFragment.kt
+++ b/app/src/main/java/com/example/doctor/Patients/Reports/Edit/TabLayout/EditSportNoFragment.kt
@@ -1,5 +1,6 @@
package com.example.doctor.Patients.Reports.Edit.TabLayout
+import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
@@ -8,7 +9,12 @@ import android.view.ViewGroup
import android.widget.Toast
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.GridLayoutManager
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
import com.example.doctor.DoctorViewModel
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
import com.example.doctor.Patients.Reports.Edit.EditSportYesAdapter
import com.example.doctor.Patients.Reports.Edit.EditSportModel
import com.example.doctor.Patients.Reports.Edit.EditSportNoAdapter
@@ -33,8 +39,11 @@ class EditSportNoFragment : Fragment(),EditSportNoAdapter.Listener {
private val model: DoctorViewModel by activityViewModels()
var id_patient = 0;
+ var editNo:List?=null
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
@@ -47,12 +56,29 @@ class EditSportNoFragment : Fragment(),EditSportNoAdapter.Listener {
super.onViewCreated(view, savedInstanceState)
initRcViewDay()
model.EditSportListNo.observe(viewLifecycleOwner){
- adapterNo.submitList(it)
+ if(it!=null){
+ if(editNo!=it){
+ editNo = it
+ adapterNo.submitList(it)
+ binding.txtNo.visibility = View.GONE
+ }
+ }
+ else{
+ binding.txtNo.visibility = View.VISIBLE
+ }
+
}
model.id_patient.observe(viewLifecycleOwner) {id->
id_patient = id.toInt()
GetCoursesSportNo(id_patient)
}
+
+
+ btnClick()
+ }
+
+ private fun btnClick()=with(binding) {
+ CLLoad.setOnClickListener { }
}
@@ -75,7 +101,7 @@ class EditSportNoFragment : Fragment(),EditSportNoAdapter.Listener {
.build()
val retrofit = Retrofit.Builder()
- .baseUrl("http://mobileapp.vmeda.org/api/")
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build()
@@ -86,77 +112,196 @@ class EditSportNoFragment : Fragment(),EditSportNoAdapter.Listener {
//Получения списка пациентов
- fun GetCoursesSportYes(id_patient:Int) {
- initRetrofit()
- val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
- CoroutineScope(Dispatchers.IO).launch {
- val sportEdit = doctorApi.GetCoursesSportYes("Bearer $Tokens", id_patient)
- requireActivity().runOnUiThread {
+ fun GetCoursesSportYes(id_patient:Int)= with(binding) {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val sportEdit = doctorApi.GetCoursesSportYes("Bearer $Tokens", id_patient)
+ requireActivity().runOnUiThread {
- //Фиксируем полученные данные
- val sportEditList = sportEdit.body()
+ //Фиксируем полученные данные
+ val List = sportEdit.body()
+ val Nice = sportEdit.isSuccessful
+ val Code = sportEdit.code()
+ if(Code==429){
+ CLLoad.visibility = View.GONE
- //Если нету ошибок
- if (sportEditList != null) {
- model.EditSportListYes.value = sportEditList.set_of_sports_exercises_yes
- //adapterYes.submitList(sportEditList.set_of_sports_exercises_yes)
- }
- }
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
- }
- }
- //Получения списка пациентов
- fun GetCoursesSportNo(id_patient:Int) {
- initRetrofit()
- val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
- CoroutineScope(Dispatchers.IO).launch {
- val sportEdit = doctorApi.GetCoursesSportNo("Bearer $Tokens", id_patient)
- requireActivity().runOnUiThread {
-
- //Фиксируем полученные данные
- val sportEditList = sportEdit.body()
-
- //Если нету ошибок
- if (sportEditList != null) {
- model.EditSportListNo.value = sportEditList.set_of_sports_exercises_no
- //adapterNo.submitList(sportEditList.set_of_sports_exercises_no)
- binding.txtNo.visibility = View.GONE
- }
- else{
- binding.txtNo.visibility = View.VISIBLE
-
- }
- }
-
- }
- }
-
-
- //Получения списка пациентов
- fun UpdateBlockSportTasksNo(id:Int) {
- initRetrofit()
- val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
- CoroutineScope(Dispatchers.IO).launch {
- val NoEdit = doctorApi.UpdateBlockSportTasksNo("Bearer $Tokens", id)
- requireActivity().runOnUiThread {
-
- //Фиксируем полученные данные
- val sportNoList= NoEdit.body()
-
- //Если нету ошибок
- if (sportNoList != null) {
- Toast(requireContext()).showCustomInfoToast(sportNoList.message, requireActivity())
- GetCoursesSportYes(id_patient)
- GetCoursesSportNo(id_patient)
-
- }
- else{
- if (sportNoList != null) {
- Toast(requireContext()).showCustomInfoToast(sportNoList.message, requireActivity())
+ startActivity(intetn)
}
+ else if(Code==200){
+ //Если нету ошибок
+ if(Nice){
+ if (List != null) {
+ model.EditSportListYes.value = List.set_of_sports_exercises_yes
+
+ }
+
+ }
+ else{
+ CLLoad.visibility = View.GONE
+ }
+ }
+ else if(Code==500){
+ CLLoad.visibility = View.GONE
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ else{
+ CLLoad.visibility = View.GONE
+ }
+
+
+
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+ //Получения списка пациентов
+ fun GetCoursesSportNo(id_patient:Int)= with(binding) {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val sportEdit = doctorApi.GetCoursesSportNo("Bearer $Tokens", id_patient)
+ requireActivity().runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = sportEdit.body()
+ val Nice = sportEdit.isSuccessful
+ val Code = sportEdit.code()
+ if(Code==429){
+ CLLoad.visibility = View.GONE
+
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200){
+ //Если нету ошибок
+ if(Nice){
+ if (List != null) {
+ model.EditSportListNo.value = List.set_of_sports_exercises_no
+ binding.txtNo.visibility = View.GONE
+ binding.CLLoad.visibility = View.GONE
+ }
+ else{
+ binding.txtNo.visibility = View.VISIBLE
+ binding.CLLoad.visibility = View.GONE
+ }
+ }
+ else{
+ CLLoad.visibility = View.GONE
+ }
+ }
+ else if(Code==500){
+ CLLoad.visibility = View.GONE
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ else{
+ CLLoad.visibility = View.GONE
+ }
+
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+
+ //Удаление упражнения из блока
+ fun UpdateBlockSportTasksNo(id:Int)= with(binding) {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val NoEdit = doctorApi.UpdateBlockSportTasksNo("Bearer $Tokens", id)
+ requireActivity().runOnUiThread {
+
+ //Фиксируем полученные данные
+ val List = NoEdit.body()
+ val Nice = NoEdit.isSuccessful
+ val Code = NoEdit.code()
+ if(Code==429){
+ CLLoad.visibility = View.GONE
+
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200){
+ //Если нету ошибок
+ if(Nice){
+ if (List != null) {
+ Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
+ GetCoursesSportYes(id_patient)
+ GetCoursesSportNo(id_patient)
+
+ }
+ else{
+ if (List != null) {
+ Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
+ CLLoad.visibility = View.GONE
+ }
+ CLLoad.visibility = View.GONE
+ }
+ }
+ else{
+ CLLoad.visibility = View.GONE
+ }
+ }
+ else if(Code==500){
+ CLLoad.visibility = View.GONE
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ else{
+ CLLoad.visibility = View.GONE
+ }
+
}
}
+
+
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
}
+
}
@@ -165,7 +310,7 @@ class EditSportNoFragment : Fragment(),EditSportNoAdapter.Listener {
}
override fun onClickAppeals(item: EditSportModel) {
-
+ binding.CLLoad.visibility = View.VISIBLE
UpdateBlockSportTasksNo(item.id)
}
diff --git a/app/src/main/java/com/example/doctor/Patients/Reports/Edit/TabLayout/EditSportYesFragment.kt b/app/src/main/java/com/example/doctor/Patients/Reports/Edit/TabLayout/EditSportYesFragment.kt
index 356ff6c..12f44bb 100644
--- a/app/src/main/java/com/example/doctor/Patients/Reports/Edit/TabLayout/EditSportYesFragment.kt
+++ b/app/src/main/java/com/example/doctor/Patients/Reports/Edit/TabLayout/EditSportYesFragment.kt
@@ -1,5 +1,6 @@
package com.example.doctor.Patients.Reports.Edit.TabLayout
+import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
@@ -9,7 +10,12 @@ import android.view.ViewGroup
import android.widget.Toast
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.GridLayoutManager
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
import com.example.doctor.DoctorViewModel
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
import com.example.doctor.Patients.Reports.Edit.EditSportYesAdapter
import com.example.doctor.Patients.Reports.Edit.EditSportModel
import com.example.doctor.Patients.Reports.Edit.EditSportNoAdapter
@@ -33,7 +39,10 @@ class EditSportYesFragment : Fragment(), EditSportYesAdapter.Listener {
val prefDoctorConclusion = ConclusionPref()
private val model: DoctorViewModel by activityViewModels()
var id_patient = 0;
+ var editYes:List?=null
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
@@ -56,8 +65,24 @@ class EditSportYesFragment : Fragment(), EditSportYesAdapter.Listener {
}
model.EditSportListYes.observe(viewLifecycleOwner){
- adapterYes.submitList(it)
+ if(it!=null){
+ if(editYes!=it){
+ editYes=it
+ adapterYes.submitList(it)
+ binding.txtYes.visibility = View.GONE
+ }
+ }
+ else{
+ binding.txtYes.visibility = View.GONE
+ }
+
+
}
+ btnClick()
+ }
+
+ private fun btnClick()=with(binding) {
+ CLLoad.setOnClickListener { }
}
@@ -82,7 +107,7 @@ class EditSportYesFragment : Fragment(), EditSportYesAdapter.Listener {
.build()
val retrofit = Retrofit.Builder()
- .baseUrl("http://mobileapp.vmeda.org/api/")
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build()
@@ -92,73 +117,198 @@ class EditSportYesFragment : Fragment(), EditSportYesAdapter.Listener {
}
//Получения списка пациентов
- fun GetCoursesSportYes(id_patient:Int) {
- initRetrofit()
- val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
- CoroutineScope(Dispatchers.IO).launch {
- val sportEdit = doctorApi.GetCoursesSportYes("Bearer $Tokens", id_patient)
- requireActivity().runOnUiThread {
+ fun GetCoursesSportYes(id_patient:Int)=with(binding) {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val sportEdit = doctorApi.GetCoursesSportYes("Bearer $Tokens", id_patient)
+ requireActivity().runOnUiThread {
- //Фиксируем полученные данные
- val sportEditList = sportEdit.body()
+ //Фиксируем полученные данные
+ val List = sportEdit.body()
+ val Nice = sportEdit.isSuccessful
+ val Code = sportEdit.code()
+ if(Code==429){
+ CLLoad.visibility = View.GONE
- //Если нету ошибок
- if (sportEditList != null) {
- model.EditSportListYes.value = sportEditList.set_of_sports_exercises_yes
- binding.txtYes.visibility = View.GONE
- }
- else{
- binding.txtYes.visibility = View.VISIBLE
- }
- }
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
- }
- }
- //Получения списка пациентов
- fun GetCoursesSportNo(id_patient:Int) {
- initRetrofit()
- val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
- CoroutineScope(Dispatchers.IO).launch {
- val sportEdit = doctorApi.GetCoursesSportNo("Bearer $Tokens",id_patient)
- requireActivity().runOnUiThread {
-
- //Фиксируем полученные данные
- val sportEditList = sportEdit.body()
-
- //Если нету ошибок
- if (sportEditList != null) {
- model.EditSportListNo.value = sportEditList.set_of_sports_exercises_no
- //adapterNo.submitList(sportEditList.set_of_sports_exercises_no)
- }
- }
-
- }
- }
-
-
- //Получения списка пациентов
- fun UpdateBlockSportTasksYes(id_pateint:Int,id_sports_tasks:Int) {
- initRetrofit()
- val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
- CoroutineScope(Dispatchers.IO).launch {
- val sportEdit = doctorApi.UpdateBlockSportTasksYes("Bearer $Tokens", id_pateint,id_sports_tasks)
- requireActivity().runOnUiThread {
-
- //Фиксируем полученные данные
- val sportEditList = sportEdit.body()
-
- //Если нету ошибок
- if (sportEditList != null) {
- Toast(requireContext()).showCustomInfoToast(sportEditList.message, requireActivity())
- GetCoursesSportYes(id_patient)
- GetCoursesSportNo(id_patient)
- }
- else{
- if (sportEditList != null) {
- Toast(requireContext()).showCustomInfoToast(sportEditList.message, requireActivity())
+ startActivity(intetn)
}
+ else if(Code==200){
+ //Если нету ошибок
+ if(Nice){
+ if (List != null) {
+ model.EditSportListYes.value = List.set_of_sports_exercises_yes
+ binding.txtYes.visibility = View.GONE
+ binding.CLLoad.visibility = View.GONE
+ }
+ else{
+ model.EditSportListYes.value = null
+
+ binding.txtYes.visibility = View.VISIBLE
+ binding.rcViewEditSportYes.visibility = View.GONE
+ binding.CLLoad.visibility = View.GONE
+ }
+ }
+ else{
+ CLLoad.visibility = View.GONE
+ }
+ }
+ else if(Code==500){
+ CLLoad.visibility = View.GONE
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ else{
+ CLLoad.visibility = View.GONE
+ }
+
+ //Фиксируем полученные данные
+ val sportEditList = sportEdit.body()
+
+ //Если нету ошибок
+
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+ //Получения списка пациентов
+ fun GetCoursesSportNo(id_patient:Int)=with(binding) {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val sportEdit = doctorApi.GetCoursesSportNo("Bearer $Tokens",id_patient)
+ requireActivity().runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = sportEdit.body()
+ val Nice = sportEdit.isSuccessful
+ val Code = sportEdit.code()
+ if(Code==429){
+ CLLoad.visibility = View.GONE
+
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200){
+ //Если нету ошибок
+ if(Nice){
+ if (List != null) {
+ model.EditSportListNo.value = List.set_of_sports_exercises_no
+ }
+ CLLoad.visibility = View.GONE
+ }
+ else{
+ CLLoad.visibility = View.GONE
+ }
+ }
+ else if(Code==500){
+ CLLoad.visibility = View.GONE
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ else{
+ CLLoad.visibility = View.GONE
+ }
+
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+
+ //Отключение упражнения
+ fun UpdateBlockSportTasksYes(id_pateint:Int,id_sports_tasks:Int)=with(binding) {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val sportEdit = doctorApi.UpdateBlockSportTasksYes("Bearer $Tokens", id_pateint,id_sports_tasks)
+ requireActivity().runOnUiThread {
+
+ //Фиксируем полученные данные
+ val List = sportEdit.body()
+ val Nice = sportEdit.isSuccessful
+ val Code = sportEdit.code()
+ if(Code==429){
+ CLLoad.visibility = View.GONE
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200){
+ //Если нету ошибок
+ if(Nice){
+ if (List != null) {
+ Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
+ GetCoursesSportYes(id_patient)
+ GetCoursesSportNo(id_patient)
+
+ }
+ else{
+ if (List != null) {
+ Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
+ CLLoad.visibility = View.GONE
+ }
+ CLLoad.visibility = View.GONE
+ }
+ }
+ else{
+ CLLoad.visibility = View.GONE
+ }
+ }
+ else if(Code==500){
+ CLLoad.visibility = View.GONE
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ else{
+ CLLoad.visibility = View.GONE
+ }
+
}
}
+
+
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
}
}
@@ -168,6 +318,7 @@ class EditSportYesFragment : Fragment(), EditSportYesAdapter.Listener {
}
override fun onClickAppeals(item: EditSportModel) {
+ binding.CLLoad.visibility = View.VISIBLE
UpdateBlockSportTasksYes(id_patient, item.id)
}
diff --git a/app/src/main/java/com/example/doctor/Patients/Reports/PatientFragment.kt b/app/src/main/java/com/example/doctor/Patients/Reports/PatientFragment.kt
index ad66fb0..74a74ca 100644
--- a/app/src/main/java/com/example/doctor/Patients/Reports/PatientFragment.kt
+++ b/app/src/main/java/com/example/doctor/Patients/Reports/PatientFragment.kt
@@ -2,6 +2,7 @@ package com.example.doctor.Patients.Reports
import android.graphics.Color
import android.os.Bundle
+import android.transition.TransitionInflater
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
@@ -16,10 +17,29 @@ import com.example.doctor.DoctorViewModel
import com.example.doctor.Patients.PatientsListFragment
import com.example.doctor.Patients.Reports.Edit.EditSportFragment
import com.example.doctor.Pref.ConclusionPref
+import com.example.doctor.R as R_D
+import android.R
+import android.content.Intent
+import androidx.fragment.app.FragmentActivity
+import com.example.doctor.Adapter.VpAdapter
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
+import com.example.doctor.Patients.Model.PatientAllModel
+import com.example.doctor.Patients.Reports.Courses.TabLayout.CoursesAllFragment
+import com.example.doctor.Patients.Reports.Courses.TabLayout.CoursesYouFragment
+import com.example.doctor.Pref.ClearPref
+import com.example.doctor.Pref.SavePref
import com.example.doctor.Retrofit.DoctorApi
+import com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.AllSportCoursesDoctorFragment
+import com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.YourSportCoursesDoctorFragment
import com.example.doctor.Toast.showCustomInfoToast
+import com.example.doctor.Toast.showCustomNiceToast
import com.example.doctor.databinding.FragmentPatientsBinding
import com.example.doctor.databinding.ItemQuestionnaireAfterBinding
+import com.google.android.material.tabs.TabLayoutMediator
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -30,18 +50,42 @@ import retrofit2.converter.gson.GsonConverterFactory
import java.time.LocalDate
-class PatientFragment : Fragment(),CoursesAdapter.Listener {
+class PatientFragment : Fragment() {
private lateinit var binding: FragmentPatientsBinding
- private val model: DoctorViewModel by activityViewModels()
+ private val modelDoctor: DoctorViewModel by activityViewModels()
lateinit var adapter: QBBAdapter
- lateinit var adapterCours: CoursesAdapter
+ lateinit var adapterCours: CoursesListAdapter
private lateinit var doctorApi: DoctorApi
val prefDoctorConclusion = ConclusionPref()
+ val prefDoctorClear = ClearPref()
+ val prefDoctorSave = SavePref()
var id: Int? = null
var block = ""
var pause = ""
var id_sport = ""
+ var btnSC = 0;
+
+ var idPatient = 0;
+
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
+
+ //Для 10 сек обновления
+ var qba:List?=null
+ var patientAll:PatientAllModel?=null
+
+ private val tList = listOf(
+ "Все",
+ "Ваши",
+ )
+
+ //Список с фрагментами для переключения
+ private val flist = listOf(
+ CoursesAllFragment.newInstance(),
+ CoursesYouFragment.newInstance(),
+ )
+
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
@@ -54,100 +98,205 @@ class PatientFragment : Fragment(),CoursesAdapter.Listener {
super.onViewCreated(view, savedInstanceState)
initRcViewDay()
- initRcViewCours()
-
- model.qbaList.observe(viewLifecycleOwner) {//viewLifecycleOwner - следит за циклом жизни fragment
- adapter.submitList(it)//Напрямую переадем созданный список в adapter(ProductAdapter)
+ init()
+ modelDoctor.qbaList.observe(viewLifecycleOwner) {//viewLifecycleOwner - следит за циклом жизни fragment
+ if(qba != it){
+ qba = it
+ adapter.submitList(it)//Напрямую переадем созданный список в adapter(ProductAdapter)
+ // binding.txtNullQBA.visibility = View.GONE
+ }
}
- model.SportCoursList.observe(viewLifecycleOwner) {//viewLifecycleOwner - следит за циклом жизни fragment
- adapterCours.submitList(it)//Напрямую переадем созданный список в adapter(ProductAdapter)
+ idPatient = prefDoctorConclusion.conclusionIdPatient(requireContext())
+
+ modelDoctor.BtnSportCoursDoctorCurrent.observe(viewLifecycleOwner){
+ if(it == 1){
+ binding.btnClearSportPatient.setCardBackgroundColor(Color.parseColor("#D86767"))
+ }
+ else if(it == 2){
+ binding.btnClearSportPatient.setCardBackgroundColor(Color.parseColor("#A9D867"))
+ }
+ else{
+ binding.btnClearSportPatient.setCardBackgroundColor(Color.parseColor("#D86767"))
+ }
}
+
+ val inflater = TransitionInflater.from(requireContext())
+ enterTransition = inflater.inflateTransition(R_D.transition.slide_right)
+
binding.btnExit.setOnClickListener {
- //Вывод фрагмента на активити при первоначальной загрузке
- activity?.supportFragmentManager?.beginTransaction()
- ?.replace(
- com.example.doctor.R.id.CLMainFragment,
- PatientsListFragment.newInstance()
- )
- ?.commit()
+ exitTransition = inflater.inflateTransition(R_D.transition.slide_right)
+
+ activity?.finish()
}
popMenu()
- model.patientCurrent.observe(viewLifecycleOwner) {
- binding.txtLogin.text = it.login
- id = it.id
- model.id_patient.value = id
- block = it.block.toString()
- pause = it.pause.toString()
- id_sport = it.id_sport_patient.toString()
- //Проверка даты, так как если дата уже прошла, то должно выводится что блока нету
- if(block == "null"){
- block(block)
- }
- else{
- if(LocalDate.parse(block)
+ tab.text =
+ tList[pos]//tab - нажатая кнопка, pos - позиция кнопки, tList[pos] - передаем название по полученной позиции
+ }.attach()// attach() - чтобы все переключалось, а не вывадило постоянно один экран
+
+ //Изменения цвета в зависомости на каком из tabLayout вы находитесь
+ binding.tabLayoutCourses.setTabTextColors(
+ getResources().getColor(com.example.doctor.R.color.black),
+ getResources().getColor(com.example.doctor.R.color.white)
+ );
}
- private fun GetPatientID() {
- CreatRetrofit()
- val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
- CoroutineScope(Dispatchers.IO).launch {
- val listPatient = doctorApi.GetPatientID("Bearer $Tokens")
- requireActivity().runOnUiThread {
-
- //Фиксируем полученные данные
- val patientId = listPatient.body()
-
- //Если нету ошибок
- if (patientId != null) {
- model.patientCurrent.value = patientId
- }
- }
+ private fun viewPatient() {
+ val viewPatient = prefDoctorConclusion.conclusionViewPatient(requireContext())
+ val idPatient = 23412
+ Log.i("viewPatient1",viewPatient.toString())
+ Log.i("idPatient1",viewPatient.toString())
+ if(viewPatient ==1 && idPatient !=0 && idPatient !=null){
+ GetPatientID(idPatient)
+ prefDoctorClear.clearIdPatient(requireContext())
+ prefDoctorClear.clearViewPatient(requireContext())
+ Log.i("viewPatient2",viewPatient.toString())
+ Log.i("idPatient2",viewPatient.toString())
}
}
+ //Инициализируем Retrofit
+ private fun initRetrofit() {
+ val interceptor = HttpLoggingInterceptor()
+ interceptor.level = HttpLoggingInterceptor.Level.BODY
+
+ val client = OkHttpClient
+ .Builder()
+ .addInterceptor(interceptor)
+ .build()
+
+ val retrofit = Retrofit.Builder()
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
+ .client(client)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+
+ doctorApi = retrofit.create(DoctorApi::class.java)
+
+ }
+ private fun GetPatientID(idPatient: Int) {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listPatient = doctorApi.GetPatientID("Bearer $Tokens", idPatient)
+ requireActivity().runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = listPatient.body()
+ val Nice = listPatient.isSuccessful
+ val Code = listPatient.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ modelDoctor.patientCurrent.value = List
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
private fun popMenu() {
//Созданиеменю
val popMenu = PopupMenu(
@@ -182,35 +331,161 @@ class PatientFragment : Fragment(),CoursesAdapter.Listener {
//Получения списка анкет ДО и ПОСЛЕ для пациента
fun ClearSportPaient(){
- CreatRetrofit()
- val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
- CoroutineScope(Dispatchers.IO).launch {
- val listcsp = doctorApi.ClearPatientSport("Bearer $Tokens",id!!)
- requireActivity().runOnUiThread {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listcsp = doctorApi.ClearPatientSport("Bearer $Tokens",id!!)
+ requireActivity().runOnUiThread {
- //Фиксируем полученные данные
- val csp = listcsp.body()
- //Если нету ошибок
- if (csp != null) {
- id_sport = "null"
- binding.btnClearSportPatient.setCardBackgroundColor(Color.parseColor("#D86767"))
- Toast(requireContext()).showCustomInfoToast(csp.message, requireActivity())
- }
- else{
- Toast(requireContext()).showCustomInfoToast("${csp?.message}", requireActivity())
+ //Фиксируем полученные данные
+ val List = listcsp.body()
+ val Nice = listcsp.isSuccessful
+ val Code = listcsp.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ GetAllCoursesSport()
+ GetCoursesDoctor()
+ modelDoctor.BtnSportCoursDoctorCurrent.value = 1
+
+ Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
+ }
+ else{
+ Toast(requireContext()).showCustomInfoToast("${List?.message}", requireActivity())
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
}
}
-
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
}
+
}
- private fun clearSportPatient(id_sport:String) {
- if (id_sport == "null") {
- binding.btnClearSportPatient.setCardBackgroundColor(Color.parseColor("#D86767"))
+ //Получения списка курсов созданных доктором
+ fun GetCoursesDoctor() {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listCoursesDoctor = doctorApi.GetCoursesDoctorPatient("Bearer $Tokens",id!!)
+
+ requireActivity().runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = listCoursesDoctor.body()
+ val Nice = listCoursesDoctor.isSuccessful
+ val Code = listCoursesDoctor.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ modelDoctor.SportCoursDoctorList.value = List.courses_doctor
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ }
} else {
- binding.btnClearSportPatient.setCardBackgroundColor(Color.parseColor("#A9D867"))
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ //Вывод всех курсов
+ fun GetAllCoursesSport(){
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listProduct = doctorApi.GetCoursAllPatient("Bearer $Tokens",id!!)
+ requireActivity().runOnUiThread {
+
+ //Фиксируем полученные данные
+ val List = listProduct.body()
+ val Nice = listProduct.isSuccessful
+ val Code = listProduct.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ modelDoctor.SportCoursList.value = List.courses
+
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ }
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ private fun btnClearSportPatient(id_sport:String) {
+ if (id_sport == "null") {
+ modelDoctor.BtnSportCoursDoctorCurrent.value = 1
+ } else {
+ modelDoctor.BtnSportCoursDoctorCurrent.value = 2
}
binding.btnClearSportPatient.setOnClickListener {
@@ -220,25 +495,53 @@ class PatientFragment : Fragment(),CoursesAdapter.Listener {
//Получения списка анкет ДО и ПОСЛЕ для пациента
fun QBAPatientList()=with(binding){
- CreatRetrofit()
- val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
- CoroutineScope(Dispatchers.IO).launch {
- val listProduct = doctorApi.GetPatientBAQiestionar("Bearer $Tokens",id!!)
- requireActivity().runOnUiThread {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listProduct = doctorApi.GetPatientBAQiestionar("Bearer $Tokens",id!!)
+ requireActivity().runOnUiThread {
- //Фиксируем полученные данные
- val qbapatientList = listProduct.body()
- //Если нету ошибок
- if (qbapatientList != null) {
- if(qbapatientList.questionnaire !=null){
- txtNullQBA.visibility = View.GONE
- model.qbaList.value = qbapatientList.questionnaire
+ //Фиксируем полученные данные
+ val List = listProduct.body()
+ val Nice = listProduct.isSuccessful
+ val Code = listProduct.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ if(List.questionnaire !=null){
+ txtNullQBA.visibility = View.GONE
+ modelDoctor.qbaList.value = List.questionnaire
+ }
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
}
}
- }
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
}
+
}
@@ -267,156 +570,304 @@ class PatientFragment : Fragment(),CoursesAdapter.Listener {
//Блокировка пациента
fun UpdateBlockPatient(){
- CreatRetrofit()
- val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
- CoroutineScope(Dispatchers.IO).launch {
- val listProduct = doctorApi.UpdateBlockAccountPatient("Bearer $Tokens", id!!)
- requireActivity().runOnUiThread {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listProduct = doctorApi.UpdateBlockAccountPatient("Bearer $Tokens", id!!)
+ requireActivity().runOnUiThread {
- //Фиксируем полученные данные
- val patientList = listProduct.body()
- //Если нету ошибок
- if (patientList != null) {
- if (block == "null") {
- block = "true"
- binding.CVBlock.setCardBackgroundColor(Color.parseColor("#D86767"))
- Toast(requireContext()).showCustomInfoToast("Блок установлен", requireActivity())
- } else {
- block = "null"
- binding.CVBlock.setCardBackgroundColor(Color.parseColor("#A9D867"))
- Toast(requireContext()).showCustomInfoToast("Блок убран", requireActivity())
+ //Фиксируем полученные данные
+ val List = listProduct.body()
+ val Nice = listProduct.isSuccessful
+ val Code = listProduct.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ if (block == "null") {
+ block = "true"
+ binding.CVBlock.setCardBackgroundColor(Color.parseColor("#D86767"))
+ Toast(requireContext()).showCustomInfoToast("Блок установлен", requireActivity())
+ } else {
+ block = "null"
+ binding.CVBlock.setCardBackgroundColor(Color.parseColor("#A9D867"))
+ Toast(requireContext()).showCustomInfoToast("Блок убран", requireActivity())
+ }
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
}
}
- }
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
}
+
}
//Блокировка пациента
fun UpdatePausePatient(){
- CreatRetrofit()
- val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
- CoroutineScope(Dispatchers.IO).launch {
- val listProduct = doctorApi.UpdatePauseAccountPatient("Bearer $Tokens", id!!)
- requireActivity().runOnUiThread {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listProduct = doctorApi.UpdatePauseAccountPatient("Bearer $Tokens", id!!)
+ requireActivity().runOnUiThread {
- //Фиксируем полученные данные
- val patientList = listProduct.body()
- //Если нету ошибок
- if (patientList != null) {
- if (pause == "null") {
- pause = "true"
- binding.CVPause.setCardBackgroundColor(Color.parseColor("#D86767"))
- Toast(requireContext()).showCustomInfoToast("Пауза установлен", requireActivity())
- } else {
- pause = "null"
- binding.CVPause.setCardBackgroundColor(Color.parseColor("#A9D867"))
- Toast(requireContext()).showCustomInfoToast("Пауза убран", requireActivity())
+ //Фиксируем полученные данные
+ val List = listProduct.body()
+ val Nice = listProduct.isSuccessful
+ val Code = listProduct.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ if (pause == "null") {
+ pause = "true"
+ binding.CVPause.setCardBackgroundColor(Color.parseColor("#D86767"))
+ Toast(requireContext()).showCustomInfoToast("Пауза установлен", requireActivity())
+ } else {
+ pause = "null"
+ binding.CVPause.setCardBackgroundColor(Color.parseColor("#A9D867"))
+ Toast(requireContext()).showCustomInfoToast("Пауза убран", requireActivity())
+ }
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
}
}
}
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
}
+
}
- //Вывод всех курсов
- fun GetAllCoursesSport(){
- CreatRetrofit()
- val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
- CoroutineScope(Dispatchers.IO).launch {
- val listProduct = doctorApi.GetCoursAllPatient("Bearer $Tokens",id!!)
- requireActivity().runOnUiThread {
- //Фиксируем полученные данные
- val sportCourses = listProduct.body()
- //Если нету ошибок
- if (sportCourses != null) {
- model.SportCoursList.value = sportCourses.courses
- binding.CVSport.visibility = View.VISIBLE
+ //Обновленеи логина
+ fun UpdatePatientLogin(id:Int,login:String){
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val updateLogin = doctorApi.UpdatePatientLogin("Bearer $Tokens",id,login)
+ requireActivity().runOnUiThread {
+
+
+
+ //Фиксируем полученные данные
+ val List = updateLogin.body()
+ val Nice = updateLogin.isSuccessful
+ val Code = updateLogin.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
+ }
+ else{
+ if (List != null) {
+ Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
+ }
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
}
}
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
}
- }
-
- //Инициализируем Retrofit
- private fun CreatRetrofit() {
- val interceptor = HttpLoggingInterceptor()
- interceptor.level = HttpLoggingInterceptor.Level.BODY
-
- val client = OkHttpClient
- .Builder()
- .addInterceptor(interceptor)
- .build()
-
- val retrofit = Retrofit.Builder()
- .baseUrl("http://mobileapp.vmeda.org/api/")
- .client(client)
- .addConverterFactory(GsonConverterFactory.create())
- .build()
-
- doctorApi = retrofit.create(DoctorApi::class.java)
}
+ //Обновленеи пароля
+ fun UpdatePatientPassword(id:Int,password:String){
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val updatePassword= doctorApi.UpdatePatientPassword("Bearer $Tokens",id,password)
+ requireActivity().runOnUiThread {
+//Фиксируем полученные данные
+ val List = updatePassword.body()
+ val Nice = updatePassword.isSuccessful
+ val Code = updatePassword.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
+ }
+ else{
+ if (List != null) {
+ Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
+ }
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+
+
+
+
private fun sport() {
- binding.btnSport.setOnClickListener {
- }
}
private fun report() = with(binding) {
+
+
+
btnExitPatientFragment.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()
?.replace(com.example.doctor.R.id.CLMainListPatient, PatientsListFragment.newInstance())
?.commit()
+ //this@PatientFragment.onDestroy()
}
- binding.btnReport.setOnClickListener {
- binding.CVReport.visibility = View.VISIBLE
+ btnReport.setOnClickListener {
+ CVReport.visibility = View.VISIBLE
QBAPatientList()
}
- binding.btnSport.setOnClickListener {
- GetAllCoursesSport()
-
-
+ btnSport.setOnClickListener {
+ binding.CVSport.visibility = View.VISIBLE
}
- binding.btnCloseReport.setOnClickListener {
- binding.CVReport.visibility = View.GONE
+ btnCloseReport.setOnClickListener {
+ CVReport.visibility = View.GONE
initRcViewDay()
}
- binding.btnCloseReport2.setOnClickListener {
- binding.CVSport.visibility = View.GONE
- }
-
-
- binding.btnCloseBefore.setOnClickListener {
- binding.CVQB.visibility = View.GONE
- }
- binding.btnCloseAfter.setOnClickListener {
- binding.CVQA.visibility = View.GONE
- }
-
-
- binding.CVReport.setOnClickListener {
- binding.CVReport.visibility = View.GONE
+ btnClouseEditSport.setOnClickListener {
+ CVEditSport.visibility = View.GONE
initRcViewDay()
}
- binding.CVSport.setOnClickListener {
- binding.CVSport.visibility = View.GONE
+ CVEditSport.setOnClickListener {
+ CVEditSport.visibility = View.GONE
+ initRcViewDay()
}
- binding.CVReportList.setOnClickListener {
+ CVEditPatient.setOnClickListener{
+ CVEditPatient.visibility = View.GONE
+ initRcViewDay()
+ }
+ btnClouseEditPatient.setOnClickListener{
+ CVEditPatient.visibility = View.GONE
+ initRcViewDay()
}
+ btnCloseReport2.setOnClickListener {
+ CVSport.visibility = View.GONE
+ }
+
+
+ btnCloseBefore.setOnClickListener {
+ CVQB.visibility = View.GONE
+ }
+ btnCloseAfter.setOnClickListener {
+ CVQA.visibility = View.GONE
+ }
+
+
+ CVReport.setOnClickListener {
+ CVReport.visibility = View.GONE
+ initRcViewDay()
+ }
+ CVSport.setOnClickListener {
+ CVSport.visibility = View.GONE
+ }
+
+ CVReportList.setOnClickListener {
+ }
+
+ btnEditPatient.setOnClickListener {
+ CVEditPatient.visibility = View.VISIBLE
+ }
+
//Переход на страницу редактирования курса
binding.btnEditSport.setOnClickListener{
binding.CVEditSport.visibility = View.VISIBLE
@@ -424,26 +875,49 @@ class PatientFragment : Fragment(),CoursesAdapter.Listener {
activity?.supportFragmentManager?.beginTransaction()
?.replace(com.example.doctor.R.id.CLEditSport, EditSportFragment.newInstance())
?.commit()
+ }
+ //Нажатие на кнопку для обновления логина
+ btnUpdateLogin.setOnClickListener{
+ val login = edLogin.text.toString()
+ if(login.count() != 0){
+ if(login.count() > 3){
+ UpdatePatientLogin(id!!,login)
+ }
+ else{
+ Toast(requireContext()).showCustomInfoToast("Логин слишком короткий", requireActivity())
+ }
+ }
+ else{
+ Toast(requireContext()).showCustomInfoToast("Поле пустое", requireActivity())
+ }
+ }
+
+ //Нажатие на кнопку для обновления пароля
+ btnUpdatePassword.setOnClickListener{
+ val password = edPassword.text.toString()
+ if(password.count() != 0){
+ if(password.count() > 10){
+ UpdatePatientPassword(id!!,password)
+ }
+ else{
+ Toast(requireContext()).showCustomInfoToast("Пароль слишком короткий", requireActivity())
+ }
+ }
+ else{
+ Toast(requireContext()).showCustomInfoToast("Поле пустое", requireActivity())
+ }
}
}
//Инициализация списка
private fun initRcViewDay() = with(binding) {
- RCView.layoutManager =
- GridLayoutManager(requireContext(), 1)//По вертикали будет выводить по умолчанию
+ RCView.layoutManager = GridLayoutManager(requireContext(), 1)//По вертикали будет выводить по умолчанию
adapter = QBBAdapter()
RCView.adapter = adapter
}
- //Инициализация списка
- private fun initRcViewCours() = with(binding) {
- rcVieeSportCourses.layoutManager = GridLayoutManager(requireContext(), 1)//По вертикали будет выводить по умолчанию
- adapterCours = CoursesAdapter(this@PatientFragment)
- rcVieeSportCourses.adapter = adapterCours
- }
-
fun closeViewCard() {
binding.txtLogin.text = ""
@@ -461,13 +935,11 @@ class PatientFragment : Fragment(),CoursesAdapter.Listener {
fun newInstance() = PatientFragment()
}
- override fun onClickCoursAdd(item: SportCoursModel) {
- if(id_sport == "" || id_sport == null){
- Toast(requireContext()).showCustomInfoToast("Сначалоа очистите курс", requireActivity())
- }
- else{
- Toast(requireContext()).showCustomInfoToast("Курс добавлен", requireActivity())
- //ТУТ ДОЛЖНА БЫТЬ ФУНКЦИЯ ДЛЯ ДОБАВЛЕНИЯ КУРСА ПАЦИЕНТУ
- }
- }
+
+
+
+
+
+
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Patients/Reports/QBAModel.kt b/app/src/main/java/com/example/doctor/Patients/Reports/QBAModel.kt
index ca522c7..283ae29 100644
--- a/app/src/main/java/com/example/doctor/Patients/Reports/QBAModel.kt
+++ b/app/src/main/java/com/example/doctor/Patients/Reports/QBAModel.kt
@@ -17,8 +17,8 @@ data class QBAModel(
val eightb: Int,
val nineb: Int,
+ val statusa: Int,
val ida: Int,
- //val statusa: Int,
val onea: Int,
val twoa: Int,
val threea: Int,
diff --git a/app/src/main/java/com/example/doctor/Patients/Reports/QBBAdapter.kt b/app/src/main/java/com/example/doctor/Patients/Reports/QBBAdapter.kt
index dba6de7..3de85ed 100644
--- a/app/src/main/java/com/example/doctor/Patients/Reports/QBBAdapter.kt
+++ b/app/src/main/java/com/example/doctor/Patients/Reports/QBBAdapter.kt
@@ -16,7 +16,8 @@ class QBBAdapter() : ListAdapter(Comparator()) {
class Holder(view: View) :
RecyclerView.ViewHolder(view) {
- val binding = ItemQbaBinding.bind(view)
+ val binding = ItemQbaBinding.bind(view)//view - здесь храянтся элементы и мы их bind заполним в ListItemBinding//ListItemBinding - это клласс даннйо разметки(карточки) которую мы будем заполнять, а нужна дання переменная(binding), чтобы мжно было при заполнение обращатся к элементам карточки
+
@SuppressLint("SuspiciousIndentation")
@@ -42,18 +43,6 @@ class QBBAdapter() : ListAdapter(Comparator()) {
CVB.setCardBackgroundColor(Color.parseColor("#ABDA83"))
}
- if(item.ninea == 1){
- txtStatusA.text = "Плохо"
- CVA.setCardBackgroundColor(Color.parseColor("#DA8383"))
- }
- else if(item.onea >= 6 || item.threea == 1 ||item.sixa == 1 ||item.eighta == 1 ||item.elevena == 1){
- txtStatusA.text = "Средне"
- CVA.setCardBackgroundColor(Color.parseColor("#DABA83"))
- }
- else{
- txtStatusA.text= "Хорошо"
- CVA.setCardBackgroundColor(Color.parseColor("#ABDA83"))
- }
txtB1.text = item.oneb.toString()
if(item.oneb==0){
@@ -119,10 +108,10 @@ class QBBAdapter() : ListAdapter(Comparator()) {
if (item.eightb == 1) {
txtB8.text = "Да"
- CLQB8.setBackgroundColor(Color.parseColor("#C6DF8686"))
+ CLQB8.setBackgroundColor(Color.parseColor("#C686DF8F"))
} else {
txtB8.text = "Нет"
- CLQB8.setBackgroundColor(Color.parseColor("#C686DF8F"))
+ CLQB8.setBackgroundColor(Color.parseColor("#C6DF8686"))
}
if (item.nineb == 1) {
@@ -133,107 +122,144 @@ class QBBAdapter() : ListAdapter(Comparator()) {
CLQB9.setBackgroundColor(Color.parseColor("#C686DF8F"))
}
+ //Если анкета после была заполнена
+ if(item.statusa == 1){
+ if(item.ninea == 1){
+ txtStatusA.text = "Плохо"
+ CVA.setCardBackgroundColor(Color.parseColor("#DA8383"))
+ }
+ else if(item.onea >= 6 || item.threea == 1 ||item.sixa == 1 ||item.eighta == 1 ||item.elevena == 1){
+ txtStatusA.text = "Средне"
+ CVA.setCardBackgroundColor(Color.parseColor("#DABA83"))
+ }
+ else{
+ txtStatusA.text= "Хорошо"
+ CVA.setCardBackgroundColor(Color.parseColor("#ABDA83"))
+ }
- txtA1.text = item.onea.toString()
- if(item.onea==0){
- CLQA1.setBackgroundColor(Color.parseColor("#C686DF8F"))
- }
- else if(item.onea in 1..5){
- CLQA1.setBackgroundColor(Color.parseColor("#C6DFD386"))
+ txtA1.text = item.onea.toString()
+ if(item.onea==0){
+ CLQA1.setBackgroundColor(Color.parseColor("#C686DF8F"))
+ }
+ else if(item.onea in 1..5){
+ CLQA1.setBackgroundColor(Color.parseColor("#C6DFD386"))
+ }
+ else{
+ CLQA1.setBackgroundColor(Color.parseColor("#C6DF8686"))
+ }
+
+ if (item.twoa == 1) {
+ txtA2.text = "Да"
+ CLQA2.setBackgroundColor(Color.parseColor("#C6DF8686"))
+ } else {
+ txtA2.text = "Нет"
+ CLQA2.setBackgroundColor(Color.parseColor("#C686DF8F"))
+ }
+
+ if (item.threea == 1) {
+ txtA3.text = "Да"
+ CLQA3.setBackgroundColor(Color.parseColor("#C6DF8686"))
+ } else {
+ txtA3.text = "Нет"
+ CLQA3.setBackgroundColor(Color.parseColor("#C686DF8F"))
+ }
+
+ if (item.foura == 1) {
+ txtA4.text = "Да"
+ CLQA4.setBackgroundColor(Color.parseColor("#C6DF8686"))
+ } else {
+ txtA4.text = "Нет"
+ CLQA4.setBackgroundColor(Color.parseColor("#C686DF8F"))
+ }
+
+ if (item.fivea == 1) {
+ txtA5.text = "Да"
+ CLQA5.setBackgroundColor(Color.parseColor("#C6DF8686"))
+ } else {
+ txtA5.text = "Нет"
+ CLQA5.setBackgroundColor(Color.parseColor("#C686DF8F"))
+ }
+
+ if (item.sixa == 1) {
+ txtA6.text = "Да"
+ CLQA6.setBackgroundColor(Color.parseColor("#C6DF8686"))
+
+ } else {
+ txtA6.text = "Нет"
+ CLQA6.setBackgroundColor(Color.parseColor("#C686DF8F"))
+ }
+
+ if (item.sevena == 1) {
+ txtA7.text = "Да"
+ CLQA7.setBackgroundColor(Color.parseColor("#C6DF8686"))
+ } else {
+ txtA7.text = "Нет"
+ CLQA7.setBackgroundColor(Color.parseColor("#C686DF8F"))
+ }
+
+ if (item.eighta == 1) {
+ txtA8.text = "Да"
+ CLQA8.setBackgroundColor(Color.parseColor("#C6DF8686"))
+ } else {
+ txtA8.text = "Нет"
+ CLQA8.setBackgroundColor(Color.parseColor("#C686DF8F"))
+ }
+
+ if (item.ninea == 1) {
+ txtA9.text = "Да"
+ CLQA9.setBackgroundColor(Color.parseColor("#C6DF8686"))
+
+ } else {
+ txtA9.text = "Нет"
+ CLQA9.setBackgroundColor(Color.parseColor("#C686DF8F"))
+ }
+
+ if (item.tena == 1) {
+ txtA10.text = "Да"
+ CLQA10.setBackgroundColor(Color.parseColor("#C6DF8686"))
+ } else {
+ txtA10.text = "Нет"
+ CLQA10.setBackgroundColor(Color.parseColor("#C686DF8F"))
+ }
+
+ if (item.elevena == 1) {
+ txtA11.text = "Да"
+ CLQA11.setBackgroundColor(Color.parseColor("#C6DF8686"))
+ } else {
+ txtA11.text = "Нет"
+ CLQA11.setBackgroundColor(Color.parseColor("#C686DF8F"))
+ }
+
+ if (item.twelvea == 1) {
+ txtA12.text = "Да"
+ CLQA12.setBackgroundColor(Color.parseColor("#C686DF8F"))
+ } else {
+ txtA12.text = "Нет"
+ CLQA12.setBackgroundColor(Color.parseColor("#C6DF8686"))
+ }
}
else{
- CLQA1.setBackgroundColor(Color.parseColor("#C6DF8686"))
+ //Если анкета ПОСЛЕ небыла заполнена
+ txtStatusA.text = "ПУСТО"
+ txtStatusA.setTextColor(Color.parseColor("#FFFFFF"))
+ CVA.setCardBackgroundColor(Color.parseColor("#000000"))
+ CVColorAfter.setCardBackgroundColor(Color.parseColor("#FF8E8E8E"))
+
+ txtA1.text = ""
+ txtA2.text = ""
+ txtA3.text = ""
+ txtA4.text = ""
+ txtA5.text = ""
+ txtA6.text = ""
+ txtA7.text = ""
+ txtA8.text = ""
+ txtA9.text = ""
+ txtA10.text = ""
+ txtA11.text = ""
+ txtA12.text = ""
}
- if (item.twoa == 1) {
- txtA2.text = "Да"
- CLQA2.setBackgroundColor(Color.parseColor("#C6DF8686"))
- } else {
- txtA2.text = "Нет"
- CLQA2.setBackgroundColor(Color.parseColor("#C686DF8F"))
- }
- if (item.threea == 1) {
- txtA3.text = "Да"
- CLQA3.setBackgroundColor(Color.parseColor("#C6DF8686"))
- } else {
- txtA3.text = "Нет"
- CLQA3.setBackgroundColor(Color.parseColor("#C686DF8F"))
- }
-
- if (item.foura == 1) {
- txtA4.text = "Да"
- CLQA4.setBackgroundColor(Color.parseColor("#C6DF8686"))
- } else {
- txtA4.text = "Нет"
- CLQA4.setBackgroundColor(Color.parseColor("#C686DF8F"))
- }
-
- if (item.fivea == 1) {
- txtA5.text = "Да"
- CLQA5.setBackgroundColor(Color.parseColor("#C6DF8686"))
- } else {
- txtA5.text = "Нет"
- CLQA5.setBackgroundColor(Color.parseColor("#C686DF8F"))
- }
-
- if (item.sixa == 1) {
- txtA6.text = "Да"
- CLQA6.setBackgroundColor(Color.parseColor("#C6DF8686"))
-
- } else {
- txtA6.text = "Нет"
- CLQA6.setBackgroundColor(Color.parseColor("#C686DF8F"))
- }
-
- if (item.sevena == 1) {
- txtA7.text = "Да"
- CLQA7.setBackgroundColor(Color.parseColor("#C6DF8686"))
- } else {
- txtA7.text = "Нет"
- CLQA7.setBackgroundColor(Color.parseColor("#C686DF8F"))
- }
-
- if (item.eighta == 1) {
- txtA8.text = "Да"
- CLQA8.setBackgroundColor(Color.parseColor("#C6DF8686"))
- } else {
- txtA8.text = "Нет"
- CLQA8.setBackgroundColor(Color.parseColor("#C686DF8F"))
- }
-
- if (item.ninea == 1) {
- txtA9.text = "Да"
- CLQA9.setBackgroundColor(Color.parseColor("#C6DF8686"))
-
- } else {
- txtA9.text = "Нет"
- CLQA9.setBackgroundColor(Color.parseColor("#C686DF8F"))
- }
-
- if (item.tena == 1) {
- txtA10.text = "Да"
- CLQA10.setBackgroundColor(Color.parseColor("#C6DF8686"))
- } else {
- txtA10.text = "Нет"
- CLQA10.setBackgroundColor(Color.parseColor("#C686DF8F"))
- }
-
- if (item.elevena == 1) {
- txtA11.text = "Да"
- CLQA11.setBackgroundColor(Color.parseColor("#C6DF8686"))
- } else {
- txtA11.text = "Нет"
- CLQA11.setBackgroundColor(Color.parseColor("#C686DF8F"))
- }
-
- if (item.twelvea == 1) {
- txtA12.text = "Да"
- CLQA12.setBackgroundColor(Color.parseColor("#C6DF8686"))
- } else {
- txtA12.text = "Нет"
- CLQA12.setBackgroundColor(Color.parseColor("#C686DF8F"))
- }
}
}
@@ -259,6 +285,7 @@ class QBBAdapter() : ListAdapter(Comparator()) {
+
}
diff --git a/app/src/main/java/com/example/doctor/Patients/TabLayoutPatient/ActiveCoursesPatientFragment.kt b/app/src/main/java/com/example/doctor/Patients/TabLayoutPatient/ActiveCoursesPatientFragment.kt
new file mode 100644
index 0000000..436742f
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Patients/TabLayoutPatient/ActiveCoursesPatientFragment.kt
@@ -0,0 +1,173 @@
+package com.example.doctor.Patients.TabLayoutPatient
+
+import android.content.Intent
+import android.os.Bundle
+import androidx.fragment.app.Fragment
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ArrayAdapter
+import androidx.fragment.app.activityViewModels
+import androidx.recyclerview.widget.GridLayoutManager
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
+import com.example.doctor.DataModel
+import com.example.doctor.DoctorViewModel
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
+import com.example.doctor.Patients.Adapter.PatientListAdapter
+import com.example.doctor.Patients.Model.PatientAllModel
+import com.example.doctor.Patients.Model.PatientIdModel
+import com.example.doctor.Patients.PatientActivity
+import com.example.doctor.Patients.Reports.PatientFragment
+import com.example.doctor.Pref.ClearPref
+import com.example.doctor.Pref.ConclusionPref
+import com.example.doctor.Pref.SavePref
+import com.example.doctor.R
+import com.example.doctor.Retrofit.DoctorApi
+import com.example.doctor.databinding.FragmentActiveCoursesPatientBinding
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+
+
+class ActiveCoursesPatientFragment : Fragment(),PatientListAdapter.Listener {
+ private lateinit var binding:FragmentActiveCoursesPatientBinding
+ private val modelDoctor: DoctorViewModel by activityViewModels()
+ private val dataModel: DataModel by activityViewModels()//Для передачи данных
+ lateinit var adapterPatient: PatientListAdapter
+ private lateinit var doctorApi: DoctorApi
+ val prefDoctorConclusion = ConclusionPref()
+ val prefDoctorClear = ClearPref()
+ val prefDoctorSave = SavePref()
+
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
+
+ var patientYesList:List?=null
+
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ binding = FragmentActiveCoursesPatientBinding.inflate(layoutInflater,container,false)
+ return binding.root
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ initRcViewDay()
+ GetPatientList()
+
+ modelDoctor.PatientActiveList.observe(viewLifecycleOwner){
+ if(patientYesList!=it){
+ patientYesList=it
+ adapterPatient.submitList(it)
+ }
+ }
+ }
+
+ //Инициализация списка
+ private fun initRcViewDay() = with(binding) {
+ rcView.layoutManager =
+ GridLayoutManager(requireContext(), 1)//По вертикали будет выводить по умолчанию
+ adapterPatient = PatientListAdapter(this@ActiveCoursesPatientFragment)
+ rcView.adapter = adapterPatient
+ }
+
+ //Инициализируем Retrofit
+ private fun initRetrofit() {
+ val interceptor = HttpLoggingInterceptor()
+ interceptor.level = HttpLoggingInterceptor.Level.BODY
+
+ val client = OkHttpClient
+ .Builder()
+ .addInterceptor(interceptor)
+ .build()
+
+ val retrofit = Retrofit.Builder()
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
+ .client(client)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+
+ doctorApi = retrofit.create(DoctorApi::class.java)
+
+ }
+ //Получения списка пациентов
+ fun GetPatientList() {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listProduct = doctorApi.GetPatientAllActive("Bearer $Tokens")
+ requireActivity().runOnUiThread {
+
+ //Фиксируем полученные данные
+ val List = listProduct.body()
+ val Nice = listProduct.isSuccessful
+ val Code = listProduct.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ modelDoctor.PatientActiveList.value = List.patient
+
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+
+ companion object {
+ fun newInstance() = ActiveCoursesPatientFragment()
+ }
+
+ override fun onClickPatient(item: PatientAllModel) {
+
+ //Вывод фрагмента на активити при первоначальной загрузке
+// activity?.supportFragmentManager?.beginTransaction()
+// ?.replace(com.example.doctor.R.id.CLMainPatient, PatientFragment.newInstance())
+// ?.commit()
+// prefDoctorSave.saveIdPatient(requireContext(),item.id!!)
+// prefDoctorSave.saveViewPatient(requireContext(),1)
+ //modelDoctor.patientId.value = PatientIdModel(item.id!!)
+
+ prefDoctorSave.saveIdPatient(requireContext(),item.id!!)
+ prefDoctorSave.saveViewPatient(requireContext(),1)
+ val intetn = Intent(requireContext(), PatientActivity::class.java)
+ startActivity(intetn)
+
+
+ // dataModel.patientList.value = 1
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Patients/TabLayoutPatient/NotActiveCoursesPatientFragment.kt b/app/src/main/java/com/example/doctor/Patients/TabLayoutPatient/NotActiveCoursesPatientFragment.kt
new file mode 100644
index 0000000..53fb183
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Patients/TabLayoutPatient/NotActiveCoursesPatientFragment.kt
@@ -0,0 +1,173 @@
+package com.example.doctor.Patients.TabLayoutPatient
+
+import android.content.Intent
+import android.os.Bundle
+import androidx.fragment.app.Fragment
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.fragment.app.activityViewModels
+import androidx.recyclerview.widget.GridLayoutManager
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
+import com.example.doctor.DataModel
+import com.example.doctor.DoctorViewModel
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
+import com.example.doctor.Patients.Adapter.PatientListAdapter
+import com.example.doctor.Patients.Model.PatientAllModel
+import com.example.doctor.Patients.Model.PatientIdModel
+import com.example.doctor.Patients.PatientActivity
+import com.example.doctor.Patients.Reports.PatientFragment
+import com.example.doctor.Pref.ClearPref
+import com.example.doctor.Pref.ConclusionPref
+import com.example.doctor.Pref.SavePref
+import com.example.doctor.R
+import com.example.doctor.Retrofit.DoctorApi
+import com.example.doctor.databinding.FragmentNotActiveCoursesPatientBinding
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+
+
+class NotActiveCoursesPatientFragment : Fragment(),PatientListAdapter.Listener {
+ private lateinit var binding:FragmentNotActiveCoursesPatientBinding
+ private val model: DoctorViewModel by activityViewModels()
+ private val dataModel: DataModel by activityViewModels()//Для передачи данных
+ lateinit var adapterPatient: PatientListAdapter
+ private lateinit var doctorApi: DoctorApi
+ val prefDoctorConclusion = ConclusionPref()
+ val prefDoctorClear = ClearPref()
+ val prefDoctorSave = SavePref()
+
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
+
+ //Список не активных пациентов
+ var patientNoList: List? = null
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ binding = FragmentNotActiveCoursesPatientBinding.inflate(layoutInflater,container,false)
+ return binding.root
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ initRcViewDay()
+ GetPatientList()
+
+ model.PatientNotList.observe(viewLifecycleOwner){
+ if(patientNoList != it){
+ patientNoList = it
+ adapterPatient.submitList(it)
+ }
+ }
+ }
+
+ //Инициализация списка
+ private fun initRcViewDay() = with(binding) {
+ rcView.layoutManager =
+ GridLayoutManager(requireContext(), 1)//По вертикали будет выводить по умолчанию
+ adapterPatient = PatientListAdapter(this@NotActiveCoursesPatientFragment)
+ rcView.adapter = adapterPatient
+ }
+
+
+ //Инициализируем Retrofit
+ private fun initRetrofit() {
+ val interceptor = HttpLoggingInterceptor()
+ interceptor.level = HttpLoggingInterceptor.Level.BODY
+
+ val client = OkHttpClient
+ .Builder()
+ .addInterceptor(interceptor)
+ .build()
+
+ val retrofit = Retrofit.Builder()
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
+ .client(client)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+
+ doctorApi = retrofit.create(DoctorApi::class.java)
+
+ }
+
+ //Получения списка пациентов
+ fun GetPatientList() {
+ if (enternetCheck.isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listProduct = doctorApi.GetPatientAllNotActive("Bearer $Tokens")
+ requireActivity().runOnUiThread {
+
+ //Фиксируем полученные данные
+ val List = listProduct.body()
+ val Nice = listProduct.isSuccessful
+ val Code = listProduct.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ model.PatientNotList.value = List.patient
+
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+ override fun onClickPatient(item: PatientAllModel) {
+
+ //Вывод фрагмента на активити при первоначальной загрузке
+// activity?.supportFragmentManager?.beginTransaction()
+// ?.replace(com.example.doctor.R.id.CLMainPatient, PatientFragment.newInstance())
+// ?.commit()
+ prefDoctorSave.saveIdPatient(requireContext(),item.id!!)
+ prefDoctorSave.saveViewPatient(requireContext(),1)
+ //model.patientId.value = PatientIdModel(item.id!!)
+
+ val intetn = Intent(requireContext(), PatientActivity::class.java)
+ startActivity(intetn)
+
+
+ // dataModel.patientList.value = 1
+ }
+
+
+
+ companion object {
+
+ fun newInstance() = NotActiveCoursesPatientFragment()
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Pref/ClearPref.kt b/app/src/main/java/com/example/doctor/Pref/ClearPref.kt
index 54ca6ef..16c9095 100644
--- a/app/src/main/java/com/example/doctor/Pref/ClearPref.kt
+++ b/app/src/main/java/com/example/doctor/Pref/ClearPref.kt
@@ -6,7 +6,35 @@ import android.content.SharedPreferences
class ClearPref() {
fun clearToken(context: Context) {
- val prefDoctor: SharedPreferences = context.getSharedPreferences("DOCTOR", Context.MODE_PRIVATE)
+ val prefDoctor: SharedPreferences = context.getSharedPreferences("DOCTORtoken", Context.MODE_PRIVATE)
+ val edit = prefDoctor.edit()
+ edit?.clear()
+ edit?.apply()
+ }
+
+ fun clearViewPatient(context: Context) {
+ val prefDoctor: SharedPreferences = context.getSharedPreferences("DOCTORviewPatient", Context.MODE_PRIVATE)
+ val edit = prefDoctor.edit()
+ edit?.clear()
+ edit?.apply()
+ }
+
+ fun clearIdPatient(context: Context) {
+ val prefDoctor: SharedPreferences = context.getSharedPreferences("DOCTORIdPatient", Context.MODE_PRIVATE)
+ val edit = prefDoctor.edit()
+ edit?.clear()
+ edit?.apply()
+ }
+
+ fun clearIdCourses(context: Context) {
+ val prefDoctor: SharedPreferences = context.getSharedPreferences("DOCTORIdCourses", Context.MODE_PRIVATE)
+ val edit = prefDoctor.edit()
+ edit?.clear()
+ edit?.apply()
+ }
+
+ fun clearIdActivitis(context: Context) {
+ val prefDoctor: SharedPreferences = context.getSharedPreferences("DOCTORIdActivitis", Context.MODE_PRIVATE)
val edit = prefDoctor.edit()
edit?.clear()
edit?.apply()
diff --git a/app/src/main/java/com/example/doctor/Pref/ConclusionPref.kt b/app/src/main/java/com/example/doctor/Pref/ConclusionPref.kt
index cd2a344..1a31981 100644
--- a/app/src/main/java/com/example/doctor/Pref/ConclusionPref.kt
+++ b/app/src/main/java/com/example/doctor/Pref/ConclusionPref.kt
@@ -6,8 +6,32 @@ import android.content.SharedPreferences
class ConclusionPref() {
fun conclusionToken(context: Context):String {
- val prefDoctor: SharedPreferences = context.getSharedPreferences("DOCTOR", Context.MODE_PRIVATE)
+ val prefDoctor: SharedPreferences = context.getSharedPreferences("DOCTORtoken", Context.MODE_PRIVATE)
val token = prefDoctor.getString("token", "")
return token.toString()
}
+
+ fun conclusionViewPatient(context: Context):Int {
+ val prefDoctor: SharedPreferences = context.getSharedPreferences("DOCTORviewPatient", Context.MODE_PRIVATE)
+ val viewPatient = prefDoctor.getInt("viewPatient", 0)
+ return viewPatient.toInt()
+ }
+
+ fun conclusionIdPatient(context: Context):Int {
+ val prefDoctor: SharedPreferences = context.getSharedPreferences("DOCTORidPatient", Context.MODE_PRIVATE)
+ val idPatient = prefDoctor.getInt("idPatient", 0)
+ return idPatient.toInt()
+ }
+
+ fun conclusionIdCourses(context: Context):Int {
+ val prefDoctor: SharedPreferences = context.getSharedPreferences("DOCTORidCourses", Context.MODE_PRIVATE)
+ val idPatient = prefDoctor.getInt("idCourses", 0)
+ return idPatient.toInt()
+ }
+
+ fun conclusionIdActivitis(context: Context):Int {
+ val prefDoctor: SharedPreferences = context.getSharedPreferences("DOCTORIdActivitis", Context.MODE_PRIVATE)
+ val idPatient = prefDoctor.getInt("idActivitis", 0)
+ return idPatient.toInt()
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Pref/SavePref.kt b/app/src/main/java/com/example/doctor/Pref/SavePref.kt
index b7cbf07..689d6f4 100644
--- a/app/src/main/java/com/example/doctor/Pref/SavePref.kt
+++ b/app/src/main/java/com/example/doctor/Pref/SavePref.kt
@@ -1,15 +1,39 @@
package com.example.doctor.Pref
+import android.annotation.SuppressLint
import android.content.Context
import android.content.SharedPreferences
class SavePref (){
- fun saveToken(context: Context,token: String) {
- val prefDoctor: SharedPreferences = context.getSharedPreferences("DOCTOR", Context.MODE_PRIVATE)
- val edit = prefDoctor.edit()
+ @SuppressLint("CommitPrefEdits")
+ fun saveToken(context: Context, token: String) {
+ val prefDoctor: SharedPreferences = context.getSharedPreferences("DOCTORtoken", Context.MODE_PRIVATE)
prefDoctor.edit().putString("token", token).apply()
}
+
+ @SuppressLint("CommitPrefEdits")
+ fun saveViewPatient(context: Context, view_patient: Int) {
+ val prefDoctor: SharedPreferences = context.getSharedPreferences("DOCTORviewPatient", Context.MODE_PRIVATE)
+ prefDoctor.edit().putInt("viewPatient", view_patient).apply()
+ }
+
+ @SuppressLint("CommitPrefEdits")
+ fun saveIdPatient(context: Context, view_patient: Int) {
+ val prefDoctor: SharedPreferences = context.getSharedPreferences("DOCTORidPatient", Context.MODE_PRIVATE)
+ prefDoctor.edit().putInt("idPatient", view_patient).apply()
+ }
+
+ @SuppressLint("CommitPrefEdits")
+ fun saveIdCourses(context: Context, view_patient: Int) {
+ val prefDoctor: SharedPreferences = context.getSharedPreferences("DOCTORidCourses", Context.MODE_PRIVATE)
+ prefDoctor.edit().putInt("idCourses", view_patient).apply()
+ }
+ @SuppressLint("CommitPrefEdits")
+ fun saveIdActivitis(context: Context, view_patient: Int) {
+ val prefDoctor: SharedPreferences = context.getSharedPreferences("DOCTORIdActivitis", Context.MODE_PRIVATE)
+ prefDoctor.edit().putInt("idActivitis", view_patient).apply()
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Retrofit/DoctorApi.kt b/app/src/main/java/com/example/doctor/Retrofit/DoctorApi.kt
index 0ecc9d2..e924ba7 100644
--- a/app/src/main/java/com/example/doctor/Retrofit/DoctorApi.kt
+++ b/app/src/main/java/com/example/doctor/Retrofit/DoctorApi.kt
@@ -1,24 +1,30 @@
package com.example.doctor.Retrofit
+import com.example.doctor.Appeals.TabLayout.Model.AppealsNewListModel
+import com.example.doctor.Appeals.TabLayout.Model.AppealsOldListModel
import com.example.doctor.Auth.Model.AuthModel
import com.example.doctor.Auth.Model.CheckTokenModel
import com.example.doctor.Auth.Model.UserModel
+import com.example.doctor.Home.HomeInfoModel
import com.example.doctor.Patients.Model.MessageModel
import com.example.doctor.Patients.Model.CreatePatientModel
import com.example.doctor.Patients.Model.PatientAllListModel
import com.example.doctor.Patients.Model.PatientAllModel
import com.example.doctor.Patients.Model.PatientModel
import com.example.doctor.Patients.Model.PauseModel
+import com.example.doctor.Patients.Reports.Courses.SportCoursDoctorListModel
+import com.example.doctor.Patients.Reports.Courses.SportCoursListModel
import com.example.doctor.Patients.Reports.Edit.EditSportListNoModel
import com.example.doctor.Patients.Reports.Edit.EditSportListYesModel
-import com.example.doctor.Patients.Reports.Edit.UpdateSportTaskNoModel
-import com.example.doctor.Patients.Reports.Edit.UpdateSportTaskYesModel
import com.example.doctor.Patients.Reports.QBAListModel
import com.example.doctor.Patients.Reports.Requests.ClearSportPatientModel
-import com.example.doctor.Patients.Reports.SportCoursListModel
+import com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Model.EditCoursesDoctorListAllModel
+import com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Model.EditCoursesDoctorListYourModel
+import com.example.doctor.Setting.Courses.Model.CoursesDoctorListModel
import com.example.doctor.Sport.AddSportPatientModel
import retrofit2.Response
import retrofit2.http.Body
+import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Headers
@@ -49,10 +55,20 @@ interface DoctorApi {
@GET("GetPatientAll")
suspend fun GetPatientAll(@Header("Authorization") token:String):Response
+ //Вывод пациентов конкретного врача с активным курсом
+ @Headers("Content-Type: application/json")
+ @GET("GetPatientAllActive")
+ suspend fun GetPatientAllActive(@Header("Authorization") token:String):Response
+
+ //Вывод пациентов конкретного врача с не активным курсом
+ @Headers("Content-Type: application/json")
+ @GET("GetPatientAllNotActive")
+ suspend fun GetPatientAllNotActive(@Header("Authorization") token:String):Response
+
//Вывод всех пациентов
@Headers("Content-Type: application/json")
@GET("GetPatientID")
- suspend fun GetPatientID(@Header("Authorization") token:String):Response
+ suspend fun GetPatientID(@Header("Authorization") token:String,@Query("id") id:Int):Response
//Поиск пациентов
@Headers("Content-Type: application/json")
@@ -68,6 +84,12 @@ interface DoctorApi {
@GET("GetCoursAllPatient")
suspend fun GetCoursAllPatient(@Header("Authorization") token:String,@Query("id") id:Int):Response
+ //Вывод курсов созданных врачем
+ @Headers("Content-Type: application/json")
+ @GET("GetCoursesDoctorPatient")
+ suspend fun GetCoursesDoctorPatient(@Header("Authorization") token:String,@Query("id") id:Int):Response
+
+
//Вывод анкеты пациентов которые сейчас действуют
@Headers("Content-Type: application/json")
@GET("GetPatientBAQiestionar")
@@ -131,6 +153,82 @@ interface DoctorApi {
//Отключенных упражнений
@Headers("Content-Type: application/json")
@PUT("UpdateBlockSportTasksNo")
- suspend fun UpdateBlockSportTasksNo(@Header("Authorization") token:String,@Query("id") id:Int,):Response
+ suspend fun UpdateBlockSportTasksNo(@Header("Authorization") token:String,@Query("id") id:Int):Response
+
+
+ //Отключенных упражнений
+ @Headers("Content-Type: application/json")
+ @PUT("UpdatePatientLogin")
+ suspend fun UpdatePatientLogin(@Header("Authorization") token:String,@Query("id") id:Int,@Query("login") login:String):Response
+ //Отключенных упражнений
+ @Headers("Content-Type: application/json")
+ @PUT("UpdatePatientPassword")
+ suspend fun UpdatePatientPassword(@Header("Authorization") token:String,@Query("id") id:Int,@Query("password") password:String):Response
+
+ //Добавление курса пациенту
+ @Headers("Content-Type: application/json")
+ @POST("AddSportPatient")
+ suspend fun AddSportPatient(@Header("Authorization") token:String,@Query("id_patient") id:Int,@Query("id_course") id_course:Int,@Query("all_day") all_day:Int):Response
+
+
+
+
+ //Вывод необработанных сообщений
+ @Headers("Content-Type: application/json")
+ @GET("GetAppealsDoctorNew")
+ suspend fun GetAppealsDoctorNew(@Header("Authorization") token:String) :Response
+
+ //Вывод необработанных сообщений
+ @Headers("Content-Type: application/json")
+ @GET("GetAppealsDoctorOld")
+ suspend fun GetAppealsDoctorOld(@Header("Authorization") token:String) :Response
+
+
+ //Подтверждение необработанных сообщений
+ @Headers("Content-Type: application/json")
+ @PUT("UpdateMessageDoctor")
+ suspend fun UpdateMessageDoctor(@Header("Authorization") token:String,@Query("id") id:Int,@Query("id_patient") id_patient:Int) :Response
+
+ //Отправка сообщения пациенту
+ @Headers("Content-Type: application/json")
+ @POST("AddMessageDoctor")
+ suspend fun AddMessageDoctor(@Header("Authorization") token:String,@Query("login") login:String,@Query("text") text:String) :Response
+
+ //Создание курса врачем
+ @Headers("Content-Type: application/json")
+ @POST("AddCoursesName")
+ suspend fun AddCoursesName(@Header("Authorization") token:String,@Query("name") name:String,@Query("description") description:String) :Response
+
+ //Вывод курсов созданных врачем
+ @Headers("Content-Type: application/json")
+ @GET("GetCoursesDoctor")
+ suspend fun GetCoursesDoctor(@Header("Authorization") token:String) :Response
+
+ //Вывод упражнений которые не входят в курс
+ @Headers("Content-Type: application/json")
+ @GET("GetEditCourseDoctorAll")
+ suspend fun GetEditCourseDoctorAll(@Header("Authorization") token:String,@Query("id_doctor_courses") id_doctor_courses:Int) :Response
+
+
+ //Вывод упражнений которые входят в курс
+ @Headers("Content-Type: application/json")
+ @GET("GetEditCourseDoctorYour")
+ suspend fun GetEditCourseDoctorYour(@Header("Authorization") token:String,@Query("id_doctor_courses") id_doctor_courses:Int) :Response
+
+
+ //Добавление упражнений в курс
+ @Headers("Content-Type: application/json")
+ @POST("AddCoursesCreatingDoctor")
+ suspend fun AddCoursesCreatingDoctor(@Header("Authorization") token:String,@Query("id_sports_tasks") id_sports_tasks:Int,@Query("id_sets_of_sports_activities") id_sets_of_sports_activities:Int) :Response
+
+ //Удаление упражнений из курса
+ @Headers("Content-Type: application/json")
+ @DELETE("ClearCoursesCreatingDoctor")
+ suspend fun ClearCoursesCreatingDoctor(@Header("Authorization") token:String,@Query("id_sets_of_sports_exercises") id_sets_of_sports_exercises:Int) :Response
+
+ //Вывод данных для первой страницы врача
+ @Headers("Content-Type: application/json")
+ @GET("CountPatientAndAppeals")
+ suspend fun CountPatientAndAppeals(@Header("Authorization") token:String) :Response
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Setting/Courses/Adapter/CoursesDoctorAdapter.kt b/app/src/main/java/com/example/doctor/Setting/Courses/Adapter/CoursesDoctorAdapter.kt
new file mode 100644
index 0000000..df1f594
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Setting/Courses/Adapter/CoursesDoctorAdapter.kt
@@ -0,0 +1,90 @@
+package com.example.doctor.Setting.Courses.Adapter
+
+import android.annotation.SuppressLint
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.recyclerview.widget.DiffUtil
+import androidx.recyclerview.widget.ListAdapter
+import androidx.recyclerview.widget.RecyclerView
+
+import com.example.doctor.R
+import com.example.doctor.Setting.Courses.Model.CoursesDoctorModel
+import com.example.doctor.databinding.ItemCardCoursesDoctorBinding
+
+
+class CoursesDoctorAdapter(val listener: Listener) :
+ ListAdapter(
+ Comparator()
+ ) {//Productitem - по этой форме будем заполнять.//ProductAdapter.holder - это создаваемый holder который хранит логику как нужно заполнять карточку
+
+
+ //В holder создаетс код с помошью которого мы будем заполнять и сохронять разметку
+ class Holder(view: View, val listener: Listener) :
+ RecyclerView.ViewHolder(view) {//Класс который будет хранить сссылки на элементы, и отвечает за один элемент за 1 раз, то есть сначсало нулевой элемент заполнит, потом первый, потом второй и т.д.
+ //Для передачи данных
+
+ val binding = ItemCardCoursesDoctorBinding.bind(view)//view - здесь храянтся элементы и мы их bind заполним в ListItemBinding//ListItemBinding - это клласс даннйо разметки(карточки) которую мы будем заполнять, а нужна дання переменная(binding), чтобы мжно было при заполнение обращатся к элементам карточки
+
+ var itemTemp: CoursesDoctorModel? =
+ null//Глобальная переменная для нашего item, чтобы можно было передать данные для нажатия
+
+ //init - дает возможность внутри адаптера обращаться к элементам экрана
+ init {
+ itemView.setOnClickListener {//Нажатие на ячейку//itemView - это весь элемент карточки из списка
+ //itemView.setEnabled(false)
+ itemTemp?.let { it1 -> listener.onClickCourses(it1) }
+
+ }
+ }
+
+ @SuppressLint("SuspiciousIndentation", "SetTextI18n")
+ fun bind(item: CoursesDoctorModel) = with(binding) {//Productitem - перпедаем данные
+ itemTemp = item
+ txtNumberCurds.text = item.number.toString() + "."
+ txtNameCoursesDoctor.text = item.name
+ }
+
+
+ }
+
+
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
+ val view = LayoutInflater.from(parent.context)
+ .inflate(R.layout.item_card_courses_doctor, parent, false)//Создаем(надуваем) list_item
+ return Holder(view, listener)//Через Holder возврощаем view
+ }
+
+ override fun onBindViewHolder(holder: Holder, position: Int) {
+ val view = holder.bind(getItem(position))//Заполняем по позиции карточку
+ }
+
+
+ //Comparator - сравнивает старый список и новый и если что-то изменилось, то работает с конкретным изменением списке, а не весь список переписывает
+ class Comparator : DiffUtil.ItemCallback() {
+ override fun areItemsTheSame(
+ oldItem: CoursesDoctorModel,
+ newItem: CoursesDoctorModel
+ ): Boolean {//Тут лучше всего сравнивать по id//oldItem - элементы старого списка, newItem - элементы нового списка//Возврощает Boolean, тоесть есть изменения или нет
+ return oldItem.id == newItem.id//Сравниваем полностью весь список новы и старый, по очередно по одной карточке и по элементно, то есть нулевой элемент, первый, второй и т.д.. Но лучше сравнивать по id списки, а не просто весь список, так как это эфективнее, так как id уникальный(oldItem.id == newItem.id)
+ }
+
+ override fun areContentsTheSame(
+ oldItem: CoursesDoctorModel,
+ newItem: CoursesDoctorModel
+ ): Boolean {//Утут нужно сравнивать весь спсок старых элементов и новых
+ return oldItem == newItem//Сравниваем полностью весь список новы и старый
+ }
+ }
+
+ //Интерфейс нажатия на кнопку удалить товар из корзины
+ interface Listener {
+ fun onClickCourses(item: CoursesDoctorModel)
+ }
+
+
+}
+
+
+
+
diff --git a/app/src/main/java/com/example/doctor/Setting/Courses/CoursesActivity.kt b/app/src/main/java/com/example/doctor/Setting/Courses/CoursesActivity.kt
new file mode 100644
index 0000000..2012e23
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Setting/Courses/CoursesActivity.kt
@@ -0,0 +1,22 @@
+package com.example.doctor.Setting.Courses
+
+import androidx.appcompat.app.AppCompatActivity
+import android.os.Bundle
+import com.example.doctor.Patients.Reports.PatientFragment
+import com.example.doctor.R
+import com.example.doctor.Setting.Courses.EditCourses.CreateCoursesFragment
+import com.example.doctor.databinding.ActivityCoursesBinding
+
+class CoursesActivity : AppCompatActivity() {
+ private lateinit var binding: ActivityCoursesBinding
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ binding = ActivityCoursesBinding.inflate(layoutInflater)
+ setContentView(binding.root)
+
+ binding.apply {
+ supportFragmentManager.beginTransaction().replace(R.id.CLCoursesActivity, CreateCoursesFragment.newInstance()).commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/CreateCoursesFragment.kt b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/CreateCoursesFragment.kt
new file mode 100644
index 0000000..4c29306
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/CreateCoursesFragment.kt
@@ -0,0 +1,407 @@
+package com.example.doctor.Setting.Courses.EditCourses
+
+import android.content.Context
+import android.content.Intent
+import android.net.ConnectivityManager
+import android.net.NetworkCapabilities
+import android.os.Build
+import android.os.Bundle
+import android.util.Log
+import androidx.fragment.app.Fragment
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.Toast
+import androidx.fragment.app.FragmentActivity
+import androidx.fragment.app.activityViewModels
+import androidx.recyclerview.widget.GridLayoutManager
+import com.example.doctor.Adapter.VpAdapter
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
+import com.example.doctor.DoctorViewModel
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetFragment
+import com.example.doctor.Pref.ClearPref
+import com.example.doctor.Pref.ConclusionPref
+import com.example.doctor.Pref.SavePref
+import com.example.doctor.R
+import com.example.doctor.Retrofit.DoctorApi
+import com.example.doctor.Setting.Courses.Adapter.CoursesDoctorAdapter
+import com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.AllSportCoursesDoctorFragment
+import com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.YourSportCoursesDoctorFragment
+import com.example.doctor.Setting.Courses.Model.CoursesDoctorModel
+import com.example.doctor.Toast.showCustomInfoToast
+import com.example.doctor.databinding.FragmentCreateCoursesBinding
+import com.google.android.material.tabs.TabLayoutMediator
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+
+
+class CreateCoursesFragment : Fragment(),CoursesDoctorAdapter.Listener {
+ private lateinit var binding: FragmentCreateCoursesBinding
+ private val model: DoctorViewModel by activityViewModels()
+ private lateinit var doctorApi: DoctorApi
+ lateinit var adapter: CoursesDoctorAdapter
+ val prefDoctorConclusion = ConclusionPref()
+ val prefDoctorClear = ClearPref()
+ val prefDoctorSave = SavePref()
+
+
+
+
+
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ binding = FragmentCreateCoursesBinding.inflate(layoutInflater,container,false)
+ return binding.root
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ binding.apply {
+ initRcView()
+
+ GetCoursesDoctor()
+ button()
+
+ CLCreate.visibility = View.GONE
+
+ btnCreateCourses.setOnClickListener{
+ CLCreate.visibility = View.VISIBLE
+ }
+
+ //Закрытие экоана создания названия
+ CLCreate.setOnClickListener{
+ CLCreate.visibility = View.GONE
+ }
+ btnExitCreat.setOnClickListener{
+ CLCreate.visibility = View.GONE
+ }
+
+// CLEditCourses.setOnClickListener {
+// CLEditCourses.visibility = View.GONE
+// }
+
+
+ btnExit.setOnClickListener{
+ activity?.finish()
+ }
+
+
+
+
+ model.CoursesDoctorList.observe(viewLifecycleOwner) {
+ adapter.submitList(it)
+ }
+
+
+ btnCreateCoursrsDoctor.setOnClickListener{
+ CreateCoursesDoctor()
+ }
+
+
+
+ }
+ }
+
+
+
+ private fun CreateCoursesDoctor() {
+ val name = binding.edCoursesDoctorName.text.toString()
+ val description = binding.edCoursesDoctorDescription.text.toString()
+ if(name!="" && description !=""){
+ AddCoursesName(name,description)
+ }
+ else{
+ Toast(requireContext()).showCustomInfoToast("Не все поля заполнены", requireActivity())
+ }
+
+ }
+
+ private fun button() = with(binding){
+ CVCardCreateCourses.setOnClickListener {
+
+ }
+// CVEditCourses.setOnClickListener {
+//
+// }
+ }
+
+ //Получения списка пациентов
+ fun AddCoursesName(name:String,description:String) {
+ if (isOnline(requireContext())) {
+ visibleLoadYes()
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listCreateCoursesDoctor = doctorApi.AddCoursesName("Bearer $Tokens",name,description)
+
+ requireActivity().runOnUiThread {
+
+
+
+ //Фиксируем полученные данные
+ val List = listCreateCoursesDoctor.body()
+ val Nice = listCreateCoursesDoctor.isSuccessful
+ val Code = listCreateCoursesDoctor.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
+ GetCoursesDoctor()
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ visibleLoadNo()
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+ //Получения списка курсов созданных доктором
+ fun GetCoursesDoctor() {
+ if (isOnline(requireContext())) {
+ visibleLoadYes()
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listCoursesDoctor = doctorApi.GetCoursesDoctor("Bearer $Tokens")
+
+ requireActivity().runOnUiThread {
+
+
+
+ //Фиксируем полученные данные
+ val List = listCoursesDoctor.body()
+ val Nice = listCoursesDoctor.isSuccessful
+ val Code = listCoursesDoctor.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ model.CoursesDoctorList.value = List.sport_courses_doctor
+ binding.txtNull.visibility = View.GONE
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+
+ visibleLoadNo()
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ //Инициализация списка
+ private fun initRcView() = with(binding) {
+ rcView.layoutManager = GridLayoutManager(requireContext(), 1)//По вертикали будет выводить по умолчанию
+ adapter = CoursesDoctorAdapter(this@CreateCoursesFragment)
+ rcView.adapter = adapter
+ }
+
+ //Инициализируем Retrofit
+ private fun initRetrofit() {
+ val interceptor = HttpLoggingInterceptor()
+ interceptor.level = HttpLoggingInterceptor.Level.BODY
+
+ val client = OkHttpClient
+ .Builder()
+ .addInterceptor(interceptor)
+ .build()
+
+ val retrofit = Retrofit.Builder()
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
+ .client(client)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+
+ doctorApi = retrofit.create(DoctorApi::class.java)
+
+ }
+
+
+ fun visible1()=with(binding){
+ constraintLayout2.visibility = View.VISIBLE
+ CLCreate.visibility = View.GONE
+ // CLEditCourses.visibility = View.GONE
+ CLLoad.visibility = View.GONE
+ }
+ fun visible2()=with(binding){
+ constraintLayout2.visibility = View.GONE
+ CLCreate.visibility = View.VISIBLE
+ //CLEditCourses.visibility = View.GONE
+ CLLoad.visibility = View.GONE
+ }
+
+ fun visible3()=with(binding){
+ constraintLayout2.visibility = View.GONE
+ CLCreate.visibility = View.GONE
+ // CLEditCourses.visibility = View.VISIBLE
+ CLLoad.visibility = View.GONE
+ }
+
+ fun visibleLoadYes()=with(binding){
+ CLLoad.visibility = View.VISIBLE
+ }
+ fun visibleLoadNo()=with(binding){
+ CLLoad.visibility = View.GONE
+ }
+ companion object {
+
+ fun newInstance() = CreateCoursesFragment()
+ }
+// //Получения списка курсов созданных доктором
+// fun GetEditCourseDoctorAll(id:Int) {
+// if (isOnline(requireContext())) {
+// initRetrofit()
+// val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+// CoroutineScope(Dispatchers.IO).launch {
+// val listCoursesDoctor = doctorApi.GetEditCourseDoctorAll("Bearer $Tokens",id)
+//
+// requireActivity().runOnUiThread {
+//
+// //Фиксируем полученные данные
+// val CoursesDoctorList = listCoursesDoctor.body()
+//
+// //Если нету ошибок
+// if (CoursesDoctorList != null) {
+// model.EditCoursesDoctorAllList.value = CoursesDoctorList.set_of_sports_exercises_all
+// binding.txtNull.visibility = View.GONE
+// }
+// else{
+// binding.txtNull.visibility = View.VISIBLE
+// }
+//
+// }
+//
+// }
+// } else {
+// val intetn = Intent(requireContext(), EnternetActivity::class.java)
+// activity?.finish()
+// startActivity(intetn)
+// }
+//
+// }
+// //Получения списка курсов созданных доктором
+// fun GetEditCourseDoctorYour(id:Int) {
+// if (isOnline(requireContext())) {
+// initRetrofit()
+// val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+// CoroutineScope(Dispatchers.IO).launch {
+// val listCoursesDoctor = doctorApi.GetEditCourseDoctorYour("Bearer $Tokens",id)
+//
+// requireActivity().runOnUiThread {
+//
+// //Фиксируем полученные данные
+// val CoursesDoctorList = listCoursesDoctor.body()
+//
+// //Если нету ошибок
+// if (CoursesDoctorList != null) {
+// model.EditCoursesDoctorYourList.value = CoursesDoctorList.set_of_sports_exercises_your
+// }
+// }
+// }
+// } else {
+// val intetn = Intent(requireContext(), EnternetActivity::class.java)
+// activity?.finish()
+// startActivity(intetn)
+// }
+//
+// }
+
+
+
+ //Проверка интернета
+ fun isOnline(context: Context): Boolean {
+ if (context == null) return false
+ val connectivityManager =
+ context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ val capabilities =
+ connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)
+ if (capabilities != null) {
+ when {
+ capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> {
+ return true
+ }
+
+ capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> {
+ return true
+ }
+
+ capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> {
+ return true
+ }
+ }
+ }
+ } else {
+ val activeNetworkInfo = connectivityManager.activeNetworkInfo
+ if (activeNetworkInfo != null && activeNetworkInfo.isConnected) {
+ return true
+ }
+ }
+ return false
+ }
+ override fun onClickCourses(item: CoursesDoctorModel){
+// // CLEditCourses.visibility = View.VISIBLE
+// prefDoctorSave.saveIdCourses(requireContext(),item.id)
+// prefDoctorSave.saveIdActivitis(requireContext(),item.id_activity)
+// // model.CoursesDoctorCA.value= CoursesDoctorCA(item.id,item.id_activity)
+// GetEditCourseDoctorAll(item.id)
+// GetEditCourseDoctorYour(item.id)
+
+ model.CoursesCustomDoctor.value = item
+ activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLCoursesActivity, EditCoursesFragment.newInstance())?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/EditCoursesFragment.kt b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/EditCoursesFragment.kt
new file mode 100644
index 0000000..18ac01d
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/EditCoursesFragment.kt
@@ -0,0 +1,242 @@
+package com.example.doctor.Setting.Courses.EditCourses
+
+import android.content.Context
+import android.content.Intent
+import android.net.ConnectivityManager
+import android.net.NetworkCapabilities
+import android.os.Build
+import android.os.Bundle
+import androidx.fragment.app.Fragment
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.fragment.app.FragmentActivity
+import androidx.fragment.app.activityViewModels
+import com.example.doctor.Adapter.VpAdapter
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
+import com.example.doctor.DoctorViewModel
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Pref.ClearPref
+import com.example.doctor.Pref.ConclusionPref
+import com.example.doctor.Pref.SavePref
+import com.example.doctor.R
+import com.example.doctor.Retrofit.DoctorApi
+import com.example.doctor.Setting.Courses.Adapter.CoursesDoctorAdapter
+import com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.AllSportCoursesDoctorFragment
+import com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.YourSportCoursesDoctorFragment
+import com.example.doctor.databinding.FragmentEditCoursesBinding
+import com.google.android.material.tabs.TabLayoutMediator
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+
+
+class EditCoursesFragment : Fragment() {
+ private lateinit var binding:FragmentEditCoursesBinding
+ private val model: DoctorViewModel by activityViewModels()
+ private lateinit var doctorApi: DoctorApi
+ lateinit var adapter: CoursesDoctorAdapter
+ val prefDoctorConclusion = ConclusionPref()
+ val prefDoctorClear = ClearPref()
+ val prefDoctorSave = SavePref()
+
+ private val tList = listOf(
+ "добавленные",
+ "Все",
+ )
+
+ //Список с фрагментами для переключения
+ private val flist = listOf(
+ YourSportCoursesDoctorFragment.newInstance(),
+ AllSportCoursesDoctorFragment.newInstance(),
+
+ )
+
+
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ binding = FragmentEditCoursesBinding.inflate(layoutInflater,container,false)
+ return binding.root
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ binding.apply {
+ init()
+
+ binding.btnBack.setOnClickListener{
+ activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLCoursesActivity, CreateCoursesFragment.newInstance())?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
+
+ }
+
+ model.CoursesCustomDoctor.observe(viewLifecycleOwner){
+ txtNameCourses.text = it.name
+ GetEditCourseDoctorYour(it.id)
+ GetEditCourseDoctorAll(it.id)
+ }
+ }
+ }
+
+ //Получения списка упражнений созданных врачем
+ fun GetEditCourseDoctorYour(id:Int) {
+ if (isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listCoursesDoctor = doctorApi.GetEditCourseDoctorYour("Bearer $Tokens",id)
+
+ requireActivity().runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = listCoursesDoctor.body()
+ val Nice = listCoursesDoctor.isSuccessful
+ val Code = listCoursesDoctor.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ model.EditCoursesDoctorYourList.value = List.set_of_sports_exercises_your
+
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+ }
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+ //Получения списка курсов созданных доктором
+ fun GetEditCourseDoctorAll(id:Int) {
+ if (isOnline(requireContext())) {
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listCoursesDoctor = doctorApi.GetEditCourseDoctorAll("Bearer $Tokens",id)
+
+ requireActivity().runOnUiThread {
+
+ //Фиксируем полученные данные
+ val CoursesDoctorList = listCoursesDoctor.body()
+
+ //Если нету ошибок
+ if (CoursesDoctorList != null) {
+ model.EditCoursesDoctorAllList.value = CoursesDoctorList.set_of_sports_exercises_all
+ }
+
+
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+
+ //Функция подключения переключения
+ private fun init() = with(binding) {
+ val adapter = VpAdapter(activity as FragmentActivity, flist)
+ vpCourses.adapter = adapter
+
+ //Переключения (связываем таблаяут(переключатель) с viewpager, чтобы переключать фрагменты)
+ TabLayoutMediator(tabLayoutCourses, vpCourses) { tab, pos ->
+ tab.text =
+ tList[pos]//tab - нажатая кнопка, pos - позиция кнопки, tList[pos] - передаем название по полученной позиции
+ }.attach()// attach() - чтобы все переключалось, а не вывадило постоянно один экран
+
+ //Изменения цвета в зависомости на каком из tabLayout вы находитесь
+ binding.tabLayoutCourses.setTabTextColors(
+ getResources().getColor(R.color.black),
+ getResources().getColor(R.color.white)
+ );
+
+
+ }
+
+ //Инициализируем Retrofit
+ private fun initRetrofit() {
+ val interceptor = HttpLoggingInterceptor()
+ interceptor.level = HttpLoggingInterceptor.Level.BODY
+
+ val client = OkHttpClient
+ .Builder()
+ .addInterceptor(interceptor)
+ .build()
+
+ val retrofit = Retrofit.Builder()
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
+ .client(client)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+
+ doctorApi = retrofit.create(DoctorApi::class.java)
+
+ }
+
+ //Проверка интернета
+ fun isOnline(context: Context): Boolean {
+ if (context == null) return false
+ val connectivityManager =
+ context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ val capabilities =
+ connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)
+ if (capabilities != null) {
+ when {
+ capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> {
+ return true
+ }
+
+ capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> {
+ return true
+ }
+
+ capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> {
+ return true
+ }
+ }
+ }
+ } else {
+ val activeNetworkInfo = connectivityManager.activeNetworkInfo
+ if (activeNetworkInfo != null && activeNetworkInfo.isConnected) {
+ return true
+ }
+ }
+ return false
+ }
+
+
+ companion object {
+ fun newInstance() = EditCoursesFragment()
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/Adapter/EditCoursesDoctorAllAdapter.kt b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/Adapter/EditCoursesDoctorAllAdapter.kt
new file mode 100644
index 0000000..2b9b13a
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/Adapter/EditCoursesDoctorAllAdapter.kt
@@ -0,0 +1,107 @@
+package com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Adapter
+
+import android.annotation.SuppressLint
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.recyclerview.widget.DiffUtil
+import androidx.recyclerview.widget.ListAdapter
+import androidx.recyclerview.widget.RecyclerView
+import com.example.doctor.R
+import com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Model.EditCoursesDoctorModel
+import com.example.doctor.databinding.ItemEditSportYesBinding
+
+
+class EditCoursesDoctorAllAdapter(val listener_sport: Listener) :
+ ListAdapter(
+ Comparator()
+ ) {//Productitem - по этой форме будем заполнять.//ProductAdapter.holder - это создаваемый holder который хранит логику как нужно заполнять карточку
+
+
+ //В holder создаетс код с помошью которого мы будем заполнять и сохронять разметку
+ class Holder(view: View, val listener_sport: Listener) :
+ RecyclerView.ViewHolder(view) {//Класс который будет хранить сссылки на элементы, и отвечает за один элемент за 1 раз, то есть сначсало нулевой элемент заполнит, потом первый, потом второй и т.д.
+ //Для передачи данных
+
+ val binding = ItemEditSportYesBinding.bind(view)//view - здесь храянтся элементы и мы их bind заполним в ListItemBinding//ListItemBinding - это клласс даннйо разметки(карточки) которую мы будем заполнять, а нужна дання переменная(binding), чтобы мжно было при заполнение обращатся к элементам карточки
+
+ var itemTemp: EditCoursesDoctorModel? =
+ null//Глобальная переменная для нашего item, чтобы можно было передать данные для нажатия
+
+ //init - дает возможность внутри адаптера обращаться к элементам экрана
+ init {
+ binding.btnYeyYes.setOnClickListener {//Нажатие на ячейку//itemView - это весь элемент карточки из списка
+ itemTemp?.let { it1 -> listener_sport.onClickCoursesAll(it1) }
+ }
+ }
+
+ @SuppressLint("SuspiciousIndentation")
+ fun bind(item: EditCoursesDoctorModel) = with(binding) {//Productitem - перпедаем данные
+ itemTemp = item
+ txtNumber.text = item.number.toString()+"."
+ txtNameSport.text = item.name
+ txtDescriptionSport.text = item.description
+
+ if (item.expand) {
+ binding.txtDescriptionSport.maxLines = 100
+
+ } else {
+ binding.txtDescriptionSport.maxLines = 1
+
+ }
+
+ binding.CardViewOld.setOnClickListener {
+ if (item.expand == false) {
+ binding.txtDescriptionSport.maxLines = 100
+ item.expand = true
+ } else {
+ binding.txtDescriptionSport.maxLines = 1
+ item.expand = false
+ }
+ }
+
+ }
+
+
+ }
+
+
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
+ val view = LayoutInflater.from(parent.context)
+ .inflate(R.layout.item_edit_sport_yes, parent, false)//Создаем(надуваем) list_item
+ return Holder(view, listener_sport)//Через Holder возврощаем view
+ }
+
+ override fun onBindViewHolder(holder: Holder, position: Int) {
+ val view = holder.bind(getItem(position))//Заполняем по позиции карточку
+ }
+
+
+ //Comparator - сравнивает старый список и новый и если что-то изменилось, то работает с конкретным изменением списке, а не весь список переписывает
+ class Comparator : DiffUtil.ItemCallback() {
+ override fun areItemsTheSame(
+ oldItem: EditCoursesDoctorModel,
+ newItem: EditCoursesDoctorModel
+ ): Boolean {//Тут лучше всего сравнивать по id//oldItem - элементы старого списка, newItem - элементы нового списка//Возврощает Boolean, тоесть есть изменения или нет
+ return oldItem.id == newItem.id//Сравниваем полностью весь список новы и старый, по очередно по одной карточке и по элементно, то есть нулевой элемент, первый, второй и т.д.. Но лучше сравнивать по id списки, а не просто весь список, так как это эфективнее, так как id уникальный(oldItem.id == newItem.id)
+ }
+
+ override fun areContentsTheSame(
+ oldItem: EditCoursesDoctorModel,
+ newItem: EditCoursesDoctorModel
+ ): Boolean {//Утут нужно сравнивать весь спсок старых элементов и новых
+ return oldItem == newItem//Сравниваем полностью весь список новы и старый
+ }
+ }
+
+ //Интерфейс нажатия на кнопку удалить товар из корзины
+ interface Listener {
+ fun onClickCoursesAll(item: EditCoursesDoctorModel)
+ }
+
+
+}
+
+
+
+
diff --git a/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/Adapter/EditCoursesDoctorYourAdapter.kt b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/Adapter/EditCoursesDoctorYourAdapter.kt
new file mode 100644
index 0000000..54769d2
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/Adapter/EditCoursesDoctorYourAdapter.kt
@@ -0,0 +1,107 @@
+package com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Adapter
+
+import android.annotation.SuppressLint
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.recyclerview.widget.DiffUtil
+import androidx.recyclerview.widget.ListAdapter
+import androidx.recyclerview.widget.RecyclerView
+import com.example.doctor.R
+import com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Model.EditCoursesDoctorModel
+import com.example.doctor.databinding.ItemEditSportNoBinding
+
+
+class EditCoursesDoctorYourAdapter(val listener_sport: Listener) :
+ ListAdapter(
+ Comparator()
+ ) {//Productitem - по этой форме будем заполнять.//ProductAdapter.holder - это создаваемый holder который хранит логику как нужно заполнять карточку
+
+
+ //В holder создаетс код с помошью которого мы будем заполнять и сохронять разметку
+ class Holder(view: View, val listener_sport: Listener) :
+ RecyclerView.ViewHolder(view) {//Класс который будет хранить сссылки на элементы, и отвечает за один элемент за 1 раз, то есть сначсало нулевой элемент заполнит, потом первый, потом второй и т.д.
+ //Для передачи данных
+
+ val binding = ItemEditSportNoBinding.bind(view)//view - здесь храянтся элементы и мы их bind заполним в ListItemBinding//ListItemBinding - это клласс даннйо разметки(карточки) которую мы будем заполнять, а нужна дання переменная(binding), чтобы мжно было при заполнение обращатся к элементам карточки
+
+ var itemTemp: EditCoursesDoctorModel? =
+ null//Глобальная переменная для нашего item, чтобы можно было передать данные для нажатия
+
+ //init - дает возможность внутри адаптера обращаться к элементам экрана
+ init {
+ binding.btnYeyNo.setOnClickListener {//Нажатие на ячейку//itemView - это весь элемент карточки из списка
+ itemTemp?.let { it1 -> listener_sport.onClickCoursesYour(it1) }
+ }
+ }
+
+ @SuppressLint("SuspiciousIndentation")
+ fun bind(item: EditCoursesDoctorModel) = with(binding) {//Productitem - перпедаем данные
+ itemTemp = item
+ txtNumber.text = item.number.toString()+"."
+ txtNameSport.text = item.name
+ txtDescriptionSport.text = item.description
+
+ if (item.expand) {
+ binding.txtDescriptionSport.maxLines = 100
+
+ } else {
+ binding.txtDescriptionSport.maxLines = 1
+
+ }
+
+ binding.CardViewOld.setOnClickListener {
+ if (item.expand == false) {
+ binding.txtDescriptionSport.maxLines = 100
+ item.expand = true
+ } else {
+ binding.txtDescriptionSport.maxLines = 1
+ item.expand = false
+ }
+ }
+
+ }
+
+
+ }
+
+
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
+ val view = LayoutInflater.from(parent.context)
+ .inflate(R.layout.item_edit_sport_no, parent, false)//Создаем(надуваем) list_item
+ return Holder(view, listener_sport)//Через Holder возврощаем view
+ }
+
+ override fun onBindViewHolder(holder: Holder, position: Int) {
+ val view = holder.bind(getItem(position))//Заполняем по позиции карточку
+ }
+
+
+ //Comparator - сравнивает старый список и новый и если что-то изменилось, то работает с конкретным изменением списке, а не весь список переписывает
+ class Comparator : DiffUtil.ItemCallback() {
+ override fun areItemsTheSame(
+ oldItem: EditCoursesDoctorModel,
+ newItem: EditCoursesDoctorModel
+ ): Boolean {//Тут лучше всего сравнивать по id//oldItem - элементы старого списка, newItem - элементы нового списка//Возврощает Boolean, тоесть есть изменения или нет
+ return oldItem.id == newItem.id//Сравниваем полностью весь список новы и старый, по очередно по одной карточке и по элементно, то есть нулевой элемент, первый, второй и т.д.. Но лучше сравнивать по id списки, а не просто весь список, так как это эфективнее, так как id уникальный(oldItem.id == newItem.id)
+ }
+
+ override fun areContentsTheSame(
+ oldItem: EditCoursesDoctorModel,
+ newItem: EditCoursesDoctorModel
+ ): Boolean {//Утут нужно сравнивать весь спсок старых элементов и новых
+ return oldItem == newItem//Сравниваем полностью весь список новы и старый
+ }
+ }
+
+ //Интерфейс нажатия на кнопку удалить товар из корзины
+ interface Listener {
+ fun onClickCoursesYour(item: EditCoursesDoctorModel)
+ }
+
+
+}
+
+
+
+
diff --git a/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/AllSportCoursesDoctorFragment.kt b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/AllSportCoursesDoctorFragment.kt
new file mode 100644
index 0000000..3f56817
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/AllSportCoursesDoctorFragment.kt
@@ -0,0 +1,292 @@
+package com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses
+
+import android.content.Context
+import android.content.Intent
+import android.net.ConnectivityManager
+import android.net.NetworkCapabilities
+import android.os.Build
+import android.os.Bundle
+import android.util.Log
+import androidx.fragment.app.Fragment
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.Toast
+import androidx.fragment.app.activityViewModels
+import androidx.recyclerview.widget.GridLayoutManager
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
+import com.example.doctor.DoctorViewModel
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetFragment
+import com.example.doctor.Pref.ClearPref
+import com.example.doctor.Pref.ConclusionPref
+import com.example.doctor.Pref.SavePref
+import com.example.doctor.R
+import com.example.doctor.Retrofit.DoctorApi
+import com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Adapter.EditCoursesDoctorAllAdapter
+import com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Model.EditCoursesDoctorModel
+import com.example.doctor.Toast.showCustomInfoToast
+import com.example.doctor.databinding.FragmentAllSportCoursesDoctorBinding
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+
+class AllSportCoursesDoctorFragment : Fragment(), EditCoursesDoctorAllAdapter.Listener{
+ private lateinit var binding:FragmentAllSportCoursesDoctorBinding
+ lateinit var adapterAll: EditCoursesDoctorAllAdapter
+ private lateinit var doctorApi: DoctorApi
+ private val model: DoctorViewModel by activityViewModels()
+ val prefDoctorConclusion = ConclusionPref()
+ val prefDoctorClear = ClearPref()
+ val prefDoctorSave = SavePref()
+ var id_patient = 0;
+ var id_courses = 0;
+ var id_activitis = 0;
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ binding = FragmentAllSportCoursesDoctorBinding.inflate(layoutInflater,container,false)
+ return binding.root
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ initRcView()
+// id_courses = prefDoctorConclusion.conclusionIdCourses(requireContext())
+// id_activitis = prefDoctorConclusion.conclusionIdActivitis(requireContext())
+
+ model.CoursesCustomDoctor.observe(viewLifecycleOwner){
+ id_courses = it.id
+ id_activitis = it.id_activity
+ GetEditCourseDoctorAll(id_courses)
+ }
+
+
+ model.EditCoursesDoctorAllList.observe(viewLifecycleOwner){
+ adapterAll.submitList(it)
+ }
+// model.CoursesDoctorCA.observe(viewLifecycleOwner){
+// requireActivity().runOnUiThread {
+// id_courses = it.id_courses
+// id_activitis = it.id_activitis
+// }
+// }
+ Log.i("2sadas","2sadasd")
+ }
+
+ override fun onResume() {
+ super.onResume()
+ Log.i("2sadas","22sadasd")
+ }
+
+ //Получения списка курсов созданных доктором
+ fun GetEditCourseDoctorAll(id:Int) {
+ if (isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listCoursesDoctor = doctorApi.GetEditCourseDoctorAll("Bearer $Tokens",id)
+
+ requireActivity().runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = listCoursesDoctor.body()
+ val Nice = listCoursesDoctor.isSuccessful
+ val Code = listCoursesDoctor.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ //Если нету ошибок
+ if (List != null) {
+ model.EditCoursesDoctorAllList.value = List.set_of_sports_exercises_all
+ binding.txtNull.visibility = View.GONE
+ }
+ else{
+ binding.txtNull.visibility = View.VISIBLE
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+ //Получения списка курсов созданных доктором
+ fun GetEditCourseDoctorYour(id:Int) {
+ if (isOnline(requireContext())) {
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listCoursesDoctor = doctorApi.GetEditCourseDoctorYour("Bearer $Tokens",id)
+
+ requireActivity().runOnUiThread {
+
+ //Фиксируем полученные данные
+ val CoursesDoctorList = listCoursesDoctor.body()
+
+ //Если нету ошибок
+ if (CoursesDoctorList != null) {
+ model.EditCoursesDoctorYourList.value = CoursesDoctorList.set_of_sports_exercises_your
+ }
+
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ //Добавление упражнения в курс
+ fun AddCoursesCreatingDoctor(id:Int,id_activitis:Int) {
+ if (isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listCoursesDoctorAllAdd = doctorApi.AddCoursesCreatingDoctor("Bearer $Tokens",id,id_activitis)
+
+ requireActivity().runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = listCoursesDoctorAllAdd.body()
+ val Nice = listCoursesDoctorAllAdd.isSuccessful
+ val Code = listCoursesDoctorAllAdd.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
+ GetEditCourseDoctorAll(id_courses)
+ GetEditCourseDoctorYour(id_courses)
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ }
+ } else {
+ activity?.supportFragmentManager?.beginTransaction()
+ ?.replace(R.id.CLMain, EnternetFragment.newInstance())
+ ?.commit()
+ }
+ }
+
+ //Инициализируем Retrofit
+ private fun initRetrofit() {
+ val interceptor = HttpLoggingInterceptor()
+ interceptor.level = HttpLoggingInterceptor.Level.BODY
+
+ val client = OkHttpClient
+ .Builder()
+ .addInterceptor(interceptor)
+ .build()
+
+ val retrofit = Retrofit.Builder()
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
+ .client(client)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+
+ doctorApi = retrofit.create(DoctorApi::class.java)
+
+ }
+
+ //Проверка интернета
+ fun isOnline(context: Context): Boolean {
+ if (context == null) return false
+ val connectivityManager =
+ context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ val capabilities =
+ connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)
+ if (capabilities != null) {
+ when {
+ capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> {
+ return true
+ }
+
+ capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> {
+ return true
+ }
+
+ capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> {
+ return true
+ }
+ }
+ }
+ } else {
+ val activeNetworkInfo = connectivityManager.activeNetworkInfo
+ if (activeNetworkInfo != null && activeNetworkInfo.isConnected) {
+ return true
+ }
+ }
+ return false
+ }
+
+
+
+
+ //Инициализация списка
+ private fun initRcView() = with(binding) {
+ rcView.layoutManager = GridLayoutManager(requireContext(), 1)//По вертикали будет выводить по умолчанию
+ adapterAll = EditCoursesDoctorAllAdapter(this@AllSportCoursesDoctorFragment)
+ rcView.adapter = adapterAll
+ }
+
+ companion object {
+ fun newInstance() = AllSportCoursesDoctorFragment()
+ }
+
+
+ override fun onClickCoursesAll(item: EditCoursesDoctorModel) {
+ AddCoursesCreatingDoctor(item.id,id_activitis)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/Model/CoursesDoctorCA.kt b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/Model/CoursesDoctorCA.kt
new file mode 100644
index 0000000..570ecda
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/Model/CoursesDoctorCA.kt
@@ -0,0 +1,8 @@
+package com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Model
+
+data class CoursesDoctorCA(
+ val id_courses: Int,
+ val id_activitis: Int,
+
+ )
+
diff --git a/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/Model/EditCoursesDoctorListAllModel.kt b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/Model/EditCoursesDoctorListAllModel.kt
new file mode 100644
index 0000000..6a206c8
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/Model/EditCoursesDoctorListAllModel.kt
@@ -0,0 +1,8 @@
+package com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Model
+
+data class EditCoursesDoctorListAllModel(
+ val set_of_sports_exercises_all: List
+
+
+ )
+
diff --git a/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/Model/EditCoursesDoctorListYourModel.kt b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/Model/EditCoursesDoctorListYourModel.kt
new file mode 100644
index 0000000..2ea8533
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/Model/EditCoursesDoctorListYourModel.kt
@@ -0,0 +1,8 @@
+package com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Model
+
+data class EditCoursesDoctorListYourModel(
+ val set_of_sports_exercises_your: List
+
+
+ )
+
diff --git a/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/Model/EditCoursesDoctorModel.kt b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/Model/EditCoursesDoctorModel.kt
new file mode 100644
index 0000000..6d0a519
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/Model/EditCoursesDoctorModel.kt
@@ -0,0 +1,12 @@
+package com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Model
+
+data class EditCoursesDoctorModel(
+ val number: Int,
+ val id: Int,
+ val id_exercises: Int,
+ val name:String,
+ val description:String,
+ val url_image:String,
+ var expand : Boolean = false,
+ )
+
diff --git a/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/YourSportCoursesDoctorFragment.kt b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/YourSportCoursesDoctorFragment.kt
new file mode 100644
index 0000000..37f8e3f
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Setting/Courses/EditCourses/TabLayoutEditCourses/YourSportCoursesDoctorFragment.kt
@@ -0,0 +1,290 @@
+package com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses
+
+import android.content.Context
+import android.content.Intent
+import android.net.ConnectivityManager
+import android.net.NetworkCapabilities
+import android.os.Build
+import android.os.Bundle
+import android.util.Log
+import androidx.fragment.app.Fragment
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.Toast
+import androidx.fragment.app.activityViewModels
+import androidx.recyclerview.widget.GridLayoutManager
+import com.example.doctor.Auth.AuthActivity
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
+import com.example.doctor.DoctorViewModel
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetFragment
+import com.example.doctor.Pref.ConclusionPref
+import com.example.doctor.R
+import com.example.doctor.Retrofit.DoctorApi
+import com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Adapter.EditCoursesDoctorYourAdapter
+import com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Model.EditCoursesDoctorModel
+import com.example.doctor.Toast.showCustomInfoToast
+import com.example.doctor.databinding.FragmentYourSportCoursesDoctorBinding
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+
+class YourSportCoursesDoctorFragment : Fragment(), EditCoursesDoctorYourAdapter.Listener {
+ private lateinit var binding: FragmentYourSportCoursesDoctorBinding
+ lateinit var adapterYour: EditCoursesDoctorYourAdapter
+ private lateinit var doctorApi: DoctorApi
+ val prefDoctorConclusion = ConclusionPref()
+ private val model: DoctorViewModel by activityViewModels()
+ var id_patient = 0;
+ var id_courses = 0;
+ var id_activitis = 0;
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ binding = FragmentYourSportCoursesDoctorBinding.inflate(layoutInflater,container,false)
+ return binding.root
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ initRcView()
+
+ model.CoursesCustomDoctor.observe(viewLifecycleOwner){
+ id_courses = it.id
+ id_activitis = it.id_activity
+ GetEditCourseDoctorYour(id_courses)
+ }
+// id_courses = prefDoctorConclusion.conclusionIdCourses(requireContext())
+// id_activitis = prefDoctorConclusion.conclusionIdActivitis(requireContext())
+
+
+ model.EditCoursesDoctorYourList.observe(viewLifecycleOwner){
+ adapterYour.submitList(it)
+ }
+// model.CoursesDoctorCA.observe(viewLifecycleOwner){
+// id_courses = it.id_courses
+// id_activitis = it.id_activitis
+// }
+ Log.i("1sadas","1sadasd")
+ }
+
+ override fun onResume() {
+ super.onResume()
+ Log.i("1sadas","11sadasd")
+
+ }
+ //Получения списка курсов созданных доктором
+ fun GetEditCourseDoctorYour(id:Int) {
+ if (isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listCoursesDoctor = doctorApi.GetEditCourseDoctorYour("Bearer $Tokens",id)
+
+ requireActivity().runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = listCoursesDoctor.body()
+ val Nice = listCoursesDoctor.isSuccessful
+ val Code = listCoursesDoctor.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ //Если нету ошибок
+ if (List != null) {
+ model.EditCoursesDoctorYourList.value = List.set_of_sports_exercises_your
+ binding.txtNull.visibility = View.GONE
+ }
+ else{
+ binding.txtNull.visibility = View.VISIBLE
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ //Получения списка курсов созданных доктором
+ fun GetEditCourseDoctorAll(id:Int) {
+ if (isOnline(requireContext())) {
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listCoursesDoctor = doctorApi.GetEditCourseDoctorAll("Bearer $Tokens",id)
+
+ requireActivity().runOnUiThread {
+
+ //Фиксируем полученные данные
+ val CoursesDoctorList = listCoursesDoctor.body()
+
+ //Если нету ошибок
+ if (CoursesDoctorList != null) {
+ model.EditCoursesDoctorAllList.value = CoursesDoctorList.set_of_sports_exercises_all
+ }
+
+
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ //Получения списка курсов созданных доктором
+ fun ClearCoursesCreatingDoctor(id:Int) {
+
+ if (isOnline(requireContext())) {
+ initRetrofit()
+ val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
+ CoroutineScope(Dispatchers.IO).launch {
+ val listCoursesDoctorYourClear = doctorApi.ClearCoursesCreatingDoctor("Bearer $Tokens",id)
+
+ requireActivity().runOnUiThread {
+
+
+ //Фиксируем полученные данные
+ val List = listCoursesDoctorYourClear.body()
+ val Nice = listCoursesDoctorYourClear.isSuccessful
+ val Code = listCoursesDoctorYourClear.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
+ GetEditCourseDoctorYour(id_courses)
+ GetEditCourseDoctorAll(id_courses)
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+ }
+
+ }
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
+
+
+ }
+
+ //Проверка интернета
+ fun isOnline(context: Context): Boolean {
+ if (context == null) return false
+ val connectivityManager =
+ context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ val capabilities =
+ connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)
+ if (capabilities != null) {
+ when {
+ capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> {
+ return true
+ }
+
+ capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> {
+ return true
+ }
+
+ capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> {
+ return true
+ }
+ }
+ }
+ } else {
+ val activeNetworkInfo = connectivityManager.activeNetworkInfo
+ if (activeNetworkInfo != null && activeNetworkInfo.isConnected) {
+ return true
+ }
+ }
+ return false
+ }
+
+
+ //Инициализируем Retrofit
+ private fun initRetrofit() {
+ val interceptor = HttpLoggingInterceptor()
+ interceptor.level = HttpLoggingInterceptor.Level.BODY
+
+ val client = OkHttpClient
+ .Builder()
+ .addInterceptor(interceptor)
+ .build()
+
+ val retrofit = Retrofit.Builder()
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
+ .client(client)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+
+ doctorApi = retrofit.create(DoctorApi::class.java)
+
+ }
+
+ //Инициализация списка
+ private fun initRcView() = with(binding) {
+ rcView.layoutManager = GridLayoutManager(requireContext(), 1)//По вертикали будет выводить по умолчанию
+ adapterYour = EditCoursesDoctorYourAdapter(this@YourSportCoursesDoctorFragment)
+ rcView.adapter = adapterYour
+ }
+ companion object {
+
+ fun newInstance() = YourSportCoursesDoctorFragment()
+ }
+
+ override fun onClickCoursesYour(item: EditCoursesDoctorModel) {
+ Log.i("sadsadsadasd",item.toString())
+
+ ClearCoursesCreatingDoctor(item.id_exercises)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/doctor/Setting/Courses/Model/CoursesDoctorListModel.kt b/app/src/main/java/com/example/doctor/Setting/Courses/Model/CoursesDoctorListModel.kt
new file mode 100644
index 0000000..22ef494
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Setting/Courses/Model/CoursesDoctorListModel.kt
@@ -0,0 +1,6 @@
+package com.example.doctor.Setting.Courses.Model
+
+data class CoursesDoctorListModel(
+ val sport_courses_doctor: List
+ )
+
diff --git a/app/src/main/java/com/example/doctor/Setting/Courses/Model/CoursesDoctorModel.kt b/app/src/main/java/com/example/doctor/Setting/Courses/Model/CoursesDoctorModel.kt
new file mode 100644
index 0000000..3898a26
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Setting/Courses/Model/CoursesDoctorModel.kt
@@ -0,0 +1,14 @@
+package com.example.doctor.Setting.Courses.Model
+
+data class CoursesDoctorModel(
+ val number: Int,
+ val id: Int,
+ val name: String,
+ val description: String,
+ val visibility: Int,
+ val user_id: Int,
+ val id_activity:Int,
+ val created_at: String,
+ val updated_at: String,
+ )
+
diff --git a/app/src/main/java/com/example/doctor/Setting/SettingFragment.kt b/app/src/main/java/com/example/doctor/Setting/SettingFragment.kt
index 7bd8131..97251f3 100644
--- a/app/src/main/java/com/example/doctor/Setting/SettingFragment.kt
+++ b/app/src/main/java/com/example/doctor/Setting/SettingFragment.kt
@@ -2,7 +2,9 @@ package com.example.doctor.Setting
import android.content.Context
import android.content.Intent
-import android.content.SharedPreferences
+import android.net.ConnectivityManager
+import android.net.NetworkCapabilities
+import android.os.Build
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
@@ -12,12 +14,17 @@ import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import com.example.doctor.Auth.AuthActivity
import com.example.doctor.Auth.AuthFragment
-import com.example.doctor.Patients.Reports.PatientFragment
+import com.example.doctor.CodeError.Code429Activity
+import com.example.doctor.CodeError.Code500Activity
+import com.example.doctor.Enternet.EnternetActivity
+import com.example.doctor.Enternet.EnternetCheck
+import com.example.doctor.Enternet.EnternetFragment
+import com.example.doctor.MainActivity
import com.example.doctor.Pref.ClearPref
import com.example.doctor.Pref.ConclusionPref
-import com.example.doctor.Pref.SavePref
import com.example.doctor.R
import com.example.doctor.Retrofit.DoctorApi
+import com.example.doctor.Setting.Courses.CoursesActivity
import com.example.doctor.Toast.showCustomInfoToast
import com.example.doctor.databinding.FragmentSettingBinding
import kotlinx.coroutines.CoroutineScope
@@ -36,6 +43,8 @@ class SettingFragment : Fragment() {
private lateinit var doctorApi: DoctorApi
val prefDoctorConclusion = ConclusionPref()
+ //Класс проверки интеренета
+ val enternetCheck = EnternetCheck()
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
@@ -59,10 +68,15 @@ class SettingFragment : Fragment() {
btnYourData.setOnClickListener{
activity?.supportFragmentManager?.beginTransaction()
- ?.replace(com.example.doctor.R.id.CLMainFragment, YourDataFragment.newInstance())
+ ?.replace(R.id.CLMainFragment, YourDataFragment.newInstance())
?.commit()
}
+ binding.btnAddCourses.setOnClickListener{
+ val intetn = Intent(requireContext(), CoursesActivity::class.java)
+ startActivity(intetn)
+ }
+
}
@@ -86,6 +100,7 @@ class SettingFragment : Fragment() {
//Получения списка пациентов
fun Logout() {
+ if (enternetCheck.isOnline(requireContext())) {
initRetrofit()
val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
CoroutineScope(Dispatchers.IO).launch {
@@ -93,22 +108,45 @@ class SettingFragment : Fragment() {
activity?.runOnUiThread {
+
//Фиксируем полученные данные
- val visibleviewList = listProduct.body()
- val visibleviewListCode = listProduct.isSuccessful()
- //Если нету ошибок
- if (visibleviewListCode) {
- Toast(requireContext()).showCustomInfoToast(visibleviewList?.message.toString(), requireActivity())
- prefDoctorClear.clearToken(requireContext())
- activity?.supportFragmentManager?.beginTransaction()
- ?.replace(R.id.CLMain, AuthFragment.newInstance())
- ?.commit()
-
-
+ val List = listProduct.body()
+ val Nice = listProduct.isSuccessful
+ val Code = listProduct.code()
+ if(Code==429){
+ val intetn = Intent(requireContext(), Code429Activity::class.java)
+ startActivity(intetn)
+ }
+ else if(Code==200) {
+ //Если нету ошибок
+ if (Nice) {
+ if (List != null) {
+ Toast(requireContext()).showCustomInfoToast(List?.message.toString(), requireActivity())
+ prefDoctorClear.clearToken(requireContext())
+ activity?.supportFragmentManager?.beginTransaction()
+ ?.replace(R.id.CLMain, AuthFragment.newInstance())
+ ?.commit()
+ }
+ }
+ }
+ else if (Code == 500) {
+ val intetn = Intent(requireContext(), Code500Activity::class.java)
+ startActivity(intetn)
+ }
+ else if (Code == 401) {
+ val intetn = Intent(requireContext(), AuthActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
}
}
}
+ } else {
+ val intetn = Intent(requireContext(), EnternetActivity::class.java)
+ activity?.finish()
+ startActivity(intetn)
+ }
}
+
//Инициализируем Retrofit
private fun initRetrofit() {
val interceptor = HttpLoggingInterceptor()
@@ -120,7 +158,7 @@ class SettingFragment : Fragment() {
.build()
val retrofit = Retrofit.Builder()
- .baseUrl("http://mobileapp.vmeda.org/api/")
+ .baseUrl("https://rehabilitation.vmeda.org/api/")
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build()
@@ -129,6 +167,8 @@ class SettingFragment : Fragment() {
}
+
+
companion object {
fun newInstance() = SettingFragment()
}
diff --git a/app/src/main/java/com/example/doctor/Worker/MyWorker.kt b/app/src/main/java/com/example/doctor/Worker/MyWorker.kt
new file mode 100644
index 0000000..f3975b1
--- /dev/null
+++ b/app/src/main/java/com/example/doctor/Worker/MyWorker.kt
@@ -0,0 +1,100 @@
+package com.example.doctor.Worker
+
+import android.annotation.SuppressLint
+import android.app.Notification
+import android.app.NotificationChannel
+import android.app.NotificationManager
+import android.app.PendingIntent
+import android.content.Context
+import android.content.Intent
+import android.os.Build
+import android.util.Log
+import androidx.core.app.NotificationManagerCompat
+import androidx.work.Worker
+import androidx.work.WorkerParameters
+import com.example.doctor.MainActivity
+import com.example.doctor.R
+import java.nio.file.attribute.AclEntry.Builder
+
+class MyWorker(context: Context, workerParameters: WorkerParameters): Worker(context,workerParameters) {
+ companion object{
+ const val CHANNEL_ID="channel_id"
+ const val NOTIFICATION=1
+ }
+ override fun doWork(): Result {
+ Log.d("doWork","doWork - error")
+ showNotification()
+ return Result.success()//Возврощаем результат
+ }
+
+ @SuppressLint("UnspecifiedImmutableFlag", "MissingPermission", "ObsoleteSdkInt")
+ private fun showNotification(){
+ val intent = Intent(applicationContext,MainActivity::class.java).apply{
+ flags=Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
+ }
+
+ val pendingIntetn= PendingIntent.getActivity(applicationContext,0,intent,0)
+
+ val notification = Notification.Builder(applicationContext, CHANNEL_ID)
+ .setSmallIcon(R.drawable.door)
+ .setContentTitle("new task")
+ .setContentText("Сообщение 1")//Сообщение
+ .setPriority(Notification.PRIORITY_MAX)//Приоритет
+ .setAutoCancel(true)//Время отмены
+ .setContentIntent(pendingIntetn)//Ожидание завершения
+
+
+ if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){
+ val channelName = "channel name"
+ val channelDescription = "channel Description"
+ val channelImportance=NotificationManager.IMPORTANCE_HIGH
+
+ //Канал
+ val channel = NotificationChannel(CHANNEL_ID,channelName,channelImportance).apply {
+ description = channelDescription
+ }
+
+ //Менеджер уведомлений
+ val notificationManager = applicationContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
+ notificationManager.createNotificationChannel(channel)//Создаем канал с помошью менеджера уведомлений
+
+ with(NotificationManagerCompat.from(applicationContext)){
+ notify(NOTIFICATION,notification.build())
+ }
+ }
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/anim/fade_in.xml b/app/src/main/res/anim/fade_in.xml
new file mode 100644
index 0000000..64a46de
--- /dev/null
+++ b/app/src/main/res/anim/fade_in.xml
@@ -0,0 +1,6 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/anim/fade_out.xml b/app/src/main/res/anim/fade_out.xml
new file mode 100644
index 0000000..afab199
--- /dev/null
+++ b/app/src/main/res/anim/fade_out.xml
@@ -0,0 +1,6 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/anim/slide_in.xml b/app/src/main/res/anim/slide_in.xml
new file mode 100644
index 0000000..8a4a29c
--- /dev/null
+++ b/app/src/main/res/anim/slide_in.xml
@@ -0,0 +1,6 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/anim/slide_out.xml b/app/src/main/res/anim/slide_out.xml
new file mode 100644
index 0000000..220ef3b
--- /dev/null
+++ b/app/src/main/res/anim/slide_out.xml
@@ -0,0 +1,6 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/add1.png b/app/src/main/res/drawable/add1.png
new file mode 100644
index 0000000..515d45e
Binary files /dev/null and b/app/src/main/res/drawable/add1.png differ
diff --git a/app/src/main/res/drawable/loading.gif b/app/src/main/res/drawable/loading.gif
new file mode 100644
index 0000000..8e4be53
Binary files /dev/null and b/app/src/main/res/drawable/loading.gif differ
diff --git a/app/src/main/res/drawable/tab_indicator.xml b/app/src/main/res/drawable/tab_indicator.xml
index 1c759f9..64dcce6 100644
--- a/app/src/main/res/drawable/tab_indicator.xml
+++ b/app/src/main/res/drawable/tab_indicator.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_appeals.xml b/app/src/main/res/layout/activity_appeals.xml
new file mode 100644
index 0000000..2563287
--- /dev/null
+++ b/app/src/main/res/layout/activity_appeals.xml
@@ -0,0 +1,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_code429.xml b/app/src/main/res/layout/activity_code429.xml
new file mode 100644
index 0000000..297b844
--- /dev/null
+++ b/app/src/main/res/layout/activity_code429.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_code500.xml b/app/src/main/res/layout/activity_code500.xml
new file mode 100644
index 0000000..0778283
--- /dev/null
+++ b/app/src/main/res/layout/activity_code500.xml
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_courses.xml b/app/src/main/res/layout/activity_courses.xml
new file mode 100644
index 0000000..9cffebc
--- /dev/null
+++ b/app/src/main/res/layout/activity_courses.xml
@@ -0,0 +1,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_enternet.xml b/app/src/main/res/layout/activity_enternet.xml
new file mode 100644
index 0000000..d2b6e93
--- /dev/null
+++ b/app/src/main/res/layout/activity_enternet.xml
@@ -0,0 +1,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 48c1732..aa6ed3d 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -6,4 +6,98 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gradientv1"
- tools:context=".MainActivity" />
\ No newline at end of file
+ tools:context=".MainActivity" >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_patient.xml b/app/src/main/res/layout/activity_patient.xml
new file mode 100644
index 0000000..812207d
--- /dev/null
+++ b/app/src/main/res/layout/activity_patient.xml
@@ -0,0 +1,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_active_courses_patient.xml b/app/src/main/res/layout/fragment_active_courses_patient.xml
new file mode 100644
index 0000000..68eea5d
--- /dev/null
+++ b/app/src/main/res/layout/fragment_active_courses_patient.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_all_sport_courses_doctor.xml b/app/src/main/res/layout/fragment_all_sport_courses_doctor.xml
new file mode 100644
index 0000000..24899ba
--- /dev/null
+++ b/app/src/main/res/layout/fragment_all_sport_courses_doctor.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_appeals.xml b/app/src/main/res/layout/fragment_appeals.xml
index 7ad5851..b9eed8a 100644
--- a/app/src/main/res/layout/fragment_appeals.xml
+++ b/app/src/main/res/layout/fragment_appeals.xml
@@ -15,6 +15,35 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
+
+
+
+
+
+
+
+
+ app:tabTextColor="#6A6A6A">
-
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_courses_all.xml b/app/src/main/res/layout/fragment_courses_all.xml
new file mode 100644
index 0000000..5c936da
--- /dev/null
+++ b/app/src/main/res/layout/fragment_courses_all.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_courses_you.xml b/app/src/main/res/layout/fragment_courses_you.xml
new file mode 100644
index 0000000..bf916d1
--- /dev/null
+++ b/app/src/main/res/layout/fragment_courses_you.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_create_courses.xml b/app/src/main/res/layout/fragment_create_courses.xml
new file mode 100644
index 0000000..b0cccf6
--- /dev/null
+++ b/app/src/main/res/layout/fragment_create_courses.xml
@@ -0,0 +1,324 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_create_message.xml b/app/src/main/res/layout/fragment_create_message.xml
new file mode 100644
index 0000000..a2e00f2
--- /dev/null
+++ b/app/src/main/res/layout/fragment_create_message.xml
@@ -0,0 +1,154 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_edit_courses.xml b/app/src/main/res/layout/fragment_edit_courses.xml
new file mode 100644
index 0000000..b56c43f
--- /dev/null
+++ b/app/src/main/res/layout/fragment_edit_courses.xml
@@ -0,0 +1,113 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_edit_sport.xml b/app/src/main/res/layout/fragment_edit_sport.xml
index df78427..96489d1 100644
--- a/app/src/main/res/layout/fragment_edit_sport.xml
+++ b/app/src/main/res/layout/fragment_edit_sport.xml
@@ -5,11 +5,12 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Patients.Reports.Edit.EditSportFragment">
+
+ android:background="#D5D5D5">
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_edit_sport_yes.xml b/app/src/main/res/layout/fragment_edit_sport_yes.xml
index cc9911b..1788299 100644
--- a/app/src/main/res/layout/fragment_edit_sport_yes.xml
+++ b/app/src/main/res/layout/fragment_edit_sport_yes.xml
@@ -31,4 +31,30 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_enternet.xml b/app/src/main/res/layout/fragment_enternet.xml
new file mode 100644
index 0000000..a8c46de
--- /dev/null
+++ b/app/src/main/res/layout/fragment_enternet.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml
index 2296e9b..bc1a60e 100644
--- a/app/src/main/res/layout/fragment_home.xml
+++ b/app/src/main/res/layout/fragment_home.xml
@@ -6,136 +6,190 @@
android:layout_height="match_parent"
tools:context=".Home.HomeFragment">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
-
+
-
+
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_main.xml b/app/src/main/res/layout/fragment_main.xml
index 0100c29..a77f359 100644
--- a/app/src/main/res/layout/fragment_main.xml
+++ b/app/src/main/res/layout/fragment_main.xml
@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- tools:context=".MainActivity">
+ tools:context=".MainFragment">
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_not_active_courses_patient.xml b/app/src/main/res/layout/fragment_not_active_courses_patient.xml
new file mode 100644
index 0000000..b46604d
--- /dev/null
+++ b/app/src/main/res/layout/fragment_not_active_courses_patient.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_old_appeals.xml b/app/src/main/res/layout/fragment_old_appeals.xml
index bcafb52..b912d7b 100644
--- a/app/src/main/res/layout/fragment_old_appeals.xml
+++ b/app/src/main/res/layout/fragment_old_appeals.xml
@@ -14,5 +14,45 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_patients.xml b/app/src/main/res/layout/fragment_patients.xml
index da5bec9..53239ed 100644
--- a/app/src/main/res/layout/fragment_patients.xml
+++ b/app/src/main/res/layout/fragment_patients.xml
@@ -4,16 +4,17 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:background="@drawable/gradientv1"
tools:context=".Patients.Reports.PatientFragment">
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
@@ -266,9 +249,9 @@
android:id="@+id/textView14"
android:layout_width="0dp"
android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
+ android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
- android:layout_marginEnd="8dp"
+ android:layout_marginEnd="16dp"
android:layout_marginBottom="8dp"
android:gravity="center"
android:text="Комплексы"
@@ -313,9 +296,9 @@
android:id="@+id/textView18"
android:layout_width="0dp"
android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
+ android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
- android:layout_marginEnd="8dp"
+ android:layout_marginEnd="16dp"
android:layout_marginBottom="8dp"
android:gravity="center"
android:text="Отчеты"
@@ -325,6 +308,11 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
+
+
@@ -335,12 +323,10 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
- android:layout_marginBottom="32dp"
app:cardBackgroundColor="#000000"
app:cardCornerRadius="15dp"
app:cardElevation="0dp"
app:cardMaxElevation="0dp"
- app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/btnReport"
app:layout_constraintStart_toStartOf="@+id/btnReport"
app:layout_constraintTop_toBottomOf="@+id/btnReport">
@@ -379,6 +365,54 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -392,811 +426,1251 @@
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:src="@drawable/arrow_24"
+ android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
-
-
+ android:layout_height="0dp"
+ android:layout_marginStart="16dp"
+ android:layout_marginTop="32dp"
+ android:layout_marginEnd="16dp"
+ android:layout_marginBottom="32dp"
+ app:cardBackgroundColor="#000000"
+ app:cardCornerRadius="20dp"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
-
+
-
-
-
-
-
+ android:layout_height="0dp"
+ android:layout_margin="2dp"
+ android:visibility="visible"
+ app:cardBackgroundColor="#FFFFFF"
+ app:cardCornerRadius="20dp"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
-
-
+ android:layout_height="match_parent"
+ android:background="#D5D5D5">
+
+
+
+
+
+
+
-
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_height="0dp"
+ android:layout_marginStart="16dp"
+ android:layout_marginTop="32dp"
+ android:layout_marginEnd="16dp"
+ android:layout_marginBottom="32dp"
+ app:cardBackgroundColor="#000000"
+ app:cardCornerRadius="20dp"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
-
+
-
+
-
-
-
-
-
+ android:layout_height="match_parent"
+ android:background="#D5D5D5">
+
+
+
+
+ android:layout_height="0dp"
+ android:layout_marginTop="16dp"
+ android:background="#FFFFFF"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/textView11">
+
+
-
-
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_patients_list.xml b/app/src/main/res/layout/fragment_patients_list.xml
index 14b2a44..5aefa8d 100644
--- a/app/src/main/res/layout/fragment_patients_list.xml
+++ b/app/src/main/res/layout/fragment_patients_list.xml
@@ -2,36 +2,26 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ app:layout_constraintTop_toTopOf="parent"
+ tools:ignore="MissingConstraints">
+ android:layout_width="256dp"
+ android:layout_height="49dp">
-
+ app:layout_constraintTop_toTopOf="parent">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_setting.xml b/app/src/main/res/layout/fragment_setting.xml
index a3b7ff8..bd32f17 100644
--- a/app/src/main/res/layout/fragment_setting.xml
+++ b/app/src/main/res/layout/fragment_setting.xml
@@ -28,6 +28,7 @@
android:layout_marginStart="32dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="32dp"
+ android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView">
@@ -79,6 +80,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
+ android:visibility="gone"
app:layout_constraintEnd_toEndOf="@+id/btnCompleted"
app:layout_constraintStart_toStartOf="@+id/btnCompleted"
app:layout_constraintTop_toBottomOf="@+id/btnCompleted">
@@ -130,6 +132,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
+ android:visibility="gone"
app:layout_constraintEnd_toEndOf="@+id/btnYourData"
app:layout_constraintStart_toStartOf="@+id/btnYourData"
app:layout_constraintTop_toBottomOf="@+id/btnYourData">
@@ -177,18 +180,75 @@
+ android:layout_marginStart="32dp"
+ android:layout_marginTop="32dp"
+ android:layout_marginEnd="32dp"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/btnPatient">
+
+
+
+
+
+
+
+
+
+ app:layout_constraintTop_toBottomOf="@+id/textView6" />
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_appeals_new.xml b/app/src/main/res/layout/item_appeals_new.xml
index e0a8849..e40e6de 100644
--- a/app/src/main/res/layout/item_appeals_new.xml
+++ b/app/src/main/res/layout/item_appeals_new.xml
@@ -76,29 +76,43 @@
android:id="@+id/txtAppeals"
android:layout_width="0dp"
android:layout_height="wrap_content"
- android:layout_marginStart="16dp"
+ android:layout_marginStart="32dp"
android:layout_marginTop="8dp"
- android:layout_marginEnd="16dp"
+ android:layout_marginEnd="32dp"
android:layout_marginBottom="8dp"
+ android:ellipsize="end"
android:maxLines="1"
android:text="sdfsdf sddf sdfsdf fsdf sddfsdfsd d vvcfdrvdredvc frv frevddrvdredvc s s d dfssdfsdfsdf d fssffs dsf dsfd sfd sfd sfd fvdfcffff"
android:textColor="#000000"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toStartOf="@+id/btnAdd"
- app:layout_constraintStart_toEndOf="@+id/txtNumber"
- app:layout_constraintTop_toBottomOf="@+id/txtLoginPatient" />
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/btnPatient" />
+
+
diff --git a/app/src/main/res/layout/item_appeals_old.xml b/app/src/main/res/layout/item_appeals_old.xml
index f3c2ffa..4f38923 100644
--- a/app/src/main/res/layout/item_appeals_old.xml
+++ b/app/src/main/res/layout/item_appeals_old.xml
@@ -48,6 +48,19 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
+
+
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/btnPatient" />
diff --git a/app/src/main/res/layout/item_buttom_menu.xml b/app/src/main/res/layout/item_buttom_menu.xml
index 1fa75fb..433118a 100644
--- a/app/src/main/res/layout/item_buttom_menu.xml
+++ b/app/src/main/res/layout/item_buttom_menu.xml
@@ -22,11 +22,12 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent">
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintVertical_bias="0.0">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_card_patient.xml b/app/src/main/res/layout/item_card_patient.xml
index e1c8d82..bb77d70 100644
--- a/app/src/main/res/layout/item_card_patient.xml
+++ b/app/src/main/res/layout/item_card_patient.xml
@@ -45,7 +45,7 @@
app:layout_constraintTop_toTopOf="parent">
diff --git a/app/src/main/res/layout/item_edit_sport_no.xml b/app/src/main/res/layout/item_edit_sport_no.xml
index 5af4273..8895b7c 100644
--- a/app/src/main/res/layout/item_edit_sport_no.xml
+++ b/app/src/main/res/layout/item_edit_sport_no.xml
@@ -84,12 +84,12 @@
android:textColor="#000000"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toStartOf="@+id/btnYeyYes"
+ app:layout_constraintEnd_toStartOf="@+id/btnYeyNo"
app:layout_constraintStart_toEndOf="@+id/txtNumber"
app:layout_constraintTop_toBottomOf="@+id/txtNameSport" />