Compare commits

...

No commits in common. "main" and "patient" have entirely different histories.

377 changed files with 31481 additions and 0 deletions

15
.gitignore vendored 100644
View File

@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties

3
.idea/.gitignore vendored 100644
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

1
.idea/.name 100644
View File

@ -0,0 +1 @@
Rehabilitation

View File

@ -0,0 +1,123 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JetCodeStyleSettings>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<codeStyleSettings language="XML">
<option name="FORCE_REARRANGE_MODE" value="1" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
<codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</codeStyleSettings>
</code_scheme>
</component>

View File

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="17" />
</component>
</project>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<targetSelectedWithDropDown>
<Target>
<type value="QUICK_BOOT_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="C:\Users\maksi\.android\avd\Pixel_6_API_29.avd" />
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-11-28T12:28:18.723737700Z" />
</component>
</project>

22
.idea/gradle.xml 100644
View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$PROJECT_DIR$/../../../../Gradle/gradle-8.2" />
<option name="gradleJvm" value="jbr-17" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
<option name="offlineMode" value="true" />
</component>
</project>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinJpsPluginSettings">
<option name="version" value="1.8.0" />
</component>
</project>

16
.idea/misc.xml 100644
View File

@ -0,0 +1,16 @@
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="VisualizationToolProject">
<option name="state">
<ProjectState>
<option name="scale" value="0.33" />
</ProjectState>
</option>
</component>
</project>

6
.idea/vcs.xml 100644
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

1
app/.gitignore vendored 100644
View File

@ -0,0 +1 @@
/build

82
app/build.gradle 100644
View File

@ -0,0 +1,82 @@
plugins {
id 'kotlin-kapt'
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.gms.google-services'
}
android {
namespace 'com.example.rehabilitation'
compileSdk 33
defaultConfig {
applicationId "com.example.rehabilitation"
minSdk 28
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures{
viewBinding true
}
}
dependencies {
implementation 'androidx.room:room-ktx:2.5.2'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.1"
implementation 'androidx.fragment:fragment-ktx:1.5.5'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.1.17'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.android.car.ui:car-ui-lib:2.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'org.apache.poi:poi:5.2.3'
implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '5.2.3'
implementation group: 'org.apache.poi', name: 'poi', version: '5.2.3'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
implementation 'com.kizitonwose.calendar:view:2.0.0'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.1"
//Retrofit
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
//OkHttp
implementation "com.squareup.okhttp3:logging-interceptor:4.7.2"
implementation "com.squareup.okhttp3:okhttp:4.7.2"
implementation 'com.squareup.picasso:picasso:2.71828'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
implementation 'com.kizitonwose.calendar:view:2.0.0'
}

View File

@ -0,0 +1,69 @@
{
"project_info": {
"project_number": "1027818028999",
"firebase_url": "https://rehabilitationtest-default-rtdb.europe-west1.firebasedatabase.app",
"project_id": "rehabilitationtest",
"storage_bucket": "rehabilitationtest.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:1027818028999:android:a97724d7840d06fdada3e2",
"android_client_info": {
"package_name": "com.example.rehabilitation"
}
},
"oauth_client": [
{
"client_id": "1027818028999-a75qvvvqqb81ber25k6eeq1fqpr60oam.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyAHvjzE2QIaIrCD9NOD1f_rShI4eXPyFVo"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "1027818028999-a75qvvvqqb81ber25k6eeq1fqpr60oam.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:1027818028999:android:1459bab345b4bf66ada3e2",
"android_client_info": {
"package_name": "com.example.user"
}
},
"oauth_client": [
{
"client_id": "1027818028999-a75qvvvqqb81ber25k6eeq1fqpr60oam.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyAHvjzE2QIaIrCD9NOD1f_rShI4eXPyFVo"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "1027818028999-a75qvvvqqb81ber25k6eeq1fqpr60oam.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}

21
app/proguard-rules.pro vendored 100644
View File

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

Binary file not shown.

View File

@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.example.rehabilitation",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
],
"elementType": "File"
}

View File

@ -0,0 +1,24 @@
package com.example.rehabilitation
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.example.rehabilitation", appContext.packageName)
}
}

View File

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-feature
android:name="android.hardware.telephony"
android:required="false" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher_logov2"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_logov2"
android:supportsRtl="true"
android:theme="@style/Theme.Rehabilitation"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
<activity
android:name=".Auth.AuthorizationActivity"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:screenOrientation="portrait"
android:value="" />
</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
android:name=".MainActivity"
android:exported="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan|stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Enternet.EnternetActivity"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:screenOrientation="portrait"
android:value="" />
</activity>
</application>
</manifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

View File

@ -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]//Возврощаем фрагмент из листа по позиции
}
}

View File

@ -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()
}
}
}
}

View File

@ -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)
}
}

View File

@ -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)
}
}

View File

@ -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()
}
}

View File

@ -0,0 +1,6 @@
package com.example.rehabilitation.Appeals.TabLayout.Model
data class AppealsNewListModel(
val appeals_new: List<AppealsNewModel>
)

View File

@ -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,
)

View File

@ -0,0 +1,6 @@
package com.example.rehabilitation.Appeals.TabLayout.Model
data class AppealsOldListModel(
val appeals_old: List<AppealsOldModel>
)

View File

@ -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,
)

View File

@ -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) {
}
}

View File

@ -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) {
}
}

View File

