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
jar { | |
from { | |
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } | |
} | |
} | |
you may need this if you get errors | |
tasks.withType(Jar) { | |
duplicatesStrategy = DuplicatesStrategy.EXCLUDE | |
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 kotlinx.coroutines.Dispatchers | |
import kotlinx.coroutines.ExperimentalCoroutinesApi | |
import kotlinx.coroutines.test.TestCoroutineDispatcher | |
import kotlinx.coroutines.test.TestCoroutineScope | |
import kotlinx.coroutines.test.resetMain | |
import kotlinx.coroutines.test.setMain | |
import org.junit.rules.TestWatcher | |
import org.junit.runner.Description | |
/** |
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
@Suppress("UNCHECKED_CAST") | |
class TasksViewModelFactory (/*pass the pram you need*/ ) : ViewModelProvider.NewInstanceFactory() { | |
override fun <T : ViewModel> create(modelClass: Class<T>) = | |
(ViewModel(/*pass the pram to view model*/) as T) | |
} |
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 LocationActivity:AppCompatActivity() { | |
private val REQUEST_TURN_DEVICE_LOCATION_ON = 29 | |
private val TAG = this::class.java.simpleName | |
private fun checkDeviceLocationSettings(resolve:Boolean = true, context:AppCompatActivity) { | |
val locationRequest = LocationRequest.create().apply { | |
priority = LocationRequest.PRIORITY_HIGH_ACCURACY | |
} | |
val builder = LocationSettingsRequest.Builder().addLocationRequest(locationRequest) | |
val settingsClient = LocationServices.getSettingsClient(context) |
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
AsyncTask.execute(()->{ | |
try { | |
AdvertisingIdClient.Info idInfo = null; | |
idInfo = AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext()); | |
System.out.println(idInfo.getId()); | |
} catch (IOException | GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException e) { | |
e.printStackTrace(); | |
} | |
} | |
); |