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
<?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" |
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
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 { |
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
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' |
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
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())); |
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
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 { |
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
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; |
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
This is givemepass project |