@ -0,0 +1,226 @@
package com.example.rehabilitation.Auth
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 com.example.admin.Toast.showCustomInfoToast
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.databinding.FragmentAuthBinding
import com.example.rehabilitation.UserPatientToken
import com.example.rehabilitation.Enternet.EnternetActivity
import com.example.rehabilitation.Enternet.EnternetCheck
import com.example.rehabilitation.MainFragment
import com.example.rehabilitation.PatientViewModel
import com.example.rehabilitation.Pref.ClearPref
import com.example.rehabilitation.Pref.ConclusionPref
import com.example.rehabilitation.Pref.SavePref
import com.example.rehabilitation.Questionnaire.Model.BeforeQuestionnaireModel
import com.example.rehabilitation.R
import com.example.rehabilitation.Retrofit.PatientApi
import com.example.rehabilitation.Sport.SceduleFragment
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
class AuthFragment : Fragment() {
private lateinit var binding: FragmentAuthBinding
private val model: MainViewModel by activityViewModels()//Инициализировали класс
private lateinit var patientApi: PatientApi
private val PatientVewModel: PatientViewModel by activityViewModels()
//Токен
private var Token = ""
val prefPatientSave = SavePref()
val prefPatientConclusion = ConclusionPref()
val prefPatientClear = ClearPref()
//Класс проверки интеренета
val enternetCheck = EnternetCheck()
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
binding = FragmentAuthBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.txtError.text = ""
// prefPatientClear.clearToken(requireContext())
Token = prefPatientConclusion.conclusionToken(requireContext())
//Авиризация пациента
binding.buttonAuthorizationPatient.setOnClickListener {
val login = binding.editTextLoginPatient.text.toString()
val password = binding.editTextPasswordPatient.text.toString()
if (login != "" || password != "") {
AuthorizationPatient(
AuthModel(
login,
password,
)
)
} else {
Toast(requireContext()).showCustomInfoToast(
"Не все поля заполнены",
requireActivity()
)
}
}
// //Если пользователь решил зайти в аккаунт врача и не подумал о том что не сможет вернуться со страницы авторизации, то он может нажать данную кнопку, и в случае если он был авторизован, то его вернет в приложение
// binding.btnBack.setOnClickListener {
// if (UserPatientToken != "") {
// activity?.supportFragmentManager?.beginTransaction()
// ?.replace(R.id.CLMain, MainFragment.newInstance())
// ?.commit()
// } else {
// Toast(requireContext()).showCustomInfoToast("Авторизуйтесь", requireActivity())
// }
// }
}
//Инициализация подлючения к серверу
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)
}
// //Получения списка пациентов
// fun BeforeQuestionnaire(item: BeforeQuestionnaireModel) {
// if (enternetCheck.isOnline(requireContext())) {
// initRetrofit()
// val Tokens = prefPatientConclusion.conclusionToken(requireContext())
// CoroutineScope(Dispatchers.IO).launch {
// val QA = patientApi.AddBeforeQuestionnaire2("Bearer $Tokens",item)
// requireActivity().runOnUiThread {
//
// //Фиксируем полученные данные
// val AQList = QA.body()
//
// //Если нету ошибок
// if (AQList != null) {
// Toast(requireContext()).showCustomInfoToast(AQList.message, requireActivity())
// }
// else{
// Toast(requireContext()).showCustomInfoToast("Ошибка при отправке", requireActivity())
//
// }
//
// //Вывод фрагмента на активити при первоначальной загрузке
// 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) {
if (enternetCheck.isOnline(requireContext())) {
initRetrofit()
CoroutineScope(Dispatchers.IO).launch {
val response = patientApi.LoginPatient(authModel)
requireActivity().runOnUiThread {
//Фиксируем полученные данные
val List = response.body()
val Nice = response.isSuccessful
val Code = response.code()
if(Code==429){
val intetn = Intent(requireContext(), Code429Activity::class.java)
startActivity(intetn)
}
else if(Code==200) {
//Если нету ошибок
if (Nice) {
//Если есть такой пользователь
if (List != null) {
//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)
}
}
override fun onDestroy() {
super.onDestroy()
activity?.finish()
}
companion object {
fun newInstance() = AuthFragment()
}
}

View File

@ -0,0 +1,30 @@
package com.example.rehabilitation.Auth
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.example.rehabilitation.R
import com.example.rehabilitation.databinding.ActivityAuthorizationBinding
class AuthorizationActivity : AppCompatActivity() {
private lateinit var binding: ActivityAuthorizationBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityAuthorizationBinding.inflate(layoutInflater)
setContentView(binding.root)
//Вывод фрагмента на активити при первоначальной загрузке
supportFragmentManager.beginTransaction()
.replace(R.id.CLAuth, AuthFragment.newInstance())
.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
}
}

View File

@ -0,0 +1,7 @@
package com.example.rehabilitation.Auth.Model
data class AuthModel(
val login: String,
val password: String,
)

View File

@ -0,0 +1,5 @@
package com.example.rehabilitation.Auth.Model
data class CheckTokenModel(
val status:String,
)

View File

@ -0,0 +1,14 @@
package com.example.rehabilitation.Auth.Model
data class PatientModel(
val id: String,
val name:String,
val surname:String,
val patronymic:String,
val diagnosis:String,
val number_of_courses:String,
//val email:String,
val login:String,
val password:String,
)

View File

@ -0,0 +1,7 @@
package com.example.rehabilitation.Auth.Model
data class UserModel(
val id: String,
val token: String,
)

View File

@ -0,0 +1,244 @@
package com.example.rehabilitation.Calendare
import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.GridLayoutManager
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.Sport.DayAdapter
import com.example.rehabilitation.databinding.FragmentCalendarBinding
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.time.LocalDate
import java.util.Timer
import kotlin.concurrent.fixedRateTimer
import kotlin.concurrent.timerTask
class CalendarFragment : Fragment(),CalendareListAdapter.Listener {
private lateinit var binding: FragmentCalendarBinding
lateinit var adapterCalendare: CalendareListAdapter
private val modelPatient: PatientViewModel by activityViewModels()//Инициализировали класс
private lateinit var patientApi: PatientApi
private lateinit var timer: Timer
val prefPatientConclusion = ConclusionPref()
//Календарь
var listCalendare:List<CalendareModel>? = null
@SuppressLint("NewApi")
//Загрузка данных для календаря
var calendare = false
//Класс проверки интеренета
val enternetCheck = EnternetCheck()
var infoVisibleCalendare = false
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentCalendarBinding.inflate(layoutInflater, container, false)
return binding.root
}
@SuppressLint("NewApi")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
if(isAdded) {
visibleLoad()
initRcView()
initRetrofit()
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(){
binding.CLCalendare.visibility = View.VISIBLE
binding.CLLoad.visibility = View.GONE
}
fun visibleLoad(){
binding.CLCalendare.visibility = View.GONE
binding.CLLoad.visibility = View.VISIBLE
}
//Инициализация списка
private fun initRcView() = with(binding) {
rcView.layoutManager = GridLayoutManager(requireContext(), 1)//По вертикали будет выводить по умолчанию
adapterCalendare = CalendareListAdapter(this@CalendarFragment)
rcView.adapter = adapterCalendare
//binding.rcVIewDayList.smoothScrollToPosition(0);
}
//Инициализация запроса
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 APIliveCountCalendareCurrent() {
if (enternetCheck.isOnline(requireContext())) {
initRetrofit()
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
CoroutineScope(Dispatchers.IO).launch {
val Calendare = patientApi.GetCalendare("Bearer $Tokens")
activity?.runOnUiThread {
//Фиксируем полученные данные
val List = Calendare.body()
val Nice = Calendare.isSuccessful
val Code = Calendare.code()
if(Code==429){
val intetn = Intent(requireContext(), Code429Activity::class.java)
startActivity(intetn)
}
else if(Code==200) {
//Если нету ошибок
if (Nice) {
//Если нету ошибок
if (List != null) {
Log.i("CalendareList_calendare_day", List.calendare_day.toString())
modelPatient.calendareList.value = List.calendare_day
}
}
}
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 {
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()
}
}
}
}

View File

@ -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)
}
}

View File

@ -0,0 +1,5 @@
package com.example.rehabilitation.Calendare
data class CalendareListModel(
val calendare_day: List<CalendareModel>
)

View File

@ -0,0 +1,19 @@
package com.example.rehabilitation.Calendare
data class CalendareModel(
val id: Int,
val id_patient : Int,
val day: String,
val date: String,
val count_workout_max:Int,
val count_workout_make: Int,
val id_sets_of_sports_activities : Int,
val article_sport_for_day: String,
val id_sport_patient :Int,
val block: String,
val pause: String,
val id_before_questionnaire : String,
val id_after_questionnaire : String,
val created_at : String,
val updated_at : String,
)

View File

@ -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()
}
}
}
}

View File

@ -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()
}
}
}
}

View File

@ -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()
}
}

View File

@ -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
}
}

View File

@ -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()
}
}

View File

@ -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()
}
}

View File

@ -0,0 +1,142 @@
package com.example.rehabilitation
import android.content.SharedPreferences
import com.example.rehabilitation.Calendare.CalendareModel
import com.example.rehabilitation.Sport.Image.ImageSportModel
import com.example.rehabilitation.Progress.AfterListModel
import com.example.rehabilitation.Progress.BeforeListModel
import com.example.rehabilitation.Progress.ProgressModel
import java.io.File
import java.io.FileOutputStream
//Постоянное хранилище
var prefUserPatientToken: SharedPreferences? = null
var UserPatientToken:String = ""
var pref: SharedPreferences? = null
//Общее количество дней курса
var prefSportCursDayAll: SharedPreferences? = null
var SportCursDayAll :Int = 0
var prefSportCursDayLast: SharedPreferences? = null
var SportCursDayLast :String = ""
var prefSportCursNumber: SharedPreferences? = null
var prefCursDay: SharedPreferences? = null
var SportCursDay :Int = 0
//7 дней пройдено
var prefSport7Day: SharedPreferences? = null
var Sport7Day :Int = 0
//15 дней пройдено
var prefSport15Day: SharedPreferences? = null
var Sport15Day :Int = 0
//15 дней пройдено и отправлен отчет
var prefSport15DayAll: SharedPreferences? = null
var Sport15DayAll :Int = 0
var prefSportCursDayNumber: SharedPreferences? = null
var SportCursDayNumber :Int = 0
var prefSport: SharedPreferences? = null
var SportUserTrue = 0
var prefCursDangerDayBefore: SharedPreferences? = null
var SportCursDayDangerBefore:Int = 0
var prefCursDangerDayAfter: SharedPreferences? = null
var SportCursDayDangerAfter:Int = 0
var prefCursDayNull: SharedPreferences? = null
var CursDayNull:String = ""
var prefSportPlusCount: SharedPreferences? = null
var SportPlusCount:Int = 0
var prefSportMaxCount: SharedPreferences? = null
var SportMaxCount:Int = 0
var prefDayBefore: SharedPreferences? = null
var DayBefore:String = ""
var prefDayAfter: SharedPreferences? = null
var DayAfter:String = ""
var prefPauseDay: SharedPreferences? = null
var PauseDay:String = ""
var prefBlock: SharedPreferences? = null
var Block:String = ""
var prefFIO: SharedPreferences? = null
var FIO:String = ""
var prefEmailPatient: SharedPreferences? = null
var EmailPatient:String = ""
//Дата начала тренировки
var prefSportDateStart: SharedPreferences? = null
var SportDateStart:String = ""
var prefUser: SharedPreferences? = null
//Хранилище для анкеты
//var questionnaire: SharedPreferences? = null
var questionnaire_before :String = ""
var questionnaire_after:String = ""
var nameSport :String = ""
var countSport:Int? = null
var countSportPlus:String = ""
//Ключи для хранилишь
//Для пациента
var tokenClass:String = ""
var counter1:String = ""
//Для врача
var counter2:String = ""
var tokenClassDoctor:String = ""
var countCategory:String = ""
//Отчет по ребилитации
var listCheckSportDay:String = ""
//Доктор
var loginDoctor:String = "maxi05092003"
//Пациент
var loginPatient:String = "t.t.maxi05092003@gmail.com"
//Хранения отчета на время
var checkDaySportString:String = ""
//Хранения для перехода на страницу
var daySpoartOpen:Int = 0
var daySpoartOpenDate:String = ""
val daySpoartOpenKey:Int = 12321313
//var itemDayOpenDate:MonthModel
//Анкетирование
var listBefore:List<BeforeListModel> = listOf()
var listAfter:List<AfterListModel> = listOf()
//Прогрес
var listProgressAll:List<ProgressModel> = listOf()
var listProgressCheck:List<ProgressModel> = listOf()
var listImageSport:List<ImageSportModel> = listOf()
var uriFileEF: File? =null
var fileUri2: FileOutputStream? =null
//Переменная для хранения дня, чтобы при нажатие на главной тсранице или в календаре
var dateHomeCalendare:String = ""
class Hranilihe {
}

