Buttons not working at first and last index?
<p>I am working on an application in which have two navigation button namely 'previous and next' which on tap load stories respectively. When i tap these buttons gently they work fine button when i tap next button to the last index continuously without any break then the previous button does not work or similarly when i start tapping previous button to the very first index i am unable to move forward.</p>

<p>Remember this only happens at the extreme cases, onClick is not called, don't know why.</p>

<p>My code is as follows, please help me out. Thanks in advance.</p>

<p>this the code of onClick, which works fine in all cases except the extreme cases, when buttons are not tapped gently.</p>

<pre><code> public void onClick(View v) {

    if (visible == true) {
        Log.e("visible", "true");
        return;
    }
    visible = true;

    try {
        Log.e("Now", "On Click");

        pDialog = new ProgressDialog(StoriesListController.this);
        pDialog.setIndeterminate(true);
        pDialog.setIcon(R.drawable.icon_small);
        pDialog.setCancelable(true);
        if (isFavoriteList == true) {
            pDialog.setMessage("Loading favorites...");
        } else {
            pDialog.setMessage("Loading data...");
        }
        pDialog.setTitle("Please wait");
        pDialog.setOnCancelListener(new OnCancelListener() {

            public void onCancel(DialogInterface arg0) {
                if (cancelableHeavyWorker != null) {
                    cancelableHeavyWorker.setHandler(null);
                }
                finish();
            }
        });
        pDialog.show();
        if (v == next) {
            if (ind &lt; items.size() - 1) {
                ind++;
                loadAndShowNextActivity();
            }
        } else if (v == previous) {
            if (ind &gt; 0) {
                ind--;
                loadAndShowNextActivity();
            }
        }
        // realeaseMemoryIfneededofStory(ind);
    } catch (Exception e) {

        Log.e("Error", "--.OnClink Message" + e.toString());
        e.printStackTrace();
    }
}
</code></pre>

<p>Moreover, the boolean variable "visible" is being set to false in the callback function.</p>

<p>The Code of Call Back Function is as follows:</p>

<pre><code>private void fetchTopStoryDetailCallback(Object resultVector) {

    System.out.println("fetchTopStoryDetailCallback");
    try {
        Vector&lt;?&gt; v = (Vector&lt;?&gt;) resultVector;
        boolean completedOrFailed = ((Boolean) v.elementAt(0)).booleanValue();
        if (completedOrFailed == true) {
            boolean slideshow = ((Boolean) v.elementAt(1)).booleanValue();
            Object result = v.elementAt(2);
            String res[] = (String[]) result;

            if (slideshow) {
                if (Utils.topStorySlidesArrayList != null &amp;&amp; Utils.topStorySlidesArrayList.size() &gt; 0) {
                    Intent articleActivityIntent = new Intent(this, SlideShowActivity.class);
                    articleActivityIntent.putExtra("storyData", (String[]) result);
                    articleActivityIntent.putExtra("back", back);
                    articleActivityIntent.putStringArrayListExtra("sid", slideids);
                    // articleActivityIntent.putExtra("contentType", )
                    articleActivityIntent.putExtra("addkey", ADDS_KEY);
                    showActivityInContoller(articleActivityIntent);
                    hidePrgressgingDailog();

                } else {
                    hidePrgressgingDailog();
                    this.closeActivity = true;
                    showMessage("Error", "This story encounter an error while opening. Check your Internet Connection and try later");
                }

            } else {

                if (res[3] != null &amp;&amp; (!(res[3].equalsIgnoreCase("null")) &amp;&amp; (!res[3].equals("")))) {
                    Intent slideshowActivtyIntent = new Intent(this, ArticleActivity.class);
                    slideshowActivtyIntent.putExtra("storyData", (String[]) result);
                    slideshowActivtyIntent.putExtra("back", back);
                    slideshowActivtyIntent.putExtra("addkey", ADDS_KEY);
                    showActivityInContoller(slideshowActivtyIntent);
                    hidePrgressgingDailog();
                } else {
                    hidePrgressgingDailog();
                    this.closeActivity = true;
                    showMessage("Error", "This story encounter an error while opening. Check your Internet Connection and try later");
                }
            }

        } else {
            showMessage("Error", "This story encounter an error while opening. Check your Internet Connection and try later");
            hidePrgressgingDailog();
        }

    } catch (Exception e) {
        Log.e("StoriesController", "Message = " + e.toString());
        e.printStackTrace();
    }
    finally {visible = false; }
}
</code></pre>

<p>this is how visiblity of the buttons is set...!!!!</p>

<p>private void adjustButtonsVisibility() {</p>

<pre><code>    try {
        if (items.size() == 1) {
            next.setEnabled(false);
            next.setImageResource(R.drawable.navigator_next_disable);
            previous.setEnabled(false);
               previous.setImageResource(R.drawable.navigator_previous_disable);
            //hidePrgressgingDailog();
            return;
        }
        if (ind == 0) {
            previous.setEnabled(false);
            next.setEnabled(true);
            previous.setImageResource(R.drawable.navigator_previous_disable);
            next.setImageResource(R.drawable.story_next_arrow);
            hidePrgressgingDailog();

        } else if (ind &gt; 0 &amp;&amp; ind &lt; items.size() - 1) {
            previous.setEnabled(true);
            next.setEnabled(true);
            previous.setImageResource(R.drawable.story_previous_arrow);
            next.setImageResource(R.drawable.story_next_arrow);
        }
        if (ind == items.size() - 1) {
            previous.setEnabled(true);
            next.setEnabled(false);
            previous.setImageResource(R.drawable.story_previous_arrow);
            next.setImageResource(R.drawable.navigator_next_disable);
            hidePrgressgingDailog();
        }
    } catch (Exception e) {
        Log.e("Error", "--,adjustButtonsVisibility Message = " + e);
        e.printStackTrace();
    }
}
</code></pre>
