Skip to content

Instantly share code, notes, and snippets.

@UtkuGlsvn
UtkuGlsvn / test.json
Last active August 16, 2023 16:16
test.json
{
"item": [
{
"name": "Create",
"request": {
"url": {
"raw": "{{base}}/user/reports/funnel-report-schedule/create?workspace_id=1&name=genel&period=1&property_id=261656317",
"query": [
{
"key": "workspace_id",
@UtkuGlsvn
UtkuGlsvn / Android multi permission function
Created August 2, 2023 18:10
Android multi permission function
private fun checkNotificationPermission(): Boolean {
val permissions = arrayOf(
Manifest.permission.POST_NOTIFICATIONS,
Manifest.permission.ACCESS_COARSE_LOCATION
)
val isAllPermissionsGranted = permissions.all {
this.checkSelfPermission(it) == PackageManager.PERMISSION_GRANTED
}
@UtkuGlsvn
UtkuGlsvn / HaftaiciTarih.js
Created May 30, 2022 21:32
Javascript Hafta İçi Tarihleri
<script language="JavaScript">
var now = new Date(); var yr = now.getYear(); var mName = now.getMonth() + 1; var dName = now.getDay()+2;
var dayNr = (((now.getDate())<10) ? "" : "")+ (now.getDate()+1);
if ( yr > 99 )
{
yr_str =" ";
if ( yr < 2000 ) yr += 1900;
}
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:gravity="center">
<shape android:shape="rectangle">
<size android:height="1dp" />
<solid android:color="@android:color/black" />
</shape>
</item>
private const val STORE_NAME = "data_store_pref"
private const val DARK_THEME = "is_dark_theme"
class DataStorePrefManager constructor(private val context: Context) {
companion object {
private val Context.dataStore by preferencesDataStore(STORE_NAME)
private val NIGHT_MODE_KEY = booleanPreferencesKey(DARK_THEME)
}
@UtkuGlsvn
UtkuGlsvn / GetPostRepository
Last active May 17, 2021 10:30
Benzinlitre Rest Service Retrofit
class Repository @Inject constructor(private val source: GetPostSource) {
suspend fun postRequest(paramsmap: HashMap<String, Any>) {
when (val result = source.executePostService(paramsmap)) {
is Resource.Success -> {
val resBody = gson.toJson(result.data.result)
val res = gson.fromJson(resBody, entity::class.java) // you entity class
//.....
}
is Resource.Error -> errorMessage.postValue(result.message)
binding.bottomNav.setOnNavigationItemSelectedListener {
if (!binding.bottomNav.menu.findItem(it.itemId).isChecked) navController.navigate(it.itemId)
true
}
class MyBillingImpl(private val activity: Activity) :
PurchasesUpdatedListener, ConsumeResponseListener, BillingProcessor.IBillingHandler {
var billingClient: BillingClient = BillingClient.newBuilder(activity)
.enablePendingPurchases()
.setListener(this)
.build()
private var list: MutableList<SkuDetails>? = null
init {
import UserNotifications
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
val clickListener = View.OnClickListener {view ->
when (view.getId()) {
R.id.textview -> firstFun()
R.id.button -> secondFun()
}
}