View File

@ -0,0 +1,50 @@
package com.example.rehabilitation.fragment.InfoFragment
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.Information.InformationFragment
import com.example.rehabilitation.databinding.FragmentCommonInfoBinding
class CommonInfoFragment : Fragment() {
private lateinit var binding: FragmentCommonInfoBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentCommonInfoBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InformationFragment.newInstance())?.addToBackStack(null)?.commit()
}
}
// override fun onResume() {
// super.onResume()
// binding.CLCommonInfo.visibility = View.VISIBLE
// }
//
// override fun onDestroy() {
// super.onDestroy()
// binding.CLCommonInfo.visibility = View.GONE
//
// }
companion object {
@JvmStatic
fun newInstance() = CommonInfoFragment()
}
}

View File

@ -0,0 +1,49 @@
package com.example.rehabilitation.fragment.InfoFragment
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.Information.InformationFragment
import com.example.rehabilitation.databinding.FragmentMedicalReabilitationBinding
class MedicalReabilitationFragment : Fragment() {
private lateinit var binding: FragmentMedicalReabilitationBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentMedicalReabilitationBinding.inflate(layoutInflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InformationFragment.newInstance())?.addToBackStack(null)?.commit()
}
}
// override fun onResume() {
// super.onResume()
// binding.CLMadicalReabilitation.visibility = View.VISIBLE
// }
//
// override fun onDestroy() {
// super.onDestroy()
// binding.CLMadicalReabilitation.visibility = View.GONE
//
// }
companion object {
@JvmStatic
fun newInstance() = MedicalReabilitationFragment()
}
}

View File

@ -0,0 +1,48 @@
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod
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 com.example.rehabilitation.R as R_P
import android.R
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment
import com.example.rehabilitation.databinding.FragmentBreathingExercisesBinding
class BreathingExercisesFragment : Fragment() {
private lateinit var binding:FragmentBreathingExercisesBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentBreathingExercisesBinding.inflate(layoutInflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R_P.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
}
val inflater = TransitionInflater.from(requireContext())
binding.DecongestantTherapy.setOnClickListener {
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()
)?.addToBackStack(null)?.commit()
}
//enterTransition = inflater.inflateTransition(R_P.transition.slide_bottom)
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.BreathingExercisesFragment()
}
}

View File

@ -0,0 +1,42 @@
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod
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.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment
import com.example.rehabilitation.databinding.FragmentContourPreventionBinding
class ContourPreventionFragment : Fragment() {
private lateinit var binding:FragmentContourPreventionBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentContourPreventionBinding.inflate(layoutInflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnPhantomPains.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.PhantomPainsFragment.Companion.newInstance()
)?.addToBackStack(null)?.commit()
}
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.ContourPreventionFragment()
}
}

View File

@ -0,0 +1,41 @@
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod
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.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment
import com.example.rehabilitation.databinding.FragmentDecongestantTherapyBinding
class DecongestantTherapyFragment : Fragment() {
private lateinit var binding: FragmentDecongestantTherapyBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentDecongestantTherapyBinding.inflate(layoutInflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnContracturesPrevention.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.ContourPreventionFragment.Companion.newInstance()
)?.addToBackStack(null)?.commit()
}
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.DecongestantTherapyFragment()
}
}

View File

@ -0,0 +1,42 @@
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod
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.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment
import com.example.rehabilitation.databinding.FragmentFormationOfTheStumpBinding
class FormationOfTheStumpFragment : Fragment() {
private lateinit var binding:FragmentFormationOfTheStumpBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentFormationOfTheStumpBinding.inflate(layoutInflater,container,false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnPhysicalExercises.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.PhysicalExercisesFragment.Companion.newInstance()
)?.addToBackStack(null)?.commit()
}
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.FormationOfTheStumpFragment()
}
}

View File

@ -0,0 +1,44 @@
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod
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 com.example.rehabilitation.R
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment
import com.example.rehabilitation.databinding.FragmentMotorModeBinding
class MotorModeFragment : Fragment() {
private lateinit var binding: FragmentMotorModeBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentMotorModeBinding.inflate(layoutInflater,container,false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
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 {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.StumpCareFragment.Companion.newInstance()
)?.addToBackStack(null)?.commit()
}
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.MotorModeFragment()
}
}

View File

@ -0,0 +1,41 @@
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod
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.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment
import com.example.rehabilitation.databinding.FragmentOrganizationOfTheDailyRoutineAfterSurgeryBinding
class OrganizationOfTheDailyRoutineAfterSurgeryFragment : Fragment() {
private lateinit var binding: FragmentOrganizationOfTheDailyRoutineAfterSurgeryBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentOrganizationOfTheDailyRoutineAfterSurgeryBinding.inflate(layoutInflater,container,false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnOrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputation.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.OrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputationFragment.Companion.newInstance()
)?.addToBackStack(null)?.commit()
}
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.OrganizationOfTheDailyRoutineAfterSurgeryFragment()
}
}

View File

@ -0,0 +1,36 @@
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod
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.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment
import com.example.rehabilitation.databinding.FragmentOrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputationBinding
class OrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputationFragment : Fragment() {
private lateinit var binding: FragmentOrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputationBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentOrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputationBinding.inflate(layoutInflater,container,false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
}
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.OrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputationFragment()
}
}

View File

@ -0,0 +1,41 @@
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod
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.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment
import com.example.rehabilitation.databinding.FragmentPhantomPainsBinding
class PhantomPainsFragment : Fragment() {
private lateinit var binding:FragmentPhantomPainsBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentPhantomPainsBinding.inflate(layoutInflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnSurfaceSensitivity.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.SurfaceSensitivityFragment.Companion.newInstance()
)?.addToBackStack(null)?.commit()
}
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.PhantomPainsFragment()
}
}

View File

@ -0,0 +1,41 @@
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod
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.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment
import com.example.rehabilitation.databinding.FragmentPhysicalExercisesBinding
class PhysicalExercisesFragment : Fragment() {
private lateinit var binding: FragmentPhysicalExercisesBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentPhysicalExercisesBinding.inflate(layoutInflater,container,false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnOrganizationOfTheDailyRoutineAfterSurgery.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.OrganizationOfTheDailyRoutineAfterSurgeryFragment.Companion.newInstance()
)?.addToBackStack(null)?.commit()
}
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.PhysicalExercisesFragment()
}
}

View File

@ -0,0 +1,43 @@
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod
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.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment
import com.example.rehabilitation.databinding.FragmentStumpCareBinding
class StumpCareFragment : Fragment() {
private lateinit var binding: FragmentStumpCareBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentStumpCareBinding.inflate(layoutInflater,container,false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnBreathingExercises.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.BreathingExercisesFragment.Companion.newInstance()
)?.addToBackStack(null)?.commit()
}
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.StumpCareFragment()
}
}

View File

@ -0,0 +1,42 @@
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod
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.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment
import com.example.rehabilitation.databinding.FragmentSurfaceSensitivityBinding
class SurfaceSensitivityFragment : Fragment() {
private lateinit var binding:FragmentSurfaceSensitivityBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentSurfaceSensitivityBinding.inflate(layoutInflater,container,false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnFormationOfTheStump.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.FormationOfTheStumpFragment.Companion.newInstance()
)?.addToBackStack(null)?.commit()
}
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.SurfaceSensitivityFragment()
}
}

