content
stringlengths 0
3.9M
| path
stringlengths 4
242
| contentHash
stringlengths 1
10
|
---|---|---|
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class Home(
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_female")
val frontFemale: Any,
@SerializedName("front_shiny")
val frontShiny: String,
@SerializedName("front_shiny_female")
val frontShinyFemale: Any
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/Home.kt | 1491290124 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class İcons(
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_female")
val frontFemale: Any
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/İcons.kt | 1208484250 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class Yellow(
@SerializedName("back_default")
val backDefault: String,
@SerializedName("back_gray")
val backGray: String,
@SerializedName("back_transparent")
val backTransparent: String,
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_gray")
val frontGray: String,
@SerializedName("front_transparent")
val frontTransparent: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/Yellow.kt | 486281979 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class XY(
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_female")
val frontFemale: Any,
@SerializedName("front_shiny")
val frontShiny: String,
@SerializedName("front_shiny_female")
val frontShinyFemale: Any
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/XY.kt | 4228137285 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class Platinum(
@SerializedName("back_default")
val backDefault: String,
@SerializedName("back_female")
val backFemale: Any,
@SerializedName("back_shiny")
val backShiny: String,
@SerializedName("back_shiny_female")
val backShinyFemale: Any,
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_female")
val frontFemale: Any,
@SerializedName("front_shiny")
val frontShiny: String,
@SerializedName("front_shiny_female")
val frontShinyFemale: Any
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/Platinum.kt | 1439290838 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class GenerationVii(
@SerializedName("icons")
val icons: com.example.pokedexapp.data.model.pokemon.İcons,
@SerializedName("ultra-sun-ultra-moon")
val ultraSunUltraMoon: com.example.pokedexapp.data.model.pokemon.UltraSunUltraMoon
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/GenerationVii.kt | 1788448218 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class RedBlue(
@SerializedName("back_default")
val backDefault: String,
@SerializedName("back_gray")
val backGray: String,
@SerializedName("back_transparent")
val backTransparent: String,
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_gray")
val frontGray: String,
@SerializedName("front_transparent")
val frontTransparent: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/RedBlue.kt | 830920058 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class DiamondPearl(
@SerializedName("back_default")
val backDefault: String,
@SerializedName("back_female")
val backFemale: Any,
@SerializedName("back_shiny")
val backShiny: String,
@SerializedName("back_shiny_female")
val backShinyFemale: Any,
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_female")
val frontFemale: Any,
@SerializedName("front_shiny")
val frontShiny: String,
@SerializedName("front_shiny_female")
val frontShinyFemale: Any
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/DiamondPearl.kt | 3030944102 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class TypeX(
@SerializedName("name")
val name: String,
@SerializedName("url")
val url: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/TypeX.kt | 4254635809 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class Crystal(
@SerializedName("back_default")
val backDefault: String,
@SerializedName("back_shiny")
val backShiny: String,
@SerializedName("back_shiny_transparent")
val backShinyTransparent: String,
@SerializedName("back_transparent")
val backTransparent: String,
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_shiny")
val frontShiny: String,
@SerializedName("front_shiny_transparent")
val frontShinyTransparent: String,
@SerializedName("front_transparent")
val frontTransparent: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/Crystal.kt | 2769634834 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class GenerationV(
@SerializedName("black-white")
val blackWhite: com.example.pokedexapp.data.model.pokemon.BlackWhite
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/GenerationV.kt | 2629776177 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class Other(
@SerializedName("dream_world")
val dreamWorld: DreamWorld?,
@SerializedName("home")
val home: Home?,
@SerializedName("official-artwork")
val officialArtwork: OfficialArtwork
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/Other.kt | 514933993 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class Emerald(
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_shiny")
val frontShiny: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/Emerald.kt | 735465299 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class MoveX(
@SerializedName("name")
val name: String,
@SerializedName("url")
val url: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/MoveX.kt | 881452695 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class GenerationVi(
@SerializedName("omegaruby-alphasapphire")
val omegarubyAlphasapphire: com.example.pokedexapp.data.model.pokemon.OmegarubyAlphasapphire,
@SerializedName("x-y")
val xY: com.example.pokedexapp.data.model.pokemon.XY
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/GenerationVi.kt | 4081309180 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class Type(
@SerializedName("slot")
val slot: Int,
@SerializedName("type")
val type: com.example.pokedexapp.data.model.pokemon.TypeX
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/Type.kt | 3680441645 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class OmegarubyAlphasapphire(
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_female")
val frontFemale: Any,
@SerializedName("front_shiny")
val frontShiny: String,
@SerializedName("front_shiny_female")
val frontShinyFemale: Any
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/OmegarubyAlphasapphire.kt | 364942985 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class Silver(
@SerializedName("back_default")
val backDefault: String,
@SerializedName("back_shiny")
val backShiny: String,
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_shiny")
val frontShiny: String,
@SerializedName("front_transparent")
val frontTransparent: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/Silver.kt | 706433631 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class BlackWhite(
@SerializedName("animated")
val animated: com.example.pokedexapp.data.model.pokemon.Animated,
@SerializedName("back_default")
val backDefault: String,
@SerializedName("back_female")
val backFemale: Any,
@SerializedName("back_shiny")
val backShiny: String,
@SerializedName("back_shiny_female")
val backShinyFemale: Any,
@SerializedName("front_default")
val frontDefault: String,
@SerializedName("front_female")
val frontFemale: Any,
@SerializedName("front_shiny")
val frontShiny: String,
@SerializedName("front_shiny_female")
val frontShinyFemale: Any
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/BlackWhite.kt | 1788929568 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class Generationİi(
@SerializedName("crystal")
val crystal: com.example.pokedexapp.data.model.pokemon.Crystal,
@SerializedName("gold")
val gold: com.example.pokedexapp.data.model.pokemon.Gold,
@SerializedName("silver")
val silver: com.example.pokedexapp.data.model.pokemon.Silver
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/Generationİi.kt | 2338636440 |
package com.example.pokedexapp.data.model.pokemon
import com.google.gson.annotations.SerializedName
data class Gameİndice(
@SerializedName("game_index")
val gameİndex: Int,
@SerializedName("version")
val version: com.example.pokedexapp.data.model.pokemon.Version
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon/Gameİndice.kt | 3053105190 |
package com.example.pokedexapp.data.model.pokemon_list
data class Result(
val name: String,
val url: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_list/Result.kt | 753534030 |
package com.example.pokedexapp.data.model.pokemon_list
data class PokemonListDto(
val count: Int,
val next: Any,
val previous: Any,
val results: List<Result>
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_list/PokemonListDto.kt | 464843359 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class Pokemon(
@SerializedName("name")
val name: String,
@SerializedName("url")
val url: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/Pokemon.kt | 2084818982 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class Language(
@SerializedName("name")
val name: String,
@SerializedName("url")
val url: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/Language.kt | 3088284865 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class Shape(
@SerializedName("name")
val name: String,
@SerializedName("url")
val url: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/Shape.kt | 2279604729 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class EvolutionChain(
@SerializedName("url")
val url: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/EvolutionChain.kt | 2707379005 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class Pokedex(
@SerializedName("name")
val name: String,
@SerializedName("url")
val url: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/Pokedex.kt | 572867196 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class Area(
@SerializedName("name")
val name: String,
@SerializedName("url")
val url: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/Area.kt | 819802151 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class GrowthRate(
@SerializedName("name")
val name: String,
@SerializedName("url")
val url: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/GrowthRate.kt | 2983836351 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class Name(
@SerializedName("language")
val language: Language,
@SerializedName("name")
val name: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/Name.kt | 3398446184 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class Version(
@SerializedName("name")
val name: String,
@SerializedName("url")
val url: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/Version.kt | 971679359 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class PokedexNumber(
@SerializedName("entry_number")
val entryNumber: Int,
@SerializedName("pokedex")
val pokedex: Pokedex
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/PokedexNumber.kt | 1072270485 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class Generation(
@SerializedName("name")
val name: String,
@SerializedName("url")
val url: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/Generation.kt | 888628867 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class Color(
@SerializedName("name")
val name: String,
@SerializedName("url")
val url: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/Color.kt | 1619785804 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class Variety(
@SerializedName("is_default")
val isDefault: Boolean,
@SerializedName("pokemon")
val pokemon: Pokemon
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/Variety.kt | 3571673314 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class FlavorTextEntry(
@SerializedName("flavor_text")
val flavorText: String,
@SerializedName("language")
val language: Language,
@SerializedName("version")
val version: Version
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/FlavorTextEntry.kt | 3596897638 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class PokemonSpeciesDto(
@SerializedName("base_happiness")
val baseHappiness: Int?,
@SerializedName("capture_rate")
val captureRate: Int?,
@SerializedName("color")
val color: Color?,
@SerializedName("egg_groups")
val eggGroups: List<EggGroup>?,
@SerializedName("evolution_chain")
val evolutionChain: EvolutionChain?,
@SerializedName("evolves_from_species")
val evolvesFromSpecies: Any?,
@SerializedName("flavor_text_entries")
val flavorTextEntries: List<FlavorTextEntry>,
@SerializedName("form_descriptions")
val formDescriptions: List<Any>?,
@SerializedName("forms_switchable")
val formsSwitchable: Boolean?,
@SerializedName("gender_rate")
val genderRate: Int?,
@SerializedName("genera")
val genera: List<Genera>?,
@SerializedName("generation")
val generation: Generation?,
@SerializedName("growth_rate")
val growthRate: GrowthRate?,
@SerializedName("habitat")
val habitat: Habitat?,
@SerializedName("has_gender_differences")
val hasGenderDifferences: Boolean?,
@SerializedName("hatch_counter")
val hatchCounter: Int?,
@SerializedName("id")
val id: Int?,
@SerializedName("is_baby")
val isBaby: Boolean?,
@SerializedName("is_legendary")
val isLegendary: Boolean?,
@SerializedName("is_mythical")
val isMythical: Boolean?,
@SerializedName("name")
val name: String?,
@SerializedName("names")
val names: List<Name>?,
@SerializedName("order")
val order: Int?,
@SerializedName("pal_park_encounters")
val palParkEncounters: List<PalParkEncounter>?,
@SerializedName("pokedex_numbers")
val pokedexNumbers: List<PokedexNumber>?,
@SerializedName("shape")
val shape: Shape?,
@SerializedName("varieties")
val varieties: List<Variety>?
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/PokemonSpeciesDto.kt | 2600481899 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class PalParkEncounter(
@SerializedName("area")
val area: Area,
@SerializedName("base_score")
val baseScore: Int,
@SerializedName("rate")
val rate: Int
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/PalParkEncounter.kt | 3524889739 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class Genera(
@SerializedName("genus")
val genus: String,
@SerializedName("language")
val language: Language
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/Genera.kt | 2089138365 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class EggGroup(
@SerializedName("name")
val name: String,
@SerializedName("url")
val url: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/EggGroup.kt | 672710297 |
package com.example.pokedexapp.data.model.pokemon_species
import com.google.gson.annotations.SerializedName
data class Habitat(
@SerializedName("name")
val name: String,
@SerializedName("url")
val url: String
) | pokedex-app/app/src/main/java/com/example/pokedexapp/data/model/pokemon_species/Habitat.kt | 79207330 |
package com.example.pokedexapp.data.remote
import com.example.pokedexapp.data.model.pokemon.PokemonDto
import com.example.pokedexapp.data.model.pokemon_list.PokemonListDto
import com.example.pokedexapp.data.model.pokemon_species.PokemonSpeciesDto
import com.example.pokedexapp.domain.model.PokemonAbout
import retrofit2.http.GET
import retrofit2.http.Path
interface PokemonApi {
@GET("pokemon/{id}")
suspend fun getPokemonByID(
@Path("id") id: String
): PokemonDto
@GET("pokemon-species/{id}")
suspend fun getPokemonAboutByID(
@Path("id") id: String
): PokemonSpeciesDto
@GET("pokemon?limit=10000")
suspend fun getAllPokemons(): PokemonListDto
@GET("pokemon/{name}")
suspend fun getPokemonByName(
@Path("name") name: String
): PokemonDto
@GET("pokemon?limit=100&offset=0")
suspend fun getFirst100Pokemons(): PokemonListDto
} | pokedex-app/app/src/main/java/com/example/pokedexapp/data/remote/PokemonApi.kt | 3540582846 |
package com.example.pokedexapp.domain.repository
import com.example.pokedexapp.data.model.pokemon.PokemonDto
import com.example.pokedexapp.data.model.pokemon_list.PokemonListDto
import com.example.pokedexapp.data.model.pokemon_species.PokemonSpeciesDto
interface PokemonRepository {
suspend fun getAllPokemons(): PokemonListDto
suspend fun getPokemonByID(pokemonID: String): PokemonDto
suspend fun getPokemonAboutByID(pokemonID: String): PokemonSpeciesDto
} | pokedex-app/app/src/main/java/com/example/pokedexapp/domain/repository/PokemonRepository.kt | 3625240502 |
package com.example.pokedexapp.domain.use_case
import com.example.pokedexapp.data.mapper.toPokemonDetail
import com.example.pokedexapp.domain.model.PokemonDetail
import com.example.pokedexapp.domain.repository.PokemonRepository
import com.example.pokedexapp.util.Resource
import javax.inject.Inject
class GetPokemonByIDUseCase @Inject constructor(
private val pokemonRepository: PokemonRepository
) {
suspend operator fun invoke(pokemonID: String): Resource<PokemonDetail> {
return try {
Resource.Success(
data = pokemonRepository.getPokemonByID(pokemonID).toPokemonDetail()
)
} catch (e: Exception) {
e.printStackTrace()
Resource.Error(e.message ?: "An unknown error occurred.")
}
}
} | pokedex-app/app/src/main/java/com/example/pokedexapp/domain/use_case/GetPokemonByIDUseCase.kt | 957935708 |
package com.example.pokedexapp.domain.use_case
import com.example.pokedexapp.data.mapper.toPokemonDetail
import com.example.pokedexapp.domain.model.PokemonAbout
import com.example.pokedexapp.domain.repository.PokemonRepository
import com.example.pokedexapp.util.Resource
import javax.inject.Inject
class GetPokemonAboutByIDUseCase @Inject constructor(
private val pokemonRepository: PokemonRepository
) {
suspend operator fun invoke(pokemonID: String): Resource<PokemonAbout> {
return try {
Resource.Success(
data = pokemonRepository.getPokemonAboutByID(pokemonID).toPokemonDetail()
)
} catch (e: Exception) {
e.printStackTrace()
Resource.Error(e.message ?: "An unknown error occurred.")
}
}
} | pokedex-app/app/src/main/java/com/example/pokedexapp/domain/use_case/GetPokemonAboutByIDUseCase.kt | 1948631869 |
package com.example.pokedexapp.domain.use_case
import com.example.pokedexapp.data.mapper.toPokemon
import com.example.pokedexapp.domain.model.Pokemon
import com.example.pokedexapp.domain.repository.PokemonRepository
import com.example.pokedexapp.util.Resource
import javax.inject.Inject
class GetAllPokemonsUseCase @Inject constructor(
private val pokemonRepository: PokemonRepository
) {
suspend operator fun invoke(): Resource<List<Pokemon>> {
return try {
Resource.Success(
data = pokemonRepository.getAllPokemons().results.map { it.toPokemon() }
)
} catch (e: Exception) {
e.printStackTrace()
// Resource.Error(e.message ?: "An unknown error occurred.")
Resource.Error("Please check your internet connection.")
}
}
} | pokedex-app/app/src/main/java/com/example/pokedexapp/domain/use_case/GetAllPokemonsUseCase.kt | 3984713882 |
package com.example.pokedexapp.domain.model
data class Pokemon(
val id: String,
val name: String,
val imageUrl: String
)
| pokedex-app/app/src/main/java/com/example/pokedexapp/domain/model/Pokemon.kt | 2894940389 |
package com.example.pokedexapp.domain.model
import android.graphics.Color
data class PokemonDetail(
val id: String,
val name: String,
val imageUrl: String,
val types: List<PokemonType>,
val weight: String,
val height: String,
val moves: List<String>,
val hp: String,
val hpInt: Int,
val attack: String,
val attackInt: Int,
val defense: String,
val defenseInt: Int,
val specialAttack: String,
val specialAttackInt: Int,
val specialDefence: String,
val specialDefenceInt: Int,
val speed: String,
val speedInt: Int,
val color: Int,
val colorTransparent: Int
)
| pokedex-app/app/src/main/java/com/example/pokedexapp/domain/model/PokemonDetail.kt | 2464388406 |
package com.example.pokedexapp.domain.model
data class PokemonAbout(
val about: String
)
| pokedex-app/app/src/main/java/com/example/pokedexapp/domain/model/PokemonAbout.kt | 1708544959 |
package com.example.pokedexapp.domain.model
data class PokemonType(
val typeName: String,
val typeColor: Int
)
| pokedex-app/app/src/main/java/com/example/pokedexapp/domain/model/PokemonType.kt | 1436986257 |
package com.example.pokedexapp.domain.model
import androidx.annotation.ColorRes
import com.example.pokedexapp.R
sealed class PokemonColor(
@ColorRes val color: Int
) {
data object BugColor : PokemonColor(
color = R.color.bugColor
)
data object DarkColor : PokemonColor(
color = R.color.darkColor
)
data object DragonColor : PokemonColor(
color = R.color.dragonColor
)
data object ElectricColor : PokemonColor(
color = R.color.electricColor
)
data object FairyColor : PokemonColor(
color = R.color.fairyColor
)
data object FightingColor : PokemonColor(
color = R.color.fightingColor
)
data object FireColor : PokemonColor(
color = R.color.fireColor
)
data object FlyingColor : PokemonColor(
color = R.color.flyingColor
)
data object GhostColor : PokemonColor(
color = R.color.ghostColor
)
data object NormalColor : PokemonColor(
color = R.color.normalColor
)
data object GrassColor : PokemonColor(
color = R.color.grassColor
)
data object GroundColor : PokemonColor(
color = R.color.groundColor
)
data object IceColor : PokemonColor(
color = R.color.iceColor
)
data object PoisonColor : PokemonColor(
color = R.color.poisonColor
)
data object PsychicColor : PokemonColor(
color = R.color.psychicColor
)
data object RockColor : PokemonColor(
color = R.color.rockColor
)
data object SteelColor : PokemonColor(
color = R.color.steelColor
)
data object WaterColor : PokemonColor(
color = R.color.waterColor
)
companion object {
fun getColor(type: String): PokemonColor {
return when (type) {
"bug" -> BugColor
"dark" -> DarkColor
"dragon" -> DragonColor
"electric" -> ElectricColor
"fairy" -> FairyColor
"fighting" -> FightingColor
"fire" -> FireColor
"flying" -> FlyingColor
"ghost" -> GhostColor
"normal" -> NormalColor
"grass" -> GrassColor
"ground" -> GroundColor
"ice" -> IceColor
"poison" -> PoisonColor
"psychic" -> PsychicColor
"rock" -> RockColor
"steel" -> SteelColor
"water" -> WaterColor
else -> NormalColor
}
}
}
} | pokedex-app/app/src/main/java/com/example/pokedexapp/domain/model/PokemonColor.kt | 3325934057 |
package com.example.pokedexapp
import android.app.Application
import dagger.hilt.android.HiltAndroidApp
@HiltAndroidApp
class PokedexApp: Application() | pokedex-app/app/src/main/java/com/example/pokedexapp/PokedexApp.kt | 3340087858 |
package com.example.pokedexapp.presentation
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import androidx.appcompat.app.AppCompatActivity
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import com.example.pokedexapp.R
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
@Inject
lateinit var fragmentFactory: MainFragmentFactory
override fun onCreate(savedInstanceState: Bundle?) {
var keepSplashOnScreen = true
val delay = 1500L
installSplashScreen().setKeepOnScreenCondition { keepSplashOnScreen }
Handler(Looper.getMainLooper()).postDelayed({ keepSplashOnScreen = false }, delay)
super.onCreate(savedInstanceState)
supportFragmentManager.fragmentFactory = fragmentFactory
setContentView(R.layout.activity_main)
}
} | pokedex-app/app/src/main/java/com/example/pokedexapp/presentation/MainActivity.kt | 3412091516 |
package com.example.pokedexapp.presentation.view.home
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.pokedexapp.domain.model.Pokemon
import com.example.pokedexapp.domain.use_case.GetAllPokemonsUseCase
import com.example.pokedexapp.util.Resource
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import javax.inject.Inject
@HiltViewModel
class HomeViewModel @Inject constructor(
private val getAllPokemonsUseCase: GetAllPokemonsUseCase
) : ViewModel() {
private val pokemonList = MutableLiveData<List<Pokemon>?>()
val pokemonError = MutableLiveData<String?>()
val shownList = MutableLiveData<MutableList<Pokemon>?>()
private var currentList: List<Pokemon>? = emptyList()
val sortEvent: MutableLiveData<SortEvent> = MutableLiveData(SortEvent.ByID)
private var startIndex = 0
private val groupSize = 50
private var endIndex = 0
init {
loadAll()
}
private fun loadAll() {
viewModelScope.launch(Dispatchers.IO) {
when (val result = getAllPokemonsUseCase()) {
is Resource.Success -> {
withContext(Dispatchers.Main) {
pokemonList.value = result.data
currentList = pokemonList.value
endIndex = 0
loadShownList()
sortShownList()
}
}
is Resource.Error -> {
withContext(Dispatchers.Main) {
pokemonError.value = result.message
}
}
}
}
}
fun searchPokemon(searchText: String) {
val searchedList =
pokemonList.value?.filter { it.id.contains(searchText) || it.name.contains(searchText) }
if (!searchedList.isNullOrEmpty()) {
pokemonError.value = null
currentList = searchedList
endIndex = 0
loadShownList()
sortShownList()
} else {
if (pokemonError.value.isNullOrEmpty()) {
pokemonError.value = "There is no pokemon found."
}
}
}
fun loadShownList() {
val currentListHere = currentList
if (currentListHere != null) {
endIndex += groupSize
if (endIndex <= currentListHere.size) {
val newList = currentListHere.subList(startIndex, endIndex)
shownList.value = newList.toMutableList()
} else {
endIndex = currentListHere.size
val newList = currentListHere.subList(startIndex, endIndex)
shownList.value = newList.toMutableList()
}
}
}
fun sortShownList() {
currentList = when (sortEvent.value) {
is SortEvent.ByID -> {
currentList?.sortedBy { it.id.toInt() }
}
is SortEvent.ByName -> {
currentList?.sortedBy { it.name }
}
else -> {
currentList?.sortedBy { it.id.toInt() }
}
}
loadShownList()
}
} | pokedex-app/app/src/main/java/com/example/pokedexapp/presentation/view/home/HomeViewModel.kt | 3039134498 |
package com.example.pokedexapp.presentation.view.home
sealed class SortEvent {
data object ByName: SortEvent()
data object ByID: SortEvent()
} | pokedex-app/app/src/main/java/com/example/pokedexapp/presentation/view/home/SortEvent.kt | 2677754315 |
package com.example.pokedexapp.presentation.view.home
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.navigation.Navigation
import androidx.recyclerview.widget.AsyncListDiffer
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import com.example.pokedexapp.R
import com.example.pokedexapp.databinding.PokemonListRecyclerViewItemBinding
import com.example.pokedexapp.domain.model.Pokemon
import com.example.pokedexapp.presentation.view.detail.DetailPokemonListData
import javax.inject.Inject
class HomeListAdapter @Inject constructor() :
RecyclerView.Adapter<HomeListAdapter.HomeListViewHolder>() {
class HomeListViewHolder(view: PokemonListRecyclerViewItemBinding) :
RecyclerView.ViewHolder(view.root)
private val diffUtil = object : DiffUtil.ItemCallback<Pokemon>() {
override fun areItemsTheSame(oldItem: Pokemon, newItem: Pokemon): Boolean {
return oldItem == newItem
}
override fun areContentsTheSame(oldItem: Pokemon, newItem: Pokemon): Boolean {
return false
}
}
var pokemons: List<Pokemon>
get() = recyclerListDiffer.currentList
set(value) = recyclerListDiffer.submitList(value)
private val recyclerListDiffer = AsyncListDiffer(this, diffUtil)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HomeListViewHolder {
val inflater = LayoutInflater.from(parent.context)
val view = DataBindingUtil.inflate<PokemonListRecyclerViewItemBinding>(
inflater,
R.layout.pokemon_list_recycler_view_item,
parent,
false
)
return HomeListViewHolder(view)
}
override fun getItemCount(): Int {
return pokemons.size
}
override fun onBindViewHolder(holder: HomeListViewHolder, position: Int) {
val binding = DataBindingUtil.bind<PokemonListRecyclerViewItemBinding>(holder.itemView)
holder.itemView.setOnClickListener {
val detailPokemonList = DetailPokemonListData(pokemons)
val action = HomeFragmentDirections.actionHomeFragmentToDetailFragment(
position.toString(),
detailPokemonList
)
Navigation.findNavController(it).navigate(action)
}
var arrangedPokemon = pokemons[position]
arrangedPokemon = arrangedPokemon.copy(
id = "#" + arrangedPokemon.id.padStart(3, '0'),
name = arrangedPokemon.name.replaceFirstChar { it.uppercaseChar() }
)
binding?.pokemon = arrangedPokemon
}
} | pokedex-app/app/src/main/java/com/example/pokedexapp/presentation/view/home/HomeListAdapter.kt | 2430962499 |
package com.example.pokedexapp.presentation.view.home
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
import android.widget.PopupWindow
import android.widget.RadioButton
import android.widget.RadioGroup
import android.widget.SearchView.OnQueryTextListener
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.pokedexapp.R
import com.example.pokedexapp.databinding.FragmentHomeBinding
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import javax.inject.Inject
class HomeFragment @Inject constructor(
private val homeListAdapter: HomeListAdapter
) : Fragment(R.layout.fragment_home) {
constructor() : this(HomeListAdapter())
private var fragmentHomeBinding: FragmentHomeBinding? = null
lateinit var homeViewModel: HomeViewModel
private var popupWindow: PopupWindow? = null
private var searchText = ""
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
homeViewModel = ViewModelProvider(requireActivity())[HomeViewModel::class.java]
val binding = FragmentHomeBinding.bind(view)
fragmentHomeBinding = binding
requireActivity().window.statusBarColor =
ContextCompat.getColor(requireContext(), R.color.PrimaryColor)
subscribeToObservers()
binding.pokemonListRecyclerView.apply {
adapter = homeListAdapter
layoutManager = GridLayoutManager(requireContext(), 3)
}
setupPagination()
searchQueryControl()
homeSortMenu()
setSortMenuButtonSrc()
}
override fun onDestroyView() {
fragmentHomeBinding = null
super.onDestroyView()
}
private fun subscribeToObservers() {
homeViewModel.shownList.observe(viewLifecycleOwner) { pokemonList ->
pokemonList?.let {
fragmentHomeBinding?.pokemonListRecyclerView?.visibility = View.VISIBLE
homeListAdapter.pokemons = pokemonList
}
}
homeViewModel.pokemonError.observe(viewLifecycleOwner) { error ->
if (!error.isNullOrEmpty()) {
fragmentHomeBinding?.apply {
pokemonListRecyclerView.visibility = View.GONE
pokemonError.visibility = View.VISIBLE
pokemonError.text = error
}
} else {
fragmentHomeBinding?.apply {
pokemonListRecyclerView.visibility = View.VISIBLE
pokemonError.visibility = View.GONE
}
}
}
}
private fun setupPagination() {
fragmentHomeBinding?.pokemonListRecyclerView?.addOnScrollListener(object :
RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
val layoutManager = recyclerView.layoutManager as LinearLayoutManager?
val visibleItemCount = layoutManager?.childCount ?: 0
val totalItemCount = layoutManager?.itemCount ?: 0
val firstVisibleItemPosition = layoutManager?.findFirstVisibleItemPosition() ?: 0
if (visibleItemCount + firstVisibleItemPosition >= totalItemCount && firstVisibleItemPosition >= 0) {
homeViewModel.loadShownList()
}
}
})
}
private fun searchQueryControl() {
var job: Job? = null
fragmentHomeBinding?.homePokemonSearch?.setOnQueryTextListener(object :
OnQueryTextListener {
override fun onQueryTextSubmit(query: String?): Boolean {
job?.cancel()
job = lifecycleScope.launch {
delay(200)
scrollTopRecyclerView()
searchPokemon(query)
fragmentHomeBinding?.homePokemonSearch?.clearFocus()
}
return true
}
override fun onQueryTextChange(newText: String?): Boolean {
if (searchText != newText) {
if (newText != null) {
searchText = newText
}
job?.cancel()
job = lifecycleScope.launch {
delay(200)
scrollTopRecyclerView()
searchPokemon(newText)
}
}
return true
}
})
}
private fun searchPokemon(searchText: String?) {
if (searchText != null) {
homeViewModel.searchPokemon(searchText.lowercase())
}
}
private fun homeSortMenu() {
fragmentHomeBinding?.homeSortMenuButton?.setOnClickListener {
showPopupMenu(it)
}
}
private fun showPopupMenu(view: View) {
val inflater = LayoutInflater.from(requireContext())
val popupView: View = inflater.inflate(R.layout.custom_menu, null)
popupWindow = PopupWindow(
popupView,
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT,
)
popupWindow?.isOutsideTouchable = true
popupWindow?.isFocusable = true
val locationInWindow = IntArray(2)
view.getLocationOnScreen(locationInWindow)
popupWindow?.showAtLocation(
view,
0,
locationInWindow[0] - 200,
locationInWindow[1] + view.bottom
)
listenSortEvent(popupView)
}
private fun listenSortEvent(view: View) {
val radioGroup = view.findViewById<RadioGroup>(R.id.sortRadioGroup)
setRadioButton(view)
radioGroup?.setOnCheckedChangeListener { group, checkedId ->
when (checkedId) {
R.id.numberRadioButton -> {
scrollTopRecyclerView()
homeViewModel.apply {
sortEvent.value = SortEvent.ByID
sortShownList()
}
}
R.id.nameRadioButton -> {
scrollTopRecyclerView()
homeViewModel.apply {
sortEvent.value = SortEvent.ByName
sortShownList()
}
}
}
setSortMenuButtonSrc()
}
}
private fun setRadioButton(view: View) {
when (homeViewModel.sortEvent.value) {
is SortEvent.ByName -> {
view.findViewById<RadioButton>(R.id.nameRadioButton).performClick()
}
is SortEvent.ByID -> {
view.findViewById<RadioButton>(R.id.numberRadioButton).performClick()
}
else -> {
view.findViewById<RadioButton>(R.id.numberRadioButton).performClick()
}
}
}
private fun setSortMenuButtonSrc() {
fragmentHomeBinding?.homeSortMenuButton?.setImageResource(
when (homeViewModel.sortEvent.value) {
is SortEvent.ByName -> R.drawable.text_format
is SortEvent.ByID -> R.drawable.tag
else -> R.drawable.tag
}
)
}
private fun scrollTopRecyclerView() {
lifecycleScope.launch {
delay(200)
fragmentHomeBinding?.pokemonListRecyclerView?.smoothScrollToPosition(0)
}
}
} | pokedex-app/app/src/main/java/com/example/pokedexapp/presentation/view/home/HomeFragment.kt | 4040938645 |
package com.example.pokedexapp.presentation.view.detail
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.pokedexapp.domain.model.PokemonAbout
import com.example.pokedexapp.domain.model.PokemonDetail
import com.example.pokedexapp.domain.use_case.GetPokemonAboutByIDUseCase
import com.example.pokedexapp.domain.use_case.GetPokemonByIDUseCase
import com.example.pokedexapp.util.Resource
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import javax.inject.Inject
@HiltViewModel
class DetailViewModel @Inject constructor(
private val getPokemonByIDUseCase: GetPokemonByIDUseCase,
private val getPokemonAboutByIDUseCase: GetPokemonAboutByIDUseCase
) : ViewModel() {
val pokemonDetail = MutableLiveData<PokemonDetail?>()
val pokemonAbout = MutableLiveData<PokemonAbout?>()
val isLoading = MutableLiveData<Boolean>()
fun loadData(pokemonID: String) {
loadDetailData(pokemonID)
loadAboutData(pokemonID)
}
private fun loadDetailData(pokemonID: String) {
isLoading.value = true
viewModelScope.launch(Dispatchers.IO) {
when (val result = getPokemonByIDUseCase(pokemonID)) {
is Resource.Success -> {
withContext(Dispatchers.Main) {
pokemonDetail.value = result.data
delay(300)
isLoading.value = false
}
}
is Resource.Error -> {
}
}
}
}
private fun loadAboutData(pokemonID: String) {
viewModelScope.launch(Dispatchers.IO) {
when (val result = getPokemonAboutByIDUseCase(pokemonID)) {
is Resource.Success -> {
withContext(Dispatchers.Main) {
pokemonAbout.value = result.data
}
}
is Resource.Error -> {
}
}
}
}
} | pokedex-app/app/src/main/java/com/example/pokedexapp/presentation/view/detail/DetailViewModel.kt | 471116369 |
package com.example.pokedexapp.presentation.view.detail
import com.example.pokedexapp.domain.model.Pokemon
import java.io.Serializable
data class DetailPokemonListData(
val pokemonList: List<Pokemon>
): Serializable | pokedex-app/app/src/main/java/com/example/pokedexapp/presentation/view/detail/DetailPokemonListData.kt | 2049324469 |
package com.example.pokedexapp.presentation.view.detail
import android.annotation.SuppressLint
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.MotionEvent
import android.view.View
import android.widget.Toast
import androidx.activity.addCallback
import androidx.core.content.ContextCompat
import androidx.core.graphics.ColorUtils
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.Navigation
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.pokedexapp.R
import com.example.pokedexapp.databinding.FragmentDetailBinding
import javax.inject.Inject
class DetailFragment @Inject constructor(
private val detailTypeAdapter: DetailTypeAdapter
) : Fragment(R.layout.fragment_detail) {
constructor() : this(DetailTypeAdapter())
private var fragmentDetailBinding: FragmentDetailBinding? = null
private lateinit var detailViewModel: DetailViewModel
private var startX = 0f
private var lastOffsetX = 0f
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
detailViewModel = ViewModelProvider(requireActivity())[DetailViewModel::class.java]
val binding = FragmentDetailBinding.bind(view)
fragmentDetailBinding = binding
val bundle: DetailFragmentArgs by navArgs()
val pokemonListPosition = bundle.pokemonPosition
val detailPokemonList = bundle.pokemonList
val pokemonId = detailPokemonList.pokemonList[pokemonListPosition.toInt()].id
detailViewModel.loadData(pokemonId)
onClickSetter(pokemonListPosition, detailPokemonList)
onBackClickSetter()
subscribeToObservers()
binding.detailTypeRecyclerView.apply {
adapter = detailTypeAdapter
layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
}
listenImageSwipe(pokemonListPosition, detailPokemonList)
}
override fun onResume() {
fragmentDetailBinding?.pokemonDetail?.copy(
color = colorTransform(R.color.mediumColor)
).also { fragmentDetailBinding?.pokemonDetail = it }
super.onResume()
}
override fun onDestroyView() {
fragmentDetailBinding = null
super.onDestroyView()
}
private fun subscribeToObservers() {
detailViewModel.pokemonDetail.observe(viewLifecycleOwner) {
detailTypeAdapter.types = it?.types?.map { pokemonType ->
pokemonType.copy(
typeColor = colorTransform(pokemonType.typeColor)
)
} ?: listOf()
fragmentDetailBinding?.pokemonDetail = it?.copy(
color = colorTransform(it.color),
colorTransparent = ColorUtils.setAlphaComponent(
colorTransform(it.color), 64
)
)
if (it != null) {
requireActivity().window.statusBarColor = colorTransform(it.color)
}
}
detailViewModel.pokemonAbout.observe(viewLifecycleOwner) {
fragmentDetailBinding?.pokemonAbout = it
}
detailViewModel.isLoading.observe(viewLifecycleOwner) {
if (!it) {
fragmentDetailBinding?.apply {
pokemonDetailLinearLayout.visibility = View.VISIBLE
detailLoadingLinearLayout.visibility = View.GONE
}
} else {
parentFragment?.view?.setBackgroundColor(colorTransform(R.color.mediumColor))
requireActivity().window.statusBarColor = colorTransform(R.color.mediumColor)
fragmentDetailBinding?.apply {
pokemonDetailMasterLinearLayout.background =
ColorDrawable(colorTransform(R.color.mediumColor))
pokemonDetailLinearLayout.visibility = View.GONE
detailLoadingLinearLayout.visibility = View.VISIBLE
}
}
}
}
private fun colorTransform(color: Int): Int {
return ContextCompat.getColor(requireContext(), color)
}
private fun onClickSetter(
pokemonListPosition: String,
detailPokemonList: DetailPokemonListData
) {
setButtonVisibility(pokemonListPosition, detailPokemonList)
fragmentDetailBinding?.apply {
detailToLeftImageView.setOnClickListener {
navigateToSelf((pokemonListPosition.toInt() - 1).toString(), detailPokemonList)
}
detailToRightImageView.setOnClickListener {
navigateToSelf((pokemonListPosition.toInt() + 1).toString(), detailPokemonList)
}
}
}
private fun setButtonVisibility(
pokemonListPosition: String,
detailPokemonList: DetailPokemonListData
) {
if (pokemonListPosition.toInt() == 0) {
fragmentDetailBinding?.detailToLeftImageView?.visibility = View.INVISIBLE
}
if (pokemonListPosition.toInt() == detailPokemonList.pokemonList.size - 1) {
fragmentDetailBinding?.detailToRightImageView?.visibility = View.INVISIBLE
}
}
@SuppressLint("ClickableViewAccessibility")
private fun listenImageSwipe(
pokemonListPosition: String,
detailPokemonList: DetailPokemonListData
) {
fragmentDetailBinding?.PokemonDetailImage?.setOnTouchListener { _, event ->
handleTouch(event, pokemonListPosition, detailPokemonList)
}
}
private fun handleTouch(
event: MotionEvent,
pokemonListPosition: String,
detailPokemonList: DetailPokemonListData
): Boolean {
var offsetX = 0f
when (event.action) {
MotionEvent.ACTION_DOWN -> {
startX = event.rawX
}
MotionEvent.ACTION_MOVE -> {
offsetX = event.rawX - startX
moveImageView(offsetX)
lastOffsetX = offsetX
}
MotionEvent.ACTION_UP -> {
centerImageView()
swipeToGo(lastOffsetX, pokemonListPosition, detailPokemonList)
}
}
return true
}
private fun moveImageView(offsetX: Float) {
fragmentDetailBinding?.PokemonDetailImage?.translationX = offsetX
}
private fun centerImageView() {
fragmentDetailBinding?.PokemonDetailImage?.animate()
?.translationX(0f)
?.translationY(0f)
?.setDuration(500)
?.start()
}
private fun swipeToGo(
offsetX: Float,
pokemonListPosition: String,
detailPokemonList: DetailPokemonListData
) {
if (offsetX > 200) {
if (pokemonListPosition.toInt() == 0) {
Toast.makeText(
requireContext(),
"There is nothing to see there.",
Toast.LENGTH_SHORT
).show()
} else {
navigateToSelf((pokemonListPosition.toInt() - 1).toString(), detailPokemonList)
}
} else if (offsetX < -200) {
if (pokemonListPosition.toInt() == detailPokemonList.pokemonList.size - 1) {
Toast.makeText(
requireContext(),
"There is nothing to see there.",
Toast.LENGTH_SHORT
).show()
} else {
navigateToSelf((pokemonListPosition.toInt() + 1).toString(), detailPokemonList)
}
}
}
private fun navigateToSelf(position: String, detailPokemonList: DetailPokemonListData) {
val action = DetailFragmentDirections.actionDetailFragmentSelf(
position,
detailPokemonList
)
Navigation.findNavController(requireView()).navigate(action)
}
private fun onBackClickSetter() {
fragmentDetailBinding?.detailOnBackImageView?.setOnClickListener {
popBackToMain()
}
requireActivity().onBackPressedDispatcher.addCallback(this) {
popBackToMain()
}
}
private fun popBackToMain() {
findNavController().popBackStack(R.id.homeFragment, false)
}
} | pokedex-app/app/src/main/java/com/example/pokedexapp/presentation/view/detail/DetailFragment.kt | 1885079732 |
package com.example.pokedexapp.presentation.view.detail
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.AsyncListDiffer
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import com.example.pokedexapp.R
import com.example.pokedexapp.databinding.DetailTypeItemBinding
import com.example.pokedexapp.domain.model.PokemonType
import javax.inject.Inject
class DetailTypeAdapter @Inject constructor() :
RecyclerView.Adapter<DetailTypeAdapter.DetailTypeViewHolder>() {
class DetailTypeViewHolder(view: DetailTypeItemBinding) :
RecyclerView.ViewHolder(view.root)
private val diffUtil = object : DiffUtil.ItemCallback<PokemonType>() {
override fun areItemsTheSame(oldItem: PokemonType, newItem: PokemonType): Boolean {
return oldItem == newItem
}
override fun areContentsTheSame(oldItem: PokemonType, newItem: PokemonType): Boolean {
return oldItem == newItem
}
}
var types: List<PokemonType>
get() = recyclerListDiffer.currentList
set(value) = recyclerListDiffer.submitList(value)
private val recyclerListDiffer = AsyncListDiffer(this, diffUtil)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DetailTypeViewHolder {
val inflater = LayoutInflater.from(parent.context)
val view = DataBindingUtil.inflate<DetailTypeItemBinding>(
inflater,
R.layout.detail_type_item,
parent,
false
)
return DetailTypeViewHolder(view)
}
override fun getItemCount(): Int {
return types.size
}
override fun onBindViewHolder(holder: DetailTypeViewHolder, position: Int) {
val binding = DataBindingUtil.bind<DetailTypeItemBinding>(holder.itemView)
binding?.pokemonType = types[position]
}
} | pokedex-app/app/src/main/java/com/example/pokedexapp/presentation/view/detail/DetailTypeAdapter.kt | 1960481557 |
package com.example.pokedexapp.presentation
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentFactory
import com.example.pokedexapp.presentation.view.detail.DetailFragment
import com.example.pokedexapp.presentation.view.detail.DetailTypeAdapter
import com.example.pokedexapp.presentation.view.home.HomeFragment
import com.example.pokedexapp.presentation.view.home.HomeListAdapter
import javax.inject.Inject
class MainFragmentFactory @Inject constructor(
private val homeListAdapter: HomeListAdapter,
private val detailTypeAdapter: DetailTypeAdapter
) : FragmentFactory() {
override fun instantiate(classLoader: ClassLoader, className: String): Fragment {
return when (className) {
HomeFragment::class.java.name -> HomeFragment(homeListAdapter)
DetailFragment::class.java.name -> DetailFragment(detailTypeAdapter)
else -> super.instantiate(classLoader, className)
}
}
} | pokedex-app/app/src/main/java/com/example/pokedexapp/presentation/MainFragmentFactory.kt | 2117670535 |
package com.example.pokedexapp
import androidx.appcompat.app.AppCompatActivity
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class HiltTestActivity : AppCompatActivity() {
} | pokedex-app/app/src/debug/java/com/example/pokedexapp/HiltTestActivity.kt | 2452894974 |
package com.example.basiccomposeexample
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.basiccomposeexample", appContext.packageName)
}
} | basicComposeExample/app/src/androidTest/java/com/example/basiccomposeexample/ExampleInstrumentedTest.kt | 293923618 |
package com.example.basiccomposeexample
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)
}
} | basicComposeExample/app/src/test/java/com/example/basiccomposeexample/ExampleUnitTest.kt | 1598315857 |
package com.example.basiccomposeexample.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) | basicComposeExample/app/src/main/java/com/example/basiccomposeexample/ui/theme/Color.kt | 1960850770 |
package com.example.basiccomposeexample.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 BasicComposeExampleTheme(
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
)
} | basicComposeExample/app/src/main/java/com/example/basiccomposeexample/ui/theme/Theme.kt | 3548113405 |
package com.example.basiccomposeexample.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
)
*/
) | basicComposeExample/app/src/main/java/com/example/basiccomposeexample/ui/theme/Type.kt | 82957141 |
package com.example.basiccomposeexample
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.basiccomposeexample.ui.theme.BasicComposeExampleTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
BasicComposeExampleTheme {
Greeting()
}
}
}
}
// Composable 이 View라고 생각하면 간단하다.
// modifier 는 뷰의 여러 속성을 다루는 객체
@Composable
fun Greeting(modifier: Modifier = Modifier) {
// true false 를 담을 변수
// 이 변수를 텍스트뷰가 감지해서 변수에 따라 값이 변한다.
var changeText by remember { mutableStateOf(false) }
// Column -> View 를 세로로 놓는 함수
Column(modifier = Modifier
// fillMaxSize() -> match_parent의 역할
.fillMaxSize()
// 수평정렬 속성
, horizontalAlignment = Alignment.CenterHorizontally,
// 수직정렬 속성
verticalArrangement = Arrangement.Center) {
// 텍스트뷰 선언 및 초기화
Text(
// changeText 변수의 값에 따라 text 값을 지정
text = if(!changeText) "바뀌기 전 텍스트" else "바뀐 후 텍스트",
// 텍스트의 정렬을 위해서 가로길이를 최대로
modifier = Modifier.fillMaxWidth(),
// 텍스트 가운데 정렬
textAlign = TextAlign.Center,
)
// 버튼 선언 및 초기화
// 클릭 했을때 changeText 변수 true , false로 바꿔줌
Button(onClick = { changeText = !changeText },
// 일반 xml과는 다르게 여기서는 padding 이 margin의 역할을 함.
// xml처럼 padding을 주기위해서는 contentPadding 사용
modifier = Modifier.padding(40.dp)) {
// button의 텍스트
Text("텍스트 변경")
}
}
}
// 미리보기
// showBackground 속성을 이용하면 배경화면이 있는 상태로 미리보기 볼 수 있음
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
BasicComposeExampleTheme {
Greeting()
}
} | basicComposeExample/app/src/main/java/com/example/basiccomposeexample/MainActivity.kt | 503497010 |
hamro_futsal/futsalowner/MyForegroundService.kt | 0 |
|
package com.example.futsalowner
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.futsalowner", appContext.packageName)
}
} | hamro_futsal/futsalowner/src/androidTest/java/com/example/futsalowner/ExampleInstrumentedTest.kt | 4040539397 |
package com.example.futsalowner
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)
}
} | hamro_futsal/futsalowner/src/test/java/com/example/futsalowner/ExampleUnitTest.kt | 2084650860 |
package com.example.futsalowner
import android.Manifest
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.Service
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
import android.os.IBinder
import androidx.core.app.ActivityCompat
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import kotlin.properties.Delegates
class NotificationForegroundService : Service() {
companion object {
private const val CHANNEL_ID = "ForegroundServiceChannel"
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
val name = intent?.getStringExtra("name") ?: ""
val status = intent?.getStringExtra("status") ?: ""
val id = intent?.getIntExtra("id",0) ?: 0
sendNotification(name, status, id)
return START_NOT_STICKY
}
private fun sendNotification(name: String, status: String, id: Int) {
createNotificationChannel()
val builder = NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.logo)
.setContentTitle(name)
.setContentText(status)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setAutoCancel(true) // Dismiss notification when tapped
with(NotificationManagerCompat.from(this)) {
if (ActivityCompat.checkSelfPermission(
this@NotificationForegroundService,
Manifest.permission.POST_NOTIFICATIONS
) != PackageManager.PERMISSION_GRANTED
) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return
}
notify(id, builder.build())
}
}
private fun createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(
CHANNEL_ID,
"Foreground Service Channel",
NotificationManager.IMPORTANCE_DEFAULT
)
val manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
manager.createNotificationChannel(channel)
}
}
override fun onBind(intent: Intent?): IBinder? {
return null
}
}
| hamro_futsal/futsalowner/src/main/java/com/example/futsalowner/NotficationForegroundService.kt | 452790894 |
package com.example.futsalowner
import android.annotation.SuppressLint
import android.app.ActivityManager
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.ContentValues.TAG
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.widget.LinearLayout
import android.widget.TextView
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.content.ContextCompat
import androidx.core.content.ContextCompat.getSystemService
import com.example.futsalowner.MyForegroundServices.Companion.CHANNEL_ID
import com.google.android.gms.tasks.OnCompleteListener
import com.google.firebase.database.*
import com.google.firebase.messaging.FirebaseMessaging
class Dashboard : AppCompatActivity() {
private lateinit var name: String
private lateinit var status: String
private var id = 0
// Firebase Database
private lateinit var database: FirebaseDatabase
private lateinit var bookingsRef: DatabaseReference
@SuppressLint(
"MissingInflatedId", "SuspiciousIndentation", "StringFormatInvalid",
"ScheduleExactAlarm"
)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_dashboard)
//Initialize Firebase Database
database = FirebaseDatabase.getInstance()
bookingsRef = database.getReference("bookings")
val linearLayout: LinearLayout = findViewById(R.id.linearLayout)
// Clear previous data
linearLayout.removeAllViews()
// val serviceIntent = Intent(this, NotificationForegroundService::class.java)
// ContextCompat.startForegroundService(this, serviceIntent)
bookingsRef.addChildEventListener(object : ChildEventListener {
@SuppressLint("SetTextI18n")
override fun onChildAdded(dataSnapshot: DataSnapshot, previousChildName: String?) {
// A new child has been added
val buttonId = dataSnapshot.child("buttonId").value.toString()
status = dataSnapshot.child("status").value.toString()
name = dataSnapshot.child("name").value.toString()
val textView = TextView(this@Dashboard)
textView.text = "Booked for: $buttonId\nStatus: $status\nBooked by: $name\n\n"
linearLayout.addView(textView)
textView.tag = dataSnapshot.key
id++
//sendNotification()
//startForegroundService(name,status,id)
}
override fun onChildChanged(dataSnapshot: DataSnapshot, previousChildName: String?) {
// Handle child node change if needed
}
override fun onChildRemoved(dataSnapshot: DataSnapshot) {
// A child has been removed
val key = dataSnapshot.key // Get the key of the removed child
// Find and remove the corresponding TextView from the LinearLayout
linearLayout.findViewWithTag<TextView>(key)?.let {
linearLayout.removeView(it)
}
}
override fun onChildMoved(dataSnapshot: DataSnapshot, previousChildName: String?) {
// Handle child node move if needed
}
@SuppressLint("SetTextI18n")
override fun onCancelled(databaseError: DatabaseError) {
// Handle errors
val textView = TextView(this@Dashboard)
textView.text = "Error: ${databaseError.message}"
linearLayout.addView(textView)
}
})
FirebaseMessaging.getInstance().token.addOnCompleteListener { task ->
if (task.isSuccessful) {
val token = task.result
Log.d("FCM Token", token)
// Do something with the token, like send it to your server
} else {
Log.e("FCM Token", "Failed to get token: ${task.exception?.message}")
}
}
}
// createNotificationChannel()
// private fun sendNotification() {
// createNotificationChannel()
// val builder = NotificationCompat.Builder(this, CHANNEL_ID)
// .setSmallIcon(R.drawable.logo)
// .setContentTitle(name)
// .setContentText(status)
// .setPriority(NotificationCompat.PRIORITY_DEFAULT)
//
// with(NotificationManagerCompat.from(this)) {
// if (ActivityCompat.checkSelfPermission(
// applicationContext,
// android.Manifest.permission.POST_NOTIFICATIONS//note to add android
// ) != PackageManager.PERMISSION_GRANTED
// ) {
// return
// }
// notify(id, builder.build())
// }
// }
//
// private fun createNotificationChannel() {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// val channel = NotificationChannel(
// CHANNEL_ID, "First Channel",
// NotificationManager.IMPORTANCE_DEFAULT
// )
// channel.description = "Test description for my channel"
//
// val notificationManager =
// getSystemService(NotificationManager::class.java)
// notificationManager.createNotificationChannel(channel)
// }
// }
// private fun startForegroundService(name: String, status: String, id: Int) {
// val serviceIntent = Intent(this, NotificationForegroundService::class.java).apply {
// putExtra("name", name)
// putExtra("status", status)
// putExtra("id", id)
// }
// // Check if the service is already running
// if (!isServiceRunning(NotificationForegroundService::class.java)) {
// ContextCompat.startForegroundService(this, serviceIntent)
// }
// }
//
// private fun isServiceRunning(serviceClass: Class<*>): Boolean {
// val manager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
// for (service in manager.getRunningServices(Int.MAX_VALUE)) {
// if (serviceClass.name == service.service.className) {
// return true
// }
// }
// return false
// }
// Declare the launcher at the top of your Activity/Fragment:
}
| hamro_futsal/futsalowner/src/main/java/com/example/futsalowner/Dashboard.kt | 3608872599 |
package com.example.futsalowner
import android.annotation.SuppressLint
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.CountDownTimer
import android.view.View
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
class MainActivity : AppCompatActivity() {
private lateinit var message: TextView
private lateinit var futsalName: TextView
private lateinit var logo: ImageView
private lateinit var topView1 : View
private lateinit var topView2 : View
private lateinit var topView3 : View
private lateinit var topView4 : View
private lateinit var topView5 : View
private lateinit var topView6 : View
private lateinit var Button : Button
private var count: Int = 0
@SuppressLint("SuspiciousIndentation")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val decorView: View = window.decorView
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
decorView.systemUiVisibility =View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_IMMERSIVE
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
setContentView(R.layout.activity_main)
//message = findViewById(R.id.message)
futsalName = findViewById(R.id.futsalName)
logo = findViewById(R.id.Logo)
topView1= findViewById(R.id.topView1)
topView2= findViewById(R.id.topView2)
topView3= findViewById(R.id.topView3)
topView4= findViewById(R.id.topView4)
topView5= findViewById(R.id.topView5)
topView6= findViewById(R.id.topView6)
Button = findViewById(R.id.Button)
Button.setOnClickListener {
val intent = Intent(this, signinActivity::class.java)
startActivity(intent)
}
val logoAnimation: Animation = AnimationUtils.loadAnimation(this, R.anim.zoom_animation)
//val messageAnimation: Animation = AnimationUtils.loadAnimation(this, R.anim.hold_animation)
val text1Animation: Animation = AnimationUtils.loadAnimation(this, R.anim.top_views_animation)
val text2Animation: Animation = AnimationUtils.loadAnimation(this, R.anim.top_views_animation)
val text3Animation: Animation = AnimationUtils.loadAnimation(this, R.anim.top_views_animation)
val text4Animation: Animation = AnimationUtils.loadAnimation(this, R.anim.bottom_view_animation)
val text5Animation: Animation = AnimationUtils.loadAnimation(this, R.anim.bottom_view_animation)
val text6Animation: Animation = AnimationUtils.loadAnimation(this, R.anim.bottom_view_animation)
val fustalAnimation: Animation = AnimationUtils.loadAnimation(this, R.anim.zoom_animation)
val ButtonAnimation: Animation = AnimationUtils.loadAnimation(this, R.anim.zoom_animation)
topView1.startAnimation(text1Animation)
topView6.startAnimation(text6Animation)
text1Animation.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation?) {
}
override fun onAnimationEnd(animation: Animation?) {
topView2.visibility = View.VISIBLE
topView5.visibility = View.VISIBLE
topView2.startAnimation(text2Animation)
topView5.startAnimation(text5Animation)
}
override fun onAnimationRepeat(animation: Animation?) {
}
})
text2Animation.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation?) {
}
override fun onAnimationEnd(animation: Animation?) {
topView3.visibility = View.VISIBLE
topView4.visibility = View.VISIBLE
topView3.startAnimation(text3Animation)
topView4.startAnimation(text4Animation)
}
override fun onAnimationRepeat(animation: Animation?) {
}
})
text3Animation.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation?) {
}
override fun onAnimationEnd(animation: Animation?) {
logo.visibility = View.VISIBLE
logo.startAnimation(logoAnimation)
}
override fun onAnimationRepeat(animation: Animation?) {
}
})
logoAnimation.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation?) {
}
override fun onAnimationEnd(animation: Animation?) {
futsalName.visibility = View.VISIBLE
futsalName.startAnimation(fustalAnimation)
}
override fun onAnimationRepeat(animation: Animation?) {
}
})
fustalAnimation.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation?) {
}
override fun onAnimationEnd(animation: Animation?) {
Button.visibility = View.VISIBLE
Button.startAnimation(ButtonAnimation)
}
override fun onAnimationRepeat(animation: Animation?) {
}
})
// fustalAnimation.setAnimationListener(object : Animation.AnimationListener {
// override fun onAnimationStart(animation: Animation?) {
//
// }
//
// override fun onAnimationEnd(animation: Animation?) {
// message.visibility = View.VISIBLE
// val animateText = message.text.toString()
// message.text = ""
// val duration = animateText.length * 120L
//
// val countDownTimer = object : CountDownTimer(duration, 15) {
// override fun onTick(millisUntilFinished: Long) {
// if (count < animateText.length) {
// message.text = "${message.text}${animateText[count]}"
// count++
// Button.visibility = View.VISIBLE
// Button.startAnimation(ButtonAnimation)
//
// }
//
// }
//
//
// override fun onFinish() {
//
//
// }
// }
//
// countDownTimer.start()
//
// }
//
// override fun onAnimationRepeat(animation: Animation?) {
//
//
// }
// })
}
} | hamro_futsal/futsalowner/src/main/java/com/example/futsalowner/MainActivity.kt | 2381436497 |
package com.example.futsalowner
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
class ResendActivity : AppCompatActivity() {
private lateinit var ResendButton : Button
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_resend)
ResendButton = findViewById(R.id.Resend)
// ResendButton.setOnClickListener{
// val intent = Intent(this,OtpActivity::class.java)
// startActivity(intent)
// }
}
} | hamro_futsal/futsalowner/src/main/java/com/example/futsalowner/ResendActivity.kt | 779013456 |
package com.example.futsalowner
data class Users(
var name :String?=null,
var email:String?=null,
var phoneNumber : String? =null,
)
| hamro_futsal/futsalowner/src/main/java/com/example/futsalowner/Users.kt | 3124444252 |
package com.example.futsalowner
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.FirebaseDatabase
class signinActivity : AppCompatActivity() {
private lateinit var database: FirebaseDatabase
private lateinit var clientRef: DatabaseReference
private lateinit var email: EditText
private lateinit var password: EditText
private lateinit var loginButton: Button
private lateinit var auth: FirebaseAuth
private lateinit var forgetPasswordText: TextView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sign_in)
database = FirebaseDatabase.getInstance()
clientRef = database.getReference("users")
auth = FirebaseAuth.getInstance()
email = findViewById(R.id.email)
password = findViewById(R.id.password)
loginButton = findViewById(R.id.LoginButton)
forgetPasswordText = findViewById(R.id.forgetPassword)
val registerText = findViewById<TextView>(R.id.register)
registerText.setOnClickListener {
val intent = Intent(this, signupActivity::class.java)
startActivity(intent)
}
// forgetPasswordText.setOnClickListener {
// val intent = Intent(this, ResetPasswordActivity::class.java)
// startActivity(intent)
// }
loginButton.setOnClickListener {
val userEmail = email.text.toString()
val userPassword = password.text.toString()
if (userEmail.isEmpty() || userPassword.isEmpty()) {
Toast.makeText(this, "Please enter both email and password", Toast.LENGTH_SHORT)
.show()
return@setOnClickListener
} else {
auth.signInWithEmailAndPassword(userEmail, userPassword)
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
val intent = Intent(this, Dashboard::class.java)
startActivity(intent)
//
} else {
Toast.makeText(baseContext, "User not found.", Toast.LENGTH_SHORT)
.show()
}
}
}
}
}
}
| hamro_futsal/futsalowner/src/main/java/com/example/futsalowner/signinActivity.kt | 3925699864 |
package com.example.futsalowner
import android.annotation.SuppressLint
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.app.Service
import android.content.Intent
import android.os.Build
import android.os.IBinder
import androidx.core.app.NotificationCompat
class MyForegroundServices : Service() {
companion object {
const val NOTIFICATION_ID = 123
const val CHANNEL_ID = "ForegroundServiceChannel"
}
@SuppressLint("ForegroundServiceType")
override fun onCreate() {
super.onCreate()
createNotificationChannel()
startForeground(NOTIFICATION_ID, createNotification())
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
// Perform any long-running tasks here
// This method is called when the service is started
return START_STICKY
}
override fun onBind(intent: Intent?): IBinder? {
return null
}
private fun createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(
CHANNEL_ID,
"Foreground Service Channel",
NotificationManager.IMPORTANCE_DEFAULT
)
val manager = getSystemService(NotificationManager::class.java)
manager.createNotificationChannel(channel)
}
}
private fun createNotification(): Notification {
val notificationText = "Foreground Service is running"
val notificationIntent = Intent(this, MainActivity::class.java)
val pendingIntent = PendingIntent.getActivity(
this,
0,
notificationIntent,
PendingIntent.FLAG_IMMUTABLE
)
return NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle("Foreground Service")
.setContentText(notificationText)
.setSmallIcon(R.drawable.logo)
.setContentIntent(pendingIntent)
.build()
}
}
| hamro_futsal/futsalowner/src/main/java/com/example/futsalowner/MyForegroundServices.kt | 835649232 |
package com.example.futsalowner
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import android.util.Patterns
import android.widget.*
import androidx.appcompat.app.AppCompatActivity
import com.google.firebase.FirebaseException
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.PhoneAuthCredential
import com.google.firebase.auth.PhoneAuthOptions
import com.google.firebase.auth.PhoneAuthProvider
import java.util.concurrent.TimeUnit
class signupActivity : AppCompatActivity() {
// private lateinit var auth: FirebaseAuth
// private lateinit var verifyOTP: Button
// private lateinit var PhoneNumber: EditText
// private lateinit var signupname: EditText
// private lateinit var signupemail: EditText
// private lateinit var signuppassword: EditText
// private lateinit var signupcpassword: EditText
// private lateinit var radioGroup: RadioGroup
// private lateinit var ownerRadio: RadioButton
// private lateinit var userRadio: RadioButton
// private lateinit var verificationId: String
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_signup)
supportActionBar?.title = "Register"
//
// auth = FirebaseAuth.getInstance()
//
// verifyOTP = findViewById(R.id.VerifyOTP)
// PhoneNumber = findViewById(R.id.phoneNumber)
// signupname = findViewById(R.id.UserName)
// signupemail = findViewById(R.id.email)
// signuppassword = findViewById(R.id.password)
// signupcpassword = findViewById(R.id.Cpassword)
// radioGroup = findViewById(R.id.RadioGroup)
// ownerRadio = findViewById(R.id.ownerRadioButton)
// userRadio = findViewById(R.id.userRadioButton)
//
// verifyOTP.setOnClickListener {
// val name = signupname.text.toString()
// val number = PhoneNumber.text.toString()
// val email = signupemail.text.toString()
// val cpassword = signupcpassword.text.toString()
// val password = signuppassword.text.toString()
//
// if (TextUtils.isEmpty(name) || TextUtils.isEmpty(number) || TextUtils.isEmpty(email) ||
// TextUtils.isEmpty(password) || TextUtils.isEmpty(cpassword)
// ) {
// Toast.makeText(this, "All fields are required", Toast.LENGTH_SHORT).show()
// } else if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
// Toast.makeText(this, "Enter a valid email", Toast.LENGTH_SHORT).show()
// } else if (password.length < 6) {
// Toast.makeText(this, "Password should be at least 6 characters long", Toast.LENGTH_SHORT).show()
// } else if (password != cpassword) {
// Toast.makeText(this, "Passwords do not match", Toast.LENGTH_SHORT).show()
// } else if (number.length < 10) {
// Toast.makeText(this, "Enter a valid phone number", Toast.LENGTH_SHORT).show()
// } else {
// //phone number verification hunxa yeta
// startPhoneNumberVerification("+977$number")
// }
// }
// }
//
// private fun startPhoneNumberVerification(phoneNumber: String) {
// val options = PhoneAuthOptions.newBuilder(auth)
// .setPhoneNumber(phoneNumber)
// .setTimeout(60L, TimeUnit.SECONDS)
// .setActivity(this)
// .setCallbacks(object : PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
// override fun onVerificationCompleted(credential: PhoneAuthCredential) {
// //yeta kunai specific kaam garnu pardaina aaile laii
// }
//
// override fun onVerificationFailed(e: FirebaseException) {
// Toast.makeText(this@signupActivity, "Verification failed", Toast.LENGTH_SHORT).show()
// }
//
// override fun onCodeSent(
// verificationId: String,
// token: PhoneAuthProvider.ForceResendingToken
// ) {
// [email protected] = verificationId
//
// val intent = Intent(this@signupActivity, OtpActivity::class.java)
// intent.putExtra("verificationId", verificationId)
// startActivity(intent)
// }
// })
// .build()
//
// PhoneAuthProvider.verifyPhoneNumber(options)
// }
}
}
| hamro_futsal/futsalowner/src/main/java/com/example/futsalowner/signupActivity.kt | 1657082844 |
package com.example.futsalowner
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
class ResetPasswordActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_reset_password)
}
} | hamro_futsal/futsalowner/src/main/java/com/example/futsalowner/ResetPasswordActivity.kt | 937504434 |
package com.example.futsalowner
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.futsalowner", appContext.packageName)
}
} | hamro_futsal/app/futsalowner/src/androidTest/java/com/example/futsalowner/ExampleInstrumentedTest.kt | 4040539397 |
package com.example.futsalowner
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)
}
} | hamro_futsal/app/futsalowner/src/test/java/com/example/futsalowner/ExampleUnitTest.kt | 2084650860 |
package com.example.futsalowner
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)
}
} | hamro_futsal/app/futsalowner/src/main/java/com/example/futsalowner/MainActivity.kt | 109976817 |
package com.example.hamrofutsal
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.hamrofutsal", appContext.packageName)
}
} | hamro_futsal/app/src/androidTest/java/com/example/hamrofutsal/ExampleInstrumentedTest.kt | 3333349645 |
package com.example.hamrofutsal
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)
}
} | hamro_futsal/app/src/test/java/com/example/hamrofutsal/ExampleUnitTest.kt | 4154550717 |
package UserMenu
import android.app.AlertDialog
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.EditText
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.example.hamrofutsal.R
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.FirebaseDatabase
class UserProfileActivity : AppCompatActivity() {
private lateinit var update: Button
private lateinit var deleteAccount: Button
private lateinit var username: EditText
private lateinit var email: EditText
private lateinit var address: EditText
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
supportActionBar?.hide()
setContentView(R.layout.activity_user_profile)
update = findViewById(R.id.Update)
deleteAccount = findViewById(R.id.Delete)
username = findViewById(R.id.UserName)
email = findViewById(R.id.email)
address = findViewById(R.id.address)
// Set a click listener for the update button
update.setOnClickListener {
updateUserData()
}
// Set a click listener for the delete account button
deleteAccount.setOnClickListener {
showDeleteAccountConfirmationDialog()
}
}
private fun updateUserData() {
// Get the current user's UID
val uid = FirebaseAuth.getInstance().currentUser?.uid
if (uid != null) {
// Get the updated values from EditText fields
val updatedUsername = username.text.toString()
val updatedEmail = email.text.toString()
val updatedAddress = address.text.toString()
// Create a map to update specific fields
val updatedData = mutableMapOf<String, Any?>()
updatedData["name"] = updatedUsername
updatedData["email"] = updatedEmail
updatedData["address"] = updatedAddress
// Reference to the user's node in the database
val userRef = FirebaseDatabase.getInstance().getReference("users").child(uid)
// Update the user data
userRef.updateChildren(updatedData)
.addOnSuccessListener {
Toast.makeText(
this,
"User data updated successfully",
Toast.LENGTH_SHORT
).show()
}
.addOnFailureListener {
Toast.makeText(
this,
"Failed to update user data",
Toast.LENGTH_SHORT
).show()
}
}
}
private fun showDeleteAccountConfirmationDialog() {
val builder = AlertDialog.Builder(this)
builder.setTitle("Confirm Account Deletion")
builder.setMessage("Are you sure you want to delete your account? This action cannot be undone.")
builder.setPositiveButton("Yes") { _, _ ->
// User confirmed, proceed with account deletion
deleteAccount()
}
builder.setNegativeButton("No") { _, _ ->
// User canceled the account deletion
val intent = Intent(this,this::class.java)
startActivity(intent)
}
val dialog = builder.create()
dialog.show()
}
private fun deleteAccount() {
val user = FirebaseAuth.getInstance().currentUser
user?.delete()
?.addOnSuccessListener {
// Account deleted successfully
// You can also remove user data from the Realtime Database if needed
removeUserDataFromDatabase()
Toast.makeText(
this,
"Account deleted successfully",
Toast.LENGTH_SHORT
).show()
System.exit(0)
}
?.addOnFailureListener {
// Failed to delete the account
Toast.makeText(
this,
"Failed to delete account: ${it.message}",
Toast.LENGTH_SHORT
).show()
}
}
private fun removeUserDataFromDatabase() {
val uid = FirebaseAuth.getInstance().currentUser?.uid
if (uid != null) {
// Reference to the user's node in the database
val userRef = FirebaseDatabase.getInstance().getReference("users").child(uid)
// Remove user data from the database
userRef.removeValue()
.addOnSuccessListener {
System.exit(0)
}
.addOnFailureListener {
Toast.makeText(this,"could not perform!!",Toast.LENGTH_SHORT).show()
}
}
}
} | hamro_futsal/app/src/main/java/UserMenu/UserProfileActivity.kt | 596253203 |
package com.example.hamrofutsal
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
class UserSearchActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window.decorView.systemUiVisibility= View.SYSTEM_UI_FLAG_FULLSCREEN
supportActionBar?.hide()
setContentView(R.layout.activity_user_search)
}
} | hamro_futsal/app/src/main/java/UserMenu/UserSearchActivity.kt | 2787149780 |
package com.example.hamrofutsal
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.widget.Button
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.FirebaseDatabase
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
class UserBookingActivity : AppCompatActivity() {
private lateinit var buttons: List<Button>
private val handler = Handler(Looper.getMainLooper())
private val originalTextMap = mutableMapOf<Button, String>()
private var selectedButtonId: Int = -1
private var status = ""
private lateinit var database: FirebaseDatabase
private lateinit var bookingsRef: DatabaseReference
private var isButtonBooked = false
private var bookedButtonId: Int = -1
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_user_booking)
database = FirebaseDatabase.getInstance()
bookingsRef = database.reference.child("bookings")
buttons = listOf(
findViewById(R.id.btn7to8),
findViewById(R.id.btn8to9),
findViewById(R.id.btn9to10),
findViewById(R.id.btn10to11),
findViewById(R.id.btn11to12),
findViewById(R.id.btn12to1),
findViewById(R.id.btn1to2),
findViewById(R.id.btn2to3),
findViewById(R.id.btn3to4),
findViewById(R.id.btn4to5),
findViewById(R.id.btn5to6),
findViewById(R.id.btn6to7)
)
for (button in buttons) {
button.setOnClickListener { onButtonClick(button) }
}
}
private fun onButtonClick(button: Button) {
if (isButtonBooked) {
showDeletePreviousBookingDialog(button)
} else {
selectedButtonId = button.id
val alertDialogBuilder = AlertDialog.Builder(this)
alertDialogBuilder.setTitle("Book or Hold?")
.setPositiveButton("Book") { _, _ ->
bookButton(button)
}
.setNegativeButton("Hold") { _, _ ->
holdButton(button)
}
.setNeutralButton("Back") { _, _ ->
backButton(button)
}
.setCancelable(false)
.show()
}
}
private fun showDeletePreviousBookingDialog(newButton: Button) {
val alertDialogBuilder = AlertDialog.Builder(this)
alertDialogBuilder.setTitle("You have already booked a slot.")
.setMessage("Do you want to delete the previous booking?")
.setPositiveButton("Delete") { _, _ ->
deletePreviousBooking(newButton)
}
.setNegativeButton("Cancel") { _, _ ->
showToast("you cancelled booking")
}
.setCancelable(false)
.show()
}
private fun deletePreviousBooking(newButton: Button) {
if (bookedButtonId != -1) {
removeBookingFromDatabase(bookedButtonId)
val previousButton = buttons.find { it.id == bookedButtonId }
restoreButtonState(previousButton)
showToast("Previous booking deleted.")
bookButton(newButton)
}
}
private fun removeBookingFromDatabase(buttonId: Int) {
bookingsRef.child(buttonId.toString()).removeValue()
}
private fun bookButton(button: Button) {
if (originalTextMap.containsKey(button) && originalTextMap[button]?.contains("Booked") == true) {
showToast("Already booked slot. Please choose another time for booking.")
return
}
originalTextMap[button] = button.text.toString()
val currentTime = SimpleDateFormat("HH:mm", Locale.getDefault()).format(Date())
button.text = "Booked ($currentTime)"
button.isEnabled = false
status = "Booked"
isButtonBooked = true
bookedButtonId = selectedButtonId
showToast("Time booked!")
saveBookingToDatabase(selectedButtonId)
handler.postDelayed({
restoreButtonState(button)
showToast("Time slot available again")
isButtonBooked = false
}, 3600000)
}
private fun holdButton(button: Button) {
originalTextMap[button] = button.text.toString()
val currentTime = SimpleDateFormat("HH:mm", Locale.getDefault()).format(Date())
button.text = "Hold ($currentTime)"
button.isEnabled = false
status = "Hold"
showToast("Time on hold for 30 seconds")
handler.postDelayed({
restoreButtonState(button)
}, 30000)
}
private fun backButton(button: Button) {
val intent = Intent(this@UserBookingActivity, UserBookingActivity::class.java)
startActivity(intent)
finish()
}
private fun restoreButtonState(button: Button?) {
button?.let {
it.text = originalTextMap[it]
it.isEnabled = true
}
}
private fun showToast(message: String) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
}
private fun saveBookingToDatabase(buttonId: Int) {
val name = intent.getStringExtra("semail") ?: ""
val bookingData = BookingData(name, buttonId.toInt(), status)
bookingsRef.child(buttonId.toString()).setValue(bookingData)
.addOnSuccessListener {
showToast("Booking acknowledged for button $buttonId")
}
.addOnFailureListener {
showToast("Failed to acknowledge booking for button $buttonId")
}
}
}
| hamro_futsal/app/src/main/java/UserMenu/UserBookingActivity.kt | 1782086526 |
package com.example.hamrofutsal
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
class UserSettingActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window.decorView.systemUiVisibility= View.SYSTEM_UI_FLAG_FULLSCREEN
supportActionBar?.hide()
setContentView(R.layout.activity_user_setting)
}
} | hamro_futsal/app/src/main/java/UserMenu/UserSettingActivity.kt | 2964140215 |
package com.example.hamrofutsal
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
class UserHomeActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window.decorView.systemUiVisibility= View.SYSTEM_UI_FLAG_FULLSCREEN
supportActionBar?.hide()
setContentView(R.layout.activity_user_home)
}
} | hamro_futsal/app/src/main/java/UserMenu/UserHomeActivity.kt | 3001749163 |
package com.example.hamrofutsal
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
class PaymentActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window.decorView.systemUiVisibility= View.SYSTEM_UI_FLAG_FULLSCREEN
supportActionBar?.hide()
setContentView(R.layout.activity_payment)
}
} | hamro_futsal/app/src/main/java/UserMenu/PaymentActivity.kt | 349697722 |
package futsalLocation
import android.Manifest
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalContext
import androidx.core.app.ActivityCompat
import com.example.hamrofutsal.R
import com.example.hamrofutsal.UserBookingActivity
import com.example.hamrofutsal.UserDashboardActivity
class ImadolFutsal : AppCompatActivity() {
private lateinit var BookNow : Button
private lateinit var OpenMap: Button
private lateinit var back: ImageView
private lateinit var email : TextView
private lateinit var phone : TextView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_imadol_futsal)
BookNow = findViewById(R.id.BookNow)
OpenMap = findViewById(R.id.OpenMap)
back = findViewById(R.id.backManakamana)
phone = findViewById(R.id.phoneId)
// checkPermissions()
back.setOnClickListener {
val intent = Intent(this, UserDashboardActivity::class.java)
startActivity(intent)
}
BookNow.setOnClickListener {
val intent = Intent(this, UserBookingActivity::class.java)
startActivity(intent)
}
OpenMap.setOnClickListener {
// Place your click listener logic here
// This code will execute when the OpenMap button is clicked
val composeView = findViewById<ComposeView>(R.id.compose_view_map)
composeView.setContent {
val mapUrl = "/M87X%2B5FG+Imadol+Futsal,+Mahalaxmi+44600/@27.6671315,85.3579745,15z/data=!3m1!4b1!4m18!1m8!3m7!1s0x39eb19fc36f255c9:0xb17b9cd24c504b98!2sImadol+Futsal!8m2!3d27.6629477!4d85.3486999!15sCg1JbWFkb2wgZnV0c2FskgEMZnV0c2FsX2ZpZWxk4AEA!16s%2Fg%2F11c0t9mf8r!4m8!1m1!4e1!1m5!1m1!1s0x39eb19fc36f255c9:0xb17b9cd24c504b98!2m2!1d85.3486026!2d27.662961?entry=ttu"
if (ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_FINE_LOCATION
) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_COARSE_LOCATION
) != PackageManager.PERMISSION_GRANTED
) {
return@setContent
}
CurrentLocationContent(usePreciseLocation = true,mapUrl)
}
}
phone.setOnClickListener{
val composeView = findViewById<ComposeView>(R.id.compose_view_phone)
composeView.setContent {
InitiatePhoneCall(phone=phone.text.toString())
}
}
}
}
| hamro_futsal/app/src/main/java/futsalLocation/ImadolFutsal.kt | 2128650846 |
package futsalLocation
import android.Manifest
import android.annotation.SuppressLint
import android.content.Intent
import android.net.Uri
import androidx.annotation.RequiresPermission
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.platform.LocalContext
import com.google.android.gms.location.LocationServices
import com.google.android.gms.location.Priority
import com.google.android.gms.tasks.CancellationTokenSource
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.tasks.await
@Composable
@SuppressLint("CoroutineCreationDuringComposition")
@RequiresPermission(
anyOf = [Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION],
)
fun CurrentLocationContent(usePreciseLocation: Boolean,mapUrl: String) {
val scope = rememberCoroutineScope()
val context = LocalContext.current
val locationClient = remember {
LocationServices.getFusedLocationProviderClient(context)
}
var longitude: Double = 85.3272174 // Initialize with default value
var latitude: Double = 27.658694 // Initialize with default value
scope.launch(Dispatchers.IO) {
val priority = if (usePreciseLocation) {
Priority.PRIORITY_HIGH_ACCURACY
} else {
Priority.PRIORITY_BALANCED_POWER_ACCURACY
}
val result = locationClient.getCurrentLocation(
priority,
CancellationTokenSource().token,
).await()
result?.let { fetchedLocation ->
// Update longitude and latitude when location data is available
longitude = fetchedLocation.longitude
latitude = fetchedLocation.latitude
val intent = Intent(
Intent.ACTION_VIEW,
//Uri.parse("https://www.google.com/maps/@${latitude},${longitude},14.77z?entry=ttu")
Uri.parse("https://www.google.com/maps/dir/${latitude},${longitude}${mapUrl}")
)
context.startActivity(intent)
}
}
} | hamro_futsal/app/src/main/java/futsalLocation/Location.kt | 2798318238 |
package futsalLocation
import android.Manifest
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalContext
import androidx.core.app.ActivityCompat
import com.example.hamrofutsal.R
import com.example.hamrofutsal.UserBookingActivity
import com.example.hamrofutsal.UserDashboardActivity
class PrimeFutsal : AppCompatActivity() {
private lateinit var BookNow : Button
private lateinit var OpenMap: Button
private lateinit var back: ImageView
private lateinit var email : TextView
private lateinit var phone : TextView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_prime_futsal)
BookNow = findViewById(R.id.BookNow)
OpenMap = findViewById(R.id.OpenMap)
back = findViewById(R.id.backManakamana)
phone = findViewById(R.id.phoneId)
// checkPermissions()
back.setOnClickListener {
val intent = Intent(this, UserDashboardActivity::class.java)
startActivity(intent)
}
BookNow.setOnClickListener {
val intent = Intent(this, UserBookingActivity::class.java)
startActivity(intent)
}
OpenMap.setOnClickListener {
// Place your click listener logic here
// This code will execute when the OpenMap button is clicked
val composeView = findViewById<ComposeView>(R.id.compose_view_map)
composeView.setContent {
val mapUrl = "/Prime+Futsal+Gyaneshwor,+Jayanti+Galli,+Kathmandu+44600/@27.6936416,85.3032786,13z/data=!3m1!4b1!4m17!1m7!3m6!1s0x39eb191ace459b7d:0xa840c9538cc417f8!2sPrime+Futsal+Gyaneshwor!8m2!3d27.7105278!4d85.3347222!16s%2Fg%2F11hf775nbf!4m8!1m1!4e1!1m5!1m1!1s0x39eb191ace459b7d:0xa840c9538cc417f8!2m2!1d85.3347222!2d27.7105278?entry=ttu"
if (ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_FINE_LOCATION
) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_COARSE_LOCATION
) != PackageManager.PERMISSION_GRANTED
) {
return@setContent
}
CurrentLocationContent(usePreciseLocation = true,mapUrl)
}
}
phone.setOnClickListener{
val composeView = findViewById<ComposeView>(R.id.compose_view_phone)
composeView.setContent {
InitiatePhoneCall(phone=phone.text.toString())
}
}
}
}
| hamro_futsal/app/src/main/java/futsalLocation/PrimeFutsal.kt | 3067776470 |
package futsalLocation
import android.Manifest
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalContext
import androidx.core.app.ActivityCompat
import com.example.hamrofutsal.R
import com.example.hamrofutsal.UserBookingActivity
import com.example.hamrofutsal.UserDashboardActivity
class KickFutsal : AppCompatActivity() {
private lateinit var BookNow : Button
private lateinit var OpenMap: Button
private lateinit var back: ImageView
private lateinit var email : TextView
private lateinit var phone : TextView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_kick_futsal)
BookNow = findViewById(R.id.BookNow)
OpenMap = findViewById(R.id.OpenMap)
back = findViewById(R.id.backManakamana)
phone = findViewById(R.id.phoneId)
// checkPermissions()
back.setOnClickListener {
val intent = Intent(this, UserDashboardActivity::class.java)
startActivity(intent)
}
BookNow.setOnClickListener {
val intent = Intent(this, UserBookingActivity::class.java)
startActivity(intent)
}
OpenMap.setOnClickListener {
// Place your click listener logic here
// This code will execute when the OpenMap button is clicked
val composeView = findViewById<ComposeView>(R.id.compose_view_map)
composeView.setContent {
val mapUrl = "/M8HH%2B8PC+Kick+Futsal+Lalitpur,+Lalitpur+44600/@27.681317,85.3056593,13z/data=!3m1!4b1!4m17!1m7!3m6!1s0x39eb19e5499fa4d3:0xeba45549ab60c8d9!2sKick+Futsal+Lalitpur!8m2!3d27.6783213!4d85.3292562!16s%2Fg%2F11f6nqq74f!4m8!1m1!4e1!1m5!1m1!1s0x39eb19e5499fa4d3:0xeba45549ab60c8d9!2m2!1d85.3291972!2d27.6783339?entry=ttu"
if (ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_FINE_LOCATION
) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_COARSE_LOCATION
) != PackageManager.PERMISSION_GRANTED
) {
return@setContent
}
CurrentLocationContent(usePreciseLocation = true,mapUrl)
}
}
phone.setOnClickListener{
val composeView = findViewById<ComposeView>(R.id.compose_view_phone)
composeView.setContent {
InitiatePhoneCall(phone=phone.text.toString())
}
}
}
}
| hamro_futsal/app/src/main/java/futsalLocation/KickFutsal.kt | 143736232 |
package futsalLocation
import android.Manifest
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalContext
import androidx.core.app.ActivityCompat
import com.example.hamrofutsal.R
import com.example.hamrofutsal.UserBookingActivity
import com.example.hamrofutsal.UserDashboardActivity
class JadibutiFutsal : AppCompatActivity() {
private lateinit var BookNow : Button
private lateinit var OpenMap: Button
private lateinit var back: ImageView
private lateinit var email : TextView
private lateinit var phone : TextView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_jadibuti_futsal)
BookNow = findViewById(R.id.BookNow)
OpenMap = findViewById(R.id.OpenMap)
back = findViewById(R.id.backManakamana)
phone = findViewById(R.id.phoneId)
// checkPermissions()
back.setOnClickListener {
val intent = Intent(this, UserDashboardActivity::class.java)
startActivity(intent)
}
BookNow.setOnClickListener {
val intent = Intent(this, UserBookingActivity::class.java)
startActivity(intent)
}
OpenMap.setOnClickListener {
// Place your click listener logic here
// This code will execute when the OpenMap button is clicked
val composeView = findViewById<ComposeView>(R.id.compose_view_map)
composeView.setContent {
val mapUrl = "/M992%2BXHM+Jadibuti+futsal,+Bhagwan+Kripa+Marga,+Kathmandu+44600/@27.6741401,85.3493531,15z/data=!3m1!4b1!4m17!1m7!3m6!1s0x39eb196bced47a63:0x9d3eef565ed6ab06!2sJadibuti+futsal!8m2!3d27.6733627!4d85.3529392!16s%2Fg%2F11h194wqg5!4m8!1m1!4e1!1m5!1m1!1s0x39eb196bced47a63:0x9d3eef565ed6ab06!2m2!1d85.3529392!2d27.6733627?entry=ttu/M992%2BXHM+Jadibuti+futsal,+Bhagwan+Kripa+Marga,+Kathmandu+44600/@27.6741401,85.3493531,15z/data=!3m1!4b1!4m17!1m7!3m6!1s0x39eb196bced47a63:0x9d3eef565ed6ab06!2sJadibuti+futsal!8m2!3d27.6733627!4d85.3529392!16s%2Fg%2F11h194wqg5!4m8!1m1!4e1!1m5!1m1!1s0x39eb196bced47a63:0x9d3eef565ed6ab06!2m2!1d85.3529392!2d27.6733627?entry=ttu"
if (ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_FINE_LOCATION
) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_COARSE_LOCATION
) != PackageManager.PERMISSION_GRANTED
) {
return@setContent
}
CurrentLocationContent(usePreciseLocation = true,mapUrl)
}
}
phone.setOnClickListener{
val composeView = findViewById<ComposeView>(R.id.compose_view_phone)
composeView.setContent {
InitiatePhoneCall(phone=phone.text.toString())
}
}
}
}
| hamro_futsal/app/src/main/java/futsalLocation/JadibutiFutsal.kt | 2638592001 |
package futsalLocation
import android.Manifest
import android.annotation.SuppressLint
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalContext
import androidx.core.app.ActivityCompat
import com.example.hamrofutsal.R
import com.example.hamrofutsal.UserBookingActivity
import com.example.hamrofutsal.UserDashboardActivity
class NationalFutsal : AppCompatActivity() {
private lateinit var BookNow : Button
private lateinit var OpenMap: Button
private lateinit var back: ImageView
private lateinit var email : TextView
private lateinit var phone : TextView
@SuppressLint("MissingInflatedId")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_national_futsal)
BookNow = findViewById(R.id.BookNow)
OpenMap = findViewById(R.id.OpenMap)
back = findViewById(R.id.backManakamana)
phone = findViewById(R.id.phoneId)
// checkPermissions()
back.setOnClickListener {
val intent = Intent(this, UserDashboardActivity::class.java)
startActivity(intent)
}
BookNow.setOnClickListener {
val intent = Intent(this, UserBookingActivity::class.java)
startActivity(intent)
}
OpenMap.setOnClickListener {
// Place your click listener logic here
// This code will execute when the OpenMap button is clicked
val composeView = findViewById<ComposeView>(R.id.compose_view_map)
composeView.setContent {
val mapUrl = "/M8GM%2B26R+National+Sports+Centre+Pvt.+Ltd.,+Lalitpur+44600/@27.679533,85.3083263,13z/data=!3m1!4b1!4m17!1m7!3m6!1s0x39eb19ea00ef9c93:0xc6689d8e05ef526a!2sNational+Sports+Centre+Pvt.+Ltd.!8m2!3d27.6770538!4d85.3338971!16s%2Fg%2F11cs1vp11g!4m8!1m1!4e1!1m5!1m1!1s0x39eb19ea00ef9c93:0xc6689d8e05ef526a!2m2!1d85.3338971!2d27.6770538?entry=ttu"
if (ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_FINE_LOCATION
) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_COARSE_LOCATION
) != PackageManager.PERMISSION_GRANTED
) {
return@setContent
}
CurrentLocationContent(usePreciseLocation = true,mapUrl)
}
}
phone.setOnClickListener{
val composeView = findViewById<ComposeView>(R.id.compose_view_phone)
composeView.setContent {
InitiatePhoneCall(phone=phone.text.toString())
}
}
}
}
| hamro_futsal/app/src/main/java/futsalLocation/NationalFutsal.kt | 2768516277 |
package futsalLocation
import android.Manifest
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalContext
import androidx.core.app.ActivityCompat
import com.example.hamrofutsal.R
import com.example.hamrofutsal.UserBookingActivity
import com.example.hamrofutsal.UserDashboardActivity
class ManakamanaFutsal : AppCompatActivity() {
private lateinit var BookNow : Button
private lateinit var OpenMap: Button
private lateinit var back: ImageView
private lateinit var email : TextView
private lateinit var phone : TextView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_manakamana_futsal)
BookNow = findViewById(R.id.BookNow)
OpenMap = findViewById(R.id.OpenMap)
back = findViewById(R.id.backManakamana)
phone = findViewById(R.id.phoneId)
// checkPermissions()
back.setOnClickListener {
val intent = Intent(this, UserDashboardActivity::class.java)
startActivity(intent)
}
BookNow.setOnClickListener {
val intent = Intent(this, UserBookingActivity::class.java)
startActivity(intent)
}
OpenMap.setOnClickListener {
// Place your click listener logic here
// This code will execute when the OpenMap button is clicked
val composeView = findViewById<ComposeView>(R.id.compose_view_map)
composeView.setContent {
val mapUrl = "/P9MQ%2B3GX+Manakamana+Futsal,+Gokarneshwor+44600/@27.7031882,85.332368,13z/data=!3m1!4b1!4m17!1m7!3m6!1s0x39eb1bd1f0853467:0x345900f774919c3c!2sManakamana+Futsal!8m2!3d27.7327285!4d85.388845!16s%2Fg%2F11h48hb416!4m8!1m1!4e1!1m5!1m1!1s0x39eb1bd1f0853467:0x345900f774919c3c!2m2!1d85.388845!2d27.7327285?entry=ttu"
if (ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_FINE_LOCATION
) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_COARSE_LOCATION
) != PackageManager.PERMISSION_GRANTED
) {
return@setContent
}
CurrentLocationContent(usePreciseLocation = true,mapUrl)
}
}
phone.setOnClickListener{
val composeView = findViewById<ComposeView>(R.id.compose_view_phone)
composeView.setContent {
InitiatePhoneCall(phone=phone.text.toString())
}
}
}
}
| hamro_futsal/app/src/main/java/futsalLocation/ManakamanaFutsal.kt | 1592748722 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.