content
stringlengths 0
13M
| path
stringlengths 4
263
| contentHash
stringlengths 1
10
|
---|---|---|
/*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.navigation
sealed class ScreenDestinations(val route: String) {
// Destinations
data object HomeScreen : ScreenDestinations("home_screen")
data object ViewScreen : ScreenDestinations("view_screen")
}
| ChatbotProject/navigation/src/main/java/template/navigation/ScreenDestinations.kt | 1565820956 |
/*
* MIT License
*
* Copyright (c) $YEAR Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
| ChatbotProject/spotless/copyright.kt | 3142865241 |
/*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.common.utils
import android.content.Context
import android.os.Build
import android.widget.Toast
import androidx.annotation.StringRes
fun Context.toast(
message: String,
onToastDisplayChange: (Boolean) -> Unit,
) {
showToast(message, onToastDisplayChange)
}
fun Context.toast(
@StringRes message: Int,
onToastDisplayChange: (Boolean) -> Unit,
) {
showToast(getString(message), onToastDisplayChange)
}
private fun Context.showToast(
message: String,
onToastDisplayChange: (Boolean) -> Unit,
) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).also {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
it.addCallback(object : Toast.Callback() {
override fun onToastHidden() {
super.onToastHidden()
onToastDisplayChange(false)
}
override fun onToastShown() {
super.onToastShown()
onToastDisplayChange(true)
}
})
}
}.show()
}
| ChatbotProject/common/src/main/java/template/common/utils/Toast.kt | 574733622 |
/*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.common.utils
import android.os.Build
import android.util.Log
import java.io.BufferedReader
import java.io.File
import java.io.InputStreamReader
/**
* ใซใผใๅใใใฆใใๅ
ๅใ่ฆใใใใ็ขบ่ชใใใกใฝใใใๆไพใใ.
*/
@Suppress("UtilityClassWithPublicConstructor")
class RootUtil {
companion object {
private val Tag = RootUtil::class.java.simpleName
private const val PATH_TO_WHICH = "/system/xbin/which"
private const val CMD_SU = "su"
private val PATHS_SU = arrayOf(
"/system/app/Superuser.apk",
"/system/etc/init.d/99SuperSUDaemon",
"/dev/com.koushikdutta.superuser.daemon/",
"/system/xbin/daemonsu",
"/system/xbin/busybox",
"/system/xbin/su",
"/system/sd/xbin/su",
"/system/bin/su",
"/system/bin/failsafe/su",
"/su/bin/su",
"/sbin/su",
"/data/local/xbin/su",
"/data/local/bin/su",
"/data/local/su",
)
/**
* ใซใผใๅใใใ็ซฏๆซใใฉใใ็ขบ่ชใใ.
*/
fun isDeviceRooted(): Boolean {
return checkRootBuild() || checkRootApps() || checkRootSu()
}
/**
* ใในใใใซใใใซในใฟใ ROM ใฎๅ
ๅใ็ขบ่ชใใ.
*/
private fun checkRootBuild(): Boolean {
val buildTags = Build.TAGS
val ret = buildTags != null && buildTags.contains("test-keys")
if (ret) {
Log.e(Tag, "Root check is false(Test build or custom build)")
}
return ret
}
/**
* ใซใผใๅใใใใใใคในใซ้ๅธธ่ฆใคใใใใกใคใซใใใงใใฏใใ.
*/
private fun checkRootApps(): Boolean {
for (path in PATHS_SU) {
if (File(path).exists()) {
Log.e(Tag, "Root check is false(SU application is found)")
return true
}
}
return false
}
/**
* su ใๅญๅจใใใใฉใใใๅคๆญใใๅฅใฎๆนๆณใฏใRuntime.getRuntime.exec() ใงๅฎ่กใ่ฉฆใฟใ.
*/
@Suppress("SwallowedException", "TooGenericExceptionCaught")
private fun checkRootSu(): Boolean {
var process: Process? = null
val ret = try {
process = Runtime.getRuntime().exec(arrayOf(PATH_TO_WHICH, CMD_SU))
val inputStream = BufferedReader(InputStreamReader(process.inputStream))
inputStream.readLine() != null
} catch (t: Throwable) {
false
} finally {
process?.destroy()
}
if (ret.not()) {
Log.e(Tag, "Root check is false(SU is enabled)")
}
return ret
}
}
}
| ChatbotProject/common/src/main/java/template/common/utils/RootUtil.kt | 1956882264 |
/*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.common.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import template.theme.TemplateTheme
@Composable
fun FullScreenCircularProgressIndicator() {
Box(
modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colorScheme.background),
contentAlignment = Alignment.Center,
) {
CircularProgressIndicator()
}
}
@TemplatePreview
@Composable
fun FullScreenCircularProgressIndicatorPreview() {
TemplateTheme {
Surface {
FullScreenCircularProgressIndicator()
}
}
}
| ChatbotProject/common/src/main/java/template/common/components/ProgressIndicators.kt | 1597716894 |
/*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.common.components
import androidx.annotation.StringRes
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Email
import androidx.compose.material.icons.filled.Info
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.unit.dp
import template.common.R
import template.theme.TemplateTheme
@Composable
fun AppTextField(
value: String,
@StringRes label: Int,
hint: String = "",
onValueChanged: (value: String) -> Unit,
isPasswordField: Boolean = false,
isClickOnly: Boolean = false,
onClick: () -> Unit = {},
leadingIcon: ImageVector? = null,
@StringRes error: Int? = null,
keyboardType: KeyboardType = KeyboardType.Text,
imeAction: ImeAction = ImeAction.Done,
onDone: () -> Unit = {},
) {
val focusManager = LocalFocusManager.current
Box(
modifier = Modifier
.fillMaxWidth()
.height(90.dp),
) {
TextField(
modifier = Modifier
.fillMaxWidth()
.clickable {
if (isClickOnly) {
onClick()
}
},
value = value,
onValueChange = { onValueChanged(it) },
singleLine = true,
isError = error != null,
readOnly = isClickOnly,
enabled = !isClickOnly,
supportingText = {
if (error != null) {
Text(
modifier = Modifier.fillMaxWidth(),
text = stringResource(error),
color = MaterialTheme.colorScheme.error,
)
}
},
visualTransformation = if (isPasswordField) PasswordVisualTransformation() else VisualTransformation.None,
label = { Text(text = stringResource(label)) },
placeholder = { Text(text = hint) },
leadingIcon = {
leadingIcon?.let {
Icon(it, hint, tint = MaterialTheme.colorScheme.onSurfaceVariant)
}
},
trailingIcon = {
if (error != null) {
Icon(Icons.Filled.Info, "error", tint = MaterialTheme.colorScheme.error)
}
},
keyboardActions = KeyboardActions(
onDone = {
focusManager.clearFocus()
onDone()
},
onNext = { focusManager.moveFocus(FocusDirection.Down) },
),
keyboardOptions = KeyboardOptions(
keyboardType = keyboardType,
imeAction = imeAction,
),
)
}
}
@TemplatePreview
@Composable
fun AppTextFieldPreview() {
TemplateTheme {
Surface {
TextField(
modifier = Modifier
.fillMaxWidth()
.clickable {},
value = "",
onValueChange = { },
singleLine = true,
isError = true,
readOnly = false,
enabled = true,
supportingText = {
Text(text = "Error Message or Supporting Message")
},
placeholder = { Text(text = "Hint") },
)
}
}
}
@TemplatePreview
@Composable
fun LoginScreenPreview() {
TemplateTheme {
Surface(modifier = Modifier.fillMaxSize()) {
AppTextField(
value = "[email protected]",
label = R.string.email,
hint = "[email protected]",
error = com.google.android.material.R.string.error_a11y_label,
leadingIcon = Icons.Filled.Email,
onValueChanged = { },
imeAction = ImeAction.Next,
)
}
}
}
| ChatbotProject/common/src/main/java/template/common/components/TextFields.kt | 3139571799 |
/*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.common.components
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.vector.ImageVector
@Composable
fun AppBar(
title: String,
navIcon: ImageVector? = null,
onNav: () -> Unit = {},
) {
TopAppBar(
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.primaryContainer,
titleContentColor = MaterialTheme.colorScheme.primary,
),
title = {
Text(text = title)
},
navigationIcon = {
navIcon?.let {
IconButton(onClick = { onNav() }) {
Icon(navIcon, contentDescription = "Nav Icon")
}
}
},
)
}
| ChatbotProject/common/src/main/java/template/common/components/AppBar.kt | 1069187939 |
/*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.common.components
import android.content.res.Configuration.UI_MODE_NIGHT_NO
import android.content.res.Configuration.UI_MODE_NIGHT_YES
import androidx.compose.ui.tooling.preview.Preview
@Preview(
name = "Preview Day",
showBackground = true,
uiMode = UI_MODE_NIGHT_NO,
)
@Preview(
name = "Preview Night",
showBackground = true,
uiMode = UI_MODE_NIGHT_YES,
)
annotation class TemplatePreview
| ChatbotProject/common/src/main/java/template/common/components/TemplatePreview.kt | 4188115053 |
/*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.common
const val DURATION_MILLIS = 500
const val VALUES_X = 0.4f
const val VALUES_Y = 0.0f
const val DURATION = 500L
| ChatbotProject/common/src/main/java/template/common/Constents.kt | 186668979 |
/*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.theme
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Shapes
import androidx.compose.ui.unit.dp
val Shapes =
Shapes(
small = RoundedCornerShape(4.dp),
medium = RoundedCornerShape(4.dp),
large = RoundedCornerShape(0.dp),
)
| ChatbotProject/theme/src/main/java/template/theme/Shape.kt | 3115525955 |
/*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.theme.splashScreen
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
@HiltViewModel
class SplashViewModel :
// @Inject constructor(
// @ApplicationContext context: Context,
// // private val prefDataStore: PrefDataStore)
ViewModel() {
private val _isLoading = MutableStateFlow(false)
val isLoading = _isLoading.asStateFlow()
companion object {
const val DELAY_DURATION = 3000L
}
init {
viewModelScope.launch {
delay(DELAY_DURATION)
_isLoading.value = true
}
}
}
| ChatbotProject/theme/src/main/java/template/theme/splashScreen/SplashViewModel.kt | 3932454659 |
/*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.theme
import androidx.compose.ui.graphics.Color
const val LIGHT_PRIMARY = 0xFF3F51B5
const val LIGHT_ON_PRIMARY = 0xFFFFFFFF
const val LIGHT_PRIMARY_CONTAINER = 0xFFFFFFFF
const val LIGHT_ON_PRIMARY_CONTAINER = 0xFF000000
const val LIGHT_SECONDARY = 0xFF303F9F
const val LIGHT_ON_SECONDARY = 0xFFFFFFFF
const val LIGHT_SECONDARY_CONTAINER = 0xFFFFFFFF
const val LIGHT_ON_SECONDARY_CONTAINER = 0xFF000000
const val LIGHT_TERTIARY = 0xFFC5CAE9
const val LIGHT_ON_TERTIARY = 0xFF000000
const val LIGHT_TERTIARY_CONTAINER = 0xFFFFFFFF
const val LIGHT_ON_TERTIARY_CONTAINER = 0xFF000000
const val LIGHT_ERROR = 0xFFB00020
const val LIGHT_ERROR_CONTAINER = 0xFFFFFFFF
const val LIGHT_ON_ERROR = 0xFFFFFFFF
const val LIGHT_ON_ERROR_CONTAINER = 0xFF000000
const val LIGHT_BACKGROUND = 0xFFFFFFFF
const val LIGHT_ON_BACKGROUND = 0xFF000000
const val LIGHT_SURFACE = 0xFFFFFFFF
const val LIGHT_ON_SURFACE = 0xFF000000
const val LIGHT_SURFACE_VARIANT = 0xFFE8EAF6
const val LIGHT_ON_SURFACE_VARIANT = 0xFF000000
const val LIGHT_OUTLINE = 0xFF000000
const val LIGHT_INVERSE_ON_SURFACE = 0xFFFFFFFF
const val LIGHT_INVERSE_SURFACE = 0xFF000000
const val LIGHT_INVERSE_PRIMARY = 0xFF000000
const val LIGHT_SHADOW = 0x14000000
const val LIGHT_SURFACE_TINT = 0x0A000000
const val LIGHT_OUTLINE_VARIANT = 0x1F000000
const val LIGHT_SCRIM = 0x33000000
const val DARK_PRIMARY = 0xFF7986CB
const val DARK_ON_PRIMARY = 0xFFFFFFFF
const val DARK_PRIMARY_CONTAINER = 0xFF303F9F
const val DARK_ON_PRIMARY_CONTAINER = 0xFFFFFFFF
const val DARK_SECONDARY = 0xFF303F9F
const val DARK_ON_SECONDARY = 0xFFFFFFFF
const val DARK_SECONDARY_CONTAINER = 0xFF3F51B5
const val DARK_ON_SECONDARY_CONTAINER = 0xFFFFFFFF
const val DARK_TERTIARY = 0xFFC5CAE9
const val DARK_ON_TERTIARY = 0xFF000000
const val DARK_TERTIARY_CONTAINER = 0xFFFFFFFF
const val DARK_ON_TERTIARY_CONTAINER = 0xFF000000
const val DARK_ERROR = 0xFFB00020
const val DARK_ERROR_CONTAINER = 0xFFFFFFFF
const val DARK_ON_ERROR = 0xFFFFFFFF
const val DARK_ON_ERROR_CONTAINER = 0xFF000000
const val DARK_BACKGROUND = 0xFF121212
const val DARK_ON_BACKGROUND = 0xFFFFFFFF
const val DARK_SURFACE = 0xFF121212
const val DARK_ON_SURFACE = 0xFFFFFFFF
const val DARK_SURFACE_VARIANT = 0xFF1E1E1E
const val DARK_ON_SURFACE_VARIANT = 0xFFFFFFFF
const val DARK_OUTLINE = 0xFF000000
const val DARK_INVERSE_ON_SURFACE = 0xFFFFFFFF
const val DARK_INVERSE_SURFACE = 0xFF000000
const val DARK_INVERSE_PRIMARY = 0xFF000000
const val DARK_SHADOW = 0x14000000
const val DARK_SURFACE_TINT = 0x0A000000
const val DARK_OUTLINE_VARIANT = 0x1F000000
const val DARK_SCRIM = 0x33000000
const val SEED = 0xFF3F51B5
val template_theme_light_primary = Color(LIGHT_PRIMARY)
val template_theme_light_onPrimary = Color(LIGHT_ON_PRIMARY)
val template_theme_light_primaryContainer = Color(LIGHT_PRIMARY_CONTAINER)
val template_theme_light_onPrimaryContainer = Color(LIGHT_ON_PRIMARY_CONTAINER)
val template_theme_light_secondary = Color(LIGHT_SECONDARY)
val template_theme_light_onSecondary = Color(LIGHT_ON_SECONDARY)
val template_theme_light_secondaryContainer = Color(LIGHT_SECONDARY_CONTAINER)
val template_theme_light_onSecondaryContainer = Color(LIGHT_ON_SECONDARY_CONTAINER)
val template_theme_light_tertiary = Color(LIGHT_TERTIARY)
val template_theme_light_onTertiary = Color(LIGHT_ON_TERTIARY)
val template_theme_light_tertiaryContainer = Color(LIGHT_TERTIARY_CONTAINER)
val template_theme_light_onTertiaryContainer = Color(LIGHT_ON_TERTIARY_CONTAINER)
val template_theme_light_error = Color(LIGHT_ERROR)
val template_theme_light_errorContainer = Color(LIGHT_ERROR_CONTAINER)
val template_theme_light_onError = Color(LIGHT_ON_ERROR)
val template_theme_light_onErrorContainer = Color(LIGHT_ON_ERROR_CONTAINER)
val template_theme_light_background = Color(LIGHT_BACKGROUND)
val template_theme_light_onBackground = Color(LIGHT_ON_BACKGROUND)
val template_theme_light_surface = Color(LIGHT_SURFACE)
val template_theme_light_onSurface = Color(LIGHT_ON_SURFACE)
val template_theme_light_surfaceVariant = Color(LIGHT_SURFACE_VARIANT)
val template_theme_light_onSurfaceVariant = Color(LIGHT_ON_SURFACE_VARIANT)
val template_theme_light_outline = Color(LIGHT_OUTLINE)
val template_theme_light_inverseOnSurface = Color(LIGHT_INVERSE_ON_SURFACE)
val template_theme_light_inverseSurface = Color(LIGHT_INVERSE_SURFACE)
val template_theme_light_inversePrimary = Color(LIGHT_INVERSE_PRIMARY)
val template_theme_light_shadow = Color(LIGHT_SHADOW)
val template_theme_light_surfaceTint = Color(LIGHT_SURFACE_TINT)
val template_theme_light_outlineVariant = Color(LIGHT_OUTLINE_VARIANT)
val template_theme_light_scrim = Color(LIGHT_SCRIM)
val template_theme_dark_primary = Color(DARK_PRIMARY)
val template_theme_dark_onPrimary = Color(DARK_ON_PRIMARY)
val template_theme_dark_primaryContainer = Color(DARK_PRIMARY_CONTAINER)
val template_theme_dark_onPrimaryContainer = Color(DARK_ON_PRIMARY_CONTAINER)
val template_theme_dark_secondary = Color(DARK_SECONDARY)
val template_theme_dark_onSecondary = Color(DARK_ON_SECONDARY)
val template_theme_dark_secondaryContainer = Color(DARK_SECONDARY_CONTAINER)
val template_theme_dark_onSecondaryContainer = Color(DARK_ON_SECONDARY_CONTAINER)
val template_theme_dark_tertiary = Color(DARK_TERTIARY)
val template_theme_dark_onTertiary = Color(DARK_ON_TERTIARY)
val template_theme_dark_tertiaryContainer = Color(DARK_TERTIARY_CONTAINER)
val template_theme_dark_onTertiaryContainer = Color(DARK_ON_TERTIARY_CONTAINER)
val template_theme_dark_error = Color(DARK_ERROR)
val template_theme_dark_errorContainer = Color(DARK_ERROR_CONTAINER)
val template_theme_dark_onError = Color(DARK_ON_ERROR)
val template_theme_dark_onErrorContainer = Color(DARK_ON_ERROR_CONTAINER)
val template_theme_dark_background = Color(DARK_BACKGROUND)
val template_theme_dark_onBackground = Color(DARK_ON_BACKGROUND)
val template_theme_dark_surface = Color(DARK_SURFACE)
val template_theme_dark_onSurface = Color(DARK_ON_SURFACE)
val template_theme_dark_surfaceVariant = Color(DARK_SURFACE_VARIANT)
val template_theme_dark_onSurfaceVariant = Color(DARK_ON_SURFACE_VARIANT)
val template_theme_dark_outline = Color(DARK_OUTLINE)
val template_theme_dark_inverseOnSurface = Color(DARK_INVERSE_ON_SURFACE)
val template_theme_dark_inverseSurface = Color(DARK_INVERSE_SURFACE)
val template_theme_dark_inversePrimary = Color(DARK_INVERSE_PRIMARY)
val template_theme_dark_shadow = Color(DARK_SHADOW)
val template_theme_dark_surfaceTint = Color(DARK_SURFACE_TINT)
val template_theme_dark_outlineVariant = Color(DARK_OUTLINE_VARIANT)
val template_theme_dark_scrim = Color(DARK_SCRIM)
val seed = Color(SEED)
| ChatbotProject/theme/src/main/java/template/theme/Color.kt | 483642369 |
/*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.theme
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
private val LightColors = lightColorScheme(
primary = template_theme_light_primary,
onPrimary = template_theme_light_onPrimary,
primaryContainer = template_theme_light_primaryContainer,
onPrimaryContainer = template_theme_light_onPrimaryContainer,
secondary = template_theme_light_secondary,
onSecondary = template_theme_light_onSecondary,
secondaryContainer = template_theme_light_secondaryContainer,
onSecondaryContainer = template_theme_light_onSecondaryContainer,
tertiary = template_theme_light_tertiary,
onTertiary = template_theme_light_onTertiary,
tertiaryContainer = template_theme_light_tertiaryContainer,
onTertiaryContainer = template_theme_light_onTertiaryContainer,
error = template_theme_light_error,
errorContainer = template_theme_light_errorContainer,
onError = template_theme_light_onError,
onErrorContainer = template_theme_light_onErrorContainer,
background = template_theme_light_background,
onBackground = template_theme_light_onBackground,
surface = template_theme_light_surface,
onSurface = template_theme_light_onSurface,
surfaceVariant = template_theme_light_surfaceVariant,
onSurfaceVariant = template_theme_light_onSurfaceVariant,
outline = template_theme_light_outline,
inverseOnSurface = template_theme_light_inverseOnSurface,
inverseSurface = template_theme_light_inverseSurface,
inversePrimary = template_theme_light_inversePrimary,
surfaceTint = template_theme_light_surfaceTint,
outlineVariant = template_theme_light_outlineVariant,
scrim = template_theme_light_scrim,
)
private val DarkColors = darkColorScheme(
primary = template_theme_dark_primary,
onPrimary = template_theme_dark_onPrimary,
primaryContainer = template_theme_dark_primaryContainer,
onPrimaryContainer = template_theme_dark_onPrimaryContainer,
secondary = template_theme_dark_secondary,
onSecondary = template_theme_dark_onSecondary,
secondaryContainer = template_theme_dark_secondaryContainer,
onSecondaryContainer = template_theme_dark_onSecondaryContainer,
tertiary = template_theme_dark_tertiary,
onTertiary = template_theme_dark_onTertiary,
tertiaryContainer = template_theme_dark_tertiaryContainer,
onTertiaryContainer = template_theme_dark_onTertiaryContainer,
error = template_theme_dark_error,
errorContainer = template_theme_dark_errorContainer,
onError = template_theme_dark_onError,
onErrorContainer = template_theme_dark_onErrorContainer,
background = template_theme_dark_background,
onBackground = template_theme_dark_onBackground,
surface = template_theme_dark_surface,
onSurface = template_theme_dark_onSurface,
surfaceVariant = template_theme_dark_surfaceVariant,
onSurfaceVariant = template_theme_dark_onSurfaceVariant,
outline = template_theme_dark_outline,
inverseOnSurface = template_theme_dark_inverseOnSurface,
inverseSurface = template_theme_dark_inverseSurface,
inversePrimary = template_theme_dark_inversePrimary,
surfaceTint = template_theme_dark_surfaceTint,
outlineVariant = template_theme_dark_outlineVariant,
scrim = template_theme_dark_scrim,
)
@Composable
fun TemplateTheme(
useDarkTheme: Boolean = isSystemInDarkTheme(),
content:
@Composable()
() -> Unit,
) {
val colors = if (!useDarkTheme) {
LightColors
} else {
DarkColors
}
MaterialTheme(
colorScheme = colors,
typography = Typography,
shapes = Shapes,
content = content,
)
}
| ChatbotProject/theme/src/main/java/template/theme/Theme.kt | 878384629 |
/*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.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(
bodyMedium =
TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
),
)
| ChatbotProject/theme/src/main/java/template/theme/Type.kt | 360953294 |
fun main() {
println(sentence("Barnie","bakes","brown","bagels","buns"))
isPandrome()
}
fun sentence(b1:String,b2:String,b3:String,b4:String,b5:String){
var words = "Barnie bakes brown bagels and buns"
}
fun isPalindrome(word:String):Boolean{
var words = "madam wow kayak"
if(words == "gender" ){
println("madam wow kayak")
}
} | press/src/main/kotlin/Main.kt | 1717384775 |
package com.pacheco.volumetechtest.ui.viewmodel
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.pacheco.volumetechtest.domain.model.WeatherModel
import com.pacheco.volumetechtest.domain.usecase.GetWeatherUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.*
import java.util.concurrent.TimeUnit
import javax.inject.Inject
@HiltViewModel
class MainViewModel @Inject constructor(
private val getWeatherUseCase: GetWeatherUseCase
) : ViewModel() {
fun getWeather(onSuccess: (WeatherModel) -> Unit) {
viewModelScope.launch(context = CoroutineExceptionHandler { _, _ ->
getWeather(onSuccess = onSuccess)
}) {
while (currentCoroutineContext().isActive) {
onSuccess(getWeatherUseCase())
delay(timeMillis = TimeUnit.HOURS.toMillis(1))
}
}
}
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/ui/viewmodel/MainViewModel.kt | 1109229957 |
package com.pacheco.volumetechtest.ui
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.pacheco.volumetechtest.domain.model.WeatherModel
import com.pacheco.volumetechtest.router.ApplicationNavHost
import com.pacheco.volumetechtest.ui.theme.VolumeTechTestTheme
import com.pacheco.volumetechtest.ui.viewmodel.MainViewModel
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.delay
import java.util.concurrent.TimeUnit
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
private val viewModel: MainViewModel by viewModels()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
VolumeTechTestTheme {
Scaffold(modifier = Modifier.fillMaxSize()) {
WeatherLayer(viewModel = viewModel)
ApplicationNavHost()
}
}
}
}
}
@Composable
private fun WeatherLayer(viewModel: MainViewModel) {
var weather: WeatherModel? by remember {
mutableStateOf(null)
}
var alignment: Pair<Alignment?, Alignment.Horizontal?> by remember {
mutableStateOf(null to null)
}
LaunchedEffect(key1 = Unit) {
while (true) {
alignment = when(alignment.first) {
Alignment.TopStart -> Alignment.TopEnd to Alignment.End
Alignment.TopEnd -> Alignment.TopStart to Alignment.Start
else -> Alignment.TopStart to Alignment.Start
}
delay(timeMillis = TimeUnit.SECONDS.toMillis(30))
}
}
weather?.let {
Box(
contentAlignment = alignment.first ?: Alignment.TopStart,
modifier = Modifier.fillMaxWidth()
) {
Column(
modifier = Modifier
.background(color = Color.Blue)
.padding(all = 10.dp),
horizontalAlignment = alignment.second ?: Alignment.Start
) {
Text(text = it.temp.toString() + "ยบC")
Text(text = it.city)
}
}
} ?: viewModel.getWeather {
weather = it
}
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/ui/MainActivity.kt | 3002005988 |
package com.pacheco.volumetechtest.ui.theme
import androidx.compose.material3.darkColorScheme
val colorScheme = darkColorScheme() | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/ui/theme/Color.kt | 2180895376 |
package com.pacheco.volumetechtest.ui.theme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
@Composable
fun VolumeTechTestTheme(content: @Composable () -> Unit) {
MaterialTheme(
colorScheme = colorScheme,
typography = typography,
content = content
)
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/ui/theme/Theme.kt | 2752708008 |
package com.pacheco.volumetechtest.ui.theme
import androidx.compose.material3.Typography
val typography = Typography() | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/ui/theme/Type.kt | 1390371375 |
package com.pacheco.volumetechtest.ui.view
import androidx.compose.runtime.Composable
@Composable
fun HomeView() {
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/ui/view/HomeView.kt | 4089622524 |
package com.pacheco.volumetechtest.di
import com.pacheco.volumetechtest.data.mapper.WeatherMapper
import com.pacheco.volumetechtest.data.mapper.WeatherMapperImp
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
abstract class MapperModule {
@Singleton
@Binds
abstract fun bindWeatherMapper(mapper: WeatherMapperImp): WeatherMapper
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/di/MapperModule.kt | 2350524149 |
package com.pacheco.volumetechtest.di
import com.pacheco.volumetechtest.data.RetrofitClient
import com.pacheco.volumetechtest.data.service.WeatherService
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
object ServiceModule {
@Singleton
@Provides
fun provideWeatherService(): WeatherService = RetrofitClient.create(classType = WeatherService::class.java)
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/di/ServiceModule.kt | 2454644355 |
package com.pacheco.volumetechtest.di
import com.pacheco.volumetechtest.data.repository.WeatherRepositoryImp
import com.pacheco.volumetechtest.domain.repository.WeatherRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
abstract class RepositoryModule {
@Singleton
@Binds
abstract fun bindWeatherRepository(repository: WeatherRepositoryImp): WeatherRepository
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/di/RepositoryModule.kt | 162967843 |
package com.pacheco.volumetechtest.di
import com.pacheco.volumetechtest.domain.usecase.GetWeatherUseCase
import com.pacheco.volumetechtest.domain.usecase.GetWeatherUseCaseImp
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
abstract class UseCaseModule {
@Singleton
@Binds
abstract fun bindGetWeatherUseCase(usecase: GetWeatherUseCaseImp): GetWeatherUseCase
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/di/UseCaseModule.kt | 691662648 |
package com.pacheco.volumetechtest
import android.app.Application
import dagger.hilt.android.HiltAndroidApp
@HiltAndroidApp
class HiltApplication : Application() | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/HiltApplication.kt | 1126531550 |
package com.pacheco.volumetechtest.data.dto
data class WeatherDto(
val name: String?,
val main: MainDto?
)
| VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/data/dto/WeatherDto.kt | 3844164055 |
package com.pacheco.volumetechtest.data.dto
data class MainDto(
val temp: Float?
)
| VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/data/dto/MainDto.kt | 1357034274 |
package com.pacheco.volumetechtest.data.repository
import com.pacheco.volumetechtest.data.mapper.WeatherMapper
import com.pacheco.volumetechtest.data.service.WeatherService
import com.pacheco.volumetechtest.domain.model.City
import com.pacheco.volumetechtest.domain.repository.WeatherRepository
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class WeatherRepositoryImp @Inject constructor(
private val service: WeatherService,
private val mapper: WeatherMapper
) : WeatherRepository {
override suspend fun getWeather(city: City) = mapper.toModel(
dto = service.getWeather(city = city.name),
city = city
)
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/data/repository/WeatherRepositoryImp.kt | 2805144711 |
package com.pacheco.volumetechtest.data
object Endpoint {
const val BASE_URL = "https://api.openweathermap.org/data/2.5/"
const val WEATHER = "weather"
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/data/Endpoint.kt | 1257965398 |
package com.pacheco.volumetechtest.data
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
object RetrofitClient {
const val API_KEY = "433f0a05409361125a827f77654820e4"
private val INSTANCE: Retrofit = Retrofit.Builder()
.baseUrl(Endpoint.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build()
fun <T> create(classType: Class<T>): T = INSTANCE.create(classType)
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/data/RetrofitClient.kt | 2215922688 |
package com.pacheco.volumetechtest.data.mapper
import com.pacheco.volumetechtest.data.dto.WeatherDto
import com.pacheco.volumetechtest.domain.model.City
import com.pacheco.volumetechtest.domain.model.WeatherModel
import javax.inject.Inject
import kotlin.math.roundToInt
class WeatherMapperImp @Inject constructor() : WeatherMapper {
override fun toModel(dto: WeatherDto?, city: City): WeatherModel {
if (dto?.name == null || dto.main?.temp == null) {
throw Exception()
}
return WeatherModel(
city = dto.name.ifBlank(city::name),
temp = dto.main.temp.roundToInt()
)
}
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/data/mapper/WeatherMapperImp.kt | 3517455199 |
package com.pacheco.volumetechtest.data.mapper
import com.pacheco.volumetechtest.data.dto.WeatherDto
import com.pacheco.volumetechtest.domain.model.City
import com.pacheco.volumetechtest.domain.model.WeatherModel
interface WeatherMapper {
fun toModel(dto: WeatherDto?, city: City): WeatherModel
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/data/mapper/WeatherMapper.kt | 263600258 |
package com.pacheco.volumetechtest.data
sealed class TempUnit(open val name: String) {
data class Metric(override val name: String = "metric"): TempUnit(name = name)
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/data/TempUnit.kt | 1032046605 |
package com.pacheco.volumetechtest.data.service
import com.pacheco.volumetechtest.data.Endpoint
import com.pacheco.volumetechtest.data.RetrofitClient
import com.pacheco.volumetechtest.data.TempUnit
import com.pacheco.volumetechtest.data.dto.WeatherDto
import retrofit2.http.GET
import retrofit2.http.Query
interface WeatherService {
@GET(Endpoint.WEATHER)
suspend fun getWeather(
@Query("q") city: String,
@Query("appid") id: String = RetrofitClient.API_KEY,
@Query("units") unit: String = TempUnit.Metric().name
): WeatherDto?
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/data/service/WeatherService.kt | 1540185752 |
package com.pacheco.volumetechtest.domain.repository
import com.pacheco.volumetechtest.domain.model.City
import com.pacheco.volumetechtest.domain.model.WeatherModel
interface WeatherRepository {
suspend fun getWeather(city: City): WeatherModel
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/domain/repository/WeatherRepository.kt | 2808971097 |
package com.pacheco.volumetechtest.domain.model
sealed class City(open val name: String) {
data class London(override val name: String = "London"): City(name = name)
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/domain/model/City.kt | 408236956 |
package com.pacheco.volumetechtest.domain.model
import java.util.*
data class WeatherModel(
val city: String,
val temp: Int,
private val uuid: UUID = UUID.randomUUID()
) {
override fun equals(other: Any?) = (other as? WeatherModel)?.uuid == this.uuid
override fun hashCode() = temp.hashCode()
}
| VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/domain/model/WeatherModel.kt | 912934264 |
package com.pacheco.volumetechtest.domain.usecase
import com.pacheco.volumetechtest.domain.model.WeatherModel
interface GetWeatherUseCase {
suspend operator fun invoke(): WeatherModel
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/domain/usecase/GetWeatherUseCase.kt | 3519947041 |
package com.pacheco.volumetechtest.domain.usecase
import com.pacheco.volumetechtest.domain.model.City
import com.pacheco.volumetechtest.domain.repository.WeatherRepository
import javax.inject.Inject
class GetWeatherUseCaseImp @Inject constructor(
private val repository: WeatherRepository
): GetWeatherUseCase {
override suspend fun invoke() = repository.getWeather(city = City.London())
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/domain/usecase/GetWeatherUseCaseImp.kt | 3832702606 |
package com.pacheco.volumetechtest.router
import androidx.compose.runtime.Composable
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.pacheco.volumetechtest.ui.view.HomeView
@Composable
fun ApplicationNavHost(navController: NavHostController = rememberNavController()) {
NavHost(navController = navController, startDestination = Destination.HOME.name) {
composable(route = Destination.HOME.name) {
HomeView()
}
}
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/router/ApplicationNavHost.kt | 76017845 |
package com.pacheco.volumetechtest.router
enum class Destination {
HOME
} | VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/router/Destination.kt | 2554851313 |
package il.massive.gea_rent
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("il.massive.gea_rent", appContext.packageName)
}
} | gea_rent_mobile_app_dummy_data/app/src/androidTest/java/il/massive/gea_rent/ExampleInstrumentedTest.kt | 2803171677 |
package il.massive.gea_rent
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)
}
} | gea_rent_mobile_app_dummy_data/app/src/test/java/il/massive/gea_rent/ExampleUnitTest.kt | 313246408 |
package il.massive.gea_rent.ui
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import il.massive.gea_rent.R
import il.massive.gea_rent.databinding.ActivityDetailBarangBinding
class DetailBarangActivity : AppCompatActivity() {
private lateinit var binding: ActivityDetailBarangBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityDetailBarangBinding.inflate(layoutInflater)
setContentView(binding.root)
val gambar_barang = intent.getIntExtra("gambar_barang",0)
val nama_barang = intent.getStringExtra("nama_barang")
val deskripsi_produk = intent.getStringExtra("deskripsi_barang")
val nama_toko = intent.getStringExtra("nama_toko")
val profil_toko = intent.getIntExtra("profil_toko",0)
val skor_barang = intent.getIntExtra("skor_barang",0)
binding.gambarProduk.setImageResource(gambar_barang)
binding.namaProduk.text = nama_barang
binding.deskripsiProduk.text = deskripsi_produk
binding.namaToko.text = nama_toko
binding.profilToko.setImageResource(profil_toko)
binding.skorBarang.setImageResource(skor_barang)
binding.icArrowBack.setOnClickListener {
finish()
}
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/DetailBarangActivity.kt | 2753137881 |
package il.massive.gea_rent.ui
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.ImageButton
import android.widget.Toast
import il.massive.gea_rent.R
class PanduanSleepingBagActivity : AppCompatActivity(), View.OnClickListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_panduan_sleeping_bag)
val btnPanduan: ImageButton = findViewById(R.id.back_panduan3)
btnPanduan.setOnClickListener(this)
}
override fun onClick(v: View?) {
when(v?.id){
R.id.back_panduan3-> {
Toast.makeText(this@PanduanSleepingBagActivity,"Kembali", Toast.LENGTH_LONG).show()
finish()
}
}
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/PanduanSleepingBagActivity.kt | 457126949 |
package il.massive.gea_rent.ui
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.google.android.material.bottomnavigation.BottomNavigationView
import il.massive.gea_rent.R
import il.massive.gea_rent.databinding.ActivityMainBinding
import il.massive.gea_rent.ui.panduan.PanduanFragment
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
loadFragment(BerandaFragment()).run {
setTitles("Beranda","","")
}
binding.bottomNav.setOnNavigationItemSelectedListener { item ->
when (item.itemId) {
R.id.beranda -> {
loadFragment(BerandaFragment())
setTitles("Beranda", "", "")
return@setOnNavigationItemSelectedListener true
}
R.id.panduan -> {
loadFragment(PanduanFragment())
setTitles("", "Panduan", "")
return@setOnNavigationItemSelectedListener true
}
R.id.profile -> {
loadFragment(ProfileFragment())
setTitles("", "", "Profile")
return@setOnNavigationItemSelectedListener true
}
else -> return@setOnNavigationItemSelectedListener false
}
}
}
private fun loadFragment(fragment: Fragment) {
supportFragmentManager.beginTransaction()
.replace(R.id.fragment_container, fragment) // Replace with your fragment container ID
.commit()
}
//set title for bottom nav
private fun setTitles(berandaTitle: String, panduanTitle: String, profileTitle: String) {
val bottomNavigationView: BottomNavigationView = findViewById(R.id.bottom_nav)
bottomNavigationView.menu.findItem(R.id.beranda).setTitle(berandaTitle)
bottomNavigationView.menu.findItem(R.id.panduan).setTitle(panduanTitle)
bottomNavigationView.menu.findItem(R.id.profile).setTitle(profileTitle)
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/MainActivity.kt | 4145805212 |
package il.massive.gea_rent.ui
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.ImageButton
import android.widget.Toast
import il.massive.gea_rent.R
class PanduanKomporActivity : AppCompatActivity(), View.OnClickListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_panduan_kompor)
val btnPanduan: ImageButton = findViewById(R.id.back_panduan)
btnPanduan.setOnClickListener(this)
}
override fun onClick(v: View?) {
when (v?.id) {
R.id.back_panduan -> {
Toast.makeText(this@PanduanKomporActivity, "Kembali", Toast.LENGTH_LONG).show()
finish()
}
}
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/PanduanKomporActivity.kt | 2222057770 |
package il.massive.gea_rent.ui
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import il.massive.gea_rent.R
class SplashScreenActivity : AppCompatActivity() {
//timer
private val SPLASH_TIME_OUT: Long = 3000 //delay 3 detik
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash_screen)
Handler().postDelayed({
startActivity((Intent(this@SplashScreenActivity, OnBoardingActivity::class.java)))
finish()
}, SPLASH_TIME_OUT)
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/SplashScreenActivity.kt | 3969244705 |
package il.massive.gea_rent.ui
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import il.massive.gea_rent.R
import il.massive.gea_rent.databinding.ActivityLoginBinding
import il.massive.gea_rent.databinding.ActivityRegisterBinding
class RegisterActivity : AppCompatActivity() {
private lateinit var binding : ActivityRegisterBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_register)
binding = ActivityRegisterBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.btnDaftar.setOnClickListener {
startActivity(Intent(this@RegisterActivity, MainActivity::class.java))
}
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/RegisterActivity.kt | 1615699775 |
package il.massive.gea_rent.ui
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.ImageButton
import il.massive.gea_rent.R
class DaftarTokoActivity : AppCompatActivity(), View.OnClickListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_daftar_toko)
val btnHalamanProfil: ImageButton = findViewById(R.id.backhalaman)
btnHalamanProfil.setOnClickListener(this)
val btnDaftarToko: Button = findViewById(R.id.btnDaftarToko)
btnDaftarToko.setOnClickListener(this)
}
override fun onClick(v: View?) {
when(v?.id){
R.id.btnDaftarToko-> {
val intent = Intent(this@DaftarTokoActivity, TokoSayaActivity::class.java)
startActivity(intent)
}
R.id.backhalaman-> {
finish()
}
}
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/DaftarTokoActivity.kt | 3145188433 |
package il.massive.gea_rent.ui
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import il.massive.gea_rent.adapter.BarangAdapter
import il.massive.gea_rent.adapter.TokoAdapter
import il.massive.gea_rent.data.barang.DataBarang
import il.massive.gea_rent.data.toko.DataToko
import il.massive.gea_rent.databinding.FragmentBerandaBinding
import il.massive.gea_rent.model.BarangModel
import il.massive.gea_rent.model.TokoModel
class BerandaFragment : Fragment() {
private var _binding: FragmentBerandaBinding? = null
private val binding get() = _binding!!
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentBerandaBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// Set layout manager for RecyclerView
binding.rvTokoTerdekat.layoutManager = LinearLayoutManager(requireContext(),LinearLayoutManager.HORIZONTAL, false)
// Set adapter for RecyclerView
binding.rvTokoTerdekat.adapter = tokoAdapter
binding.rvBarangTerlengkap.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
binding.rvBarangTerlengkap.adapter = barangAdapter
binding.lyBerandaTerdekat.setOnClickListener {
startActivity(Intent(requireContext(), TokoTerdekatActivity::class.java))
}
}
private val tokoAdapter by lazy {
val items = DataToko.dummyTokoData
TokoAdapter(items, object : TokoAdapter.onAdapterListener{
override fun onClick(result: TokoModel) {
val intent = Intent(requireContext(),DetailTokoActivity::class.java)
intent.putExtra("gambar_toko", result.image)
intent.putExtra("nama_toko", result.nama)
intent.putExtra("alamat_toko", result.alamat)
intent.putExtra("no_telepon", result.telpon)
startActivity(intent)
}
})
}
private val barangAdapter by lazy {
val items = DataBarang.dummyDataBarang
BarangAdapter(items, object: BarangAdapter.onAdapterListener{
override fun onClick(barang: BarangModel) {
openDetailBarang(barang)
}
})
}
private fun openDetailBarang(barang: BarangModel) {
val intent = Intent(requireContext(), DetailBarangActivity::class.java)
intent.putExtra("gambar_barang", barang.gambar)
intent.putExtra("harga_barang", barang.harga)
intent.putExtra("nama_barang", barang.nama)
intent.putExtra("deskripsi_barang", barang.deskripsi)
intent.putExtra("nama_toko", barang.toko.nama)
intent.putExtra("profil_toko", barang.toko.image)
intent.putExtra("skor_barang", barang.skor)
startActivity(intent)
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
| gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/BerandaFragment.kt | 837889703 |
package il.massive.gea_rent.ui
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.ImageButton
import il.massive.gea_rent.R
class ProdukSewaActivity : AppCompatActivity(), View.OnClickListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_produk_sewa)
val btnkembalitoko: ImageButton = findViewById(R.id.backTokoSy)
btnkembalitoko.setOnClickListener(this)
val btnUpdateProduk:Button = findViewById(R.id.updateproduk)
btnUpdateProduk.setOnClickListener(this)
}
override fun onClick(v: View?) {
when(v?.id){
R.id.updateproduk-> {
val intent = Intent(this@ProdukSewaActivity, TokoSayaActivity::class.java)
startActivity(intent)
}
R.id.backTokoSy-> {
val intent = Intent(this@ProdukSewaActivity, TokoSayaActivity::class.java)
startActivity(intent)
}
}
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/ProdukSewaActivity.kt | 1637028727 |
package il.massive.gea_rent.ui
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import il.massive.gea_rent.R
import il.massive.gea_rent.adapter.TokoAdapter
import il.massive.gea_rent.adapter.TokoTerdekatAdapter
import il.massive.gea_rent.data.toko.DataToko
import il.massive.gea_rent.databinding.ActivityTokoTerdekatBinding
import il.massive.gea_rent.databinding.TokoTerdekatBinding
import il.massive.gea_rent.model.TokoModel
class TokoTerdekatActivity : AppCompatActivity() {
private lateinit var binding: ActivityTokoTerdekatBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityTokoTerdekatBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.icArrowBack.setOnClickListener {
finish()
}
}
override fun onStart() {
super.onStart()
setUpRecyclerView()
}
private fun setUpRecyclerView(){
val items = DataToko.dummyTokoData
var tokoAdapter = TokoTerdekatAdapter(items, object: TokoTerdekatAdapter.OnAdapterListener{
override fun onClick(result: TokoModel) {
val intent = Intent(this@TokoTerdekatActivity, DetailTokoActivity::class.java)
intent.putExtra("gambar_toko", result.image)
intent.putExtra("nama_toko", result.nama)
intent.putExtra("alamat_toko", result.alamat)
intent.putExtra("no_telepon", result.telpon)
startActivity(intent)
}
})
binding.rvTokoTerdekatLihatSemua.apply {
layoutManager = LinearLayoutManager(this@TokoTerdekatActivity)
adapter = tokoAdapter
}
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/TokoTerdekatActivity.kt | 2384351951 |
package il.massive.gea_rent.ui
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import il.massive.gea_rent.R
import il.massive.gea_rent.databinding.ActivityOnBoardingBinding
class OnBoardingActivity : AppCompatActivity() {
private lateinit var binding: ActivityOnBoardingBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityOnBoardingBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.btnDaftarOnboarding.setOnClickListener {
startActivity(Intent(this@OnBoardingActivity, RegisterActivity::class.java))
}
binding.tvMasukDisini.setOnClickListener {
startActivity(Intent(this@OnBoardingActivity, LoginActivity::class.java))
}
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/OnBoardingActivity.kt | 1515152278 |
package il.massive.gea_rent.ui
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.ImageButton
import android.widget.Toast
import il.massive.gea_rent.R
class PanduanKompasActivity : AppCompatActivity(), View.OnClickListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_panduan_kompas)
val btnPanduan: ImageButton = findViewById(R.id.back_panduan5)
btnPanduan.setOnClickListener(this)
}
override fun onClick(v: View?) {
when(v?.id){
R.id.back_panduan5-> {
Toast.makeText(this@PanduanKompasActivity,"Kembali", Toast.LENGTH_LONG).show()
finish()
}
}
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/PanduanKompasActivity.kt | 2624494533 |
package il.massive.gea_rent.ui
import android.content.Intent
import android.net.Uri
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import il.massive.gea_rent.R
import il.massive.gea_rent.adapter.BarangAdapter
import il.massive.gea_rent.adapter.LayananAdapter
import il.massive.gea_rent.adapter.TokoTerdekatAdapter
import il.massive.gea_rent.data.barang.DataBarang
import il.massive.gea_rent.data.toko.DataToko
import il.massive.gea_rent.databinding.ActivityLayananBinding
import il.massive.gea_rent.databinding.ActivityTokoTerdekatBinding
import il.massive.gea_rent.model.BarangModel
import il.massive.gea_rent.model.TokoModel
class LayananActivity : AppCompatActivity() {
private lateinit var binding: ActivityLayananBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityLayananBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.icArrowBack.setOnClickListener {
finish()
}
binding.btnHubungiStore.setOnClickListener {
// Ganti nomor ini dengan nomor WhatsApp toko yang sesuai
val nomorWhatsApp = "628979276362"
val pesanWhatsApp = "Saya tertarik dengan produk yang berada di toko anda"
val url = "https://api.whatsapp.com/send?phone=$nomorWhatsApp&text=${Uri.encode(pesanWhatsApp)}"
// Buka WhatsApp dengan Intent
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(intent)
}
}
override fun onStart() {
super.onStart()
setUpRecyclerView()
}
private fun setUpRecyclerView(){
val items = DataBarang.dummyDataBarang
var barangAdapter = LayananAdapter(items, object: LayananAdapter.onAdapterListener{
override fun onClick(result: BarangModel) {
Toast.makeText(this@LayananActivity, result.nama, Toast.LENGTH_SHORT).show()
}
})
binding.rvLayanan.apply {
layoutManager = LinearLayoutManager(this@LayananActivity)
adapter = barangAdapter
}
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/LayananActivity.kt | 193641610 |
package il.massive.gea_rent.ui
import android.content.Intent
import android.net.Uri
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.viewpager.widget.ViewPager
import com.google.android.material.tabs.TabLayout
import il.massive.gea_rent.R
import il.massive.gea_rent.adapter.LayananAdapter
import il.massive.gea_rent.data.barang.DataBarang
import il.massive.gea_rent.databinding.ActivityDetailTokoBinding
import il.massive.gea_rent.databinding.ActivityTokoTerdekatBinding
import il.massive.gea_rent.model.BarangModel
class DetailTokoActivity : AppCompatActivity() {
private lateinit var binding: ActivityDetailTokoBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityDetailTokoBinding.inflate(layoutInflater)
setContentView(binding.root)
val gambar = intent.getIntExtra("gambar_toko",0)
val nama = intent.getStringExtra("nama_toko")
val alamat = intent.getStringExtra("alamat_toko")
binding.ivFotoToko.setImageResource(gambar)
binding.tvNamaToko.text = nama
binding.tvAlamatToko.text = alamat
binding.arrowBack.setOnClickListener {
finish()
}
setUpRecyclerView()
hubungiStore()
}
private fun setUpRecyclerView(){
val items = DataBarang.dummyDataBarang
var barangAdapter = LayananAdapter(items, object: LayananAdapter.onAdapterListener{
override fun onClick(barang: BarangModel) {
val intent = Intent(this@DetailTokoActivity, DetailBarangActivity::class.java)
intent.putExtra("gambar_barang", barang.gambar)
intent.putExtra("harga_barang", barang.harga)
intent.putExtra("nama_barang", barang.nama)
intent.putExtra("deskripsi_barang", barang.deskripsi)
intent.putExtra("nama_toko", barang.toko.nama)
intent.putExtra("profil_toko", barang.toko.image)
startActivity(intent)
}
})
binding.rvProdukToko.apply {
layoutManager = GridLayoutManager(this@DetailTokoActivity,2)
adapter = barangAdapter
}
}
private fun hubungiStore(){
val telpon = intent.getStringExtra("no_telepon").toString()
val nomorWhatsApp = telpon
binding.btnHubungiStore.setOnClickListener {
// Ganti nomor ini dengan nomor WhatsApp toko yang sesuai
val pesanWhatsApp = "Saya tertarik dengan produk yang berada di toko anda"
val url = "https://api.whatsapp.com/send?phone=$nomorWhatsApp&text=${Uri.encode(pesanWhatsApp)}"
// Buka WhatsApp dengan Intent
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(intent)
}
}
}
| gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/DetailTokoActivity.kt | 4112368497 |
package il.massive.gea_rent.ui
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.ImageButton
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import il.massive.gea_rent.R
import il.massive.gea_rent.databinding.ActivityTokoSayaBinding
import il.massive.gea_rent.adapter.TokoSayaAdapter
import il.massive.gea_rent.model.TokoSayaModel
class TokoSayaActivity : AppCompatActivity(), View.OnClickListener {
private lateinit var adapter: TokoSayaAdapter
private lateinit var binding: ActivityTokoSayaBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityTokoSayaBinding.inflate(layoutInflater)
setContentView(binding.root)
setTokoSayaAdapter()
val btnTambahProduk: Button = findViewById(R.id.produksewa_tambah)
btnTambahProduk.setOnClickListener(this)
val btnBackToko: ImageButton = findViewById(R.id.backToko)
btnBackToko.setOnClickListener(this)
}
override fun onClick(v: View?) {
when(v?.id){
R.id.produksewa_tambah-> {
val intent = Intent(this@TokoSayaActivity, TambahProdukActivity::class.java)
startActivity(intent)
}
R.id.backToko-> {
val intent = Intent(this@TokoSayaActivity, MainActivity::class.java)
startActivity(intent)
}
}
}
private fun setTokoSayaAdapter() {
val dataList: MutableList<TokoSayaModel> = mutableListOf()
judul().forEachIndexed { index, judul ->
dataList.add(TokoSayaModel(image()[index], judul, tersedia()[index], harga()[index]))
}
// Inisialisasi adapter setelah membuat dataList
adapter = TokoSayaAdapter(dataList, this)
// Atur RecyclerView
binding.recylerview.layoutManager = LinearLayoutManager(this)
binding.recylerview.adapter = adapter
}
private fun judul(): Array<String> = resources.getStringArray(R.array.judul)
private fun tersedia(): Array<String> = resources.getStringArray(R.array.tersedia)
private fun harga(): Array<String> = resources.getStringArray(R.array.harga)
private fun image(): List<Int> = listOf(
R.drawable.img_item1,
R.drawable.img_item2,
R.drawable.img_item3,
R.drawable.img_item4,
R.drawable.img_item5,
R.drawable.img_item6,
R.drawable.img_item7
)
}
| gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/TokoSayaActivity.kt | 4020065246 |
package il.massive.gea_rent.ui
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import il.massive.gea_rent.R
import il.massive.gea_rent.databinding.ActivityDetailPanduanBinding
class DetailPanduanActivity : AppCompatActivity() {
private lateinit var binding: ActivityDetailPanduanBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_detail_panduan)
binding = ActivityDetailPanduanBinding.inflate(layoutInflater)
setContentView(binding.root)
val gambar_panduan= intent.getIntExtra("gambar_panduan",0)
val nama_panduan = intent.getStringExtra("nama_panduan")
val deskripsi_panduan = intent.getStringExtra("deskripsi_panduan")
binding.gambarPanduan.setImageResource(gambar_panduan)
binding.namaPanduan.text = nama_panduan
binding.deskripsiPanduan.text = deskripsi_panduan
binding.icArrowBack.setOnClickListener {
finish()
}
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/DetailPanduanActivity.kt | 2956816125 |
package il.massive.gea_rent.ui.panduan
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import il.massive.gea_rent.R
import il.massive.gea_rent.adapter.PanduanAdapter
import il.massive.gea_rent.adapter.TokoAdapter
import il.massive.gea_rent.data.panduan.DataPanduan
import il.massive.gea_rent.data.toko.DataToko
import il.massive.gea_rent.databinding.FragmentBerandaBinding
import il.massive.gea_rent.databinding.FragmentPanduanBinding
import il.massive.gea_rent.model.BarangModel
import il.massive.gea_rent.model.PanduanModel
import il.massive.gea_rent.ui.DetailPanduanActivity
import il.massive.gea_rent.ui.PanduanKompasActivity
import il.massive.gea_rent.ui.PanduanKomporActivity
import il.massive.gea_rent.ui.PanduanSleepingBagActivity
import il.massive.gea_rent.ui.PanduanTendaActivity
import il.massive.gea_rent.ui.PanduanWaterActivity
class PanduanFragment : Fragment() {
private var _binding: FragmentPanduanBinding? = null
private val binding get() = _binding!!
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentPanduanBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// Set layout manager for RecyclerView
binding.rvPanduan.layoutManager = LinearLayoutManager(requireContext(),
LinearLayoutManager.VERTICAL, false)
// Set adapter for RecyclerView
binding.rvPanduan.adapter = panduanAdapter
}
private val panduanAdapter by lazy {
val items = DataPanduan.dummyDataPanduan
PanduanAdapter(items, object: PanduanAdapter.onAdapterListener{
override fun onClick(panduan: PanduanModel) {
if (panduan.judul=="Panduan Penggunaan Kompor Portable"){
startActivity(Intent(requireContext(),PanduanKomporActivity::class.java))
}
if (panduan.judul=="Panduan Mendirikan Tenda Dome"){
startActivity(Intent(requireContext(),PanduanTendaActivity::class.java))
}
if (panduan.judul=="Panduan Penggunaan Sleeping Bag yang Benar"){
startActivity(Intent(requireContext(), PanduanSleepingBagActivity::class.java))
}
if (panduan.judul=="Panduan Memakai Water Bladder dengan Hydropack"){
startActivity(Intent(requireContext(), PanduanWaterActivity::class.java))
}
if (panduan.judul=="Panduan Penggunaan Kompas yang Benar"){
startActivity(Intent(requireContext(), PanduanKompasActivity::class.java))
}
}
})
}
private fun openDetailPanduan(panduan: PanduanModel) {
val intent = Intent(requireContext(), DetailPanduanActivity::class.java)
intent.putExtra("gambar_panduan", panduan.gambar)
intent.putExtra("nama_panduan", panduan.judul)
intent.putExtra("deskripsi_panduan", panduan.deskripsi)
startActivity(intent)
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/PanduanFragment.kt | 3115285663 |
package il.massive.gea_rent.ui
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import il.massive.gea_rent.R
import il.massive.gea_rent.databinding.ActivityLoginBinding
import il.massive.gea_rent.databinding.ActivityOnBoardingBinding
class LoginActivity : AppCompatActivity() {
private lateinit var binding : ActivityLoginBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityLoginBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.btnLogin.setOnClickListener {
startActivity(Intent(this@LoginActivity, MainActivity::class.java))
}
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/LoginActivity.kt | 4275907194 |
package il.massive.gea_rent.ui
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.ImageButton
import android.widget.Toast
import il.massive.gea_rent.R
class PanduanWaterActivity : AppCompatActivity(), View.OnClickListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_panduan_water)
val btnPanduan: ImageButton = findViewById(R.id.back_panduan4)
btnPanduan.setOnClickListener(this)
}
override fun onClick(v: View?) {
when(v?.id){
R.id.back_panduan4-> {
Toast.makeText(this@PanduanWaterActivity,"Kembali", Toast.LENGTH_LONG).show()
finish()
}
}
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/PanduanWaterActivity.kt | 803737075 |
package il.massive.gea_rent.ui
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageButton
import il.massive.gea_rent.R
import il.massive.gea_rent.databinding.FragmentProfileBinding
class ProfileFragment : Fragment() {
private lateinit var binding: FragmentProfileBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
// Inflate the layout for this fragment
binding = FragmentProfileBinding.inflate(inflater, container, false)
val view = binding.root
// Find the button by ID
val btnbukatoko: ImageButton = view.findViewById(R.id.bukatoko)
// val btntokosaya: ImageButton = view.findViewById(R.id.tokosaya)
// Set an OnClickListener for the button
btnbukatoko.setOnClickListener {
val intent = Intent(activity, DaftarTokoActivity::class.java)
startActivity(intent)
}
// btntokosaya.setOnClickListener {
// val intent = Intent(activity, TokoSayaActivity::class.java)
// startActivity(intent)
// }
return view
}
}
| gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/ProfileFragment.kt | 2815332400 |
package il.massive.gea_rent.ui
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.ImageButton
import il.massive.gea_rent.R
class TambahProdukActivity : AppCompatActivity(), View.OnClickListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_tambah_produk)
val btnSimpanProduk: Button = findViewById(R.id.simpan_produk)
btnSimpanProduk.setOnClickListener(this)
val btnBackToko:ImageButton = findViewById(R.id.backTokoSaya)
btnBackToko.setOnClickListener(this)
}
override fun onClick(v: View?) {
when(v?.id){
R.id.simpan_produk-> {
val intent = Intent(this@TambahProdukActivity, TokoSayaActivity::class.java)
startActivity(intent)
}
R.id.backTokoSaya-> {
val intent = Intent(this@TambahProdukActivity, TokoSayaActivity::class.java)
startActivity(intent)
}
}
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/TambahProdukActivity.kt | 2066958814 |
package il.massive.gea_rent.ui
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.ImageButton
import android.widget.Toast
import il.massive.gea_rent.R
class PanduanTendaActivity : AppCompatActivity(), View.OnClickListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_panduan_tenda)
val btnPanduan: ImageButton = findViewById(R.id.back_panduan2)
btnPanduan.setOnClickListener(this)
}
override fun onClick(v: View?) {
when(v?.id){
R.id.back_panduan2-> {
Toast.makeText(this@PanduanTendaActivity,"Kembali", Toast.LENGTH_LONG).show()
finish()
}
}
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/PanduanTendaActivity.kt | 161234776 |
package il.massive.gea_rent.adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import il.massive.gea_rent.R
import il.massive.gea_rent.model.BarangModel
import il.massive.gea_rent.model.PanduanModel
class PanduanAdapter(
val panduan: List<PanduanModel>,
val listener: PanduanAdapter.onAdapterListener
): RecyclerView.Adapter<PanduanAdapter.ViewHolder>(){
class ViewHolder(val view: View):RecyclerView.ViewHolder(view){
val iv_panduan = view.findViewById<ImageView>(R.id.iv_panduan)
val judul_panduan = view.findViewById<TextView>(R.id.judul_panduan)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return PanduanAdapter.ViewHolder(
LayoutInflater.from(parent.context).inflate(R.layout.panduan_item, parent, false)
)
}
override fun getItemCount() = panduan.size
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val panduan = panduan[position]
holder.iv_panduan.setImageResource(panduan.gambar)
holder.judul_panduan.text = panduan.judul
holder.itemView.setOnClickListener{
listener.onClick(panduan)
}
}
interface onAdapterListener{
fun onClick(result:PanduanModel)
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/adapter/PanduanAdapter.kt | 210516073 |
package il.massive.gea_rent.adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import il.massive.gea_rent.R
import il.massive.gea_rent.model.TokoModel
class TokoTerdekatAdapter(
val tokos: List<TokoModel>,
val listener: OnAdapterListener
): RecyclerView.Adapter<TokoTerdekatAdapter.ViewHolder>() {
class ViewHolder(val view: View):RecyclerView.ViewHolder(view){
val image = view.findViewById<ImageView>(R.id.iv_profile_toko_terdekat)
val nama = view.findViewById<TextView>(R.id.nama_toko_terdekat)
val alamat = view.findViewById<TextView>(R.id.alamat_toko_terdekat)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(
LayoutInflater.from(parent.context).inflate(R.layout.toko_terdekat, parent, false)
)
}
override fun getItemCount() = tokos.size
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val toko = tokos[position]
holder.image.setImageResource(toko.image)
holder.nama.text = toko.nama
holder.alamat.text = toko.alamat
holder.itemView.setOnClickListener{
listener.onClick(toko)
}
}
interface OnAdapterListener{
fun onClick(result: TokoModel)
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/adapter/TokoTerdekatAdapter.kt | 521630323 |
package il.massive.gea_rent.adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import il.massive.gea_rent.R
import il.massive.gea_rent.model.BarangModel
class LayananAdapter(
val barangs: List<BarangModel>,
val listener: LayananAdapter.onAdapterListener
): RecyclerView.Adapter<LayananAdapter.ViewHolder>() {
class ViewHolder(val view: View):RecyclerView.ViewHolder(view){
val image = view.findViewById<ImageView>(R.id.iv_produk)
val nama = view.findViewById<TextView>(R.id.nama_produk)
val stok = view.findViewById<TextView>(R.id.jumlah_produk)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(
LayoutInflater.from(parent.context).inflate(R.layout.layanan_toko, parent, false)
)
}
override fun getItemCount() = barangs.size
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val barang = barangs[position]
holder.image.setImageResource(barang.gambar)
holder.nama.text = barang.nama
holder.stok.text = barang.stok.toString()
holder.itemView.setOnClickListener{
listener.onClick(barang)
}
}
interface onAdapterListener{
fun onClick(result: BarangModel)
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/adapter/LayananAdapter.kt | 86921364 |
package il.massive.gea_rent.adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import il.massive.gea_rent.R
import il.massive.gea_rent.data.toko.DataToko
import il.massive.gea_rent.model.BarangModel
import il.massive.gea_rent.model.TokoModel
class BarangAdapter(
val barangs: List<BarangModel>,
val listener: BarangAdapter.onAdapterListener
): RecyclerView.Adapter<BarangAdapter.ViewHolder>() {
class ViewHolder(val view: View):RecyclerView.ViewHolder(view){
val image = view.findViewById<ImageView>(R.id.iv_barang)
val nama = view.findViewById<TextView>(R.id.tv_nama_barang)
val harga = view.findViewById<TextView>(R.id.tv_harga_barang)
val stok = view.findViewById<TextView>(R.id.tv_jumlah_stok_barang)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(
LayoutInflater.from(parent.context).inflate(R.layout.barang_terlengkap_adapter, parent, false)
)
}
override fun getItemCount() = barangs.size
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val barang = barangs[position]
holder.image.setImageResource(barang.gambar)
holder.nama.text = barang.nama
holder.harga.text = barang.harga.toString().plus(" /hari")
holder.stok.text = barang.stok.toString()
holder.stok.text = barang.stok.toString()
holder.itemView.setOnClickListener{
listener.onClick(barang)
}
}
interface onAdapterListener{
fun onClick(barang: BarangModel)
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/adapter/BarangAdapter.kt | 1742575627 |
package il.massive.gea_rent.adapter
import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import il.massive.gea_rent.databinding.TokoItemBinding
import il.massive.gea_rent.ui.ProdukSewaActivity
import il.massive.gea_rent.model.TokoSayaModel
class TokoSayaAdapter(private val list: List<TokoSayaModel>, private val context:Context) :
RecyclerView.Adapter<TokoSayaAdapter.ViewHolder>() {
class ViewHolder(val binding: TokoItemBinding) : RecyclerView.ViewHolder(binding.root)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val binding = TokoItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return ViewHolder(binding)
}
override fun getItemCount(): Int = list.size
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
with(holder){
with(list[position]){
binding.imagealat.setImageResource(this.image)
binding.judulalat.text = this.judul
binding.tersedia.text = this.tersedia
binding.hargaalat.text = this.harga
}
}
holder.itemView.setOnClickListener {
val context = holder.itemView.context
val intent = Intent(context, ProdukSewaActivity::class.java)
// Anda dapat menambahkan data tambahan ke intent jika diperlukan
intent.putExtra("judul", list[position].judul)
intent.putExtra("tersedia", list[position].tersedia)
intent.putExtra("harga", list[position].harga)
context.startActivity(intent)
}
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/adapter/TokoSayaAdapter.kt | 2702974280 |
package il.massive.gea_rent.adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import il.massive.gea_rent.R
import il.massive.gea_rent.data.toko.DataToko
import il.massive.gea_rent.model.TokoModel
class TokoAdapter(
val tokos: List<TokoModel>,
val listener: onAdapterListener
): RecyclerView.Adapter<TokoAdapter.ViewHolder>() {
class ViewHolder(val view: View):RecyclerView.ViewHolder(view){
val image = view.findViewById<ImageView>(R.id.iv_toko)
val nama = view.findViewById<TextView>(R.id.tv_nama_toko)
val alamat = view.findViewById<TextView>(R.id.tv_alamat_toko)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(
LayoutInflater.from(parent.context).inflate(R.layout.toko_adapter, parent, false)
)
}
override fun getItemCount() = tokos.size
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val toko = tokos[position]
holder.image.setImageResource(toko.image)
holder.nama.text = toko.nama
holder.alamat.text = toko.alamat
holder.itemView.setOnClickListener{
listener.onClick(toko)
}
}
interface onAdapterListener{
fun onClick(result: TokoModel)
}
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/adapter/TokoAdapter.kt | 2639222600 |
package il.massive.gea_rent.model
import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
@Parcelize
data class TokoModel(
val image: Int,
val nama: String,
val alamat: String,
val telpon: String
):Parcelable
| gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/model/TokoModel.kt | 3260100832 |
package il.massive.gea_rent.model
data class PanduanModel(
val judul: String,
val deskripsi: String,
val url: String,
val gambar: Int
) | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/model/PanduanModel.kt | 1744876565 |
package il.massive.gea_rent.model
data class TokoSayaModel(
val image : Int,
val judul : String,
val tersedia : String,
val harga : String
)
| gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/model/TokoSayaModel.kt | 4292822140 |
package il.massive.gea_rent.model
data class BarangModel(
val toko: TokoModel,
val nama: String,
val deskripsi: String,
val harga: Int,
val stok: Int,
val gambar: Int,
val skor: Int
)
| gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/model/BarangModel.kt | 2273766160 |
package il.massive.gea_rent.data.toko
import il.massive.gea_rent.R
import il.massive.gea_rent.model.TokoModel
object DataToko {
val dummyTokoData = listOf<TokoModel>(
TokoModel(
R.drawable.toko1_1,
"Green Campus Outdoor",
"Jln. Jabaru I No.13",
"628979276362"
),
TokoModel(
R.drawable.toko2_1,
"Pandu Adventure Camp",
"Jln. Raya Puncak Bogor",
"6285882175993"
),
TokoModel(
R.drawable.toko3,
"Bandakala Rental",
"Jln. Raya Kemang Baru",
"628979276362"
),
TokoModel(
R.drawable.toko4,
"Green Campus Outdoor",
"Jln. Raya Dago, Bandung",
"6285882175993"
),
TokoModel(
R.drawable.toko5,
"Green Campus Outdoor",
"Jln. Puspitek, Gunung Sindur",
"6285882175993"
),
TokoModel(
R.drawable.toko6,
"Green Campus Outdoor",
"Jln. Raya Parungpanjang",
"6285882175993"
),
)
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/data/toko/TokoData.kt | 3232527349 |
package il.massive.gea_rent.data.barang
import il.massive.gea_rent.R
import il.massive.gea_rent.data.toko.DataToko
import il.massive.gea_rent.model.BarangModel
object DataBarang {
val dummyDataBarang = listOf<BarangModel>(
BarangModel(
DataToko.dummyTokoData[0],
"Sepatu Gunung",
"Desain yang modern dengan berbagai ukuran yang tersedia. Cocok untuk berbagai kegiatan outdoor, dari hiking hingga camping.",
80000,
2,
R.drawable.sepatu,
R.drawable.skor_barang1
),
BarangModel(
DataToko.dummyTokoData[1],
"Kompor Portable",
"Desain yang modern dengan berbagai ukuran yang tersedia. Cocok untuk berbagai kegiatan outdoor, dari hiking hingga camping.",
50000,
7,
R.drawable.produk2,
R.drawable.skor_barang_2
),
BarangModel(
DataToko.dummyTokoData[2],
"Terpal",
"Terpal ukuran 4 x 5, cocok untuk dijadikan alas dalam berkemah agar pakaian dan alat tetap bersih",
80000,
2,
R.drawable.terpal,
R.drawable.skor_barang1
),
BarangModel(
DataToko.dummyTokoData[3],
"Tenda Dome",
"Tenda Dome ukuran besar dapat menampun 4-5 orang",
50000,
7,
R.drawable.tenda_dome,
R.drawable.skor_barang_2
),
BarangModel(
DataToko.dummyTokoData[4],
"Sleeping Bad",
"Slepeping Bad ukuran besar, dengan bahas yang halus dan tebal",
80000,
2,
R.drawable.sleeping_bad,
R.drawable.skor_barang1
),
BarangModel(
DataToko.dummyTokoData[5],
"Kompor Portable",
"Desain yang modern dengan berbagai ukuran yang tersedia. Cocok untuk berbagai kegiatan outdoor, dari hiking hingga camping.",
50000,
7,
R.drawable.produk2,
R.drawable.skor_barang_2
),
BarangModel(
DataToko.dummyTokoData[3],
"Sepatu Gunung",
"Desain yang modern dengan berbagai ukuran yang tersedia. Cocok untuk berbagai kegiatan outdoor, dari hiking hingga camping.",
80000,
2,
R.drawable.sepatu,
R.drawable.skor_barang1
),
BarangModel(
DataToko.dummyTokoData[2],
"Kompor Portable",
"Desain yang modern dengan berbagai ukuran yang tersedia. Cocok untuk berbagai kegiatan outdoor, dari hiking hingga camping.",
50000,
7,
R.drawable.produk2,
R.drawable.skor_barang_2
),
)
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/data/barang/DataBarang.kt | 3968205995 |
package il.massive.gea_rent.data.panduan
import il.massive.gea_rent.R
import il.massive.gea_rent.model.PanduanModel
import il.massive.gea_rent.model.TokoModel
object DataPanduan {
val dummyDataPanduan = listOf<PanduanModel>(
PanduanModel("Panduan Penggunaan Kompor Portable",
"Penggunaan kompor portable kini sangat luas untuk berbagai keperluan memasak, Berikut ini adalah Tutorial cara memasang kompor portable yang mudah, aman, praktis dibawa kemana saja",
"https://youtu.be/FtlufGzJ53E?si=V8a3BSkhScSz2Lz7", R.drawable.img_alat1),
PanduanModel("Panduan Mendirikan Tenda Dome",
"Sebagai salah satu perlakuan & pemeliharaan agar umur penggunaan tenda anda menjadi lebih lama dan awet. Berikut tutorial cara pasang tenda camping kapasitas 4 orang ",
"https://youtu.be/eR8EpwTOfNc?si=AfPqk7STXjdapU3A", R.drawable.img_alat2),
PanduanModel("Panduan Penggunaan Sleeping Bag yang Benar",
"Sebagai salah satu perlakuan & pemeliharaan agar umur penggunaan sleeping bed anda menjadi lebih lama dan awet. Bisa simak video berikut cara membuka dan penggunaan sleeping bed ",
"https://youtu.be/M1Rnzu-4g64?si=7MfY-O77iyduq36T", R.drawable.img_alat3),
PanduanModel("Panduan Memakai Water Bladder dengan Hydropack",
"Penggunaan water bladder dengan mudah sebagai berikut",
"https://youtu.be/zcQxoM3gRcw?si=4rcnhH39pQ7tYoW-", R.drawable.img_alat4),
PanduanModel("Panduan Penggunaan Kompas yang Benar",
"Penggunaan kompas dengan mudah sebagai berikut",
"https://kumparan.com/tips-dan-trik/cara-menggunakan-kompas-sebagai-penunjuk-arah-20dkkS2k0c8/full", R.drawable.img_alat5),
)
} | gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/data/panduan/DataPanduan.kt | 1039063931 |
package com.example.kusitms_29th_hackathon_front
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.kusitms_29th_hackathon_front", appContext.packageName)
}
} | fronted/app/src/androidTest/java/com/example/kusitms_29th_hackathon_front/ExampleInstrumentedTest.kt | 3706660958 |
package com.example.kusitms_29th_hackathon_front
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)
}
} | fronted/app/src/test/java/com/example/kusitms_29th_hackathon_front/ExampleUnitTest.kt | 596863709 |
package com.example.kusitms_29th_hackathon_front.login_api
import com.google.gson.annotations.SerializedName
data class Result(
@SerializedName("userId")
val userId: Int
) | fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/login_api/Result.kt | 3608228071 |
package com.example.kusitms_29th_hackathon_front.login_api
import okhttp3.OkHttpClient
import okhttp3.Request
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
object RetrofitClient {
private const val BASE_URL = "http://3.37.99.87"
private val retrofit: Retrofit by lazy {
val client = OkHttpClient.Builder()
.addInterceptor { chain ->
val originalRequest: Request = chain.request()
val requestWithHeaders: Request = originalRequest.newBuilder()
.build()
chain.proceed(requestWithHeaders)
}
.build()
Retrofit.Builder()
.baseUrl(BASE_URL)
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build()
}
val login: LoginItf by lazy {
retrofit.create(LoginItf::class.java)
}
} | fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/login_api/RetrofitClient.kt | 2924285540 |
package com.example.kusitms_29th_hackathon_front.login_api
import retrofit2.Call
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.POST
interface LoginItf {
// ํ์๊ฐ์
@POST("/oauth/KAKAO")
fun postSignUp(
@Header("OAuth-AccessToken") authorization: String
): Call<Void>
// ๋ก๊ทธ์ธ ์ ๋ณด ํ์ธ
@GET("/oauth/KAKAO")
fun getLogIn(
@Header("OAuth-AccessToken") accessToken: String
): Call<getLogInResponse>
} | fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/login_api/LoginItf.kt | 497285830 |
package com.example.kusitms_29th_hackathon_front.login_api
data class getLogInResponse(
val code: Int,
val message: String,
val result: ResultX,
val status: Int
) | fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/login_api/getLogInResponse.kt | 3386030183 |
package com.example.kusitms_29th_hackathon_front.login_api
data class ResultX(
val accessToken: String,
val isUser: Boolean
) | fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/login_api/ResultX.kt | 3249550459 |
package com.example.kusitms_29th_hackathon_front.login_api
import com.google.gson.annotations.SerializedName
data class SignUpResponse(
@SerializedName("code")
val code: Int,
@SerializedName("message")
val message: String,
@SerializedName("result")
val result: Result,
@SerializedName("status")
val status: Int
) | fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/login_api/SignUpResponse.kt | 1154328316 |
package com.example.kusitms_29th_hackathon_front
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View
import com.example.kusitms_29th_hackathon_front.databinding.ActivityMainBinding
import com.example.kusitms_29th_hackathon_front.mining.Mining1Activity
import com.example.kusitms_29th_hackathon_front.mining.MiningDetailActivity
import com.example.kusitms_29th_hackathon_front.mining.MiningDoneActivity
class MainActivity : AppCompatActivity() {
lateinit var binding: ActivityMainBinding
var new: Int ?= -1
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.startBtn.setOnClickListener {
val intent = Intent(this, Mining1Activity::class.java)
startActivity(intent)
}
binding.myBtn.setOnClickListener {
val intent = Intent(this, MyPageActivity::class.java)
startActivity(intent)
}
new = intent.getIntExtra("new", -1)
Log.d("my log", ""+new)
if(new == 1) {
binding.done.visibility == View.VISIBLE
} else {
binding.done.visibility == View.GONE
}
binding.done.setOnClickListener {
val intent = Intent(this, MiningDetailActivity::class.java)
intent.putExtra("done", 1)
startActivity(intent)
}
}
} | fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/MainActivity.kt | 3267438635 |
package com.example.kusitms_29th_hackathon_front.mining
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import com.example.kusitms_29th_hackathon_front.databinding.ActivityMiningDoneBinding
class MiningDoneActivity : AppCompatActivity() {
lateinit var binding: ActivityMiningDoneBinding
private val handler = Handler()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMiningDoneBinding.inflate(layoutInflater)
setContentView(binding.root)
// 2์ด ํ์ Mining3Activity๋ก ์ด๋
handler.postDelayed({
val intent = Intent(this, Mining3Activity::class.java)
startActivity(intent)
finish()
}, 2000)
binding.closeBtn.setOnClickListener {
finish()
}
}
override fun onDestroy() {
// Activity๊ฐ ์๋ฉธ๋ ๋ Handler์ ์์
์ ์ทจ์ํ์ฌ ๋ฉ๋ชจ๋ฆฌ ๋์๋ฅผ ๋ฐฉ์ง
handler.removeCallbacksAndMessages(null)
super.onDestroy()
}
} | fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/mining/MiningDoneActivity.kt | 463076683 |
package com.example.kusitms_29th_hackathon_front.mining
import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.util.Log
import android.view.inputmethod.InputMethodManager
import com.example.kusitms_29th_hackathon_front.R
import com.example.kusitms_29th_hackathon_front.api_server.AddMiningManager
import com.example.kusitms_29th_hackathon_front.databinding.ActivityMining2Binding
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
class Mining2Activity : AppCompatActivity() {
lateinit var binding: ActivityMining2Binding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMining2Binding.inflate(layoutInflater)
setContentView(binding.root)
// Mining1Activity๋ก๋ถํฐ ์ ๋ฌ๋ฐ์ ๋ฐ์ดํฐ ์ถ์ถ
val question = intent.getStringExtra("question")
val miningId = intent.getIntExtra("miningId", 0) // miningId๊ฐ Int ํ์
์ด๋ฏ๋ก ๋ํดํธ ๊ฐ์ผ๋ก 0 ์ค์
Log.d("my log", "2์กํฐ๋นํฐ"+question+miningId)
binding.question.setText(question)
// EditText์ TextWatcher ์ถ๊ฐ
binding.content.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
override fun afterTextChanged(s: Editable?) {
// EditText์ ํ
์คํธ๊ฐ ๋ณ๊ฒฝ๋ ๋๋ง๋ค ํธ์ถ๋๋ฉฐ, ํ
์คํธ์ ๊ธธ์ด๋ฅผ ํ์ธํ์ฌ ๋ฒํผ ํ์ฑํ ์ฌ๋ถ ๊ฒฐ์
val text = s.toString()
binding.nextBtn.isEnabled = text.isNotEmpty()
if (text.isNotEmpty()) {
// ํ
์คํธ๊ฐ ์
๋ ฅ๋๋ฉด ๋ฒํผ ์์ ๋ฐ ํ
์คํธ ์์ ๋ณ๊ฒฝ
binding.nextBtn.setBackgroundResource(R.drawable.btn_primary)
binding.nextBtn.setTextColor(resources.getColor(R.color.gray20))
} else {
// ํ
์คํธ๊ฐ ์์ผ๋ฉด ๋ฒํผ ๋นํ์ฑํ
binding.nextBtn.setBackgroundResource(R.drawable.btn_gray)
binding.nextBtn.setTextColor(resources.getColor(R.color.gray60))
}
}
})
binding.nextBtn.setOnClickListener {
val answer = binding.content.text.toString()
Log.d("my log", ""+ answer)
AddMiningManager.addMiningService(miningId!!, answer!!, object : Callback<Void> {
override fun onResponse(call: Call<Void>, response: Response<Void>) {
if (response.isSuccessful) {
val mining = response.body()
mining?.let {
}
val intent = Intent(this@Mining2Activity, MiningDoneActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
startActivity(intent)
finish()
} else {
val errorBody = response.errorBody()?.string()
Log.e("์๋ฒ ํ
์คํธ", "์ค๋ฅ1: $errorBody")
}
}
override fun onFailure(call: Call<Void>, t: Throwable) {
Log.e("์๋ฒ ํ
์คํธ", "์ค๋ฅ2: ${t.message}")
}
})
}
binding.root.setOnClickListener {
// ํ๋ฉด์ ๋ค๋ฅธ ๋ถ๋ถ์ ํด๋ฆญํ๋ฉด EditText์ ํฌ์ปค์ค๋ฅผ ํด์ ํ๊ณ ํค๋ณด๋๋ฅผ ๋ด๋ฆผ
hideKeyboard()
}
binding.backBtn.setOnClickListener {
finish()
}
}
private fun hideKeyboard() {
binding.content.clearFocus()
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(binding.root.windowToken, 0)
}
} | fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/mining/Mining2Activity.kt | 3373841073 |
package com.example.kusitms_29th_hackathon_front.mining
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.example.kusitms_29th_hackathon_front.MainActivity
import com.example.kusitms_29th_hackathon_front.databinding.ActivityMining3Binding
class Mining3Activity : AppCompatActivity() {
lateinit var binding: ActivityMining3Binding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMining3Binding.inflate(layoutInflater)
setContentView(binding.root)
binding.backBtn.setOnClickListener {
finish()
}
binding.nextBtn.setOnClickListener {
// MainActivity๋ฅผ ์์ํ๊ณ , ์คํ์ ์์ธ ๋ชจ๋ ์กํฐ๋นํฐ๋ฅผ ์ข
๋ฃ
val intent = Intent(this, MainActivity::class.java)
intent.putExtra("new", 1)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
startActivity(intent)
finish()
}
binding.list.setOnClickListener {
val intent = Intent(this, MiningDetailActivity::class.java)
startActivity(intent)
}
}
} | fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/mining/Mining3Activity.kt | 2506973913 |
package com.example.kusitms_29th_hackathon_front.mining
import android.content.Context
import android.opengl.Visibility
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.View
import android.view.inputmethod.InputMethodManager
import com.example.kusitms_29th_hackathon_front.R
import com.example.kusitms_29th_hackathon_front.databinding.ActivityMiningDetailBinding
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.YouTubePlayer
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.YouTubePlayerCallback
class MiningDetailActivity : AppCompatActivity() {
lateinit var binding: ActivityMiningDetailBinding
var new: Int ?= -1
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMiningDetailBinding.inflate(layoutInflater)
setContentView(binding.root)
playYouTubeVideo("t9vBtX499pA")
binding.closeBtn.setOnClickListener {
finish()
}
new = intent.getIntExtra("done", -1)
if (new == 1) {
binding.content.visibility = View.GONE
}
// EditText์ TextWatcher ์ถ๊ฐ
binding.content.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
override fun afterTextChanged(s: Editable?) {
// EditText์ ํ
์คํธ๊ฐ ๋ณ๊ฒฝ๋ ๋๋ง๋ค ํธ์ถ๋๋ฉฐ, ํ
์คํธ์ ๊ธธ์ด๋ฅผ ํ์ธํ์ฌ ๋ฒํผ ํ์ฑํ ์ฌ๋ถ ๊ฒฐ์
val text = s.toString()
if (text.isNotEmpty()) {
// ํ
์คํธ๊ฐ ์
๋ ฅ๋๋ฉด ๋ฒํผ ์์ ๋ฐ ํ
์คํธ ์์ ๋ณ๊ฒฝ
binding.done.visibility = View.VISIBLE
} else {
// ํ
์คํธ๊ฐ ์์ผ๋ฉด ๋ฒํผ ๋นํ์ฑํ
binding.done.visibility = View.GONE
}
}
})
binding.done.setOnClickListener {
binding.layout.visibility = View.VISIBLE
// EditText์์ ์
๋ ฅ๋ ํ
์คํธ ๊ฐ์ ธ์ค๊ธฐ
val answerText = binding.content.text.toString()
// ๊ฐ์ ธ์จ ํ
์คํธ๋ฅผ answer ํ
์คํธ ๋ทฐ์ ์ค์ ํ๊ธฐ
binding.answer.text = answerText
// EditText์ ํฌ์ปค์ค ์ ๊ฑฐ
binding.content.clearFocus()
}
binding.root.setOnClickListener {
// ํ๋ฉด์ ๋ค๋ฅธ ๋ถ๋ถ์ ํด๋ฆญํ๋ฉด EditText์ ํฌ์ปค์ค๋ฅผ ํด์ ํ๊ณ ํค๋ณด๋๋ฅผ ๋ด๋ฆผ
hideKeyboard()
}
}
private fun playYouTubeVideo(videoId: String) {
binding.youtubePlayerView.visibility = View.VISIBLE
lifecycle.addObserver(binding.youtubePlayerView)
// YouTubePlayer๋ฅผ ์ด๊ธฐํํ์ฌ ๋์์ ์ฌ์
binding.youtubePlayerView.getYouTubePlayerWhenReady(object : YouTubePlayerCallback {
override fun onYouTubePlayer(youTubePlayer: YouTubePlayer) {
youTubePlayer.loadVideo(videoId, 0f)
}
})
}
private fun hideKeyboard() {
binding.content.clearFocus()
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(binding.root.windowToken, 0)
}
} | fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/mining/MiningDetailActivity.kt | 1418675263 |
package com.example.kusitms_29th_hackathon_front.mining
import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.util.Log
import android.view.View
import android.view.inputmethod.InputMethodManager
import androidx.core.content.ContextCompat.getSystemService
import com.example.kusitms_29th_hackathon_front.R
import com.example.kusitms_29th_hackathon_front.api_server.Mining
import com.example.kusitms_29th_hackathon_front.api_server.MiningManager
import com.example.kusitms_29th_hackathon_front.databinding.ActivityMining1Binding
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.YouTubePlayer
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.YouTubePlayerCallback
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import java.util.regex.Matcher
import java.util.regex.Pattern
class Mining1Activity : AppCompatActivity() {
lateinit var binding: ActivityMining1Binding
var videoId: String ?= null
var platformUrl: String ?= null
var question: String ?= null
var miningId: Int ?= null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMining1Binding.inflate(layoutInflater)
setContentView(binding.root)
// num ํ
์คํธ๋ทฐ์ 1๋ถํฐ 5๊น์ง์ ๋๋ค ์ซ์ ์ค์
val randomNumber = (1..5).random()
binding.num.text = randomNumber.toString()
// EditText์ TextWatcher ์ถ๊ฐ
binding.urlText.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
binding.youtubePlayerView.visibility = View.GONE
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
// ํ
์คํธ๊ฐ ๋ณ๊ฒฝ๋ ๋๋ง๋ค URL์์ videoId ์ถ์ถํ์ฌ ๋์์ ์ฌ์
videoId = extractVideoIdFromUrl(binding.urlText.text.toString())
platformUrl = binding.urlText.text.toString()
Log.d("my log", ""+videoId)
playYouTubeVideo(videoId!!)
}
override fun afterTextChanged(s: Editable?) {}
})
// YouTubePlayerView ์ด๊ธฐํ
lifecycle.addObserver(binding.youtubePlayerView)
// ์ด๊ธฐ ๋์์ ์ฌ์์ ์ํ ๋น videoId๋ก ์ฌ์ ์์
//playYouTubeVideo("")
binding.nextBtn.setOnClickListener {
Log.d("my log", ""+platformUrl)
MiningManager.miningService(platformUrl!!, object : Callback<Mining> {
override fun onResponse(call: Call<Mining>, response: Response<Mining>) {
if (response.isSuccessful) {
val mining = response.body()
mining?.let {
// ์๋ฒ์์ ๋ฐ์ ๋ฐ์ดํฐ ์ฒ๋ฆฌ
Log.d("Mining", "Question: ${mining.question}, Mining ID: ${mining.miningId}")
question = mining.question
miningId = mining.miningId
// ์๋ต์ ๋ฐ์ ํ์ Intent๋ฅผ ์์
val intent = Intent(this@Mining1Activity, Mining2Activity::class.java)
intent.putExtra("question", question)
intent.putExtra("miningId", miningId)
startActivity(intent)
}
} else {
val errorBody = response.errorBody()?.string()
Log.e("์๋ฒ ํ
์คํธ", "์ค๋ฅ1: $errorBody")
}
}
override fun onFailure(call: Call<Mining>, t: Throwable) {
Log.e("์๋ฒ ํ
์คํธ", "์ค๋ฅ2: ${t.message}")
}
})
// val intent = Intent(this, Mining2Activity::class.java)
// Log.d("my log", "1์กํฐ๋นํฐ"+question+miningId)
// intent.putExtra("question", question)
// intent.putExtra("miningId", miningId)
// startActivity(intent)
}
binding.root.setOnClickListener {
// ํ๋ฉด์ ๋ค๋ฅธ ๋ถ๋ถ์ ํด๋ฆญํ๋ฉด EditText์ ํฌ์ปค์ค๋ฅผ ํด์ ํ๊ณ ํค๋ณด๋๋ฅผ ๋ด๋ฆผ
hideKeyboard()
}
binding.closeBtn.setOnClickListener {
finish()
}
}
private fun playYouTubeVideo(videoId: String) {
binding.youtubePlayerView.visibility = View.VISIBLE
lifecycle.addObserver(binding.youtubePlayerView)
// YouTubePlayer๋ฅผ ์ด๊ธฐํํ์ฌ ๋์์ ์ฌ์
binding.youtubePlayerView.getYouTubePlayerWhenReady(object : YouTubePlayerCallback {
override fun onYouTubePlayer(youTubePlayer: YouTubePlayer) {
youTubePlayer.loadVideo(videoId, 0f)
binding.nextBtn.isEnabled = true // ์ ํ๋ธ ๋งํฌ๊ฐ ์ ํจํ ๊ฒฝ์ฐ ๋ฒํผ์ ํ์ฑํ
binding.nextBtn.setBackgroundResource(R.drawable.btn_primary) // ๋ฒํผ ์์ ๋ณ๊ฒฝ
binding.nextBtn.setTextColor(resources.getColor(R.color.gray20))
}
})
}
private fun extractVideoIdFromUrl(url: String): String {
val pattern = "(?<=\\/shorts\\/|watch\\?v=|\\/videos\\/|embed\\/|youtu.be\\/|\\/v\\/|\\/e\\/|watch\\?v%3D|watch\\?feature=player_embedded&v=|%2Fvideos%2F|embed%2Fvideos%2F|youtu.be%2F|watch\\?v=|embed\\?video_id=|&v=)([a-zA-Z0-9_-]{11})"
val compiledPattern: Pattern = Pattern.compile(pattern)
val matcher: Matcher = compiledPattern.matcher(url)
return if (matcher.find()) {
matcher.group()
} else {
""
}
}
private fun hideKeyboard() {
binding.urlText.clearFocus()
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(binding.root.windowToken, 0)
}
} | fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/mining/Mining1Activity.kt | 1288443697 |
package com.example.kusitms_29th_hackathon_front
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
class HomeMiningDetailActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home_mining_detail)
}
} | fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/HomeMiningDetailActivity.kt | 181908448 |
package com.example.kusitms_29th_hackathon_front.api_server
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.create
import java.text.SimpleDateFormat
import java.util.*
class MyApplication {
val retrofit = Retrofit.Builder()
.baseUrl("http://3.37.99.87") // ์๋ฒ URL
.addConverterFactory(GsonConverterFactory.create(getGson()))
.client(OkHttpClient.Builder().build())
.build()
fun getGson(): Gson {
val timeFormat = SimpleDateFormat("HH:mm:ss", Locale.getDefault()) // ์ํ๋ ์๊ฐ ํ์ ์ง์
return GsonBuilder()
.setDateFormat("yyyy-MM-dd") // Date ํ์ ์ง์
.create()
}
val authJoinService = retrofit.create(AuthJoinService::class.java)
val miningService = retrofit.create(MiningService::class.java)
val addMiningService = retrofit.create(AddMiningService::class.java)
} | fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/api_server/MyApplication.kt | 3195870916 |
package com.example.kusitms_29th_hackathon_front.api_server
import android.util.Log
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
object JoinManager {
fun sendJoinToServer(join: Join) {
val apiService = MyApplication().authJoinService
val call = apiService.sendAuthRequest(join)
call.enqueue(object : Callback<Void> {
override fun onResponse(call: Call<Void>, response: Response<Void>) {
if (response.isSuccessful) {
} else {
val errorBody = response.errorBody()?.string()
Log.e("์๋ฒ ํ
์คํธ", "์ค๋ฅ1: $errorBody")
}
}
override fun onFailure(call: Call<Void>, t: Throwable) {
Log.e("์๋ฒ ํ
์คํธ", "์ค๋ฅ2: ${t.message}")
}
})
}
}
object MiningManager {
fun miningService(platformUrl: String, callback: Callback<Mining>) {
val apiService = MyApplication().miningService
val call = apiService.sendMiningRequest(platformUrl)
call.enqueue(callback)
}
}
object AddMiningManager {
fun addMiningService(miningId: Int, answer: String, callback: Callback<Void>) {
val apiService = MyApplication().addMiningService
val call = apiService.addMiningRequest(miningId, answer)
call.enqueue(callback)
}
} | fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/api_server/ApiManager.kt | 2328839726 |
package com.example.kusitms_29th_hackathon_front.api_server
import retrofit2.Call
import retrofit2.http.*
interface AuthJoinService { // ํ์๊ฐ์
// "api ๊ฒฝ๋ก"
// ํจ์๋ช
(์๋ฒ์ ๋ณด๋ด๋ ๋ฐ์ดํฐ:Body ๋ณ์๋ช
: ๋ฐ์ดํฐํ์
): Call<์๋ฒ์ ๋ฐ์์ค๋ ๋ฐ์ดํฐ ํํ>
@POST("auth/join")
fun sendAuthRequest(@Body join: Join): Call<Void>
}
interface MiningService { // ์ง๋ฌธ ์์ฑ
@POST("/mining")
fun sendMiningRequest(@Body platformUrl: String): Call<Mining>
}
interface AddMiningService {
@PATCH("/mining/{miningId}")
fun addMiningRequest(@Path("miningId") miningId: Int,
@Body answer: String): Call<Void>
} | fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/api_server/ApiService.kt | 2967010565 |
package com.example.kusitms_29th_hackathon_front.api_server
data class User(
val userId: Int,
val username: String,
val identify: String,
val nickname: String,
val password: String,
val address: String,
val phoneNumber: String,
val image: String
)
data class Join(
val username: String,
val nickname: String,
val identify: String,
val address: String,
val password: String,
val phoneNumber: String
)
data class Mining(
val question: String,
val miningId: Int
)
| fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/api_server/DataModel.kt | 2422318574 |
package com.example.kusitms_29th_hackathon_front
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.example.kusitms_29th_hackathon_front.databinding.ActivityMainBinding
import com.example.kusitms_29th_hackathon_front.databinding.ActivityMyPageBinding
class MyPageActivity : AppCompatActivity() {
lateinit var binding: ActivityMyPageBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMyPageBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.backBtn.setOnClickListener {
finish()
}
}
} | fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/MyPageActivity.kt | 2740314526 |
package com.example.kusitms_29th_hackathon_front
import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import com.example.kusitms_29th_hackathon_front.BuildConfig.KAKAO_APP_KEY
import com.example.kusitms_29th_hackathon_front.databinding.ActivityLoginBinding
import com.example.kusitms_29th_hackathon_front.login_api.RetrofitClient
import com.example.kusitms_29th_hackathon_front.login_api.getLogInResponse
import com.google.gson.Gson
import com.kakao.sdk.auth.model.OAuthToken
import com.kakao.sdk.common.KakaoSdk
import com.kakao.sdk.common.util.Utility
import com.kakao.sdk.user.UserApiClient
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
class LoginActivity : AppCompatActivity() {
lateinit var binding: ActivityLoginBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityLoginBinding.inflate(layoutInflater)
setContentView(binding.root)
// ์ ์ฅ๋ ํ ํฐ ๊บผ๋ด๊ธฐ
val sharedPreferences = getSharedPreferences("my_token", Context.MODE_PRIVATE)
val accessToken = sharedPreferences.getString("access_token", null)
Log.d("my log", ""+accessToken)
KakaoSdk.init(this, "${KAKAO_APP_KEY}")
val callback: (OAuthToken?, Throwable?) -> Unit = { token, error ->
if (error != null) {
// ๋ก๊ทธ์ธ ์คํจ
Log.d("my log", "๋ก๊ทธ์ธ ์คํจ")
}
else if (token != null){
// ๋ก๊ทธ์ธ ์ฑ๊ณต
Log.d("my log", "๋ก๊ทธ์ธ ํ ํฐ ํ
์คํธ" + token.accessToken)
// ํ ํฐ ์ ์ฅ
val sharedPreferences = this.getSharedPreferences("my_token", Context.MODE_PRIVATE)
val editor = sharedPreferences.edit()
val gson = Gson()
val tokenJson = gson.toJson(token)
editor.putString("kakao_token", tokenJson) // ์นด์นด์ค ํ ํฐ ์ ์ฒด
editor.putString("access_token", token.accessToken) // ์ก์ธ์ค ํ ํฐ
editor.apply()
RetrofitClient.login.postSignUp("${token.accessToken}")
.enqueue(object : Callback<Void> {
override fun onResponse(call: Call<Void>, response: Response<Void>) {
if (response.isSuccessful) {
Log.d("์๋ฒ ํ
์คํธ", "์ฑ๊ณต")
val intent = Intent(this@LoginActivity, MainActivity::class.java)
startActivity(intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
finish()
} else {
val errorBody = response.errorBody()?.string()
Log.e("์๋ฒ ํ
์คํธ", "์ค๋ฅ1: $errorBody")
}
}
override fun onFailure(call: Call<Void>, t: Throwable) {
Log.e("์๋ฒ ํ
์คํธ", "์ค๋ฅ2: ${t.message}")
}
})
// RetrofitClient.login.getLogIn("Bearer ${token.accessToken}").enqueue(object :
// Callback<getLogInResponse> {
// override fun onResponse(call: Call<getLogInResponse>, response: Response<getLogInResponse>) {
// Log.d("์ก์ธ์ค ํ ํฐ", token.accessToken)
// if (response.isSuccessful) {
// val logInResponse = response.body()
// Log.d("์ฑ๊ณต",response.body().toString())
// if (logInResponse != null) {
// if (logInResponse.result.isUser) {
// val intent = Intent(this@LoginActivity, MainActivity::class.java)
// startActivity(intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
// finish()
// } else {
// // ๋ก๊ทธ์ธ ํ๋๋ฐ ํ์ ์ ๋ณด๊ฐ ์์ ๋ -> ํ์ ๊ฐ์
์ผ๋ก
// //val intent = Intent(this@LoginActivity, OnboardingActivity::class.java)
//// intent.putExtra("accessToken", logInResponse.result.accessToken)
//// startActivity(intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
//// finish()
// }
// }
// } else {
// // ๋ก๊ทธ์ธ ์คํจ
// val errorMessage = "์์ฒญ ์คํจ: ${response.code()} ${response.message()}"
// Log.e("API ์์ฒญ ์คํจ", errorMessage)
// // ์ถ๊ฐ ์ ๋ณด ์ถ๋ ฅ
// try {
// val errorBody = response.errorBody()?.string()
// Log.e("API ์๋ต ์๋ฌ", errorBody ?: "์๋ฌ ์๋ต ๋ณธ๋ฌธ์ด ์์ต๋๋ค.")
// } catch (e: Exception) {
// Log.e("API ์๋ต ์๋ฌ", "์๋ฌ ๋ณธ๋ฌธ์ ์ฝ๋ ์ค ์๋ฌ๊ฐ ๋ฐ์ํ์ต๋๋ค.")
// }
// }
// }
//
// override fun onFailure(call: Call<getLogInResponse>, t: Throwable) {
// // ๋คํธ์ํฌ ์ค๋ฅ ๋ฑ์ผ๋ก ์์ฒญ ์คํจ ์ฒ๋ฆฌ
// Log.e("๋ก๊ทธ์ธ ํธ์ถ ์คํจ", "์์ฒญ ์คํจ: ${t.message}", t)
// }
// })
}
}
binding.loginBtn.setOnClickListener {
if(UserApiClient.instance.isKakaoTalkLoginAvailable(this)){
UserApiClient.instance.loginWithKakaoTalk(this, callback = callback)
} else {
UserApiClient.instance.loginWithKakaoAccount(this, callback = callback)
}
}
}
} | fronted/app/src/main/java/com/example/kusitms_29th_hackathon_front/LoginActivity.kt | 2392389959 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.