View File

@ -0,0 +1,111 @@
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations
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.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.BreathingExercisesFragment
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.ContourPreventionFragment
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.DecongestantTherapyFragment
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.FormationOfTheStumpFragment
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.MotorModeFragment
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.OrganizationOfTheDailyRoutineAfterSurgeryFragment
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.OrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputationFragment
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.PhantomPainsFragment
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.PhysicalExercisesFragment
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.StumpCareFragment
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.SurfaceSensitivityFragment
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendationsFragment
import com.example.rehabilitation.databinding.FragmentEarlyPostoperativePeriodBinding
class EarlyPostoperativePeriodFragment : Fragment() {
private lateinit var binding:FragmentEarlyPostoperativePeriodBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentEarlyPostoperativePeriodBinding.inflate(layoutInflater,container,false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnMotorMode.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.MotorModeFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnStumpCare.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.StumpCareFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnBreathingExercises.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.BreathingExercisesFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.DecongestantTherapy.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.DecongestantTherapyFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnContracturesPrevention.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.ContourPreventionFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnPhantomPains.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.PhantomPainsFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendationsFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnFurther.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.Companion.newInstance()
)?.addToBackStack(null)?.commit()
}
binding.btnSurfaceSensitivity.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.SurfaceSensitivityFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnFormationOfTheStump.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.FormationOfTheStumpFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnPhysicalExercises.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.PhysicalExercisesFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnOrganizationOfTheDailyRoutineAfterSurgery.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.OrganizationOfTheDailyRoutineAfterSurgeryFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnOrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputation.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriod.OrganizationOfTheDayRegimeOfTheSecondWeekAfterAmputationFragment.newInstance())?.addToBackStack(null)?.commit()
}
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment()
}
}

View File

@ -0,0 +1,43 @@
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod
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.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment
import com.example.rehabilitation.databinding.FragmentDecongestantTherapyLateBinding
class DecongestantTherapyLateFragment : Fragment() {
private lateinit var binding: FragmentDecongestantTherapyLateBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentDecongestantTherapyLateBinding.inflate(layoutInflater,container,false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(
R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnMassageTechniqueLate.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.MassageTechniqueLateFragment.Companion.newInstance()
)?.addToBackStack(null)?.commit()
}
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.DecongestantTherapyLateFragment()
}
}

View File

@ -0,0 +1,42 @@
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod
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.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment
import com.example.rehabilitation.databinding.FragmentMassageTechniqueLateBinding
class MassageTechniqueLateFragment : Fragment() {
private lateinit var binding: FragmentMassageTechniqueLateBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentMassageTechniqueLateBinding.inflate(layoutInflater,container,false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnPreventionOfContracturesLate.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PreventionOfContracturesLateFragment.Companion.newInstance()
)?.addToBackStack(null)?.commit()
}
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.MassageTechniqueLateFragment()
}
}

View File

@ -0,0 +1,38 @@
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod
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.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment
import com.example.rehabilitation.databinding.FragmentPhantomPainsLateBinding
class PhantomPainsLateFragment : Fragment() {
private lateinit var binding:FragmentPhantomPainsLateBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentPhantomPainsLateBinding.inflate(layoutInflater,container,false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(
R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
}
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PhantomPainsLateFragment()
}
}

View File

@ -0,0 +1,43 @@
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod
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.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment
import com.example.rehabilitation.databinding.FragmentPreparationForProstheticsLateBinding
class PreparationForProstheticsLateFragment : Fragment() {
private lateinit var binding: FragmentPreparationForProstheticsLateBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentPreparationForProstheticsLateBinding.inflate(layoutInflater,container,false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(
R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnDecongestantTherapyLate.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.DecongestantTherapyLateFragment.Companion.newInstance()
)?.addToBackStack(null)?.commit()
}
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PreparationForProstheticsLateFragment()
}
}

View File

@ -0,0 +1,41 @@
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod
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.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment
import com.example.rehabilitation.databinding.FragmentPreventionOfContracturesLateBinding
class PreventionOfContracturesLateFragment : Fragment() {
private lateinit var binding: FragmentPreventionOfContracturesLateBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentPreventionOfContracturesLateBinding.inflate(layoutInflater,container,false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnPhantomPainsLate.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PhantomPainsLateFragment.Companion.newInstance()
)?.addToBackStack(null)?.commit()
}
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PreventionOfContracturesLateFragment()
}
}

View File

@ -0,0 +1,63 @@
package com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations
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.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.DecongestantTherapyLateFragment
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.MassageTechniqueLateFragment
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PhantomPainsLateFragment
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PreparationForProstheticsLateFragment
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PreventionOfContracturesLateFragment
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendationsFragment
import com.example.rehabilitation.databinding.FragmentLatePostoperativePeriodBinding
class LatePostoperativePeriodFragment : Fragment() {
private lateinit var binding: FragmentLatePostoperativePeriodBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentLatePostoperativePeriodBinding.inflate(layoutInflater,container,false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendationsFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnPreparationForProstheticsLate.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PreparationForProstheticsLateFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnDecongestantTherapyLate.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.DecongestantTherapyLateFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnMassageTechniqueLate.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.MassageTechniqueLateFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnPreventionOfContracturesLate.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PreventionOfContracturesLateFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnPhantomPainsLate.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriod.PhantomPainsLateFragment.newInstance())?.addToBackStack(null)?.commit()
}
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment()
}
}

View File

@ -0,0 +1,48 @@
package com.example.rehabilitation.Information.InfoFragment
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.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment
import com.example.rehabilitation.Information.InformationFragment
import com.example.rehabilitation.databinding.FragmentMethodologicalRecommendationsBinding
class MethodologicalRecommendationsFragment : Fragment() {
private lateinit var binding: FragmentMethodologicalRecommendationsBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentMethodologicalRecommendationsBinding.inflate(layoutInflater,container,false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InformationFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnEarlyPostoperativePeriod.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.EarlyPostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
}
binding.btnLatePostoperativePeriod.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendations.LatePostoperativePeriodFragment.newInstance())?.addToBackStack(null)?.commit()
}
}
companion object {
fun newInstance() =
com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendationsFragment()
}
}

View File

@ -0,0 +1,50 @@
package com.example.rehabilitation.fragment.InfoFragment
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.Information.InformationFragment
import com.example.rehabilitation.databinding.FragmentFaqBinding
class faqFragment : Fragment() {
private lateinit var binding: FragmentFaqBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
binding = FragmentFaqBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.btnExit.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()?.replace(R.id.CLInformationMain,
com.example.rehabilitation.Information.InformationFragment.newInstance())?.addToBackStack(null)?.commit()
}
}
// override fun onResume() {
// super.onResume()
// binding.CLFaq.visibility = View.VISIBLE
// }
//
// override fun onDestroy() {
// super.onDestroy()
// binding.CLFaq.visibility = View.GONE
//
// }
companion object {
@JvmStatic
fun newInstance() = faqFragment()
}
}

View File

