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
@Override | |
public void onActivityCreated( Bundle savedInstanceState ) { | |
super.onActivityCreated( savedInstanceState ); | |
mainActivity = (MainActivity) getActivity(); | |
buttonStart.setOnClickListener( new OnClickListener() { | |
@Override | |
public void onClick( View v ) { | |
onStart( v ); | |
} |
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
/* | |
* Copyright 2009 Michael Burton | |
* | |
* 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 |
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
import io.reactivex.Maybe; | |
import io.reactivex.MaybeSource; | |
import io.reactivex.Observable; | |
import io.reactivex.ObservableTransformer; | |
import io.reactivex.disposables.Disposable; | |
import io.reactivex.functions.Consumer; | |
import io.reactivex.functions.Function; | |
import io.reactivex.subjects.BehaviorSubject; | |
import java.util.ArrayList; | |
import java.util.Arrays; |
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 static class MainActivity extends Activity | |
implements HeadlinesFragment.HeadlineListener{ | |
... | |
public void onArticleSelected(int position) { | |
// The user selected the headline of an article from the HeadlinesFragment | |
// Do something here to display that article | |
} | |
} |
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 HeadlinesFragment extends ListFragment { | |
HeadlineListener mCallback; | |
// Container Activity must implement this interface | |
public interface HeadlineListener { | |
public void onArticleSelected(int position); | |
} | |
@Override | |
public void onAttach(Activity 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
public static class MainActivity extends Activity { | |
public void onArticleSelected(int position) { | |
} | |
} |
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 interface HeadlineListener<T extends Activity> extends Serializable { | |
public void onArticleSelected(T activity, int position); | |
} |
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 HeadlinesFragment extends ListFragment { | |
HeadlineListener mCallback; | |
public <T> void setHeadlineListener(HeadlineListener<T> listener) { | |
this.mCallBack = listener; | |
} | |
@Override | |
public void onListItemClick(ListView l, View v, int p, long i) { | |
// Send the event to the host 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
public static class MainActivity extends Activity { | |
public void bindFragment(HeadlinesFragment fragment) { | |
fragment.setHeadlineListener(MainActivity::onArticleSelected); | |
} | |
public void onArticleSelected(int position) { | |
... | |
} | |
} |
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
just(0) | |
.map(this::onArticleSelected) | |
.subscribe(...); |
OlderNewer