content
stringlengths
0
13M
path
stringlengths
4
263
contentHash
stringlengths
1
10
package com.example.controlpivot.data.local.datasource import com.example.controlpivot.data.local.model.MachinePendingDelete import com.example.controlpivot.utils.Resource interface MachinePendingDeleteDatasource { suspend fun savePendingDelete(machinesPending: MachinePendingDelete): Resource<Int> suspend fun getPendingDelete(): Resource<MachinePendingDelete> }
pivot-control/app/src/main/java/com/example/controlpivot/data/local/datasource/MachinePendingDeleteDatasource.kt
3014156284
package com.example.controlpivot.data.local.datasource import com.example.controlpivot.R import com.example.controlpivot.data.local.DataObjectStorage import com.example.controlpivot.data.local.model.MachinePendingDelete import com.example.controlpivot.utils.Message import com.example.controlpivot.utils.Resource import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.first import kotlinx.coroutines.withContext class MachinePendingDeleteDatasourceImpl( private val machinePendingDeleteStorage: DataObjectStorage<MachinePendingDelete> ): MachinePendingDeleteDatasource { override suspend fun savePendingDelete(machinesPending: MachinePendingDelete): Resource<Int> = withContext(Dispatchers.IO) { machinePendingDeleteStorage.saveData(machinesPending) } override suspend fun getPendingDelete(): Resource<MachinePendingDelete> = withContext(Dispatchers.IO) { try { machinePendingDeleteStorage.getData().first() } catch (e: Exception) { Resource.Error(Message.StringResource(R.string.get_pending_delete_error)) } } }
pivot-control/app/src/main/java/com/example/controlpivot/data/local/datasource/MachinePendingDeleteDatasourceImpl.kt
469347541
package com.example.controlpivot.data.local.datasource import com.example.controlpivot.data.local.model.PivotMachineEntity import com.example.controlpivot.utils.Resource import kotlinx.coroutines.flow.Flow interface PivotMachineLocalDatasource { suspend fun addPivotMachine(machine: PivotMachineEntity): Resource<Int> suspend fun getPivotMachine(id: Int): Resource<PivotMachineEntity> fun getPivotMachineAsync(id: Int): Flow<Resource<PivotMachineEntity>> suspend fun getPivotMachineByRemoteId(remoteId: Int): Resource<PivotMachineEntity> suspend fun getPivotMachines(): Resource<List<PivotMachineEntity>> fun getPivotMachines(query: String): Flow<Resource<List<PivotMachineEntity>>> suspend fun upsertPivotMachines(machines: List<PivotMachineEntity>): Resource<Int> suspend fun updatePivotMachine(machine: PivotMachineEntity): Resource<Int> suspend fun deletePivotMachine(machine: PivotMachineEntity): Resource<Int> }
pivot-control/app/src/main/java/com/example/controlpivot/data/local/datasource/PivotMachineLocalDatasource.kt
544351933
package com.example.controlpivot.data.local.datasource import com.example.controlpivot.data.common.model.Session import com.example.controlpivot.utils.Resource interface SessionLocalDatasource { suspend fun saveSession(session: Session): Resource<Int> suspend fun getSession(): Resource<Session> }
pivot-control/app/src/main/java/com/example/controlpivot/data/local/datasource/SessionLocalDatasource.kt
2773796556
package com.example.controlpivot.data.local.datasource import com.example.controlpivot.data.common.model.Climate import com.example.controlpivot.utils.Resource import kotlinx.coroutines.flow.Flow interface ClimateLocalDatasource { suspend fun addClimate(climate: Climate): Resource<Int> suspend fun getClimate(id: Int): Resource<Climate> suspend fun getClimatesByIdPivot(id: Int): Resource<List<Climate>> fun getClimates(query: String): Flow<Resource<List<Climate>>> suspend fun upsertClimates(climates: List<Climate>): Resource<Int> suspend fun updateClimate(climate: Climate): Resource<Int> suspend fun deleteClimate(climate: Climate): Resource<Int> }
pivot-control/app/src/main/java/com/example/controlpivot/data/local/datasource/ClimateLocalDatasource.kt
1889629380
package com.example.controlpivot.data.local.datasource import com.example.controlpivot.R import com.example.controlpivot.data.local.database.dao.PivotMachineDao import com.example.controlpivot.data.local.model.PivotMachineEntity import com.example.controlpivot.utils.Message import com.example.controlpivot.utils.Resource import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext class PivotMachineLocalDatasourceImpl( private val pivotMachineDao: PivotMachineDao ): PivotMachineLocalDatasource { override suspend fun addPivotMachine(machine: PivotMachineEntity): Resource<Int> = withContext(Dispatchers.IO) { val result = pivotMachineDao.insert(machine) if (result > 0L) return@withContext Resource.Success(result.toInt()) Resource.Error( Message.StringResource(R.string.add_machine_error) ) } override suspend fun getPivotMachine(id: Int): Resource<PivotMachineEntity> = withContext(Dispatchers.IO) { val result = pivotMachineDao.get(id) if (result != null) return@withContext Resource.Success(result) Resource.Error( Message.StringResource(R.string.machine_not_found) ) } override fun getPivotMachineAsync(id: Int): Flow<Resource<PivotMachineEntity>> = flow { pivotMachineDao.getPivotMachineAsync(id).onEach { if (it == null) emit(Resource.Error(Message.StringResource(R.string.machine_not_found))) else emit(Resource.Success(it)) }.collect() } override suspend fun getPivotMachineByRemoteId(remoteId: Int): Resource<PivotMachineEntity> = withContext(Dispatchers.IO) { val result = pivotMachineDao.getPivotMachine(remoteId) if (result != null) return@withContext Resource.Success(result) Resource.Error( Message.StringResource(R.string.machine_not_found) ) } override suspend fun getPivotMachines(): Resource<List<PivotMachineEntity>> = withContext(Dispatchers.IO) { val result = pivotMachineDao.getAllMachines() if (result != null) return@withContext Resource.Success(result) Resource.Error( Message.StringResource(R.string.get_machines_error) ) } override fun getPivotMachines(query: String): Flow<Resource<List<PivotMachineEntity>>> = flow { pivotMachineDao.getAll(query).onEach { emit(Resource.Success(it)) }.catch { Resource.Error<List<PivotMachineEntity>>( Message.StringResource(R.string.get_machines_error) ) }.collect() } override suspend fun upsertPivotMachines(machines: List<PivotMachineEntity>): Resource<Int> = synchronized(this) { runBlocking(Dispatchers.IO) { pivotMachineDao.getAll().forEach { machine -> if (machines.find { it.remoteId == machine.id } == null) pivotMachineDao.delete(machine) } val result = pivotMachineDao.upsertAll(machines) if (result.isEmpty() && machines.isNotEmpty()) return@runBlocking Resource.Error<Int>( Message.StringResource(R.string.update_machines_error) ) Resource.Success(result.size) } } override suspend fun updatePivotMachine(machine: PivotMachineEntity): Resource<Int> = withContext(Dispatchers.IO) { val result = pivotMachineDao.update(machine) if (result > 0) return@withContext Resource.Success(result) Resource.Error( Message.StringResource(R.string.update_machine_error) ) } override suspend fun deletePivotMachine(machine: PivotMachineEntity): Resource<Int> = withContext(Dispatchers.IO) { val result = pivotMachineDao.delete(machine) if (result > 0) return@withContext Resource.Success(result) Resource.Error( Message.StringResource(R.string.delete_machine_error) ) } }
pivot-control/app/src/main/java/com/example/controlpivot/data/local/datasource/PivotMachineLocalDatasourceImpl.kt
1849567105
package com.example.controlpivot.data.local.datasource import com.example.controlpivot.R import com.example.controlpivot.data.common.model.Session import com.example.controlpivot.data.local.DataObjectStorage import com.example.controlpivot.utils.Message import com.example.controlpivot.utils.Resource import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.first import kotlinx.coroutines.withContext class SessionLocalDatasourceImpl( private val sessionStorage: DataObjectStorage<Session>, ) : SessionLocalDatasource { override suspend fun saveSession(session: Session): Resource<Int> = withContext(Dispatchers.IO) { sessionStorage.saveData(session) } override suspend fun getSession(): Resource<Session> = withContext(Dispatchers.IO) { try { sessionStorage.getData().first() } catch (e: Exception) { Resource.Error(Message.StringResource(R.string.get_session_error)) } } }
pivot-control/app/src/main/java/com/example/controlpivot/data/local/datasource/SessionLocalDatasourceImpl.kt
1986973309
package com.example.controlpivot.data.local.datasource import com.example.controlpivot.R import com.example.controlpivot.data.common.model.Climate import com.example.controlpivot.data.local.database.dao.ClimateDao import com.example.controlpivot.utils.Message import com.example.controlpivot.utils.Resource import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext class ClimateLocalDatasourceImpl( private val climateDao: ClimateDao ): ClimateLocalDatasource { override suspend fun addClimate(climate: Climate): Resource<Int> = withContext(Dispatchers.IO) { val result = climateDao.insert(climate) if (result > 0L) return@withContext Resource.Success(result.toInt()) Resource.Error( Message.StringResource(R.string.add_climate_error) ) } override suspend fun getClimate(id: Int): Resource<Climate> = withContext(Dispatchers.IO) { val result = climateDao.get(id) if (result != null) return@withContext Resource.Success(result) Resource.Error( Message.StringResource(R.string.climate_not_found) ) } override suspend fun getClimatesByIdPivot(id: Int): Resource<List<Climate>> = withContext(Dispatchers.IO) { val result = climateDao.getByIdPivot(id) if (result != null) return@withContext Resource.Success(result) Resource.Error( Message.StringResource(R.string.climate_not_found) ) } override fun getClimates(query: String): Flow<Resource<List<Climate>>> = flow { climateDao.getAll(query).onEach { emit(Resource.Success(it)) }.catch { Resource.Error<List<Climate>>( Message.StringResource(R.string.get_climates_error) ) }.collect() } override suspend fun upsertClimates(climates: List<Climate>): Resource<Int> = synchronized(this) { runBlocking(Dispatchers.IO) { val result = climateDao.upsertAll(climates) if (result.isEmpty() && climates.isNotEmpty()) return@runBlocking Resource.Error<Int>( Message.StringResource(R.string.update_climates_error) ) Resource.Success(result.size) } } override suspend fun updateClimate(climate: Climate): Resource<Int> = withContext(Dispatchers.IO) { val result = climateDao.update(climate) if (result > 0) return@withContext Resource.Success(result) Resource.Error( Message.StringResource(R.string.update_climate_error) ) } override suspend fun deleteClimate(climate: Climate): Resource<Int> = withContext(Dispatchers.IO) { val result = climateDao.delete(climate) if (result > 0) return@withContext Resource.Success(result) Resource.Error( Message.StringResource(R.string.delete_climate_error) ) } }
pivot-control/app/src/main/java/com/example/controlpivot/data/local/datasource/ClimateLocalDatasourceImpl.kt
331163178
package com.example.controlpivot.data.local.datasource import com.example.controlpivot.data.local.model.PivotControlEntity import com.example.controlpivot.data.local.model.SectorControl import com.example.controlpivot.utils.Resource import kotlinx.coroutines.flow.Flow interface PivotControlLocalDatasource { suspend fun addPivotControl(pivot: PivotControlEntity): Resource<Int> suspend fun upsertSectorControl(sectorControl: SectorControl) : Resource<Int> suspend fun getPivotControl(id: Int): Resource<PivotControlEntity> fun getPivotControls(query: String): Flow<Resource<List<PivotControlEntity>>> fun getSectorControls(query: String): Flow<Resource<List<SectorControl>>> fun getSectorsForPivot(query: Int): Flow<Resource<List<SectorControl>>> suspend fun upsertPivotControls(pivots: List<PivotControlEntity>): Resource<Int> suspend fun updatePivotControl(pivot: PivotControlEntity): Resource<Int> suspend fun deletePivotControl(pivot: PivotControlEntity): Resource<Int> }
pivot-control/app/src/main/java/com/example/controlpivot/data/local/datasource/PivotControlLocalDatasource.kt
4272110003
package com.example.controlpivot.data.local.database.dao import androidx.room.Dao import androidx.room.Query import com.example.controlpivot.data.local.model.PivotControlEntity import com.example.controlpivot.data.local.model.SectorControl import kotlinx.coroutines.flow.Flow @Dao abstract class SectorControlDao: BaseDao<SectorControl>() { override fun getTableName(): String = "sector_controls" @Query("SELECT * FROM sector_control WHERE sector_control_id = :id ") abstract fun getSectorsForPivot(id: Int): Flow<List<SectorControl>> @Query("SELECT * FROM sector_control WHERE sector_control_id LIKE '%' || :query || '%' ORDER BY sector_control_id ASC") abstract fun getAllSectors(query: String): Flow<List<SectorControl>> }
pivot-control/app/src/main/java/com/example/controlpivot/data/local/database/dao/SectorControlDao.kt
4182577339
package com.example.controlpivot.data.local.database.dao import androidx.room.Dao import androidx.room.Query import com.example.controlpivot.data.common.model.Climate import com.example.controlpivot.data.local.database.dao.BaseDao import kotlinx.coroutines.flow.Flow @Dao abstract class ClimateDao: BaseDao<Climate>() { override fun getTableName(): String = "climatic_var" @Query("SELECT * FROM climatic_var WHERE id_pivot LIKE '%' || :query || '%' ORDER BY id_pivot ASC") abstract fun getAll(query: String): Flow<List<Climate>> @Query("SELECT * FROM climatic_var WHERE id_pivot = :id ") abstract fun getByIdPivot(id: Int): List<Climate> }
pivot-control/app/src/main/java/com/example/controlpivot/data/local/database/dao/ClimateDao.kt
2757833967
package com.example.controlpivot.data.local.database.dao import androidx.room.Dao import androidx.room.Delete import androidx.room.Insert import androidx.room.OnConflictStrategy.Companion.REPLACE import androidx.room.RawQuery import androidx.room.Update import androidx.sqlite.db.SimpleSQLiteQuery import androidx.sqlite.db.SupportSQLiteQuery @Dao abstract class BaseDao<T> { protected abstract fun getTableName(): String @Insert(onConflict = REPLACE) abstract suspend fun insert(item: T): Long @Insert(onConflict = REPLACE) abstract suspend fun upsertAll(items: List<T>): List<Long> @RawQuery protected abstract fun query(query: SupportSQLiteQuery): List<T> fun getAll(): List<T> = query(SimpleSQLiteQuery("SELECT * FROM ${getTableName()}")) fun get(id: Int): T? = query( SimpleSQLiteQuery( "SELECT * FROM ${getTableName()} WHERE id = $id" ) ).firstOrNull() @Update abstract suspend fun update(item: T): Int @Delete abstract suspend fun delete(item : T): Int }
pivot-control/app/src/main/java/com/example/controlpivot/data/local/database/dao/BaseDao.kt
1217766121
package com.example.controlpivot.data.local.database.dao import androidx.room.Dao import androidx.room.Query import com.example.controlpivot.data.local.model.PivotControlEntity import kotlinx.coroutines.flow.Flow @Dao abstract class PivotControlDao: BaseDao<PivotControlEntity>() { override fun getTableName(): String = "pivot_control" @Query("SELECT * FROM pivot_control WHERE idPivot LIKE '%' || :query || '%' ORDER BY idPivot ASC") abstract fun getAll(query: String): Flow<List<PivotControlEntity>> }
pivot-control/app/src/main/java/com/example/controlpivot/data/local/database/dao/PivotControlDao.kt
1229274609
package com.example.controlpivot.data.local.database.dao import androidx.room.Dao import androidx.room.Query import com.example.controlpivot.data.local.model.PivotMachineEntity import kotlinx.coroutines.flow.Flow @Dao abstract class PivotMachineDao: BaseDao<PivotMachineEntity>() { override fun getTableName(): String = "pivot_machines" @Query( "SELECT * FROM pivot_machines WHERE name LIKE " + "'%' || :query || '%' OR " + "location LIKE '%' || :query || '%' OR " + "endowment LIKE '%' || :query || '%'OR " + "flow LIKE '%' || :query || '%' OR " + "pressure LIKE '%' || :query || '%' OR " + "length LIKE '%' || :query || '%' OR " + "area LIKE '%' || :query || '%' OR " + "power LIKE '%' || :query || '%' OR " + "speed LIKE '%' || :query || '%' OR " + "efficiency LIKE '%' || :query || '%' ORDER BY name ASC") abstract fun getAll(query: String): Flow<List<PivotMachineEntity>> @Query("SELECT * FROM pivot_machines ORDER BY name ASC") abstract fun getAllMachines(): List<PivotMachineEntity> @Query("SELECT * FROM pivot_machines WHERE remote_id=:remoteId") abstract fun getPivotMachine(remoteId: Int): PivotMachineEntity? @Query("SELECT * FROM pivot_machines WHERE id=:id") abstract fun getPivotMachineAsync(id: Int): Flow<PivotMachineEntity?> @Query("DELETE FROM pivot_machines") abstract suspend fun deleteAll(): Int }
pivot-control/app/src/main/java/com/example/controlpivot/data/local/database/dao/PivotMachineDao.kt
1149077397
package com.example.controlpivot.data.local.database import androidx.room.Database import androidx.room.RoomDatabase import androidx.room.TypeConverters import com.example.controlpivot.data.common.model.Climate import com.example.controlpivot.data.local.model.PivotControlEntity import com.example.controlpivot.data.local.model.SectorControl import com.example.controlpivot.data.local.database.dao.ClimateDao import com.example.controlpivot.data.local.database.dao.PivotControlDao import com.example.controlpivot.data.local.database.dao.PivotMachineDao import com.example.controlpivot.data.local.database.dao.SectorControlDao import com.example.controlpivot.data.local.model.PivotMachineEntity import com.example.controlpivot.utils.Converters @Database( entities = [ PivotMachineEntity::class, Climate::class, PivotControlEntity::class, SectorControl::class ], version = 1, exportSchema = false ) @TypeConverters(Converters::class) abstract class AppDatabase : RoomDatabase() { abstract fun pivotMachineDao(): PivotMachineDao abstract fun climateDao(): ClimateDao abstract fun pivotControlDao(): PivotControlDao abstract fun sectorControlDao(): SectorControlDao }
pivot-control/app/src/main/java/com/example/controlpivot/data/local/database/AppDatabase.kt
43821114
package com.example.controlpivot.data.local import android.util.Log import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import com.example.controlpivot.AppConstants import com.example.controlpivot.R import com.example.controlpivot.utils.Message import com.example.controlpivot.utils.Resource import com.google.gson.Gson import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.map import java.lang.reflect.Type class DataObjectStorage<T> constructor( private val gson: Gson, private val type: Type, private val dataStore: DataStore<Preferences>, private val preferenceKey: Preferences.Key<String>, ) { suspend fun saveData(data: T): Resource<Int> { try { dataStore.edit { val jsonString = gson.toJson(data, type) it[preferenceKey] = jsonString } } catch (e: Exception) { return Resource.Error(Message.StringResource(R.string.save_data_error)) } return Resource.Success(0) } fun getData(): Flow<Resource<T>> = flow { dataStore.data.map { preferences -> val jsonString = preferences[preferenceKey]?:AppConstants.EMPTY_JSON_STRING val elements = gson.fromJson<T>(jsonString, type) Log.d("TAG", elements.toString()) elements }.catch { emit(Resource.Error(Message.StringResource(R.string.retrieve_data_error))) }.collect { if (it == null) { emit(Resource.Error(Message.StringResource(R.string.retrieve_data_error))) } else emit(Resource.Success(it)) } } }
pivot-control/app/src/main/java/com/example/controlpivot/data/local/DataObjectStorage.kt
277208927
package com.example.controlpivot.data.local.model data class MachinePendingDelete( var listId: List<Int> = listOf(), )
pivot-control/app/src/main/java/com/example/controlpivot/data/local/model/MachinePendingDelete.kt
3029572555
package com.example.controlpivot.data.local.model import androidx.room.ColumnInfo import androidx.room.Entity import androidx.room.PrimaryKey import com.example.controlpivot.data.remote.model.PivotMachine @Entity(tableName = "pivot_machines") data class PivotMachineEntity( @PrimaryKey(autoGenerate = true) val id: Int = 0, @ColumnInfo(name = "remote_id") val remoteId: Int = Int.MAX_VALUE, @ColumnInfo(name = "name") val name: String = "", val location: String = "", val endowment: Double = 0.0, val flow: Double = 0.0, val pressure: Double = 0.0, val length: Double = 0.0, val area: Double = 0.0, val power: Double = 0.0, val speed: Double = 0.0, val efficiency: Double = 0.0, val isSave: Boolean = true, ) fun PivotMachine.toLocal() = PivotMachineEntity( id, id, name, location, endowment, flow, pressure, length, area, power, speed, efficiency )
pivot-control/app/src/main/java/com/example/controlpivot/data/local/model/PivotMachineEntity.kt
1774464975
package com.example.controlpivot.data.local.model import androidx.room.ColumnInfo import androidx.room.Entity import androidx.room.PrimaryKey @Entity(tableName = "pivot_control") data class PivotControlEntity( @PrimaryKey val id: Int, val idPivot: Int, val progress: Float, val isRunning: Boolean, val stateBomb: Boolean, val wayToPump: Boolean, val turnSense: Boolean, ) @Entity(tableName = "sector_control") data class SectorControl( @PrimaryKey val id: Int, @ColumnInfo(name = "sector_id") val sector_id: Int, val irrigateState: Boolean, val dosage: Int, val motorVelocity: Int, @ColumnInfo(name = "sector_control_id") val sector_control_id: Int )
pivot-control/app/src/main/java/com/example/controlpivot/data/local/model/PivotControlEntity.kt
3693948279
package com.example.controlpivot.data.common.model import androidx.room.Entity import androidx.room.PrimaryKey @Entity(tableName = "climatic_var") data class Climate( @PrimaryKey val id:Int, val id_pivot: Int, val referenceEvapo: Double, val cropEvapo: Double, val cropCoefficient: Double, val solarRadiation: Int, val windSpeed: Double, val atmoPressure: Double, val rainy: Int, val temp: Double, val RH: Double, val timestamp: String = "", )
pivot-control/app/src/main/java/com/example/controlpivot/data/common/model/Climate.kt
3582991337
package com.example.controlpivot.data.common.model import com.google.gson.annotations.SerializedName data class Session( @SerializedName("id") val id: Int, @SerializedName("name") val name: String, @SerializedName("user_name") val userName: String, @SerializedName("password") val password: String, @SerializedName("role") val role: String )
pivot-control/app/src/main/java/com/example/controlpivot/data/common/model/Session.kt
2748796486
package com.example.controlpivot.data.remote.datasource import com.example.controlpivot.R import com.example.controlpivot.data.common.model.Session import com.example.controlpivot.data.remote.MessageBody import com.example.controlpivot.data.remote.service.SessionApiService import com.example.controlpivot.ui.screen.login.Credentials import com.example.controlpivot.utils.Message import com.example.controlpivot.utils.Resource import com.google.gson.Gson import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext class SessionRemoteDatasourceImpl( private val sessionApiService: SessionApiService, ) : SessionRemoteDatasource { override suspend fun getSession( credentials: Credentials, ): Resource<Session> = withContext(Dispatchers.IO){ try { val response = sessionApiService.getSession( credentials ) if (response.isSuccessful) { return@withContext Resource.Success(response.body()!!.session) } Resource.Error( Message.DynamicString(Gson().fromJson( response.errorBody()?.charStream(), MessageBody::class.java ).message) ) }catch (e: Exception) { Resource.Error(Message.StringResource(R.string.login_error)) } } override suspend fun updateSession(credentials: Credentials): Resource<Session> = withContext(Dispatchers.IO){ try { val response = sessionApiService.updateSession( credentials ) if (response.isSuccessful) { return@withContext Resource.Success(response.body()!!) } Resource.Error(Message.StringResource(R.string.update_error)) }catch (e: Exception) { Resource.Error(Message.StringResource(R.string.update_error)) } } }
pivot-control/app/src/main/java/com/example/controlpivot/data/remote/datasource/SessionRemoteDatasourceImpl.kt
714052464
package com.example.controlpivot.data.remote.datasource import com.example.controlpivot.data.local.model.PivotControlEntity import com.example.controlpivot.data.local.model.SectorControl import com.example.controlpivot.data.remote.model.PivotControl import com.example.controlpivot.utils.Resource interface PivotControlRemoteDatasource { suspend fun getPivotControls(): Resource<List<PivotControl>> suspend fun getSectorControls(): Resource<List<SectorControl>> suspend fun insertPivotControl(pivot: PivotControlEntity): Resource<Int> suspend fun insertSectorControl(sector: SectorControl): Resource<Int> suspend fun updatePivotControl(pivot: PivotControlEntity): Resource<Int> suspend fun updateSectorControl(sector: SectorControl): Resource<Int> suspend fun deletePivotControl(pivotId: Int): Resource<Int> }
pivot-control/app/src/main/java/com/example/controlpivot/data/remote/datasource/PivotControlRemoteDatasource.kt
1970878351
package com.example.controlpivot.data.remote.datasource import com.example.controlpivot.data.remote.model.PivotMachine import com.example.controlpivot.utils.Resource interface PivotMachineRemoteDatasource { suspend fun getPivotMachines(): Resource<List<PivotMachine>> suspend fun insertPivotMachine(machine: PivotMachine): Resource<PivotMachine> suspend fun updatePivotMachine(machine: PivotMachine): Resource<Int> suspend fun deletePivotMachine(machineId: Int): Resource<Int> }
pivot-control/app/src/main/java/com/example/controlpivot/data/remote/datasource/PivotMachineRemoteDatasource.kt
1133698628
package com.example.controlpivot.data.remote.datasource import com.example.controlpivot.R import com.example.controlpivot.data.remote.MessageBody import com.example.controlpivot.data.remote.model.PivotMachine import com.example.controlpivot.data.remote.service.PivotMachineApiService import com.example.controlpivot.utils.Message import com.example.controlpivot.utils.Resource import com.google.gson.Gson import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext class PivotMachineRemoteDatasourceImpl( private val pivotMachineApiService: PivotMachineApiService ): PivotMachineRemoteDatasource { override suspend fun getPivotMachines(): Resource<List<PivotMachine>> = withContext(Dispatchers.IO) { try { val response = pivotMachineApiService.getPivotMachines() if (response.isSuccessful) return@withContext Resource.Success(response.body()!!) Resource.Error(Message.DynamicString( Gson().fromJson( response.errorBody()?.charStream(), MessageBody::class.java ).message )) }catch (e: Exception) { Resource.Error(Message.StringResource(R.string.fetch_machines_error)) } } override suspend fun insertPivotMachine(machine: PivotMachine): Resource<PivotMachine> = withContext(Dispatchers.IO) { try { val response = pivotMachineApiService.insertPivotMachine(machine) if (response.isSuccessful) return@withContext Resource.Success(response.body()!!) Resource.Error(Message.DynamicString(response.errorBody().toString())) }catch (e: Exception) { Resource.Error(Message.StringResource(R.string.add_machine_error)) } } override suspend fun updatePivotMachine(machine: PivotMachine): Resource<Int> = withContext(Dispatchers.IO) { try { val response = pivotMachineApiService.updatePivotMachine(machine) if (response.isSuccessful) return@withContext Resource.Success(response.body()!!) Resource.Error(Message.DynamicString(response.errorBody().toString())) }catch (e: Exception) { Resource.Error(Message.StringResource(R.string.update_machine_error)) } } override suspend fun deletePivotMachine(machineId: Int): Resource<Int> = withContext(Dispatchers.IO) { try { val response = pivotMachineApiService.deletePivotMachine(machineId) if (response.isSuccessful || response.code() == 404) return@withContext Resource.Success(response.body()!!) Resource.Error(Message.DynamicString(response.errorBody().toString())) }catch (e: Exception) { Resource.Error(Message.StringResource(R.string.delete_machine_error)) } } }
pivot-control/app/src/main/java/com/example/controlpivot/data/remote/datasource/PivotMachineRemoteDatasourceImpl.kt
1870393944
package com.example.controlpivot.data.remote.datasource import com.example.controlpivot.data.common.model.Climate import com.example.controlpivot.utils.Resource interface ClimateRemoteDatasource { suspend fun getClimates(): Resource<List<Climate>> suspend fun insertClimate(climate: Climate): Resource<Int> suspend fun updateClimate(climate: Climate): Resource<Int> suspend fun deleteClimate(climateId: Int): Resource<Int> }
pivot-control/app/src/main/java/com/example/controlpivot/data/remote/datasource/ClimateRemoteDatasource.kt
3374557398
package com.example.controlpivot.data.remote.datasource import com.example.controlpivot.R import com.example.controlpivot.data.common.model.Climate import com.example.controlpivot.data.remote.MessageBody import com.example.controlpivot.data.remote.service.ClimateApiService import com.example.controlpivot.utils.Message import com.example.controlpivot.utils.Resource import com.google.gson.Gson import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext class ClimateRemoteDatasourceImpl( private val climateApiService: ClimateApiService ): ClimateRemoteDatasource { override suspend fun getClimates(): Resource<List<Climate>> = withContext(Dispatchers.IO) { try { val response = climateApiService.getClimates() if (response.isSuccessful) return@withContext Resource.Success(response.body()!!) Resource.Error( Message.DynamicString( Gson().fromJson( response.errorBody()?.charStream(), MessageBody::class.java ).message )) }catch (e: Exception) { Resource.Error(Message.StringResource(R.string.fetch_climates_error)) } } override suspend fun insertClimate(climate: Climate): Resource<Int> = withContext(Dispatchers.IO) { try { val response = climateApiService.insertClimate(climate) if (response.isSuccessful) return@withContext Resource.Success(response.body()!!) Resource.Error(Message.DynamicString(response.errorBody().toString())) }catch (e: Exception) { Resource.Error(Message.StringResource(R.string.add_climate_error)) } } override suspend fun updateClimate(climate: Climate): Resource<Int> = withContext(Dispatchers.IO) { try { val response = climateApiService.updateClimate(climate) if (response.isSuccessful) return@withContext Resource.Success(response.body()!!) Resource.Error(Message.DynamicString(response.errorBody().toString())) }catch (e: Exception) { Resource.Error(Message.StringResource(R.string.update_climate_error)) } } override suspend fun deleteClimate(climateId: Int): Resource<Int> = withContext(Dispatchers.IO) { try { val response = climateApiService.deleteClimate(climateId) if (response.isSuccessful) return@withContext Resource.Success(response.body()!!) Resource.Error(Message.DynamicString(response.errorBody().toString())) }catch (e: Exception) { Resource.Error(Message.StringResource(R.string.delete_climate_error)) } } }
pivot-control/app/src/main/java/com/example/controlpivot/data/remote/datasource/ClimateRemoteDatasourceImpl.kt
1806045858
package com.example.controlpivot.data.remote.datasource import com.example.controlpivot.data.common.model.Session import com.example.controlpivot.ui.screen.login.Credentials import com.example.controlpivot.utils.Resource interface SessionRemoteDatasource { suspend fun getSession( credentials: Credentials ): Resource<Session> suspend fun updateSession( credentials: Credentials ): Resource<Session> }
pivot-control/app/src/main/java/com/example/controlpivot/data/remote/datasource/SessionRemoteDatasource.kt
3571800476
package com.example.controlpivot.data.remote.datasource import com.example.controlpivot.R import com.example.controlpivot.data.local.model.PivotControlEntity import com.example.controlpivot.data.remote.model.PivotControl import com.example.controlpivot.data.local.model.SectorControl import com.example.controlpivot.data.remote.MessageBody import com.example.controlpivot.data.remote.service.PivotControlApiService import com.example.controlpivot.data.remote.service.SectorControlApiService import com.example.controlpivot.utils.Message import com.example.controlpivot.utils.Resource import com.google.gson.Gson import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext class PivotControlRemoteDatasourceImpl( private val pivotControlApiService: PivotControlApiService, private val sectorControlApiService: SectorControlApiService ): PivotControlRemoteDatasource { override suspend fun getPivotControls(): Resource<List<PivotControl>> = withContext(Dispatchers.IO) { try { val response = pivotControlApiService.getPivotControls() if (response.isSuccessful) return@withContext Resource.Success(response.body()!!) Resource.Error( Message.DynamicString( Gson().fromJson( response.errorBody()?.charStream(), MessageBody::class.java ).message )) }catch (e: Exception) { Resource.Error(Message.StringResource(R.string.fetch_pivots_error)) } } override suspend fun getSectorControls(): Resource<List<SectorControl>> = withContext(Dispatchers.IO) { try { val response = sectorControlApiService.getSectorControls() if (response.isSuccessful) return@withContext Resource.Success(response.body()!!) Resource.Error( Message.DynamicString( Gson().fromJson( response.errorBody()?.charStream(), MessageBody::class.java ).message )) }catch (e: Exception) { Resource.Error(Message.StringResource(R.string.fetch_sectors_error)) } } override suspend fun insertPivotControl(pivot: PivotControlEntity): Resource<Int> = withContext(Dispatchers.IO) { try { val response = pivotControlApiService.insertPivotControl(pivot) if (response.isSuccessful) return@withContext Resource.Success(response.body()!!) Resource.Error(Message.DynamicString(response.errorBody().toString())) }catch (e: Exception) { Resource.Error(Message.StringResource(R.string.add_pivot_error)) } } override suspend fun insertSectorControl(sector: SectorControl): Resource<Int> = withContext(Dispatchers.IO) { try { val response = sectorControlApiService.insertSectorControl(sector) if (response.isSuccessful) return@withContext Resource.Success(response.body()!!) Resource.Error(Message.DynamicString(response.errorBody().toString())) }catch (e: Exception) { Resource.Error(Message.StringResource(R.string.add_sector_error)) } } override suspend fun updatePivotControl(pivot: PivotControlEntity): Resource<Int> = withContext(Dispatchers.IO) { try { val response = pivotControlApiService.updatePivotControl(pivot) if (response.isSuccessful) return@withContext Resource.Success(response.body()!!) Resource.Error(Message.DynamicString(response.errorBody().toString())) }catch (e: Exception) { Resource.Error(Message.StringResource(R.string.update_pivot_error)) } } override suspend fun updateSectorControl(sector: SectorControl): Resource<Int> = withContext(Dispatchers.IO) { try { val response = sectorControlApiService.updateSectorControl(sector) if (response.isSuccessful) return@withContext Resource.Success(response.body()!!) Resource.Error(Message.DynamicString(response.errorBody().toString())) }catch (e: Exception) { Resource.Error(Message.StringResource(R.string.update_sector_error)) } } override suspend fun deletePivotControl(pivotId: Int): Resource<Int> = withContext(Dispatchers.IO) { try { val response = pivotControlApiService.deletePivotControl(pivotId) if (response.isSuccessful) return@withContext Resource.Success(response.body()!!) Resource.Error(Message.DynamicString(response.errorBody().toString())) }catch (e: Exception) { Resource.Error(Message.StringResource(R.string.delete_pivot_error)) } } }
pivot-control/app/src/main/java/com/example/controlpivot/data/remote/datasource/PivotControlRemoteDatasourceImpl.kt
3244514884
package com.example.controlpivot.data.remote.model import com.example.controlpivot.data.local.model.SectorControl data class PivotControl( val id: Int, val idPivot: Int, val progress: Float, val isRunning: Boolean, val stateBomb: Boolean, val wayToPump: Boolean, val turnSense: Boolean, val sectorControlList: List<SectorControl> )
pivot-control/app/src/main/java/com/example/controlpivot/data/remote/model/PivotControl.kt
64384816
package com.example.controlpivot.data.remote.model import com.example.controlpivot.data.local.model.PivotMachineEntity data class PivotMachine( val id: Int, val name: String, val location: String, val endowment: Double, val flow: Double, val pressure: Double, val length: Double, val area: Double, val power: Double, val speed: Double, val efficiency: Double, ) fun PivotMachineEntity.toNetwork() = PivotMachine( remoteId, name, location, endowment, flow, pressure, length, area, power, speed, efficiency )
pivot-control/app/src/main/java/com/example/controlpivot/data/remote/model/PivotMachine.kt
4269663237
package com.example.controlpivot.data.remote import com.example.controlpivot.data.common.model.Session data class MessageBody ( val message: String, val session: Session, )
pivot-control/app/src/main/java/com/example/controlpivot/data/remote/MessageBody.kt
572214489
package com.example.controlpivot.data.remote.service import com.example.controlpivot.AppConstants import com.example.controlpivot.data.common.model.Session import com.example.controlpivot.data.remote.MessageBody import com.example.controlpivot.ui.screen.login.Credentials import retrofit2.Response import retrofit2.http.Body import retrofit2.http.Headers import retrofit2.http.POST import retrofit2.http.PUT interface SessionApiService { @Headers("Content-Type: application/json") @POST(AppConstants.SESSION_API_PATH) suspend fun getSession( @Body credentials: Credentials ): Response<MessageBody> @Headers("Content-Type: application/json") @PUT(AppConstants.SESSION_API_PATH) suspend fun updateSession( @Body credentials: Credentials ): Response<Session> }
pivot-control/app/src/main/java/com/example/controlpivot/data/remote/service/SessionApiService.kt
2065835893
package com.example.controlpivot.data.remote.service import com.example.controlpivot.AppConstants import com.example.controlpivot.data.local.model.SectorControl import retrofit2.Response import retrofit2.http.Body import retrofit2.http.DELETE import retrofit2.http.GET import retrofit2.http.POST import retrofit2.http.PUT import retrofit2.http.Query interface SectorControlApiService { @GET(AppConstants.PIVOT_SECTOR_CONTROL_API_PATH) suspend fun getSectorControls( ): Response<List<SectorControl>> @POST suspend fun insertSectorControl( @Body sectorControl: SectorControl ): Response<Int> @PUT suspend fun updateSectorControl( @Body sectorControl: SectorControl ): Response<Int> @DELETE suspend fun deleteSectorControl( @Query("pivotId") sectorId: Int ): Response<Int> }
pivot-control/app/src/main/java/com/example/controlpivot/data/remote/service/SectorControlApiService.kt
540705318
package com.example.controlpivot.data.remote.service import com.example.controlpivot.AppConstants import com.example.controlpivot.data.local.model.PivotControlEntity import com.example.controlpivot.data.local.model.PivotMachineEntity import com.example.controlpivot.data.remote.model.PivotControl import retrofit2.Response import retrofit2.http.Body import retrofit2.http.DELETE import retrofit2.http.GET import retrofit2.http.POST import retrofit2.http.PUT import retrofit2.http.Query interface PivotControlApiService { @GET(AppConstants.PIVOT_CONTROL_API_PATH) suspend fun getPivotControls( ): Response<List<PivotControl>> @POST suspend fun insertPivotControl( @Body pivotControl: PivotControlEntity ): Response<Int> @PUT suspend fun updatePivotControl( @Body pivotControl: PivotControlEntity ): Response<Int> @DELETE suspend fun deletePivotControl( @Query("pivotId") pivotId: Int ): Response<Int> }
pivot-control/app/src/main/java/com/example/controlpivot/data/remote/service/PivotControlApiService.kt
2096036173
package com.example.controlpivot.data.remote.service import com.example.controlpivot.AppConstants import com.example.controlpivot.data.common.model.Climate import retrofit2.Response import retrofit2.http.Body import retrofit2.http.DELETE import retrofit2.http.GET import retrofit2.http.POST import retrofit2.http.PUT import retrofit2.http.Query interface ClimateApiService { @GET(AppConstants.CLIMATE_API_PATH) suspend fun getClimates( ): Response<List<Climate>> @POST suspend fun insertClimate( @Body climate: Climate ): Response<Int> @PUT suspend fun updateClimate( @Body climate: Climate ): Response<Int> @DELETE suspend fun deleteClimate( @Query("climateId") climateId: Int ): Response<Int> }
pivot-control/app/src/main/java/com/example/controlpivot/data/remote/service/ClimateApiService.kt
3082050165
package com.example.controlpivot.data.remote.service import com.example.controlpivot.AppConstants import com.example.controlpivot.data.remote.model.PivotMachine import retrofit2.Response import retrofit2.http.Body import retrofit2.http.DELETE import retrofit2.http.GET import retrofit2.http.POST import retrofit2.http.PUT import retrofit2.http.Path interface PivotMachineApiService { @GET(AppConstants.PIVOT_MACHINES_API_PATH) suspend fun getPivotMachines( ): Response<List<PivotMachine>> @POST(AppConstants.PIVOT_MACHINES_API_PATH) suspend fun insertPivotMachine( @Body pivotMachine: PivotMachine ): Response<PivotMachine> @PUT(AppConstants.PIVOT_MACHINES_API_PATH) suspend fun updatePivotMachine( @Body pivotMachine: PivotMachine ): Response<Int> @DELETE(AppConstants.PIVOT_MACHINES_API_PATH+AppConstants.DELETE_API_PATH) suspend fun deletePivotMachine( @Path("id") id: Int ): Response<Int> }
pivot-control/app/src/main/java/com/example/controlpivot/data/remote/service/PivotMachineApiService.kt
2331514197
package com.example.controlpivot.domain.usecase import android.util.Log import com.example.controlpivot.data.local.model.SectorControl import com.example.controlpivot.data.repository.PivotControlRepository import com.example.controlpivot.ui.model.PivotControlsWithSectors import com.example.controlpivot.utils.Resource import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.onEach class GetPivotControlsWithSectorsUseCase( private val controlRepository: PivotControlRepository, ) { operator fun invoke(query: String): Flow<Resource<List<PivotControlsWithSectors>>> = flow { controlRepository.getAllPivotControls(query) .combine(controlRepository.getAllSectorControls("")) { result, resource -> when (result) { is Resource.Error -> { emit(Resource.Error(result.message)) return@combine } is Resource.Success -> { var sectorList = listOf<SectorControl>() when (resource) { is Resource.Error -> { emit(Resource.Error(resource.message)) return@combine } is Resource.Success -> { sectorList = resource.data Log.d("GET", resource.data.toString()) } } emit( Resource.Success( result.data.map { pivotControl -> PivotControlsWithSectors( id = pivotControl.id, idPivot = pivotControl.idPivot, progress = pivotControl.progress, isRunning = pivotControl.isRunning, stateBomb = pivotControl.stateBomb, wayToPump = pivotControl.wayToPump, turnSense = pivotControl.turnSense, sectorList = sectorList.filter { it.sector_control_id == pivotControl.id } ) } )) } } }.collect() } }
pivot-control/app/src/main/java/com/example/controlpivot/domain/usecase/GetPivotControlsWithSectorsUseCase.kt
3673847876
package com.example.controlpivot.domain.usecase import com.example.controlpivot.data.repository.PivotMachineRepository import com.example.controlpivot.ui.model.IdPivotModel import com.example.controlpivot.utils.Resource import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.onEach class GetIdPivotNameUseCase( private val pivotMachineRepository: PivotMachineRepository, ) { operator fun invoke(query: String): Flow<Resource<List<IdPivotModel>>> = flow { pivotMachineRepository.getAllPivotMachines(query).onEach { result -> when (result) { is Resource.Error -> { emit(Resource.Error(result.message)) return@onEach } is Resource.Success -> { emit(Resource.Success( result.data.filter { it.remoteId != Int.MAX_VALUE } .map { machine -> IdPivotModel( idPivot = machine.remoteId, pivotName = machine.name ) } )) } } }.collect() } }
pivot-control/app/src/main/java/com/example/controlpivot/domain/usecase/GetIdPivotNameUseCase.kt
3125131138
package com.example.controlpivot.domain.usecase import com.example.controlpivot.data.local.model.MachinePendingDelete import com.example.controlpivot.data.remote.datasource.PivotMachineRemoteDatasource import com.example.controlpivot.data.repository.MachinePendingDeleteRepository import com.example.controlpivot.utils.Resource import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking class DeletePendingMachineUseCase( private val remoteDatasource: PivotMachineRemoteDatasource, private val machinePendingDeleteRepository: MachinePendingDeleteRepository, ) { suspend operator fun invoke() = synchronized(this) { runBlocking(Dispatchers.IO) { machinePendingDeleteRepository.getPendingDelete().let { resource -> val pendingDelete = when (resource) { is Resource.Error -> MachinePendingDelete() is Resource.Success -> resource.data } val deletedList = pendingDelete.listId.toMutableList() pendingDelete.listId.forEach { when (remoteDatasource.deletePivotMachine(it)) { is Resource.Success -> { deletedList.remove(it) machinePendingDeleteRepository.savePendingDelete( MachinePendingDelete(deletedList) ) } else -> {} } } } } } }
pivot-control/app/src/main/java/com/example/controlpivot/domain/usecase/DeletePendingMachineUseCase.kt
2690419018
package com.example.dmstingachcalculator 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.dmstingachcalculator", appContext.packageName) } }
Calculator-Android/app/src/androidTest/java/com/example/dmstingachcalculator/ExampleInstrumentedTest.kt
6363477
package com.example.dmstingachcalculator import org.junit.Test import org.junit.Assert.* /** * Example local unit test, which will execute on the development machine (host). * * See [testing documentation](http://d.android.com/tools/testing). */ class ExampleUnitTest { @Test fun addition_isCorrect() { assertEquals(4, 2 + 2) } }
Calculator-Android/app/src/test/java/com/example/dmstingachcalculator/ExampleUnitTest.kt
937775570
package com.example.dmstingachcalculator import android.os.Bundle import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) } }
Calculator-Android/app/src/main/java/com/example/dmstingachcalculator/MainActivity.kt
1481363606
package com.example.login 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.login", appContext.packageName) } }
AndroidApp_VeXe/app/src/androidTest/java/com/example/login/ExampleInstrumentedTest.kt
4292129466
package com.example.login import org.junit.Test import org.junit.Assert.* /** * Example local unit test, which will execute on the development machine (host). * * See [testing documentation](http://d.android.com/tools/testing). */ class ExampleUnitTest { @Test fun addition_isCorrect() { assertEquals(4, 2 + 2) } }
AndroidApp_VeXe/app/src/test/java/com/example/login/ExampleUnitTest.kt
595896254
package com.example.login.ui.theme import androidx.compose.ui.graphics.Color val Purple80 = Color(0xFFD0BCFF) val PurpleGrey80 = Color(0xFFCCC2DC) val Pink80 = Color(0xFFEFB8C8) val Purple40 = Color(0xFF6650a4) val PurpleGrey40 = Color(0xFF625b71) val Pink40 = Color(0xFF7D5260)
AndroidApp_VeXe/app/src/main/java/com/example/login/ui/theme/Color.kt
178537291
package com.example.login.ui.theme import android.app.Activity import android.os.Build import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.MaterialTheme import androidx.compose.material3.darkColorScheme import androidx.compose.material3.dynamicDarkColorScheme import androidx.compose.material3.dynamicLightColorScheme import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable import androidx.compose.runtime.SideEffect import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalView import androidx.core.view.WindowCompat private val DarkColorScheme = darkColorScheme( primary = Purple80, secondary = PurpleGrey80, tertiary = Pink80 ) private val LightColorScheme = lightColorScheme( primary = Purple40, secondary = PurpleGrey40, tertiary = Pink40 /* Other default colors to override background = Color(0xFFFFFBFE), surface = Color(0xFFFFFBFE), onPrimary = Color.White, onSecondary = Color.White, onTertiary = Color.White, onBackground = Color(0xFF1C1B1F), onSurface = Color(0xFF1C1B1F), */ ) @Composable fun LoginTheme( darkTheme: Boolean = isSystemInDarkTheme(), // Dynamic color is available on Android 12+ dynamicColor: Boolean = true, content: @Composable () -> Unit ) { val colorScheme = when { dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { val context = LocalContext.current if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) } darkTheme -> DarkColorScheme else -> LightColorScheme } val view = LocalView.current if (!view.isInEditMode) { SideEffect { val window = (view.context as Activity).window window.statusBarColor = colorScheme.primary.toArgb() WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme } } MaterialTheme( colorScheme = colorScheme, typography = Typography, content = content ) }
AndroidApp_VeXe/app/src/main/java/com/example/login/ui/theme/Theme.kt
4227603865
package com.example.login.ui.theme import androidx.compose.material3.Typography import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.sp // Set of Material typography styles to start with val Typography = Typography( bodyLarge = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Normal, fontSize = 16.sp, lineHeight = 24.sp, letterSpacing = 0.5.sp ) /* Other default text styles to override titleLarge = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Normal, fontSize = 22.sp, lineHeight = 28.sp, letterSpacing = 0.sp ), labelSmall = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Medium, fontSize = 11.sp, lineHeight = 16.sp, letterSpacing = 0.5.sp ) */ )
AndroidApp_VeXe/app/src/main/java/com/example/login/ui/theme/Type.kt
3273098344
package com.example.login import androidx.appcompat.app.AppCompatActivity import android.os.Bundle class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) } }
AndroidApp_VeXe/app/src/main/java/com/example/login/MainActivity.kt
1994883971
package com.example.login import androidx.appcompat.app.AppCompatActivity import android.os.Bundle class Login : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_login) } }
AndroidApp_VeXe/app/src/main/java/com/example/login/Login.kt
2630439124
package com.example.login import androidx.appcompat.app.AppCompatActivity import android.os.Bundle class Registration : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_registration) } }
AndroidApp_VeXe/app/src/main/java/com/example/login/Registration.kt
4195786672
package com.example.mylocation 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.mylocation", appContext.packageName) } }
My_Location/app/src/androidTest/java/com/example/mylocation/ExampleInstrumentedTest.kt
2064907680
package com.example.mylocation import org.junit.Test import org.junit.Assert.* /** * Example local unit test, which will execute on the development machine (host). * * See [testing documentation](http://d.android.com/tools/testing). */ class ExampleUnitTest { @Test fun addition_isCorrect() { assertEquals(4, 2 + 2) } }
My_Location/app/src/test/java/com/example/mylocation/ExampleUnitTest.kt
1438559452
package com.example.mylocation import android.content.pm.PackageManager import android.location.Location import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.Toast import androidx.core.app.ActivityCompat import com.google.android.gms.maps.CameraUpdateFactory import com.google.android.gms.maps.GoogleMap import com.google.android.gms.maps.OnMapReadyCallback import com.google.android.gms.maps.SupportMapFragment import com.google.android.gms.maps.model.LatLng import com.google.android.gms.maps.model.MarkerOptions import com.example.mylocation.databinding.ActivityMapsBinding import com.google.android.gms.location.CurrentLocationRequest import com.google.android.gms.location.FusedLocationProviderClient import com.google.android.gms.location.LocationServices class MapsActivity : AppCompatActivity(), OnMapReadyCallback { private lateinit var mMap: GoogleMap private lateinit var binding: ActivityMapsBinding private lateinit var currentLocation: Location private lateinit var fusedLocationProviderClient: FusedLocationProviderClient private val permissionCode = 101 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivityMapsBinding.inflate(layoutInflater) setContentView(binding.root) fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this) // Obtain the SupportMapFragment and get notified when the map is ready to be used. getCurrentLocationUser() } private fun getCurrentLocationUser(){ if(ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission( this, android.Manifest.permission.ACCESS_COARSE_LOCATION)!= PackageManager.PERMISSION_GRANTED){ ActivityCompat.requestPermissions(this, arrayOf(android.Manifest.permission.ACCESS_FINE_LOCATION), permissionCode) Toast.makeText(this, "permission", Toast.LENGTH_LONG).show() return } else{ fusedLocationProviderClient.lastLocation.addOnSuccessListener { location -> if(location != null){ currentLocation = location Toast.makeText(this, currentLocation.latitude.toString()+ "" + currentLocation.longitude.toString(), Toast.LENGTH_LONG).show() val mapFragment = supportFragmentManager .findFragmentById(R.id.map) as SupportMapFragment mapFragment.getMapAsync(this) getCurrentLocationUser() } else{ Toast.makeText( this, "Permission denied. Unable to show current location.", Toast.LENGTH_SHORT ).show() } } } } override fun onRequestPermissionsResult( requestCode: Int, permissions: Array<out String>, grantResults: IntArray ) { super.onRequestPermissionsResult(requestCode, permissions, grantResults) when(requestCode){ permissionCode -> if(grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED){ getCurrentLocationUser() } } } /** * Manipulates the map once available. * This callback is triggered when the map is ready to be used. * This is where we can add markers or lines, add listeners or move the camera. In this case, * we just add a marker near Sydney, Australia. * If Google Play services is not installed on the device, the user will be prompted to install * it inside the SupportMapFragment. This method will only be triggered once the user has * installed Google Play services and returned to the app. */ override fun onMapReady(googleMap: GoogleMap) { val latLng = LatLng(currentLocation.latitude, currentLocation.longitude) val markerOptions: MarkerOptions = MarkerOptions().position(latLng).title("Current Location") googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15f)) googleMap.addMarker(markerOptions) } }
My_Location/app/src/main/java/com/example/mylocation/MapsActivity.kt
311010508
package com.example.corounitesample 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.corounitesample", appContext.packageName) } }
CorouniteSample/app/src/androidTest/java/com/example/corounitesample/ExampleInstrumentedTest.kt
1838679690
package com.example.corounitesample import org.junit.Test import org.junit.Assert.* /** * Example local unit test, which will execute on the development machine (host). * * See [testing documentation](http://d.android.com/tools/testing). */ class ExampleUnitTest { @Test fun addition_isCorrect() { assertEquals(4, 2 + 2) } }
CorouniteSample/app/src/test/java/com/example/corounitesample/ExampleUnitTest.kt
4028589944
package com.example.corounitesample import android.widget.Toast import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.filterIsInstance import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.take import kotlinx.coroutines.flow.takeWhile import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext import java.util.Locale import kotlin.math.roundToInt val customCoroutineScope = CoroutineScope(Dispatchers.Default) fun main() { println("START MAIN") println("MAIN FUN") /* val values = listOf("А", "Б", "1", "2", "В", "3", "Г", "Д", "4", "5") val sortedValues = values.sortedWith(Comparator { a, b -> when { a.matches(Regex("[a-zA-Z]")) && b.matches(Regex("[0-9]")) -> -1 // буквенное значение идет перед числовым a.matches(Regex("[0-9]")) && b.matches(Regex("[a-zA-Z]")) -> 1 // числовое значение идет после буквенного else -> a.compareTo(b) // сортировка по умолчанию } }) println(sortedValues) */ // val strings = listOf("Привет", "Hello", "Мир", "World", "1", "2") // // val sortedStrings = strings.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.toLowerCase(Locale.getDefault()) }) // println(sortedStrings) customCoroutineScope.launch { (2..10).map { println("START $it") delay(100) getBasket() println("END $it") } } runBlocking { delay(2000) } } fun getBasket() = customCoroutineScope.launch { println("START GETBASKET") //delay(100) getPurchases() println("END GETBASKET") } suspend fun getPurchases() { // withContext(Dispatchers.IO) { println("START GETPURCHASES") (0..1).map { delay(50) println("PURCHASE $it") //getPurchasePrice(it.toString()) } println("END GETPURCHASES") // } } suspend fun getPurchasePrice(i: String) { println("START GETPURCHASEPRICE $i") savePurchase(i) println("END GETPURCHASEPRICE $i") } suspend fun savePurchase(i: String) { customCoroutineScope.launch(Dispatchers.IO) { println("START SAVEPURCHASE $i") delay(50) println("END SAVEPURCHASE $i") } } suspend fun coroutine() { customCoroutineScope.launch { println("start coroutine") suspendFuncWithDelay() println("end coroutine") } } suspend fun suspendFuncWithDelay() { println("start suspendFuncWithDelay") delay(100) println("end suspendFuncWithDelay") } private fun deviationVirtualTemperature(temperature: Double): Double { val map = mapOf(0..4 to 0.5, 5..9 to 0.5, 10..14 to 1.0, 15..24 to 1.0, 25..29 to 2.0, 30..39 to 3.5,) val interval = map.entries.find { temperature.roundToInt() in it.key }?.key val popravka = when (interval) { 0..4, 10..14 -> map[interval]!! 5..9, 15..24, 30..39, -> map[interval]!! + (temperature.roundToInt() - interval.first)*0.1 25..29 -> map[interval]!! + (temperature.roundToInt() - interval.first)*0.3 40..100 -> 4.5 else -> 0.0 } return temperature + popravka - 15.9 }
CorouniteSample/app/src/main/java/com/example/corounitesample/Main.kt
2316781533
package com.example.corounitesample import java.text.SimpleDateFormat import java.util.Calendar import java.util.Locale import kotlin.math.atan2 import kotlin.math.cos import kotlin.math.pow import kotlin.math.roundToInt import kotlin.math.sin import kotlin.math.sqrt /* data class MeteoData(val pressure: Double, val height: Double, val temperature: Double, val humidity: Double, val averageMolecularWeight: Double, val windSpeed: Double, val windDirection: Double) fun interpolateMeteoData(targetHeight: Double, data1: MeteoData, data2: MeteoData): MeteoData { val fraction = (targetHeight - data1.height) / (data2.height - data1.height) return MeteoData( interpolate(data1.pressure, data2.pressure, fraction), targetHeight, interpolate(data1.temperature, data2.temperature, fraction), interpolate(data1.humidity, data2.humidity, fraction), interpolate(data1.averageMolecularWeight, data2.averageMolecularWeight, fraction), interpolate(data1.windSpeed, data2.windSpeed, fraction), interpolate(data1.windDirection, data2.windDirection, fraction) ) } fun interpolate(value1: Double, value2: Double, fraction: Double): Double { return value1 + fraction * (value2 - value1) } fun main() { val meteoDataList = listOf( MeteoData(1000.0, 108.0, -8.7, 74.0, 5621.0, 3.2, 0.0), MeteoData(975.0, 303.0, -10.7, 83.0, 5677.0, 5.2, 0.0), MeteoData(950.0, 502.0, -12.7, 93.0, 5700.0, 7.2, 31.0), MeteoData(925.0, 705.0, -13.8, 92.0, 118.0, 8.4, 33.0), MeteoData(900.0, 914.0, -12.6, 86.0, 288.0, 8.4, 14.0), MeteoData(850.0, 1353.0, -9.0, 91.0, 386.0, 5.5, 36.0), MeteoData(800.0, 1821.0, -9.6, 92.0, 571.0, 3.7, 45.0), MeteoData(700.0, 2845.0, -13.6, 76.0, 38.0, 7.5, 10.0), MeteoData(600.0, 4001.0, -20.5, 76.0, 5756.0, 3.6, 10.0), MeteoData(500.0, 5331.0, -27.8, 74.0, 3562.0, 6.6, 7.0), MeteoData(400.0, 6901.0, -38.5, 61.0, 3618.0, 10.0, 0.0), MeteoData(300.0, 8817.0, -52.5, 28.0, 3629.0, 12.8, 0.0), MeteoData(250.0, 9977.0, -58.0, 21.0, 3512.0, 16.4, 0.0), MeteoData(200.0, 11379.0, -58.5, 5.0, 3571.0, 17.6, 0.0), MeteoData(150.0, 13184.0, -59.0, 3.0, 3911.0, 15.9, 0.0), MeteoData(100.0, 15719.0, -60.8, 3.0, 4173.0, 13.5, 0.0), MeteoData(70.0, 17913.0, -65.0, 4.0, 4189.0, 17.8, 0.0), MeteoData(50.0, 19945.0, -68.4, 4.0, 4317.0, 24.0, 0.0), MeteoData(30.0, 23006.0, -69.8, 4.0, 4329.0, 29.0, 0.0) ) val targetHeights = listOf(0.0, 200.0, 400.0, 800.0, 1200.0, 1600.0, 2000.0, 2400.0, 3000.0, 4000.0, 5000.0, 6000.0, 8000.0, 10000.0, 12000.0, 14000.0, 18000.0, 22000.0, 26000.0, 30000.0) for (height in targetHeights) { val (data1, data2) = findClosestDataPoints(height, meteoDataList) val interpolatedData = interpolateMeteoData(height, data1, data2) println("На высоте $height м:") println("Давление: ${interpolatedData.pressure} гПа") println("Температура: ${interpolatedData.temperature} градусов Цельсия") println("Влажность: ${interpolatedData.humidity}%") println("Скорость ветра: ${interpolatedData.windSpeed} м/с") println("Направление ветра: ${interpolatedData.windDirection} градусов") println("-----------") } } fun findClosestDataPoints(targetHeight: Double, data: List<MeteoData>): Pair<MeteoData, MeteoData> { val sortedData = data.sortedBy { it.height } for (i in 0 until sortedData.size - 1) { val data1 = sortedData[i] val data2 = sortedData[i + 1] if (targetHeight >= data1.height && targetHeight <= data2.height) { return Pair(data1, data2) } } // Если не нашли точные данные для интерполяции, можно вернуть ближайшие return Pair(sortedData.last(), sortedData.first()) }*/
CorouniteSample/app/src/main/java/com/example/corounitesample/Deviation.kt
755316548
package com.example.corounitesample import android.os.Build import androidx.annotation.RequiresApi import java.nio.ByteBuffer import java.text.SimpleDateFormat import java.time.LocalDateTime import java.time.ZoneId import java.util.Date import java.util.Locale import kotlin.math.E @RequiresApi(Build.VERSION_CODES.O) fun main() { // val knownHeight = 108 // высота в метрах // val knownTemperature = -8.7 // температура в градусах Цельсия // val knownWindDirection = 337 // направление ветра в градусах // val knownWindSpeed = 3.2 // скорость ветра в метрах в секунду // // // Высота, на которую нужно интерполировать данные // val targetHeight = 200 // высота в метрах // // // Гравитационный алгоритм для интерполяции температуры // val lapseRate = 0.0065 // адиабатический градиент // val deltaHeight = targetHeight - knownHeight // val targetTemperature = knownTemperature + lapseRate * deltaHeight // // // Интерполяция направления ветра // val deltaWindDirection = 0 // можно изменить в зависимости от данных // val targetWindDirection = knownWindDirection + deltaWindDirection // // // Интерполяция скорости ветра // val deltaWindSpeed = 0.0 // можно изменить в зависимости от данных // val targetWindSpeed = knownWindSpeed + deltaWindSpeed // // // Вывод результатов // println("На высоте $targetHeight м:") // println("Температура: $targetTemperature градусов Цельсия") // println("Направление ветра: $targetWindDirection градусов") // println("Скорость ветра: $targetWindSpeed м/с") //println(g().map { it.contentToString() }) //aaa() //sss() //m9g() //getHourlyList() println(test().convertToMeteo()) } data class MeteoTableData( val id: Int = 0, val B: Float, val L: Float, val time: String, val temperature: Double, val pressure: Double, val height: Double, val meteoAverage: List<MeteoData>, val state: MeteoTypes, val lastUpdate: String ) data class MeteoData( val height: Int, val dT: Int, val windDirection: Int, val windSpeed: Int, val type: MeteoTypes ) enum class MeteoTypes { AVERAGE, APPROXIMATE, UPDATED } fun ByteArray.convertToMeteo(): MeteoTableData { println("SIZE ${this.size}") val lat = this.copyOfRange(0, 4).toFloat() val lon = this.copyOfRange(4, 8).toFloat() val time = this.copyOfRange(8, 16).toLong() val temperature = this.copyOfRange(16, 20).toFloat() val pressure = this.copyOfRange(20, 24).toInt() val height = this.copyOfRange(24, 28).toInt() val meteoTable = mutableListOf<MeteoData>() (28..this.lastIndex step 4).map { println("STEP $it") meteoTable.add( MeteoData( this[it].toInt(), this[it+1].toInt(), this[it+2].toInt(), this[it+3].toInt(), type = MeteoTypes.AVERAGE ) ) } return MeteoTableData( B = lat, L = lon, time = convertMillisecondsToDateFormat(time), temperature = temperature.toDouble(), pressure = pressure.toDouble(), height = height.toDouble(), state = MeteoTypes.AVERAGE, lastUpdate = convertMillisecondsToDateFormat(time), meteoAverage = meteoTable.toList() ) } fun convertMillisecondsToDateFormat(milliseconds: Long): String { val dateFormat = SimpleDateFormat("dd.MM.yyyy-HH:mm:ss") val date = Date(milliseconds) return dateFormat.format(date) } fun test(): ByteArray { val data = "46.794044;19.079527;27.11.2023-10:19:54;1,2;760;0;0;64;39;3;2;63;44;5;4;62;46;7;8;61;48;10;12;61;48;12;16;61;49;12;20;61;49;12;24;61;49;13;30;61;50;14;40;61;50;15;50;61;51;17;60;61;51;19;80;61;52;24;10;61;53;28;12;60;52;29;14;59;52;29;18;59;52;29;22;59;51;29;26;59;51;29;30;59;51;29" val items = data.split(";") var byteArray = items[0].toFloat().toByteArray() + items[1].toFloat().toByteArray() + convertDateTimeToMilliseconds(items[2]).toByteArray() + items[3].replace(",", ".").toFloat().toByteArray() + items[4].toInt().toByteArray() + items[5].toInt().toByteArray() (6..items.lastIndex).map { byteArray += items[it].toInt().toByte() } return byteArray } fun convertDateTimeToMilliseconds(dateTime: String): Long { val format = SimpleDateFormat("dd.MM.yyyy-HH:mm:ss") val date = format.parse(dateTime) return date.time } fun Float.toByteArray(): ByteArray = ByteBuffer.allocate(Float.SIZE_BYTES).putFloat(this).array() fun Int.toByteArray(): ByteArray = ByteBuffer.allocate(Int.SIZE_BYTES).putInt(this).array() fun Long.toByteArray(): ByteArray = ByteBuffer.allocate(Long.SIZE_BYTES).putLong(this).array() fun Byte.toByteArray(): ByteArray = byteArrayOf(this) fun ByteArray.toFloat(): Float = ByteBuffer.wrap(this).float fun ByteArray.toInt(): Int = ByteBuffer.wrap(this).int fun ByteArray.toLong(): Long = ByteBuffer.wrap(this).long fun getHourlyList() { val list = mutableListOf<String>() val baseList = listOf( "temperature", "relative_humidity_2m", "precipitation", "weather_code","surface_pressure","cloud_cover", "cloud_cover_low","cloud_cover_mid","cloud_cover_high", "visibility","wind_speed_10m","wind_direction_10m") list.addAll(baseList) val heightList = listOf( "1000", "975", "950", "925", "900", "850", "700", "500", "400", "300", "250", "200", "150", "100", "70", "50", "30") val params = listOf("temperature_", "relative_humidity_", "cloud_cover_", "windspeed_", "winddirection_", "geopotential_height_") params.forEach {param -> heightList.forEach { height -> list.add(param+height+"hPa") } } println(list) } fun f(d3: Double): Double { return when { d3 < -2000.0 || d3 >= 9324.0 -> { if (d3 > 9324.0 && d3 <= 12000.0) { val pow = Math.pow(E, (0.1939 - Math.atan((12000.0 - d3) / 13750.0)) * -2.119) val d4 = 0.2923 pow * d4 } else if (d3 <= 12000.0) { 0.0 } else { val pow = Math.pow(E, (d3 - 12000.0) * -1.542E-4) val d4 = 0.1938 pow * d4 } } else -> Math.pow(1.0 - (d3 * 2.19E-5), 5.4) } } fun d(d3: Double): Double { return when { d3 < -2000.0 || d3 >= 9324.0 -> { when { d3 <= 9324.0 || d3 > 12000.0 -> if (d3 > 12000.0) 221.5 else 0.0 else -> { val d4 = d3 - 9324.0 (230.0 - (0.006328 * d4)) + (Math.pow(d4, 2.0) * 1.1718518518518518E-6) } } } else -> 288.9 - (d3 * 0.006328) } } fun aaa() { val f5042l1 = 700 val f5046m1 = -13.6 val f5050n1 = 76 val f5038k1 = 743 // Вычисление основной части температуры val baseTemperature = f5042l1 - (f(30000.0) * 750.0) // Вычисление параметров для расчета насыщенного давления водяного пара val saturationVaporPressure = Math.pow(E, (17.625 * f5046m1 + 243.04) / (f5046m1 + 273.0) * 6.1094) // Вычисление параметров для расчета относительной влажности val vaporPressure = f5046m1* 100.0 val saturationPressureCorrection = 0.378 * f5050n1 val relativeHumidity = ((f5050n1 * 0.622) / 100.0 * saturationVaporPressure) * (f5046m1 * 0.608) / (f5038k1 - (saturationPressureCorrection / 100.0) * saturationVaporPressure) // Вычисление параметров для расчета температуры точки росы val dewPointTemperature = (saturationVaporPressure * 4283.58 / Math.pow(f5046m1 + 243.04, 2.0) * (f5046m1 + 273.0) + 1.0) * vaporPressure - saturationPressureCorrection // Вычисление конечной температуры println((f5046m1 + relativeHumidity) - (d(30000.0) - 273.0)) } fun g(): Array<Array<String>> { val strArr = arrayOf( "0", "200", "400", "800", "1200", "1600", "2000", "2400", "3000", "4000", "5000", "6000", "8000", "10000", "12000", "14000", "18000", "22000", "26000", "30000" ) val strArr2 = Array(20) { Array(5) { "" } } for (i3 in 0 until 20) { strArr2[i3][0] = strArr[i3] val doubleValue = strArr[i3].toDouble() strArr2[i3][1] = String.format("%.3f", f(doubleValue) * (348.35562 / d(doubleValue))) strArr2[i3][2] = String.format("%.1f", f(doubleValue) * 750.0) strArr2[i3][3] = String.format("%.1f", d(doubleValue) - 273.0) strArr2[i3][4] = String.format("%.1f", Math.pow(d(doubleValue), 0.5) * 20.04679584) } return strArr2 } fun t(dArr: Array<DoubleArray>?): Array<DoubleArray>? { if (dArr == null) { return null } val dArr2 = Array(dArr.size) { DoubleArray(dArr[it].size) } for (i3 in dArr.indices) { val dArr3 = DoubleArray(dArr[i3].size) dArr2[i3] = dArr3 val dArr4 = dArr[i3] System.arraycopy(dArr4, 0, dArr3, 0, dArr4.size) } return dArr2 } val f5085w0 = SimpleDateFormat("DD", Locale.getDefault()).format(Date()).toInt() val f4983V0 = doubleArrayOf( 1000.0, 975.0, 950.0, 925.0, 900.0, 850.0, 800.0, 700.0, 600.0, 500.0, 400.0, 300.0, 250.0, 200.0, 150.0, 100.0, 70.0, 50.0, 30.0 ) val f4986W0 = doubleArrayOf( 0.0, 200.0, 400.0, 800.0, 1200.0, 1600.0, 2000.0, 2400.0, 3000.0, 4000.0, 5000.0, 6000.0, 8000.0, 10000.0, 12000.0, 14000.0, 18000.0, 22000.0, 26000.0, 30000.0 ) val geopotential_height_1000hPa = doubleArrayOf( 140.00, 139.00, 137.00, 135.00, 136.00, 137.00, 139.00, 139.00, 137.00, 138.00, 142.00, 146.00, 145.00, 144.00, 142.00, 142.00, 143.00, 142.00, 140.00, 138.00, 136.00, 138.00, 133.00, 130.00 ) val geopotential_height_975hPa = doubleArrayOf( 335.61, 334.61, 332.61, 330.61, 331.12, 332.12, 334.12, 334.12, 332.61, 333.61, 337.61, 341.61, 340.61, 339.61, 337.12, 337.61, 338.61, 337.61, 335.61, 334.11, 332.10, 333.61, 328.61, 325.12 ) val geopotential_height_950hPa = doubleArrayOf( 535.00, 534.00, 532.00, 530.00, 530.00, 531.00, 533.00, 533.00, 532.00, 533.00, 537.00, 541.00, 540.00, 539.00, 536.00, 537.00, 538.00, 537.00, 535.00, 534.00, 532.00, 533.00, 528.00, 524.00 ) val geopotential_height_925hPa = doubleArrayOf( 738.00, 737.00, 735.00, 733.00, 733.00, 734.00, 736.00, 735.00, 735.00, 736.00, 740.00, 744.00, 744.00, 742.00, 739.00, 740.00, 741.00, 740.00, 739.00, 737.00, 735.00, 736.00, 731.00, 728.00 ) val geopotential_height_900hPa = doubleArrayOf( 948.00, 946.00, 944.00, 942.00, 942.00, 943.00, 944.00, 944.00, 942.00, 943.00, 947.00, 951.00, 951.00, 950.00, 947.00, 947.00, 948.00, 948.00, 946.00, 945.00, 943.00, 944.00, 938.00, 935.00 ) val geopotential_height_850hPa = doubleArrayOf( 1388.00, 1386.00, 1383.00, 1381.00, 1382.00, 1382.00, 1384.00, 1383.00, 1381.00, 1381.00, 1384.00, 1387.00, 1386.00, 1384.00, 1381.00, 1381.00, 1381.00, 1380.00, 1378.00, 1376.00, 1373.00, 1374.00, 1369.00, 1367.00 ) val geopotential_height_800hPa = doubleArrayOf( 1855.00, 1853.00, 1850.00, 1847.00, 1847.00, 1848.00, 1850.00, 1848.00, 1846.00, 1845.00, 1847.00, 1849.00, 1848.00, 1845.00, 1840.00, 1840.00, 1839.00, 1838.00, 1836.00, 1833.00, 1829.00, 1829.00, 1825.00, 1823.00 ) val geopotential_height_700hPa = doubleArrayOf( 2871.00, 2867.00, 2865.00, 2862.00, 2861.00, 2861.00, 2862.00, 2859.00, 2856.00, 2853.00, 2854.00, 2855.00, 2852.00, 2848.00, 2842.00, 2840.00, 2839.00, 2836.00, 2832.00, 2827.00, 2822.00, 2821.00, 2817.00, 2816.00 ) val geopotential_height_600hPa = doubleArrayOf( 4016.00, 4011.00, 4009.00, 4006.00, 4005.00, 4005.00, 4006.00, 4004.00, 4000.00, 3997.00, 3997.00, 3997.00, 3993.00, 3988.00, 3981.00, 3977.00, 3975.00, 3972.00, 3968.00, 3962.00, 3956.00, 3955.00, 3950.00, 3950.00 ) val geopotential_height_500hPa = doubleArrayOf( 5323.00, 5318.00, 5314.00, 5311.00, 5311.00, 5312.00, 5313.00, 5311.00, 5307.00, 5304.00, 5303.00, 5303.00, 5298.00, 5292.00, 5284.00, 5280.00, 5278.00, 5275.00, 5271.00, 5266.00, 5260.00, 5260.00, 5257.00, 5257.00 ) val geopotential_height_400hPa = doubleArrayOf( 6867.90, 6860.49, 6855.56, 6853.09, 6853.09, 6854.32, 6855.56, 6853.09, 6849.38, 6844.44, 6841.98, 6840.74, 6834.57, 6827.16, 6817.28, 6813.58, 6811.11, 6809.88, 6806.17, 6801.23, 6797.53, 6800.00, 6797.53, 6801.23 ) val geopotential_height_300hPa = doubleArrayOf( 8775.81, 8767.74, 8761.29, 8756.45, 8753.23, 8751.61, 8751.61, 8746.77, 8741.94, 8735.48, 8732.26, 8730.65, 8724.19, 8717.74, 8709.68, 8706.45, 8706.45, 8706.45, 8704.84, 8703.23, 8703.23, 8709.68, 8712.90, 8722.58 ) val geopotential_height_250hPa = doubleArrayOf( 9935.24, 9927.62, 9920.00, 9914.29, 9912.38, 9910.48, 9912.38, 9910.48, 9906.67, 9902.86, 9900.95, 9900.95, 9897.14, 9893.33, 9887.62, 9887.62, 9889.52, 9891.43, 9889.52, 9889.52, 9889.52, 9897.14, 9900.95, 9908.57 ) val geopotential_height_200hPa = doubleArrayOf( 11344.19, 11339.54, 11334.88, 11327.91, 11327.91, 11327.91, 11332.56, 11332.56, 11327.91, 11325.58, 11325.58, 11327.91, 11325.58, 11325.58, 11323.26, 11325.58, 11327.91, 11330.23, 11330.23, 11330.23, 11332.56, 11339.54, 11341.86, 11346.51 ) val geopotential_height_150hPa = doubleArrayOf( 13167.16, 13164.18, 13158.21, 13149.25, 13149.25, 13152.24, 13158.21, 13155.22, 13152.24, 13149.25, 13155.22, 13158.21, 13158.21, 13158.21, 13158.21, 13158.21, 13164.18, 13170.15, 13170.15, 13170.15, 13173.13, 13179.10, 13182.09, 13188.06 ) val geopotential_height_100hPa = doubleArrayOf( 15700.00, 15691.67, 15683.33, 15679.17, 15683.33, 15687.50, 15691.67, 15687.50, 15683.33, 15687.50, 15691.67, 15695.83, 15700.00, 15695.83, 15695.83, 15695.83, 15704.17, 15708.33, 15708.33, 15712.50, 15716.67, 15725.00, 15725.00, 15733.33 ) val geopotential_height_70hPa = doubleArrayOf( 17879.78, 17868.85, 17863.39, 17863.39, 17863.39, 17868.85, 17874.32, 17868.85, 17868.85, 17868.85, 17874.32, 17879.78, 17885.25, 17885.25, 17879.78, 17885.25, 17890.71, 17896.18, 17896.18, 17907.10, 17907.10, 17912.57, 17918.03, 17928.96 ) val geopotential_height_50hPa = doubleArrayOf( 19903.45, 19896.55, 19889.66, 19889.66, 19889.66, 19896.55, 19896.55, 19896.55, 19896.55, 19896.55, 19903.45, 19910.35, 19917.24, 19910.35, 19903.45, 19910.35, 19924.14, 19931.04, 19937.93, 19937.93, 19937.93, 19944.83, 19951.72, 19958.62 ) val geopotential_height_30hPa = doubleArrayOf( 22943.93, 22934.58, 22934.58, 22925.23, 22925.23, 22925.23, 22925.23, 22934.58, 22934.58, 22934.58, 22943.93, 22943.93, 22943.93, 22943.93, 22943.93, 22953.27, 22962.62, 22971.96, 22971.96, 22971.96, 22971.96, 22981.31, 22981.31, 22990.66 ) val temperature_1000hPa = doubleArrayOf( -8.5, -8.6, -8.6, -8.4, -8.6, -8.7, -8.8, -8.7, -8.6, -8.4, -8.1, -8.1, -8.2, -8.4, -8.4, -8.4, -8.3, -8.2, -8.2, -8.1, -8.3, -8.5, -8.7, -8.9 ) val temperature_975hPa = doubleArrayOf( -10.3, -10.5, -10.5, -10.3, -10.5, -10.6, -10.7, -10.7, -10.6, -10.4, -10.1, -10.1, -10.2, -10.4, -10.4, -10.4, -10.2, -10.1, -10.1, -9.9, -10.0, -10.2, -10.5, -10.5 ) val temperature_950hPa = doubleArrayOf( -12.2, -12.3, -12.3, -12.2, -12.4, -12.5, -12.6, -12.7, -12.6, -12.4, -12.1, -12.1, -12.2, -12.4, -12.3, -12.3, -12.2, -12.0, -12.0, -11.8, -11.8, -12.0, -12.3, -12.1 ) val temperature_925hPa = doubleArrayOf( -13.0, -13.2, -13.6, -13.7, -14.0, -14.2, -14.3, -14.4, -14.4, -14.3, -14.1, -14.1, -14.1, -14.2, -14.1, -14.1, -14.0, -13.9, -13.9, -13.8, -13.6, -13.7, -13.9, -13.8 ) val temperature_900hPa = doubleArrayOf( -11.6, -11.9, -12.2, -12.2, -12.4, -12.5, -12.6, -12.8, -13.4, -14.0, -14.2, -14.2, -14.8, -14.8, -14.9, -15.1, -15.2, -15.7, -15.9, -15.7, -15.4, -15.5, -15.5, -15.6 ) val temperature_850hPa = doubleArrayOf( -9.5, -9.9, -10.0, -9.9, -9.9, -9.8, -10.0, -10.4, -11.0, -11.5, -11.7, -12.2, -12.7, -13.2, -13.5, -14.1, -14.5, -14.7, -14.8, -14.7, -14.8, -15.4, -15.2, -14.6 ) val temperature_800hPa = doubleArrayOf( -11.1, -11.4, -11.4, -11.5, -11.7, -11.9, -12.1, -12.2, -12.4, -12.7, -13.0, -13.5, -13.7, -14.6, -14.9, -15.3, -15.7, -15.9, -16.3, -17.0, -17.5, -17.5, -17.6, -17.4 ) val temperature_700hPa = doubleArrayOf( -16.0, -16.4, -16.4, -16.3, -16.1, -16.1, -16.0, -16.1, -16.3, -16.4, -16.4, -16.4, -16.7, -17.2, -18.1, -18.6, -19.0, -19.3, -19.6, -20.2, -20.8, -20.7, -20.5, -20.5 ) val temperature_600hPa = doubleArrayOf( -23.6, -23.6, -23.8, -23.8, -23.9, -23.8, -23.8, -23.6, -23.4, -23.6, -23.6, -23.8, -23.8, -23.9, -24.1, -24.3, -24.5, -24.5, -24.7, -24.7, -24.7, -24.5, -23.9, -23.8 ) val temperature_500hPa = doubleArrayOf( -32.0, -32.4, -32.7, -32.7, -32.7, -32.7, -32.9, -33.1, -33.4, -33.6, -33.6, -33.8, -33.8, -33.6, -33.6, -33.4, -33.4, -33.1, -33.1, -33.1, -32.9, -32.4, -32.4, -32.2 ) val temperature_400hPa = doubleArrayOf( -40.4, -40.4, -40.4, -40.4, -40.4, -40.7, -41.0, -41.4, -41.7, -41.7, -42.0, -42.3, -42.6, -43.3, -43.3, -43.3, -43.3, -43.0, -42.6, -42.6, -42.3, -42.0, -41.7, -40.7 ) val temperature_300hPa = doubleArrayOf( -53.0, -53.5, -53.5, -54.0, -54.0, -54.5, -54.0, -54.0, -54.0, -54.0, -53.5, -53.0, -53.0, -52.5, -52.0, -51.0, -50.5, -50.5, -51.0, -50.5, -50.0, -50.0, -49.0, -49.0 ) val temperature_250hPa = doubleArrayOf( -58.0, -57.5, -57.0, -57.0, -56.5, -56.5, -56.0, -56.0, -55.5, -55.5, -55.0, -54.5, -54.0, -53.5, -53.0, -52.5, -52.0, -52.0, -52.0, -51.5, -51.5, -51.5, -52.0, -52.0 ) val temperature_200hPa = doubleArrayOf( -56.5, -56.0, -56.0, -56.5, -56.5, -56.0, -56.0, -56.0, -56.0, -56.0, -55.5, -55.0, -54.5, -54.5, -54.0, -53.5, -54.0, -53.5, -53.0, -53.0, -53.0, -53.0, -53.0, -53.5 ) val temperature_150hPa = doubleArrayOf( -57.5, -57.5, -58.0, -58.0, -58.0, -57.5, -57.5, -57.5, -57.5, -57.0, -57.0, -56.5, -56.5, -56.5, -56.5, -57.0, -56.5, -56.5, -56.5, -56.5, -56.5, -56.5, -56.5, -56.0 ) val temperature_100hPa = doubleArrayOf( -62.5, -62.5, -62.5, -62.5, -62.0, -62.0, -62.0, -62.5, -62.0, -62.0, -62.0, -62.0, -62.0, -62.0, -62.0, -62.0, -61.5, -61.5, -61.5, -61.0, -61.0, -61.0, -61.0, -61.0 ) val temperature_70hPa = doubleArrayOf( -66.5, -66.5, -66.0, -66.0, -65.5, -65.5, -66.0, -65.5, -65.5, -65.5, -65.5, -65.5, -65.5, -66.0, -66.0, -65.5, -65.5, -65.5, -65.0, -65.0, -65.5, -65.0, -65.5, -65.0 ) val temperature_50hPa = doubleArrayOf( -69.0, -69.0, -69.0, -68.5, -68.5, -69.0, -69.0, -69.0, -69.0, -69.0, -69.0, -68.5, -69.0, -69.0, -68.5, -69.0, -68.0, -68.0, -68.5, -68.5, -68.5, -68.5, -69.0, -69.0 ) val temperature_30hPa = doubleArrayOf( -70.5, -70.0, -70.5, -70.5, -71.0, -71.0, -71.0, -71.0, -71.0, -71.0, -71.0, -71.0, -71.0, -71.0, -71.0, -71.5, -71.5, -71.5, -71.5, -71.5, -71.5, -71.5, -71.0, -71.5 ) val relativehumidity_1000hPa = doubleArrayOf( 80.0, 80.0, 80.0, 80.0, 78.0, 78.0, 76.0, 76.0, 76.0, 73.0, 72.0, 72.0, 75.0, 75.0, 75.0, 75.0, 75.0, 75.0, 74.0, 70.0, 84.0, 74.0, 79.0, 84.0 ) val relativehumidity_975hPa = doubleArrayOf( 86.0, 87.0, 87.0, 88.0, 86.0, 87.0, 85.0, 85.0, 84.0, 82.0, 80.0, 80.0, 84.0, 85.0, 85.0, 84.0, 84.0, 82.0, 80.0, 76.0, 88.0, 81.0, 86.0, 88.0 ) val relativehumidity_950hPa = doubleArrayOf( 93.0, 94.0, 94.0, 96.0, 95.0, 96.0, 94.0, 94.0, 93.0, 91.0, 89.0, 88.0, 92.0, 95.0, 95.0, 93.0, 93.0, 90.0, 87.0, 83.0, 93.0, 88.0, 94.0, 92.0 ) val relativehumidity_925hPa = doubleArrayOf( 88.0, 89.0, 90.0, 92.0, 94.0, 99.0, 98.0, 99.0, 100.0, 100.0, 93.0, 96.0, 100.0, 100.0, 100.0, 100.0, 100.0, 98.0, 96.0, 92.0, 93.0, 88.0, 87.0, 93.0 ) val relativehumidity_900hPa = doubleArrayOf( 87.0, 88.0, 88.0, 89.0, 88.0, 90.0, 89.0, 88.0, 83.0, 84.0, 88.0, 89.0, 95.0, 89.0, 93.0, 97.0, 97.0, 100.0, 100.0, 100.0, 90.0, 89.0, 88.0, 90.0 ) val relativehumidity_850hPa = doubleArrayOf( 90.0, 91.0, 92.0, 93.0, 92.0, 91.0, 91.0, 91.0, 92.0, 65.0, 43.0, 53.0, 55.0, 56.0, 56.0, 63.0, 67.0, 64.0, 63.0, 58.0, 57.0, 61.0, 65.0, 58.0 ) val relativehumidity_800hPa = doubleArrayOf( 89.0, 90.0, 90.0, 90.0, 90.0, 90.0, 89.0, 89.0, 88.0, 90.0, 79.0, 63.0, 58.0, 40.0, 45.0, 49.0, 49.0, 41.0, 40.0, 43.0, 40.0, 32.0, 41.0, 37.0 ) val relativehumidity_700hPa = doubleArrayOf( 84.0, 87.0, 83.0, 82.0, 79.0, 78.0, 73.0, 43.0, 42.0, 36.0, 33.0, 30.0, 28.0, 31.0, 38.0, 34.0, 31.0, 32.0, 32.0, 33.0, 22.0, 16.0, 12.0, 10.0 ) val relativehumidity_600hPa = doubleArrayOf( 80.0, 79.0, 79.0, 76.0, 68.0, 58.0, 38.0, 30.0, 25.0, 22.0, 22.0, 16.0, 18.0, 22.0, 29.0, 32.0, 31.0, 30.0, 18.0, 18.0, 21.0, 16.0, 11.0, 10.0 ) val relativehumidity_500hPa = doubleArrayOf( 27.0, 26.0, 27.0, 26.0, 21.0, 24.0, 26.0, 26.0, 31.0, 34.0, 39.0, 37.0, 36.0, 27.0, 23.0, 21.0, 20.0, 19.0, 17.0, 16.0, 16.0, 17.0, 17.0, 14.0 ) val relativehumidity_400hPa = doubleArrayOf( 10.0, 12.0, 10.0, 10.0, 8.0, 10.0, 12.0, 13.0, 15.0, 13.0, 13.0, 13.0, 12.0, 13.0, 13.0, 13.0, 12.0, 12.0, 12.0, 10.0, 12.0, 12.0, 10.0, 7.0 ) val relativehumidity_300hPa = doubleArrayOf( 10.0, 8.0, 8.0, 10.0, 16.0, 18.0, 16.0, 16.0, 16.0, 14.0, 12.0, 10.0, 8.0, 8.0, 6.0, 6.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 6.0, 4.0 ) val relativehumidity_250hPa = doubleArrayOf( 9.0, 9.0, 7.0, 7.0, 4.0, 4.0, 4.0, 4.0, 4.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ) val relativehumidity_200hPa = doubleArrayOf( 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ) val relativehumidity_150hPa = doubleArrayOf( 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, ) val relativehumidity_100hPa = doubleArrayOf( 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, ) val relativehumidity_70hPa = doubleArrayOf( 4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0, ) val relativehumidity_50hPa = doubleArrayOf( 4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0, ) val relativehumidity_30hPa = doubleArrayOf( 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, ) val winddirection_1000hPa = doubleArrayOf( 325.0, 327.0, 327.0, 327.0, 327.0, 328.0, 328.0, 333.0, 336.0, 339.0, 334.0, 333.0, 334.0, 331.0, 333.0, 335.0, 336.0, 337.0, 336.0, 331.0, 308.0, 309.0, 312.0, 290.0 ) val winddirection_975hPa = doubleArrayOf( 339.0, 340.0, 339.0, 338.0, 336.0, 336.0, 336.0, 336.0, 339.0, 341.0, 336.0, 335.0, 335.0, 333.0, 336.0, 339.0, 341.0, 343.0, 344.0, 340.0, 319.0, 324.0, 322.0, 315.0 ) val winddirection_950hPa = doubleArrayOf( 343.0, 344.0, 343.0, 342.0, 340.0, 338.0, 339.0, 338.0, 340.0, 341.0, 336.0, 335.0, 335.0, 334.0, 337.0, 341.0, 342.0, 345.0, 346.0, 343.0, 322.0, 328.0, 326.0, 321.0 ) val winddirection_925hPa = doubleArrayOf( 6.0, 8.0, 7.0, 5.0, 1.0, 347.0, 348.0, 338.0, 343.0, 342.0, 337.0, 335.0, 335.0, 334.0, 338.0, 341.0, 343.0, 347.0, 349.0, 344.0, 335.0, 339.0, 336.0, 331.0 ) val winddirection_900hPa = doubleArrayOf( 2.0, 6.0, 8.0, 10.0, 10.0, 4.0, 356.0, 350.0, 349.0, 349.0, 346.0, 345.0, 347.0, 349.0, 348.0, 349.0, 352.0, 348.0, 349.0, 344.0, 342.0, 344.0, 336.0, 342.0 ) val winddirection_850hPa = doubleArrayOf( 350.0, 350.0, 354.0, 360.0, 3.0, 359.0, 351.0, 342.0, 339.0, 337.0, 348.0, 358.0, 7.0, 8.0, 6.0, 5.0, 1.0, 358.0, 351.0, 343.0, 341.0, 335.0, 344.0, 343.0 ) val winddirection_800hPa = doubleArrayOf( 14.0, 7.0, 356.0, 344.0, 342.0, 338.0, 334.0, 330.0, 324.0, 324.0, 324.0, 328.0, 332.0, 353.0, 357.0, 355.0, 356.0, 346.0, 337.0, 330.0, 326.0, 337.0, 342.0, 344.0 ) val winddirection_700hPa = doubleArrayOf( 343.0, 338.0, 334.0, 330.0, 327.0, 306.0, 285.0, 275.0, 278.0, 275.0, 285.0, 300.0, 307.0, 317.0, 327.0, 324.0, 316.0, 310.0, 309.0, 308.0, 312.0, 328.0, 335.0, 331.0 ) val winddirection_600hPa = doubleArrayOf( 338.0, 333.0, 325.0, 309.0, 302.0, 299.0, 298.0, 297.0, 294.0, 288.0, 280.0, 278.0, 283.0, 288.0, 293.0, 296.0, 292.0, 293.0, 296.0, 305.0, 313.0, 313.0, 317.0, 321.0 ) val winddirection_500hPa = doubleArrayOf( 297.0, 293.0, 295.0, 294.0, 298.0, 302.0, 299.0, 296.0, 289.0, 282.0, 272.0, 267.0, 267.0, 273.0, 280.0, 288.0, 297.0, 303.0, 312.0, 319.0, 321.0, 324.0, 327.0, 330.0 ) val winddirection_400hPa = doubleArrayOf( 235.0, 256.0, 272.0, 279.0, 285.0, 284.0, 279.0, 273.0, 270.0, 264.0, 262.0, 257.0, 258.0, 261.0, 268.0, 277.0, 291.0, 309.0, 320.0, 323.0, 325.0, 331.0, 338.0, 342.0 ) val winddirection_300hPa = doubleArrayOf( 236.0, 240.0, 243.0, 238.0, 245.0, 253.0, 251.0, 255.0, 256.0, 255.0, 252.0, 251.0, 254.0, 260.0, 268.0, 283.0, 306.0, 320.0, 332.0, 342.0, 343.0, 346.0, 347.0, 349.0 ) val winddirection_250hPa = doubleArrayOf( 229.0, 224.0, 224.0, 229.0, 237.0, 245.0, 250.0, 250.0, 251.0, 253.0, 257.0, 260.0, 267.0, 275.0, 287.0, 300.0, 313.0, 325.0, 333.0, 337.0, 343.0, 344.0, 344.0, 344.0 ) val winddirection_200hPa = doubleArrayOf( 238.0, 240.0, 246.0, 252.0, 254.0, 255.0, 254.0, 252.0, 252.0, 256.0, 263.0, 272.0, 284.0, 299.0, 312.0, 321.0, 329.0, 335.0, 338.0, 341.0, 339.0, 342.0, 343.0, 344.0 ) val winddirection_150hPa = doubleArrayOf( 253.0, 256.0, 255.0, 251.0, 247.0, 249.0, 256.0, 266.0, 274.0, 286.0, 299.0, 306.0, 309.0, 312.0, 321.0, 326.0, 331.0, 330.0, 335.0, 337.0, 340.0, 341.0, 342.0, 338.0 ) val winddirection_100hPa = doubleArrayOf( 250.0, 251.0, 256.0, 263.0, 272.0, 280.0, 284.0, 286.0, 283.0, 285.0, 290.0, 296.0, 299.0, 304.0, 310.0, 322.0, 327.0, 332.0, 335.0, 336.0, 333.0, 337.0, 342.0, 338.0) val winddirection_70hPa = doubleArrayOf( 251.0, 253.0, 259.0, 271.0, 281.0, 288.0, 289.0, 286.0, 288.0, 289.0, 291.0, 290.0, 297.0, 306.0, 315.0, 318.0, 324.0, 324.0, 327.0, 327.0, 337.0, 337.0, 337.0, 338.0 ) val winddirection_50hPa = doubleArrayOf( 270.0, 276.0, 279.0, 283.0, 281.0, 277.0, 270.0, 270.0, 276.0, 282.0, 286.0, 290.0, 295.0, 300.0, 306.0, 313.0, 314.0, 315.0, 322.0, 326.0, 326.0, 328.0, 331.0, 333.0 ) val winddirection_30hPa = doubleArrayOf( 262.0, 263.0, 264.0, 265.0, 266.0, 268.0, 272.0, 276.0, 280.0, 281.0, 282.0, 283.0, 284.0, 286.0, 289.0, 295.0, 299.0, 300.0, 302.0, 302.0, 303.0, 306.0, 310.0, 315.0 ) val windspeed_1000hPa = doubleArrayOf( 10.1, 9.9, 9.9, 9.9, 9.9, 10.2, 10.2, 11.3, 10.6, 11.2, 10.8, 11.3, 10.8, 11.1, 11.8, 11.9, 11.4, 10.2, 9.8, 9.0, 8.2, 10.2, 10.2, 8.4 ) val windspeed_975hPa = doubleArrayOf( 20.0, 19.9, 19.5, 18.9, 18.7, 19.2, 19.1, 19.9, 19.1, 19.5, 18.9, 19.5, 19.2, 19.7, 21.4, 23.1, 22.8, 21.8, 21.0, 20.2, 19.5, 21.5, 20.5, 20.5 ) val windspeed_950hPa = doubleArrayOf( 30.4, 30.3, 29.5, 28.2, 27.7, 28.3, 28.2, 28.5, 27.5, 27.8, 27.0, 27.7, 27.7, 28.4, 31.1, 34.4, 34.2, 33.6, 32.3, 31.6, 30.9, 33.2, 30.9, 33.6 ) val windspeed_925hPa = doubleArrayOf( 35.6, 35.7, 35.3, 33.9, 32.2, 31.8, 33.3, 29.4, 30.7, 29.6, 31.0, 29.3, 28.8, 29.1, 31.7, 35.7, 36.1, 38.3, 36.5, 35.9, 35.6, 40.0, 39.2, 36.9 ) val windspeed_900hPa = doubleArrayOf( 29.7, 32.0, 31.7, 29.3, 25.5, 22.7, 23.5, 27.2, 31.5, 31.6, 32.8, 30.8, 30.5, 29.9, 33.0, 36.2, 36.8, 39.4, 37.1, 36.6, 36.5, 37.4, 36.2, 34.4 ) val windspeed_850hPa = doubleArrayOf( 23.2, 25.0, 24.8, 23.2, 20.5, 18.2, 17.1, 17.7, 21.9, 25.3, 28.9, 31.9, 31.7, 33.6, 32.6, 34.3, 34.2, 32.4, 31.8, 30.4, 32.9, 35.3, 37.1, 34.9 ) val windspeed_800hPa = doubleArrayOf( 16.0, 15.6, 15.5, 16.6, 17.4, 17.7, 18.3, 20.2, 21.5, 25.4, 28.6, 28.3, 28.4, 27.2, 28.5, 29.6, 30.1, 29.8, 28.7, 30.5, 32.4, 32.5, 33.7, 32.8 ) val windspeed_700hPa = doubleArrayOf( 14.9, 14.8, 15.8, 15.0, 12.6, 11.5, 12.2, 15.6, 18.8, 21.2, 23.8, 26.4, 27.9, 29.0, 29.6, 28.4, 26.8, 26.9, 25.6, 25.2, 26.8, 31.5, 38.3, 39.7 ) val windspeed_600hPa = doubleArrayOf( 19.4, 18.3, 17.0, 18.0, 18.4, 20.5, 21.2, 22.0, 22.3, 23.3, 22.5, 24.0, 26.0, 25.9, 26.8, 26.3, 25.7, 27.5, 28.2, 30.0, 30.1, 29.0, 34.7, 40.1 ) val windspeed_500hPa = doubleArrayOf( 16.1, 18.3, 22.5, 29.0, 32.8, 34.0, 31.7, 30.6, 29.2, 28.2, 27.6, 26.4, 26.4, 26.4, 28.0, 27.7, 26.8, 28.6, 30.6, 33.2, 34.1, 38.6, 39.9, 41.4 ) val windspeed_400hPa = doubleArrayOf( 29.3, 29.7, 34.8, 38.9, 42.2, 44.5, 43.8, 43.3, 44.4, 44.7, 44.8, 44.3, 41.7, 36.5, 31.2, 29.0, 29.6, 32.4, 35.8, 36.0, 39.6, 46.7, 50.6, 60.7 ) val windspeed_300hPa = doubleArrayOf( 36.3, 33.3, 33.8, 31.3, 31.7, 33.8, 36.8, 41.0, 45.7, 49.8, 47.8, 44.4, 39.9, 35.3, 31.2, 25.9, 26.6, 31.5, 40.8, 49.3, 57.7, 63.2, 77.7, 102.6 ) val windspeed_250hPa = doubleArrayOf( 33.2, 33.1, 33.1, 33.2, 33.0, 34.4, 35.7, 34.6, 33.0, 32.6, 30.9, 28.0, 26.4, 25.3, 25.1, 26.3, 29.7, 35.3, 40.2, 49.5, 56.6, 63.8, 76.0, 88.5 ) val windspeed_200hPa = doubleArrayOf( 36.6, 33.3, 32.8, 30.4, 26.2, 23.6, 21.3, 22.8, 23.9, 24.7, 27.8, 28.8, 29.7, 30.1, 30.6, 34.1, 37.7, 39.7, 44.1, 48.2, 53.9, 61.9, 70.2, 76.3 ) val windspeed_150hPa = doubleArrayOf( 32.6, 29.7, 27.4, 25.4, 24.7, 27.0, 29.7, 31.3, 31.3, 31.2, 30.1, 26.6, 26.4, 28.9, 34.1, 36.3, 39.7, 45.7, 47.8, 52.2, 58.8, 63.4, 65.6, 73.8 ) val windspeed_100hPa = doubleArrayOf( 34.6, 36.8, 39.6, 39.9, 38.4, 34.1, 29.7, 26.2, 25.9, 28.5, 31.9, 33.3, 34.4, 38.9, 42.6, 44.4, 48.6, 48.8, 50.5, 52.6, 60.6, 69.3, 72.1, 76.4 ) val windspeed_70hPa = doubleArrayOf( 50.9, 53.9, 56.2, 55.2, 50.1, 42.9, 36.8, 34.9, 35.3, 36.8, 37.2, 38.3, 45.6, 49.0, 47.5, 50.1, 53.3, 55.0, 54.6, 66.9, 65.1, 66.7, 70.4, 75.3 ) val windspeed_50hPa = doubleArrayOf( 68.4, 61.5, 54.6, 49.2, 42.8, 41.1, 43.2, 50.4, 55.5, 56.5, 56.2, 58.8, 59.6, 59.7, 61.0, 62.0, 58.6, 62.8, 66.7, 62.2, 68.2, 69.6, 75.2, 78.4 ) val windspeed_30hPa = doubleArrayOf( 89.6, 88.3, 86.9, 84.3, 86.6, 87.6, 90.0, 89.3, 84.0, 77.0, 77.2, 77.7, 79.2, 79.8, 82.3, 84.8, 78.4, 81.7, 80.3, 79.2, 81.5, 84.3, 81.7, 86.5 ) val cloudcover_1000hPa = doubleArrayOf( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ) val cloudcover_975hPa = doubleArrayOf( 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.0, 0.0, 0.0, 4.0 ) val cloudcover_950hPa = doubleArrayOf( 32.0, 37.0, 37.0, 49.0, 42.0, 49.0, 37.0, 37.0, 32.0, 23.0, 15.0, 11.0, 27.0, 42.0, 42.0, 32.0, 32.0, 19.0, 7.0, 0.0, 32.0, 11.0, 37.0, 27.0 ) val cloudcover_925hPa = doubleArrayOf( 16.0, 20.0, 24.0, 32.0, 41.0, 76.0, 66.0, 76.0, 100.0, 100.0, 36.0, 52.0, 100.0, 100.0, 100.0, 100.0, 100.0, 66.0, 52.0, 32.0, 36.0, 16.0, 13.0, 36.0 ) val cloudcover_900hPa = doubleArrayOf( 17.0, 21.0, 21.0, 24.0, 21.0, 28.0, 24.0, 21.0, 6.0, 8.0, 21.0, 24.0, 49.0, 24.0, 39.0, 60.0, 60.0, 100.0, 100.0, 100.0, 28.0, 24.0, 21.0, 28.0 ) val cloudcover_850hPa = doubleArrayOf( 34.0, 37.0, 41.0, 45.0, 41.0, 37.0, 37.0, 37.0, 41.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ) val cloudcover_800hPa = doubleArrayOf( 35.0, 38.0, 38.0, 38.0, 38.0, 38.0, 35.0, 35.0, 32.0, 38.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ) val cloudcover_700hPa = doubleArrayOf( 27.0, 33.0, 25.0, 22.0, 15.0, 13.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ) val cloudcover_600hPa = doubleArrayOf( 18.0, 16.0, 16.0, 11.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ) val cloudcover_500hPa = doubleArrayOf( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ) val cloudcover_400hPa = doubleArrayOf( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ) val cloudcover_300hPa = doubleArrayOf( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ) val cloudcover_250hPa = doubleArrayOf( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ) val cloudcover_200hPa = doubleArrayOf( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ) val cloudcover_150hPa = doubleArrayOf( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ) val cloudcover_100hPa = doubleArrayOf( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ) val cloudcover_70hPa = doubleArrayOf( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ) val cloudcover_50hPa = doubleArrayOf( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ) val cloudcover_30hPa = doubleArrayOf( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ) @RequiresApi(Build.VERSION_CODES.O) fun m9g() { val dArr4 = f4983V0 //Атмосферное давление пересчитанное val f4992Y0: DoubleArray = DoubleArray(dArr4.size) //ПУстой массив. В итоге направление ветра по выбранному часу val f5010d1: DoubleArray = DoubleArray(dArr4.size) //ПУстой массив. В итоге температура по выбранному часу val f5002b1: DoubleArray = DoubleArray(dArr4.size) //Относительная влажность по выбранному часу val f5006c1: DoubleArray = DoubleArray(dArr4.size) // geopotential height val f4998a1: DoubleArray = DoubleArray(dArr4.size) //Направление ветра в тысячных??? val f5014e1: DoubleArray = DoubleArray(dArr4.size) // Скорость ветра val f5018f1: DoubleArray = DoubleArray(dArr4.size) // val f5022g1: DoubleArray = DoubleArray(dArr4.size) // облачность val f5026h1: DoubleArray = DoubleArray(dArr4.size) // Что то с ветром (зависит от f5022g1) val f5030i1: DoubleArray = DoubleArray(dArr4.size) // Что то с ветром (зависит от f5022g1) val f5034j1: DoubleArray = DoubleArray(dArr4.size) /**temperature*/ val f4968Q0: Array<DoubleArray> = arrayOf<DoubleArray>(temperature_1000hPa, temperature_975hPa, temperature_950hPa, temperature_925hPa, temperature_900hPa, temperature_850hPa, temperature_800hPa, temperature_700hPa, temperature_600hPa, temperature_500hPa, temperature_400hPa, temperature_300hPa, temperature_250hPa, temperature_200hPa, temperature_150hPa, temperature_100hPa, temperature_70hPa, temperature_50hPa, temperature_30hPa) /**temperature_2m*/ val f5089x0 = arrayOf( -8.8, -8.8, -8.9, -8.8, -8.9, -9.0, -9.0, -8.9, -8.7, -8.5, -8.1, -8.2, -8.4, -8.6, -8.6, -8.7, -8.6, -8.5, -8.5, -8.4, -8.6, -8.8, -9.1, -9.3 ) /**relativehumidity_2m*/ val f5093y0 = arrayOf( 80.0, 80.0, 80.0, 80.0, 79.0, 79.0, 77.0, 76.0, 76.0, 73.0, 73.0, 72.0, 76.0, 75.0, 75.0, 76.0, 76.0, 76.0, 74.0, 72.0, 85.0, 75.0, 80.0, 85.0 ) /**windspeed_10m*/ val f4909A0 = arrayOf( 9.9, 9.7, 9.7, 9.9, 9.9, 10.2, 10.0, 11.3, 10.6, 11.2, 10.8, 11.1, 10.8, 11.1, 11.6, 11.8, 11.3, 10.0, 9.5, 9.3, 8.2, 10.0, 9.7, 8.0 ) /**relativehumidity*/ val f4971R0: Array<DoubleArray> = arrayOf<DoubleArray>(relativehumidity_1000hPa, relativehumidity_975hPa, relativehumidity_950hPa, relativehumidity_925hPa, relativehumidity_900hPa, relativehumidity_850hPa, relativehumidity_800hPa, relativehumidity_700hPa, relativehumidity_600hPa, relativehumidity_500hPa, relativehumidity_400hPa, relativehumidity_300hPa, relativehumidity_250hPa, relativehumidity_200hPa, relativehumidity_150hPa, relativehumidity_100hPa, relativehumidity_70hPa, relativehumidity_50hPa, relativehumidity_30hPa) /**winddirection*/ val f4974S0: Array<DoubleArray> = arrayOf<DoubleArray>(winddirection_1000hPa, winddirection_975hPa, winddirection_950hPa, winddirection_925hPa, winddirection_900hPa, winddirection_850hPa, winddirection_800hPa, winddirection_700hPa, winddirection_600hPa, winddirection_500hPa, winddirection_400hPa, winddirection_300hPa, winddirection_250hPa, winddirection_200hPa, winddirection_150hPa, winddirection_100hPa, winddirection_70hPa, winddirection_50hPa, winddirection_30hPa) /**windspeed*/ val f4977T0: Array<DoubleArray> = arrayOf<DoubleArray>(windspeed_1000hPa, windspeed_975hPa, windspeed_950hPa, windspeed_925hPa, windspeed_900hPa, windspeed_850hPa, windspeed_800hPa, windspeed_700hPa, windspeed_600hPa, windspeed_500hPa, windspeed_400hPa, windspeed_300hPa, windspeed_250hPa, windspeed_200hPa, windspeed_150hPa, windspeed_100hPa, windspeed_70hPa, windspeed_50hPa, windspeed_30hPa) /**cloudcover*/ val f4980U0: Array<DoubleArray> = arrayOf<DoubleArray>( cloudcover_1000hPa, cloudcover_975hPa, cloudcover_950hPa, cloudcover_925hPa, cloudcover_900hPa, cloudcover_850hPa, cloudcover_800hPa, cloudcover_700hPa, cloudcover_600hPa, cloudcover_500hPa, cloudcover_400hPa, cloudcover_300hPa, cloudcover_250hPa, cloudcover_200hPa, cloudcover_150hPa, cloudcover_100hPa, cloudcover_70hPa, cloudcover_50hPa, cloudcover_30hPa ) /**visibility*/ val f4917C0: Array<Double> = arrayOf<Double>( 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 24140.00, 23480.00 ) /**cloudcover*/ val f4921D0: Array<Double> = arrayOf<Double>( 92.0, 97.0, 95.0, 90.0, 92.0, 92.0, 93.0, 99.0, 96.0, 100.0, 97.0, 97.0, 100.0, 100.0, 100.0, 100.0, 100.0, 91.0, 100.0, 93.0, 96.0, 73.0, 74.0, 79.0 ) /**precipiation*/ val f4925E0: Array<Double> = arrayOf<Double>( 0.10, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00) /**weathercode*/ val f4929F0: Array<Double> = arrayOf( 71.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 71.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 2.0, 2.0, 2.0 ) /**Высота*/ val f5071s2 = 0 /**winddirection_10m*/ val f4913B0 = arrayOf( 327.0, 329.0, 329.0, 327.0, 327.0, 328.0, 330.0, 333.0, 336.0, 339.0, 334.0, 335.0, 334.0, 331.0, 334.0, 337.0, 338.0, 339.0, 335.0, 332.0, 308.0, 311.0, 312.0, 288.0 ) /**geopotential_height*/ val f4965P0: Array<DoubleArray> = arrayOf<DoubleArray>( geopotential_height_1000hPa, geopotential_height_975hPa, geopotential_height_950hPa, geopotential_height_925hPa, geopotential_height_900hPa, geopotential_height_850hPa, geopotential_height_800hPa, geopotential_height_700hPa, geopotential_height_600hPa, geopotential_height_500hPa, geopotential_height_400hPa, geopotential_height_300hPa, geopotential_height_250hPa, geopotential_height_200hPa, geopotential_height_150hPa, geopotential_height_100hPa, geopotential_height_70hPa, geopotential_height_50hPa, geopotential_height_30hPa ) val currentDateTime = LocalDateTime.now() val parseDouble = 8 val correctedParseDouble = if (parseDouble < 0) parseDouble + 24 else parseDouble val i = if (parseDouble == 384) parseDouble else correctedParseDouble + 1 val f4933G0 = SimpleDateFormat("ss.SSS", Locale.getDefault()).format(Date()).toDouble() + (SimpleDateFormat("mm", Locale.getDefault()).format(Date()).toDouble() * 60.0) val d = (f5089x0[i] - f5089x0[correctedParseDouble]) / 3600.0 * f4933G0 val f4937H0 = d + f5089x0[correctedParseDouble] val f4941I0 = (f5093y0[i] - f5093y0[correctedParseDouble]) / 3600.0 * f4933G0 + f5093y0[correctedParseDouble] // println("f4941I0 = $f4941I0") val f4945J0 = d val f4949K0 = d * 0.750063755419211 val f4953L0 = ((((f4909A0[i] - f4909A0[correctedParseDouble]) / 3600.0) * f4933G0 + f4909A0[correctedParseDouble]) * 1000.0) / 3600.0 val d3 = 6.0 val f4956M0 = ((((f4913B0[i] - f4913B0[correctedParseDouble]) / 3600.0) * f4933G0 + f4913B0[correctedParseDouble]) * 100.0) / 6.0 f4917C0.get(parseDouble) f4917C0.get(i) f4917C0.get(parseDouble) f4921D0.get(parseDouble) f4921D0.get(i) f4921D0.get(parseDouble) f4925E0[parseDouble] f4925E0[i] f4925E0[parseDouble] f4929F0.get(parseDouble) val f4959N0 = Math.cos(Math.toRadians(f4956M0 / 100.0 * 6.0)) * f4953L0 val f4962O0 = Math.sin(Math.toRadians(f4956M0 / 100.0 * 6.0)) * f4953L0 val dArr3: DoubleArray = f4986W0 val f4989X0 = DoubleArray(dArr3.size) for (i2 in dArr3.indices) { f4989X0[i2] = f5071s2.toDouble() + dArr3[i2] } for (i3 in 0 until f4983V0.size) { f4992Y0[i3] = f4983V0[i3] * 0.750063755419211 val dArr5 = f4965P0[i3] val d4 = dArr5.get(correctedParseDouble) val d5 = f4933G0 val d6 = (((dArr5.get(i) - d4) / 3600.0) * d5) + d4 dArr5[i3] = d6 f4998a1[i3] = (d6 * 6356863.0188) / (6356863.0188 - d6) val dArr7 = f5002b1 val dArr8 = f4968Q0[i3] val d7 = dArr8[correctedParseDouble] dArr7[i3] = (((dArr8[i] - d7) / 3600.0) * d5) + d7 val dArr9 = f5006c1 val dArr10 = f4971R0[i3] val d8 = dArr10[correctedParseDouble] dArr9[i3] = (((dArr10[i] - d8) / 3600.0) * d5) + d8 val dArr11 = f5010d1 val dArr12 = f4974S0[i3] val d9 = dArr12[correctedParseDouble] val d10 = (((dArr12[i] - d9) / 3600.0) * d5) + d9 dArr11[i3] = d10 val dArr13 = f5014e1 dArr13[i3] = (d10 * 100.0) / 6.0 val dArr14 = f5018f1 val dArr15 = f4977T0[i3] val d11 = dArr15[correctedParseDouble] val d12 = (((dArr15[i] - d11) / 3600.0) * d5) + d11 dArr14[i3] = d12 val dArr16 = f5022g1 dArr16[i3] = (d12 * 1000.0) / 3600.0 val dArr17 = f5026h1 val dArr18 = f4980U0[i3] val d13 = dArr18[correctedParseDouble] dArr17[i3] = (((dArr18[i] - d13) / 3600.0) * d5) + d13 f5030i1[i3] = Math.cos(Math.toRadians((dArr13[i3] / 100.0) * 6.0)) * dArr16[i3] f5034j1[i3] = Math.sin(Math.toRadians((f5014e1[i3] / 100.0) * 6.0)) * f5022g1[i3] } val dArr19 = f4989X0 //темп val f5038k1 = DoubleArray(dArr19.size) //темп val f5042l1 = DoubleArray(dArr19.size) //темп val f5046m1 = DoubleArray(dArr19.size) //скорость ветра val f5050n1 = DoubleArray(dArr19.size) //направление ветра val f5054o1 = DoubleArray(dArr19.size) //скорость ветра val f5058p1 = DoubleArray(dArr19.size) //скорость ветра val f5062q1 = DoubleArray(dArr19.size) //направление ветра val f5066r1 = DoubleArray(dArr19.size) var dArr = f4989X0 for (i4 in f4989X0.indices) { if (i4 == 0) { f5038k1[i4] = f4945J0 f5042l1[i4] = f4949K0 f5046m1[i4] = f4937H0 f5050n1[i4] = f4941I0 f5054o1[i4] = f4956M0 f5058p1[i4] = f4953L0 f5062q1[i4] = Math.cos(Math.toRadians((f5054o1[i4] / 100.0) * 6.0)) * f5058p1[i4] f5066r1[i4] = Math.sin(Math.toRadians((f5054o1[i4] / 100.0) * 6.0)) * f5058p1[i4] } if (i4 > 0) { var i5 = 0 val dArr20 = f4998a1 while (i5 < dArr20.size) { if (i5 < dArr20.size - 1) { val d14 = f4989X0[i4] val d15 = dArr20[i5] if (d14 >= d15) { val i6 = i5 + 1 val d16 = dArr20[i6] if (d14 < d16) { val d17 = (d14 - d15) / (d16 - d15) val dArr21 = f5038k1 val d18 = f4983V0[i5] dArr21[i4] = ((f4983V0[i6] - d18) * d17) + d18 val dArr22 = f5042l1 val dArr23 = f4992Y0 val d19 = dArr23[i5] dArr22[i4] = ((dArr23[i6] - d19) * d17) + d19 val dArr24 = f5046m1 val dArr25 = f5002b1 val d20 = dArr25[i5] dArr24[i4] = ((dArr25[i6] - d20) * d17) + d20 val dArr26 = f5050n1 val dArr27 = f5006c1 val d21 = dArr27[i5] dArr26[i4] = ((dArr27[i6] - d21) * d17) + d21 val dArr28 = f5054o1 val dArr29 = f5014e1 val d22 = dArr29[i5] dArr28[i4] = ((dArr29[i6] - d22) * d17) + d22 val dArr30 = f5058p1 val dArr31 = f5022g1 val d23 = dArr31[i5] dArr30[i4] = ((dArr31[i6] - d23) * d17) + d23 val dArr32 = f5062q1 val dArr33 = f5030i1 val d24 = dArr33[i5] dArr32[i4] = ((dArr33[i6] - d24) * d17) + d24 val dArr34 = f5066r1 val dArr35 = f5034j1 val d25 = dArr35[i5] dArr34[i4] = ((dArr35[i6] - d25) * d17) + d25 } } } else if (f4989X0[i4] >= dArr20[i5]) { val dArr36 = f5038k1 val i7 = i4 - 1 dArr36[i4] = dArr36[i7] val dArr37 = f5042l1 dArr37[i4] = dArr37[i7] val dArr38 = f5046m1 dArr38[i4] = dArr38[i7] val dArr39 = f5050n1 dArr39[i4] = dArr39[i7] val dArr40 = f5054o1 dArr40[i4] = dArr40[i7] val dArr41 = f5058p1 dArr41[i4] = dArr41[i7] val dArr42 = f5062q1 dArr42[i4] = dArr42[i7] val dArr43 = f5066r1 dArr43[i4] = dArr43[i7] } i5++ } } } val dArr44 = DoubleArray(dArr.size) val dArr45 = DoubleArray(dArr.size) var i8 = 0 val dArr2 = f4989X0 while (i8 < dArr2.size) { dArr44[i8] = f5042l1[i8] - (f(dArr3[i8]) * 750.0) val d26 = f5046m1[i8] val d27 = 17.625 * d26 val d28 = d26 + 243.04 val pow = Math.pow(E, d27 / d28) * 6.1094 Math.pow(Math.pow(((pow * 4283.58) / Math.pow(d28, 2.0)) * 0.0, 2.0), 0.5) val d29 = f5046m1[i8] val d30 = f5038k1[i8] val d31 = f5050n1[i8] val d32 = d29 + 273.0 val d33 = 0.378 * d31 val d34 = ((((d31 * 0.622) / 100.0) * pow) * (d32 * 0.608)) / (d30 - ((d33 / 100.0) * pow)) val d35 = d30 * 100.0 val d36 = d33 * 0.0 val pow2 = ((((((4283.58 / Math.pow(d29 + 243.04, 2.0)) * d32) + 1.0) * d35) - d36) * (((d31 * 0.608) * 0.622) * 0.0)) / Math.pow((pow * 100.0) - d36, 2.0) val d37 = d35 - d36 Math.pow(Math.pow(((((((d31 * 100.0) * 0.608) * 0.622) * 0.0) * d32) / Math.pow(d37, 2.0)) * 0.0, 2.0) + Math.pow((((((d35 * 0.608) * 0.622) * 0.0) * d32) / Math.pow(d37, 2.0)) * 0.0, 2.0) + Math.pow(pow2 * 0.0, 2.0), 0.5) dArr45[i8] = (f5046m1[i8] + d34) - (d(dArr3[i8]) - 273.0) i8++ } //темп val f5070s1 = DoubleArray(dArr2.size) val f5074t1 = DoubleArray(dArr2.size) //направление ветра 10 м val f5078u1 = DoubleArray(dArr2.size) // скорость ветра 10 м val f5082v1 = DoubleArray(dArr2.size) // val f5086w1 = DoubleArray(dArr2.size) val f5090x1 = DoubleArray(dArr2.size) var i9 = 0 val dArr46: DoubleArray = f4989X0 while (i9 < dArr46.size) { if (i9 == 0) { f5070s1[i9] = dArr44[i9] f5074t1[i9] = dArr45[i9] f5082v1[i9] = f5058p1[i9] f5078u1[i9] = f5054o1[i9] * 0.01 f5086w1[i9] = f5062q1[i9] f5090x1[i9] = f5066r1[i9] } if (i9 > 0) { val dArr47: DoubleArray = f5070s1 val i10 = i9 - 1 val d38 = dArr47[i10] val d39 = dArr46[i10] val d40 = dArr46[i9] dArr47[i9] = (d40 - d39) * dArr44[i9] / d40 + d38 * d39 / d40 val dArr48: DoubleArray = f5074t1 val d41 = dArr48[i10] val d42 = dArr46[i10] val d43 = dArr46[i9] dArr48[i9] = (d43 - d42) * dArr45[i9] / d43 + d41 * d42 / d43 val dArr49: DoubleArray = f5086w1 val d44 = dArr49[i10] val d45 = dArr46[i10] val d46 = dArr46[i9] dArr49[i9] = (d46 - d45) * f5062q1.get(i9) / d46 + d44 * d45 / d46 val dArr50: DoubleArray = f5090x1 val d47 = dArr50[i10] val d48 = dArr46[i10] val d49 = dArr46[i9] dArr50[i9] = (d49 - d48) * f5066r1.get(i9) / d49 + d47 * d48 / d49 f5082v1[i9] = Math.sqrt( Math.pow(Math.abs(f5090x1.get(i9)), 2.0) + Math.pow( Math.abs( dArr49[i9] ), 2.0 ) ) var acos = Math.acos(f5086w1.get(i9) / f5082v1.get(i9)) if (f5090x1.get(i9) < 0.0) { acos = 6.283185307179586 - acos } f5078u1[i9] = Math.toDegrees(acos) / 6.0 } i9++ } /**temperature 2 m*/ println(f5070s1.contentToString()) /**Первый параметр. Считается норм*/ println(f5074t1.contentToString()) /**Второй параметр. Считается норм*/ println(f5078u1.contentToString()) /**Третий параметр. Считается норм*/ println(f5082v1.contentToString()) println(f5086w1.contentToString()) println(f5090x1.contentToString()) }
CorouniteSample/app/src/main/java/com/example/corounitesample/Zevs.kt
1609747460
package com.example.englishwordsapp 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.englishwordsapp", appContext.packageName) } }
LearnEnglishApp_AZE/app/src/androidTest/java/com/example/englishwordsapp/ExampleInstrumentedTest.kt
1459099181
package com.example.englishwordsapp import org.junit.Test import org.junit.Assert.* /** * Example local unit test, which will execute on the development machine (host). * * See [testing documentation](http://d.android.com/tools/testing). */ class ExampleUnitTest { @Test fun addition_isCorrect() { assertEquals(4, 2 + 2) } }
LearnEnglishApp_AZE/app/src/test/java/com/example/englishwordsapp/ExampleUnitTest.kt
2394062741
package com.example.englishwordsapp.ui.splash 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.englishwordsapp.databinding.FragmentSplashBinding import com.example.englishwordsapp.ui.MainActivity import com.example.englishwordsapp.ui.MainActivityArgs class SplashFragment : Fragment() { private var binding: FragmentSplashBinding? = null override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { binding = FragmentSplashBinding.inflate(layoutInflater) return binding?.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) launchMainScreen(true) } private fun launchMainScreen(isSignedIn: Boolean){ val intent = Intent(requireContext(), MainActivity::class.java) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK) val args = MainActivityArgs(isSignedIn) intent.putExtras(args.toBundle()) startActivity(intent) } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/splash/SplashFragment.kt
20193281
package com.example.englishwordsapp.ui.splash import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import com.example.englishwordsapp.R class SplashActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_splash) } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/splash/SplashActivity.kt
3297761397
package com.example.englishwordsapp.ui import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import com.example.englishwordsapp.R import com.example.englishwordsapp.databinding.ActivityMainBinding import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint class MainActivity : AppCompatActivity() { private var binding: ActivityMainBinding? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding?.root) } private fun isSignedIn(): Boolean { val bundle = intent.extras ?: throw IllegalStateException("No required arguments") val args = MainActivityArgs.fromBundle(bundle) return args.isSignedIn } private fun getMainNavigationGraphId(): Int = R.navigation.main_graph private fun getTabsDestination(): Int = R.id.tabsFragment private fun getSignInDestination(): Int = R.id.signInFragment }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/MainActivity.kt
1640639601
package com.example.englishwordsapp.ui.auth import android.os.Bundle import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import com.example.englishwordsapp.R import com.example.englishwordsapp.databinding.FragmentSignInBinding class SignInFragment : Fragment() { private var binding: FragmentSignInBinding? = null override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { binding = FragmentSignInBinding.inflate(layoutInflater) return inflater.inflate(R.layout.fragment_sign_in, container, false) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/auth/SignInFragment.kt
2941021094
package com.example.englishwordsapp.ui.main.settings import android.os.Bundle import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import com.example.englishwordsapp.R class SettingsFragment : Fragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_settings, container, false) } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/settings/SettingsFragment.kt
4009615908
package com.example.englishwordsapp.ui.main.learn class SimpleWordsModel( val word: String?, val translationToAze: String?, val transcription: String?, val partOfSpeech: String?, val level: String?, ) { }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/SimpleWordsModel.kt
1562681974
package com.example.englishwordsapp.ui.main.learn.speechRecognition sealed class SpeechRecognitionAnswerWordState{ data object CORRECT : SpeechRecognitionAnswerWordState() data object WRONG : SpeechRecognitionAnswerWordState() data class Last(val countOfCorrectAnswer: Int) : SpeechRecognitionAnswerWordState() }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/speechRecognition/SpeechRecognitionAnswerWordState.kt
4225759167
package com.example.englishwordsapp.ui.main.learn.speechRecognition import android.content.Context import android.speech.tts.TextToSpeech import java.util.Locale import javax.inject.Inject class SoundPlayer @Inject constructor() { private lateinit var textToSpeech: TextToSpeech fun playSound(word: String, context: Context){ textToSpeech = TextToSpeech(context, null) textToSpeech.setLanguage(Locale.US) textToSpeech.speak(word, TextToSpeech.QUEUE_FLUSH, null, null) } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/speechRecognition/SoundPlayer.kt
3601314202
package com.example.englishwordsapp.ui.main.learn.speechRecognition import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.example.englishwordsapp.data.model.core.ResultWrapper import com.example.englishwordsapp.data.repositories.SpeechRecognitionRepositoryImpl import com.example.englishwordsapp.ui.main.learn.SimpleWordsModel import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import javax.inject.Inject @HiltViewModel class SpeechRecognitionViewModel @Inject constructor( private val speechRecognitionRepository: SpeechRecognitionRepositoryImpl, private val soundPlayer: SoundPlayer, private val wordsAnswerChecker: SpeechRecognitionAnswerChecker, ) : ViewModel() { private val _word = MutableLiveData<SimpleWordsModel>() val word: LiveData<SimpleWordsModel> = _word private val _state = MutableLiveData<SpeechRecognitionAnswerWordState>() val state: LiveData<SpeechRecognitionAnswerWordState> = _state private val _progress = MutableLiveData(0) val progress: LiveData<Int> = _progress private var countOfCorrectAnswer = 0 private val _countOfQuestions = MutableLiveData(0) val countOfQuestions: LiveData<Int> = _countOfQuestions private val wordsList = mutableListOf<SimpleWordsModel>() private var questionModelForSkipButton: SimpleWordsModel? = null fun startRecognition() { val word = wordsList.removeLast() questionModelForSkipButton = word _word.value = word _progress.value = wordsList.size } fun checkAnswer(userAnswer: String) { val word = _word.value?.word val isCorrect = wordsAnswerChecker.checkAnswer(word.toString(), userAnswer) if (wordsList.isEmpty()) { _state.value = SpeechRecognitionAnswerWordState.Last(countOfCorrectAnswer) _progress.value = wordsList.size } else { if (isCorrect) { _state.value = SpeechRecognitionAnswerWordState.CORRECT _progress.value = wordsList.size countOfCorrectAnswer++ } else { _state.value = SpeechRecognitionAnswerWordState.WRONG _progress.value = wordsList.size } } } fun skipWord() { if (wordsList.isNotEmpty()) { questionModelForSkipButton?.let { wordsList.add(0, it) } val word = wordsList.removeLast() questionModelForSkipButton = word _word.value = word } } // fun playSound(word: String){ // soundPlayer.playSound(word, context) // } fun loadWords(difficultyLevel: String) { wordsModelData.postValue(WordRecognitionState.Loading(true)) viewModelScope.launch { withContext(Dispatchers.IO) { speechRecognitionRepository.getWordsList(difficultyLevel).collect { when (it) { is ResultWrapper.Success -> { wordsModelData.postValue(WordRecognitionState.Loading(false)) wordsList.addAll(it.data) withContext(Dispatchers.Main) { _countOfQuestions.value = wordsList.size val word = wordsList.removeLast() questionModelForSkipButton = word _word.value = word _progress.value = wordsList.size } wordsModelData.postValue(WordRecognitionState.Success(_word.value!!)) } is ResultWrapper.Error -> { wordsModelData.postValue(WordRecognitionState.Loading(false)) wordsModelData.postValue(WordRecognitionState.Error(it.error.orEmpty())) } else -> { wordsModelData.postValue(WordRecognitionState.Loading(false)) } } } } } } val wordsModelData = MutableLiveData<WordRecognitionState>() }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/speechRecognition/SpeechRecognitionViewModel.kt
1142265546
package com.example.englishwordsapp.ui.main.learn.speechRecognition import android.content.Context import android.os.Bundle import android.speech.tts.TextToSpeech import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.view.inputmethod.InputMethodManager import androidx.core.content.ContextCompat import androidx.core.view.isVisible import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController import com.example.englishwordsapp.R import com.example.englishwordsapp.databinding.FragmentSpeechRecognitionBinding import com.example.englishwordsapp.ui.main.learn.ResultDialogFragment import dagger.hilt.android.AndroidEntryPoint import java.util.Locale @AndroidEntryPoint class SpeechRecognitionFragment : Fragment() { private var binding: FragmentSpeechRecognitionBinding? = null private lateinit var textToSpeech: TextToSpeech private var countOfAllQuestions: Int? = null private var isResultShown = false private val viewModel by viewModels<SpeechRecognitionViewModel>() override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { binding = FragmentSpeechRecognitionBinding.inflate(layoutInflater) textToSpeech = TextToSpeech(requireContext(), null) return binding?.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) val difficultyLevel = arguments?.getString("difficultyLevel") difficultyLevel?.let { viewModel.loadWords(it) } viewModel.progress.observe(viewLifecycleOwner){count-> count?.let { binding?.tvProgressCount?.text = count.toString() binding?.progressIndicator?.progress = count } } viewModel.countOfQuestions.observe(viewLifecycleOwner){count-> count?.let { countOfAllQuestions = count binding?.progressIndicator?.max = count } } viewModel.wordsModelData.observe(viewLifecycleOwner){word-> when(word){ is WordRecognitionState.Success->{ binding?.progressBarLoadingData?.isVisible = false // viewModel.playSound(word.listOfQuestions.word!!) textToSpeech.setLanguage(Locale.US) textToSpeech.speak(word.listOfQuestions.word, TextToSpeech.QUEUE_FLUSH, null, null) } is WordRecognitionState.Error -> { } is WordRecognitionState.Loading -> { binding?.progressBarLoadingData?.isVisible = word.isLoading } } } binding?.btConfirm?.setOnClickListener { hideKeyboard(binding?.btConfirm!!) viewModel.state.observe(viewLifecycleOwner) { state -> state?.let { when (state) { is SpeechRecognitionAnswerWordState.CORRECT -> { changeContinueButtonState(ContinueBtStates.CORRECT) } is SpeechRecognitionAnswerWordState.WRONG -> { changeContinueButtonState(ContinueBtStates.WRONG) } is SpeechRecognitionAnswerWordState.Last -> { if (!isResultShown){ showResult(state.countOfCorrectAnswer) isResultShown = true } } } } } viewModel.checkAnswer(binding?.etInputCorrectAnswer?.text.toString() .replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }) } binding?.imagePlaySpeaker?.setOnClickListener { viewModel.word.observe(viewLifecycleOwner){word-> word?.let { it.word?.let { it1 -> pronounceWord(it1) } // viewModel.playSound(word.word!!) } } } binding?.btContinue?.setOnClickListener { changeContinueButtonState(ContinueBtStates.NORMAL) viewModel.startRecognition() viewModel.word.observe(viewLifecycleOwner){word-> word?.let { it.word?.let { it1 -> pronounceWord(it1) } } } } binding?.btSkip?.setOnClickListener { viewModel.skipWord() viewModel.word.observe(viewLifecycleOwner){word-> word?.let { textToSpeech.setLanguage(Locale.US) textToSpeech.speak(it.word, TextToSpeech.QUEUE_FLUSH, null, null) } } } binding?.imageButtonClose?.setOnClickListener { findNavController().popBackStack() } } private fun hideKeyboard(view: View){ val inputMethodManager = requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0) } private fun pronounceWord(word: String){ textToSpeech.setLanguage(Locale.US) textToSpeech.speak(word, TextToSpeech.QUEUE_FLUSH, null, null) } private fun showResult(countOfCorrectAnswer: Int){ countOfAllQuestions?.let { val wrongAnswer = it - countOfCorrectAnswer val dialogFragment = ResultDialogFragment() dialogFragment.isCancelable = false dialogFragment.setScore(countOfCorrectAnswer.toString(), wrongAnswer.toString()) dialogFragment.show( parentFragmentManager, ResultDialogFragment::class.java.canonicalName ) } } // // private fun increaseStep() { // binding?.tvProgressCount?.text = listOfWords.size.toString() // binding?.progressIndicator?.progress = binding?.progressIndicator?.progress?.plus(1) ?: 0 // } // private fun changeContinueButtonState(buttonState: ContinueBtStates){ when(buttonState){ ContinueBtStates.CORRECT -> { binding?.btSkip?.isVisible = false binding?.continueButtonLayout?.isVisible = true binding?.continueButtonLayout?.setBackgroundResource(R.color.green) binding?.imageView?.setImageResource(R.drawable.ic_correct) binding?.tvCorrectOrWrong?.text = "Correct!" binding?.btContinue?.setTextColor(ContextCompat.getColor(requireContext(), R.color.green)) } ContinueBtStates.WRONG ->{ binding?.btSkip?.isVisible = false binding?.continueButtonLayout?.isVisible = true binding?.continueButtonLayout?.setBackgroundResource(R.color.red) binding?.imageView?.setImageResource(R.drawable.ic_incorrect) binding?.tvCorrectOrWrong?.text = "Wrong!" binding?.btContinue?.setTextColor(ContextCompat.getColor(requireContext(), R.color.red)) } ContinueBtStates.NORMAL ->{ binding?.continueButtonLayout?.isVisible = false binding?.btSkip?.isVisible = true binding?.etInputCorrectAnswer?.text?.clear() } } } private fun Boolean.isClickable(){ binding?.imagePlaySpeaker?.isClickable = this binding?.btConfirm?.isClickable = this binding?.etInputCorrectAnswer?.isClickable = this binding?.etInputCorrectAnswer?.text?.clear() } private enum class ContinueBtStates{ NORMAL, CORRECT, WRONG } override fun onDestroy() { if (::textToSpeech.isInitialized) { textToSpeech.stop() textToSpeech.shutdown() } super.onDestroy() } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/speechRecognition/SpeechRecognitionFragment.kt
3888815845
package com.example.englishwordsapp.ui.main.learn.speechRecognition import com.example.englishwordsapp.ui.main.learn.SimpleWordsModel import com.example.englishwordsapp.ui.main.learn.vocabulary.VocabularyState sealed class WordRecognitionState { data class Error(val errorException: String): WordRecognitionState() data class Success(val listOfQuestions: SimpleWordsModel): WordRecognitionState() class Loading(val isLoading: Boolean): WordRecognitionState() }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/speechRecognition/WordRecognitionState.kt
123813200
package com.example.englishwordsapp.ui.main.learn.speechRecognition import javax.inject.Inject class SpeechRecognitionAnswerChecker @Inject constructor() { fun checkAnswer(wrightAnswer: String, userAnswer: String): Boolean{ return wrightAnswer == userAnswer } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/speechRecognition/SpeechRecognitionAnswerChecker.kt
3329537089
package com.example.englishwordsapp.ui.main.learn import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.DialogFragment import com.example.englishwordsapp.databinding.DialogFilterWordsBinding class FilterWordsDialogFragment: DialogFragment() { private var binding: DialogFilterWordsBinding? = null override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { binding = DialogFilterWordsBinding.inflate(layoutInflater) return binding?.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) binding?.imageButtonClose?.setOnClickListener { dismiss() } binding?.btConfirm?.setOnClickListener { dismiss() } } enum class WordCategories{ NOUN,VERB } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/FilterWordsDialogFragment.kt
2458140648
package com.example.englishwordsapp.ui.main.learn.quiz sealed class QuizState { data class Error(val errorException: String): QuizState() data class Success(val listOfQuestions: List<QuizQuestionsModel>): QuizState() class Loading(val isLoading: Boolean): QuizState() }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/quiz/QuizState.kt
2461776870
package com.example.englishwordsapp.ui.main.learn.quiz import android.os.Bundle import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.LinearLayout import android.widget.TextView import android.widget.Toast import androidx.core.content.ContextCompat import androidx.core.view.isVisible import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController import com.example.englishwordsapp.R import com.example.englishwordsapp.databinding.FragmentQuizBinding import com.example.englishwordsapp.ui.main.learn.ResultDialogFragment import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint class QuizFragment : Fragment() { private var binding: FragmentQuizBinding? = null private val viewModel by viewModels<QuizViewModel>() private val listOfWords = mutableListOf<QuizQuestionsModel>() private var correctAnswer: String? = null private var wrongAnswer = 0 private var countOfAllQuestions: Int? = null private var questionModel: QuizQuestionsModel? = null override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { binding = FragmentQuizBinding.inflate(layoutInflater, container, false) return binding?.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) val difficultyLevel = arguments?.getString("difficultyLevel") viewModel.questionModelData.observe(viewLifecycleOwner){result -> result?.let { when(result){ is QuizState.Success ->{ handleOnSuccessResult(result.listOfQuestions) } is QuizState.Error ->{ Toast.makeText(requireContext(), "Error: ${result.errorException}", Toast.LENGTH_LONG).show() } is QuizState.Loading ->{ binding?.progressBarLoadingData?.isVisible = result.isLoading } else -> {} } } } difficultyLevel?.let { viewModel.getQuestionList(it) } binding?.layoutVariant1?.setOnClickListener { if (correctAnswer == binding?.tvAnswer1?.text) { checkAnswer( binding?.layoutVariant1, binding?.tvAnswer1Nuber, binding?.tvAnswer1, VariantStates.CORRECT ) } else { checkAnswer( binding?.layoutVariant1, binding?.tvAnswer1Nuber, binding?.tvAnswer1, VariantStates.WRONG ) } } binding?.layoutVariant2?.setOnClickListener { if (correctAnswer == binding?.tvAnswer2?.text) { checkAnswer( binding?.layoutVariant2, binding?.tvAnswer2Nuber, binding?.tvAnswer2, VariantStates.CORRECT ) } else { checkAnswer( binding?.layoutVariant2, binding?.tvAnswer2Nuber, binding?.tvAnswer2, VariantStates.WRONG ) } } binding?.layoutVariant3?.setOnClickListener { if (correctAnswer == binding?.tvAnswer3?.text) { checkAnswer( binding?.layoutVariant3, binding?.tvAnswer3Nuber, binding?.tvAnswer3, VariantStates.CORRECT ) } else { checkAnswer( binding?.layoutVariant3, binding?.tvAnswer3Nuber, binding?.tvAnswer3, VariantStates.WRONG ) } } binding?.layoutVariant4?.setOnClickListener { if (correctAnswer == binding?.tvAnswer4?.text) { checkAnswer( binding?.layoutVariant4, binding?.tvAnswer4Nuber, binding?.tvAnswer4, VariantStates.CORRECT ) } else { checkAnswer( binding?.layoutVariant4, binding?.tvAnswer4Nuber, binding?.tvAnswer4, VariantStates.WRONG ) } } binding?.btContinue?.setOnClickListener { changeContinueButtonState(ContinueBtStates.NORMAL) checkAnswer(binding?.layoutVariant1, binding?.tvAnswer1Nuber, binding?.tvAnswer1, VariantStates.NORMAL ) checkAnswer(binding?.layoutVariant2, binding?.tvAnswer2Nuber, binding?.tvAnswer2, VariantStates.NORMAL ) checkAnswer(binding?.layoutVariant4, binding?.tvAnswer4Nuber, binding?.tvAnswer4,VariantStates.NORMAL ) checkAnswer(binding?.layoutVariant3, binding?.tvAnswer3Nuber, binding?.tvAnswer3,VariantStates.NORMAL ) increaseStep() if(listOfWords.size > 0) { showQuestion() }else { showResult() } } binding?.btSkip?.setOnClickListener { questionModel?.let { listOfWords.add(0, it) } if (listOfWords.size > 0) { showQuestion() } else { showResult() } } binding?.imageButtonClose?.setOnClickListener { findNavController().popBackStack() } } private fun handleOnSuccessResult(listOfQuestions: List<QuizQuestionsModel>){ listOfWords.addAll(listOfQuestions) binding?.progressIndicator?.max = listOfWords.size binding?.tvProgressCount?.text = listOfWords.size.toString() countOfAllQuestions = listOfWords.size listOfWords.shuffle() showQuestion() binding?.progressBarLoadingData?.isVisible = false } private fun increaseStep() { binding?.tvProgressCount?.text = listOfWords.size.toString() binding?.progressIndicator?.progress = binding?.progressIndicator?.progress?.plus(1) ?: 0 } private fun showQuestion(){ questionModel = listOfWords.last() listOfWords.removeLast() val questionWord = questionModel?.question val answerWords = questionModel?.answers?.shuffled() correctAnswer = questionModel?.correctAnswer binding?.tvQuestionWord?.text = questionWord binding?.tvAnswer1?.text = answerWords?.get(0) binding?.tvAnswer2?.text = answerWords?.get(1) binding?.tvAnswer3?.text = answerWords?.get(2) binding?.tvAnswer4?.text = answerWords?.get(3) } private fun showResult(){ countOfAllQuestions?.let { val countOfCorrectAnswer = it - wrongAnswer val dialogFragment = ResultDialogFragment() dialogFragment.isCancelable = false dialogFragment.setScore(countOfCorrectAnswer.toString(), wrongAnswer.toString()) dialogFragment.show( parentFragmentManager, ResultDialogFragment::class.java.canonicalName ) } } private fun changeContinueButtonState(buttonState: ContinueBtStates){ when(buttonState){ ContinueBtStates.CORRECT -> handleCorrectAnswerButton() ContinueBtStates.WRONG -> handleWrongAnswerButton() ContinueBtStates.NORMAL -> normalStateContinueButton() } } private fun handleCorrectAnswerButton() { binding?.btSkip?.isVisible = false binding?.continueButtonLayout?.isVisible = true binding?.continueButtonLayout?.setBackgroundResource(R.color.green) binding?.imageView?.setImageResource(R.drawable.ic_correct) binding?.tvCorrectOrWrong?.text = "Correct!" binding?.btContinue?.setTextColor(ContextCompat.getColor(requireContext(), R.color.green)) false.changeVariantsClickState() } private fun handleWrongAnswerButton() { binding?.btSkip?.isVisible = false binding?.continueButtonLayout?.isVisible = true binding?.continueButtonLayout?.setBackgroundResource(R.color.red) binding?.imageView?.setImageResource(R.drawable.ic_incorrect) binding?.tvCorrectOrWrong?.text = "Wrong!" binding?.btContinue?.setTextColor(ContextCompat.getColor(requireContext(), R.color.red)) false.changeVariantsClickState() } private fun normalStateContinueButton() { binding?.continueButtonLayout?.isVisible = false binding?.btSkip?.isVisible = true true.changeVariantsClickState() } private fun Boolean.changeVariantsClickState() { binding?.layoutVariant1?.isClickable = this binding?.layoutVariant2?.isClickable = this binding?.layoutVariant3?.isClickable = this binding?.layoutVariant4?.isClickable = this } private fun checkAnswer( layout: LinearLayout?, textViewVariantNumber: TextView?, textViewVariantValue: TextView?, variantStates: VariantStates ) { when (variantStates) { VariantStates.CORRECT -> handleCorrectAnswer( layout, textViewVariantNumber, textViewVariantValue ) VariantStates.WRONG -> handleWrongAnswer( layout, textViewVariantNumber, textViewVariantValue ) VariantStates.NORMAL -> variantsNormalState( layout, textViewVariantNumber, textViewVariantValue ) } } private fun handleCorrectAnswer( layout: LinearLayout?, textViewVariantNumber: TextView?, textViewVariantValue: TextView?, ) { layout?.background = ContextCompat.getDrawable( requireContext(), R.drawable.shape_rounded_containers_correct ) textViewVariantNumber?.background = ContextCompat.getDrawable( requireContext(), R.drawable.shape_rounded_variants_correct ) textViewVariantNumber?.setTextColor( ContextCompat.getColor( requireContext(), R.color.white ) ) textViewVariantValue?.setTextColor( ContextCompat.getColor( requireContext(), R.color.green ) ) changeContinueButtonState(ContinueBtStates.CORRECT) } private fun handleWrongAnswer( layout: LinearLayout?, textViewVariantNumber: TextView?, textViewVariantValue: TextView?, ){ layout?.background = ContextCompat.getDrawable( requireContext(), R.drawable.shape_rounded_containers_wrong ) textViewVariantNumber?.background = ContextCompat.getDrawable( requireContext(), R.drawable.shape_rounded_variants_wrong ) textViewVariantNumber?.setTextColor( ContextCompat.getColor( requireContext(), R.color.white ) ) textViewVariantValue?.setTextColor(ContextCompat.getColor( requireContext(), R.color.red )) wrongAnswer++ when(correctAnswer){ binding?.tvAnswer1?.text -> { handleCorrectAnswer( binding?.layoutVariant1, binding?.tvAnswer1Nuber, binding?.tvAnswer1 ) } binding?.tvAnswer2?.text ->{ handleCorrectAnswer( binding?.layoutVariant2, binding?.tvAnswer2Nuber, binding?.tvAnswer2 ) } binding?.tvAnswer3?.text ->{ handleCorrectAnswer( binding?.layoutVariant3, binding?.tvAnswer3Nuber, binding?.tvAnswer3 ) } binding?.tvAnswer4?.text ->{ handleCorrectAnswer( binding?.layoutVariant4, binding?.tvAnswer4Nuber, binding?.tvAnswer4 ) } } changeContinueButtonState(ContinueBtStates.WRONG) } private fun variantsNormalState( layout: LinearLayout?, textViewVariantNumber: TextView?, textViewVariantValue: TextView?, ) { layout?.background = ContextCompat.getDrawable( requireContext(), R.drawable.shape_rounded_containers ) textViewVariantNumber?.background = ContextCompat.getDrawable( requireContext(), R.drawable.shape_rounded_variants ) textViewVariantNumber?.setTextColor( ContextCompat.getColor( requireContext(), R.color.textVariantsColor ) ) textViewVariantValue?.setTextColor( ContextCompat.getColor( requireContext(), R.color.textVariantsColor ) ) changeContinueButtonState(ContinueBtStates.NORMAL) } private enum class ContinueBtStates{ NORMAL, CORRECT, WRONG } private enum class VariantStates { NORMAL, CORRECT, WRONG } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/quiz/QuizFragment.kt
2042605928
package com.example.englishwordsapp.ui.main.learn.quiz import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.example.englishwordsapp.data.model.core.ResultWrapper import com.example.englishwordsapp.data.repositories.QuizRepositoryImpl import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import javax.inject.Inject @HiltViewModel class QuizViewModel @Inject constructor( private val quizRepository: QuizRepositoryImpl ): ViewModel() { val questionModelData = MutableLiveData<QuizState>() fun getQuestionList(difficultyLevel: String){ questionModelData.postValue(QuizState.Loading(true)) viewModelScope.launch { withContext(Dispatchers.IO){ quizRepository.getQuestionList(difficultyLevel).collect{ when(it){ is ResultWrapper.Success ->{ questionModelData.postValue(QuizState.Loading(false)) questionModelData.postValue(QuizState.Success(it.data)) } is ResultWrapper.Error->{ questionModelData.postValue(QuizState.Loading(false)) questionModelData.postValue(QuizState.Error(it.error.orEmpty())) } else -> { questionModelData.postValue(QuizState.Loading(false)) } } } } } } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/quiz/QuizViewModel.kt
2629750192
package com.example.englishwordsapp.ui.main.learn.quiz class QuizQuestionsModel( val question: String, val correctAnswer: String, val answers: List<String>, ) { }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/quiz/QuizQuestionsModel.kt
1892619698
package com.example.englishwordsapp.ui.main.learn import android.content.DialogInterface import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.DialogFragment import com.example.englishwordsapp.R import com.example.englishwordsapp.databinding.LevelSetDialogFragmentBinding class LevelSetDialogFragment : DialogFragment() { private var binding: LevelSetDialogFragmentBinding? = null var onLevelSelectedListener: OnLevelSelectedListener? = null override fun onDismiss(dialog: DialogInterface) { super.onDismiss(dialog) } override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { binding = LevelSetDialogFragmentBinding.inflate(layoutInflater) return binding?.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) val width = resources.getDimensionPixelSize(R.dimen.dialog_width) val height = resources.getDimensionPixelSize(R.dimen.level_dialog_height) dialog?.window?.setLayout(width, height) binding?.btStart?.setOnClickListener { var selectedLevel: String? = null when (binding?.radioGroupLevels?.checkedRadioButtonId) { binding?.beginnerLevel?.id -> selectedLevel = "beginner_level" binding?.elementaryLevel?.id -> selectedLevel = "elementary_level" binding?.intermediateLevel?.id -> selectedLevel = "intermediate_level" binding?.advanceLevel?.id -> selectedLevel = "advance_level" } if (selectedLevel != null) { onLevelSelectedListener?.onLevelSelected(selectedLevel) } dismiss() } } interface OnLevelSelectedListener { fun onLevelSelected(level: String) } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/LevelSetDialogFragment.kt
320798245
package com.example.englishwordsapp.ui.main.learn import android.app.Dialog import android.content.DialogInterface import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.DialogFragment import androidx.navigation.fragment.findNavController import com.example.englishwordsapp.R import com.example.englishwordsapp.databinding.DialogEndQuestBinding class ResultDialogFragment: DialogFragment() { private var binding: DialogEndQuestBinding? = null private var countOfCorrectAnswer: String? = null private var countOfWrongAnswer: String? = null fun setScore(correct: String, wrong: String){ countOfCorrectAnswer = correct countOfWrongAnswer = wrong } override fun onDismiss(dialog: DialogInterface) { super.onDismiss(dialog) } override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { return super.onCreateDialog(savedInstanceState) } override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { binding = DialogEndQuestBinding.inflate(layoutInflater, container, false) return binding?.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) val width = resources.getDimensionPixelSize(R.dimen.dialog_width) val height = resources.getDimensionPixelSize(R.dimen.dialog_height) dialog?.window?.setLayout(width, height) binding?.tvCorrectScore?.text = countOfCorrectAnswer binding?.tvWrongScore?.text = countOfWrongAnswer binding?.btClose?.setOnClickListener { findNavController().popBackStack() dismiss() } } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/ResultDialogFragment.kt
4072818348
package com.example.englishwordsapp.ui.main.learn.sentenceBuild class SentenceModel( val question: String, val answerWordsList: List<String> ) { }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/sentenceBuild/SentenceModel.kt
4277481917
package com.example.englishwordsapp.ui.main.learn.sentenceBuild 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.core.content.ContextCompat import androidx.core.view.isVisible import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController import com.example.englishwordsapp.R import com.example.englishwordsapp.databinding.FragmentSentenceBuildBinding import com.google.android.material.chip.Chip import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint class SentenceBuildFragment : Fragment() { private var binding: FragmentSentenceBuildBinding? = null private val viewModel by viewModels<SentenceBuildViewModel>() private val answerList = mutableListOf<String>() private val suggestedList = mutableListOf<String>() private var listOfSentences = mutableListOf<SentenceModel>() private var sentenceModelForSkipButton: SentenceModel? = null private var sentenceIndex = 0 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) } override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { binding = FragmentSentenceBuildBinding.inflate(layoutInflater) return binding?.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) val difficultyLevel = arguments?.getString("difficultyLevel") viewModel.questionModelData.observe(viewLifecycleOwner) { result -> result?.let { when (result) { is SentenceBuildState.Success -> { handleOnSuccessResult(result.listOfQuestions) } is SentenceBuildState.Error -> { Toast.makeText( requireContext(), "Error: ${result.errorException}", Toast.LENGTH_LONG ).show() } is SentenceBuildState.Loading -> { binding?.progressBarLoadingData?.isVisible = result.isLoading } } } } difficultyLevel?.let { viewModel.getSentenceModel(it) } binding?.btConfirm?.setOnClickListener { checkAnswerList() } binding?.btSkip?.setOnClickListener { sentenceModelForSkipButton?.let { listOfSentences.add(0, it) } changeContinueButtonState(ContinueBtStates.NORMAL) if (listOfSentences.size > 0){ setQuestion() }else{ Toast.makeText(requireContext(), "Result", Toast.LENGTH_SHORT).show() } } binding?.btContinue?.setOnClickListener { checkAnswerList() changeContinueButtonState(ContinueBtStates.NORMAL) } binding?.imageButtonClose?.setOnClickListener { findNavController().popBackStack() } } private fun handleOnSuccessResult(listOfQuestions: List<SentenceModel>){ listOfSentences.addAll(listOfQuestions) listOfSentences.shuffle() setQuestion() binding?.progressIndicator?.max = listOfSentences.size binding?.tvProgressCount?.text = listOfSentences.size.toString() binding?.progressBarLoadingData?.isVisible = false } private fun setQuestion(){ binding?.suggestedChipGroup?.removeAllViews() binding?.answerChipGroup?.removeAllViews() suggestedList.clear() answerList.clear() binding?.tvSentenceInAze?.text = listOfSentences.last().question sentenceModelForSkipButton = listOfSentences.last() suggestedList.addAll(listOfSentences.last().answerWordsList) suggestedList.shuffle() createSuggestedView() createAnsweredView() listOfSentences.removeLast() } private fun createSuggestedView() { suggestedList.forEach { item -> addSuggestedViewItem(item) } } private fun createAnsweredView() { answerList.forEach { item -> addEmptyViewItem(item) } } private fun onSuggestedItemClicked(item: String) { answerList.add(item) removeSuggestedViewItem(item) addEmptyViewItem(item) } private fun onAnsweredItemClicked(item: String) { answerList.remove(item) removeEmptyViewItem(item) addSuggestedViewItem(item) } private fun addSuggestedViewItem(item: String) { val chip = Chip(requireContext()) chip.text = item chip.tag = item chip.setOnClickListener { onSuggestedItemClicked(item) } binding?.suggestedChipGroup?.addView(chip) } private fun removeSuggestedViewItem(tag: String) { val chip = binding?.suggestedChipGroup?.findViewWithTag<Chip>(tag) binding?.suggestedChipGroup?.removeView(chip) } private fun addEmptyViewItem(item: String) { val chip = Chip(requireContext()) chip.text = item chip.tag = item chip.setOnClickListener { onAnsweredItemClicked(item) } binding?.answerChipGroup?.addView(chip) } private fun removeEmptyViewItem(tag: String) { val chip = binding?.answerChipGroup?.findViewWithTag<Chip>(tag) binding?.answerChipGroup?.removeView(chip) } private fun checkAnswerList() { if (listOfSentences.size > 0) { val rightAnswerList = sentenceModelForSkipButton?.answerWordsList var isRight = false isRight = answerList.size != 0 && answerList == rightAnswerList changeContinueButtonState(ContinueBtStates.CORRECT) if (isRight) { setQuestion() binding?.tvProgressCount?.text = listOfSentences.size.toString() binding?.progressIndicator?.progress = binding?.progressIndicator?.progress!! + 1 } else { changeContinueButtonState(ContinueBtStates.WRONG) } }else { val sentence = listOfSentences[sentenceIndex] val rightAnswerList = sentence.answerWordsList if(answerList.size != 0 && answerList == rightAnswerList){ Toast.makeText(requireContext(), "Done", Toast.LENGTH_LONG).show() }else{ changeContinueButtonState(ContinueBtStates.WRONG) } } } private fun changeContinueButtonState(buttonState: ContinueBtStates){ when(buttonState){ ContinueBtStates.CORRECT -> handleCorrectAnswerButton() ContinueBtStates.WRONG -> handleWrongAnswerButton() ContinueBtStates.NORMAL -> normalStateContinueButton() } } private fun handleCorrectAnswerButton() { binding?.btSkip?.isVisible = false binding?.continueButtonLayout?.isVisible = true binding?.continueButtonLayout?.setBackgroundResource(R.color.green) binding?.imageView?.setImageResource(R.drawable.ic_correct) binding?.tvCorrectOrWrong?.text = "Correct!" binding?.btContinue?.setTextColor(ContextCompat.getColor(requireContext(), R.color.green)) } private fun handleWrongAnswerButton() { binding?.continueButtonLayout?.isVisible = true binding?.continueButtonLayout?.setBackgroundResource(R.color.red) binding?.imageView?.setImageResource(R.drawable.ic_incorrect) binding?.tvCorrectOrWrong?.text = "Wrong!" binding?.btContinue?.setTextColor(ContextCompat.getColor(requireContext(), R.color.red)) } private fun normalStateContinueButton() { binding?.continueButtonLayout?.isVisible = false binding?.btSkip?.isVisible = true } private enum class ContinueBtStates{ NORMAL, CORRECT, WRONG } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/sentenceBuild/SentenceBuildFragment.kt
431624593
package com.example.englishwordsapp.ui.main.learn.sentenceBuild sealed class SentenceBuildState { data class Error(val errorException: String): SentenceBuildState() data class Success(val listOfQuestions: List<SentenceModel>): SentenceBuildState() class Loading(val isLoading: Boolean): SentenceBuildState() }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/sentenceBuild/SentenceBuildState.kt
1823529449
package com.example.englishwordsapp.ui.main.learn.sentenceBuild object Sentences { val listOfStentences = mutableListOf<SentenceModel>( SentenceModel("Sənin adın nədir?", mutableListOf("what", "is", "your", "name", "?")), SentenceModel("Sənin neçə yaşın var?", mutableListOf("how", "old", "are", "you", "?")), SentenceModel("Mənim adım Əlidir.", mutableListOf("my", "name", "is", "Ali")), // SentenceModel("Mən hər gün məktəbə gedirəm.", mutableListOf("I", "go", "to", "school", "every", "day")), // SentenceModel("Qələm masanın üstündədir.", mutableListOf("the", "pen", "is", "on", "the", "table")), // SentenceModel("Mənim iki qardaşım var.", mutableListOf("I", "have", "2", "brothers")), // SentenceModel("Pişik mənim ən sevdiyim heyvandır.", mutableListOf("cat", "is", "my", "favorite", "animal")), // SentenceModel("Sənin atan mühəndisdir?", mutableListOf("is", "your", "father", "an", "engineer", "?")), // SentenceModel("Bakı Azərbaycanın paytaxtıdır.", mutableListOf("Baku", "capital", "of", "Azerbaijan")), // SentenceModel("Çatntamda çoxlu kitablar var.", mutableListOf("there", "are", "a", "lot", "of", "books", "in", "my", "bag")), ) }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/sentenceBuild/Sentences.kt
4278813316
package com.example.englishwordsapp.ui.main.learn.sentenceBuild import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.example.englishwordsapp.data.model.core.ResultWrapper import com.example.englishwordsapp.data.repositories.SentenceBuildRepositoryImpl import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import javax.inject.Inject @HiltViewModel class SentenceBuildViewModel @Inject constructor( private val sentenceBuildRepository: SentenceBuildRepositoryImpl ) : ViewModel() { val questionModelData = MutableLiveData<SentenceBuildState>() fun getSentenceModel(level: String) { questionModelData.postValue(SentenceBuildState.Loading(true)) viewModelScope.launch { withContext(Dispatchers.IO) { sentenceBuildRepository.getSentencesList(level).collect{ when(it){ is ResultWrapper.Success ->{ questionModelData.postValue(SentenceBuildState.Loading(false)) questionModelData.postValue(SentenceBuildState.Success(it.data)) } is ResultWrapper.Error ->{ questionModelData.postValue(SentenceBuildState.Loading(false)) questionModelData.postValue(SentenceBuildState.Error(it.error.orEmpty())) } else -> { questionModelData.postValue(SentenceBuildState.Loading(false)) } } } } } } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/sentenceBuild/SentenceBuildViewModel.kt
3071553125
package com.example.englishwordsapp.ui.main.learn.vocabulary import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.example.englishwordsapp.data.model.core.ResultWrapper import com.example.englishwordsapp.data.repositories.VocabularyRepositoryImpl import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import javax.inject.Inject @HiltViewModel class VocabularyTranslationViewModel @Inject constructor( private val vocabularyRepository: VocabularyRepositoryImpl ) : ViewModel() { val wordsModelData = MutableLiveData<VocabularyState>() fun getWordsList(difficultyLevel: String) { wordsModelData.postValue(VocabularyState.Loading(true)) viewModelScope.launch { withContext(Dispatchers.IO) { vocabularyRepository.getWordsList(difficultyLevel).collect { when (it) { is ResultWrapper.Success -> { wordsModelData.postValue(VocabularyState.Loading(false)) wordsModelData.postValue(VocabularyState.Success(it.data)) } is ResultWrapper.Error -> { wordsModelData.postValue(VocabularyState.Loading(false)) wordsModelData.postValue(VocabularyState.Error(it.error.orEmpty())) } else -> {} } } } } } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/vocabulary/VocabularyTranslationViewModel.kt
3405584789
package com.example.englishwordsapp.ui.main.learn.vocabulary import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView.ViewHolder import com.example.englishwordsapp.databinding.ExampleWordTranslationBinding import com.example.englishwordsapp.ui.main.learn.SimpleWordsModel class VocabularyListAdapter: ListAdapter<SimpleWordsModel, VocabularyListAdapter.VocabularyWH>(DIFF_UTIL) { private var onItemClik: ((word: SimpleWordsModel) -> Unit)? = null fun onItemClickListener(onItemClick: (word: SimpleWordsModel) -> Unit){ this.onItemClik = onItemClick } class VocabularyWH( private val binding: ExampleWordTranslationBinding ): ViewHolder(binding.root) { fun bind(data: SimpleWordsModel, onItemClick: ((word: SimpleWordsModel) -> Unit)?){ binding.tvWordInEng.text = data.word binding.tvWordInAze.text = data.translationToAze binding.tvWordTranscript.text = data.transcription binding.imagePlaySpeaker.setOnClickListener { onItemClick?.invoke(data) } } } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VocabularyWH { val inflater = LayoutInflater.from(parent.context) val binding = ExampleWordTranslationBinding.inflate(inflater, parent, false) return VocabularyWH(binding) } override fun onBindViewHolder(holder: VocabularyWH, position: Int) { holder.bind(currentList[position], onItemClik) } companion object{ val DIFF_UTIL = object : DiffUtil.ItemCallback<SimpleWordsModel>(){ override fun areItemsTheSame( oldItem: SimpleWordsModel, newItem: SimpleWordsModel ): Boolean { return oldItem.word == newItem.word } override fun areContentsTheSame( oldItem: SimpleWordsModel, newItem: SimpleWordsModel ): Boolean { return oldItem.word == newItem.word && oldItem.transcription == newItem.transcription && oldItem.translationToAze == newItem.translationToAze && oldItem.level == newItem.level && oldItem.partOfSpeech == newItem.partOfSpeech } } } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/vocabulary/VocabularyListAdapter.kt
1409924576
package com.example.englishwordsapp.ui.main.learn.vocabulary import android.os.Bundle import android.speech.tts.TextToSpeech import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.SearchView import android.widget.Toast import androidx.core.view.isVisible import androidx.fragment.app.viewModels import com.example.englishwordsapp.databinding.FragmentTranslationWordsBinding import com.example.englishwordsapp.ui.main.learn.FilterWordsDialogFragment import com.example.englishwordsapp.ui.main.learn.SimpleWordsModel import dagger.hilt.android.AndroidEntryPoint import java.util.Locale @AndroidEntryPoint class TranslationWordsFragment : Fragment() { private var binding: FragmentTranslationWordsBinding? = null private val adapterForWords by lazy { VocabularyListAdapter() } private val listOfWords = mutableListOf<SimpleWordsModel>() private lateinit var textToSpeech: TextToSpeech private val viewModel by viewModels<VocabularyTranslationViewModel>() override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { binding = FragmentTranslationWordsBinding.inflate(layoutInflater, container, false) // textToSpeech = TextToSpeech(requireContext()) { status -> // if (status == TextToSpeech.SUCCESS) { // val result = textToSpeech.setLanguage(Locale.US) // if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { // // Обработка ошибки // } // } else { // // Обработка ошибки // } // } textToSpeech = TextToSpeech(requireContext(), null) return binding?.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) binding?.rcView?.adapter = adapterForWords viewModel.wordsModelData.observe(viewLifecycleOwner) { result -> result?.let { when (result) { is VocabularyState.Success -> { adapterForWords.submitList(result.listOfQuestions) listOfWords.addAll(result.listOfQuestions) binding?.progressBarLoadingData?.isVisible = false } is VocabularyState.Error -> { Toast.makeText( requireContext(), "Error: ${result.errorException}", Toast.LENGTH_SHORT ).show() } is VocabularyState.Loading -> { binding?.progressBarLoadingData?.isVisible = result.isLoading } else -> { } } } } viewModel.getWordsList("beginner_level") adapterForWords.onItemClickListener { word-> textToSpeech.setLanguage(Locale.US) textToSpeech.speak(word.word, TextToSpeech.QUEUE_FLUSH, null, null) } // adapterForWords.setOnClickListener(object : VocabularyAdapter.RvOnClickListener { // override fun onClick(data: SimpleWordsModel) { // } // override fun playSpeaker(text: String, position: Int) { // textToSpeech.setLanguage(Locale.US) // textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, null, null) // } // }) binding?.searchView?.setOnQueryTextListener(object : SearchView.OnQueryTextListener { override fun onQueryTextSubmit(p0: String?): Boolean { return true } override fun onQueryTextChange(newText: String?): Boolean { newText?.let { query -> val filteredList = listOfWords.filter { item -> item.word?.contains( query, ignoreCase = true ) == true || item.translationToAze?.contains( query, ignoreCase = true ) == true }.toMutableList() adapterForWords.submitList(filteredList) return true } return false } }) binding?.ivFilterginSearch?.setOnClickListener { showFilterDialog() } } override fun onDestroy() { if (::textToSpeech.isInitialized) { textToSpeech.stop() textToSpeech.shutdown() } super.onDestroy() } private fun showFilterDialog(){ val dialog = FilterWordsDialogFragment() dialog.show(childFragmentManager, "FilterDialog") } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/vocabulary/TranslationWordsFragment.kt
601603024
package com.example.englishwordsapp.ui.main.learn.vocabulary import com.example.englishwordsapp.ui.main.learn.SimpleWordsModel sealed class VocabularyState { data class Error(val errorException: String): VocabularyState() data class Success(val listOfQuestions: List<SimpleWordsModel>): VocabularyState() class Loading(val isLoading: Boolean): VocabularyState() }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/vocabulary/VocabularyState.kt
2673249023
package com.example.englishwordsapp.ui.main.learn import android.os.Bundle import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.navigation.fragment.findNavController import com.example.englishwordsapp.R import com.example.englishwordsapp.databinding.FragmentLearnBinding import com.example.englishwordsapp.extensions.findTopNavController import com.example.englishwordsapp.ui.main.learn.quiz.QuizFragment import com.example.englishwordsapp.ui.main.learn.sentenceBuild.SentenceBuildFragment import com.example.englishwordsapp.ui.main.learn.speechRecognition.SpeechRecognitionFragment class LearnFragment : Fragment() { private var binding: FragmentLearnBinding? = null override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { binding = FragmentLearnBinding.inflate(layoutInflater) return binding?.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) binding?.btQuiz?.setOnClickListener { showDifficultyLevelDialog(QuizFragment(), R.id.quizFragment) } binding?.btVocabularyTranslation?.setOnClickListener { findNavController().navigate(R.id.action_learnFragment_to_translationWordsFragment) } binding?.btSpeechRecognition?.setOnClickListener { showDifficultyLevelDialog(SpeechRecognitionFragment(),R.id.speechRecognitionFragment2 ) } binding?.btSentenceBuild?.setOnClickListener { showDifficultyLevelDialog(SentenceBuildFragment(), R.id.sentenceBuildFragment) } } private fun showDifficultyLevelDialog(fragment: Fragment, fragmentID: Int){ val dialog = LevelSetDialogFragment() dialog.onLevelSelectedListener = object : LevelSetDialogFragment.OnLevelSelectedListener { override fun onLevelSelected(level: String) { startFragment(level, fragment, fragmentID) } } dialog.show(childFragmentManager, "DifficultyLevelDialog") } private fun startFragment( difficultyLevel: String, fragment: Fragment, fragmentID: Int ) { val bundle = Bundle() bundle.putString("difficultyLevel", difficultyLevel) findTopNavController().navigate(fragmentID, bundle) } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/learn/LearnFragment.kt
2281734879
package com.example.englishwordsapp.ui.main.profile import android.os.Bundle import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import com.example.englishwordsapp.databinding.FragmentProfileBinding class ProfileFragment : Fragment() { private var binding: FragmentProfileBinding? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) } override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { binding = FragmentProfileBinding.inflate(layoutInflater) return binding?.root } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/profile/ProfileFragment.kt
3397695698
package com.example.englishwordsapp.ui.main import android.os.Bundle import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.navigation.fragment.NavHostFragment import androidx.navigation.ui.NavigationUI import com.example.englishwordsapp.R import com.example.englishwordsapp.databinding.FragmentMainBinding import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint class MainFragment : Fragment() { private var binding: FragmentMainBinding? = null 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) val navHost = childFragmentManager.findFragmentById(R.id.tabsContainer) as NavHostFragment val navController = navHost.navController binding?.bottomNav?.let { NavigationUI.setupWithNavController(it, navController) } } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/ui/main/MainFragment.kt
3064453446
package com.example.englishwordsapp.adminPanel import com.example.englishwordsapp.ui.main.learn.SimpleWordsModel object Words { val listOfWords = mutableListOf( SimpleWordsModel("Apple", "Alma", "[ˈæpl]", "noun", "beginner_level"), SimpleWordsModel("Car", "Avtomobil", "[kɑːr]", "noun", "beginner_level"), SimpleWordsModel("Cat", "Pişik", "[kæt]", "noun", "beginner_level"), SimpleWordsModel("Dog", "It", "[dɔg]", "noun", "beginner_level"), SimpleWordsModel("Table", "Masa", "[ˈteɪbəl]", "noun", "beginner_level"), SimpleWordsModel("Room", "Otaq", "[ruːm]", "noun", "beginner_level"), SimpleWordsModel("Door", "Qapı", "[dɔr]", "noun", "beginner_level"), SimpleWordsModel("Star", "Ulduz", "[stɑːr]", "noun", "beginner_level"), SimpleWordsModel("Sun", "Günəş", "[sʌn]", "noun", "beginner_level"), SimpleWordsModel("Pen", "Qələm", "[pɛn]", "noun", "beginner_level"), SimpleWordsModel("Book", "Kitab", "[bʊk]", "noun", "beginner_level"), SimpleWordsModel("Ice", "Buz", "[aɪs]", "noun", "beginner_level"), SimpleWordsModel("Mother", "Ana", "[ˈmʌðər]", "noun", "beginner_level"), SimpleWordsModel("Father", "Ata", "[ˈfɑːðər]", "noun", "beginner_level"), SimpleWordsModel("Brother", "Qardaş", "[ˈbrʌðər]", "noun", "beginner_level"), SimpleWordsModel("Phone", "Telefon", "[foʊn]", "noun", "beginner_level"), SimpleWordsModel("Bus", "Avtobus", "[bʌs]", "noun", "beginner_level"), SimpleWordsModel("School", "Məktəb", "[skuːl]", "noun", "beginner_level"), SimpleWordsModel("City", "Şəhər", "[ˈsɪti]", "noun", "beginner_level"), SimpleWordsModel("Cheese", "Pendir", "[ʧiz]", "noun", "beginner_level") ) }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/adminPanel/Words.kt
1943851331
package com.example.englishwordsapp.adminPanel import com.google.firebase.firestore.ktx.firestore import com.google.firebase.ktx.Firebase class AddingSimpleWordsModel { fun addWords(){ val db = Firebase.firestore val finalList = Words.listOfWords for(i in finalList){ val wordData = hashMapOf( "level" to i.level, "partOfSpeech" to i.partOfSpeech, "transcription" to i.transcription, "translationToAze" to i.translationToAze, "word" to i.word ) // db.collection("wordsForVocabulary") // .add(wordData) // .addOnSuccessListener { documentReference -> // Log.d("Musa","Error mesage :$documentReference") // } // .addOnFailureListener { e -> // Log.d("Musa","Error mesage :$e") // } } } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/adminPanel/AddingSimpleWordsModel.kt
370054323
package com.example.englishwordsapp import android.app.Application import com.google.firebase.FirebaseApp import dagger.hilt.android.HiltAndroidApp @HiltAndroidApp class App: Application() { override fun onCreate() { super.onCreate() FirebaseApp.initializeApp(this) } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/App.kt
3097181054
package com.example.englishwordsapp.extensions import androidx.fragment.app.Fragment import androidx.navigation.NavController import androidx.navigation.fragment.NavHostFragment import androidx.navigation.fragment.findNavController import com.example.englishwordsapp.R fun Fragment.findTopNavController(): NavController { val topLevelHost = requireActivity().supportFragmentManager.findFragmentById(R.id.fragmentContainerInActivity) as NavHostFragment? return topLevelHost?.navController ?: findNavController() }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/extensions/FragmentExtensions.kt
1817074485
package com.example.englishwordsapp.data.datasource import com.example.englishwordsapp.data.model.QuizQuestionsResponse import com.example.englishwordsapp.data.model.core.ResultWrapper class QuizRetrofitDatasource: QuizDatasource { override suspend fun getQuestions(difficultyLevel: String): ResultWrapper<List<QuizQuestionsResponse>> { TODO("Not yet implemented") } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/data/datasource/QuizRetrofitDatasource.kt
50127342
package com.example.englishwordsapp.data.datasource import com.example.englishwordsapp.data.model.QuizQuestionsResponse import com.example.englishwordsapp.data.model.core.ResultWrapper import com.google.android.gms.tasks.Tasks import com.google.firebase.firestore.FirebaseFirestore import com.google.firebase.firestore.ktx.firestore import com.google.firebase.ktx.Firebase import javax.inject.Inject class QuizFirebaseDatasource @Inject constructor( private val db: FirebaseFirestore ): QuizDatasource { override suspend fun getQuestions(difficultyLevel: String): ResultWrapper<List<QuizQuestionsResponse>> { val docRef = db.collection("wordsForQuiz") .document(difficultyLevel) .collection("questionsModel") val result = kotlin.runCatching { Tasks.await(docRef.get()) } val data = result.getOrNull()?.toObjects(QuizQuestionsResponse::class.java).orEmpty() return ResultWrapper.Success(data) } }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/data/datasource/QuizFirebaseDatasource.kt
270580238
package com.example.englishwordsapp.data.datasource import com.example.englishwordsapp.data.model.QuizQuestionsResponse import com.example.englishwordsapp.data.model.core.ResultWrapper interface QuizDatasource { suspend fun getQuestions(difficultyLevel: String): ResultWrapper<List<QuizQuestionsResponse>> }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/data/datasource/QuizDatasource.kt
2421280820
package com.example.englishwordsapp.data.roomDatabase import androidx.room.ColumnInfo import androidx.room.Entity import androidx.room.PrimaryKey @Entity( tableName = "Table_for_words" ) class Entity( @PrimaryKey(autoGenerate = true) val id: Int?, @ColumnInfo val wordInEnglish: String?, @ColumnInfo val wordInRussian: String?, @ColumnInfo val wordTranscription: String?, @ColumnInfo val pronunciation: String?, ) { }
LearnEnglishApp_AZE/app/src/main/java/com/example/englishwordsapp/data/roomDatabase/Entity.kt
2650949431