Created
October 26, 2016 14:42
-
-
Save senneco/7aa086ba23c6ef2b37eabc623f21a7d4 to your computer and use it in GitHub Desktop.
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 PlayerActivity extends MvpAppCompatActivity implements PlayerView { | |
@InjectPresenter | |
PlayerPresenter mPlayerPresenter; | |
Player mPlayer; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_hello); | |
mPlayer = new Player(); | |
} | |
@Override | |
protected void onStart() { | |
super.onStart(); | |
mPlayerPresenter.onStart(); | |
} | |
@Override | |
protected void onStop() { | |
super.onStop(); | |
mPlayerPresenter.onStop(mPlayer.playPosition()); | |
} | |
@Override | |
public void play(String url, long position) { | |
mPlayer.play(url, position); | |
} | |
@Override | |
public void stop() { | |
mPlayer.stop(); | |
} | |
} |
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
@InjectViewState | |
public class PlayerPresenter extends MvpPresenter<PlayerView>{ | |
private long mLastPlayPosition; | |
public void onStart() { | |
getViewState().play(selectUrl(), mLastPlayPosition); | |
} | |
public void onStop(long lastPlayPosition) { | |
mLastPlayPosition = lastPlayPosition; | |
getViewState().stop(); | |
} | |
private String selectUrl() { | |
return "http://google.com"; | |
} | |
} |
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 PlayerView extends MvpView { | |
void play(String url, long position); | |
void stop(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment