doctor 1
parent
819a66dcad
commit
7cf154daa0
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<targetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="C:\Users\maksi\.android\avd\Pixel_5_API_29_2.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</targetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2023-11-30T18:27:18.890685800Z" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="SameParameterValue" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
</profile>
|
||||
</component>
|
|
@ -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"
|
||||
|
||||
|
||||
}
|
|
@ -1,13 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
xmlns:tools="http://schemas.android.com/tools" >
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission
|
||||
android:name="android.permission.CALL_PHONE"
|
||||
tools:ignore="PermissionImpliesUnsupportedChromeOsHardware" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:usesCleartextTraffic="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
|
@ -16,14 +22,34 @@
|
|||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Doctor"
|
||||
tools:targetApi="31">
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:targetApi="31" >
|
||||
|
||||
<activity
|
||||
android:name=".CodeError.Code500Activity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".CodeError.Code429Activity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".Enternet.EnternetActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".Setting.Courses.CoursesActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".Appeals.AppealsCreateMessageActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".Patients.PatientActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".Auth.AuthActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name="MainActivity"
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:windowSoftInputMode="adjustPan|stateAlwaysHidden">
|
||||
android:windowSoftInputMode="adjustPan|stateAlwaysHidden" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
|
|
@ -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<Fragment>):FragmentStateAdapter(fr_act) {//private val list:List<Fragment> - список с фрагментами сюда передастся, тоесть с двумя фрагментами
|
||||
//Возврощаем для createFragment количество элементов(фрагментов) в листе(List)
|
||||
override fun getItemCount(): Int {
|
||||
return list.size//возврощаем количество фрагметов
|
||||
}
|
||||
|
||||
//Позиция фрагмента или 1 или 2, то есть 0 или 1. И по позиции будут выводится фрагмент.
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
return list[position]//Возврощаем фрагмент из листа по позиции
|
||||
}
|
||||
}
|
|
@ -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,
|
||||
)
|
||||
|
|
@ -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() - это то что мы вставляем
|
||||
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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<AppealsNewModel, AppealsNewAdapter.Holder>(
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
@ -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<AppealsOldModel, AppealsOldAdapter.Holder>(
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
@ -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<PatientAllModel>?=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<PatientAllModel>) {
|
||||
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<PatientModel>()
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package com.example.doctor.Appeals.TabLayout.Model
|
||||
|
||||
data class AppealsNewListModel(
|
||||
val appeals_new: List<AppealsNewModel>
|
||||
)
|
||||
|
|
@ -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,
|
||||
|
||||
)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.example.doctor.Appeals.TabLayout.Model
|
||||
|
||||
data class AppealsOldListModel(
|
||||
val appeals_old: List<AppealsOldModel>
|
||||
)
|
||||
|
|
@ -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,
|
||||
|
||||
)
|
||||
|
|
@ -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<AppealsNewModel>? = 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<AppealsNewModel>()
|
||||
//Получение необработанных сообщений
|
||||
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)
|
||||
}
|
||||
}
|
|
@ -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<AppealsOldModel>? = 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<AppealsOldModel>()
|
||||
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)
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.example.doctor
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
|
||||
//Ослеживание за обновлением подробной продуктовой карточкой
|
||||
open class DataModel: ViewModel() {
|
||||
/*//Для отлеживания обновлений активити
|
||||
val messageForActivity: MutableLiveData<String> by lazy{//by lazy - чтобы каждый раз не создавался MutableLiveData(MutableLiveData<String>()), а он один раз при загрузке создаться и дальше будет пользоваться уже созданным
|
||||
MutableLiveData<String>()//LiveData - означает что будет обновляться в нужынй момент, не постоянна, а в зависимоти от жизни активити
|
||||
}*/
|
||||
//Для отлеживания обновлений фрагммента 1
|
||||
val messageForFrag1: MutableLiveData<Int> by lazy{//by lazy - чтобы каждый раз не создавался MutableLiveData(MutableLiveData<String>()), а он один раз при загрузке создаться и дальше будет пользоваться уже созданным
|
||||
MutableLiveData<Int>()//LiveData - означает что будет обновляться в нужынй момент, не постоянна, а в зависимоти от жизни активити
|
||||
}
|
||||
|
||||
val fragmentMenu: MutableLiveData<Int> by lazy{//by lazy - чтобы каждый раз не создавался MutableLiveData(MutableLiveData<String>()), а он один раз при загрузке создаться и дальше будет пользоваться уже созданным
|
||||
MutableLiveData<Int>()//LiveData - означает что будет обновляться в нужынй момент, не постоянна, а в зависимоти от жизни активити
|
||||
}
|
||||
val patientList: MutableLiveData<Int> by lazy{//by lazy - чтобы каждый раз не создавался MutableLiveData(MutableLiveData<String>()), а он один раз при загрузке создаться и дальше будет пользоваться уже созданным
|
||||
MutableLiveData<Int>()//LiveData - означает что будет обновляться в нужынй момент, не постоянна, а в зависимоти от жизни активити
|
||||
}
|
||||
val patientAppeal: MutableLiveData<Int> by lazy{//by lazy - чтобы каждый раз не создавался MutableLiveData(MutableLiveData<String>()), а он один раз при загрузке создаться и дальше будет пользоваться уже созданным
|
||||
MutableLiveData<Int>()//LiveData - означает что будет обновляться в нужынй момент, не постоянна, а в зависимоти от жизни активити
|
||||
}
|
||||
/*//Для отлеживания обновлений фрагммента 2
|
||||
val messageForFrag2: MutableLiveData<String> by lazy{//by lazy - чтобы каждый раз не создавался MutableLiveData(MutableLiveData<String>()), а он один раз при загрузке создаться и дальше будет пользоваться уже созданным
|
||||
MutableLiveData<String>()//LiveData - означает что будет обновляться в нужынй момент, не постоянна, а в зависимоти от жизни активити
|
||||
}*/
|
||||
}
|
|
@ -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<String>()
|
||||
|
||||
//Пациенты
|
||||
val patientId = MutableLiveData<PatientIdModel>()
|
||||
val patientCurrent = MutableLiveData<PatientAllModel>()
|
||||
val patientListList= MutableLiveData<PatientAllModel>()
|
||||
|
||||
//Обращения новые
|
||||
//Обращения необработанные
|
||||
val appealsNewCurrent = MutableLiveData<AppealsNewModel>()
|
||||
val appealsNewList= MutableLiveData<List<AppealsNewModel>>()
|
||||
|
||||
//Обращения все
|
||||
val appealsAllCurrent = MutableLiveData<AppealsOldModel>()
|
||||
val appealsAllList= MutableLiveData<List<AppealsOldModel>>()
|
||||
//Обращения обработанные
|
||||
val appealsOldCurrent = MutableLiveData<AppealsOldModel>()
|
||||
val appealsOldList= MutableLiveData<List<AppealsOldModel>>()
|
||||
|
||||
//val productList = MutableLiveData<List<Product>>()
|
||||
val patientOneCurrent = MutableLiveData<PatientModel>()
|
||||
|
@ -41,6 +44,9 @@ class DoctorViewModel: ViewModel() {
|
|||
//КУрсы
|
||||
val SportCoursCurrent = MutableLiveData<SportCoursModel>()
|
||||
val SportCoursList= MutableLiveData<List<SportCoursModel>>()
|
||||
val SportCoursDoctorList= MutableLiveData<List<SportCoursModel>>()
|
||||
|
||||
val BtnSportCoursDoctorCurrent = MutableLiveData<Int>()
|
||||
|
||||
//Редактирование занятий
|
||||
val EditSportCurrentYes = MutableLiveData<EditSportModel>()
|
||||
|
@ -50,7 +56,38 @@ class DoctorViewModel: ViewModel() {
|
|||
val EditSportCurrentNO = MutableLiveData<EditSportModel>()
|
||||
val EditSportListNo= MutableLiveData<List<EditSportModel>>()
|
||||
|
||||
//Список пациентов
|
||||
val PatientActiveCurrent = MutableLiveData<PatientAllModel>()
|
||||
val PatientActiveList= MutableLiveData<List<PatientAllModel>>()
|
||||
val PatientNotCurrent = MutableLiveData<PatientAllModel>()
|
||||
val PatientNotList= MutableLiveData<List<PatientAllModel>>()
|
||||
|
||||
//Список со всеми пациентами
|
||||
val PatientAllModel= MutableLiveData<List<PatientAllModel>>()
|
||||
|
||||
//id пациента
|
||||
val id_patient = MutableLiveData<Int>()
|
||||
|
||||
//Курсы созданный доктором
|
||||
val CoursesDoctorCurrent = MutableLiveData<CoursesDoctorModel>()
|
||||
val CoursesDoctorList= MutableLiveData<List<CoursesDoctorModel>>()
|
||||
|
||||
|
||||
//Упражнения не входяшие в курс доктора
|
||||
val EditCoursesDoctorAllCurrent = MutableLiveData<EditCoursesDoctorModel>()
|
||||
val EditCoursesDoctorAllList= MutableLiveData<List<EditCoursesDoctorModel>>()
|
||||
|
||||
//Упражнения входяшие в курс доктора
|
||||
val EditCoursesDoctorYourCurrent = MutableLiveData<EditCoursesDoctorModel>()
|
||||
val EditCoursesDoctorYourList= MutableLiveData<List<EditCoursesDoctorModel>>()
|
||||
|
||||
val CoursesDoctorCA = MutableLiveData<CoursesDoctorCA>()
|
||||
|
||||
|
||||
//Список пациентов для поисковой строки
|
||||
val patientListSearch= MutableLiveData<List<PatientAllModel>>()
|
||||
|
||||
//Для передачи данных редактируемого курса
|
||||
val CoursesCustomDoctor = MutableLiveData<CoursesDoctorModel>()
|
||||
|
||||
}
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package com.example.doctor.Home
|
||||
|
||||
data class HomeInfoModel(
|
||||
val patient: Int,
|
||||
val appeals_check: Int,
|
||||
val appeals_all: Int,
|
||||
)
|
||||
|
|
@ -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)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
|
||||
}
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package com.example.doctor.Patients.Model
|
||||
|
||||
import java.util.Date
|
||||
|
||||
data class PatientIdModel(
|
||||
val id: Int
|
||||
|
||||
)
|
||||
|
|
@ -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)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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<PatientAllModel>?=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<Fragment>)
|
||||
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<PatientAllModel>) {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -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<SportCoursModel, CoursesAllAdapter.Holder>(
|
||||
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<SportCoursModel>() {
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -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<SportCoursModel, CoursesYouAdapter.Holder>(
|
||||
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<SportCoursModel>() {
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.example.doctor.Patients.Reports.Courses
|
||||
|
||||
data class SportCoursDoctorListModel(
|
||||
val courses_doctor: List<SportCoursModel>
|
||||
)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.example.doctor.Patients.Reports
|
||||
package com.example.doctor.Patients.Reports.Courses
|
||||
|
||||
data class SportCoursListModel(
|
||||
val courses: List<SportCoursModel>
|
|
@ -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,
|
||||
)
|
||||
|
||||
)
|
|
@ -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<SportCoursModel>?=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)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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<SportCoursModel>?=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)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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<SportCoursModel, CoursesAdapter.Holder>(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<SportCoursModel>() {
|
||||
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)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -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<SportCoursModel, CoursesListAdapter.Holder>(
|
||||
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<SportCoursModel>() {
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -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) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<EditSportModel>?=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)
|
||||
|
||||
}
|
||||
|
|
|
@ -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<EditSportModel>?=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)
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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,
|
||||
|
|
|
@ -16,7 +16,8 @@ class QBBAdapter() : ListAdapter<QBAModel, QBBAdapter.Holder>(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<QBAModel, QBBAdapter.Holder>(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<QBAModel, QBBAdapter.Holder>(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<QBAModel, QBBAdapter.Holder>(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<QBAModel, QBBAdapter.Holder>(Comparator()) {
|
|||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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<PatientAllModel>?=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
|
||||
}
|
||||
}
|
|
@ -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<PatientAllModel>? = 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()
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
}
|
||||
}
|
|
@ -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<PatientAllListModel>
|
||||
|
||||
//Вывод пациентов конкретного врача с активным курсом
|
||||
@Headers("Content-Type: application/json")
|
||||
@GET("GetPatientAllActive")
|
||||
suspend fun GetPatientAllActive(@Header("Authorization") token:String):Response<PatientAllListModel>
|
||||
|
||||
//Вывод пациентов конкретного врача с не активным курсом
|
||||
@Headers("Content-Type: application/json")
|
||||
@GET("GetPatientAllNotActive")
|
||||
suspend fun GetPatientAllNotActive(@Header("Authorization") token:String):Response<PatientAllListModel>
|
||||
|
||||
//Вывод всех пациентов
|
||||
@Headers("Content-Type: application/json")
|
||||
@GET("GetPatientID")
|
||||
suspend fun GetPatientID(@Header("Authorization") token:String):Response<PatientAllModel>
|
||||
suspend fun GetPatientID(@Header("Authorization") token:String,@Query("id") id:Int):Response<PatientAllModel>
|
||||
|
||||
//Поиск пациентов
|
||||
@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<SportCoursListModel>
|
||||
|
||||
//Вывод курсов созданных врачем
|
||||
@Headers("Content-Type: application/json")
|
||||
@GET("GetCoursesDoctorPatient")
|
||||
suspend fun GetCoursesDoctorPatient(@Header("Authorization") token:String,@Query("id") id:Int):Response<SportCoursDoctorListModel>
|
||||
|
||||
|
||||
//Вывод анкеты пациентов которые сейчас действуют
|
||||
@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<MessageModel>
|
||||
suspend fun UpdateBlockSportTasksNo(@Header("Authorization") token:String,@Query("id") id:Int):Response<MessageModel>
|
||||
|
||||
|
||||
//Отключенных упражнений
|
||||
@Headers("Content-Type: application/json")
|
||||
@PUT("UpdatePatientLogin")
|
||||
suspend fun UpdatePatientLogin(@Header("Authorization") token:String,@Query("id") id:Int,@Query("login") login:String):Response<MessageModel>
|
||||
//Отключенных упражнений
|
||||
@Headers("Content-Type: application/json")
|
||||
@PUT("UpdatePatientPassword")
|
||||
suspend fun UpdatePatientPassword(@Header("Authorization") token:String,@Query("id") id:Int,@Query("password") password:String):Response<MessageModel>
|
||||
|
||||
//Добавление курса пациенту
|
||||
@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<MessageModel>
|
||||
|
||||
|
||||
|
||||
|
||||
//Вывод необработанных сообщений
|
||||
@Headers("Content-Type: application/json")
|
||||
@GET("GetAppealsDoctorNew")
|
||||
suspend fun GetAppealsDoctorNew(@Header("Authorization") token:String) :Response<AppealsNewListModel>
|
||||
|
||||
//Вывод необработанных сообщений
|
||||
@Headers("Content-Type: application/json")
|
||||
@GET("GetAppealsDoctorOld")
|
||||
suspend fun GetAppealsDoctorOld(@Header("Authorization") token:String) :Response<AppealsOldListModel>
|
||||
|
||||
|
||||
//Подтверждение необработанных сообщений
|
||||
@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<MessageModel>
|
||||
|
||||
//Отправка сообщения пациенту
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("AddMessageDoctor")
|
||||
suspend fun AddMessageDoctor(@Header("Authorization") token:String,@Query("login") login:String,@Query("text") text:String) :Response<MessageModel>
|
||||
|
||||
//Создание курса врачем
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("AddCoursesName")
|
||||
suspend fun AddCoursesName(@Header("Authorization") token:String,@Query("name") name:String,@Query("description") description:String) :Response<MessageModel>
|
||||
|
||||
//Вывод курсов созданных врачем
|
||||
@Headers("Content-Type: application/json")
|
||||
@GET("GetCoursesDoctor")
|
||||
suspend fun GetCoursesDoctor(@Header("Authorization") token:String) :Response<CoursesDoctorListModel>
|
||||
|
||||
//Вывод упражнений которые не входят в курс
|
||||
@Headers("Content-Type: application/json")
|
||||
@GET("GetEditCourseDoctorAll")
|
||||
suspend fun GetEditCourseDoctorAll(@Header("Authorization") token:String,@Query("id_doctor_courses") id_doctor_courses:Int) :Response<EditCoursesDoctorListAllModel>
|
||||
|
||||
|
||||
//Вывод упражнений которые входят в курс
|
||||
@Headers("Content-Type: application/json")
|
||||
@GET("GetEditCourseDoctorYour")
|
||||
suspend fun GetEditCourseDoctorYour(@Header("Authorization") token:String,@Query("id_doctor_courses") id_doctor_courses:Int) :Response<EditCoursesDoctorListYourModel>
|
||||
|
||||
|
||||
//Добавление упражнений в курс
|
||||
@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<MessageModel>
|
||||
|
||||
//Удаление упражнений из курса
|
||||
@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<MessageModel>
|
||||
|
||||
//Вывод данных для первой страницы врача
|
||||
@Headers("Content-Type: application/json")
|
||||
@GET("CountPatientAndAppeals")
|
||||
suspend fun CountPatientAndAppeals(@Header("Authorization") token:String) :Response<HomeInfoModel>
|
||||
|
||||
}
|
|
@ -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<CoursesDoctorModel, CoursesDoctorAdapter.Holder>(
|
||||
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<CoursesDoctorModel>() {
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -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() - это то что мы вставляем
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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() - это то что мы вставляем
|
||||
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
}
|
||||
}
|
|
@ -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<EditCoursesDoctorModel, EditCoursesDoctorAllAdapter.Holder>(
|
||||
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<EditCoursesDoctorModel>() {
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -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<EditCoursesDoctorModel, EditCoursesDoctorYourAdapter.Holder>(
|
||||
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<EditCoursesDoctorModel>() {
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Model
|
||||
|
||||
data class CoursesDoctorCA(
|
||||
val id_courses: Int,
|
||||
val id_activitis: Int,
|
||||
|
||||
)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Model
|
||||
|
||||
data class EditCoursesDoctorListAllModel(
|
||||
val set_of_sports_exercises_all: List<EditCoursesDoctorModel>
|
||||
|
||||
|
||||
)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.example.doctor.Setting.Courses.EditCourses.TabLayoutEditCourses.Model
|
||||
|
||||
data class EditCoursesDoctorListYourModel(
|
||||
val set_of_sports_exercises_your: List<EditCoursesDoctorModel>
|
||||
|
||||
|
||||
)
|
||||
|
|
@ -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,
|
||||
)
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package com.example.doctor.Setting.Courses.Model
|
||||
|
||||
data class CoursesDoctorListModel(
|
||||
val sport_courses_doctor: List<CoursesDoctorModel>
|
||||
)
|
||||
|
|
@ -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,
|
||||
)
|
||||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="@android:integer/config_shortAnimTime"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:fromAlpha="0"
|
||||
android:toAlpha="1" />
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="@android:integer/config_shortAnimTime"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:fromAlpha="1"
|
||||
android:toAlpha="0" />
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<translate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="@android:integer/config_shortAnimTime"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:fromXDelta="100%"
|
||||
android:toXDelta="0%" />
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<translate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="@android:integer/config_shortAnimTime"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:fromXDelta="0%"
|
||||
android:toXDelta="100%" />
|
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="#004F7B"/>
|
||||
<solid android:color="#4BA5D8"/>
|
||||
<corners android:radius="100dp" />
|
||||
</shape>
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/CLAppealsActivity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Appeals.AppealsCreateMessageActivity">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".CodeError.Code429Activity">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
app:cardBackgroundColor="#000000"
|
||||
app:cardCornerRadius="15dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="1dp"
|
||||
app:cardCornerRadius="15dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView80"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:gravity="center"
|
||||
android:text="Подключение"
|
||||
android:textColor="#121111"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="@+id/textView7"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView7"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView7" />
|
||||
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/gifImageView3"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:src="@drawable/loading"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/textView80"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView80"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView80" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView7"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
android:gravity="center"
|
||||
android:text="Ранее вы отправляли слишеом много запросов !!!"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,89 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".CodeError.Code500Activity">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
app:cardBackgroundColor="#000000"
|
||||
app:cardCornerRadius="15dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="1dp"
|
||||
app:cardCornerRadius="15dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/gifImageView"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:src="@drawable/loading"
|
||||
app:layout_constraintEnd_toEndOf="@+id/textView49"
|
||||
app:layout_constraintHorizontal_bias="0.497"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView49"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView49" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView7"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
android:gravity="center"
|
||||
android:text="Потеря соединения с сервером"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView49"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:gravity="center"
|
||||
android:text="Подключение"
|
||||
android:textColor="#121111"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="@+id/textView7"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView7"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView7" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView42"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:gravity="center"
|
||||
android:text="Если в ближайшее время вы не подключитесь, то вас отправит на страницу авторизации. Это может означать что в ваш аккаунт кто-то вошел с другого устройства"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/gifImageView" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/CLCoursesActivity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Setting.Courses.CoursesActivity">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/CLEnternet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Enternet.EnternetActivity">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -6,4 +6,98 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/gradientv1"
|
||||
tools:context=".MainActivity" />
|
||||
tools:context=".MainActivity" >
|
||||
|
||||
|
||||
<!-- <fragment-->
|
||||
<!-- android:id="@+id/fragmentContainerView"-->
|
||||
<!-- android:name="androidx.navigation.fragment.NavHostFragment"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="match_parent"-->
|
||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toTopOf="parent"-->
|
||||
<!-- app:defaultNavHost="true"-->
|
||||
<!-- app:navGraph="@navigation/main_nav"-->
|
||||
<!-- tools:layout="@layout/fragment_main" />-->
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/CLLoad"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/CardViewLoad"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:visibility="visible"
|
||||
app:cardBackgroundColor="#FFFFFF"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:src="@drawable/loading"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.497"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView3"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView3"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="300dp"
|
||||
android:layout_marginTop="100dp"
|
||||
android:src="@drawable/logovmediv2"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn11"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Button"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn22"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Button"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Button"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toStartOf="@+id/btn22"
|
||||
app:layout_constraintStart_toEndOf="@+id/btn11"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/CLPatientActivity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Patients.PatientActivity">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Patients.TabLayoutPatient.ActiveCoursesPatientFragment">
|
||||
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rcView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:overScrollMode="never"
|
||||
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Setting.Courses.EditCourses.TabLayoutEditCourses.AllSportCoursesDoctorFragment">
|
||||
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rcView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtNull"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="Пусто.."
|
||||
android:textColor="#000000"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -15,6 +15,35 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/btnAddMessage"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:cardBackgroundColor="#ECECEC"
|
||||
app:cardCornerRadius="50dp"
|
||||
app:cardElevation="10dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView11"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:src="@drawable/add1"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="MissingConstraints" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/tabLayoutProduct"
|
||||
android:layout_width="0dp"
|
||||
|
@ -32,10 +61,10 @@
|
|||
app:tabIndicatorAnimationMode="elastic"
|
||||
app:tabIndicatorColor="@null"
|
||||
app:tabIndicatorGravity="stretch"
|
||||
app:tabMaxWidth="0dp"
|
||||
app:tabRippleColor="#00515151"
|
||||
app:tabSelectedTextColor="#FFFFFF"
|
||||
app:tabTextColor="#6A6A6A"
|
||||
app:tabMaxWidth="0dp">
|
||||
app:tabTextColor="#6A6A6A">
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -50,7 +79,6 @@
|
|||
tools:ignore="HardcodedText" />
|
||||
|
||||
|
||||
|
||||
</com.google.android.material.tabs.TabLayout>
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
|
@ -64,4 +92,42 @@
|
|||
app:layout_constraintTop_toBottomOf="@+id/tabLayoutProduct" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/CLAppeals"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/gradientv1"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/CLMainPatientAppeals"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#FFFFFF"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btnExit"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
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" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Patients.Reports.Courses.TabLayout.CoursesAllFragment">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtNull"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="Пусто..."
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rcView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Patients.Reports.Courses.TabLayout.CoursesYouFragment">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtNull"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="Пусто..."
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rcView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,324 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/CLCreateCourses"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Setting.Courses.EditCourses.CreateCoursesFragment">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraintLayout2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="1.0">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/btnCreateCourses"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
app:cardBackgroundColor="#000000"
|
||||
app:cardCornerRadius="15dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/btnExit">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
app:cardBackgroundColor="#71C3EF"
|
||||
app:cardCornerRadius="15dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView55"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="Создать"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btnExit"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:src="@drawable/arrow_24"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="MissingConstraints" />
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardView7"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:cardBackgroundColor="#000000"
|
||||
app:cardCornerRadius="15dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/btnCreateCourses">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="2dp"
|
||||
app:cardCornerRadius="15dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView56"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center"
|
||||
android:text="Созданные вами курсы"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rcView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="#CDCDCD"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView56">
|
||||
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtNull"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Пусто..."
|
||||
android:textColor="#000000"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/rcView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/rcView" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView54"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
android:text="Создание курса"
|
||||
android:textColor="#000000"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/CLCreate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/CVCreateCourses"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:cardBackgroundColor="#94B5B5B5"
|
||||
app:cardCornerRadius="0dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardMaxElevation="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/CVCardCreateCourses"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="32dp"
|
||||
app:cardCornerRadius="20dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btnExitCreat"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:src="@drawable/close"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView57"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:text="Создание"
|
||||
android:textColor="#000000"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edCoursesDoctorName"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
android:ems="10"
|
||||
android:hint="Введите навзание"
|
||||
android:inputType="text"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView57" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edCoursesDoctorDescription"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="32dp"
|
||||
android:ems="10"
|
||||
android:hint="Описание"
|
||||
android:inputType="text"
|
||||
app:layout_constraintBottom_toTopOf="@+id/btnCreateCoursrsDoctor"
|
||||
app:layout_constraintEnd_toEndOf="@+id/edCoursesDoctorName"
|
||||
app:layout_constraintStart_toStartOf="@+id/edCoursesDoctorName"
|
||||
app:layout_constraintTop_toBottomOf="@+id/edCoursesDoctorName" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnCreateCoursrsDoctor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="Создать"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/edCoursesDoctorDescription"
|
||||
app:layout_constraintStart_toStartOf="@+id/edCoursesDoctorDescription" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/CLLoad"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/CardViewLoad"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:visibility="visible"
|
||||
app:cardBackgroundColor="#FFFFFF"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:src="@drawable/loading"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.497"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView3"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView3"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="300dp"
|
||||
android:layout_marginTop="100dp"
|
||||
android:src="@drawable/logovmediv2"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,154 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Appeals.CreateMessageFragment">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardView6"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:cardBackgroundColor="#000000"
|
||||
app:cardCornerRadius="10dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardMaxElevation="0dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView50"
|
||||
tools:ignore="MissingConstraints">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardView5"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
app:cardBackgroundColor="#FFFFFF"
|
||||
app:cardCornerRadius="10dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardMaxElevation="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<AutoCompleteTextView
|
||||
android:id="@+id/searchPatient"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:background="@null"
|
||||
android:ems="10"
|
||||
android:gravity="center"
|
||||
android:hint="Введите логин"
|
||||
android:iconifiedByDefault="false"
|
||||
android:inputType="text"
|
||||
android:searchHintIcon="@null"
|
||||
android:searchIcon="@null"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView50"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="Отправка сообщения пациенту"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/btnExit" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btnExit"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:src="@drawable/arrow_24"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardView12"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:maxHeight="300dp"
|
||||
app:cardBackgroundColor="#000000"
|
||||
app:cardCornerRadius="10dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cardView6">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
app:cardCornerRadius="10dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="300dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edTextMessagePatient"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@null"
|
||||
android:ems="10"
|
||||
android:gravity="top|left"
|
||||
android:hint="Введите ваше сообщение"
|
||||
android:inputType="textMultiLine|textPersonName"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnAddMessagePatient"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="Отправить"
|
||||
app:layout_constraintEnd_toEndOf="@+id/cardView12"
|
||||
app:layout_constraintStart_toStartOf="@+id/cardView12"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cardView12" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,113 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Setting.Courses.EditCourses.EditCoursesFragment">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/CLEditCourses"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#94B5B5B5"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/CVEditCourses"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:cardCornerRadius="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btnBack"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:src="@drawable/arrow_24"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="MissingConstraints" />
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/tabLayoutCourses"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="#003E3E3E"
|
||||
android:backgroundTint="#00AEAEAE"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/btnBack"
|
||||
app:tabIconTint="#009E9E9E"
|
||||
app:tabIndicator="@drawable/tab_indicator"
|
||||
app:tabIndicatorAnimationMode="elastic"
|
||||
app:tabIndicatorColor="@null"
|
||||
app:tabIndicatorGravity="stretch"
|
||||
app:tabMaxWidth="0dp"
|
||||
app:tabRippleColor="#00515151"
|
||||
app:tabSelectedTextColor="#FFFFFF"
|
||||
app:tabTextColor="#6A6A6A">
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Все"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Добавленные"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
|
||||
</com.google.android.material.tabs.TabLayout>
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/vpCourses"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:overScrollMode="never"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tabLayoutCourses" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtNameCourses"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:gravity="center"
|
||||
android:text="TextView"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/btnBack"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/btnBack" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -5,11 +5,12 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Patients.Reports.Edit.EditSportFragment">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/ConstrainLayoutSportEdit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
android:background="#D5D5D5">
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/tabLayoutSport"
|
||||
|
@ -18,8 +19,10 @@
|
|||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="#003E3E3E"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="#00AEAEAE"
|
||||
android:backgroundTint="#00AEAEAE"
|
||||
app:layout_constraintBottom_toTopOf="@+id/vpEditSport"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
@ -52,6 +55,7 @@
|
|||
android:id="@+id/vpEditSport"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:background="#FFFFFF"
|
||||
android:overScrollMode="never"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
|
@ -33,4 +33,29 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/CLLoad"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#60BCBCBC"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtLoad"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Отправка..."
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.25" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -31,4 +31,30 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/CLLoad"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#60BCBCBC"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtLoad"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Отправка..."
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.25" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Enternet.EnternetFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView28"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="32dp"
|
||||
android:gravity="center"
|
||||
android:text="Ошибка подключения к интернету"
|
||||
android:textColor="#000000"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/btnEnternet"
|
||||
app:layout_constraintEnd_toEndOf="@+id/btnEnternet"
|
||||
app:layout_constraintStart_toStartOf="@+id/btnEnternet" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnEnternet"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Переподключиться"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -6,136 +6,190 @@
|
|||
android:layout_height="match_parent"
|
||||
tools:context=".Home.HomeFragment">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardView7"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
app:cardBackgroundColor="#004F7B"
|
||||
app:cardCornerRadius="5dp"
|
||||
app:layout_constraintEnd_toStartOf="@+id/CVCenter"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/CVPatinet"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
app:cardBackgroundColor="#004F7B"
|
||||
app:cardCornerRadius="5dp"
|
||||
app:layout_constraintEnd_toStartOf="@+id/space"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView6"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center"
|
||||
android:text="Пациентов"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtCountPatient"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:gravity="center"
|
||||
android:text="0"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/textView6"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView6"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView6" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/CVAppeals"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
app:cardBackgroundColor="#004F7B"
|
||||
app:cardCornerRadius="5dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/space"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView9"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center"
|
||||
android:text="Обращений"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView13"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="/"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/textView9"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView9"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView9" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtCountAppealsNew"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:text="0"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/textView13"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView13"
|
||||
app:layout_constraintTop_toTopOf="@+id/textView13" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtCountAppealsAll"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:text="0"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/textView13"
|
||||
app:layout_constraintStart_toEndOf="@+id/textView13"
|
||||
app:layout_constraintTop_toTopOf="@+id/textView13" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<Space
|
||||
android:id="@+id/space"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/CLLoad"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/CardViewLoad"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:visibility="visible"
|
||||
app:cardBackgroundColor="#FFFFFF"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView6"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center"
|
||||
android:text="Пациентов"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtCountPatient"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:gravity="center"
|
||||
android:text="7"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/textView6"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView6"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView6" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:src="@drawable/loading"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.497"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView3"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
app:cardBackgroundColor="#004F7B"
|
||||
app:cardCornerRadius="5dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/CVCenter"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
<ImageView
|
||||
android:id="@+id/imageView3"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="300dp"
|
||||
android:layout_marginTop="100dp"
|
||||
android:src="@drawable/logovmediv2"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView9"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center"
|
||||
android:text="Обращений"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView13"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="/"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/textView9"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView9"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView9" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtCountAppealsNew"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:text="6"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/textView13"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView13"
|
||||
app:layout_constraintTop_toTopOf="@+id/textView13" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtCountAppealsAll"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:text="13"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/textView13"
|
||||
app:layout_constraintStart_toEndOf="@+id/textView13"
|
||||
app:layout_constraintTop_toTopOf="@+id/textView13" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/CVCenter"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="0dp"
|
||||
app:cardBackgroundColor="#00FFFFFF"
|
||||
app:cardCornerRadius="0dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardMaxElevation="0dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:layout_editor_absoluteY="63dp" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue