How to list all classes in autocompletion inside annotations in Intellij IDEA? - autocomplete

I have custom class InternalTimerServiceController in my application. I want to use it in another class inside android annotations. And it seems that autocompletion does not work correctly in this case.
I have this interface
public interface InternalTimerServiceControllerContract
{
void doWork();
}
And this class
#EBean
public class InternalTimerServiceController implements InternalTimerServiceControllerContract
{
#Override
public void doWork()
{
// do work
}
}
And this is my Activity
public class MyActivity extends Activity
{
// try uncomment line below and see if autocomplete works properly
//#Bean(Internal)
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}

It's a bug, thanks for reporting. I've created a ticket for it: http://youtrack.jetbrains.com/issue/IDEA-98298

Related

How to maintain order of methods of interface in implemented class

Suppose I am having below interface inside binary jar:
public interface OrderDemo
{
public void add();
public void shut();
public void manage();
}
When I am adding this as Jar as part of dependency in my project in eclipse after implementing OrderDemo interface order of method get changed.
public class Demo implements OrderDemo
{
#Override
public void add();
{
}
#Override
public void manage()
{
}
#Override
public void shut()
{
}
}
Tried option given in eclipse preference but won't work.

i cant add toast in libgdx

im trying to create toast by call it with interface
the interface works fine it just that when i try to make a toast with it, it crashes
in Android Launcher
public class AndroidLauncher extends AndroidApplication implements Interface {
public void tost() {
Toast.makeText(getContext(), "wrong num",
Toast.LENGTH_LONG).show();}}
in gameclass
interface Interface{void tost();}
public class MyGdxGame extends ApplicationAdapter {
final private Interface interface;
public MyGdxGame(Interface interface){this.interface=interface;}
public void render() {interface.tost}
Android toasts must be performed on the Android UI thread. The game loop in LibGDX runs on the OpenGL thread, so you must post your method to the UI thread to safely run it, like this:
public class AndroidLauncher extends AndroidApplication implements Interface {
public void tost() {
runOnUiThread(new Runnable() {
#Override
public void run () {
Toast.makeText(getContext(), "wrong num",
Toast.LENGTH_LONG).show();}
}
});
}
}

GWT's Editor Framework and GWTP

building on this answer, i try to integrate the GWT editors into a popup presenter widget. What is the right way to do that?
My view looks like this:
public class DeviceEditorDialogView extends
PopupViewWithUiHandlers<DeviceEditorDialogUiHandlers> implements
DeviceEditorDialogPresenterWidget.MyView {
interface Binder extends UiBinder<PopupPanel, DeviceEditorDialogView> {
}
public interface Driver extends SimpleBeanEditorDriver<DeviceDto, DeviceEditorDialogView> {
}
#Inject
DeviceEditorDialogView(Binder uiBinder, EventBus eventBus) {
super(eventBus);
initWidget(uiBinder.createAndBindUi(this));
}
#Override
public SimpleBeanEditorDriver<DeviceDto, ?> createEditorDriver() {
Driver driver = GWT.create(Driver.class);
driver.initialize(this);
return driver;
}
}
and my presenter looks like this:
public class DeviceEditorDialogPresenterWidget extends PresenterWidget<DeviceEditorDialogPresenterWidget.MyView> implements
DeviceEditorDialogUiHandlers {
#Inject
DeviceEditorDialogPresenterWidget(EventBus eventBus,
MyView view) {
super(eventBus, view);
getView().setUiHandlers(this);
}
/**
* {#link LocalDialogPresenterWidget}'s PopupView.
*/
public interface MyView extends PopupView, DevicesEditView<DeviceDto>, HasUiHandlers<DeviceEditorDialogUiHandlers> {
}
private DeviceDto currentDeviceDTO = null;
private SimpleBeanEditorDriver<DeviceDto, ?> driver;
public DeviceDto getCurrentDeviceDTO() {
return currentDeviceDTO;
}
public void setCurrentDeviceDTO(DeviceDto currentDeviceDTO) {
this.currentDeviceDTO = currentDeviceDTO;
}
#Override
protected void onBind() {
super.onBind();
driver = getView().createEditorDriver();
}
//UiHandler Method: Person person = driver.flush();
}
Is this the right approach? What is missing? Currently nothing happens when i try to use it like this:
#Override
public void showDeviceDialog() {
deviceEditorDialog.setCurrentDeviceDTO(new DeviceDto());
addToPopupSlot(deviceEditorDialog);
}
showDeviceDialog is in the parent presenter and called when clicking a button in that parent Presenter, that instantiates the dialog with private final DeviceEditorDialogPresenterWidget deviceEditorDialog;
Thanks!
Here are a few key points that are missing from your code above:
Your DeviceEditorDialogView should implement Editor<DeviceDto>. This is required in order for the fields of DeviceEditorDialogView to be populated with data from you POJO.
Your DeviceEditorDialogView should have child editors that are mapped to fields in your POJO. For example, given the field deviceDto.modelName (type String), you could have a GWT Label named modelName in your DeviceEditorDialogView. This Label implements Editor<String> and will be populated with the modelName from your DeviceDto when you call driver.edit(deviceDto)
You should call driver.initialize(this) only once, in DeviceEditorDialogView's constructor
You should override onReveal() like this:
#Override
public void onReveal() {
super.onReveal();
driver.edit(currentDeviceDTO); // this will populate your view with the data from your POJO
}
This method will be called when the popup is displayed, just after your DeviceEditorDialogPresenterWidget has been addToPopupSlot