@ -0,0 +1,118 @@
package com.example.rehabilitation.Information
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.Enternet.EnternetCheck
import com.example.rehabilitation.MainActivity
import com.example.rehabilitation.R
import com.example.rehabilitation.Information.InfoFragment.MethodologicalRecommendationsFragment
import com.example.rehabilitation.MainFragment
import com.example.rehabilitation.Setting.SettingFragment
import com.example.rehabilitation.databinding.FragmentInformationBinding
import com.example.rehabilitation.fragment.InfoFragment.CommonInfoFragment
import com.example.rehabilitation.fragment.InfoFragment.MedicalReabilitationFragment
import com.example.rehabilitation.fragment.InfoFragment.faqFragment
class InformationFragment : Fragment() {
private lateinit var binding: FragmentInformationBinding
//Класс проверки интеренета
val enternetCheck = EnternetCheck()
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentInformationBinding.inflate(layoutInflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
if(isAdded()) {
//Выход со страницы
binding.btnExitInformation.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()
?.replace(R.id.CLMain, MainFragment.newInstance())
?.commit()
}
binding.methodologicalRecommendationsButton.setOnClickListener {
// val infoFrag = activity?.supportFragmentManager?.beginTransaction()
// infoFrag?.replace(
// R.id.CLInformation,MethodologicalRecommendationsFragment.newInstance()
// )
// infoFrag?.addToBackStack(null)
// infoFrag?.commit()
activity?.supportFragmentManager?.beginTransaction()
?.replace(R.id.CLInformationMain, MethodologicalRecommendationsFragment.newInstance())
?.commit()
}
binding.commonInformationButton.setOnClickListener {
// val infoFrag = activity?.supportFragmentManager?.beginTransaction()
// infoFrag?.replace(R.id.CLInformation, CommonInfoFragment.newInstance())
// infoFrag?.addToBackStack(null)
// infoFrag?.commit()
activity?.supportFragmentManager?.beginTransaction()
?.replace(R.id.CLInformationMain, CommonInfoFragment.newInstance())
?.commit()
}
binding.frequentlyAskedQuestionsButton.setOnClickListener {
// val infoFrag = activity?.supportFragmentManager?.beginTransaction()
// infoFrag?.replace(R.id.CLInformation, faqFragment.newInstance())
// infoFrag?.addToBackStack(null)
// infoFrag?.commit()
activity?.supportFragmentManager?.beginTransaction()
?.replace(R.id.CLInformationMain, faqFragment.newInstance())
?.commit()
}
binding.medicalReabilitationButton.setOnClickListener {
// val infoFrag = activity?.supportFragmentManager?.beginTransaction()
// infoFrag?.replace(R.id.CLInformation, MedicalReabilitationFragment.newInstance())
// infoFrag?.addToBackStack(null)
// infoFrag?.commit()
activity?.supportFragmentManager?.beginTransaction()
?.replace(R.id.CLInformationMain, MedicalReabilitationFragment.newInstance())
?.commit()
}
binding.fondButton.setOnClickListener {
val i = Intent(
Intent.ACTION_VIEW,
Uri.parse("https://фонд-защитники-отечества.рф/filials")
)
startActivity(i)
}
}
}
// override fun onDestroy() {
// super.onDestroy()
// activity?.finish()
//
// binding.CLFragmentInformation.visibility = View.GONE
// }
//
// override fun onResume() {
// super.onResume()
// binding.CLFragmentInformation.visibility = View.VISIBLE
//
// }
companion object {
fun newInstance() = com.example.rehabilitation.Information.InformationFragment()
}
}

View File

@ -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()
}
}

View File

@ -0,0 +1,325 @@
package com.example.rehabilitation
import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
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.Retrofit.PatientApi
import com.example.rehabilitation.databinding.ActivityMainBinding
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
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
private lateinit var patientApi: PatientApi
private val modelPatient: PatientViewModel by viewModels()//Инициализировали класс
private val model: MainViewModel by viewModels()//Инициализировали класс
//Токен
private var Token = ""
val prefPatientConclusion = ConclusionPref()
var backPressedTime: Long = 0
//Класс проверки интеренета
val enternetCheck = EnternetCheck()
@SuppressLint("DiscouragedApi")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
MainAndAuth()
}
fun MainAndAuth() {
Token = prefPatientConclusion.conclusionToken(this)
Log.i("sadasdsadsd", Token)
//CheckTokenAuth(Token)
if (Token == "") {
Auth()
} else {
CheckTokenAuth(Token)
}
}
fun Auth() {
binding.CLLoad.visibility = View.GONE
//Вывод фрагмента на активити при первоначальной загрузке
supportFragmentManager.beginTransaction()
.replace(R.id.CLMain, AuthFragment.newInstance())
.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
}
fun Main() {
binding.CLLoad.visibility = View.GONE
fragment_inicializ()
// fixedRateTimer("timer", false, 0, 10000) {
// this@MainActivity.runOnUiThread {
// GetVisibleViewList()
// ProgressPatientCourses()
// APIliveCountCalendareCurrent()
// getNewAppeals()
// getOldAppeals()
// }
// }
}
@SuppressLint("SuspiciousIndentation")
private fun CheckTokenAuth(token: String) {
if (enternetCheck.isOnline(this)) {
initRetrofit()
CoroutineScope(Dispatchers.IO).launch {
val response = patientApi.CheckToken("Bearer $token")
runOnUiThread {
//Фиксируем полученные данные
val List = response.body()
val Nice = response.isSuccessful
val Code = response.code()
if(Code==429){
val intetn = Intent(this@MainActivity, Code429Activity::class.java)
startActivity(intetn)
}
else if(Code==200) {
//Если нету ошибок
if (Nice) {
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)
}
}
//Инициализируем 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 fragment_inicializ() {
//Вывод фрагмента на активити при первоначальной загрузке
supportFragmentManager.beginTransaction()
.replace(R.id.CLMain, MainFragment.newInstance())
.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
}
// override fun onBackPressed() {
// if (backPressedTime + 3000 > System.currentTimeMillis()) {
// super.onBackPressed()
// finish()
// } else {
// AlertDialog.Builder(this@MainActivity)
// .setTitle("Выйти")
// .setMessage("Вы точно хотите выйти из приложения?")
// .setPositiveButton("Да") { dialog, whichButton ->
// super.onBackPressed()
// }
// .setNegativeButton("Нет") { dialog, whichButton ->
//
// }
// .show()
// }
// 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() {
super.onDestroy()
finish()
}
override fun onResume() {
super.onResume()
}
}

View File

@ -0,0 +1,431 @@
package com.example.rehabilitation
import android.annotation.SuppressLint
import android.content.Intent
import android.icu.text.SimpleDateFormat
import android.icu.util.Calendar
import android.os.Bundle
import android.os.SystemClock
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.fragment.app.activityViewModels
import androidx.fragment.app.viewModels
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.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.InformationMainFragment
import com.example.rehabilitation.Pref.ConclusionPref
import com.example.rehabilitation.Progress.ProgresFragment
import com.example.rehabilitation.Retrofit.PatientApi
import com.example.rehabilitation.Setting.SettingFragment
import com.example.rehabilitation.Sport.SceduleFragment
import com.example.rehabilitation.databinding.FragmentMainBinding
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.Timer
import kotlin.concurrent.fixedRateTimer
class MainFragment : Fragment() {
private lateinit var binding: FragmentMainBinding
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")
var sdf: SimpleDateFormat = SimpleDateFormat("EEEE")
var d: Date = Date()
var dayOfTheWeek: String = sdf.format(d)
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentMainBinding.inflate(layoutInflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Log.d("5645546564","5645546564")
if (isAdded) {
main_inicializ()
//MainAndAuth()
}
dataModel.fragmentMenu.observe(viewLifecycleOwner, Observer {
binding.buttonNavigation.selectedItemId = it
})
// fixedRateTimer("timer", false, 0, 10000) {
// activity?.runOnUiThread {
//
// }
// }
}
fun main_inicializ() {
dataModel.fragmentMenu.observe(this as LifecycleOwner, {
binding.buttonNavigation.selectedItemId = it
})
//Функция инициализации фрагметов
fragment_inicializ()
binding.btnSetting.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()
?.replace(R.id.CLMain, SettingFragment.newInstance())
//?.addToBackStack(null)
?.commit()
}
binding.btnInformation.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()
?.replace(R.id.CLMain, InformationMainFragment.newInstance())
//?.addToBackStack(null)
?.commit()
}
//Выводим сегоднящнюю дату
addDate()
}
//Инициализация фрагментов
fun fragment_inicializ() {
//Вывод фрагмента на активити при первоначальной загрузке
activity?.supportFragmentManager?.beginTransaction()
?.replace(R.id.placeHolderFragment, SceduleFragment.newInstance())
?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
//Эран который будет выбран по умолчанию(кнопка которая будет прожата по умолчанию)
binding.buttonNavigation.selectedItemId =
R.id.schedule//По умолчанию и так первая, но на всякий случай выберу еще програмным путем первую ячейку
//Нажатие на bottom navigation
binding.buttonNavigation.setOnItemSelectedListener {
when (it.itemId) {//it.itemId - это id нажатого элемента
R.id.schedule -> {
if (!isClickRecently()) {
activity?.supportFragmentManager?.beginTransaction()
?.replace(R.id.placeHolderFragment, SceduleFragment.newInstance())
?.commit()//Заменяем наш экран на фрагмент (используем наш экран как основу)//R.id.placeHolder - куда всталяем //MainFragment.newInstance() - это то что мы вставляем
}
}
R.id.calendar -> {
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 -> {//Если вы не авторизованный пользваотель то вам не будет доступен доступ к данном фрагменту
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
}
}
private fun addDate() {
val calendar: Calendar = Calendar.getInstance()
val sdf: SimpleDateFormat = SimpleDateFormat("EEEE")
val d: Date = Date()
val DayOfTheWeek: String = sdf.format(d)
val Day = calendar.get(Calendar.DATE)
val Month = calendar.get(Calendar.MONTH).plus(1)
var day = Day.toString()
var month = ""
var date_of_the_week = ""
when (Month) {
1 -> month = "Январь"
2 -> month = "Февраль"
3 -> month = "Март"
4 -> month = "Апрель"
5 -> month = "Май"
6 -> month = "Июнь"
7 -> month = "Июль"
8 -> month = "Август"
9 -> month = "Сентябрь"
10 -> month = "Октябрь"
11 -> month = "Ноябрь"
12 -> month = "Декабрь"
else -> { // обратите внимание на блок
month = ""
}
}
when (dayOfTheWeek) {
"Monday" -> date_of_the_week = "Пн"
"Tuesday" -> date_of_the_week = "Вт"
"Wednesday" -> date_of_the_week = "Ср"
"Thursday" -> date_of_the_week = "Чт"
"Friday" -> date_of_the_week = "Пт"
"Saturday" -> date_of_the_week = "Сб"
"Sunday" -> date_of_the_week = "Вс"
"Понедельник" -> date_of_the_week = "Пн"
"Вторник" -> date_of_the_week = "Вт"
"Стреда" -> date_of_the_week = "Ср"
"Четверг" -> date_of_the_week = "Чт"
"Пятница" -> date_of_the_week = "Пт"
"Суббота" -> date_of_the_week = "Сб"
"Воскресенье" -> date_of_the_week = "Вс"
else -> {
date_of_the_week = ""
}
}
System.out.println(calendar.get(Calendar.DATE))
binding.txtDate.setText("${day}" + " " + "${month}")
}
//Получения экрана
fun 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 {
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()
}
}
}
}

