0% found this document useful (0 votes)
2 views2 pages

Recipient Picker Activity

The document describes a UI component called 'Gesture' which includes a block named 'Tap and Hold with Progress'. It provides a code snippet for implementing a progress bar that updates based on user touch events, handling both touch down and touch up actions. The code utilizes a handler to update the progress at regular intervals until a specified condition is met.

Uploaded by

roxanw48
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Recipient Picker Activity

The document describes a UI component called 'Gesture' which includes a block named 'Tap and Hold with Progress'. It provides a code snippet for implementing a progress bar that updates based on user touch events, handling both touch down and touch up actions. The code utilizes a handler to update the progress at regular intervals until a specified condition is met.

Uploaded by

roxanw48
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

"pallets": [

{
"name": "Gesture",
"blocks": [
{
"name": "Tap and Hold with Progress",
"type": "regular",
"typeName": "tapAndHoldProgress",
"color": "#FFA500",
"spec": "%s,%d,%s,%s",
"code": "final ProgressBar progressBar_%1$s = (ProgressBar)
findViewById(R.id.%1$s);\n" +
"progressBar_%1$s.setProgress(0);\n" +
"View view_%1$s = (View) findViewById(R.id.%1$s);\n" +
"view_%1$s.setOnTouchListener(new View.OnTouchListener() {\n" +
" private long startTime = 0;\n" +
" private boolean isRunning = false;\n" +
" private Handler handler = new Handler();\n" +
" private Runnable progressRunnable;\n" +
"\n" +
" @Override\n" +
" public boolean onTouch(View v, MotionEvent event) {\n" +
" switch (event.getAction()) {\n" +
" case MotionEvent.ACTION_DOWN:\n" +
" startTime = System.currentTimeMillis();\n" +
" progressBar_%1$s.setProgress(0);\n" +
" isRunning = true;\n" +
" progressRunnable = new Runnable() {\n" +
" @Override\n" +
" public void run() {\n" +
" if (!isRunning) return;\n" +
" long elapsed =
System.currentTimeMillis() - startTime;\n" +
" int progress = (int) (elapsed / 30); //
প্রতিবার ৩০ ms\n" +
" progressBar_%1$s.setProgress(progress);\
n" +
" if (progress >= 100) {\n" +
" // কাজ সম্পন্ন হলে\n" +
" %4$s\n" + // user code
" isRunning = false;\n" +
" } else {\n" +
" handler.postDelayed(this, 30);\n" +
" }\n" +
" }\n" +
" };\n" +
" handler.post(progressRunnable);\n" +
" return true;\n" +
" case MotionEvent.ACTION_UP:\n" +
" case MotionEvent.ACTION_CANCEL:\n" +
" isRunning = false;\n" +
" handler.removeCallbacks(progressRunnable);\n" +
" progressBar_%1$s.setProgress(0);\n" +
" return true;\n" +
" }\n" +
" return false;\n" +
" }\n" +
"});"
}
]
}
]
}

You might also like