Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9148787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:21:59+00:00 2026-06-17T11:21:59+00:00

I am trying to disable onTouch() when my LoadPreview().execute is being launched because if

  • 0

I am trying to disable onTouch() when my LoadPreview().execute is being launched because if the user taps on the button which triggles my LoadPreview(), there will be duplicate preview buttons. So I want to disable onTouch() during the loading process.

is there a way?

This is my ontouch method:

@Override
                public boolean onTouch(View arg0, MotionEvent arg1) {
                    // TODO Auto-generated method stub

                    switch(arg1.getAction())
                    {
                    case MotionEvent.ACTION_DOWN:
                        adapter.clear();
                        new LoadPreview().execute();
                    break;
                    } 

                    return true;
                }   

             }
                );

             }

this is my loadpreview()

/**
     * Background Async Task to Load all product by making HTTP Request
     * */
    class LoadPreview extends AsyncTask<String, String, String> {

        /**
         * getting preview url and then load them
         * */
        protected String doInBackground(String... args) {


            // Building Parameters
                List<NameValuePair> params = new ArrayList<NameValuePair>();
                // getting JSON string from URL
                JSONObject json = jParser.makeHttpRequest(url_magazine, "GET", params);

                // Check your log cat for JSON reponse
                Log.d("All Products: ", json.toString());

                try {
                    // Checking for SUCCESS TAG
                    int success = json.getInt(TAG_SUCCESS);

                    if (success == 1) {
                        // products found
                        // Getting Array of Products
                        mag = json.getJSONArray(TAG_MAGAZINE);

                        for (int i = 0; i < mag.length(); i++) {
                            JSONObject c = mag.getJSONObject(i);

                            // Storing each json item in variable
                            String magazinePreview = c.getString(TAG_MAGAZINE_PREVIEW);

                            previewList.add(magazinePreview);
                        }                   
                    } 
                    else {

                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }

            for (int a = 0; a <= previewList.size(); a++)
            {           
                if(pos == a)
                {
            // Building Parameters
            List<NameValuePair> param = new ArrayList<NameValuePair>();
            // getting JSON string from URL
            JSONObject json1 = jParser.makeHttpRequest(previewList.get(a), "GET", param);

            // CHECKING OF JSON RESPONSE
            Log.d("All guide: ", json.toString());

            try {
                preview = json1.getJSONArray(TAG_PREVIEWS);

                for (int i = 0; i < preview.length(); i++) {
                    JSONObject c = preview.getJSONObject(i);

                    String image = c.getString(TAG_IMAGE);

                    previewImagesList.add(image);
                    //System.out.println(guideList);
                }   

                // STOP THE LOOP
                break;

            } catch (JSONException e) {
                e.printStackTrace();
            }


            }

            }


            return null;
        }

        /**
         * After completing background task Dismiss the progress dialog
         * **/
        protected void onPostExecute(String file_url) {

        /**
         *  Updating parsed JSON data into ListView
        * */            
            adapter.notifyDataSetChanged();

        }
    }

onItemClick method:

coverFlow.setOnItemClickListener(new OnItemClickListener()
    {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1,
                int arg2, long arg3) {

            adapter.clear();
            File sdCard1 = Environment.getExternalStorageDirectory();
            File dir1 = new File (sdCard1.getAbsolutePath() + "/Futsing/issue"+issueNumber+"/"); 

                    /** IF FILE EXISTS **/
                    if(dir1.exists())
                    {
                        Intent intent = new Intent();
                        intent.setClass(CoverFlowExample.this, Reader.class);
                        intent.putExtra("issue", issueNumber);
                        startActivityForResult(intent, GET_INTENT_CODE);
                    }
                    else
                    {
                        if(process==false)
                        {
                            new LoadPreview().execute();
                            process = true;
                        }

                        else
                        {
                            process = false;
                        }
                    }
        }

    }

);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:22:00+00:00Added an answer on June 17, 2026 at 11:22 am

    do as Gabe said.
    You can also do the thing like here i have explained.
    1. define one boolean like:

    private boolean process = false;
    
    1. Override the method like onPreExecution in the AsyncTask.
    2. Put boolean on the above method an define its value to true.

      process = true;

    3. Now, onPostExecution method put this:

      process = false

    4. And also implement your onTouch method like below:

      @Override
      public boolean onTouch(View arg0, MotionEvent arg1) {
      // TODO Auto-generated method stub
      
      if(process==false){
      
          switch(arg1.getAction())
          {
              case MotionEvent.ACTION_DOWN:
                 adapter.clear();
                 new LoadPreview().execute();
                 break;
          } 
      
          return true;
          }   
          else{
            return false;
      }
      
      }                
      

      );

    ** FOR onItenClick **

    You can use below code for onItemClick to work as you want.

    @Override
        public void onItemClick(AdapterView<?> arg0, View arg1,
                int arg2, long arg3) {
    
           if(process==false)
           {
    
            adapter.clear();
            File sdCard1 = Environment.getExternalStorageDirectory();
            File dir1 = new File (sdCard1.getAbsolutePath() + "/Futsing/issue"+issueNumber+"/"); 
    
                    /** IF FILE EXISTS **/
                    if(dir1.exists())
                    {
                        Intent intent = new Intent();
                        intent.setClass(CoverFlowExample.this, Reader.class);
                        intent.putExtra("issue", issueNumber);
                        startActivityForResult(intent, GET_INTENT_CODE);
                    }
                    else
                    {
    
                            new LoadPreview().execute();
    
    
                    }
              }else{
                    // nothing to do here it means the process is running
              }
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to disable the user's ability to alter the state of a
I am trying to disable top inner shadow in input=text field which is applied
I'm trying to disable the backspace button on an order page in all cases
I am trying to disable a button - using jQuery 1.4.4 the following code
I am trying to disable a button after it has been clicked so that
I am trying to disable the form on my site when the user click
I'm trying to disable a button when it is clicked: Private Sub submitButton_Click() Me.submitButton.Enabled
I am trying to disable user text input in a text field, and am
I'm basically trying to disable the scroll on List View. Which can be done
I am trying disable the left/right buttons that allow the user to change months.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.