ユーザーが LoadPreview() をトリガーするボタンをタップすると、プレビュー ボタンが重複するため、LoadPreview().execute の起動時に onTouch() を無効にしようとしています。そのため、読み込みプロセス中に onTouch() を無効にしたいと考えています。
方法はありますか?
これは私のオンタッチ方法です:
@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;
}
}
);
}
これは私の 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 メソッド:
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;
}
}
}
}
);