Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
initViewModel
infoRepository = InfoRepository()
val map = HashMap<String, ViewModel>()
map[InfoViewModel::class.java.simpleName] = InfoViewModel(infoRepository)
infoFactory = InfoFactory(map)
infoViewModel = ViewModelProviders.of(this, infoFactory).get(InfoViewModel::class.java)
InfoFactory
class InfoFactory(private var map : HashMap<String, ViewModel>) : ViewModelProvider.Factory {
Observable.fromIterable<MainActivity.Album>(getAlbum())
.flatMap<MainActivity.Song> {Observable.fromIterable<MainActivity.Song>(it.songs)}
.filter { it.songTime > 100}
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { it.songName }
implementation "io.reactivex.rxjava2:rxjava:2.2.9"
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
Observable.fromIterable(getAlbum())
.flatMap((Function<Album, ObservableSource<Song>>) album -> Observable.fromIterable(album.getSongs()))
.filter(song -> false)
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(s->System.out.println(s.getSongName()));
Observable.fromIterable(getAlbum())
.flatMap(new Function<Album, ObservableSource<Song>>() {
@Override
public ObservableSource<Song> apply(Album album) throws Exception {
return Observable.fromIterable(album.getSongs());
}
})
.filter(new Predicate<Song>() {
@Override
public boolean test(@NonNull Song song) throws Exception {
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("mailto:")) {
context.startActivity(new Intent(Intent.ACTION_SENDTO, Uri.parse(url)));
} else if(url.startsWith("http:")){
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}
view.reload();
return true;
@givemepassxd999
givemepassxd999 / givemepass
Created February 23, 2014 16:00
givemepass project
This is givemepass project