Skip to content

Instantly share code, notes, and snippets.

View halilozel1903's full-sized avatar
🦅
The rest of the world was black and white 🖤 🤍

Halil Özel halilozel1903

🦅
The rest of the world was black and white 🖤 🤍
View GitHub Profile
fun main() {
val limit = 20
print("Prime numbers up to $limit: ")
for (i in 2..limit) {
if (isPrime(i)) {
print("$i ")
}
}
}
fun isLeapYear(year: Int?): Boolean {
return if (year != null) {
(year % 4 == 0) && (year % 100 != 0 || year % 400 == 0)
} else {
false
}
}
fun main() {
print("Enter favorite year: ")
val car = Car.makeCar(150)
println(Car.Factory.cars.size)
class Car(val horsepowers: Int) {
companion object Factory {
val cars = mutableListOf<Car>()
fun makeCar(horsepowers: Int): Car {
val car = Car(horsepowers)
cars.add(car)
return car
}
}
}
companion object {
private var instance: BusinessManager? = null
fun getInstance(): BusinessManager {
if (instance == null) {
instance = BusinessManager()
}
return instance as BusinessManager
}
String deviceId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
Toast.makeText(this, deviceId, Toast.LENGTH_LONG).show();
val deviceId: String = Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)
Toast.makeText(this, deviceId, Toast.LENGTH_LONG).show()
@halilozel1903
halilozel1903 / ExoPlayerMp4.kt
Created September 14, 2022 20:11
How to play .mp4 in ExoPlayer?
package com.halil.ozel.exoplayerdashsample
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.MediaItem
import com.google.android.exoplayer2.source.MediaSource
import com.google.android.exoplayer2.source.ProgressiveMediaSource
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource
import com.halil.ozel.exoplayerdashsample.databinding.ActivityMainBinding
@halilozel1903
halilozel1903 / ExoplayerMediaType.kt
Created September 14, 2022 19:46
How to check media type in ExoPlayer?
private fun checkMediaType() {
val type = when(Util.inferContentType(URL.toUri())){
C.CONTENT_TYPE_HLS -> {
println("Type HLS")
}
C.CONTENT_TYPE_DASH -> {
println("Type DAS")
}
C.CONTENT_TYPE_OTHER -> {
println("Type OTHER")