Created
January 10, 2017 08:13
-
-
Save anonymous/111e6c4c50548503f46868731fb08d9f to your computer and use it in GitHub Desktop.
Test SendToView
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 MainActivity extends CompositeActivity implements MainView { | |
final TiActivityPlugin<MainPresenter, MainView> plugin = new TiActivityPlugin<>( | |
new TiPresenterProvider<MainPresenter>() { | |
@NonNull | |
@Override | |
public MainPresenter providePresenter() { | |
return new MainPresenter(); | |
} | |
}); | |
public MainActivity() { | |
addPlugin(plugin); | |
} | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
plugin.getPresenter().helloWorld(); | |
} | |
@Override | |
public void showToast() { | |
Toast.makeText(this, "Hello World", Toast.LENGTH_LONG).show(); | |
} | |
} |
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 MainPresenter extends TiPresenter<MainView> { | |
public void helloWorld() { | |
sendToView(new ViewAction<MainView>() { | |
@Override | |
public void call(final MainView mainView) { | |
mainView.showToast(); | |
} | |
}); | |
} | |
} |
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 MainView extends TiView { | |
void showToast(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment