Note that there are some explanatory texts on larger screens.

plurals
  1. POThreads and listener instance issue
    primarykey
    data
    text
    <p>I am having a strange behavior with threads and a `onclick listener instance in some phones (strange that its not by android version, have test it in a GalaxyII with android 4.03 and work, in a Samsumg Galaxy Tab with 3.2 works fine and in a HTC EVO Design 4G with android 4.03 and a HTC EVO 4G with android 2.3.3 doesn't work) so here is the issue:</p> <p>I have a async class that calls a web service and blocks the screen until the service finishes, then the thread notifies the UI that the service call is finished so the UI shows a modal screen making a <code>addView(GenerateView)</code> to the activity. That works fine until I need to avoid the multiple clicks in the button that triggers the action because multiple views are adding to the activity. So I implement a custom <code>OnClickListener</code> like this:</p> <pre><code>public abstract class OnOneClickListener implements OnClickListener { private boolean clickable; public OnOneClickListener(){ clickable = true; } public final void onClick(View v) { if (clickable) { clickable = false; onOneClick(v); } } public abstract void onOneClick(View v); public void reset() { clickable = true; } } </code></pre> <p>So I implement the custom <code>onclick</code>, block the clickabilty of the button, call the web service and when it finishes in the function that creates and returns the view to add to the activity as a modal windows calls <code>reset()</code> and allows the click in button again. That function receives the instance of the class by parameters. That works like a charm in the phone that mentioned before but in the HTCs when i debug can see that the <code>OnOneClickListener()</code> function modify the clickable variable and the <code>reset()</code> function doesn't see it!! and it happens in the other way too, like if the call of the functions where in two different instances of the class and it NOT!! and thats just one issue that im having with HTCs and threads, the most incredible one.</p> <p>So here goes my questions:</p> <ul> <li>Is some knowed issues with HTCs and threads??</li> <li>Is there some work around?? (Im using AsyncTask to make the calls and it works perfect until now)</li> </ul> <p>In fact anything that you can tell me that help me understand where is the fail will be very helpful because it's driving me crazy.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload