This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* You can edit, run, and share this code. | |
* play.kotlinlang.org | |
*/ | |
fun main() { | |
val siswa1 = Siswa(Modules.nama) | |
val siswa2 = Siswa(Modules.module.get("nama"), Modules.module.get("kelas")) | |
println("siswa 1 nama: " + siswa1.nama) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with(tabCatalog) { | |
setupWithViewPager(vpCatalog) | |
val linearLayout = getChildAt(0) as LinearLayout | |
linearLayout.showDividers = LinearLayout.SHOW_DIVIDER_MIDDLE | |
val drawable = GradientDrawable() | |
drawable.setColor(ResourcesCompat.getColor(resources, R.color.black16, null)) | |
drawable.setSize(1, 1) | |
linearLayout.dividerPadding = 40 | |
linearLayout.dividerDrawable = drawable | |
requestLayout() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<androidx.coordinatorlayout.widget.CoordinatorLayout | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
app:layout_constraintBottom_toTopOf="@id/view_separator" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent"> | |
<com.google.android.material.appbar.AppBarLayout | |
android:id="@+id/appbar" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- android style --> | |
<resources> | |
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | |
<item name="bottomSheetDialogTheme">@style/BottomSheetTheme</item> | |
</style> | |
<style name="BottomSheetTheme" parent="Theme.MaterialComponents.Light.BottomSheetDialog"> | |
<item name="bottomSheetStyle">@style/BottomSheetModalStyle</item> | |
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<network-security-config> | |
<domain-config cleartextTrafficPermitted="true"> | |
<domain includeSubdomains="true">yoururl</domain> | |
</domain-config> | |
<base-config cleartextTrafficPermitted="true"> | |
<trust-anchors> | |
<certificates src="system" /> | |
</trust-anchors> | |
</base-config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android{ | |
..... | |
fun getString(key: String): String { | |
val items = mutableMapOf<String, String>() | |
val fl = rootProject.file("./kmm/kmm.properties") | |
(fl.exists())?.let { | |
fl.forEachLine { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserRepository @Inject constructor( | |
private val webservice: Webservice, | |
private val userDao: UserDao | |
) { | |
fun getUser(userId: String) = | |
object : NetworkBoundResource<User, User>() { | |
override suspend fun saveCallResult(item: User) { | |
userDao.save(item) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val outputDirectory = File(applicationContext.filesDir, OUTPUT_PATH) | |
if (outputDirectory.exists()) { | |
val entries = outputDirectory.listFiles() | |
if (entries != null) { | |
for (entry in entries) { | |
val name = entry.name | |
if (name.isNotEmpty() && name.endsWith(".png")) { | |
val deleted = entry.delete() | |
Timber.i("Deleted $name - $deleted") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NetworkDownload { | |
static let shared = NetworkDownload() | |
func download(url: String, result: @escaping (URL) -> Void, onProgress: ((Double) -> Void)? = nil) { | |
let fileName = url.components(separatedBy: "/").last ?? "File \(Date.currentDateTime())" | |
let destination: DownloadRequest.DownloadFileDestination = { _, _ in | |
let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! | |
let fileURL: URL = documentsURL.appendingPathComponent(fileName) | |
return (fileURL, [.removePreviousFile, .createIntermediateDirectories]) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DownloadManager(private val context: Context) { | |
fun download(url: String, fileName: String) { | |
try { | |
val uri = Uri.parse(url) | |
val downloadRequest = DownloadManager.Request(uri).apply { | |
val extension = MimeTypeMap.getFileExtensionFromUrl(url) | |
val name = "$fileName.$extension" | |
setTitle(name) | |
setAllowedOverMetered(true) | |
setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED) |
OlderNewer