View File

@ -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()
}
}

View File

@ -0,0 +1,6 @@
package com.example.rehabilitation
data class MessageModel(
val message: String,
)

View File

@ -0,0 +1,37 @@
package com.example.rehabilitation
import androidx.lifecycle.MutableLiveData
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.ViewVisibleModel
class PatientViewModel: ViewModel() {
val token = MutableLiveData<String>()
val liveDaySportOne = MutableLiveData<SportDayOneModel>()
//Обращения необработанные
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>>()
}

View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -0,0 +1,14 @@
package com.example.rehabilitation.Pref
import android.content.Context
import android.content.SharedPreferences
class ClearPref() {
fun clearToken(context: Context) {
val prefDoctor: SharedPreferences = context.getSharedPreferences("PATIENT", Context.MODE_PRIVATE)
val edit = prefDoctor.edit()
edit?.clear()
edit?.apply()
}
}

View File

@ -0,0 +1,19 @@
package com.example.rehabilitation.Pref
import android.content.Context
import android.content.SharedPreferences
class ConclusionPref() {
fun conclusionToken(context: Context):String {
val prefDoctor: SharedPreferences = context.getSharedPreferences("PATIENT", Context.MODE_PRIVATE)
val token = prefDoctor.getString("token", "")
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()
}
}

View File

@ -0,0 +1,20 @@
package com.example.rehabilitation.Pref
import android.content.Context
import android.content.SharedPreferences
class SavePref (){
fun saveToken(context: Context,token: String) {
val prefPatient: SharedPreferences = context.getSharedPreferences("PATIENT", Context.MODE_PRIVATE)
val edit = prefPatient.edit()
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()
}
}

View File

@ -0,0 +1,19 @@
package com.example.rehabilitation.Progress
data class AfterListModel(
val id: Int,
val one: String,
val two: String,
val thee:String,
val four:String,
val five:String,
val six:String,
val seven:String,
val eight:String,
val nine:String,
val ten:String,
val eleven:String,
val twelve:String,
val date:String,
)

View File

@ -0,0 +1,18 @@
package com.example.rehabilitation.Progress
data class BeforeListModel(
val id: Int,
val one: String,
val two: String,
val thee:String,
val four:String,
val five:String,
val six:String,
val seven:String,
val eight:String,
val nine:String,
val date:String,
)

View File

