button color changed but not updated in screen in android - android-runonuithread

See I have used runOnUIThread(){} in AsyncTask to update button color. After updating those button attributes I can read its color, name, etc... In Log everything is showing correctly but those properties were not getting updated in UI. How to fix it?
Here is my code,
MainActivity.activity.runOnUiThread(new Runnable()
{
#Override
public void run() {
Log.d("status","Inside Main Thread");
Log.d("status","Chaning to your turn");
yourTurn.setText("your turn *");
oppTurn.setText("");
Log.d("status","Your turn : " + yourTurn.getText().toString());
Log.d("status","Your turn boolean : " + isYourTurn);
Log.d("status","Changing bg color");
button.getBackground().setColorFilter(0xFFFF0000,PorterDuff.Mode.MULTIPLY);
Log.d("status","Updating the scores");
yourScoreView.setText(gamer.getGamerName() + " Score : " + gamer.getYourScore());
oppScoreView.setText(gamer.getOppName() + " Score : " + gamer.getOppScore());
}
});

Related

How to use QuickTip on Grid cell Sencha GXT 3.1.1?

I need add a tooltip on grid cell, but this tooltip must allow the user select text inside the tooltip. I'm using the QuickTip like this.
ColumnConfig<ClientModel, String> clmName = new ColumnConfig<ClientModel, String>
(dpGridModel.name(), 150, "Name");
clmName.setCell(new TextCell() {
#Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
if (value != null) {
StringBuilder bAux = new StringBuilder();
ClientModel c = lstModel.get(context.getIndex());
bAux.append("<div style='width:100%;height:21px;' qtip='<table>");
bAux.append("<tr><td><b>ID:</b></td><td>" + c.getId() + "</td></tr>");
bAux.append("<tr><td><b>Name:</b></td><td>" + c.getName() + "</td></tr>");
bAux.append("<tr><td><b>Adress:</b></td><td>" + c.getAddress()+ "</td></tr>");
bAux.append("<tr><td><b>City:</b></td><td>" + c.getCity()+ "</td></tr>");
bAux.append("<tr><td><b>Email:</b></td><td>" + c.getEmail() + "</td></tr>");
bAux.append("<tr><td><b>Phone:</b></td><td>" + c.getPhone() + "</td></tr>");
bAux.append("<tr><td><b>Zip Code:</b></td><td>" + c.getZipcode() + "</td></tr>");
bAux.append("</table>'>" + value + "</div>");
sb.appendHtmlConstant(bAux.toString());
}
}
});
QuickTip t = new QuickTip(gridClient);
t.setAllowTextSelection(true);
t.setClosable(true);
The Tooltip ever hides when mouse move. I need what the Tooltip wait by close click to hide, like ToolTip with ToolTipConfig.
I tryed using QuickTip with ToolTipConfig like this.
QuickTip cqt = new QuickTip(gridClient);
cqt.setMaxWidth(650);
cqt.setClosable(true);
cqt.setQuickShowInterval(500);
cqt.setAllowTextSelection(true);
ToolTipConfig config = new ToolTipConfig();
config.setAutoHide(false);
cqt.setToolTipConfig(config);
It's works QuickTip doesn't hide, but appears a blank tooltip above the QuickTip
thanks for help :D
The second try does not work because when you call setToolTipConfig in the QuickTip object it is going to create a new ToolTip for the QuickTip and this is not what we want.
In the first case we just need to set autoHide to false, but there is no method to do this in the QuickTip class, so the option is to use the update method like this:
QuickTip t = new QuickTip(gridClient);
t.setAllowTextSelection(true);
ToolTipConfig config = new ToolTipConfig();
config.setAutoHide(false);
config.setCloseable(true); // need to set it here otherwise it will be overwritten
t.update(config);

ProgressMessageBox Is Not Updating

