patient 1
|
@ -7,11 +7,11 @@
|
||||||
<deviceKey>
|
<deviceKey>
|
||||||
<Key>
|
<Key>
|
||||||
<type value="VIRTUAL_DEVICE_PATH" />
|
<type value="VIRTUAL_DEVICE_PATH" />
|
||||||
<value value="C:\Users\maksi\.android\avd\Pixel_7_Edited_API_29.avd" />
|
<value value="C:\Users\maksi\.android\avd\Pixel_6_API_29.avd" />
|
||||||
</Key>
|
</Key>
|
||||||
</deviceKey>
|
</deviceKey>
|
||||||
</Target>
|
</Target>
|
||||||
</targetSelectedWithDropDown>
|
</targetSelectedWithDropDown>
|
||||||
<timeTargetWasSelectedWithDropDown value="2023-11-01T08:15:09.629698400Z" />
|
<timeTargetWasSelectedWithDropDown value="2023-11-28T12:28:18.723737700Z" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -30,9 +30,7 @@
|
||||||
android:theme="@style/Theme.Rehabilitation"
|
android:theme="@style/Theme.Rehabilitation"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
tools:targetApi="31">
|
tools:targetApi="31">
|
||||||
<activity
|
|
||||||
android:name=".Information.InformationActivity"
|
|
||||||
android:exported="false" />
|
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="${applicationId}.provider"
|
android:authorities="${applicationId}.provider"
|
||||||
|
@ -43,15 +41,7 @@
|
||||||
android:resource="@xml/provider_paths" />
|
android:resource="@xml/provider_paths" />
|
||||||
</provider>
|
</provider>
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name=".Feedback.FeedbackActivity"
|
|
||||||
android:exported="false"
|
|
||||||
android:screenOrientation="portrait" />
|
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name=".Setting.SettingActivity"
|
|
||||||
android:exported="false"
|
|
||||||
android:screenOrientation="portrait" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".Auth.AuthorizationActivity"
|
android:name=".Auth.AuthorizationActivity"
|
||||||
android:exported="false">
|
android:exported="false">
|
||||||
|
@ -60,6 +50,24 @@
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:value="" />
|
android:value="" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".CodeError.Code429Activity"
|
||||||
|
android:exported="false">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.app.lib_name"
|
||||||
|
android:screenOrientation="portrait"
|
||||||
|
android:value="" />
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".CodeError.Code500Activity"
|
||||||
|
android:exported="false">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.app.lib_name"
|
||||||
|
android:screenOrientation="portrait"
|
||||||
|
android:value="" />
|
||||||
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
@ -71,6 +79,15 @@
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".Enternet.EnternetActivity"
|
||||||
|
android:exported="false">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.app.lib_name"
|
||||||
|
android:screenOrientation="portrait"
|
||||||
|
android:value="" />
|
||||||
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.example.rehabilitation.Adapter
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
|
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||||
|
|
||||||
|
class VpAdapter(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,245 @@
|
||||||
|
package com.example.rehabilitation.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 androidx.fragment.app.FragmentActivity
|
||||||
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import com.example.rehabilitation.Adapter.VpAdapter
|
||||||
|
import com.example.rehabilitation.Appeals.TabLayout.NewAppealsFragment
|
||||||
|
import com.example.rehabilitation.Appeals.TabLayout.OldAppealsFragment
|
||||||
|
import com.example.rehabilitation.Auth.AuthorizationActivity
|
||||||
|
import com.example.rehabilitation.CodeError.Code429Activity
|
||||||
|
import com.example.rehabilitation.CodeError.Code500Activity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetActivity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetCheck
|
||||||
|
import com.example.rehabilitation.PatientViewModel
|
||||||
|
import com.example.rehabilitation.Pref.ConclusionPref
|
||||||
|
import com.example.rehabilitation.R
|
||||||
|
import com.example.rehabilitation.Retrofit.PatientApi
|
||||||
|
import com.example.rehabilitation.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 val modelPatient: PatientViewModel by activityViewModels()
|
||||||
|
private lateinit var patientApi: PatientApi
|
||||||
|
private lateinit var timer: Timer
|
||||||
|
|
||||||
|
val prefPatientConclusion = ConclusionPref()
|
||||||
|
|
||||||
|
//Класс проверки интеренета
|
||||||
|
val enternetCheck = EnternetCheck()
|
||||||
|
|
||||||
|
private val tList = listOf(
|
||||||
|
"новые",
|
||||||
|
"обработанные",
|
||||||
|
)
|
||||||
|
|
||||||
|
//Список с фрагментами для переключения
|
||||||
|
private val flist = listOf(
|
||||||
|
NewAppealsFragment.newInstance(),
|
||||||
|
OldAppealsFragment.newInstance(),
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
binding = FragmentAppealsBinding.inflate(layoutInflater, container, false)
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
init()
|
||||||
|
|
||||||
|
binding.btnAddMessage.setOnClickListener {
|
||||||
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
|
?.replace(R.id.CLAppeals, CreateMessageFragment.newInstance())?.commit()
|
||||||
|
binding.ConstrainLayoutProductEdit.visibility = View.GONE
|
||||||
|
binding.CLAppeals.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
|
// fixedRateTimer("timer", false, 0, 10000) {
|
||||||
|
// activity?.runOnUiThread {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun getOldAppeals() {
|
||||||
|
initRetrofit()
|
||||||
|
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
val listAppeals = patientApi.GetAppealsPatientOld("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){
|
||||||
|
modelPatient.appealsOldList.value = List.appeals_old
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
getNewAppeals()
|
||||||
|
}
|
||||||
|
else if (Code == 500) {
|
||||||
|
val intetn = Intent(requireContext(), Code500Activity::class.java)
|
||||||
|
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
else if (Code == 401) {
|
||||||
|
val intetn = Intent(requireContext(), AuthorizationActivity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Получение необработанных сообщений
|
||||||
|
private fun getNewAppeals() {
|
||||||
|
if (enternetCheck.isOnline(requireContext())) {
|
||||||
|
initRetrofit()
|
||||||
|
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
val listAppeals = patientApi.GetAppealsPatientNew("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){
|
||||||
|
modelPatient.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(), AuthorizationActivity::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("http://mobileapp.vmeda.org/api/")
|
||||||
|
.client(client)
|
||||||
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
|
.build()
|
||||||
|
|
||||||
|
patientApi = retrofit.create(PatientApi::class.java)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Функция подключения переключения
|
||||||
|
private fun init() = with(binding) {
|
||||||
|
val adapter = VpAdapter(activity as FragmentActivity, flist)
|
||||||
|
vpProduct.adapter = adapter
|
||||||
|
|
||||||
|
//Переключения (связываем таблаяут(переключатель) с viewpager, чтобы переключать фрагменты)
|
||||||
|
TabLayoutMediator(tabLayoutProduct, vpProduct) { tab, pos ->
|
||||||
|
tab.text =
|
||||||
|
tList[pos]//tab - нажатая кнопка, pos - позиция кнопки, tList[pos] - передаем название по полученной позиции
|
||||||
|
}.attach()// attach() - чтобы все переключалось, а не вывадило постоянно один экран
|
||||||
|
|
||||||
|
//Изменения цвета в зависомости на каком из tabLayout вы находитесь
|
||||||
|
binding.tabLayoutProduct.setTabTextColors(getResources().getColor(R.color.black),
|
||||||
|
getResources().getColor(R.color.white));
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
fun newInstance() = AppealsFragment()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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) {
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
getOldAppeals()
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,118 @@
|
||||||
|
package com.example.rehabilitation.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.rehabilitation.Appeals.TabLayout.Model.AppealsNewModel
|
||||||
|
import com.example.rehabilitation.R
|
||||||
|
import com.example.rehabilitation.databinding.ItemAppealsNewBinding
|
||||||
|
|
||||||
|
|
||||||
|
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_check_apeals: Listener, val listener_patient_apeals: Listener2) :
|
||||||
|
RecyclerView.ViewHolder(view) {//Класс который будет хранить сссылки на элементы, и отвечает за один элемент за 1 раз, то есть сначсало нулевой элемент заполнит, потом первый, потом второй и т.д.
|
||||||
|
//Для передачи данных
|
||||||
|
|
||||||
|
val binding =
|
||||||
|
ItemAppealsNewBinding.bind(view)//view - здесь храянтся элементы и мы их bind заполним в ListItemBinding//ListItemBinding - это клласс даннйо разметки(карточки) которую мы будем заполнять, а нужна дання переменная(binding), чтобы мжно было при заполнение обращатся к элементам карточки
|
||||||
|
|
||||||
|
var itemTemp: AppealsNewModel? =
|
||||||
|
null//Глобальная переменная для нашего item, чтобы можно было передать данные для нажатия
|
||||||
|
|
||||||
|
//init - дает возможность внутри адаптера обращаться к элементам экрана
|
||||||
|
init {
|
||||||
|
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_check_apeals.onClickAppeals(it2) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SuspiciousIndentation")
|
||||||
|
fun bind(item: AppealsNewModel) = with(binding) {//Productitem - перпедаем данные
|
||||||
|
itemTemp = item
|
||||||
|
txtNumber.text = item.number.toString()+"."
|
||||||
|
txtAppeals.text = item.text
|
||||||
|
txtLoginPatient.text = item.login
|
||||||
|
|
||||||
|
|
||||||
|
if (item.expand) {
|
||||||
|
txtAppeals.maxLines = 30
|
||||||
|
} else {
|
||||||
|
txtAppeals.maxLines = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
CardViewNew.setOnClickListener {
|
||||||
|
if (item.expand == false) {
|
||||||
|
txtAppeals.maxLines = 100
|
||||||
|
|
||||||
|
item.expand = true
|
||||||
|
} else {
|
||||||
|
txtAppeals.maxLines = 1
|
||||||
|
item.expand = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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_check_apeals,listener_patient_apeals)//Через Holder возврощаем view
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: Holder, position: Int) {
|
||||||
|
val view = holder.bind(getItem(position))//Заполняем по позиции карточку
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Comparator - сравнивает старый список и новый и если что-то изменилось, то работает с конкретным изменением списке, а не весь список переписывает
|
||||||
|
class Comparator : DiffUtil.ItemCallback<AppealsNewModel>() {
|
||||||
|
override fun areItemsTheSame(
|
||||||
|
oldItem: AppealsNewModel,
|
||||||
|
newItem: AppealsNewModel
|
||||||
|
): Boolean {//Тут лучше всего сравнивать по id//oldItem - элементы старого списка, newItem - элементы нового списка//Возврощает Boolean, тоесть есть изменения или нет
|
||||||
|
return oldItem.id == newItem.id//Сравниваем полностью весь список новы и старый, по очередно по одной карточке и по элементно, то есть нулевой элемент, первый, второй и т.д.. Но лучше сравнивать по id списки, а не просто весь список, так как это эфективнее, так как id уникальный(oldItem.id == newItem.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun areContentsTheSame(
|
||||||
|
oldItem: AppealsNewModel,
|
||||||
|
newItem: AppealsNewModel
|
||||||
|
): Boolean {//Утут нужно сравнивать весь спсок старых элементов и новых
|
||||||
|
return oldItem == newItem//Сравниваем полностью весь список новы и старый
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interface Listener {
|
||||||
|
fun onClickAppeals(item: AppealsNewModel)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interface Listener2 {
|
||||||
|
fun onClickAppealsPatient(item: AppealsNewModel)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
package com.example.rehabilitation.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.rehabilitation.Appeals.TabLayout.Model.AppealsOldModel
|
||||||
|
import com.example.rehabilitation.R
|
||||||
|
import com.example.rehabilitation.databinding.ItemAppealsOldBinding
|
||||||
|
|
||||||
|
|
||||||
|
class AppealsOldAdapter(val listener_zakaz: Listener) :
|
||||||
|
ListAdapter<AppealsOldModel, AppealsOldAdapter.Holder>(
|
||||||
|
Comparator()
|
||||||
|
) {//Productitem - по этой форме будем заполнять.//ProductAdapter.holder - это создаваемый holder который хранит логику как нужно заполнять карточку
|
||||||
|
|
||||||
|
|
||||||
|
//В holder создаетс код с помошью которого мы будем заполнять и сохронять разметку
|
||||||
|
class Holder(view: View, val listener_zakaz: Listener) :
|
||||||
|
RecyclerView.ViewHolder(view) {//Класс который будет хранить сссылки на элементы, и отвечает за один элемент за 1 раз, то есть сначсало нулевой элемент заполнит, потом первый, потом второй и т.д.
|
||||||
|
//Для передачи данных
|
||||||
|
|
||||||
|
val binding =
|
||||||
|
ItemAppealsOldBinding.bind(view)//view - здесь храянтся элементы и мы их bind заполним в ListItemBinding//ListItemBinding - это клласс даннйо разметки(карточки) которую мы будем заполнять, а нужна дання переменная(binding), чтобы мжно было при заполнение обращатся к элементам карточки
|
||||||
|
|
||||||
|
var itemTemp: AppealsOldModel? =
|
||||||
|
null//Глобальная переменная для нашего item, чтобы можно было передать данные для нажатия
|
||||||
|
|
||||||
|
//init - дает возможность внутри адаптера обращаться к элементам экрана
|
||||||
|
init {
|
||||||
|
itemView.setOnClickListener {//Нажатие на ячейку//itemView - это весь элемент карточки из списка
|
||||||
|
itemView.setEnabled(false)
|
||||||
|
itemTemp?.let { it1 -> listener_zakaz.onClickAppeals(it1) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SuspiciousIndentation")
|
||||||
|
fun bind(item: AppealsOldModel) = with(binding) {//Productitem - перпедаем данные
|
||||||
|
itemTemp = item
|
||||||
|
txtNumber.text = item.number.toString()+"."
|
||||||
|
txtAppeals.text = item.text
|
||||||
|
txtLoginPatient.text = item.login
|
||||||
|
|
||||||
|
if (item.expand) {
|
||||||
|
binding.txtAppeals.maxLines = 100
|
||||||
|
|
||||||
|
} else {
|
||||||
|
binding.txtAppeals.maxLines = 1
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.CardViewOld.setOnClickListener {
|
||||||
|
if (item.expand == false) {
|
||||||
|
binding.txtAppeals.maxLines = 100
|
||||||
|
item.expand = true
|
||||||
|
} else {
|
||||||
|
binding.txtAppeals.maxLines = 1
|
||||||
|
item.expand = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: Holder, position: Int) {
|
||||||
|
val view = holder.bind(getItem(position))//Заполняем по позиции карточку
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Comparator - сравнивает старый список и новый и если что-то изменилось, то работает с конкретным изменением списке, а не весь список переписывает
|
||||||
|
class Comparator : DiffUtil.ItemCallback<AppealsOldModel>() {
|
||||||
|
override fun areItemsTheSame(
|
||||||
|
oldItem: AppealsOldModel,
|
||||||
|
newItem: AppealsOldModel
|
||||||
|
): Boolean {//Тут лучше всего сравнивать по id//oldItem - элементы старого списка, newItem - элементы нового списка//Возврощает Boolean, тоесть есть изменения или нет
|
||||||
|
return oldItem.id == newItem.id//Сравниваем полностью весь список новы и старый, по очередно по одной карточке и по элементно, то есть нулевой элемент, первый, второй и т.д.. Но лучше сравнивать по id списки, а не просто весь список, так как это эфективнее, так как id уникальный(oldItem.id == newItem.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun areContentsTheSame(
|
||||||
|
oldItem: AppealsOldModel,
|
||||||
|
newItem: AppealsOldModel
|
||||||
|
): Boolean {//Утут нужно сравнивать весь спсок старых элементов и новых
|
||||||
|
return oldItem == newItem//Сравниваем полностью весь список новы и старый
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Интерфейс нажатия на кнопку удалить товар из корзины
|
||||||
|
interface Listener {
|
||||||
|
fun onClickAppeals(item: AppealsOldModel)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,153 @@
|
||||||
|
package com.example.rehabilitation.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.Toast
|
||||||
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import com.example.admin.Toast.showCustomInfoToast
|
||||||
|
import com.example.rehabilitation.Auth.AuthorizationActivity
|
||||||
|
import com.example.rehabilitation.CodeError.Code429Activity
|
||||||
|
import com.example.rehabilitation.CodeError.Code500Activity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetActivity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetCheck
|
||||||
|
import com.example.rehabilitation.Pref.ClearPref
|
||||||
|
import com.example.rehabilitation.Pref.ConclusionPref
|
||||||
|
import com.example.rehabilitation.R
|
||||||
|
import com.example.rehabilitation.Retrofit.PatientApi
|
||||||
|
import com.example.rehabilitation.databinding.FragmentCreateMessageBinding
|
||||||
|
import com.example.rehabilitation.model_adapter.DataModel
|
||||||
|
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 CreateMessageFragment : Fragment() {
|
||||||
|
private lateinit var binding: FragmentCreateMessageBinding
|
||||||
|
private val dataModel: DataModel by activityViewModels()//Для передачи данных
|
||||||
|
private lateinit var patientApi: PatientApi
|
||||||
|
val prefDoctorConclusion = ConclusionPref()
|
||||||
|
val prefDoctorClear = ClearPref()
|
||||||
|
|
||||||
|
//Класс проверки интеренета
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
binding.btnAddMessagePatient.setOnClickListener{
|
||||||
|
val text = binding.edTextMessagePatient.text.toString()
|
||||||
|
if(text!=""){
|
||||||
|
AddMessageDoctor()
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Toast(requireContext()).showCustomInfoToast("Поле пустое", requireActivity())
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.btnExit.setOnClickListener{
|
||||||
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
|
?.replace(R.id.placeHolderFragment, AppealsFragment.newInstance())
|
||||||
|
//?.addToBackStack(null)
|
||||||
|
?.commit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Отправка сообщения
|
||||||
|
fun AddMessageDoctor() {
|
||||||
|
if (enternetCheck.isOnline(requireContext())) {
|
||||||
|
initRetrofit()
|
||||||
|
val Tokens = prefDoctorConclusion.conclusionToken(requireContext())
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
val message = patientApi.AddMessagePatient("Bearer $Tokens",binding.edTextMessagePatient.text.toString())
|
||||||
|
requireActivity().runOnUiThread {
|
||||||
|
|
||||||
|
//Фиксируем полученные данные
|
||||||
|
val List = message.body()
|
||||||
|
val Nice = message.isSuccessful
|
||||||
|
val Code = message.code()
|
||||||
|
if(Code==429){
|
||||||
|
val intetn = Intent(requireContext(), Code429Activity::class.java)
|
||||||
|
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
else if(Code==200) {
|
||||||
|
//Если нету ошибок
|
||||||
|
if (Nice) {
|
||||||
|
//Если нету ошибок
|
||||||
|
if (List != null) {
|
||||||
|
Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Code == 500) {
|
||||||
|
val intetn = Intent(requireContext(), Code500Activity::class.java)
|
||||||
|
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
else if (Code == 401) {
|
||||||
|
val intetn = Intent(requireContext(), AuthorizationActivity::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()
|
||||||
|
|
||||||
|
patientApi = retrofit.create(PatientApi::class.java)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
fun newInstance() = CreateMessageFragment()
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package com.example.rehabilitation.Appeals.TabLayout.Model
|
||||||
|
|
||||||
|
data class AppealsNewListModel(
|
||||||
|
val appeals_new: List<AppealsNewModel>
|
||||||
|
)
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.example.rehabilitation.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.rehabilitation.Appeals.TabLayout.Model
|
||||||
|
|
||||||
|
data class AppealsOldListModel(
|
||||||
|
val appeals_old: List<AppealsOldModel>
|
||||||
|
)
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.example.rehabilitation.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,
|
||||||
|
|
||||||
|
)
|
||||||
|
|
|
@ -0,0 +1,284 @@
|
||||||
|
package com.example.rehabilitation.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.admin.Toast.showCustomInfoToast
|
||||||
|
import com.example.rehabilitation.Appeals.AppealsNewAdapter
|
||||||
|
import com.example.rehabilitation.Appeals.TabLayout.Model.AppealsNewModel
|
||||||
|
import com.example.rehabilitation.Auth.AuthorizationActivity
|
||||||
|
import com.example.rehabilitation.CodeError.Code429Activity
|
||||||
|
import com.example.rehabilitation.CodeError.Code500Activity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetActivity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetCheck
|
||||||
|
import com.example.rehabilitation.PatientViewModel
|
||||||
|
import com.example.rehabilitation.Pref.ConclusionPref
|
||||||
|
import com.example.rehabilitation.Retrofit.PatientApi
|
||||||
|
import com.example.rehabilitation.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, AppealsNewAdapter.Listener2 {
|
||||||
|
private lateinit var binding: FragmentNewAppealsBinding
|
||||||
|
private val modelPatient: PatientViewModel by activityViewModels()
|
||||||
|
lateinit var adapter: AppealsNewAdapter
|
||||||
|
private lateinit var patientApi: PatientApi
|
||||||
|
val prefPatientConclusion = ConclusionPref()
|
||||||
|
|
||||||
|
//Список обрашений новых
|
||||||
|
var appealsNewList: List<AppealsNewModel>? = null
|
||||||
|
|
||||||
|
//Класс проверки интеренета
|
||||||
|
val enternetCheck = EnternetCheck()
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
binding = FragmentNewAppealsBinding.inflate(layoutInflater,container,false)
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
initRcViewAppeals()
|
||||||
|
patientListCurrent()
|
||||||
|
modelPatient.appealsNewList.observe(viewLifecycleOwner) {//viewLifecycleOwner - следит за циклом жизни fragment
|
||||||
|
if(appealsNewList != it){
|
||||||
|
appealsNewList = it
|
||||||
|
adapter.submitList(it)//Напрямую переадем созданный список в adapter(ProductAdapter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getNewAppeals()
|
||||||
|
}
|
||||||
|
|
||||||
|
//Получение необработанных сообщений
|
||||||
|
private fun getNewAppeals() {
|
||||||
|
if (enternetCheck.isOnline(requireContext())) {
|
||||||
|
initRetrofit()
|
||||||
|
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
val listAppeals = patientApi.GetAppealsPatientNew("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){
|
||||||
|
binding.txtNull.visibility = View.GONE
|
||||||
|
modelPatient.appealsNewList.value = List.appeals_new
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
binding.txtNull.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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(), AuthorizationActivity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val intetn = Intent(requireContext(), EnternetActivity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getOldAppeals() {
|
||||||
|
if (enternetCheck.isOnline(requireContext())) {
|
||||||
|
initRetrofit()
|
||||||
|
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
val listAppeals = patientApi.GetAppealsPatientOld("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){
|
||||||
|
// binding.txtNull.visibility = View.GONE
|
||||||
|
modelPatient.appealsOldList.value = List.appeals_old
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
// binding.txtNull.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
}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(), AuthorizationActivity::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 = prefPatientConclusion.conclusionToken(requireContext())
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
val listAppeals = patientApi.UpdateMessagePatient("Bearer $Tokens",id)
|
||||||
|
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(), AuthorizationActivity::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()
|
||||||
|
|
||||||
|
patientApi = retrofit.create(PatientApi::class.java)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Вывод прогресса на один день
|
||||||
|
private fun patientListCurrent() = with(binding) {
|
||||||
|
// model.appealsAllCurrent.observe(viewLifecycleOwner) {//viewLifecycleOwner - следит за циклом жизни fragment
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Инициализация списка
|
||||||
|
private fun initRcViewAppeals() = with(binding) {
|
||||||
|
rcView.layoutManager = GridLayoutManager(requireContext(),1)//По вертикали будет выводить по умолчанию
|
||||||
|
adapter = AppealsNewAdapter(this@NewAppealsFragment,this@NewAppealsFragment)
|
||||||
|
rcView.adapter = adapter
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
fun newInstance() = NewAppealsFragment()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onClickAppeals(item: AppealsNewModel) {
|
||||||
|
addCheckAppeals(item.id,item.id_patient)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onClickAppealsPatient(item: AppealsNewModel) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,168 @@
|
||||||
|
package com.example.rehabilitation.Appeals.TabLayout
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
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.rehabilitation.Appeals.AppealsOldAdapter
|
||||||
|
import com.example.rehabilitation.Appeals.TabLayout.Model.AppealsNewModel
|
||||||
|
import com.example.rehabilitation.Appeals.TabLayout.Model.AppealsOldModel
|
||||||
|
import com.example.rehabilitation.Auth.AuthorizationActivity
|
||||||
|
import com.example.rehabilitation.CodeError.Code429Activity
|
||||||
|
import com.example.rehabilitation.CodeError.Code500Activity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetActivity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetCheck
|
||||||
|
import com.example.rehabilitation.PatientViewModel
|
||||||
|
import com.example.rehabilitation.Pref.ConclusionPref
|
||||||
|
import com.example.rehabilitation.Retrofit.PatientApi
|
||||||
|
import com.example.rehabilitation.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
|
||||||
|
|
||||||
|
|
||||||
|
class OldAppealsFragment : Fragment(), AppealsOldAdapter.Listener {
|
||||||
|
private lateinit var binding: FragmentOldAppealsBinding
|
||||||
|
private val model: PatientViewModel by activityViewModels()
|
||||||
|
lateinit var adapter: AppealsOldAdapter
|
||||||
|
private lateinit var patientApi: PatientApi
|
||||||
|
val prefPatientConclusion = ConclusionPref()
|
||||||
|
|
||||||
|
//Класс проверки интеренета
|
||||||
|
val enternetCheck = EnternetCheck()
|
||||||
|
|
||||||
|
//Список обрашений старых
|
||||||
|
var appealsOldList: List<AppealsOldModel>? = null
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
binding = FragmentOldAppealsBinding.inflate(layoutInflater,container,false)
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
initRcViewAppeals()
|
||||||
|
appealsAllCurrent()
|
||||||
|
model.appealsOldList.observe(viewLifecycleOwner) {//viewLifecycleOwner - следит за циклом жизни fragment
|
||||||
|
if(appealsOldList != it){
|
||||||
|
appealsOldList = it
|
||||||
|
adapter.submitList(it)//Напрямую переадем созданный список в adapter(ProductAdapter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getOldAppeals()
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SuspiciousIndentation")
|
||||||
|
private fun getOldAppeals() {
|
||||||
|
if (enternetCheck.isOnline(requireContext())) {
|
||||||
|
initRetrofit()
|
||||||
|
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
val listAppeals = patientApi.GetAppealsPatientOld("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){
|
||||||
|
binding.txtNull.visibility = View.GONE
|
||||||
|
model.appealsOldList.value = List.appeals_old
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
binding.txtNull.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
}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(), AuthorizationActivity::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()
|
||||||
|
|
||||||
|
patientApi = retrofit.create(PatientApi::class.java)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Вывод прогресса на один день
|
||||||
|
private fun appealsAllCurrent() = with(binding) {
|
||||||
|
// model.appealsAllCurrent.observe(viewLifecycleOwner) {//viewLifecycleOwner - следит за циклом жизни fragment
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Инициализация списка
|
||||||
|
private fun initRcViewAppeals() = with(binding) {
|
||||||
|
rcView.layoutManager = GridLayoutManager(requireContext(),1)//По вертикали будет выводить по умолчанию
|
||||||
|
adapter = AppealsOldAdapter(this@OldAppealsFragment)
|
||||||
|
rcView.adapter = adapter
|
||||||
|
}
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
fun newInstance() = OldAppealsFragment()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onClickAppeals(item: AppealsOldModel) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,38 +1,37 @@
|
||||||
package com.example.rehabilitation.Auth
|
package com.example.rehabilitation.Auth
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import com.example.admin.Toast.showCustomDangerToast
|
|
||||||
import com.example.admin.Toast.showCustomInfoToast
|
import com.example.admin.Toast.showCustomInfoToast
|
||||||
import com.example.rehabilitation.Auth.Model.AuthModel
|
import com.example.rehabilitation.Auth.Model.AuthModel
|
||||||
|
import com.example.rehabilitation.CodeError.Code429Activity
|
||||||
|
import com.example.rehabilitation.CodeError.Code500Activity
|
||||||
import com.example.rehabilitation.MainActivity
|
import com.example.rehabilitation.MainActivity
|
||||||
import com.example.rehabilitation.databinding.FragmentAuthBinding
|
import com.example.rehabilitation.databinding.FragmentAuthBinding
|
||||||
import com.example.rehabilitation.UserPatientToken
|
import com.example.rehabilitation.UserPatientToken
|
||||||
import com.example.rehabilitation.Auth.Model.PatientModel
|
import com.example.rehabilitation.Enternet.EnternetActivity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetCheck
|
||||||
import com.example.rehabilitation.MainFragment
|
import com.example.rehabilitation.MainFragment
|
||||||
import com.example.rehabilitation.PatientViewModel
|
import com.example.rehabilitation.PatientViewModel
|
||||||
|
import com.example.rehabilitation.Pref.ClearPref
|
||||||
import com.example.rehabilitation.Pref.ConclusionPref
|
import com.example.rehabilitation.Pref.ConclusionPref
|
||||||
import com.example.rehabilitation.Pref.SavePref
|
import com.example.rehabilitation.Pref.SavePref
|
||||||
import com.example.rehabilitation.Questionnaire.Model.BeforeQuestionnaireModel
|
import com.example.rehabilitation.Questionnaire.Model.BeforeQuestionnaireModel
|
||||||
import com.example.rehabilitation.R
|
import com.example.rehabilitation.R
|
||||||
import com.example.rehabilitation.Retrofit.PatientApi
|
import com.example.rehabilitation.Retrofit.PatientApi
|
||||||
import com.example.rehabilitation.Sport.SceduleFragment
|
import com.example.rehabilitation.Sport.SceduleFragment
|
||||||
import com.example.rehabilitation.prefUserPatientToken
|
|
||||||
import com.example.sqlitework.dip.MainViewModel
|
import com.example.sqlitework.dip.MainViewModel
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.logging.HttpLoggingInterceptor
|
import okhttp3.logging.HttpLoggingInterceptor
|
||||||
import org.json.JSONObject
|
|
||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
import retrofit2.converter.gson.GsonConverterFactory
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
|
|
||||||
|
@ -47,7 +46,9 @@ class AuthFragment : Fragment() {
|
||||||
private var Token = ""
|
private var Token = ""
|
||||||
val prefPatientSave = SavePref()
|
val prefPatientSave = SavePref()
|
||||||
val prefPatientConclusion = ConclusionPref()
|
val prefPatientConclusion = ConclusionPref()
|
||||||
|
val prefPatientClear = ClearPref()
|
||||||
|
//Класс проверки интеренета
|
||||||
|
val enternetCheck = EnternetCheck()
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
|
@ -60,6 +61,7 @@ class AuthFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.txtError.text = ""
|
binding.txtError.text = ""
|
||||||
|
// prefPatientClear.clearToken(requireContext())
|
||||||
Token = prefPatientConclusion.conclusionToken(requireContext())
|
Token = prefPatientConclusion.conclusionToken(requireContext())
|
||||||
|
|
||||||
//Авиризация пациента
|
//Авиризация пациента
|
||||||
|
@ -81,16 +83,16 @@ class AuthFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Если пользователь решил зайти в аккаунт врача и не подумал о том что не сможет вернуться со страницы авторизации, то он может нажать данную кнопку, и в случае если он был авторизован, то его вернет в приложение
|
// //Если пользователь решил зайти в аккаунт врача и не подумал о том что не сможет вернуться со страницы авторизации, то он может нажать данную кнопку, и в случае если он был авторизован, то его вернет в приложение
|
||||||
binding.btnBack.setOnClickListener {
|
// binding.btnBack.setOnClickListener {
|
||||||
if (UserPatientToken != "") {
|
// if (UserPatientToken != "") {
|
||||||
activity?.supportFragmentManager?.beginTransaction()
|
// activity?.supportFragmentManager?.beginTransaction()
|
||||||
?.replace(R.id.CLMain, MainFragment.newInstance())
|
// ?.replace(R.id.CLMain, MainFragment.newInstance())
|
||||||
?.commit()
|
// ?.commit()
|
||||||
} else {
|
// } else {
|
||||||
Toast(requireContext()).showCustomInfoToast("Авторизуйтесь", requireActivity())
|
// Toast(requireContext()).showCustomInfoToast("Авторизуйтесь", requireActivity())
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,7 +108,7 @@ class AuthFragment : Fragment() {
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val retrofit = Retrofit.Builder()
|
val retrofit = Retrofit.Builder()
|
||||||
.baseUrl("http://mobileapp.vmeda.org/api/")
|
.baseUrl("https://rehabilitation.vmeda.org/api/")
|
||||||
.client(client)
|
.client(client)
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
.build()
|
.build()
|
||||||
|
@ -115,60 +117,100 @@ class AuthFragment : Fragment() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Получения списка пациентов
|
// //Получения списка пациентов
|
||||||
fun BeforeQuestionnaire(item: BeforeQuestionnaireModel) {
|
// fun BeforeQuestionnaire(item: BeforeQuestionnaireModel) {
|
||||||
initRetrofit()
|
// if (enternetCheck.isOnline(requireContext())) {
|
||||||
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
// initRetrofit()
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
// val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
||||||
val QA = patientApi.AddBeforeQuestionnaire2("Bearer $Tokens",item)
|
// CoroutineScope(Dispatchers.IO).launch {
|
||||||
requireActivity().runOnUiThread {
|
// val QA = patientApi.AddBeforeQuestionnaire2("Bearer $Tokens",item)
|
||||||
|
// requireActivity().runOnUiThread {
|
||||||
//Фиксируем полученные данные
|
//
|
||||||
val AQList = QA.body()
|
// //Фиксируем полученные данные
|
||||||
|
// val AQList = QA.body()
|
||||||
//Если нету ошибок
|
//
|
||||||
if (AQList != null) {
|
// //Если нету ошибок
|
||||||
Toast(requireContext()).showCustomInfoToast(AQList.message, requireActivity())
|
// if (AQList != null) {
|
||||||
}
|
// Toast(requireContext()).showCustomInfoToast(AQList.message, requireActivity())
|
||||||
else{
|
// }
|
||||||
Toast(requireContext()).showCustomInfoToast("Ошибка при отправке", requireActivity())
|
// else{
|
||||||
|
// Toast(requireContext()).showCustomInfoToast("Ошибка при отправке", requireActivity())
|
||||||
}
|
//
|
||||||
|
// }
|
||||||
//Вывод фрагмента на активити при первоначальной загрузке
|
//
|
||||||
activity?.supportFragmentManager?.beginTransaction()
|
// //Вывод фрагмента на активити при первоначальной загрузке
|
||||||
?.replace(R.id.CLMain, SceduleFragment.newInstance())?.commit()
|
// activity?.supportFragmentManager?.beginTransaction()
|
||||||
}
|
// ?.replace(R.id.CLMain, SceduleFragment.newInstance())?.commit()
|
||||||
|
// }
|
||||||
}
|
//
|
||||||
}
|
// }
|
||||||
|
// } else {
|
||||||
|
// activity?.finish()
|
||||||
|
// val intetn = Intent(requireContext(), EnternetActivity::class.java)
|
||||||
|
// startActivity(intetn)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
private fun AuthorizationPatient(authModel: AuthModel) {
|
private fun AuthorizationPatient(authModel: AuthModel) {
|
||||||
initRetrofit()
|
if (enternetCheck.isOnline(requireContext())) {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
initRetrofit()
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
|
||||||
val response = patientApi.LoginPatient(authModel)
|
val response = patientApi.LoginPatient(authModel)
|
||||||
requireActivity().runOnUiThread {
|
requireActivity().runOnUiThread {
|
||||||
val user = response.body()
|
|
||||||
//Если есть такой пользователь
|
|
||||||
if (user != null) {
|
|
||||||
|
|
||||||
//PatientVewModel.token.value = user.token
|
|
||||||
prefPatientSave.saveToken(requireContext(),user.token)
|
|
||||||
|
|
||||||
val intetn = Intent(requireContext(), MainActivity::class.java)
|
//Фиксируем полученные данные
|
||||||
startActivity(intetn)
|
val List = response.body()
|
||||||
activity?.finish()
|
val Nice = response.isSuccessful
|
||||||
}
|
val Code = response.code()
|
||||||
else{
|
if(Code==429){
|
||||||
Toast(requireContext()).showCustomInfoToast(
|
val intetn = Intent(requireContext(), Code429Activity::class.java)
|
||||||
"Такого пользователя нету",
|
|
||||||
requireActivity()
|
startActivity(intetn)
|
||||||
)
|
}
|
||||||
|
else if(Code==200) {
|
||||||
|
//Если нету ошибок
|
||||||
|
if (Nice) {
|
||||||
|
//Если есть такой пользователь
|
||||||
|
if (List != null) {
|
||||||
|
|
||||||
|
//PatientVewModel.token.value = user.token
|
||||||
|
prefPatientSave.saveToken(requireContext(),List.token)
|
||||||
|
val intetn = Intent(requireContext(), MainActivity::class.java)
|
||||||
|
startActivity(intetn)
|
||||||
|
|
||||||
|
}
|
||||||
|
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(), AuthorizationActivity::class.java)
|
||||||
|
// activity?.finish()
|
||||||
|
// startActivity(intetn)
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
val intetn = Intent(requireContext(), EnternetActivity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,15 @@ class AuthorizationActivity : AppCompatActivity() {
|
||||||
binding = ActivityAuthorizationBinding.inflate(layoutInflater)
|
binding = ActivityAuthorizationBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
|
//Вывод фрагмента на активити при первоначальной загрузке
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(R.id.CLAuth, AuthFragment.newInstance())
|
||||||
|
.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onDestroy() {
|
|
||||||
super.onDestroy()
|
|
||||||
finish()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,44 +1,26 @@
|
||||||
package com.example.rehabilitation.Calendare
|
package com.example.rehabilitation.Calendare
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.graphics.Typeface
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.util.TypedValue
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.TextView
|
|
||||||
import androidx.core.view.children
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import com.example.rehabilitation.Auth.AuthorizationActivity
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import com.example.rehabilitation.CodeError.Code429Activity
|
||||||
import com.example.rehabilitation.Calendare.Calendare.CalendareAdapter
|
import com.example.rehabilitation.CodeError.Code500Activity
|
||||||
import com.example.rehabilitation.Calendare.Calendare.getColorCompat
|
import com.example.rehabilitation.Enternet.EnternetActivity
|
||||||
import com.example.rehabilitation.Calendare.Calendare.setTextColorRes
|
import com.example.rehabilitation.Enternet.EnternetCheck
|
||||||
import com.example.rehabilitation.Calendare.Calendare.shared.displayText
|
import com.example.rehabilitation.PatientViewModel
|
||||||
import com.example.rehabilitation.Calendare.Calendare.shared.generateFlights
|
|
||||||
import com.example.rehabilitation.Pref.ConclusionPref
|
import com.example.rehabilitation.Pref.ConclusionPref
|
||||||
import com.example.rehabilitation.R
|
|
||||||
import com.example.rehabilitation.Retrofit.PatientApi
|
import com.example.rehabilitation.Retrofit.PatientApi
|
||||||
import com.example.rehabilitation.Sport.DayAdapter
|
import com.example.rehabilitation.Sport.DayAdapter
|
||||||
import com.example.rehabilitation.databinding.Example5CalendarDayBinding
|
|
||||||
import com.example.rehabilitation.databinding.Example5CalendarHeaderBinding
|
|
||||||
import com.example.rehabilitation.databinding.FragmentCalendarBinding
|
import com.example.rehabilitation.databinding.FragmentCalendarBinding
|
||||||
import com.example.rehabilitation.listCalendare
|
|
||||||
import com.example.sqlitework.dip.MainViewModel
|
import com.example.sqlitework.dip.MainViewModel
|
||||||
import com.kizitonwose.calendar.core.CalendarDay
|
|
||||||
import com.kizitonwose.calendar.core.CalendarMonth
|
|
||||||
import com.kizitonwose.calendar.core.DayPosition
|
|
||||||
import com.kizitonwose.calendar.core.daysOfWeek
|
|
||||||
import com.kizitonwose.calendar.core.nextMonth
|
|
||||||
import com.kizitonwose.calendar.core.previousMonth
|
|
||||||
import com.kizitonwose.calendar.view.MonthDayBinder
|
|
||||||
import com.kizitonwose.calendar.view.MonthHeaderFooterBinder
|
|
||||||
import com.kizitonwose.calendar.view.ViewContainer
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
@ -46,29 +28,36 @@ import okhttp3.OkHttpClient
|
||||||
import okhttp3.logging.HttpLoggingInterceptor
|
import okhttp3.logging.HttpLoggingInterceptor
|
||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
import retrofit2.converter.gson.GsonConverterFactory
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
import java.time.DayOfWeek
|
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
import java.time.YearMonth
|
|
||||||
import java.util.Timer
|
import java.util.Timer
|
||||||
|
import kotlin.concurrent.fixedRateTimer
|
||||||
import kotlin.concurrent.timerTask
|
import kotlin.concurrent.timerTask
|
||||||
|
|
||||||
|
|
||||||
class CalendarFragment : Fragment() {
|
class CalendarFragment : Fragment(),CalendareListAdapter.Listener {
|
||||||
private lateinit var binding: FragmentCalendarBinding
|
private lateinit var binding: FragmentCalendarBinding
|
||||||
lateinit var adapterDay: DayAdapter
|
lateinit var adapterCalendare: CalendareListAdapter
|
||||||
private val model: MainViewModel by activityViewModels()//Инициализировали класс
|
private val modelPatient: PatientViewModel by activityViewModels()//Инициализировали класс
|
||||||
private lateinit var patientApi: PatientApi
|
private lateinit var patientApi: PatientApi
|
||||||
private var selectedDate: LocalDate? = null
|
private lateinit var timer: Timer
|
||||||
|
|
||||||
val prefPatientConclusion = ConclusionPref()
|
val prefPatientConclusion = ConclusionPref()
|
||||||
private val flightsAdapter = CalendareAdapter()
|
|
||||||
//Для разрешения проверки количества дней
|
|
||||||
var lookDateSportMax = false
|
|
||||||
|
//Календарь
|
||||||
|
var listCalendare:List<CalendareModel>? = null
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
|
|
||||||
//Загрузка данных для календаря
|
//Загрузка данных для календаря
|
||||||
var calendare = false
|
var calendare = false
|
||||||
|
|
||||||
|
//Класс проверки интеренета
|
||||||
|
val enternetCheck = EnternetCheck()
|
||||||
|
|
||||||
|
var infoVisibleCalendare = false
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
|
@ -81,14 +70,44 @@ class CalendarFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
|
||||||
if(isAdded) {
|
if(isAdded) {
|
||||||
calendare = false
|
visibleLoad()
|
||||||
initRcViewCalendareMoment()
|
initRcView()
|
||||||
|
initRetrofit()
|
||||||
APIliveCountCalendareCurrent()
|
APIliveCountCalendareCurrent()
|
||||||
|
|
||||||
|
|
||||||
|
modelPatient.calendareList.observe(viewLifecycleOwner){
|
||||||
|
if(listCalendare != it){
|
||||||
|
listCalendare = it
|
||||||
|
adapterCalendare.submitList(it)
|
||||||
|
}
|
||||||
|
visibleCalendare()
|
||||||
|
}
|
||||||
|
|
||||||
|
// fixedRateTimer("timer", false, 0, 10000) {
|
||||||
|
// activity?.runOnUiThread {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.btnInfoCalendare.setOnClickListener{
|
||||||
|
if(infoVisibleCalendare == false){
|
||||||
|
infoVisibleCalendare = true
|
||||||
|
binding.CVInfoCalendare.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
infoVisibleCalendare = false
|
||||||
|
binding.CVInfoCalendare.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun visibleCalendare(){
|
fun visibleCalendare(){
|
||||||
binding.CLCalendare.visibility = View.VISIBLE
|
binding.CLCalendare.visibility = View.VISIBLE
|
||||||
binding.CLLoad.visibility = View.GONE
|
binding.CLLoad.visibility = View.GONE
|
||||||
|
@ -102,55 +121,15 @@ class CalendarFragment : Fragment() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
|
||||||
private fun calendareTwoAdd() {
|
|
||||||
if(calendare == false) {
|
|
||||||
calendare = true
|
|
||||||
// binding.exFiveRv.apply {
|
|
||||||
// layoutManager = LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false)
|
|
||||||
// adapter = flightsAdapter
|
|
||||||
// }
|
|
||||||
Log.i("listCalendare1", listCalendare.toString())
|
|
||||||
flightsAdapter.notifyDataSetChanged()
|
|
||||||
|
|
||||||
val daysOfWeek = daysOfWeek()
|
//Инициализация списка
|
||||||
val currentMonth = YearMonth.now()
|
private fun initRcView() = with(binding) {
|
||||||
val startMonth = currentMonth.minusMonths(200)
|
rcView.layoutManager = GridLayoutManager(requireContext(), 1)//По вертикали будет выводить по умолчанию
|
||||||
val endMonth = currentMonth.plusMonths(200)
|
adapterCalendare = CalendareListAdapter(this@CalendarFragment)
|
||||||
configureBinders(daysOfWeek)
|
rcView.adapter = adapterCalendare
|
||||||
binding.exFiveCalendar.setup(startMonth, endMonth, daysOfWeek.first())
|
//binding.rcVIewDayList.smoothScrollToPosition(0);
|
||||||
binding.exFiveCalendar.scrollToMonth(currentMonth)
|
|
||||||
|
|
||||||
binding.exFiveCalendar.monthScrollListener = { month ->
|
|
||||||
binding.exFiveMonthYearText.text = month.yearMonth.displayText()
|
|
||||||
|
|
||||||
selectedDate?.let {
|
|
||||||
// Clear selection if we scroll to a new month.
|
|
||||||
selectedDate = null
|
|
||||||
binding.exFiveCalendar.notifyDateChanged(it)
|
|
||||||
updateAdapterForDate(null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.exFiveNextMonthImage.setOnClickListener {
|
|
||||||
binding.exFiveCalendar.findFirstVisibleMonth()?.let {
|
|
||||||
binding.exFiveCalendar.smoothScrollToMonth(it.yearMonth.nextMonth)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.exFivePreviousMonthImage.setOnClickListener {
|
|
||||||
binding.exFiveCalendar.findFirstVisibleMonth()?.let {
|
|
||||||
binding.exFiveCalendar.smoothScrollToMonth(it.yearMonth.previousMonth)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
visibleCalendare()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initRcViewCalendareMoment() = with(binding) {
|
|
||||||
exFiveRv.layoutManager = GridLayoutManager(requireContext(), 1)//По вертикали будет выводить по умолчанию
|
|
||||||
exFiveRv.adapter = flightsAdapter
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Инициализация запроса
|
//Инициализация запроса
|
||||||
|
@ -165,7 +144,8 @@ class CalendarFragment : Fragment() {
|
||||||
|
|
||||||
//Базовая ссылка
|
//Базовая ссылка
|
||||||
val retrofit = Retrofit.Builder()
|
val retrofit = Retrofit.Builder()
|
||||||
.baseUrl("http://mobileapp.vmeda.org/api/").client(client)
|
.baseUrl("https://rehabilitation.vmeda.org/api/")
|
||||||
|
.client(client)
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
.build()
|
.build()
|
||||||
patientApi = retrofit.create(PatientApi::class.java)//Экземпляр
|
patientApi = retrofit.create(PatientApi::class.java)//Экземпляр
|
||||||
|
@ -173,137 +153,92 @@ class CalendarFragment : Fragment() {
|
||||||
|
|
||||||
//Функция получения данных для заполнения календаря
|
//Функция получения данных для заполнения календаря
|
||||||
private fun APIliveCountCalendareCurrent() {
|
private fun APIliveCountCalendareCurrent() {
|
||||||
visibleLoad()
|
if (enternetCheck.isOnline(requireContext())) {
|
||||||
initRetrofit()
|
|
||||||
|
|
||||||
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
initRetrofit()
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
|
||||||
val Calendare = patientApi.PatientCalendareDay("Bearer $Tokens")
|
|
||||||
|
|
||||||
activity?.runOnUiThread {
|
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
||||||
//Фиксируем полученные данные
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
val CalendareList = Calendare.body()
|
val Calendare = patientApi.GetCalendare("Bearer $Tokens")
|
||||||
Log.i("1111111111111111111",CalendareList.toString())
|
|
||||||
//Если нету ошибок
|
|
||||||
if (CalendareList != null) {
|
|
||||||
Log.i("2222","2222")
|
|
||||||
listCalendare = CalendareList.сalendare
|
|
||||||
Log.i("listCalendare",listCalendare.toString())
|
|
||||||
calendareTwoAdd()
|
|
||||||
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
timerCalendare()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private fun timerCalendare() {
|
|
||||||
Log.i("asdasdasdasd444444444", "23231x2wswqxsxsas")
|
|
||||||
calendare = false
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
|
||||||
Timer().schedule(timerTask {
|
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
APIliveCountCalendareCurrent()
|
|
||||||
}
|
|
||||||
}, 15000)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private fun updateAdapterForDate(date: LocalDate?) {
|
//Фиксируем полученные данные
|
||||||
val flightss = generateFlights().groupBy { it.time.toLocalDate() }
|
val List = Calendare.body()
|
||||||
flightsAdapter.flights.clear()
|
val Nice = Calendare.isSuccessful
|
||||||
flightsAdapter.flights.addAll(flightss[date].orEmpty())
|
val Code = Calendare.code()
|
||||||
flightsAdapter.notifyDataSetChanged()
|
if(Code==429){
|
||||||
}
|
val intetn = Intent(requireContext(), Code429Activity::class.java)
|
||||||
|
|
||||||
private fun configureBinders(daysOfWeek: List<DayOfWeek>) {
|
startActivity(intetn)
|
||||||
class DayViewContainer(view: View) : ViewContainer(view) {
|
|
||||||
lateinit var day: CalendarDay // Will be set when this container is bound.
|
|
||||||
val binding = Example5CalendarDayBinding.bind(view)
|
|
||||||
|
|
||||||
init {
|
|
||||||
view.setOnClickListener {
|
|
||||||
if (day.position == DayPosition.MonthDate) {
|
|
||||||
if (selectedDate != day.date) {
|
|
||||||
val oldDate = selectedDate
|
|
||||||
selectedDate = day.date
|
|
||||||
val binding = this@CalendarFragment.binding
|
|
||||||
binding.exFiveCalendar.notifyDateChanged(day.date)
|
|
||||||
oldDate?.let { binding.exFiveCalendar.notifyDateChanged(it) }
|
|
||||||
updateAdapterForDate(day.date)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
else if(Code==200) {
|
||||||
}
|
//Если нету ошибок
|
||||||
}
|
if (Nice) {
|
||||||
binding.exFiveCalendar.dayBinder = object : MonthDayBinder<DayViewContainer> {
|
//Если нету ошибок
|
||||||
override fun create(view: View) = DayViewContainer(view)
|
if (List != null) {
|
||||||
|
Log.i("CalendareList_calendare_day", List.calendare_day.toString())
|
||||||
@SuppressLint("NewApi")
|
modelPatient.calendareList.value = List.calendare_day
|
||||||
override fun bind(container: DayViewContainer, data: CalendarDay) {
|
|
||||||
container.day = data
|
|
||||||
val context = container.binding.root.context
|
|
||||||
val textView = container.binding.exFiveDayText
|
|
||||||
val layout = container.binding.exFiveDayLayout
|
|
||||||
textView.text = data.date.dayOfMonth.toString()
|
|
||||||
|
|
||||||
val flightTopView = container.binding.exFiveDayFlightTop
|
|
||||||
val flightBottomView = container.binding.exFiveDayFlightBottom
|
|
||||||
flightTopView.background = null
|
|
||||||
flightBottomView.background = null
|
|
||||||
|
|
||||||
if (data.position == DayPosition.MonthDate) {
|
|
||||||
textView.setTextColorRes(R.color.black)
|
|
||||||
layout.setBackgroundResource(if (selectedDate == data.date) R.drawable.example_5_selected_bg else 0)
|
|
||||||
val flightss = generateFlights().groupBy { it.time.toLocalDate() }
|
|
||||||
val flights = flightss[data.date]
|
|
||||||
if (flights != null) {
|
|
||||||
if (flights.count() == 1) {
|
|
||||||
flightBottomView.setBackgroundColor(context.getColorCompat(flights[0].color))
|
|
||||||
} else {
|
|
||||||
flightTopView.setBackgroundColor(context.getColorCompat(flights[0].color))
|
|
||||||
flightBottomView.setBackgroundColor(context.getColorCompat(flights[1].color))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
textView.setTextColorRes(R.color.blue)
|
|
||||||
layout.background = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MonthViewContainer(view: View) : ViewContainer(view) {
|
|
||||||
val legendLayout = Example5CalendarHeaderBinding.bind(view).legendLayout.root
|
|
||||||
}
|
|
||||||
|
|
||||||
val typeFace = Typeface.create("sans-serif-light", Typeface.NORMAL)
|
|
||||||
binding.exFiveCalendar.monthHeaderBinder =
|
|
||||||
object : MonthHeaderFooterBinder<MonthViewContainer> {
|
|
||||||
override fun create(view: View) = MonthViewContainer(view)
|
|
||||||
override fun bind(container: MonthViewContainer, data: CalendarMonth) {
|
|
||||||
// Setup each header day text if we have not done that already.
|
|
||||||
if (container.legendLayout.tag == null) {
|
|
||||||
container.legendLayout.tag = data.yearMonth
|
|
||||||
container.legendLayout.children.map { it as TextView }
|
|
||||||
.forEachIndexed { index, tv ->
|
|
||||||
tv.text = daysOfWeek[index].displayText(uppercase = true)
|
|
||||||
tv.setTextColorRes(R.color.black)
|
|
||||||
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12f)
|
|
||||||
tv.typeface = typeFace
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Code == 500) {
|
||||||
|
val intetn = Intent(requireContext(), Code500Activity::class.java)
|
||||||
|
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
else if (Code == 401) {
|
||||||
|
val intetn = Intent(requireContext(), AuthorizationActivity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
val intetn = Intent(requireContext(), EnternetActivity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun newInstance() = CalendarFragment()
|
fun newInstance() = CalendarFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onClickCalendare(item: CalendareModel) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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) {
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
APIliveCountCalendareCurrent()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,59 +0,0 @@
|
||||||
package com.example.rehabilitation.Calendare.Calendare
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.graphics.drawable.Drawable
|
|
||||||
import android.util.TypedValue
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.inputmethod.InputMethodManager
|
|
||||||
import android.widget.TextView
|
|
||||||
import androidx.annotation.ColorRes
|
|
||||||
import androidx.annotation.DrawableRes
|
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.lifecycle.findViewTreeLifecycleOwner
|
|
||||||
import com.example.rehabilitation.Calendare.Calendare.shared.StatusBarColorLifecycleObserver
|
|
||||||
|
|
||||||
|
|
||||||
fun View.makeVisible() {
|
|
||||||
visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
|
|
||||||
fun View.makeInVisible() {
|
|
||||||
visibility = View.INVISIBLE
|
|
||||||
}
|
|
||||||
|
|
||||||
fun View.makeGone() {
|
|
||||||
visibility = View.GONE
|
|
||||||
}
|
|
||||||
|
|
||||||
fun dpToPx(dp: Int, context: Context): Int =
|
|
||||||
TypedValue.applyDimension(
|
|
||||||
TypedValue.COMPLEX_UNIT_DIP,
|
|
||||||
dp.toFloat(),
|
|
||||||
context.resources.displayMetrics,
|
|
||||||
).toInt()
|
|
||||||
|
|
||||||
internal val Context.layoutInflater: LayoutInflater
|
|
||||||
get() = LayoutInflater.from(this)
|
|
||||||
|
|
||||||
internal val Context.inputMethodManager
|
|
||||||
get() = this.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
|
||||||
|
|
||||||
internal fun Context.getDrawableCompat(@DrawableRes drawable: Int): Drawable =
|
|
||||||
requireNotNull(ContextCompat.getDrawable(this, drawable))
|
|
||||||
|
|
||||||
internal fun Context.getColorCompat(@ColorRes color: Int) =
|
|
||||||
ContextCompat.getColor(this, color)
|
|
||||||
|
|
||||||
internal fun TextView.setTextColorRes(@ColorRes color: Int) =
|
|
||||||
setTextColor(context.getColorCompat(color))
|
|
||||||
|
|
||||||
fun Fragment.addStatusBarColorUpdate(@ColorRes colorRes: Int) {
|
|
||||||
view?.findViewTreeLifecycleOwner()?.lifecycle?.addObserver(
|
|
||||||
StatusBarColorLifecycleObserver(
|
|
||||||
requireActivity(),
|
|
||||||
requireContext().getColorCompat(colorRes),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
|
@ -1,67 +0,0 @@
|
||||||
package com.example.rehabilitation.Calendare.Calendare.shared
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.icu.text.SimpleDateFormat
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.annotation.ColorRes
|
|
||||||
import com.example.rehabilitation.R
|
|
||||||
import com.example.rehabilitation.listCalendare
|
|
||||||
import java.time.LocalDate
|
|
||||||
import java.time.LocalDateTime
|
|
||||||
import java.time.Month
|
|
||||||
import java.time.YearMonth
|
|
||||||
import java.time.format.DateTimeFormatter
|
|
||||||
import kotlin.time.Duration.Companion.days
|
|
||||||
|
|
||||||
|
|
||||||
data class Flight(
|
|
||||||
val time: LocalDateTime,
|
|
||||||
val item: String,
|
|
||||||
@ColorRes val color: Int,
|
|
||||||
) {
|
|
||||||
data class Airport(val city: String, val code: String)
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
fun generateFlights(): List<Flight> = buildList {
|
|
||||||
//val currentMonth = LocalDate.now()
|
|
||||||
Log.i("listCalendare.size",listCalendare.size.toString())
|
|
||||||
Log.i("listCalendare.toString()",listCalendare.toString())
|
|
||||||
if(listCalendare.size>0){
|
|
||||||
for (i in 0..listCalendare.size-1) {
|
|
||||||
Log.i("listCalendare[i-1].date",listCalendare[0].day.toString())
|
|
||||||
// val day = "${date[3]}"+"${date[4]}"//День
|
|
||||||
// val mount = "${date[0]}"+"${date[1]}"//Месяц
|
|
||||||
var date = listCalendare[i].date
|
|
||||||
var dateDay = date[8]+""+date[9]
|
|
||||||
var dateMonth = date[5]+""+date[6]
|
|
||||||
var dateYear = date[0]+""+date[1]+""+date[2]+""+date[3]
|
|
||||||
Log.i("dateDay",dateDay)
|
|
||||||
|
|
||||||
|
|
||||||
LocalDate.of(dateYear.toInt(), dateMonth.toInt(), dateDay.toInt()).plusMonths(0).also { date ->
|
|
||||||
if(listCalendare[i].block != null){
|
|
||||||
Log.i("listCalendare[i].block",listCalendare[i].block)
|
|
||||||
add(Flight(date.atTime(0, 0), "Блокировка", R.color.red_800))
|
|
||||||
}
|
|
||||||
else if(listCalendare[i].pause != null){
|
|
||||||
add(Flight(date.atTime(0, 0), "Пауза", R.color.example_7_yellow))
|
|
||||||
}
|
|
||||||
if(listCalendare[i].id_after_questionnaire != null){
|
|
||||||
add(Flight(date.atTime(0, 0), "Выполнена тренировка", R.color.green_700))
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(listCalendare[i].block == null){
|
|
||||||
add(Flight(date.atTime(0, 0), "День комплекса", R.color.blue_800))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
val flightDateTimeFormatter: DateTimeFormatter =
|
|
||||||
DateTimeFormatter.ofPattern("EEE'\n'dd MMM'\n'HH:mm")
|
|
|
@ -1,43 +0,0 @@
|
||||||
package com.example.rehabilitation.Calendare.Calendare.shared
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.app.Activity
|
|
||||||
import android.graphics.Color
|
|
||||||
import android.os.Build
|
|
||||||
import android.view.View
|
|
||||||
import androidx.annotation.ColorInt
|
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.core.graphics.ColorUtils
|
|
||||||
import androidx.lifecycle.DefaultLifecycleObserver
|
|
||||||
import androidx.lifecycle.LifecycleOwner
|
|
||||||
import com.example.rehabilitation.R
|
|
||||||
|
|
||||||
import java.lang.ref.WeakReference
|
|
||||||
|
|
||||||
class StatusBarColorLifecycleObserver(
|
|
||||||
activity: Activity,
|
|
||||||
@ColorInt private val color: Int,
|
|
||||||
) : DefaultLifecycleObserver {
|
|
||||||
private val isLightColor = ColorUtils.calculateLuminance(color) > 0.5
|
|
||||||
private val defaultStatusBarColor = R.color.colorPrimaryDark
|
|
||||||
private val activity = WeakReference(activity)
|
|
||||||
|
|
||||||
override fun onStart(owner: LifecycleOwner) {
|
|
||||||
activity.get()?.window?.apply {
|
|
||||||
statusBarColor = color
|
|
||||||
if (isLightColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("ResourceAsColor")
|
|
||||||
override fun onStop(owner: LifecycleOwner) {
|
|
||||||
activity.get()?.window?.apply {
|
|
||||||
statusBarColor = defaultStatusBarColor
|
|
||||||
if (isLightColor) decorView.systemUiVisibility = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroy(owner: LifecycleOwner) = activity.clear()
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
package com.example.rehabilitation.Calendare.Calendare.shared
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.ContextWrapper
|
|
||||||
import com.kizitonwose.calendar.core.Week
|
|
||||||
import com.kizitonwose.calendar.core.yearMonth
|
|
||||||
import java.time.DayOfWeek
|
|
||||||
import java.time.Month
|
|
||||||
import java.time.YearMonth
|
|
||||||
import java.time.format.TextStyle
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
fun YearMonth.displayText(short: Boolean = false): String {
|
|
||||||
return "${this.month.displayText(short = short)} ${this.year}"
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
fun Month.displayText(short: Boolean = true): String {
|
|
||||||
val style = if (short) TextStyle.SHORT else TextStyle.FULL
|
|
||||||
return getDisplayName(style, Locale.ENGLISH)
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
fun DayOfWeek.displayText(uppercase: Boolean = false): String {
|
|
||||||
return getDisplayName(TextStyle.SHORT, Locale.ENGLISH).let { value ->
|
|
||||||
if (uppercase) value.uppercase(Locale.ENGLISH) else value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Context.findActivity(): Activity {
|
|
||||||
var context = this
|
|
||||||
while (context is ContextWrapper) {
|
|
||||||
if (context is Activity) return context
|
|
||||||
context = context.baseContext
|
|
||||||
}
|
|
||||||
throw IllegalStateException("no activity")
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
fun getWeekPageTitle(week: Week): String {
|
|
||||||
val firstDate = week.days.first().date
|
|
||||||
val lastDate = week.days.last().date
|
|
||||||
return when {
|
|
||||||
firstDate.yearMonth == lastDate.yearMonth -> {
|
|
||||||
firstDate.yearMonth.displayText()
|
|
||||||
}
|
|
||||||
firstDate.year == lastDate.year -> {
|
|
||||||
"${firstDate.month.displayText(short = false)} - ${lastDate.yearMonth.displayText()}"
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
"${firstDate.yearMonth.displayText()} - ${lastDate.yearMonth.displayText()}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
package com.example.rehabilitation.Calendare.Calendare
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import com.example.rehabilitation.Calendare.Calendare.getColorCompat
|
|
||||||
import com.example.rehabilitation.Calendare.Calendare.layoutInflater
|
|
||||||
import com.example.rehabilitation.Calendare.Calendare.shared.Flight
|
|
||||||
import com.example.rehabilitation.Calendare.Calendare.shared.flightDateTimeFormatter
|
|
||||||
import com.example.rehabilitation.databinding.Example5EventItemViewv2Binding
|
|
||||||
|
|
||||||
|
|
||||||
class CalendareAdapter :
|
|
||||||
RecyclerView.Adapter<CalendareAdapter.Example5FlightsViewHolder>() {
|
|
||||||
|
|
||||||
val flights = mutableListOf<Flight>()
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Example5FlightsViewHolder {
|
|
||||||
return Example5FlightsViewHolder(
|
|
||||||
Example5EventItemViewv2Binding.inflate(parent.context.layoutInflater, parent, false),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBindViewHolder(viewHolder: Example5FlightsViewHolder, position: Int) {
|
|
||||||
viewHolder.bind(flights[position])
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItemCount(): Int = flights.size
|
|
||||||
|
|
||||||
inner class Example5FlightsViewHolder(val binding: Example5EventItemViewv2Binding) :
|
|
||||||
RecyclerView.ViewHolder(binding.root) {
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
fun bind(flight: Flight) {
|
|
||||||
binding.itemFlightDateText.apply {
|
|
||||||
text = flightDateTimeFormatter.format(flight.time)
|
|
||||||
setBackgroundColor(itemView.context.getColorCompat(flight.color))
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.txtItem.text = flight.item
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,123 @@
|
||||||
|
package com.example.rehabilitation.Calendare
|
||||||
|
|
||||||
|
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.rehabilitation.R
|
||||||
|
import com.example.rehabilitation.databinding.ItemCalendareBinding
|
||||||
|
import java.time.LocalDate
|
||||||
|
|
||||||
|
|
||||||
|
class CalendareListAdapter(val listener: Listener) :
|
||||||
|
ListAdapter<CalendareModel, CalendareListAdapter.Holder>(
|
||||||
|
Comparator()
|
||||||
|
) {//Productitem - по этой форме будем заполнять.//ProductAdapter.holder - это создаваемый holder который хранит логику как нужно заполнять карточку
|
||||||
|
|
||||||
|
|
||||||
|
//В holder создаетс код с помошью которого мы будем заполнять и сохронять разметку
|
||||||
|
class Holder(view: View, val listener: Listener) :
|
||||||
|
RecyclerView.ViewHolder(view) {//Класс который будет хранить сссылки на элементы, и отвечает за один элемент за 1 раз, то есть сначсало нулевой элемент заполнит, потом первый, потом второй и т.д.
|
||||||
|
//Для передачи данных
|
||||||
|
|
||||||
|
val binding = ItemCalendareBinding.bind(view)//view - здесь храянтся элементы и мы их bind заполним в ListItemBinding//ListItemBinding - это клласс даннйо разметки(карточки) которую мы будем заполнять, а нужна дання переменная(binding), чтобы мжно было при заполнение обращатся к элементам карточки
|
||||||
|
|
||||||
|
var itemTemp: CalendareModel? =
|
||||||
|
null//Глобальная переменная для нашего item, чтобы можно было передать данные для нажатия
|
||||||
|
|
||||||
|
//init - дает возможность внутри адаптера обращаться к элементам экрана
|
||||||
|
init {
|
||||||
|
itemView.setOnClickListener {//Нажатие на ячейку//itemView - это весь элемент карточки из списка
|
||||||
|
//itemView.setEnabled(false)
|
||||||
|
itemTemp?.let { it1 -> listener.onClickCalendare(it1) }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SuspiciousIndentation", "SetTextI18n")
|
||||||
|
fun bind(item: CalendareModel) = with(binding) {//Productitem - перпедаем данные
|
||||||
|
itemTemp = item
|
||||||
|
txtDay.text = item.day
|
||||||
|
val date1 = item.date[8];
|
||||||
|
val date2 = item.date[9];
|
||||||
|
val date3 = item.date[5];
|
||||||
|
val date4 = item.date[6];
|
||||||
|
val date5 = item.date[0];
|
||||||
|
val date6 = item.date[1];
|
||||||
|
val date7 = item.date[2];
|
||||||
|
val date8 = item.date[3];
|
||||||
|
txtDate.text = date1+""+date2+"."+date3+""+date4+"."+date5+""+date6+""+date7+""+date8
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(item.block != null){
|
||||||
|
binding.CVBlock.setCardBackgroundColor(Color.parseColor("#FF0000"))
|
||||||
|
}
|
||||||
|
else if(item.pause != null){
|
||||||
|
binding.CVPause.setCardBackgroundColor(Color.parseColor("#FFA355"))
|
||||||
|
}
|
||||||
|
if(item.id_after_questionnaire != null){
|
||||||
|
binding.CVDay.setCardBackgroundColor(Color.parseColor("#7FE668"))
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(item.block == null){
|
||||||
|
if(item.date >= LocalDate.now().toString()){
|
||||||
|
binding.CVDay.setCardBackgroundColor(Color.parseColor("#55B6FF"))
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
binding.CVDay.setCardBackgroundColor(Color.parseColor("#9C9C9C"))
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
|
||||||
|
val view = LayoutInflater.from(parent.context)
|
||||||
|
.inflate(R.layout.item_calendare, 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<CalendareModel>() {
|
||||||
|
override fun areItemsTheSame(
|
||||||
|
oldItem: CalendareModel,
|
||||||
|
newItem: CalendareModel
|
||||||
|
): Boolean {//Тут лучше всего сравнивать по id//oldItem - элементы старого списка, newItem - элементы нового списка//Возврощает Boolean, тоесть есть изменения или нет
|
||||||
|
return oldItem.id == newItem.id//Сравниваем полностью весь список новы и старый, по очередно по одной карточке и по элементно, то есть нулевой элемент, первый, второй и т.д.. Но лучше сравнивать по id списки, а не просто весь список, так как это эфективнее, так как id уникальный(oldItem.id == newItem.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun areContentsTheSame(
|
||||||
|
oldItem: CalendareModel,
|
||||||
|
newItem: CalendareModel
|
||||||
|
): Boolean {//Утут нужно сравнивать весь спсок старых элементов и новых
|
||||||
|
return oldItem == newItem//Сравниваем полностью весь список новы и старый
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Интерфейс нажатия на кнопку удалить товар из корзины
|
||||||
|
interface Listener {
|
||||||
|
fun onClickCalendare(item: CalendareModel)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package com.example.rehabilitation.Calendare
|
package com.example.rehabilitation.Calendare
|
||||||
|
|
||||||
data class CalendareListModel(
|
data class CalendareListModel(
|
||||||
val сalendare: List<CalendareModel>
|
val calendare_day: List<CalendareModel>
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,161 @@
|
||||||
|
package com.example.rehabilitation.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.rehabilitation.Auth.AuthorizationActivity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetActivity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetCheck
|
||||||
|
import com.example.rehabilitation.MainActivity
|
||||||
|
import com.example.rehabilitation.Pref.ClearPref
|
||||||
|
import com.example.rehabilitation.Pref.ConclusionPref
|
||||||
|
import com.example.rehabilitation.Pref.SavePref
|
||||||
|
import com.example.rehabilitation.Retrofit.PatientApi
|
||||||
|
import com.example.rehabilitation.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 patientApi: PatientApi
|
||||||
|
private lateinit var timer: Timer
|
||||||
|
|
||||||
|
|
||||||
|
val prefPatientConclusion = ConclusionPref()
|
||||||
|
val prefPatientClear = ClearPref()
|
||||||
|
val prefPatientSave = SavePref()
|
||||||
|
|
||||||
|
//Класс проверки интеренета
|
||||||
|
val enternetCheck = EnternetCheck()
|
||||||
|
|
||||||
|
var checkClose = false
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
binding = ActivityCode429Binding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
|
|
||||||
|
// binding.apply {
|
||||||
|
// btnBack.isEnabled = false
|
||||||
|
// btnBack.isClickable = false
|
||||||
|
// val timer = object: CountDownTimer(20000, 1000) {
|
||||||
|
// override fun onTick(millisUntilFinished: Long) {
|
||||||
|
// txtTime.setText( "${(millisUntilFinished / 1000)} сек");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// override fun onFinish() {
|
||||||
|
// btnBack.isEnabled = true
|
||||||
|
// btnBack.isClickable = true
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// timer.start()
|
||||||
|
|
||||||
|
// binding.btnBack.setOnClickListener{
|
||||||
|
// Log.i("clogon1232222","clogon1232222")
|
||||||
|
// finish()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressLint("SuspiciousIndentation")
|
||||||
|
fun CheckToken()=with(binding){
|
||||||
|
if (enternetCheck.isOnline(this@Code429Activity)) {
|
||||||
|
initRetrofit()
|
||||||
|
val Tokens = prefPatientConclusion.conclusionToken(this@Code429Activity)
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
val list = patientApi.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, AuthorizationActivity::class.java)
|
||||||
|
finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
val intetn = Intent(this@Code429Activity, 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()
|
||||||
|
|
||||||
|
patientApi = retrofit.create(PatientApi::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,160 @@
|
||||||
|
package com.example.rehabilitation.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.rehabilitation.Auth.AuthorizationActivity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetActivity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetCheck
|
||||||
|
import com.example.rehabilitation.MainActivity
|
||||||
|
import com.example.rehabilitation.Pref.ClearPref
|
||||||
|
import com.example.rehabilitation.Pref.ConclusionPref
|
||||||
|
import com.example.rehabilitation.Pref.SavePref
|
||||||
|
import com.example.rehabilitation.Retrofit.PatientApi
|
||||||
|
import com.example.rehabilitation.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 patientApi: PatientApi
|
||||||
|
private lateinit var timer: Timer
|
||||||
|
|
||||||
|
|
||||||
|
val prefPatientConclusion = ConclusionPref()
|
||||||
|
val prefPatientClear = ClearPref()
|
||||||
|
val prefPatientSave = SavePref()
|
||||||
|
|
||||||
|
//Класс проверки интеренета
|
||||||
|
val enternetCheck = EnternetCheck()
|
||||||
|
|
||||||
|
var checkClose = false
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
binding = ActivityCode500Binding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
binding.apply {
|
||||||
|
|
||||||
|
val timer = object: CountDownTimer(30000, 1000) {
|
||||||
|
override fun onTick(millisUntilFinished: Long) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFinish() {
|
||||||
|
val intetn = Intent(this@Code500Activity, AuthorizationActivity::class.java)
|
||||||
|
finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
timer.start()
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressLint("SuspiciousIndentation")
|
||||||
|
fun CheckToken()=with(binding){
|
||||||
|
if (enternetCheck.isOnline(this@Code500Activity)) {
|
||||||
|
initRetrofit()
|
||||||
|
val Tokens = prefPatientConclusion.conclusionToken(this@Code500Activity)
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
val list = patientApi.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, AuthorizationActivity::class.java)
|
||||||
|
finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
val intetn = Intent(this@Code500Activity, 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()
|
||||||
|
|
||||||
|
patientApi = retrofit.create(PatientApi::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@Code500Activity.runOnUiThread {
|
||||||
|
CheckToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.example.rehabilitation.Enternet
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import android.os.Bundle
|
||||||
|
import com.example.rehabilitation.R
|
||||||
|
import com.example.rehabilitation.databinding.ActivityEnternetBinding
|
||||||
|
|
||||||
|
|
||||||
|
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.rehabilitation.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.rehabilitation.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.rehabilitation.MainActivity
|
||||||
|
import com.example.rehabilitation.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()
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
package com.example.rehabilitation.Feedback
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import com.example.rehabilitation.R
|
||||||
|
import com.example.rehabilitation.Setting.SettingFragment
|
||||||
|
import com.example.rehabilitation.databinding.FragmentFeedbackBinding
|
||||||
|
|
||||||
|
|
||||||
|
class FeedbackFragment : Fragment() {
|
||||||
|
private lateinit var binding: FragmentFeedbackBinding
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
binding = FragmentFeedbackBinding.inflate(layoutInflater,container,false)
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
if(isAdded()) {
|
||||||
|
//Выход
|
||||||
|
binding.btnExit.setOnClickListener {
|
||||||
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
|
?.replace(R.id.CLMain, SettingFragment.newInstance())
|
||||||
|
?.commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
//Переход по ссылке на сайт
|
||||||
|
binding.txtUrlVmeda.setOnClickListener {
|
||||||
|
val i = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.vmeda.org/"))
|
||||||
|
startActivity(i)
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// //Переход на почту
|
||||||
|
// binding.txtEmailDoctor.setOnClickListener{
|
||||||
|
// val intent = Intent(Intent.ACTION_SEND)
|
||||||
|
// intent.data = Uri.parse("mailto:")
|
||||||
|
// intent.type = "text/plain"
|
||||||
|
// intent.putExtra(Intent.EXTRA_EMAIL, arrayOf(binding.txtEmailDoctor.text.toString()))// herer adresses is already string
|
||||||
|
//
|
||||||
|
// try{
|
||||||
|
// startActivity(Intent.createChooser(intent,"Choose Email Client..."))
|
||||||
|
// }
|
||||||
|
// catch (e:Exception){
|
||||||
|
// Toast.makeText(this,e.message, Toast.LENGTH_LONG).show()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //Номер врача
|
||||||
|
// binding.txtNumberDoctor.setOnClickListener{
|
||||||
|
// val intent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + binding.txtNumberDoctor.text.toString()))
|
||||||
|
// startActivity(intent)
|
||||||
|
// }
|
||||||
|
|
||||||
|
//Номер регистратуры
|
||||||
|
binding.txtNumberRegister.setOnClickListener {
|
||||||
|
val intent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + "+78122923286"))
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
|
||||||
|
//Номер ДМС
|
||||||
|
binding.txtNumberDMS.setOnClickListener {
|
||||||
|
val intent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + "+78122923412"))
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
fun newInstance() = FeedbackFragment()
|
||||||
|
}
|
||||||
|
}
|
|
@ -137,7 +137,6 @@ var fileUri2: FileOutputStream? =null
|
||||||
//Переменная для хранения дня, чтобы при нажатие на главной тсранице или в календаре
|
//Переменная для хранения дня, чтобы при нажатие на главной тсранице или в календаре
|
||||||
var dateHomeCalendare:String = ""
|
var dateHomeCalendare:String = ""
|
||||||
|
|
||||||
//Календарь
|
|
||||||
var listCalendare:List<CalendareModel> = listOf()
|
|
||||||
class Hranilihe {
|
class Hranilihe {
|
||||||
}
|
}
|
|
@ -26,7 +26,7 @@ class CommonInfoFragment : Fragment() {
|
||||||
|
|
||||||
|
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InformationFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InformationFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ class MedicalReabilitationFragment : Fragment() {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InformationFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InformationFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod
|
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.transition.TransitionInflater
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.example.rehabilitation.R
|
import com.example.rehabilitation.R as R_P
|
||||||
|
import android.R
|
||||||
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment
|
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment
|
||||||
import com.example.rehabilitation.databinding.FragmentBreathingExercisesBinding
|
import com.example.rehabilitation.databinding.FragmentBreathingExercisesBinding
|
||||||
|
|
||||||
|
@ -23,16 +25,19 @@ class BreathingExercisesFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R_P.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
val inflater = TransitionInflater.from(requireContext())
|
||||||
binding.DecongestantTherapy.setOnClickListener {
|
binding.DecongestantTherapy.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
exitTransition = inflater.inflateTransition(R.transition.slide_top)
|
||||||
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R_P.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.DecongestantTherapyFragment.Companion.newInstance()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.DecongestantTherapyFragment.Companion.newInstance()
|
||||||
)?.addToBackStack(null)?.commit()
|
)?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//enterTransition = inflater.inflateTransition(R_P.transition.slide_bottom)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -24,12 +24,12 @@ class ContourPreventionFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnPhantomPains.setOnClickListener {
|
binding.btnPhantomPains.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.PhantomPainsFragment.Companion.newInstance()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.PhantomPainsFragment.Companion.newInstance()
|
||||||
)?.addToBackStack(null)?.commit()
|
)?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,12 +23,12 @@ class DecongestantTherapyFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnContracturesPrevention.setOnClickListener {
|
binding.btnContracturesPrevention.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.ContourPreventionFragment.Companion.newInstance()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.ContourPreventionFragment.Companion.newInstance()
|
||||||
)?.addToBackStack(null)?.commit()
|
)?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,11 @@ class FormationOfTheStumpFragment : Fragment() {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
binding.btnPhysicalExercises.setOnClickListener {
|
binding.btnPhysicalExercises.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.PhysicalExercisesFragment.Companion.newInstance()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.PhysicalExercisesFragment.Companion.newInstance()
|
||||||
)?.addToBackStack(null)?.commit()
|
)?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod
|
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.transition.TransitionInflater
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
@ -24,12 +25,13 @@ class MotorModeFragment : Fragment() {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
// val inflater = TransitionInflater.from(requireContext())
|
||||||
|
// exitTransition = inflater.inflateTransition(R.transition.slide_bottom)
|
||||||
binding.btnStumpCare.setOnClickListener {
|
binding.btnStumpCare.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.StumpCareFragment.Companion.newInstance()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.StumpCareFragment.Companion.newInstance()
|
||||||
)?.addToBackStack(null)?.commit()
|
)?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,11 @@ class OrganizationOfTheDailyRoutineAfterSurgeryFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
binding.btnOrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputation.setOnClickListener {
|
binding.btnOrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputation.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.OrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputationFragment.Companion.newInstance()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.OrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputationFragment.Companion.newInstance()
|
||||||
)?.addToBackStack(null)?.commit()
|
)?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ class OrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputationFragment : Fragmen
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,11 @@ class PhantomPainsFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
binding.btnSurfaceSensitivity.setOnClickListener {
|
binding.btnSurfaceSensitivity.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.SurfaceSensitivityFragment.Companion.newInstance()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.SurfaceSensitivityFragment.Companion.newInstance()
|
||||||
)?.addToBackStack(null)?.commit()
|
)?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,11 @@ class PhysicalExercisesFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
binding.btnOrganizationOfTheDailyRoutineAfterSurgery.setOnClickListener {
|
binding.btnOrganizationOfTheDailyRoutineAfterSurgery.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.OrganizationOfTheDailyRoutineAfterSurgeryFragment.Companion.newInstance()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.OrganizationOfTheDailyRoutineAfterSurgeryFragment.Companion.newInstance()
|
||||||
)?.addToBackStack(null)?.commit()
|
)?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,12 @@ class StumpCareFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnBreathingExercises.setOnClickListener {
|
binding.btnBreathingExercises.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.BreathingExercisesFragment.Companion.newInstance()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.BreathingExercisesFragment.Companion.newInstance()
|
||||||
)?.addToBackStack(null)?.commit()
|
)?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,11 +24,11 @@ class SurfaceSensitivityFragment : Fragment() {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
binding.btnFormationOfTheStump.setOnClickListener {
|
binding.btnFormationOfTheStump.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.FormationOfTheStumpFragment.Companion.newInstance()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.FormationOfTheStumpFragment.Companion.newInstance()
|
||||||
)?.addToBackStack(null)?.commit()
|
)?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,68 +35,68 @@ class EarlyPostoperativePeriodFragment : Fragment() {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
binding.btnMotorMode.setOnClickListener {
|
binding.btnMotorMode.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.MotorModeFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.MotorModeFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnStumpCare.setOnClickListener {
|
binding.btnStumpCare.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.StumpCareFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.StumpCareFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnBreathingExercises.setOnClickListener {
|
binding.btnBreathingExercises.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.BreathingExercisesFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.BreathingExercisesFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.DecongestantTherapy.setOnClickListener {
|
binding.DecongestantTherapy.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.DecongestantTherapyFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.DecongestantTherapyFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnContracturesPrevention.setOnClickListener {
|
binding.btnContracturesPrevention.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.ContourPreventionFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.ContourPreventionFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnPhantomPains.setOnClickListener {
|
binding.btnPhantomPains.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.PhantomPainsFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.PhantomPainsFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendationsFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendationsFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnFurther.setOnClickListener {
|
binding.btnFurther.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.Companion.newInstance()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.Companion.newInstance()
|
||||||
)?.addToBackStack(null)?.commit()
|
)?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnSurfaceSensitivity.setOnClickListener {
|
binding.btnSurfaceSensitivity.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.SurfaceSensitivityFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.SurfaceSensitivityFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnFormationOfTheStump.setOnClickListener {
|
binding.btnFormationOfTheStump.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.FormationOfTheStumpFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.FormationOfTheStumpFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnPhysicalExercises.setOnClickListener {
|
binding.btnPhysicalExercises.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.PhysicalExercisesFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.PhysicalExercisesFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnOrganizationOfTheDailyRoutineAfterSurgery.setOnClickListener {
|
binding.btnOrganizationOfTheDailyRoutineAfterSurgery.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.OrganizationOfTheDailyRoutineAfterSurgeryFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.OrganizationOfTheDailyRoutineAfterSurgeryFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnOrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputation.setOnClickListener {
|
binding.btnOrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputation.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.OrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputationFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.OrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputationFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,14 +24,15 @@ class DecongestantTherapyLateFragment : Fragment() {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(
|
activity?.supportFragmentManager?.beginTransaction()?.replace(
|
||||||
R.id.CLInformation,
|
R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
binding.btnMassageTechniqueLate.setOnClickListener {
|
binding.btnMassageTechniqueLate.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.MassageTechniqueLateFragment.Companion.newInstance()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.MassageTechniqueLateFragment.Companion.newInstance()
|
||||||
)?.addToBackStack(null)?.commit()
|
)?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -24,11 +24,11 @@ class MassageTechniqueLateFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
binding.btnPreventionOfContracturesLate.setOnClickListener {
|
binding.btnPreventionOfContracturesLate.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PreventionOfContracturesLateFragment.Companion.newInstance()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PreventionOfContracturesLateFragment.Companion.newInstance()
|
||||||
)?.addToBackStack(null)?.commit()
|
)?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ class PhantomPainsLateFragment : Fragment() {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(
|
activity?.supportFragmentManager?.beginTransaction()?.replace(
|
||||||
R.id.CLInformation,
|
R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,11 @@ class PreparationForProstheticsLateFragment : Fragment() {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(
|
activity?.supportFragmentManager?.beginTransaction()?.replace(
|
||||||
R.id.CLInformation,
|
R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
binding.btnDecongestantTherapyLate.setOnClickListener {
|
binding.btnDecongestantTherapyLate.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.DecongestantTherapyLateFragment.Companion.newInstance()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.DecongestantTherapyLateFragment.Companion.newInstance()
|
||||||
)?.addToBackStack(null)?.commit()
|
)?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,11 @@ class PreventionOfContracturesLateFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
binding.btnPhantomPainsLate.setOnClickListener {
|
binding.btnPhantomPainsLate.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PhantomPainsLateFragment.Companion.newInstance()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PhantomPainsLateFragment.Companion.newInstance()
|
||||||
)?.addToBackStack(null)?.commit()
|
)?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,28 +29,28 @@ class LatePostoperativePeriodFragment : Fragment() {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendationsFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendationsFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnPreparationForProstheticsLate.setOnClickListener {
|
binding.btnPreparationForProstheticsLate.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PreparationForProstheticsLateFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PreparationForProstheticsLateFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
binding.btnDecongestantTherapyLate.setOnClickListener {
|
binding.btnDecongestantTherapyLate.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.DecongestantTherapyLateFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.DecongestantTherapyLateFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
binding.btnMassageTechniqueLate.setOnClickListener {
|
binding.btnMassageTechniqueLate.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.MassageTechniqueLateFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.MassageTechniqueLateFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
binding.btnPreventionOfContracturesLate.setOnClickListener {
|
binding.btnPreventionOfContracturesLate.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PreventionOfContracturesLateFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PreventionOfContracturesLateFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
binding.btnPhantomPainsLate.setOnClickListener {
|
binding.btnPhantomPainsLate.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PhantomPainsLateFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PhantomPainsLateFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,17 +25,17 @@ class MethodologicalRecommendationsFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InformationFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InformationFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnEarlyPostoperativePeriod.setOnClickListener {
|
binding.btnEarlyPostoperativePeriod.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnLatePostoperativePeriod.setOnClickListener {
|
binding.btnLatePostoperativePeriod.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class faqFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.btnExit.setOnClickListener {
|
binding.btnExit.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformation,
|
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
|
||||||
com.example.rehabilitation.Information.InformationFragment.newInstance())?.addToBackStack(null)?.commit()
|
com.example.rehabilitation.Information.InformationFragment.newInstance())?.addToBackStack(null)?.commit()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
package com.example.rehabilitation.Information
|
|
||||||
|
|
||||||
import android.content.Intent
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import android.os.Bundle
|
|
||||||
import com.example.rehabilitation.MainActivity
|
|
||||||
import com.example.rehabilitation.R
|
|
||||||
import com.example.rehabilitation.databinding.ActivityInformationBinding
|
|
||||||
|
|
||||||
class InformationActivity : AppCompatActivity() {
|
|
||||||
var backPressedTime: Long = 0
|
|
||||||
private lateinit var binding: ActivityInformationBinding
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
binding = ActivityInformationBinding.inflate(layoutInflater)
|
|
||||||
setContentView(binding.root)
|
|
||||||
|
|
||||||
supportFragmentManager.beginTransaction()
|
|
||||||
.replace(R.id.CLInformation, InformationFragment.newInstance())
|
|
||||||
.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBackPressed() {
|
|
||||||
val intetn = Intent(this, MainActivity::class.java)
|
|
||||||
startActivity(intetn)
|
|
||||||
finish()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -7,6 +7,7 @@ import androidx.fragment.app.Fragment
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetCheck
|
||||||
import com.example.rehabilitation.MainActivity
|
import com.example.rehabilitation.MainActivity
|
||||||
import com.example.rehabilitation.R
|
import com.example.rehabilitation.R
|
||||||
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendationsFragment
|
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendationsFragment
|
||||||
|
@ -20,6 +21,9 @@ import com.example.rehabilitation.fragment.InfoFragment.faqFragment
|
||||||
|
|
||||||
class InformationFragment : Fragment() {
|
class InformationFragment : Fragment() {
|
||||||
private lateinit var binding: FragmentInformationBinding
|
private lateinit var binding: FragmentInformationBinding
|
||||||
|
|
||||||
|
//Класс проверки интеренета
|
||||||
|
val enternetCheck = EnternetCheck()
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
|
@ -36,41 +40,50 @@ class InformationFragment : Fragment() {
|
||||||
activity?.supportFragmentManager?.beginTransaction()
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
?.replace(R.id.CLMain, MainFragment.newInstance())
|
?.replace(R.id.CLMain, MainFragment.newInstance())
|
||||||
?.commit()
|
?.commit()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.methodologicalRecommendationsButton.setOnClickListener {
|
binding.methodologicalRecommendationsButton.setOnClickListener {
|
||||||
val infoFrag = activity?.supportFragmentManager?.beginTransaction()
|
// val infoFrag = activity?.supportFragmentManager?.beginTransaction()
|
||||||
infoFrag?.replace(
|
// infoFrag?.replace(
|
||||||
R.id.CLInformation,
|
// R.id.CLInformation,MethodologicalRecommendationsFragment.newInstance()
|
||||||
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendationsFragment.newInstance()
|
// )
|
||||||
)
|
// infoFrag?.addToBackStack(null)
|
||||||
infoFrag?.addToBackStack(null)
|
// infoFrag?.commit()
|
||||||
infoFrag?.commit()
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
|
?.replace(R.id.CLInformationMain, MethodologicalRecommendationsFragment.newInstance())
|
||||||
|
?.commit()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.commonInformationButton.setOnClickListener {
|
binding.commonInformationButton.setOnClickListener {
|
||||||
val infoFrag = activity?.supportFragmentManager?.beginTransaction()
|
// val infoFrag = activity?.supportFragmentManager?.beginTransaction()
|
||||||
infoFrag?.replace(R.id.CLInformation, CommonInfoFragment.newInstance())
|
// infoFrag?.replace(R.id.CLInformation, CommonInfoFragment.newInstance())
|
||||||
infoFrag?.addToBackStack(null)
|
// infoFrag?.addToBackStack(null)
|
||||||
infoFrag?.commit()
|
// infoFrag?.commit()
|
||||||
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
|
?.replace(R.id.CLInformationMain, CommonInfoFragment.newInstance())
|
||||||
|
?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.frequentlyAskedQuestionsButton.setOnClickListener {
|
binding.frequentlyAskedQuestionsButton.setOnClickListener {
|
||||||
val infoFrag = activity?.supportFragmentManager?.beginTransaction()
|
// val infoFrag = activity?.supportFragmentManager?.beginTransaction()
|
||||||
infoFrag?.replace(R.id.CLInformation, faqFragment.newInstance())
|
// infoFrag?.replace(R.id.CLInformation, faqFragment.newInstance())
|
||||||
infoFrag?.addToBackStack(null)
|
// infoFrag?.addToBackStack(null)
|
||||||
infoFrag?.commit()
|
// infoFrag?.commit()
|
||||||
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
|
?.replace(R.id.CLInformationMain, faqFragment.newInstance())
|
||||||
|
?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.medicalReabilitationButton.setOnClickListener {
|
binding.medicalReabilitationButton.setOnClickListener {
|
||||||
val infoFrag = activity?.supportFragmentManager?.beginTransaction()
|
// val infoFrag = activity?.supportFragmentManager?.beginTransaction()
|
||||||
infoFrag?.replace(R.id.CLInformation, MedicalReabilitationFragment.newInstance())
|
// infoFrag?.replace(R.id.CLInformation, MedicalReabilitationFragment.newInstance())
|
||||||
infoFrag?.addToBackStack(null)
|
// infoFrag?.addToBackStack(null)
|
||||||
infoFrag?.commit()
|
// infoFrag?.commit()
|
||||||
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
|
?.replace(R.id.CLInformationMain, MedicalReabilitationFragment.newInstance())
|
||||||
|
?.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.fondButton.setOnClickListener {
|
binding.fondButton.setOnClickListener {
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.example.rehabilitation.Information
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import com.example.rehabilitation.R
|
||||||
|
import com.example.rehabilitation.databinding.FragmentInformationMainBinding
|
||||||
|
|
||||||
|
|
||||||
|
class InformationMainFragment : Fragment() {
|
||||||
|
private lateinit var binding: FragmentInformationMainBinding
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
binding = FragmentInformationMainBinding.inflate(layoutInflater,container,false)
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
|
?.replace(R.id.CLInformationMain, InformationFragment.newInstance())
|
||||||
|
?.commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance() = InformationMainFragment()
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,14 +1,22 @@
|
||||||
package com.example.rehabilitation
|
package com.example.rehabilitation
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.appcompat.app.AlertDialog
|
import android.view.View
|
||||||
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.example.rehabilitation.Auth.AuthFragment
|
import com.example.rehabilitation.Auth.AuthFragment
|
||||||
|
import com.example.rehabilitation.Auth.AuthorizationActivity
|
||||||
|
import com.example.rehabilitation.CodeError.Code429Activity
|
||||||
|
import com.example.rehabilitation.CodeError.Code500Activity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetActivity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetCheck
|
||||||
import com.example.rehabilitation.Pref.ConclusionPref
|
import com.example.rehabilitation.Pref.ConclusionPref
|
||||||
import com.example.rehabilitation.Retrofit.PatientApi
|
import com.example.rehabilitation.Retrofit.PatientApi
|
||||||
import com.example.rehabilitation.databinding.ActivityMainBinding
|
import com.example.rehabilitation.databinding.ActivityMainBinding
|
||||||
|
import com.example.sqlitework.dip.MainViewModel
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
@ -21,12 +29,16 @@ import retrofit2.converter.gson.GsonConverterFactory
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: ActivityMainBinding
|
private lateinit var binding: ActivityMainBinding
|
||||||
private lateinit var patientApi: PatientApi
|
private lateinit var patientApi: PatientApi
|
||||||
|
private val modelPatient: PatientViewModel by viewModels()//Инициализировали класс
|
||||||
|
private val model: MainViewModel by viewModels()//Инициализировали класс
|
||||||
|
|
||||||
//Токен
|
//Токен
|
||||||
private var Token = ""
|
private var Token = ""
|
||||||
val prefPatientConclusion = ConclusionPref()
|
val prefPatientConclusion = ConclusionPref()
|
||||||
var backPressedTime: Long = 0
|
var backPressedTime: Long = 0
|
||||||
|
|
||||||
|
//Класс проверки интеренета
|
||||||
|
val enternetCheck = EnternetCheck()
|
||||||
|
|
||||||
@SuppressLint("DiscouragedApi")
|
@SuppressLint("DiscouragedApi")
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
@ -34,16 +46,13 @@ class MainActivity : AppCompatActivity() {
|
||||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
|
|
||||||
initRetrofit()
|
|
||||||
|
|
||||||
MainAndAuth()
|
MainAndAuth()
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
fun MainAndAuth() {
|
fun MainAndAuth() {
|
||||||
Token = prefPatientConclusion.conclusionToken(this)
|
Token = prefPatientConclusion.conclusionToken(this)
|
||||||
Log.i("sadasdsadsd",Token)
|
Log.i("sadasdsadsd", Token)
|
||||||
//CheckTokenAuth(Token)
|
//CheckTokenAuth(Token)
|
||||||
if (Token == "") {
|
if (Token == "") {
|
||||||
Auth()
|
Auth()
|
||||||
|
@ -53,6 +62,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Auth() {
|
fun Auth() {
|
||||||
|
binding.CLLoad.visibility = View.GONE
|
||||||
//Вывод фрагмента на активити при первоначальной загрузке
|
//Вывод фрагмента на активити при первоначальной загрузке
|
||||||
supportFragmentManager.beginTransaction()
|
supportFragmentManager.beginTransaction()
|
||||||
.replace(R.id.CLMain, AuthFragment.newInstance())
|
.replace(R.id.CLMain, AuthFragment.newInstance())
|
||||||
|
@ -61,26 +71,62 @@ class MainActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Main() {
|
fun Main() {
|
||||||
|
binding.CLLoad.visibility = View.GONE
|
||||||
fragment_inicializ()
|
fragment_inicializ()
|
||||||
|
|
||||||
|
// fixedRateTimer("timer", false, 0, 10000) {
|
||||||
|
// this@MainActivity.runOnUiThread {
|
||||||
|
// GetVisibleViewList()
|
||||||
|
// ProgressPatientCourses()
|
||||||
|
// APIliveCountCalendareCurrent()
|
||||||
|
// getNewAppeals()
|
||||||
|
// getOldAppeals()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SuspiciousIndentation")
|
@SuppressLint("SuspiciousIndentation")
|
||||||
private fun CheckTokenAuth(token: String) {
|
private fun CheckTokenAuth(token: String) {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
if (enternetCheck.isOnline(this)) {
|
||||||
val response = patientApi.CheckToken("Bearer $token")
|
initRetrofit()
|
||||||
runOnUiThread {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
val checkToken = response.body()
|
val response = patientApi.CheckToken("Bearer $token")
|
||||||
val user1 = response.code()
|
runOnUiThread {
|
||||||
val userCode = response.isSuccessful()
|
|
||||||
Log.i("12213213213", user1.toString())
|
|
||||||
|
|
||||||
if (userCode) {
|
//Фиксируем полученные данные
|
||||||
Main()
|
val List = response.body()
|
||||||
} else {
|
val Nice = response.isSuccessful
|
||||||
Auth()
|
val Code = response.code()
|
||||||
|
if(Code==429){
|
||||||
|
val intetn = Intent(this@MainActivity, Code429Activity::class.java)
|
||||||
|
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
else if(Code==200) {
|
||||||
|
//Если нету ошибок
|
||||||
|
if (Nice) {
|
||||||
|
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, AuthorizationActivity::class.java)
|
||||||
|
finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
val intetn = Intent(this, Code500Activity::class.java)
|
||||||
|
finish()
|
||||||
|
startActivity(intetn)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -97,7 +143,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val retrofit = Retrofit.Builder()
|
val retrofit = Retrofit.Builder()
|
||||||
.baseUrl("http://mobileapp.vmeda.org/api/")
|
.baseUrl("https://rehabilitation.vmeda.org/api/")
|
||||||
.client(client)
|
.client(client)
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
.build()
|
.build()
|
||||||
|
@ -132,6 +178,139 @@ class MainActivity : AppCompatActivity() {
|
||||||
// backPressedTime = System.currentTimeMillis()
|
// backPressedTime = System.currentTimeMillis()
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// //Получения экрана
|
||||||
|
// fun GetVisibleViewList() {
|
||||||
|
// if (enternetCheck.isOnline(this)) {
|
||||||
|
// initRetrofit()
|
||||||
|
// val Tokens = prefPatientConclusion.conclusionToken(this)
|
||||||
|
// CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
// val listProduct = patientApi.VisibleView3("Bearer $Tokens")
|
||||||
|
//
|
||||||
|
// runOnUiThread {
|
||||||
|
//
|
||||||
|
// //Фиксируем полученные данные
|
||||||
|
// val visibleviewList = listProduct.body()
|
||||||
|
// val visibleviewListCode = listProduct.isSuccessful()
|
||||||
|
// //Если нету ошибок
|
||||||
|
// if (visibleviewListCode) {
|
||||||
|
// modelPatient.viewCurrent.value = visibleviewList
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
//// val intetn = Intent(this, EnternetActivity::class.java)
|
||||||
|
//// finish()
|
||||||
|
//// startActivity(intetn)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //Вывод прогресса пациента
|
||||||
|
// fun ProgressPatientCourses() {
|
||||||
|
// if (enternetCheck.isOnline(this)) {
|
||||||
|
// initRetrofit()
|
||||||
|
// val Tokens = prefPatientConclusion.conclusionToken(this)
|
||||||
|
// CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
// val progress = patientApi.ProgressPatientCourses("Bearer $Tokens")
|
||||||
|
//
|
||||||
|
// runOnUiThread {
|
||||||
|
// //Фиксируем полученные данные
|
||||||
|
// val progressMes = progress.body()
|
||||||
|
// val progressMesCode = progress.isSuccessful()
|
||||||
|
// //Если нету ошибок
|
||||||
|
// if (progressMesCode) {
|
||||||
|
// model.liveProgressCheckList.value = progressMes?.search_check_sport
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
//// val intetn = Intent(this, EnternetActivity::class.java)
|
||||||
|
//// finish()
|
||||||
|
//// startActivity(intetn)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //Функция получения данных для заполнения календаря
|
||||||
|
// private fun APIliveCountCalendareCurrent() {
|
||||||
|
// if (enternetCheck.isOnline(this)) {
|
||||||
|
// val Tokens = prefPatientConclusion.conclusionToken(this)
|
||||||
|
// CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
// val Calendare = patientApi.GetCalendare("Bearer $Tokens")
|
||||||
|
//
|
||||||
|
// this@MainActivity?.runOnUiThread {
|
||||||
|
// //Фиксируем полученные данные
|
||||||
|
// val CalendareList = Calendare.body()
|
||||||
|
// //Если нету ошибок
|
||||||
|
// if (CalendareList != null) {
|
||||||
|
// modelPatient.calendareList.value = CalendareList.calendare_day
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// val intetn = Intent(this, EnternetActivity::class.java)
|
||||||
|
// finish()
|
||||||
|
// startActivity(intetn)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//ввыапваыапыва
|
||||||
|
// //Получение необработанных сообщений
|
||||||
|
// private fun getNewAppeals() {
|
||||||
|
// if (enternetCheck.isOnline(this)) {
|
||||||
|
// initRetrofit()
|
||||||
|
// val Tokens = prefPatientConclusion.conclusionToken(this)
|
||||||
|
// CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
// val listAppeals = patientApi.GetAppealsPatientNew("Bearer $Tokens")
|
||||||
|
// runOnUiThread {
|
||||||
|
//
|
||||||
|
// //Фиксируем полученные данные
|
||||||
|
// val AppealsMes = listAppeals.body()
|
||||||
|
//
|
||||||
|
// //Если нету ошибок
|
||||||
|
// if (AppealsMes != null) {
|
||||||
|
// if (AppealsMes.appeals_new != null) {
|
||||||
|
// modelPatient.appealsNewList.value = AppealsMes.appeals_new
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
//// val intetn = Intent(this, EnternetActivity::class.java)
|
||||||
|
//// finish()
|
||||||
|
//// startActivity(intetn)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //Получение обработанных сообщений
|
||||||
|
// private fun getOldAppeals() {
|
||||||
|
// if (enternetCheck.isOnline(this)) {
|
||||||
|
// initRetrofit()
|
||||||
|
// val Tokens = prefPatientConclusion.conclusionToken(this)
|
||||||
|
// CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
// val listAppeals = patientApi.GetAppealsPatientOld("Bearer $Tokens")
|
||||||
|
// runOnUiThread {
|
||||||
|
//
|
||||||
|
// //Фиксируем полученные данные
|
||||||
|
// val AppealsMes = listAppeals.body()
|
||||||
|
//
|
||||||
|
// //Если нету ошибок
|
||||||
|
// if (AppealsMes != null) {
|
||||||
|
// if (AppealsMes.appeals_old != null) {
|
||||||
|
// modelPatient.appealsOldList.value = AppealsMes.appeals_old
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
//// val intetn = Intent(this, EnternetActivity::class.java)
|
||||||
|
//// finish()
|
||||||
|
//// startActivity(intetn)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
|
@ -143,8 +322,4 @@ class MainActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,53 +1,101 @@
|
||||||
package com.example.rehabilitation
|
package com.example.rehabilitation
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Intent
|
||||||
import android.icu.text.SimpleDateFormat
|
import android.icu.text.SimpleDateFormat
|
||||||
import android.icu.util.Calendar
|
import android.icu.util.Calendar
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.SystemClock
|
||||||
|
import android.util.Log
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
import androidx.lifecycle.LifecycleOwner
|
import androidx.lifecycle.LifecycleOwner
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
|
import com.example.admin.Toast.showCustomInfoToast
|
||||||
|
import com.example.rehabilitation.Appeals.AppealsFragment
|
||||||
|
import com.example.rehabilitation.Auth.AuthorizationActivity
|
||||||
import com.example.rehabilitation.Calendare.CalendarFragment
|
import com.example.rehabilitation.Calendare.CalendarFragment
|
||||||
|
import com.example.rehabilitation.CodeError.Code429Activity
|
||||||
|
import com.example.rehabilitation.CodeError.Code500Activity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetActivity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetCheck
|
||||||
import com.example.rehabilitation.Information.InformationFragment
|
import com.example.rehabilitation.Information.InformationFragment
|
||||||
|
import com.example.rehabilitation.Information.InformationMainFragment
|
||||||
|
import com.example.rehabilitation.Pref.ConclusionPref
|
||||||
import com.example.rehabilitation.Progress.ProgresFragment
|
import com.example.rehabilitation.Progress.ProgresFragment
|
||||||
|
import com.example.rehabilitation.Retrofit.PatientApi
|
||||||
import com.example.rehabilitation.Setting.SettingFragment
|
import com.example.rehabilitation.Setting.SettingFragment
|
||||||
import com.example.rehabilitation.Sport.SceduleFragment
|
import com.example.rehabilitation.Sport.SceduleFragment
|
||||||
import com.example.rehabilitation.databinding.FragmentMainBinding
|
import com.example.rehabilitation.databinding.FragmentMainBinding
|
||||||
import com.example.rehabilitation.model_adapter.DataModel
|
import com.example.rehabilitation.model_adapter.DataModel
|
||||||
|
import com.example.sqlitework.dip.MainViewModel
|
||||||
|
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.Date
|
import java.util.Date
|
||||||
|
import java.util.Timer
|
||||||
|
import kotlin.concurrent.fixedRateTimer
|
||||||
|
|
||||||
|
|
||||||
class MainFragment : Fragment() {
|
class MainFragment : Fragment() {
|
||||||
private lateinit var binding: FragmentMainBinding
|
private lateinit var binding: FragmentMainBinding
|
||||||
|
|
||||||
private val dataModel: DataModel by viewModels()//Для передачи данных
|
private val dataModel: DataModel by viewModels()//Для передачи данных
|
||||||
|
private val model: MainViewModel by activityViewModels()//Инициализировали класс
|
||||||
|
private val modelPatient: PatientViewModel by activityViewModels()//Инициализировали класс
|
||||||
|
|
||||||
|
private lateinit var patientApi: PatientApi
|
||||||
|
private lateinit var timer: Timer
|
||||||
|
|
||||||
|
val prefPatientConclusion = ConclusionPref()
|
||||||
|
|
||||||
|
//Класс проверки интеренета
|
||||||
|
val enternetCheck = EnternetCheck()
|
||||||
|
|
||||||
@SuppressLint("SimpleDateFormat")
|
@SuppressLint("SimpleDateFormat")
|
||||||
var sdf: SimpleDateFormat = SimpleDateFormat("EEEE")
|
var sdf: SimpleDateFormat = SimpleDateFormat("EEEE")
|
||||||
var d: Date = Date()
|
var d: Date = Date()
|
||||||
var dayOfTheWeek: String = sdf.format(d)
|
var dayOfTheWeek: String = sdf.format(d)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
): View? {
|
||||||
binding = FragmentMainBinding.inflate(layoutInflater,container,false)
|
binding = FragmentMainBinding.inflate(layoutInflater, container, false)
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
if(isAdded) {
|
|
||||||
|
Log.d("5645546564","5645546564")
|
||||||
|
if (isAdded) {
|
||||||
main_inicializ()
|
main_inicializ()
|
||||||
|
//MainAndAuth()
|
||||||
}
|
}
|
||||||
|
dataModel.fragmentMenu.observe(viewLifecycleOwner, Observer {
|
||||||
|
binding.buttonNavigation.selectedItemId = it
|
||||||
|
})
|
||||||
|
|
||||||
|
// fixedRateTimer("timer", false, 0, 10000) {
|
||||||
|
// activity?.runOnUiThread {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun main_inicializ(){
|
fun main_inicializ() {
|
||||||
|
|
||||||
dataModel.fragmentMenu.observe(this as LifecycleOwner, {
|
dataModel.fragmentMenu.observe(this as LifecycleOwner, {
|
||||||
binding.buttonNavigation.selectedItemId = it
|
binding.buttonNavigation.selectedItemId = it
|
||||||
|
@ -65,7 +113,7 @@ class MainFragment : Fragment() {
|
||||||
|
|
||||||
binding.btnInformation.setOnClickListener {
|
binding.btnInformation.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
?.replace(R.id.CLMain, InformationFragment.newInstance())
|
?.replace(R.id.CLMain, InformationMainFragment.newInstance())
|
||||||
//?.addToBackStack(null)
|
//?.addToBackStack(null)
|
||||||
?.commit()
|
?.commit()
|
||||||
}
|
}
|
||||||
|
@ -75,8 +123,6 @@ class MainFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Инициализация фрагментов
|
//Инициализация фрагментов
|
||||||
fun fragment_inicializ() {
|
fun fragment_inicializ() {
|
||||||
//Вывод фрагмента на активити при первоначальной загрузке
|
//Вывод фрагмента на активити при первоначальной загрузке
|
||||||
|
@ -86,22 +132,59 @@ class MainFragment : Fragment() {
|
||||||
|
|
||||||
|
|
||||||
//Эран который будет выбран по умолчанию(кнопка которая будет прожата по умолчанию)
|
//Эран который будет выбран по умолчанию(кнопка которая будет прожата по умолчанию)
|
||||||
binding.buttonNavigation.selectedItemId = R.id.schedule//По умолчанию и так первая, но на всякий случай выберу еще програмным путем первую ячейку
|
binding.buttonNavigation.selectedItemId =
|
||||||
|
R.id.schedule//По умолчанию и так первая, но на всякий случай выберу еще програмным путем первую ячейку
|
||||||
|
|
||||||
//Нажатие на bottom navigation
|
//Нажатие на bottom navigation
|
||||||
binding.buttonNavigation.setOnItemSelectedListener {
|
binding.buttonNavigation.setOnItemSelectedListener {
|
||||||
|
|
||||||
when (it.itemId) {//it.itemId - это id нажатого элемента
|
when (it.itemId) {//it.itemId - это id нажатого элемента
|
||||||
R.id.schedule -> {
|
R.id.schedule -> {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.placeHolderFragment, SceduleFragment.newInstance())?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
|
if (!isClickRecently()) {
|
||||||
|
|
||||||
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
|
?.replace(R.id.placeHolderFragment, SceduleFragment.newInstance())
|
||||||
|
?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.calendar -> {
|
R.id.calendar -> {
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.placeHolderFragment, CalendarFragment.newInstance())?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
|
val view = prefPatientConclusion.conclusionView(requireContext())
|
||||||
|
Log.i("dasda2",view.toString())
|
||||||
|
if(view.toInt()==1 || view.toInt()==2){
|
||||||
|
Toast(requireContext()).showCustomInfoToast("У вас отсутсвует курс", requireActivity())
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Log.i("dasda22",view.toString())
|
||||||
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
|
?.replace(R.id.placeHolderFragment, CalendarFragment.newInstance())
|
||||||
|
?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.progress -> {//Если вы не авторизованный пользваотель то вам не будет доступен доступ к данном фрагменту
|
R.id.progress -> {//Если вы не авторизованный пользваотель то вам не будет доступен доступ к данном фрагменту
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.placeHolderFragment, ProgresFragment.newInstance())?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
|
val view = prefPatientConclusion.conclusionView(requireContext())
|
||||||
|
Log.i("dasda2",view.toString())
|
||||||
|
if(view.toInt()==1 || view.toInt()==2){
|
||||||
|
Toast(requireContext()).showCustomInfoToast("У вас отсутсвует курс", requireActivity())
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Log.i("dasda22",view.toString())
|
||||||
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
|
?.replace(R.id.placeHolderFragment, ProgresFragment.newInstance())
|
||||||
|
?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
R.id.chat -> {//Если вы не авторизованный пользваотель то вам не будет доступен доступ к данном фрагменту
|
||||||
|
if (!isClickRecently()) {
|
||||||
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
|
?.replace(R.id.placeHolderFragment, AppealsFragment.newInstance())
|
||||||
|
?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -120,49 +203,229 @@ class MainFragment : Fragment() {
|
||||||
var date_of_the_week = ""
|
var date_of_the_week = ""
|
||||||
|
|
||||||
when (Month) {
|
when (Month) {
|
||||||
1 -> month="Январь"
|
1 -> month = "Январь"
|
||||||
2 -> month="Февраль"
|
2 -> month = "Февраль"
|
||||||
3 -> month="Март"
|
3 -> month = "Март"
|
||||||
4 -> month="Апрель"
|
4 -> month = "Апрель"
|
||||||
5 -> month="Май"
|
5 -> month = "Май"
|
||||||
6 -> month="Июнь"
|
6 -> month = "Июнь"
|
||||||
7 -> month="Июль"
|
7 -> month = "Июль"
|
||||||
8 -> month="Август"
|
8 -> month = "Август"
|
||||||
9 -> month="Сентябрь"
|
9 -> month = "Сентябрь"
|
||||||
10 -> month="Октябрь"
|
10 -> month = "Октябрь"
|
||||||
11 -> month="Ноябрь"
|
11 -> month = "Ноябрь"
|
||||||
12 -> month="Декабрь"
|
12 -> month = "Декабрь"
|
||||||
else -> { // обратите внимание на блок
|
else -> { // обратите внимание на блок
|
||||||
month=""
|
month = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
when (dayOfTheWeek) {
|
when (dayOfTheWeek) {
|
||||||
"Monday" -> date_of_the_week="Пн"
|
"Monday" -> date_of_the_week = "Пн"
|
||||||
"Tuesday" -> date_of_the_week="Вт"
|
"Tuesday" -> date_of_the_week = "Вт"
|
||||||
"Wednesday" -> date_of_the_week="Ср"
|
"Wednesday" -> date_of_the_week = "Ср"
|
||||||
"Thursday" -> date_of_the_week="Чт"
|
"Thursday" -> date_of_the_week = "Чт"
|
||||||
"Friday" -> date_of_the_week="Пт"
|
"Friday" -> date_of_the_week = "Пт"
|
||||||
"Saturday" -> date_of_the_week="Сб"
|
"Saturday" -> date_of_the_week = "Сб"
|
||||||
"Sunday" -> 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="Чт"
|
"Четверг" -> 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 -> {
|
else -> {
|
||||||
date_of_the_week=""
|
date_of_the_week = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(calendar.get(Calendar.DATE))
|
System.out.println(calendar.get(Calendar.DATE))
|
||||||
binding.txtDate.setText("${day}" +" "+ "${month}")
|
binding.txtDate.setText("${day}" + " " + "${month}")
|
||||||
|
}
|
||||||
|
|
||||||
|
//Получения экрана
|
||||||
|
fun GetVisibleViewListTimer() {
|
||||||
|
if (enternetCheck.isOnline(requireContext())) {
|
||||||
|
initRetrofit()
|
||||||
|
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
val listProduct = patientApi.VisibleView3("Bearer $Tokens")
|
||||||
|
|
||||||
|
activity?.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) {
|
||||||
|
modelPatient.viewCurrent.value = List
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Следующий по счету
|
||||||
|
GetSportDay()
|
||||||
|
}
|
||||||
|
else if (Code == 500) {
|
||||||
|
val intetn = Intent(requireContext(), Code500Activity::class.java)
|
||||||
|
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val intetn = Intent(requireContext(), EnternetActivity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Получения списка упражнений
|
||||||
|
fun GetSportDay() {
|
||||||
|
|
||||||
|
if (enternetCheck.isOnline(requireContext())) {
|
||||||
|
initRetrofit()
|
||||||
|
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
val sportDay = patientApi.GetSportDay("Bearer $Tokens")
|
||||||
|
requireActivity().runOnUiThread {
|
||||||
|
|
||||||
|
//Фиксируем полученные данные
|
||||||
|
val List = sportDay.body()
|
||||||
|
val Nice = sportDay.isSuccessful
|
||||||
|
val Code = sportDay.code()
|
||||||
|
if(Code==429){
|
||||||
|
val intetn = Intent(requireContext(), Code429Activity::class.java)
|
||||||
|
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
else if(Code==200) {
|
||||||
|
//Если нету ошибок
|
||||||
|
if (Nice) {
|
||||||
|
//Если нету ошибок
|
||||||
|
if (List != null) {
|
||||||
|
model.liveDayList.value = List?.sport_for_day
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Code == 500) {
|
||||||
|
val intetn = Intent(requireContext(), Code500Activity::class.java)
|
||||||
|
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// else{
|
||||||
|
// Log.i("asdasdasdasd22222222","23231x2wswqxsxsas")
|
||||||
|
// Handler().postDelayed({
|
||||||
|
// GetSportDay()
|
||||||
|
// }, 5000)
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val intetn = Intent(requireContext(), EnternetActivity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// fun ProgressPatientCourses() {
|
||||||
|
// if (enternetCheck.isOnline(requireContext())) {
|
||||||
|
// initRetrofit()
|
||||||
|
// val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
||||||
|
// CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
// val progress = patientApi.ProgressPatientCourses("Bearer $Tokens")
|
||||||
|
//
|
||||||
|
// activity?.runOnUiThread {
|
||||||
|
//
|
||||||
|
// //Фиксируем полученные данные
|
||||||
|
// val progressMes = progress.body()
|
||||||
|
// val progressMesCode = progress.isSuccessful()
|
||||||
|
// //Если нету ошибок
|
||||||
|
// if (progressMesCode) {
|
||||||
|
// model.liveProgressCheckList.value = progressMes?.search_check_sport
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// val intetn = Intent(requireContext(), EnternetActivity::class.java)
|
||||||
|
// activity?.finish()
|
||||||
|
// startActivity(intetn)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//Инициализация подлючения к серверу
|
||||||
|
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()
|
||||||
|
|
||||||
|
patientApi = retrofit.create(PatientApi::class.java)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Задержка нажатия
|
||||||
|
var mLastClickTime = 0L
|
||||||
|
fun isClickRecently(): Boolean {
|
||||||
|
if (SystemClock.elapsedRealtime() - mLastClickTime < 500) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
mLastClickTime = SystemClock.elapsedRealtime()
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance() = MainFragment()
|
fun newInstance() = MainFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
checkForUpdates(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
timer.cancel()
|
||||||
|
timer.purge()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkForUpdates(daemonIsTrue: Boolean) {
|
||||||
|
|
||||||
|
timer = fixedRateTimer("default", daemonIsTrue, 0, 15000) {
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
GetVisibleViewListTimer()
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.example.rehabilitation.Message
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import com.example.rehabilitation.R as R_P
|
||||||
|
import android.R
|
||||||
|
import com.example.rehabilitation.databinding.FragmentMessageChatBinding
|
||||||
|
|
||||||
|
class MessageChatFragment : Fragment() {
|
||||||
|
private lateinit var binding:FragmentMessageChatBinding
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
binding = FragmentMessageChatBinding.inflate(layoutInflater,container,false)
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
fun newInstance() = MessageChatFragment()
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,141 +0,0 @@
|
||||||
package com.example.rehabilitation.Mysorka
|
|
||||||
|
|
||||||
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 androidx.fragment.app.activityViewModels
|
|
||||||
import androidx.lifecycle.asLiveData
|
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
|
||||||
import com.example.rehabilitation.R
|
|
||||||
import com.example.rehabilitation.databinding.FragmentHomeBinding
|
|
||||||
import com.example.rehabilitation.dateHomeCalendare
|
|
||||||
import com.example.rehabilitation.model_adapter.DataModel
|
|
||||||
import com.example.rehabilitation.Sport.DayAdapter
|
|
||||||
import com.example.rehabilitation.Sport.DayListModel
|
|
||||||
import com.example.rehabilitation.Sport.SportForDayModel
|
|
||||||
import com.example.rehabilitation.model_adapter.modelCount.CountDayModel
|
|
||||||
import com.example.sqlitework.dip.MainViewModel
|
|
||||||
import java.time.LocalDate
|
|
||||||
|
|
||||||
class HomeFragment : Fragment()/*, DayAdapter.Listener*/ {
|
|
||||||
private lateinit var binding: FragmentHomeBinding
|
|
||||||
// private val model: MainViewModel by activityViewModels()//Инициализировали класс
|
|
||||||
// lateinit var adapterDay: DayAdapter
|
|
||||||
// //private val dataModel: DataModel by activityViewModels()//Для передачи данных
|
|
||||||
// private val dataModel: DataModel by activityViewModels()//Для передачи данных
|
|
||||||
override fun onCreateView(
|
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
|
||||||
savedInstanceState: Bundle?
|
|
||||||
): View? {
|
|
||||||
binding = FragmentHomeBinding.inflate(layoutInflater,container,false)
|
|
||||||
return binding.root
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
// super.onViewCreated(view, savedInstanceState)
|
|
||||||
// initRcViewDay()
|
|
||||||
//
|
|
||||||
// model.liveDayList.observe(viewLifecycleOwner) {//viewLifecycleOwner - следит за циклом жизни fragment
|
|
||||||
// adapterDay.submitList(it)//Напрямую переадем созданный список в adapter(ProductAdapter)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// progresMonthAndDay()
|
|
||||||
// liveCountDayCurrent()
|
|
||||||
// addListModelCardsDay(LocalDate.now().toString())
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //Инициализация экрана уведобляющего о том что курса нету
|
|
||||||
// fun viewSportNo(){
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// //Заполнения модели и списка
|
|
||||||
// private fun addListModelCardsDay(day:String){
|
|
||||||
//
|
|
||||||
//// val db = MainDB.getDB(requireContext())
|
|
||||||
//// val list = ArrayList<DayListModel>()
|
|
||||||
//// db.getDaoDaySport().getAllItemDaySport(day).asLiveData().observe(requireActivity()){itList->
|
|
||||||
//// var number = 1;
|
|
||||||
////
|
|
||||||
//// itList.forEach{
|
|
||||||
//// Log.d("123",it.category)
|
|
||||||
//// //db.getDaoSportCategory().getAllItemsSportCategory(it.category).asLiveData().observe(requireActivity()){itSport->
|
|
||||||
//// val itemDay = DayListModel(
|
|
||||||
//// it.id.toString(),
|
|
||||||
//// number++.toString(),
|
|
||||||
//// day,
|
|
||||||
//// it.category.toString(),
|
|
||||||
//// it.check.toString(),
|
|
||||||
//// )
|
|
||||||
//// list.add(itemDay)//Передали заполненый список
|
|
||||||
//// model.liveDayList.value = list
|
|
||||||
//// //}
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// Log.d("sadas",list.toString())
|
|
||||||
//// }
|
|
||||||
// }
|
|
||||||
// private fun progresMonthAndDay() {
|
|
||||||
//// val db = MainDB.getDB(requireContext())
|
|
||||||
//// val data= LocalDate.now().toString()
|
|
||||||
////
|
|
||||||
//// var listDayDown =0
|
|
||||||
//// var listDayAll =0
|
|
||||||
//// var name = ""
|
|
||||||
//// //Прогрес за в течение данного дня
|
|
||||||
//// db.getDaoDaySport().getAllItemDaySport(LocalDate.now().toString()).asLiveData().observe(requireActivity()){itList->
|
|
||||||
//// var number = 1;
|
|
||||||
////
|
|
||||||
//// itList.forEach{
|
|
||||||
////
|
|
||||||
//// if(it.check ==1){
|
|
||||||
//// listDayDown=listDayDown+1
|
|
||||||
//// listDayAll=listDayAll+1
|
|
||||||
//// }
|
|
||||||
//// else{
|
|
||||||
//// listDayAll=listDayAll+1
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
//// val item = CountDayModel(
|
|
||||||
//// listDayDown,
|
|
||||||
//// listDayAll
|
|
||||||
//// )
|
|
||||||
//// model.liveCountDayCurrent.value = item
|
|
||||||
////
|
|
||||||
//// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //Вывод прогресса на один день
|
|
||||||
// private fun liveCountDayCurrent() = with(binding) {
|
|
||||||
// model.liveCountDayCurrent.observe(viewLifecycleOwner) {//viewLifecycleOwner - следит за циклом жизни fragment
|
|
||||||
// binding.txtSportToday.setText(it.countDown.toString())
|
|
||||||
// binding.txtSportTodayAll.setText(it.countAll.toString())
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// //Инициализация списка
|
|
||||||
// private fun initRcViewDay() = with(binding) {
|
|
||||||
// rcVIewDayList.layoutManager = GridLayoutManager(requireContext(),1)//По вертикали будет выводить по умолчанию
|
|
||||||
// adapterDay = DayAdapter(this@HomeFragment)
|
|
||||||
// rcVIewDayList.adapter = adapterDay
|
|
||||||
// }
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
fun newInstance() = HomeFragment()
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// override fun onClickDay(item: SportForDayModel) {
|
|
||||||
// //Передаем фрагмент на вывод(это фрагмент страницы с продукцией)
|
|
||||||
// //parentFragmentManager.beginTransaction() .replace(R.id.placeHolderFragment, SceduleFragment()).commit()
|
|
||||||
// dataModel.fragmentMenu.value = R.id.schedule
|
|
||||||
// // dateHomeCalendare = item.day
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -2,13 +2,36 @@ package com.example.rehabilitation
|
||||||
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
|
import com.example.rehabilitation.Appeals.TabLayout.Model.AppealsNewModel
|
||||||
|
import com.example.rehabilitation.Appeals.TabLayout.Model.AppealsOldModel
|
||||||
|
import com.example.rehabilitation.Calendare.CalendareModel
|
||||||
|
import com.example.rehabilitation.Questionnaire.Model.AfterLookModel
|
||||||
|
import com.example.rehabilitation.Questionnaire.Model.BeforeLookModel
|
||||||
import com.example.rehabilitation.Sport.SportDayOneModel
|
import com.example.rehabilitation.Sport.SportDayOneModel
|
||||||
|
import com.example.rehabilitation.Sport.ViewVisibleModel
|
||||||
|
|
||||||
class PatientViewModel: ViewModel() {
|
class PatientViewModel: ViewModel() {
|
||||||
val token = MutableLiveData<String>()
|
val token = MutableLiveData<String>()
|
||||||
|
|
||||||
|
|
||||||
val liveDaySportOne = MutableLiveData<SportDayOneModel>()
|
val liveDaySportOne = MutableLiveData<SportDayOneModel>()
|
||||||
// val productList = MutableLiveData<List<Product>>()
|
|
||||||
|
//Обращения необработанные
|
||||||
|
val appealsNewCurrent = MutableLiveData<AppealsNewModel>()
|
||||||
|
val appealsNewList= MutableLiveData<List<AppealsNewModel>>()
|
||||||
|
|
||||||
|
//Обращения обработанные
|
||||||
|
val appealsOldCurrent = MutableLiveData<AppealsOldModel>()
|
||||||
|
val appealsOldList= MutableLiveData<List<AppealsOldModel>>()
|
||||||
|
|
||||||
|
//Экраны
|
||||||
|
val viewCurrent = MutableLiveData<ViewVisibleModel>()
|
||||||
|
|
||||||
|
//Календарь
|
||||||
|
val calendareList = MutableLiveData<List<CalendareModel>>()
|
||||||
|
|
||||||
|
val afterLook = MutableLiveData<AfterLookModel>()
|
||||||
|
val beforeLook = MutableLiveData<BeforeLookModel>()
|
||||||
|
// val productList = MutableLiveData<List<Product>>()
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/Pref.iml" filepath="$PROJECT_DIR$/Pref.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/../../../../../../../.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -10,4 +10,10 @@ class ConclusionPref() {
|
||||||
val token = prefDoctor.getString("token", "")
|
val token = prefDoctor.getString("token", "")
|
||||||
return token.toString()
|
return token.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun conclusionView(context: Context):String {
|
||||||
|
val prefDoctor: SharedPreferences = context.getSharedPreferences("VIEW", Context.MODE_PRIVATE)
|
||||||
|
val view = prefDoctor.getString("view","")
|
||||||
|
return view.toString()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -11,4 +11,10 @@ class SavePref (){
|
||||||
prefPatient.edit().putString("token", token).apply()
|
prefPatient.edit().putString("token", token).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun saveView(context: Context,view: String) {
|
||||||
|
val prefPatient: SharedPreferences = context.getSharedPreferences("VIEW", Context.MODE_PRIVATE)
|
||||||
|
val edit = prefPatient.edit()
|
||||||
|
prefPatient.edit().putString("view", view).apply()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package com.example.rehabilitation.Progress
|
package com.example.rehabilitation.Progress
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
@ -10,20 +11,25 @@ import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import com.example.rehabilitation.Auth.AuthorizationActivity
|
||||||
|
import com.example.rehabilitation.CodeError.Code429Activity
|
||||||
|
import com.example.rehabilitation.CodeError.Code500Activity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetActivity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetCheck
|
||||||
import com.example.rehabilitation.Pref.ConclusionPref
|
import com.example.rehabilitation.Pref.ConclusionPref
|
||||||
|
import com.example.rehabilitation.R
|
||||||
import com.example.rehabilitation.Retrofit.PatientApi
|
import com.example.rehabilitation.Retrofit.PatientApi
|
||||||
|
import com.example.rehabilitation.Sport.SceduleFragment
|
||||||
import com.example.rehabilitation.databinding.FragmentProgresBinding
|
import com.example.rehabilitation.databinding.FragmentProgresBinding
|
||||||
import com.example.rehabilitation.listCalendare
|
|
||||||
import com.example.rehabilitation.listProgressCheck
|
|
||||||
import com.example.sqlitework.dip.MainViewModel
|
import com.example.sqlitework.dip.MainViewModel
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.logging.HttpLoggingInterceptor
|
import okhttp3.logging.HttpLoggingInterceptor
|
||||||
import org.json.JSONObject
|
|
||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
import retrofit2.converter.gson.GsonConverterFactory
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
|
import kotlin.concurrent.fixedRateTimer
|
||||||
|
|
||||||
class ProgresFragment : Fragment() {
|
class ProgresFragment : Fragment() {
|
||||||
private lateinit var binding: FragmentProgresBinding
|
private lateinit var binding: FragmentProgresBinding
|
||||||
|
@ -38,6 +44,10 @@ class ProgresFragment : Fragment() {
|
||||||
|
|
||||||
val prefPatientConclusion = ConclusionPref()
|
val prefPatientConclusion = ConclusionPref()
|
||||||
|
|
||||||
|
var progresList : List<ProgressModel>? = null
|
||||||
|
|
||||||
|
//Класс проверки интеренета
|
||||||
|
val enternetCheck = EnternetCheck()
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
|
@ -52,14 +62,37 @@ class ProgresFragment : Fragment() {
|
||||||
Token = prefToken?.getString("token", "")!!
|
Token = prefToken?.getString("token", "")!!
|
||||||
|
|
||||||
model.liveProgressCheckList.observe(viewLifecycleOwner) {//viewLifecycleOwner - следит за циклом жизни fragment
|
model.liveProgressCheckList.observe(viewLifecycleOwner) {//viewLifecycleOwner - следит за циклом жизни fragment
|
||||||
adapterProgress.submitList(it)//Напрямую переадем созданный список в adapter(ProductAdapter)
|
if(progresList != it){
|
||||||
visible1()
|
progresList = it
|
||||||
|
if(it.isEmpty()){
|
||||||
|
binding.txtLoadProgres.visibility = View.VISIBLE
|
||||||
|
visible1()
|
||||||
|
initRCView()
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
adapterProgress.submitList(it)//Напрямую переадем созданный список в adapter(ProductAdapter)
|
||||||
|
binding.txtLoadProgres.visibility = View.GONE
|
||||||
|
visible1()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
initRetrofit()
|
initRetrofit()
|
||||||
initRCView()
|
initRCView()
|
||||||
visibleLoad()
|
visibleLoad()
|
||||||
AddProgresSportDayList()
|
ProgressPatientCourses()
|
||||||
|
|
||||||
|
// fixedRateTimer("timer", false, 0, 10000) {
|
||||||
|
// activity?.runOnUiThread {
|
||||||
|
// ProgressPatientCourses()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
binding.button7.setOnClickListener {
|
||||||
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
|
?.replace(R.id.placeHolderFragment, SceduleFragment.newInstance())?.commit()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,7 +108,7 @@ class ProgresFragment : Fragment() {
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val retrofit = Retrofit.Builder()
|
val retrofit = Retrofit.Builder()
|
||||||
.baseUrl("http://mobileapp.vmeda.org/api/")
|
.baseUrl("https://rehabilitation.vmeda.org/api/")
|
||||||
.client(client)
|
.client(client)
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
.build()
|
.build()
|
||||||
|
@ -86,33 +119,60 @@ class ProgresFragment : Fragment() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Инициализация подлючения к серверу
|
//Вывод прогресса пациента
|
||||||
fun AddProgresSportDayList() {
|
fun ProgressPatientCourses() {
|
||||||
if (view_progress == false) {
|
if (enternetCheck.isOnline(requireContext())) {
|
||||||
view_progress = true
|
Log.i("sdasd2312","312ewqds")
|
||||||
visibleLoad()
|
if (view_progress == false) {
|
||||||
initRetrofit()
|
view_progress = true
|
||||||
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
visibleLoad()
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
initRetrofit()
|
||||||
val progress = patientApi.ProgressPatientCourses("Bearer $Tokens")
|
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
val progress = patientApi.ProgressPatientCourses("Bearer $Tokens")
|
||||||
|
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
|
//Фиксируем полученные данные
|
||||||
|
val List = progress.body()
|
||||||
|
val Nice = progress.isSuccessful
|
||||||
|
val Code = progress.code()
|
||||||
|
if(Code==429){
|
||||||
|
val intetn = Intent(requireContext(), Code429Activity::class.java)
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
else if(Code==200) {
|
||||||
|
//Если нету ошибок
|
||||||
|
if (Nice) {
|
||||||
|
//Если нету ошибок
|
||||||
|
if (List != null) {
|
||||||
|
model.liveProgressCheckList.value = List?.search_check_sport
|
||||||
|
binding.txtLoadProgres.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
binding.txtLoadProgres.visibility = View.VISIBLE
|
||||||
|
visible1()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Code == 500) {
|
||||||
|
val intetn = Intent(requireContext(), Code500Activity::class.java)
|
||||||
|
|
||||||
//Фиксируем полученные данные
|
startActivity(intetn)
|
||||||
val progressMes = progress.body()
|
}
|
||||||
val progressMesCode = progress.isSuccessful()
|
else if (Code == 401) {
|
||||||
//Если нету ошибок
|
val intetn = Intent(requireContext(), AuthorizationActivity::class.java)
|
||||||
if (progressMesCode) {
|
activity?.finish()
|
||||||
model.liveProgressCheckList.value = progressMes?.search_check_sport
|
startActivity(intetn)
|
||||||
binding.txtLoadProgres.visibility = View.GONE
|
}
|
||||||
}
|
|
||||||
else{
|
|
||||||
binding.txtLoadProgres.visibility = View.VISIBLE
|
|
||||||
visible1()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
val intetn = Intent(requireContext(), EnternetActivity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private fun initRCView() = with(binding) {
|
private fun initRCView() = with(binding) {
|
||||||
rcViewProgress.layoutManager = LinearLayoutManager(
|
rcViewProgress.layoutManager = LinearLayoutManager(
|
||||||
|
|
|
@ -29,8 +29,9 @@ class ProgressAdapter() : ListAdapter<ProgressModel, ProgressAdapter.Holder>(Com
|
||||||
@SuppressLint("SuspiciousIndentation", "SetTextI18n")
|
@SuppressLint("SuspiciousIndentation", "SetTextI18n")
|
||||||
fun bind(item: ProgressModel) = with(binding) {//Productitem - перпедаем данные
|
fun bind(item: ProgressModel) = with(binding) {//Productitem - перпедаем данные
|
||||||
itemTemp = item
|
itemTemp = item
|
||||||
txtDate.text = item.id.toString() + ". " + item.day + ": "
|
txtNumber.text = item.number.toString()+ ". "
|
||||||
txtProgress.text = item.count.toString() + "/" + item.count_workout_max.toString()
|
txtDate.text = item.day + " - " +item.count.toString() + "/" + item.count_workout_max.toString()
|
||||||
|
//txtProgress.text =
|
||||||
if (item.count_workout_max != item.count) {
|
if (item.count_workout_max != item.count) {
|
||||||
CardViewDay.setCardBackgroundColor(Color.parseColor("#1993FF"))
|
CardViewDay.setCardBackgroundColor(Color.parseColor("#1993FF"))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
package com.example.rehabilitation.Questionnaire.Model
|
||||||
|
|
||||||
|
data class AfterLookModel(
|
||||||
|
val after_look: Int,
|
||||||
|
)
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
package com.example.rehabilitation.Questionnaire.Model
|
||||||
|
|
||||||
|
data class BeforeLookModel(
|
||||||
|
val before_look: Int,
|
||||||
|
)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.example.rehabilitation.Questionnaire.QuestionnaireFragment
|
package com.example.rehabilitation.Questionnaire.QuestionnaireFragment
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
|
import android.content.Intent
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
@ -9,9 +11,15 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import com.example.admin.Toast.showCustomDangerToast
|
import androidx.fragment.app.activityViewModels
|
||||||
import com.example.admin.Toast.showCustomInfoToast
|
import com.example.admin.Toast.showCustomInfoToast
|
||||||
|
import com.example.rehabilitation.CodeError.Code429Activity
|
||||||
|
import com.example.rehabilitation.CodeError.Code500Activity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetActivity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetCheck
|
||||||
|
import com.example.rehabilitation.PatientViewModel
|
||||||
import com.example.rehabilitation.Pref.ConclusionPref
|
import com.example.rehabilitation.Pref.ConclusionPref
|
||||||
|
import com.example.rehabilitation.Questionnaire.Model.AfterLookModel
|
||||||
import com.example.rehabilitation.Questionnaire.Model.AfterQuestionnaireModel
|
import com.example.rehabilitation.Questionnaire.Model.AfterQuestionnaireModel
|
||||||
import com.example.rehabilitation.R
|
import com.example.rehabilitation.R
|
||||||
import com.example.rehabilitation.Retrofit.PatientApi
|
import com.example.rehabilitation.Retrofit.PatientApi
|
||||||
|
@ -22,21 +30,23 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.logging.HttpLoggingInterceptor
|
import okhttp3.logging.HttpLoggingInterceptor
|
||||||
import org.json.JSONObject
|
|
||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
import retrofit2.converter.gson.GsonConverterFactory
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
|
import java.util.Timer
|
||||||
import java.time.LocalDate
|
import kotlin.concurrent.fixedRateTimer
|
||||||
|
|
||||||
|
|
||||||
class QAfterFragment : Fragment() {
|
class QAfterFragment : Fragment() {
|
||||||
private lateinit var binding: FragmentQAfterBinding
|
private lateinit var binding: FragmentQAfterBinding
|
||||||
private lateinit var patientApi: PatientApi
|
private lateinit var patientApi: PatientApi
|
||||||
|
private lateinit var timer: Timer
|
||||||
|
|
||||||
val prefPatientConclusion = ConclusionPref()
|
val prefPatientConclusion = ConclusionPref()
|
||||||
|
private val modelPatient: PatientViewModel by activityViewModels()//Инициализировали класс
|
||||||
|
|
||||||
var one = 100
|
var one = 100
|
||||||
var two = 100
|
var two = 100
|
||||||
var thee = 100
|
var three = 100
|
||||||
var four =100
|
var four =100
|
||||||
var five =100
|
var five =100
|
||||||
var six =100
|
var six =100
|
||||||
|
@ -47,7 +57,10 @@ class QAfterFragment : Fragment() {
|
||||||
var eleven = 100
|
var eleven = 100
|
||||||
var twelve = 100
|
var twelve = 100
|
||||||
|
|
||||||
|
//Класс проверки интеренета
|
||||||
|
val enternetCheck = EnternetCheck()
|
||||||
|
|
||||||
|
var AfterLook: AfterLookModel? = null
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
|
@ -62,11 +75,30 @@ class QAfterFragment : Fragment() {
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
viewVisible()
|
||||||
|
if (isAdded()) {
|
||||||
|
LookAfter()
|
||||||
|
modelPatient.afterLook.observe(viewLifecycleOwner) {
|
||||||
|
if( AfterLook != it){
|
||||||
|
if(it.after_look == 1){
|
||||||
|
AfterLook = it
|
||||||
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
|
?.replace(R.id.placeHolderFragment, SceduleFragment.newInstance())?.commit()
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
AfterLook = it
|
||||||
|
After()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun After() {
|
||||||
|
viewMainAfter()
|
||||||
buttenAdd()
|
buttenAdd()
|
||||||
|
|
||||||
//Выход
|
//Выход
|
||||||
binding.btnBack.setOnClickListener {
|
binding.btnBack.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
|
@ -75,7 +107,7 @@ class QAfterFragment : Fragment() {
|
||||||
|
|
||||||
//Сохраняем результат
|
//Сохраняем результат
|
||||||
binding.btnSaveQuestionnaire.setOnClickListener {
|
binding.btnSaveQuestionnaire.setOnClickListener {
|
||||||
if (one != 100 && two != 100 && thee != 100 && four != 100 && five != 100 && six != 100 && seven != 100 && eight != 100 && nine != 100 && ten != 100 && eleven != 100 && twelve != 100) {
|
if (one != 100 && two != 100 && three != 100 && four != 100 && five != 100 && six != 100 && seven != 100 && eight != 100 && nine != 100 && ten != 100 && eleven != 100 && twelve != 100) {
|
||||||
|
|
||||||
if(nine == 1){
|
if(nine == 1){
|
||||||
AlertDialog.Builder(requireContext())
|
AlertDialog.Builder(requireContext())
|
||||||
|
@ -89,7 +121,7 @@ class QAfterFragment : Fragment() {
|
||||||
}
|
}
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
else if(one >=6 && thee == 0 && six == 1 && eight == 1 && eleven == 1){
|
else if(one >=6 && three == 0 && six == 1 && eight == 1 && eleven == 1){
|
||||||
AlertDialog.Builder(requireContext())
|
AlertDialog.Builder(requireContext())
|
||||||
.setTitle("Анкета")
|
.setTitle("Анкета")
|
||||||
.setMessage("Уверены ли Вы в выбранных ответах на вопросы анкеты? Халатное отношение к вопросам анкеты приведет к паузе комплекса")
|
.setMessage("Уверены ли Вы в выбранных ответах на вопросы анкеты? Халатное отношение к вопросам анкеты приведет к паузе комплекса")
|
||||||
|
@ -111,6 +143,55 @@ class QAfterFragment : Fragment() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// fixedRateTimer("timer", false, 0, 10000) {
|
||||||
|
// activity?.runOnUiThread {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
//Проверка анкеты ПОСЛЕ
|
||||||
|
fun LookAfter() {
|
||||||
|
if (enternetCheck.isOnline(requireActivity())) {
|
||||||
|
initRetrofit()
|
||||||
|
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
val listAfter = patientApi.LookAfter("Bearer $Tokens")
|
||||||
|
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
|
||||||
|
//Фиксируем полученные данные
|
||||||
|
val List = listAfter.body()
|
||||||
|
val Nice = listAfter.isSuccessful
|
||||||
|
val Code = listAfter.code()
|
||||||
|
if(Code==429){
|
||||||
|
val intetn = Intent(requireContext(), Code429Activity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
else if(Code==200) {
|
||||||
|
//Если нету ошибок
|
||||||
|
if (Nice) {
|
||||||
|
//Если нету ошибок
|
||||||
|
if (List != null) {
|
||||||
|
modelPatient.afterLook.value = List
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Code == 500) {
|
||||||
|
val intetn = Intent(requireContext(), Code500Activity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val intetn = Intent(requireContext(), EnternetActivity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addQuestionAfter() {
|
fun addQuestionAfter() {
|
||||||
|
@ -118,7 +199,7 @@ class QAfterFragment : Fragment() {
|
||||||
val item = AfterQuestionnaireModel(
|
val item = AfterQuestionnaireModel(
|
||||||
one,
|
one,
|
||||||
two,
|
two,
|
||||||
thee,
|
three,
|
||||||
four,
|
four,
|
||||||
five,
|
five,
|
||||||
six,
|
six,
|
||||||
|
@ -144,7 +225,7 @@ class QAfterFragment : Fragment() {
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val retrofit = Retrofit.Builder()
|
val retrofit = Retrofit.Builder()
|
||||||
.baseUrl("http://mobileapp.vmeda.org/api/")
|
.baseUrl("https://rehabilitation.vmeda.org/api/")
|
||||||
.client(client)
|
.client(client)
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
.build()
|
.build()
|
||||||
|
@ -153,35 +234,67 @@ class QAfterFragment : Fragment() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Получения списка пациентов
|
//Отправка анкеты ПОСЛЕ
|
||||||
fun AfterQuestionnaire(item:AfterQuestionnaireModel) {
|
fun AfterQuestionnaire(item:AfterQuestionnaireModel) {
|
||||||
initRetrofit()
|
if (enternetCheck.isOnline(requireContext())) {
|
||||||
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
initRetrofit()
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
||||||
val QA = patientApi.AddAfterQuestionnaire2("Bearer $Tokens",item)
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
requireActivity().runOnUiThread {
|
val QA = patientApi.AddAfterQuestionnaire2("Bearer $Tokens",item)
|
||||||
|
requireActivity().runOnUiThread {
|
||||||
|
|
||||||
//Фиксируем полученные данные
|
|
||||||
val AQList = QA.body()
|
|
||||||
|
|
||||||
//Если нету ошибок
|
|
||||||
if (AQList != null) {
|
//Фиксируем полученные данные
|
||||||
Toast(requireContext()).showCustomInfoToast(AQList.message, requireActivity())
|
val List = QA.body()
|
||||||
}
|
val Nice = QA.isSuccessful
|
||||||
else{
|
val Code = QA.code()
|
||||||
if (AQList != null) {
|
if(Code==429){
|
||||||
Toast(requireContext()).showCustomInfoToast(AQList.message, requireActivity())
|
val intetn = Intent(requireContext(), Code429Activity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
}
|
}
|
||||||
|
else if(Code==200) {
|
||||||
|
//Если нету ошибок
|
||||||
|
if (Nice) {
|
||||||
|
//Если нету ошибок
|
||||||
|
if (List != null) {
|
||||||
|
Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
|
||||||
|
viewVisible()
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if (List != null) {
|
||||||
|
Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Code == 500) {
|
||||||
|
val intetn = Intent(requireContext(), Code500Activity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
activity?.supportFragmentManager?.beginTransaction()
|
|
||||||
?.replace(R.id.placeHolderFragment, SceduleFragment.newInstance())?.commit()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val intetn = Intent(requireContext(), EnternetActivity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun viewMainAfter(){
|
||||||
|
binding.CLLoad.visibility = View.GONE
|
||||||
|
binding.CLMainAfter.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
|
fun viewVisible(){
|
||||||
|
binding.CLLoad.visibility = View.VISIBLE
|
||||||
|
binding.CLMainAfter.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
private fun buttenAdd() {
|
private fun buttenAdd() {
|
||||||
buttenAdd1()
|
buttenAdd1()
|
||||||
|
@ -370,12 +483,12 @@ class QAfterFragment : Fragment() {
|
||||||
Log.d("CVQyes3", "CVQyes3")
|
Log.d("CVQyes3", "CVQyes3")
|
||||||
binding.CVQyes3.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
|
binding.CVQyes3.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
|
||||||
binding.CVQno3.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
|
binding.CVQno3.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
|
||||||
thee = 1
|
three = 1
|
||||||
}
|
}
|
||||||
binding.CVQno3.setOnClickListener {
|
binding.CVQno3.setOnClickListener {
|
||||||
binding.CVQyes3.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
|
binding.CVQyes3.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
|
||||||
binding.CVQno3.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
|
binding.CVQno3.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
|
||||||
thee = 0
|
three = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,6 +610,27 @@ class QAfterFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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, 15000) {
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
LookAfter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// fun QBSaveDataA(date: String) {
|
// fun QBSaveDataA(date: String) {
|
||||||
// val QB = questionnaire?.edit()
|
// val QB = questionnaire?.edit()
|
||||||
// QB?.putString("QA", date)
|
// QB?.putString("QA", date)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.example.rehabilitation.Questionnaire.QuestionnaireFragment
|
package com.example.rehabilitation.Questionnaire.QuestionnaireFragment
|
||||||
|
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
|
import android.content.Intent
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
@ -9,10 +10,15 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import com.example.admin.Toast.showCustomDangerToast
|
|
||||||
import com.example.admin.Toast.showCustomInfoToast
|
import com.example.admin.Toast.showCustomInfoToast
|
||||||
|
import com.example.rehabilitation.CodeError.Code429Activity
|
||||||
|
import com.example.rehabilitation.CodeError.Code500Activity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetActivity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetCheck
|
||||||
|
import com.example.rehabilitation.PatientViewModel
|
||||||
import com.example.rehabilitation.Pref.ConclusionPref
|
import com.example.rehabilitation.Pref.ConclusionPref
|
||||||
import com.example.rehabilitation.Questionnaire.Model.AfterQuestionnaireModel
|
import com.example.rehabilitation.Questionnaire.Model.AfterLookModel
|
||||||
|
import com.example.rehabilitation.Questionnaire.Model.BeforeLookModel
|
||||||
import com.example.rehabilitation.Questionnaire.Model.BeforeQuestionnaireModel
|
import com.example.rehabilitation.Questionnaire.Model.BeforeQuestionnaireModel
|
||||||
import com.example.rehabilitation.R
|
import com.example.rehabilitation.R
|
||||||
import com.example.rehabilitation.Retrofit.PatientApi
|
import com.example.rehabilitation.Retrofit.PatientApi
|
||||||
|
@ -24,20 +30,25 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.logging.HttpLoggingInterceptor
|
import okhttp3.logging.HttpLoggingInterceptor
|
||||||
import org.json.JSONObject
|
|
||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
import retrofit2.converter.gson.GsonConverterFactory
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
|
import java.util.Timer
|
||||||
|
import kotlin.concurrent.fixedRateTimer
|
||||||
|
|
||||||
|
|
||||||
class QBeforeFragment : Fragment() {
|
class QBeforeFragment : Fragment() {
|
||||||
private lateinit var binding: FragmentQBeforeBinding
|
private lateinit var binding: FragmentQBeforeBinding
|
||||||
private val model: MainViewModel by activityViewModels()//Инициализировали класс
|
private val model: MainViewModel by activityViewModels()//Инициализировали класс
|
||||||
|
private val modelPatient: PatientViewModel by activityViewModels()//Инициализировали класс
|
||||||
|
|
||||||
private lateinit var patientApi: PatientApi
|
private lateinit var patientApi: PatientApi
|
||||||
|
private lateinit var timer: Timer
|
||||||
|
|
||||||
val prefPatientConclusion = ConclusionPref()
|
val prefPatientConclusion = ConclusionPref()
|
||||||
|
|
||||||
var one = 100
|
var one = 100
|
||||||
var two = 100
|
var two = 100
|
||||||
var thee = 100
|
var three = 100
|
||||||
var four = 100
|
var four = 100
|
||||||
var five = 100
|
var five = 100
|
||||||
var six = 100
|
var six = 100
|
||||||
|
@ -52,6 +63,11 @@ class QBeforeFragment : Fragment() {
|
||||||
//Для разрешения проверки количества дней
|
//Для разрешения проверки количества дней
|
||||||
var lookDateSportMax = false
|
var lookDateSportMax = false
|
||||||
|
|
||||||
|
//Класс проверки интеренета
|
||||||
|
val enternetCheck = EnternetCheck()
|
||||||
|
|
||||||
|
var BeforeLook: BeforeLookModel? = null
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
|
@ -68,9 +84,26 @@ class QBeforeFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
|
||||||
buttenAdd()
|
buttenAdd()
|
||||||
|
if (isAdded()) {
|
||||||
|
LookBefore()
|
||||||
|
modelPatient.beforeLook.observe(viewLifecycleOwner) {
|
||||||
|
if( BeforeLook != it){
|
||||||
|
if(it.before_look == 1){
|
||||||
|
BeforeLook = it
|
||||||
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
|
?.replace(R.id.placeHolderFragment, SceduleFragment.newInstance())?.commit()
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
BeforeLook = it
|
||||||
|
Before()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Before() {
|
||||||
//Выход
|
//Выход
|
||||||
binding.btnExitQB.setOnClickListener {
|
binding.btnExitQB.setOnClickListener {
|
||||||
activity?.supportFragmentManager?.beginTransaction()
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
|
@ -80,7 +113,7 @@ class QBeforeFragment : Fragment() {
|
||||||
//Сохраняем результат
|
//Сохраняем результат
|
||||||
binding.btnSaveQuestionnaire.setOnClickListener {
|
binding.btnSaveQuestionnaire.setOnClickListener {
|
||||||
|
|
||||||
if (one != 100 && two != 100 && thee != 100 && four != 100 && five != 100 && six != 100 && seven != 100 && eight != 100 && nine != 100) {
|
if (one != 100 && two != 100 && three != 100 && four != 100 && five != 100 && six != 100 && seven != 100 && eight != 100 && nine != 100) {
|
||||||
if(one >= 6) {
|
if(one >= 6) {
|
||||||
AlertDialog.Builder(requireContext())
|
AlertDialog.Builder(requireContext())
|
||||||
.setTitle("Анкета")
|
.setTitle("Анкета")
|
||||||
|
@ -112,6 +145,12 @@ class QBeforeFragment : Fragment() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fixedRateTimer("timer", false, 0, 10000) {
|
||||||
|
// activity?.runOnUiThread {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
//Функция
|
//Функция
|
||||||
|
@ -119,7 +158,7 @@ class QBeforeFragment : Fragment() {
|
||||||
val item = BeforeQuestionnaireModel(
|
val item = BeforeQuestionnaireModel(
|
||||||
one,
|
one,
|
||||||
two,
|
two,
|
||||||
thee,
|
three,
|
||||||
four,
|
four,
|
||||||
five,
|
five,
|
||||||
six,
|
six,
|
||||||
|
@ -142,7 +181,7 @@ class QBeforeFragment : Fragment() {
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val retrofit = Retrofit.Builder()
|
val retrofit = Retrofit.Builder()
|
||||||
.baseUrl("http://mobileapp.vmeda.org/api/")
|
.baseUrl("https://rehabilitation.vmeda.org/api/")
|
||||||
.client(client)
|
.client(client)
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
.build()
|
.build()
|
||||||
|
@ -151,32 +190,102 @@ class QBeforeFragment : Fragment() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Получения списка пациентов
|
//Отправка запроса
|
||||||
fun BeforeQuestionnaire(item: BeforeQuestionnaireModel) {
|
fun BeforeQuestionnaire(item: BeforeQuestionnaireModel) {
|
||||||
initRetrofit()
|
if (enternetCheck.isOnline(requireContext())) {
|
||||||
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
initRetrofit()
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
||||||
val QA = patientApi.AddBeforeQuestionnaire2("Bearer $Tokens",item)
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
requireActivity().runOnUiThread {
|
val QA = patientApi.AddBeforeQuestionnaire2("Bearer $Tokens",item)
|
||||||
|
requireActivity().runOnUiThread {
|
||||||
|
|
||||||
//Фиксируем полученные данные
|
|
||||||
val AQList = QA.body()
|
|
||||||
|
|
||||||
//Если нету ошибок
|
|
||||||
if (AQList != null) {
|
//Фиксируем полученные данные
|
||||||
Toast(requireContext()).showCustomInfoToast(AQList.message, requireActivity())
|
val List = QA.body()
|
||||||
}
|
val Nice = QA.isSuccessful
|
||||||
else{
|
val Code = QA.code()
|
||||||
Toast(requireContext()).showCustomInfoToast("Ошибка при отправке", requireActivity())
|
if(Code==429){
|
||||||
|
val intetn = Intent(requireContext(), Code429Activity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
else if(Code==200) {
|
||||||
|
//Если нету ошибок
|
||||||
|
if (Nice) {
|
||||||
|
//Если нету ошибок
|
||||||
|
if (List != null) {
|
||||||
|
Toast(requireContext()).showCustomInfoToast(List.message, requireActivity())
|
||||||
|
activity?.supportFragmentManager?.beginTransaction()
|
||||||
|
?.replace(R.id.placeHolderFragment, SceduleFragment.newInstance())?.commit()
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Toast(requireContext()).showCustomInfoToast("Ошибка при отправке", requireActivity())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Code == 500) {
|
||||||
|
val intetn = Intent(requireContext(), Code500Activity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
activity?.supportFragmentManager?.beginTransaction()
|
|
||||||
?.replace(R.id.placeHolderFragment, SceduleFragment.newInstance())?.commit()
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
val intetn = Intent(requireContext(), EnternetActivity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Проверка анкеты ПОСЛЕ
|
||||||
|
fun LookBefore() {
|
||||||
|
if (enternetCheck.isOnline(requireActivity())) {
|
||||||
|
initRetrofit()
|
||||||
|
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
val listBefore = patientApi.LookBefore("Bearer $Tokens")
|
||||||
|
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
|
||||||
|
//Фиксируем полученные данные
|
||||||
|
val List = listBefore.body()
|
||||||
|
val Nice = listBefore.isSuccessful
|
||||||
|
val Code = listBefore.code()
|
||||||
|
if(Code==429){
|
||||||
|
val intetn = Intent(requireContext(), Code429Activity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
else if(Code==200) {
|
||||||
|
//Если нету ошибок
|
||||||
|
if (Nice) {
|
||||||
|
//Если нету ошибок
|
||||||
|
if (List != null) {
|
||||||
|
modelPatient.beforeLook.value = List
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Code == 500) {
|
||||||
|
val intetn = Intent(requireContext(), Code500Activity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val intetn = Intent(requireContext(), EnternetActivity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private fun buttenAdd() {
|
private fun buttenAdd() {
|
||||||
buttenAdd1()
|
buttenAdd1()
|
||||||
|
@ -192,6 +301,16 @@ class QBeforeFragment : Fragment() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun viewMainBefore(){
|
||||||
|
binding.CLLoad.visibility = View.GONE
|
||||||
|
binding.CLMainBefore.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
|
fun viewVisible(){
|
||||||
|
binding.CLLoad.visibility = View.VISIBLE
|
||||||
|
binding.CLMainBefore.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun buttenAdd1() {
|
private fun buttenAdd1() {
|
||||||
binding.CVQyes1.setOnClickListener {
|
binding.CVQyes1.setOnClickListener {
|
||||||
|
@ -380,12 +499,12 @@ class QBeforeFragment : Fragment() {
|
||||||
binding.CVQyes3.setOnClickListener {
|
binding.CVQyes3.setOnClickListener {
|
||||||
binding.CVQyes3.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
|
binding.CVQyes3.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
|
||||||
binding.CVQno3.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
|
binding.CVQno3.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
|
||||||
thee = 1
|
three = 1
|
||||||
}
|
}
|
||||||
binding.CVQno3.setOnClickListener {
|
binding.CVQno3.setOnClickListener {
|
||||||
binding.CVQyes3.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
|
binding.CVQyes3.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
|
||||||
binding.CVQno3.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
|
binding.CVQno3.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
|
||||||
thee = 0
|
three = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,4 +587,26 @@ class QBeforeFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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, 15000) {
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
LookBefore()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,14 +1,19 @@
|
||||||
package com.example.rehabilitation.Retrofit
|
package com.example.rehabilitation.Retrofit
|
||||||
|
|
||||||
|
import com.example.rehabilitation.Appeals.TabLayout.Model.AppealsNewListModel
|
||||||
|
import com.example.rehabilitation.Appeals.TabLayout.Model.AppealsOldListModel
|
||||||
import com.example.rehabilitation.Auth.Model.AuthModel
|
import com.example.rehabilitation.Auth.Model.AuthModel
|
||||||
import com.example.rehabilitation.Auth.Model.CheckTokenModel
|
import com.example.rehabilitation.Auth.Model.CheckTokenModel
|
||||||
import com.example.rehabilitation.Auth.Model.UserModel
|
import com.example.rehabilitation.Auth.Model.UserModel
|
||||||
import com.example.rehabilitation.Calendare.CalendareListModel
|
import com.example.rehabilitation.Calendare.CalendareListModel
|
||||||
|
import com.example.rehabilitation.Calendare.CalendareModel
|
||||||
import com.example.rehabilitation.MessageModel
|
import com.example.rehabilitation.MessageModel
|
||||||
import com.example.rehabilitation.Progress.ProgressListModel
|
import com.example.rehabilitation.Progress.ProgressListModel
|
||||||
import com.example.rehabilitation.Progress.ProgressModel
|
import com.example.rehabilitation.Progress.ProgressModel
|
||||||
|
import com.example.rehabilitation.Questionnaire.Model.AfterLookModel
|
||||||
import com.example.rehabilitation.Questionnaire.Model.AfterQuestionnaireMessage
|
import com.example.rehabilitation.Questionnaire.Model.AfterQuestionnaireMessage
|
||||||
import com.example.rehabilitation.Questionnaire.Model.AfterQuestionnaireModel
|
import com.example.rehabilitation.Questionnaire.Model.AfterQuestionnaireModel
|
||||||
|
import com.example.rehabilitation.Questionnaire.Model.BeforeLookModel
|
||||||
import com.example.rehabilitation.Questionnaire.Model.BeforeQuestionnaireMessage
|
import com.example.rehabilitation.Questionnaire.Model.BeforeQuestionnaireMessage
|
||||||
import com.example.rehabilitation.Questionnaire.Model.BeforeQuestionnaireModel
|
import com.example.rehabilitation.Questionnaire.Model.BeforeQuestionnaireModel
|
||||||
import com.example.rehabilitation.Questionnaire.Model.QuestionnaireModel
|
import com.example.rehabilitation.Questionnaire.Model.QuestionnaireModel
|
||||||
|
@ -35,7 +40,7 @@ interface PatientApi {
|
||||||
//Проверка токена
|
//Проверка токена
|
||||||
@Headers("Content-Type: application/json")
|
@Headers("Content-Type: application/json")
|
||||||
@GET("CheckTokenPatient")
|
@GET("CheckTokenPatient")
|
||||||
suspend fun CheckToken(@Header("Authorization") token:String): Response<CheckTokenModel>
|
suspend fun CheckToken(@Header("Authorization") token:String) :Response<CheckTokenModel>
|
||||||
|
|
||||||
//Авторизация
|
//Авторизация
|
||||||
@Headers("Content-Type: application/json")
|
@Headers("Content-Type: application/json")
|
||||||
|
@ -96,4 +101,78 @@ interface PatientApi {
|
||||||
@Headers("Content-Type: application/json")
|
@Headers("Content-Type: application/json")
|
||||||
@GET("ProgressPatientCourses")
|
@GET("ProgressPatientCourses")
|
||||||
suspend fun ProgressPatientCourses(@Header("Authorization") token:String):Response<ProgressListModel>
|
suspend fun ProgressPatientCourses(@Header("Authorization") token:String):Response<ProgressListModel>
|
||||||
}
|
|
||||||
|
//Вывод необработанных сообщений
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@GET("GetAppealsPatientNew")
|
||||||
|
suspend fun GetAppealsPatientNew(@Header("Authorization") token:String) :Response<AppealsNewListModel>
|
||||||
|
|
||||||
|
//Вывод необработанных сообщений
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@GET("GetAppealsPatientOld")
|
||||||
|
suspend fun GetAppealsPatientOld(@Header("Authorization") token:String) :Response<AppealsOldListModel>
|
||||||
|
|
||||||
|
|
||||||
|
//Подтверждение необработанных сообщений
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@PUT("UpdateMessagePatient")
|
||||||
|
suspend fun UpdateMessagePatient(@Header("Authorization") token:String,@Query("id") id:Int) :Response<MessageModel>
|
||||||
|
|
||||||
|
//Отправка сообщения пациенту
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@POST("AddMessagePatient")
|
||||||
|
suspend fun AddMessagePatient(@Header("Authorization") token:String, @Query("text") text:String) :Response<MessageModel>
|
||||||
|
|
||||||
|
//Вывод есть ли анкета ДО
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@GET("LookBefore")
|
||||||
|
suspend fun LookBefore(@Header("Authorization") token:String) :Response<BeforeLookModel>
|
||||||
|
|
||||||
|
//Вывод есть ли анкета ПОСЛЕ
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@GET("LookAfter")
|
||||||
|
suspend fun LookAfter(@Header("Authorization") token:String) :Response<AfterLookModel>
|
||||||
|
|
||||||
|
|
||||||
|
//Вывод есть ли анкета ПОСЛЕ
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@GET("GetCalendare")
|
||||||
|
suspend fun GetCalendare(@Header("Authorization") token:String) :Response<CalendareListModel>
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.example.rehabilitation.Setting
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
@ -12,6 +11,10 @@ import androidx.appcompat.app.AlertDialog
|
||||||
import com.example.admin.Toast.showCustomInfoToast
|
import com.example.admin.Toast.showCustomInfoToast
|
||||||
import com.example.rehabilitation.Auth.AuthFragment
|
import com.example.rehabilitation.Auth.AuthFragment
|
||||||
import com.example.rehabilitation.Auth.AuthorizationActivity
|
import com.example.rehabilitation.Auth.AuthorizationActivity
|
||||||
|
import com.example.rehabilitation.CodeError.Code429Activity
|
||||||
|
import com.example.rehabilitation.CodeError.Code500Activity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetActivity
|
||||||
|
import com.example.rehabilitation.Enternet.EnternetCheck
|
||||||
import com.example.rehabilitation.Feedback.FeedbackFragment
|
import com.example.rehabilitation.Feedback.FeedbackFragment
|
||||||
import com.example.rehabilitation.MainFragment
|
import com.example.rehabilitation.MainFragment
|
||||||
import com.example.rehabilitation.Pref.ClearPref
|
import com.example.rehabilitation.Pref.ClearPref
|
||||||
|
@ -34,6 +37,9 @@ class SettingFragment : Fragment() {
|
||||||
val prefPatientClear = ClearPref()
|
val prefPatientClear = ClearPref()
|
||||||
val prefPatientConclusion = ConclusionPref()
|
val prefPatientConclusion = ConclusionPref()
|
||||||
private lateinit var patientApi: PatientApi
|
private lateinit var patientApi: PatientApi
|
||||||
|
|
||||||
|
//Класс проверки интеренета
|
||||||
|
val enternetCheck = EnternetCheck()
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
|
@ -94,7 +100,7 @@ class SettingFragment : Fragment() {
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val retrofit = Retrofit.Builder()
|
val retrofit = Retrofit.Builder()
|
||||||
.baseUrl("http://mobileapp.vmeda.org/api/")
|
.baseUrl("https://rehabilitation.vmeda.org/api/")
|
||||||
.client(client)
|
.client(client)
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
.build()
|
.build()
|
||||||
|
@ -105,28 +111,58 @@ class SettingFragment : Fragment() {
|
||||||
|
|
||||||
//Получения списка пациентов
|
//Получения списка пациентов
|
||||||
fun Logout() {
|
fun Logout() {
|
||||||
initRetrofit()
|
if (enternetCheck.isOnline(requireContext())) {
|
||||||
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
initRetrofit()
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
|
||||||
val listProduct = patientApi.LogoutPatient("Bearer $Tokens")
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
val listProduct = patientApi.LogoutPatient("Bearer $Tokens")
|
||||||
|
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
|
|
||||||
//Фиксируем полученные данные
|
|
||||||
val visibleviewList = listProduct.body()
|
|
||||||
val visibleviewListCode = listProduct.isSuccessful()
|
|
||||||
//Если нету ошибок
|
|
||||||
if (visibleviewListCode) {
|
|
||||||
Toast(requireContext()).showCustomInfoToast(visibleviewList?.message.toString(), requireActivity())
|
|
||||||
prefPatientClear.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())
|
||||||
|
prefPatientClear.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(), AuthorizationActivity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
val intetn = Intent(requireContext(), EnternetActivity::class.java)
|
||||||
|
activity?.finish()
|
||||||
|
startActivity(intetn)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
||||||
import com.example.rehabilitation.R
|
import com.example.rehabilitation.R
|
||||||
import com.example.rehabilitation.databinding.ImageSportCardsBinding
|
import com.example.rehabilitation.databinding.ImageSportCardsBinding
|
||||||
|
import com.squareup.picasso.Picasso
|
||||||
|
|
||||||
|
|
||||||
class ImageSportAdapter(val contextF:Context) : ListAdapter<ImageSportModel, ImageSportAdapter.Holder>(
|
class ImageSportAdapter(val contextF:Context) : ListAdapter<ImageSportModel, ImageSportAdapter.Holder>(
|
||||||
|
@ -40,8 +41,8 @@ class ImageSportAdapter(val contextF:Context) : ListAdapter<ImageSportModel, Ima
|
||||||
@SuppressLint("DiscouragedApi")
|
@SuppressLint("DiscouragedApi")
|
||||||
fun bind(item: ImageSportModel) = with(binding) {//Productitem - перпедаем данные
|
fun bind(item: ImageSportModel) = with(binding) {//Productitem - перпедаем данные
|
||||||
itemTemp = item
|
itemTemp = item
|
||||||
val image = contextF.resources.getIdentifier("${item.name}", "drawable", contextF.packageName)
|
Picasso.get().load("http://mobileapp.vmeda.org"+item.url_image).into(imageSport)
|
||||||
imageSport.setImageResource(image)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.example.rehabilitation.Sport
|
||||||
|
|
||||||
|
data class ViewModel(
|
||||||
|
val view: Int,
|
||||||
|
val text: String,
|
||||||
|
|
||||||
|
)
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
package com.example.rehabilitation.model_adapter.Calendare
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import com.example.rehabilitation.Calendare.Calendare.getColorCompat
|
|
||||||
import com.example.rehabilitation.Calendare.Calendare.layoutInflater
|
|
||||||
import com.example.rehabilitation.Calendare.Calendare.shared.Flight
|
|
||||||
import com.example.rehabilitation.Calendare.Calendare.shared.flightDateTimeFormatter
|
|
||||||
import com.example.rehabilitation.databinding.Example5EventItemViewv2Binding
|
|
||||||
|
|
||||||
|
|
||||||
class CalendareAdapter :
|
|
||||||
RecyclerView.Adapter<CalendareAdapter.Example5FlightsViewHolder>() {
|
|
||||||
|
|
||||||
val flights = mutableListOf<Flight>()
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Example5FlightsViewHolder {
|
|
||||||
return Example5FlightsViewHolder(
|
|
||||||
Example5EventItemViewv2Binding.inflate(parent.context.layoutInflater, parent, false),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBindViewHolder(viewHolder: Example5FlightsViewHolder, position: Int) {
|
|
||||||
viewHolder.bind(flights[position])
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItemCount(): Int = flights.size
|
|
||||||
|
|
||||||
inner class Example5FlightsViewHolder(val binding: Example5EventItemViewv2Binding) :
|
|
||||||
RecyclerView.ViewHolder(binding.root) {
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
fun bind(flight: Flight) {
|
|
||||||
binding.itemFlightDateText.apply {
|
|
||||||
text = flightDateTimeFormatter.format(flight.time)
|
|
||||||
setBackgroundColor(itemView.context.getColorCompat(flight.color))
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.txtItem.text = flight.item
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
After Width: | Height: | Size: 13 KiB |
|
@ -0,0 +1,5 @@
|
||||||
|
<vector android:autoMirrored="true" android:height="24dp"
|
||||||
|
android:tint="#000000" android:viewportHeight="24"
|
||||||
|
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
|
||||||
|
</vector>
|
Before Width: | Height: | Size: 333 KiB |
Before Width: | Height: | Size: 339 KiB |
Before Width: | Height: | Size: 382 KiB |
Before Width: | Height: | Size: 385 KiB |
Before Width: | Height: | Size: 308 KiB |
Before Width: | Height: | Size: 334 KiB |
Before Width: | Height: | Size: 359 KiB |
Before Width: | Height: | Size: 318 KiB |
Before Width: | Height: | Size: 365 KiB |
Before Width: | Height: | Size: 320 KiB |
Before Width: | Height: | Size: 318 KiB |
Before Width: | Height: | Size: 301 KiB |
Before Width: | Height: | Size: 502 KiB |
Before Width: | Height: | Size: 455 KiB |
Before Width: | Height: | Size: 426 KiB |
Before Width: | Height: | Size: 417 KiB |
Before Width: | Height: | Size: 422 KiB |
Before Width: | Height: | Size: 324 KiB |
Before Width: | Height: | Size: 348 KiB |