@ -0,0 +1,202 @@
package com.example.rehabilitation.Progress
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
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.R
import com.example.rehabilitation.Retrofit.PatientApi
import com.example.rehabilitation.Sport.SceduleFragment
import com.example.rehabilitation.databinding.FragmentProgresBinding
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 kotlin.concurrent.fixedRateTimer
class ProgresFragment : Fragment() {
private lateinit var binding: FragmentProgresBinding
private val model: MainViewModel by activityViewModels()//Инициализировали класс
//Хранинение токена
private var prefToken: SharedPreferences? = null
private var Token = ""
private lateinit var patientApi: PatientApi
lateinit var adapterProgress: ProgressAdapter
var view_progress = false
val prefPatientConclusion = ConclusionPref()
var progresList : List<ProgressModel>? = null
//Класс проверки интеренета
val enternetCheck = EnternetCheck()
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentProgresBinding.inflate(layoutInflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
prefToken = activity?.getSharedPreferences("token", Context.MODE_PRIVATE)
Token = prefToken?.getString("token", "")!!
model.liveProgressCheckList.observe(viewLifecycleOwner) {//viewLifecycleOwner - следит за циклом жизни fragment
if(progresList != it){
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()
initRCView()
visibleLoad()
ProgressPatientCourses()
// fixedRateTimer("timer", false, 0, 10000) {
// activity?.runOnUiThread {
// ProgressPatientCourses()
// }
// }
binding.button7.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()
?.replace(R.id.placeHolderFragment, SceduleFragment.newInstance())?.commit()
}
}
//Функция получения данных для заполнения списка прогресса
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)
}
//Вывод прогресса пациента
fun ProgressPatientCourses() {
if (enternetCheck.isOnline(requireContext())) {
Log.i("sdasd2312","312ewqds")
if (view_progress == false) {
view_progress = true
visibleLoad()
initRetrofit()
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
CoroutineScope(Dispatchers.IO).launch {
val progress = patientApi.ProgressPatientCourses("Bearer $Tokens")
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)
}
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 initRCView() = with(binding) {
rcViewProgress.layoutManager = LinearLayoutManager(
requireContext(),
LinearLayoutManager.VERTICAL,
false
)//По вертикали будет выводить по умолчанию
adapterProgress = ProgressAdapter()
rcViewProgress.adapter = adapterProgress
}
fun visible1() {
binding.CLMainProgres.visibility = View.VISIBLE
binding.CLLoad.visibility = View.GONE
}
fun visibleLoad() {
binding.CLMainProgres.visibility = View.GONE
binding.CLLoad.visibility = View.VISIBLE
}
companion object {
fun newInstance() = ProgresFragment()
}
}

View File

@ -0,0 +1,76 @@
package com.example.rehabilitation.Progress
import android.annotation.SuppressLint
import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.example.rehabilitation.R
import com.example.rehabilitation.databinding.RcItemProgressBinding
class ProgressAdapter() : ListAdapter<ProgressModel, ProgressAdapter.Holder>(Comparator()) {//Productitem - по этой форме будем заполнять.//ProductAdapter.holder - это создаваемый holder который хранит логику как нужно заполнять карточку
//В holder создаетс код с помошью которого мы будем заполнять и сохронять разметку
class Holder(view: View) :
RecyclerView.ViewHolder(view) {//Класс который будет хранить сссылки на элементы, и отвечает за один элемент за 1 раз, то есть сначсало нулевой элемент заполнит, потом первый, потом второй и т.д.
//Для передачи данных
val binding =
RcItemProgressBinding.bind(view)//view - здесь храянтся элементы и мы их bind заполним в ListItemBinding//ListItemBinding - это клласс даннйо разметки(карточки) которую мы будем заполнять, а нужна дання переменная(binding), чтобы мжно было при заполнение обращатся к элементам карточки
var itemTemp: ProgressModel? =
null//Глобальная переменная для нашего item, чтобы можно было передать данные для нажатия
@SuppressLint("SuspiciousIndentation", "SetTextI18n")
fun bind(item: ProgressModel) = with(binding) {//Productitem - перпедаем данные
itemTemp = item
txtNumber.text = item.number.toString()+ ". "
txtDate.text = item.day + " - " +item.count.toString() + "/" + item.count_workout_max.toString()
//txtProgress.text =
if (item.count_workout_max != item.count) {
CardViewDay.setCardBackgroundColor(Color.parseColor("#1993FF"))
} else {
CardViewDay.setCardBackgroundColor(Color.parseColor("#98EA88"))
}
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.rc_item_progress, parent, false)//Создаем(надуваем) list_item
return Holder(view)//Через Holder возврощаем view
}
override fun onBindViewHolder(holder: Holder, position: Int) {
val view = holder.bind(getItem(position))//Заполняем по позиции карточку
}
//Comparator - сравнивает старый список и новый и если что-то изменилось, то работает с конкретным изменением списке, а не весь список переписывает
class Comparator : DiffUtil.ItemCallback<ProgressModel>() {
override fun areItemsTheSame(
oldItem: ProgressModel,
newItem: ProgressModel
): Boolean {//Тут лучше всего сравнивать по id//oldItem - элементы старого списка, newItem - элементы нового списка//Возврощает Boolean, тоесть есть изменения или нет
return oldItem.id == newItem.id//Сравниваем полностью весь список новы и старый, по очередно по одной карточке и по элементно, то есть нулевой элемент, первый, второй и т.д.. Но лучше сравнивать по id списки, а не просто весь список, так как это эфективнее, так как id уникальный(oldItem.id == newItem.id)
}
override fun areContentsTheSame(
oldItem: ProgressModel,
newItem: ProgressModel
): Boolean {//Утут нужно сравнивать весь спсок старых элементов и новых
return oldItem == newItem//Сравниваем полностью весь список новы и старый
}
}
}

View File

@ -0,0 +1,6 @@
package com.example.rehabilitation.Progress
data class ProgressListModel(
val search_check_sport: List<ProgressModel>,
)

View File

@ -0,0 +1,12 @@
package com.example.rehabilitation.Progress
data class ProgressModel(
val number: Int,
val id: Int,
val day: String,
var count_workout_max: Int,
var count: Int,
val finish: Int,
)

View File

@ -0,0 +1,6 @@
package com.example.rehabilitation.Questionnaire.Model
data class AfterLookModel(
val after_look: Int,
)

View File

@ -0,0 +1,6 @@
package com.example.rehabilitation.Questionnaire.Model
data class AfterQuestionnaireMessage(
val message: Int,
)

View File

@ -0,0 +1,17 @@
package com.example.rehabilitation.Questionnaire.Model
data class AfterQuestionnaireModel(
val one: Int,
val two: Int,
val three: Int,
val four: Int,
val five: Int,
val six: Int,
val seven: Int,
val eight: Int,
val nine: Int,
val ten: Int,
val eleven: Int,
val twelve: Int,
)

View File

@ -0,0 +1,6 @@
package com.example.rehabilitation.Questionnaire.Model
data class BeforeLookModel(
val before_look: Int,
)

View File

@ -0,0 +1,6 @@
package com.example.rehabilitation.Questionnaire.Model
data class BeforeQuestionnaireMessage(
val message: Int,
)

View File

@ -0,0 +1,14 @@
package com.example.rehabilitation.Questionnaire.Model
data class BeforeQuestionnaireModel(
val one: Int,
val two: Int,
val three: Int,
val four: Int,
val five: Int,
val six: Int,
val seven: Int,
val eight: Int,
val nine: Int,
)

View File

@ -0,0 +1,6 @@
package com.example.rehabilitation.Questionnaire.Model
data class QuestionnaireModel(
val massage: String,
)

View File

@ -0,0 +1,639 @@
package com.example.rehabilitation.Questionnaire.QuestionnaireFragment
import android.app.Activity
import android.app.AlertDialog
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.fragment.app.activityViewModels
import 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.Questionnaire.Model.AfterLookModel
import com.example.rehabilitation.Questionnaire.Model.AfterQuestionnaireModel
import com.example.rehabilitation.R
import com.example.rehabilitation.Retrofit.PatientApi
import com.example.rehabilitation.Sport.SceduleFragment
import com.example.rehabilitation.databinding.FragmentQAfterBinding
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 QAfterFragment : Fragment() {
private lateinit var binding: FragmentQAfterBinding
private lateinit var patientApi: PatientApi
private lateinit var timer: Timer
val prefPatientConclusion = ConclusionPref()
private val modelPatient: PatientViewModel by activityViewModels()//Инициализировали класс
var one = 100
var two = 100
var three = 100
var four =100
var five =100
var six =100
var seven = 100
var eight = 100
var nine = 100
var ten =100
var eleven = 100
var twelve = 100
//Класс проверки интеренета
val enternetCheck = EnternetCheck()
var AfterLook: AfterLookModel? = null
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentQAfterBinding.inflate(layoutInflater, container, false)
return binding.root
}
companion object {
fun newInstance() = QAfterFragment()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
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()
//Выход
binding.btnBack.setOnClickListener {
activity?.supportFragmentManager?.beginTransaction()
?.replace(R.id.placeHolderFragment, SceduleFragment.newInstance())?.commit()
}
//Сохраняем результат
binding.btnSaveQuestionnaire.setOnClickListener {
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){
AlertDialog.Builder(requireContext())
.setTitle("Анкета")
.setMessage("Уверены ли Вы в выбранных ответах на вопросы анкеты? Халатное отношение к вопросам анкеты приведет к блокировке комплекса")
.setNeutralButton("Подтвердить") { dialog, whichButton ->
addQuestionAfter()
}
.setNegativeButton("Отмена") { dialog, whichButton ->
}
.show()
}
else if(one >=6 && three == 0 && six == 1 && eight == 1 && eleven == 1){
AlertDialog.Builder(requireContext())
.setTitle("Анкета")
.setMessage("Уверены ли Вы в выбранных ответах на вопросы анкеты? Халатное отношение к вопросам анкеты приведет к паузе комплекса")
.setNeutralButton("Подтвердить") { dialog, whichButton ->
addQuestionAfter()
}
.setNegativeButton("Отмена") { dialog, whichButton ->
}
.show()
}
else{
addQuestionAfter()
}
} else {
Toast(requireContext()).showCustomInfoToast(
"Не все пункты выбраны",
requireActivity()
)
}
}
// 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() {
val item = AfterQuestionnaireModel(
one,
two,
three,
four,
five,
six,
seven,
eight,
nine,
ten,
eleven,
twelve,
)
AfterQuestionnaire(item)
}
//Инициализация подлючения к серверу
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)
}
//Отправка анкеты ПОСЛЕ
fun AfterQuestionnaire(item:AfterQuestionnaireModel) {
if (enternetCheck.isOnline(requireContext())) {
initRetrofit()
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
CoroutineScope(Dispatchers.IO).launch {
val QA = patientApi.AddAfterQuestionnaire2("Bearer $Tokens",item)
requireActivity().runOnUiThread {
//Фиксируем полученные данные
val List = QA.body()
val Nice = QA.isSuccessful
val Code = QA.code()
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())
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)
}
}
}
} 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() {
buttenAdd1()
buttenAdd2()
buttenAdd3()
buttenAdd4()
buttenAdd5()
buttenAdd6()
buttenAdd7()
buttenAdd8()
buttenAdd9()
buttenAdd10()
buttenAdd11()
buttenAdd12()
}
private fun buttenAdd1() {
binding.CVQ10.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 0
}
binding.CVQ11.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 1
}
binding.CVQ12.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 2
}
binding.CVQ13.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 3
}
binding.CVQ14.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ110.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 4
}
binding.CVQ15.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ110.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 5
}
binding.CVQ16.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ110.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 6
}
binding.CVQ17.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ110.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 7
}
binding.CVQ18.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ110.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 8
}
binding.CVQ19.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ110.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 9
}
binding.CVQ110.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ110.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
one = 10
}
}
private fun buttenAdd2() {
binding.CVQyes2.setOnClickListener {
binding.CVQyes2.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno2.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
two = 1
}
binding.CVQno2.setOnClickListener {
binding.CVQyes2.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno2.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
two = 0
}
}
private fun buttenAdd3() {
binding.CVQyes3.setOnClickListener {
Log.d("CVQyes3", "CVQyes3")
binding.CVQyes3.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno3.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
three = 1
}
binding.CVQno3.setOnClickListener {
binding.CVQyes3.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno3.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
three = 0
}
}
private fun buttenAdd4() {
binding.CVQyes4.setOnClickListener {
binding.CVQyes4.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno4.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
four = 1
}
binding.CVQno4.setOnClickListener {
binding.CVQyes4.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno4.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
four = 0
}
}
private fun buttenAdd5() {
binding.CVQyes5.setOnClickListener {
binding.CVQyes5.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno5.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
five = 1
}
binding.CVQno5.setOnClickListener {
binding.CVQyes5.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno5.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
five = 0
}
}
private fun buttenAdd6() {
binding.CVQyes6.setOnClickListener {
binding.CVQyes6.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno6.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
six = 1
}
binding.CVQno6.setOnClickListener {
binding.CVQyes6.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno6.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
six =0
}
}
private fun buttenAdd7() {
binding.CVQyes7.setOnClickListener {
binding.CVQyes7.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno7.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
seven = 1
}
binding.CVQno7.setOnClickListener {
binding.CVQyes7.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno7.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
seven =0
}
}
private fun buttenAdd8() {
binding.CVQyes8.setOnClickListener {
binding.CVQyes8.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno8.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
eight = 1
}
binding.CVQno8.setOnClickListener {
binding.CVQyes8.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno8.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
eight = 0
}
}
private fun buttenAdd9() {
binding.CVQyes9.setOnClickListener {
binding.CVQyes9.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno9.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
nine = 1
}
binding.CVQno9.setOnClickListener {
binding.CVQyes9.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno9.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
nine = 0
}
}
private fun buttenAdd10() {
binding.CVQyes10.setOnClickListener {
binding.CVQyes10.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
ten = 1
}
binding.CVQno10.setOnClickListener {
binding.CVQyes10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno10.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
ten = 0
}
}
private fun buttenAdd11() {
binding.CVQyes11.setOnClickListener {
binding.CVQyes11.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
eleven = 1
}
binding.CVQno11.setOnClickListener {
binding.CVQyes11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno11.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
eleven = 0
}
}
private fun buttenAdd12() {
binding.CVQyes12.setOnClickListener {
binding.CVQyes12.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
twelve = 1
}
binding.CVQno12.setOnClickListener {
binding.CVQyes12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno12.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
twelve = 0
}
}
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) {
// val QB = questionnaire?.edit()
// QB?.putString("QA", date)
// QB?.apply()
// }
}

