Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have defined the image view and the progress bar as final and sending these references to the AsyncTask where the magazine downloading activity is going, on click of image view. AsyncTask spawns multiple threads and that's how progress of each download can be updated.Code:</p> <pre><code> @Override public View getView(final int position, View convertView, ViewGroup arg2) { View grid; if (convertView == null) { grid = new View(context); grid = layoutInflater.inflate(item, null); } else { grid = (View) convertView; } final TextView title = (TextView) grid.findViewById(R.id.mgntitle); title.setText(bank.get(position).getTitle()); final ImageView imageView = (ImageView) grid .findViewById(R.id.thumbnail); imageView.setImageResource(R.drawable.icon); final ProgressBar progress = (ProgressBar) grid .findViewById(R.id.progress); final ImageView downloadmark = (ImageView) grid .findViewById(R.id.downloadmark); String pdfLink = bank.get(position).getPdfLink(); String filename = pdfLink.substring(pdfLink.lastIndexOf("/") + 1); final File targetDir = new File(fileLocation + filename); System.out.println("target file name " + targetDir); if (new File(fileLocation + filename).exists()) { if (!getPrefName(filename).equalsIgnoreCase("NA")) { downloadmark.setVisibility(View.VISIBLE); } } imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!targetDir.exists()) { map.put(bank.get(position).getTitle(), progress); new DoBackgroundTask(GridDisplayActivity.this, bank .get(position).getPdfLink(), progress, downloadmark, imageView, position) .execute(); } } }); imageView.setImageBitmap(BitmapFactory.decodeByteArray( bank.get(position).getCoverPages(), 0, bank.get(position) .getCoverPages().length)); return grid; } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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