In GXT (from Sencha) I am attempting to use a ProgressMessageBox to show the user that work is being done, but I am not seeing the message box until after all of the work is complete. Here is the code:
final ProgressMessageBox messageBox = new ProgressMessageBox("Task Description",
"Executing Task...");
messageBox.setProgressText("Calculating...");
messageBox.setPredefinedButtons();
messageBox.show();
for (int i = 0; i < 5; ++i) {
for (long l = 0l; l < 10000000000l; ++l) {
if (l == 12345l) {
MyUtil.info(60, "" + System.currentTimeMillis() / 1000);
}
}
messageBox.updateProgress((double)(i + 1) / 5, "{0}% Complete");
}
This code is in the SelectionHandler of a menu item. Obviously I am not actually just looping a few billion times in the "real" code, but when I perform the work that I want to execute I get the same result ... the message box is shown after all the work has been completed. I see the "info" messages (MyUtil#info is simply a wrapper around the GXT Info capability, which causes an info message to be displayed for the specified number of seconds) ... and on my machine, running the code shown, each message has a value that is about seven seconds greater than the previous message (but they all show up at the same time as the message box).
Is there something that I need to do after calling ProgressMessageBox#updateProgress to force the screen or message box to refresh?
I was able to get this to work by putting the task into a Scheduler#execute method. The example in the Sencha Explorer Demo uses a Timer, but since I don't know how long the execution will take I chose to use the Scheduler approach. Here is the relevant final code:
...
menuItem.addSelectionHandler(new SelectionHandler<Item>() {
#Override
public void onSelection(final SelectionEvent<Item> selectionEvent) {
final ProgressMessageBox messageBox = new ProgressMessageBox("Size All Columns", //
"Resizing Columns...");
messageBox.setProgressText("Calculating...");
// messageBox.setPredefinedButtons();
messageBox.show();
resizeNextColumn(messageBox,
_selectionModel instanceof CheckBoxSelectionModel ? 1 : 0,
_grid.getColumnModel().getColumnCount() - 1);
}
});
...
private void resizeNextColumn(final ProgressMessageBox messageBox,
final int columnIndex,
final int lastColumnIndex) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
#Override
public void execute() {
resizeColumnToFit(columnIndex);
if (columnIndex == lastColumnIndex) {
messageBox.hide();
_grid.getView().refresh(true);
return;
}
messageBox.updateProgress((double)columnIndex / (lastColumnIndex + 1),
"{0}% Complete");
resizeNextColumn(messageBox, columnIndex + 1, lastColumnIndex);
}
});
}
One thing that didn't appear to work is the messageBox.setPredefinedButtons() call ... when I use this the progress bar in the message box doesn't update at all. I really didn't want an "OK" button on the dialog, but for now it'll have to do. I'm using 3.1.0 of GXT.

GWT Bootstrap Popover and Tooltip placement left not working on flow right elements

I am trying to create a tooltip / popover over a button that has pull-right class set(pull-right basically sets the flow to right). The tooltip/popover crashes when trying to do a placement left. Any suggestions/ help?
/* The widget updateStatusDate is a button that floats right*/
Tooltip tooltip = new Tooltip("Date : " + timeOfOperation + " Comment : " + comment);
setUpdateStatusDate("Last Updated by : " + userName);
tooltip.setWidget(updateStatusDate); tooltip.setPlacement(Placement.LEFT);
tooltip.reconfigure();
Given your code, I have put its simplified version into my project and it works without problems. You can copy it to your project and check if it works:
#Override
public void onModuleLoad() {
// essentials from questioned code
Tooltip tooltip = new Tooltip("text");
Button updateStatusDate = new Button("test button");
tooltip.setWidget(updateStatusDate);
tooltip.setPlacement(Placement.LEFT);
tooltip.reconfigure();
// change style for the rootPanel, so the button flows to the center
// it is just for fast and short code example, do not do this in your regular project
com.google.gwt.dom.client.Style.TextAlign center = TextAlign.CENTER;
RootPanel.get().getElement().getStyle().setTextAlign(center);
//add button
RootPanel.get().add(updateStatusDate);
}
My Bootstrap version is: 2.3.2.0-SNAPSHOT, and my GWT version is 2.5.1.

Wicket 6 modal window parent page update

I have two modal window scenarios that worked with Wicket 1.4 but no longer work with Wicket 6.
Case 1
Modal1 inserts an item into list on parent page, then closes.
Callback on parent page refreshes the list using target.add(container)
I can see that the callback is firing but the refresh no longer has any effect.
modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback(){
#Override
public void onClose(AjaxRequestTarget target) {
logger.info("Running Modal1 closed callback... ");
logger.info("AjaxRequestTarget: " + target.getPageClass().getName());
target.add(sampleListView);
modal.close(target);
}
});
Case 2
Parent page defines two modal windows.
Callback for Modal2 launches Modal1.
I can see that the callback is firing but Modal2 is no longer launching.
modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback(){
#Override
public void onClose(AjaxRequestTarget target) {
logger.info("Running Modal2 closed callback... ");
logger.info("AjaxRequestTarget: " + target.getPageClass().getName());
if (originalSample != null){
logger.info("originalSample is not null");
...do some stuff...
modal1.show(target);
}else{
modal.close(target);
}
}
});
I can't figure out why this no longer works. Any advice would be appreciated!

