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
sealed class WidgetType { | |
data class SlideBar(val min: Int, val max: Int, val step: Int) : WidgetType() | |
data class Radio(val items: List<RadioItem>) : WidgetType() | |
} | |
data class RadioItem( | |
val name: String, | |
val value: Int | |
) |
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 Solution { | |
fun strStr(source: String, target: String): Int { | |
if (target.isEmpty()) { | |
return 0 | |
} | |
if(source == target) { | |
return 0 | |
} |
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
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout | |
android:id="@+id/refreshLayout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<WebView | |
android:id="@+id/web" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" /> |
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 MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
val fragment = MainFragment() | |
supportFragmentManager.beginTransaction() | |
.replace(R.id.container, fragment) | |
.commit() | |
} |
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
fun batchDebit(accounts: List<ADTAccount>, amount: Int): Try<List<ADTAccount>> { | |
val debitAccounts = accounts.map { debit(it, amount) } | |
val anyFail = debitAccounts.any { it is Fail } | |
return if (anyFail) { | |
Fail(IllegalArgumentException("Insufficient balance in account")) | |
} else { | |
Success(debitAccounts.map { (it as Success<ADTAccount>).value }) | |
} | |
} |
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
CustomDialog.create(context, { | |
titleRes { R.string.create_order } | |
positiveTextRes { R.string.confirm } | |
positiveClick { // do something } | |
negativeTextRes { R.string.cancel } | |
customView { view } | |
}) |
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
public class AnimatorActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(@Nullable Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_animator); | |
Button button = (Button) findViewById(R.id.button); | |
final View cube = findViewById(R.id.cube); |
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
public class AlarmActivity extends AppCompatActivity{ | |
@Override | |
protected void onCreate(@Nullable Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); | |
Calendar calendar = Calendar.getInstance(); | |
// 現在的 18:30:00 |
NewerOlder