This file contains hidden or 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"?> | |
<layout> | |
<data> | |
</data> | |
<androidx.constraintlayout.widget.ConstraintLayout 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" |
This file contains hidden or 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
def nav_version_ktx = "2.3.0-alpha01" | |
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version_ktx" | |
implementation "androidx.navigation:navigation-ui-ktx:$nav_version_ktx" | |
def material_version = "1.1.0" | |
implementation "com.google.android.material:material:$material_version" | |
def fragment_version = "1.2.2" | |
implementation "androidx.fragment:fragment-ktx:$fragment_version" |
This file contains hidden or 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
// Complete the maxInversions function below. | |
fun maxInversions(prices: Array<Int>): Long { | |
var inversionsCounter = 0L | |
val arraySize = prices.size | |
for (i in 0 until arraySize - 1) { | |
var smaller = 0 //smaller elements on right | |
for (j in i + 1 until arraySize) { | |
if (prices[i] > prices[j]) { | |
smaller++ |
This file contains hidden or 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 vanhack | |
import com.google.gson.Gson | |
import java.io.File | |
import java.io.InputStreamReader | |
import java.time.LocalDate | |
import java.time.Month | |
import java.time.format.DateTimeFormatter | |
import java.util.* |
This file contains hidden or 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
@RunWith(AndroidJUnit4ClassRunner::class) | |
class MyUITestWithIdlingResourcesRuleTest { | |
... //some variable def | |
@get:Rule | |
val activityRule = ActivityScenarioRule(MyMainActivity::class.java) | |
//this line replaces the registration/deregistration within @Before/@After methods | |
@get:Rule | |
val espressoIdlingResourceRule = MyEspressoIdlingResourceRule() | |
This file contains hidden or 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 MyEspressoIdlingResourceRule: TestWatcher() { | |
private val idlingResource = EspressoIdlingResource.countingIdlingResource | |
override fun starting(description: Description?) { | |
IdlingRegistry.getInstance().register(idlingResource) | |
super.starting(description) | |
} | |
override fun finished(description: Description?) { | |
IdlingRegistry.getInstance().unregister(idlingResource) |
This file contains hidden or 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
@RunWith(AndroidJUnit4ClassRunner::class) | |
class MyUITestWithIdlingResourcesTest { | |
... //some variable def | |
@get:Rule | |
val activityRule = ActivityScenarioRule(MyMainActivity::class.java) | |
@Before | |
fun setup() { | |
//register idling resource | |
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource) |
This file contains hidden or 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 int totalCallRequestCount = 0; | |
private int totalCallResponseCount = 0; | |
private void setupLiveDataMerger() { | |
processFinishedSuccessfullyLiveData = new MediatorLiveData<>(); | |
processFinishedSuccessfullyLiveData.addSource(userInfoLiveData, new Observer<Person>() { | |
@Override | |
public void onChanged(@Nullable Person person) { | |
totalCallResponseCount++; | |
setProcessFinishedSuccessfully(); |
This file contains hidden or 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
fun getTimes(times: Array<Int>, directions: Array<Int>): Array<Int> { | |
val result: Array<Int> = Array(times.size) { 0 } | |
val endTime: Int = times.max() ?: 0 | |
if (endTime == 0) return result | |
val inQueue: Queue<Int> = LinkedList() | |
val outQueue: Queue<Int> = LinkedList() | |
var currentIndex = 0 | |
var turnstile = 0 |
This file contains hidden or 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 MyAppFirebaseMessagingService : FirebaseMessagingService() { | |
override fun onMessageReceived(remoteMessage: RemoteMessage) { | |
//the logic here | |
} | |
override fun onNewToken(token: String) { | |
//all the logic of the old FirebaseInstanceIdService.onTokenRefresh() here | |
//usually, to send to the app server the instance ID token | |
sendTokenToTheAppServer(token) |