onScroll of Android's ListView is not called

I'm new to Android and Java.
I created a custom ListView as follows:
public class CustomEndlessListView extends ListView implements
OnScrollListener, android.widget.AdapterView.OnItemClickListener, IReceiver {
and then I clicked the 'Add unimplemented methods' option on Eclipse.
This result in the following method:
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
Log.d(TAG,"onScroll !!!!!");
}
with no #Override annotation.
If I manually add the #Override annotation I get :
Multiple markers at this line
- implements android.widget.AbsListView.OnScrollListener.onScroll
- The method onScroll(AbsListView, int, int, int) of type CustomEndlessListView must override a superclass method
When I run the application (without the #Override annotation) this method (onScroll) is never called. Any ideas?
Thanks in advance.
You must register for scroll events by calling the setOnScrollListener. Since you have implemented the OnScrollListener interface in your ListView subclass (which is not the only possibility) you can try something like the following:
public class MyActivity extends ListActivity {
#override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.custom_list_layout);
CustomEndlessListView lv = new CustomEndlessListView(this);
lv.setOnScrollListener(lv);
setListAdapter(lv);
}
}
Alternately you might register for the events in your CustomEndlessListView constructor:
public CustomEndlessListView(Context context) {
// ....
setOnScrollListener(this);
// ....
}

GIN & GWT: Binding Presentation layer with View

I'm trying to bind a GWT view with its presentation layer, but it doesn't seem to be doing anything.
It's a Spring Roo GWT generated project and I'm trying to use the scaffold given as far as possible.
The view is a simple button (R.ui.xml) and the rest of the view is defined in R.java:
public class R extends Composite implements RPresenter.Display {
interface MyUiBinder extends UiBinder<Widget, R> {}
private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
#UiField Button myButton;
private ClickHandler buttonClickHandler = null;
public R(){
initWidget(uiBinder.createAndBindUi(this));
}
#UiHandler("myButton")
void onButtonClick(ClickEvent event){
GWT.log('Button clicked');
if (buttonClickHandler != null){
GWT.log("buttonClickHandler event triggered");
buttonClickHandler.onClick(event);
}
}
#Override
public void setButtonClickHandler(ClickHandler buttonClickHandler) {
GWT.log("setButtonClickHandler");
this.buttonClickHandler = buttonClickHandler;
}
}
The presenter:
public class RPresenter {
public interface Display extends IsWidget {
void setButtonClickHandler(ClickHandler buttonClickHandler);
}
private final Display display;
private final EventBus eventBus;
#Inject
public RPresenter(EventBus eventBus, Display display){
this.display = display;
this.eventBus = eventBus;
bind();
}
private void bind(){
display.setButtonClickHandler(new ClickHandler() {
#Override
public void onClick(ClickEvent event) {
GWT.log("onClick event triggered");
}
});
}
public void go(HasWidgets container){
container.add(display.asWidget());
}
}
And for my GIN module I use the generated ScaffoldModule in the ...client.scaffold.ioc package:
public class ScaffoldModule extends AbstractGinModule {
#Override
protected void configure() {
GWT.log("ScaffoldModule configure");
bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
bind(ApplicationRequestFactory.class).toProvider(RequestFactoryProvider.class).in(Singleton.class);
bind(PlaceController.class).toProvider(PlaceControllerProvider.class).in(Singleton.class);
//bind(RPresenter.Display.class).to(R.class).in(Singleton.class);
bind(RPresenter.Display.class).to(R.class);
}
static class PlaceControllerProvider implements Provider<PlaceController> {
private final EventBus eventBus;
#Inject
public PlaceControllerProvider(EventBus eventBus) {
this.eventBus = eventBus;
}
public PlaceController get() {
return new PlaceController(eventBus);
}
}
static class RequestFactoryProvider implements Provider<ApplicationRequestFactory> {
private final EventBus eventBus;
#Inject
public RequestFactoryProvider(EventBus eventBus) {
this.eventBus = eventBus;
}
public ApplicationRequestFactory get() {
ApplicationRequestFactory requestFactory = GWT.create(ApplicationRequestFactory.class);
requestFactory.initialize(eventBus);
return requestFactory;
}
}
}
In the GWT development mode console, the "ScaffoldModule configure" never displays, yet the generated scaffold seems to binding just fine as the events get passed along from component to component without a hitch, unless the binding is magically happening somewhere else and that is dead code.
When I put my bind(RPresenter.Display.class).to(R.class) in, it doesn't seem to do the binding. The only output I get in the GWT console is "Button clicked" which is called in the view and then nothing further. I'm clearly missing something, any ideas?
The call to GWT.log() will not output anything from an AbstractGinModule - classes that extend AbstractGinModule (ScaffoldModule in your situation) are used by gin at compile time to decide which concrete implementations to use for injected interfaces. From the rest of your description (i.e. that the UI shows up in the application) it appears that your dependency injection is working correctly.