View File

@ -0,0 +1,612 @@
package com.example.rehabilitation.Questionnaire.QuestionnaireFragment
import android.app.AlertDialog
import android.content.Intent
import android.graphics.Color
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 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.Questionnaire.Model.AfterLookModel
import com.example.rehabilitation.Questionnaire.Model.BeforeLookModel
import com.example.rehabilitation.Questionnaire.Model.BeforeQuestionnaireModel
import com.example.rehabilitation.R
import com.example.rehabilitation.Retrofit.PatientApi
import com.example.rehabilitation.Sport.SceduleFragment
import com.example.rehabilitation.databinding.FragmentQBeforeBinding
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.Timer
import kotlin.concurrent.fixedRateTimer
class QBeforeFragment : Fragment() {
private lateinit var binding: FragmentQBeforeBinding
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()
var one = 100
var two = 100
var three = 100
var four = 100
var five = 100
var six = 100
var seven = 100
var eight = 100
var nine = 100
var calendareDate = false
var countDay = 0
//Для разрешения проверки количества дней
var lookDateSportMax = false
//Класс проверки интеренета
val enternetCheck = EnternetCheck()
var BeforeLook: BeforeLookModel? = null
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
// Inflate the layout for this fragment
binding = FragmentQBeforeBinding.inflate(layoutInflater, container, false)
return binding.root
}
companion object {
fun newInstance() = QBeforeFragment()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
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 {
activity?.supportFragmentManager?.beginTransaction()
?.replace(R.id.placeHolderFragment, SceduleFragment.newInstance())?.commit()
}
//Сохраняем результат
binding.btnSaveQuestionnaire.setOnClickListener {
if (one != 100 && two != 100 && three != 100 && four != 100 && five != 100 && six != 100 && seven != 100 && eight != 100 && nine != 100) {
if(one >= 6) {
AlertDialog.Builder(requireContext())
.setTitle("Анкета")
.setMessage("Уверены ли Вы в выбранных ответах на вопросы анкеты? Халатное отношение к вопросам анкеты приведет к блокировке комплекса")
.setNeutralButton("Подтвердить") { dialog, whichButton ->
addQuestionnaire()
}
.setNegativeButton("Отмена") { dialog, whichButton ->
}.show()
}
else if(four == 1 && five == 1 && six == 1 && seven == 1 && nine == 1){
AlertDialog.Builder(requireContext())
.setTitle("Анкета")
.setMessage("Уверены ли Вы в выбранных ответах на вопросы анкеты? Халатное отношение к вопросам анкеты приведет к паузе комплекса")
.setNeutralButton("Подтвердить") { dialog, whichButton ->
addQuestionnaire()
}
.setNegativeButton("Отмена") { dialog, whichButton ->
}.show()
}
else{
addQuestionnaire()
}
} else {
Toast(requireContext()).showCustomInfoToast(
"Не все пункты выбраны",
requireActivity()
)
}
}
// fixedRateTimer("timer", false, 0, 10000) {
// activity?.runOnUiThread {
//
// }
// }
}
//Функция
fun addQuestionnaire(){
val item = BeforeQuestionnaireModel(
one,
two,
three,
four,
five,
six,
seven,
eight,
nine,
)
BeforeQuestionnaire(item)
}
//Инициализация подлючения к серверу
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)
}
//Отправка запроса
fun BeforeQuestionnaire(item: BeforeQuestionnaireModel) {
if (enternetCheck.isOnline(requireContext())) {
initRetrofit()
val Tokens = prefPatientConclusion.conclusionToken(requireContext())
CoroutineScope(Dispatchers.IO).launch {
val QA = patientApi.AddBeforeQuestionnaire2("Bearer $Tokens",item)
requireActivity().runOnUiThread {
//Фиксируем полученные данные
val List = QA.body()
val Nice = QA.isSuccessful
val Code = QA.code()
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)
}
}
}
} 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() {
buttenAdd1()
buttenAdd1_2()
buttenAdd2()
buttenAdd3()
buttenAdd4()
buttenAdd5()
buttenAdd6()
buttenAdd7()
buttenAdd8()
buttenAdd9()
}
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() {
binding.CVQyes1.setOnClickListener {
binding.CLQ112.visibility = View.VISIBLE
binding.CVQyes1.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno1.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
}
binding.CVQno1.setOnClickListener {
binding.CLQ112.visibility = View.GONE
binding.CVQyes1.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno1.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
one = 0
}
}
private fun buttenAdd1_2() {
binding.CVQ10.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 0
}
binding.CVQ11.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 1
}
binding.CVQ12.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 2
}
binding.CVQ13.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 3
}
binding.CVQ14.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ110.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 4
}
binding.CVQ15.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ110.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 5
}
binding.CVQ16.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ110.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 6
}
binding.CVQ17.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ110.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 7
}
binding.CVQ18.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ110.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 8
}
binding.CVQ19.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQ110.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
one = 9
}
binding.CVQ110.setOnClickListener {
binding.CVQ10.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ11.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ12.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ13.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ14.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ15.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ16.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ17.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ18.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ19.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQ110.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
one = 10
}
}
private fun buttenAdd2() {
binding.CVQyes2.setOnClickListener {
binding.CVQyes2.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno2.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
two = 1
}
binding.CVQno2.setOnClickListener {
binding.CVQyes2.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno2.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
two = 0
}
}
private fun buttenAdd3() {
binding.CVQyes3.setOnClickListener {
binding.CVQyes3.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno3.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
three = 1
}
binding.CVQno3.setOnClickListener {
binding.CVQyes3.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno3.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
three = 0
}
}
private fun buttenAdd4() {
binding.CVQyes4.setOnClickListener {
binding.CVQyes4.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno4.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
four = 1
}
binding.CVQno4.setOnClickListener {
binding.CVQyes4.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno4.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
four = 0
}
}
private fun buttenAdd5() {
binding.CVQyes5.setOnClickListener {
binding.CVQyes5.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno5.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
five = 1
}
binding.CVQno5.setOnClickListener {
binding.CVQyes5.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno5.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
five = 0
}
}
private fun buttenAdd6() {
binding.CVQyes6.setOnClickListener {
binding.CVQyes6.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno6.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
six = 1
}
binding.CVQno6.setOnClickListener {
binding.CVQyes6.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno6.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
six = 0
}
}
private fun buttenAdd7() {
binding.CVQyes7.setOnClickListener {
binding.CVQyes7.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno7.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
seven = 1
}
binding.CVQno7.setOnClickListener {
binding.CVQyes7.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno7.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
seven = 0
}
}
private fun buttenAdd8() {
binding.CVQyes8.setOnClickListener {
binding.CVQyes8.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno8.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
eight = 1
}
binding.CVQno8.setOnClickListener {
binding.CVQyes8.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno8.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
eight = 0
}
}
private fun buttenAdd9() {
binding.CVQyes9.setOnClickListener {
binding.CVQyes9.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
binding.CVQno9.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
nine = 1
}
binding.CVQno9.setOnClickListener {
binding.CVQyes9.setCardBackgroundColor(Color.parseColor("#A8A8A8"))
binding.CVQno9.setCardBackgroundColor(Color.parseColor("#3AB0FF"))
nine = 0
}
}
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()
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More