Working Set Selection Programmatically in Eclipse

I want to achieve the functionality of selecting a working set programmatically. I tried with the below code:
IWorkingSetManager wsMgr = PlatformUI.getWorkbench().getWorkingSetManager();
IWorkingSet ws = wsMgr.getWorkingSet("custom");
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IWorkingSet[] windowset = new IWorkingSet[]{ws};
page.setWorkingSets(windowset);
But the above code does not work and the Project Explorer does not show the working set.
Why does not the above code work and what is the solution for the above?
For updating the ProjectExplorer view with a working set, I tried the below code
IWorkingSetManager wsMgr = PlatformUI.getWorkbench().getWorkingSetManager();
IWorkingSet ws = wsMgr.getWorkingSet("custom");
ProjectExplorer pView = (ProjectExplorer)page.findView(IPageLayout.ID_PROJECT_EXPLORER);
pView.getCommonViewer().setInput(ws);
The above code displays the content of the working set in ProjectExplorer, but that is not persisted. I mean once Eclipse is restarted, instead of the working set, all projects are getting displayed.
Here's an example handler I created that can set working sets programmatically in a Project Explorer and turn on top level workingsets if it's not already on:
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow workbenchWindow = HandlerUtil
.getActiveWorkbenchWindowChecked(event);
IWorkbenchPage page = workbenchWindow.getActivePage();
IWorkingSetManager manager = workbenchWindow.getWorkbench()
.getWorkingSetManager();
ProjectExplorer projExplorer = (ProjectExplorer) page
.findView(IPageLayout.ID_PROJECT_EXPLORER);
// This is just a test, to ensure we got hold on the correct object for
// Project Explorer.
// The project explorer will get focus now.
projExplorer.setFocus();
// Obtain list of all existing working sets.
// This assumes that the debug workspace used have some working sets
// prepared.
IWorkingSet[] allExistingSets = manager.getWorkingSets();
IWorkingSet workingSet = null;
// The prints information about all working sets.
for (IWorkingSet myset : allExistingSets) {
workingSet = myset;
IAdaptable[] elems = myset.getElements();
System.out.println("Working set " + myset.getName() + " has "
+ elems.length + " projects.");
for (IAdaptable elem : elems) {
System.out.println("Working set " + myset.getName()
+ " contains " + elem.toString());
}
}
page.setWorkingSets(allExistingSets);
NavigatorActionService actionService = projExplorer
.getNavigatorActionService();
CommonViewer viewer = (CommonViewer) projExplorer
.getAdapter(CommonViewer.class);
INavigatorContentService contentService = viewer
.getNavigatorContentService();
try {
IExtensionStateModel extensionStateModel = contentService
.findStateModel(WorkingSetsContentProvider.EXTENSION_ID);
extensionStateModel.setBooleanProperty(
WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS,
true);
projExplorer.setRootMode(ProjectExplorer.WORKING_SETS);
WorkingSetActionProvider provider = (WorkingSetActionProvider) getActionProvider(
contentService, actionService,
WorkingSetActionProvider.class);
IPropertyChangeListener l = provider.getFilterChangeListener();
PropertyChangeEvent pevent = new PropertyChangeEvent(this,
WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null,
page.getAggregateWorkingSet());
l.propertyChange(pevent);
viewer.refresh();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static CommonActionProvider getActionProvider(
INavigatorContentService contentService,
NavigatorActionService actionService, Class cls) throws Exception {
CommonActionProvider provider = null;
CommonActionProviderDescriptor[] providerDescriptors = CommonActionDescriptorManager
.getInstance().findRelevantActionDescriptors(contentService,
new ActionContext(new StructuredSelection()));
if (providerDescriptors.length > 0) {
for (int i = 0; i < providerDescriptors.length; i++) {
provider = actionService
.getActionProviderInstance(providerDescriptors[i]);
if (provider.getClass() == cls)
return provider;
}
}
return null;
}
It doesn't reset the radio button in the view menu for Top Level Elements though. It also has to use internals to work.
After setting the new working sets into the active page. Did you change your project explorer view into working sets mode?
Please find the project explorer view and do set the mode.
ProjectExplorer projExplorer = (ProjectExplorer) page.findView(IPageLayout.ID_PROJECT_EXPLORER);
projExplorer.setRootMode(ProjectExplorer.WORKING_SETS);