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
private fun reverseArr(array:ArrayList<Int>):ArrayList<Int>{ | |
val reversedArr:ArrayList<Int> = ArrayList() | |
reversedArr.addAll(array) | |
var initElementIdx = reversedArr.size | |
array.forEachIndexed { index, num -> | |
reversedArr[initElementIdx - 1] = num | |
initElementIdx -= 1 | |
} | |
return reversedArr | |
} |
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
package gad.samples.periodicworkmanager | |
import android.content.Context | |
import android.os.Bundle | |
import androidx.work.Constraints | |
import androidx.work.CoroutineWorker | |
import androidx.work.ExistingPeriodicWorkPolicy | |
import androidx.work.NetworkType | |
import androidx.work.PeriodicWorkRequest | |
import androidx.work.PeriodicWorkRequestBuilder |
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
object CalendarHelper { | |
const val ORGANIZER = "My App" | |
// Projection array. Creating indices for this array instead of doing | |
// dynamic lookups improves performance. | |
private val EVENT_PROJECTION: Array<String> = arrayOf( | |
Events.ORIGINAL_ID, // 0 | |
Events.TITLE, // 1 | |
Events.ALLOWED_REMINDERS, // 2 |
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"?> | |
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | |
<item android:id="@android:id/secondaryProgress"> | |
<shape | |
android:innerRadiusRatio="3" | |
android:shape="ring" | |
android:thicknessRatio="20.0" | |
android:useLevel="true"> |
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"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="70dp" | |
android:layout_height="wrap_content" | |
android:background="@android:color/white" | |
android:orientation="vertical" | |
android:layout_marginRight="10dp" | |
android:layout_marginLeft="10dp" |
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
<com.google.android.material.textfield.TextInputLayout | |
style="@style/TextInputLayoutStyle" | |
android:id="@+id/textInputLyt" | |
android:layout_width="match_parent" | |
android:layout_height="60dp" | |
android:elevation="2dp" | |
android:textColorHint="@color/color_b9b9b9" | |
android:textSize="@dimen/dimen_14f" | |
app:boxCornerRadiusBottomEnd="8dp" | |
app:boxCornerRadiusBottomStart="8dp" |
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
package mostafazsc.projects.exts | |
import androidx.paging.PagingData | |
import kotlinx.coroutines.flow.Flow | |
import kotlinx.coroutines.flow.single | |
@Suppress("UNCHECKED_CAST") | |
suspend fun <T : Any> PagingData<T>.toList(): List<T> { | |
val flow = PagingData::class.java.getDeclaredField("flow").apply { | |
isAccessible = true |
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
// implmentation | |
implementation "androidx.datastore:datastore-preferences:1.0.0-alpha01" | |
implementation "androidx.datastore:datastore-core:1.0.0-alpha01" | |
class DataStorePreferencesHelper constructor(context: Context) : DateStoreHelper { | |
private val applicationContext = context.applicationContext | |
private val dataStore: DataStore<Preferences> |
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 log_dump = | |
"name=Dan B, username=db, email=db@gmail.com, id=123; name=Hannah, username=hsmith, id=333, email=hsm@test.com; name=Dan Brick, username=db, email=db@gmail.com, id=663;" | |
val toTypedArray = log_dump.split(";").toTypedArray().filter { it.isNotEmpty() } | |
val filtered:ArrayList<String> = ArrayList() | |
for (item in toTypedArray) { | |
item.replace("${item.substringBefore(", id=").substringBefore(",")}", "") | |
Log.i("GadTest1", "$item") | |
} | |
toTypedArray?.forEachIndexed { index, data -> | |
if (index > 0){ |
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
import android.annotation.SuppressLint | |
import android.app.Activity | |
import android.location.Location | |
import android.os.Looper | |
import androidx.lifecycle.LifecycleOwner | |
import androidx.lifecycle.LiveData | |
import androidx.lifecycle.MutableLiveData | |
import com.google.android.gms.location.LocationCallback | |
import com.google.android.gms.location.LocationRequest | |
import com.google.android.gms.location.LocationResult |