Skip to content

Instantly share code, notes, and snippets.

View Kalaiz's full-sized avatar
🐢

Kalaiarasan Somasundaram Kalaiz

🐢
View GitHub Profile
@Kalaiz
Kalaiz / SO: Split list when predicate is true
Last active December 5, 2020 05:19
Split Kotlin List<String> using Delimiter Testing
/* https://stackoverflow.com/questions/65140871/split-list-when-predicate-is-true*/
/* First Way */
inline fun List<String>.splitWhenOne(predicate: (String)->Boolean):List<List<String>> {
val list = mutableListOf<MutableList<String>>()
var needNewList = false
forEach {
string->
if(!predicate(string)){
if(needNewList||list.isEmpty()){
list.add(mutableListOf(string))
@Kalaiz
Kalaiz / SO:Custom Tab layout with ViewPager2
Last active December 17, 2020 13:15
Simple Tab Layout XML Example
<?xml version="1.0" encoding="utf-8"?>
<--https://stackoverflow.com/questions/65078252/custom-tab-layout-with-viewpager2/65079234#65079234 -->
<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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">