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
var findByTitle: (String) -> (MutableList<Movie>) -> List<Movie> = | |
{ query -> { collection -> | |
val predicate = matches(query) | |
filter(predicate)(collection) | |
}} | |
val filter: ((Movie) -> Boolean) -> (List<Movie>) -> List<Movie> = | |
{ predicate -> { collection -> | |
collection.filter(predicate) | |
}} |
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
val findByTitle = {query: String -> {collection: MutableList<Movie> -> | |
val predicate = matches(query) | |
filter(predicate)(collection) | |
}} | |
val filter = {predicate: (Movie) -> Boolean -> {collection: List<Movie> -> | |
collection.filter(predicate) | |
}} | |
val matches = {query: String -> { movie: Movie -> |
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 findByTitle(query: String, collection: MutableList<Movie>): List<Movie>{ | |
var results: MutableList<Movie> = mutableListOf() | |
do { | |
val movie = collection.removeAt(0) | |
if (movie.title.contains(query)){ | |
results.add(movie) | |
} | |
} |
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 SplashScreenActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
((AnimationDrawable) getWindow().getDecorView().getBackground()).start(); | |
// Launch main activity | |
... | |
} | |
} |
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
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="fr.jgl.animatedsplashscreen"> | |
... | |
<activity android:name=".SplashScreenActivity" android:theme="@style/SplashTheme"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity> |
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
<resources> | |
... | |
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar"> | |
<item name="android:windowBackground">@drawable/splash_animation</item> | |
</style> | |
... | |
</resources> |
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
<?xml version="1.0" encoding="utf-8"?> | |
<animation-list | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/splash_animation" android:oneshot="false"> | |
<item android:drawable="@drawable/blue_circle" android:duration="330" /> | |
<item android:drawable="@drawable/red_circle" android:duration="330" /> | |
<item android:drawable="@drawable/yellow_circle" android:duration="330" /> | |
<item android:drawable="@drawable/blue_circle" android:duration="330" /> | |
<item android:drawable="@drawable/green_circle" android:duration="330" /> | |
<item android:drawable="@drawable/red_circle" android:duration="330" /> |
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
/** | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
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 ObserverActivity extends Activity implements Observer{ | |
... | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
... | |
MyObservable myObservable = new MyObservable(); | |
// Registering of the observer (here the activity) | |
myObservable.addObserver(this); | |
// Changing the state of the observable | |
myObservable.setValue("Hello ! "); |
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 ReceiveFromServiceActivity extends AppCompatActivity { | |
// Message handler of the service | |
class ResponseHandler extends Handler { | |
@Override public void handleMessage(Message message) { | |
Toast.makeText(ReceiveFromServiceActivity.this, "message from service : " + message.getData().getString("message"), | |
Toast.LENGTH_SHORT).show(); | |
} | |
} | |
// Messenger toward the activity |
NewerOlder