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
@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
@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
@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
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); | |
// } |
OlderNewer