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 Solution { | |
public int firstMissingPositive(int[] nums) { | |
// Solution 1 | |
// int result = 1; | |
// Map<Integer,Integer> map = new HashMap<Integer,Integer>(); | |
// for(int i = 0; i < nums.length; i++ ){ | |
// map.put(nums[i],i); | |
// } |
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
@Composable | |
fun AnnotatedString(modifier: Modifier = Modifier) { | |
// Define tags for expanded and minified text | |
val tagExpanded = "expanded_text" | |
val tagMinified = "minified_text" | |
// Maintain the state of text toggling (expanded or minified) | |
val textToggleState = remember { mutableStateOf(Pair(tagMinified, "Read more ...")) } | |
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
@OptIn(FlowPreview::class) | |
@Composable | |
fun LazyColumnPosition(modifier: Modifier = Modifier) { | |
val context = LocalContext.current | |
val pref by lazy { | |
context.getSharedPreferences("prefs", MODE_PRIVATE) | |
} | |
val scrollPosition = pref.getInt("scroll_position", 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
@OptIn(ExperimentalAnimationApi::class) | |
@Composable | |
fun AnimatedContentExample(modifier: Modifier = Modifier) { | |
var expanded by remember { | |
mutableStateOf(false) | |
} | |
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { | |
Card(modifier = Modifier.clickable { |
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 MainCoroutineRule : TestWatcher(){ | |
//TestWatcher is class which is use to make JUnit rule. | |
val testDispatcher = StandardTestDispatcher() | |
override fun starting(discription: Description?){ | |
super.starting(description) | |
Dispatchers.setMain(testDispatcher) | |
} | |
override fun finished(description: Description?){ |
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 QuoteManagerTest{ | |
@Mock | |
lateinit var context: Context | |
@Mock | |
lateinit var assertManager: AssertManager | |
@Before | |
fun setup(){ |
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
data class User( | |
val id:Int, | |
val name:String, | |
val email:String, | |
val password:String | |
) | |
enum class LOGIN_STATUS{ | |
INVALID_USER, | |
INVALID_PASSWORD, |
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
import androidx.lifecycle.LiveData | |
import androidx.lifecycle.Observer | |
import java.util.concurrent.CountDownLatch | |
import java.util.concurrent.TimeUnit | |
import java.util.concurrent.TimeoutException | |
fun <T> LiveData<T>.getOrAwaitValue( | |
time: Long = 2, | |
timeUnit: TimeUnit = TimeUnit.SECONDS, | |
afterObserve: () -> Unit = {} |
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 PasswordTest{ | |
@Test | |
fun `validatePassword blank input expected required field`(){ | |
val sut = Utils() | |
val result = sut.validatePassword(" ") | |
assertEquals("Password is required field", result) | |
} | |
@Test | |
fun `validatePassword 2CharInput expected validation Msg`(){ |
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
import android.content.Context | |
import androidx.test.core.app.ApplicationProvider | |
import com.google.gson.JsonSyntaxException | |
import org.junit.Assert.* | |
import org.junit.After | |
import org.junit.Before | |
import org.junit.Test | |
import java.io.FileNotFoundException |
NewerOlder