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

  • Home
  • SEARCH
  • 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 7792701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:16:02+00:00 2026-06-01T22:16:02+00:00

(Sorry for my mistakes in spelling) I have a problem in the combination of

  • 0

(Sorry for my mistakes in spelling)

I have a problem in the combination of some things:

I use a GridView to download show content from a database. onClick a file is downloaded which can be viewed later. Its about 20MB. This download is done by a service.

Every item in the gridView contains a progressbar in the layout. this progressbar is just shown if the item is donwloading in the background via the service.

The Service sends a broadcast about the download Progress, the Intent contains the ID of the item to find it in data of the Adapter for the gridview.

A BroadcastReceiver ist registered in my Activity to get the Progress Update (remember, simultaneous downloads are possible) which calls a function “setProgress” in the gridview-adapter

public void setProgress(long id, int progress)
{
   for (int i = 0;i < list.size();i++)
   {
      if (list.get(i).getId() == id)
      {
          list.get(i).setProgress(progress);
          notifyDataSetChanged();
      }
   }        
}

To this point everything works fine.

Additionally im using QuickAction implementation from http:// www. londatiga.net/it/how-to-create-quickaction-dialog-in-android/ (Spaces because i cannot post more than two hyperlinks)

Now comes the problem:

Sometimes, i guess when notifydatasetchanged is called and the user taps on an item, the quickaction is shown on a wrong position.

To make this clearer here are two pictures:

The first one is what should happen (in this case a click on the first item of the gridview)
http://dl.dropbox.com/u/9031500/expected.png

The second picture shows what happens sometimes (only when some downloads are running, thats why i guess its because of the “notifydatasetchanged” and the rebuild of the views). This was also a click on the first item, unfortunately the quick-action is shown to the fourth item:
http://dl.dropbox.com/u/9031500/wrong.png

This is my implementation in my activity for the call of the quick-action:

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    showQuickAction(view, position);
}

@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    showQuickAction(view, position);
    return true;
}


private void showQuickAction(View view, int position)
{
    RelativeLayout facsimile = (RelativeLayout) view.findViewById(R.id.lib_item_image_layout);
    Log.i(LOGTAG, "Position:"+position);
    currentPaper = TZReader.paperDao.load(libraryAdapter.getItemId(position));
    Log.i(LOGTAG,"Set CurrentPaper:"+currentPaper.getTitelWithDate());

    ActionItem downloadItem = new ActionItem(ACTION_ITEM_DOWNLOAD, "Download", getResources().getDrawable(R.drawable.ic_action_download));
    ActionItem readItem = new ActionItem(ACTION_ITEM_READ, "Lesen", getResources().getDrawable(R.drawable.ic_action_read));
    ActionItem deleteItem = new ActionItem(ACTION_ITEM_DELETE, "Löschen", getResources().getDrawable(R.drawable.ic_action_delete));
    ActionItem cancelItem = new ActionItem(ACTION_ITEM_CANCEL, "Abbrechen", getResources().getDrawable(R.drawable.ic_action_cancel));

    QuickAction mQuickAction = new QuickAction(this, QuickAction.HORIZONTAL);

    switch (currentPaper.getState())
    {
    case Paper.DOWNLOADED_READABLE:
        mQuickAction.addActionItem(readItem);
        mQuickAction.addActionItem(deleteItem);         
        break;
    case Paper.DOWNLOADED_BUT_UPDATE:
        mQuickAction.addActionItem(downloadItem);
        mQuickAction.addActionItem(deleteItem);
        break;
    case Paper.IS_DOWNLOADING:
        mQuickAction.addActionItem(cancelItem);
        break;
    case Paper.NOT_DOWNLOADED:
        mQuickAction.addActionItem(downloadItem);
        break;  
    }


    //Set listener for action item clicked
    mQuickAction.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() {         
        @Override
        public void onItemClick(QuickAction source, int pos, int actionId) {                        
            //here we can filter which action item was clicked with pos or actionId parameter
            switch(actionId)
            {
            case ACTION_ITEM_DOWNLOAD:
                Intent downloadIntent = new Intent(getApplicationContext(), DownloadService.class);
                downloadIntent.putExtra(DownloadService.PARAMETER_PAPER_DB_ID_LONG, currentPaper.getId());
                startService(downloadIntent);
                break;
            case ACTION_ITEM_READ:

                break;
            case ACTION_ITEM_DELETE:
                DeleteAlertDialogFragment newFragment = DeleteAlertDialogFragment.newInstance(currentPaper.getId());
                newFragment.setStyle(SherlockDialogFragment.STYLE_NO_TITLE,0);
                newFragment.show(getSupportFragmentManager(), "dialog");
                break;
            case ACTION_ITEM_CANCEL:
                break;                  
            }
        }
    });     



    mQuickAction.show(facsimile);   
}

Maybe someone has any idea or hints for me how i can handle this problem!
Thanks a million in advance!

  • 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-01T22:16:03+00:00Added an answer on June 1, 2026 at 10:16 pm

    I found a solution for my problem.

    The solution is that i implement my own ProgressBar, which contains now a BroadcastListerner and set the progress on each item. So i can change the value without need to call “notifydatasetchanged”. perfect for my needs. Im still not sur if this is a good solution, but it works well.

    Here is the code for the Progressbar:

    public class ListeningProgressBar extends ProgressBar {
    
    public ListeningProgressBar(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    
    
    final IntentFilter intentDownloadProgressFilter = new IntentFilter(DownloadService.DOWNLOAD_PROGRESS_BROADCAST);
    private long paperId = 0;
    private boolean isReceiverRegistered = false;
    
    @Override
    protected void onAttachedToWindow() {
    
        getContext().getApplicationContext().registerReceiver(downloadProgressBroadcastReceiver,intentDownloadProgressFilter);
        isReceiverRegistered = true;
    
        super.onAttachedToWindow();
    }
    
    @Override
    protected void onDetachedFromWindow() {
        if (isReceiverRegistered)
        {
            getContext().getApplicationContext().unregisterReceiver(downloadProgressBroadcastReceiver);
            isReceiverRegistered = false;
        }
        super.onDetachedFromWindow();
    }
    
    private BroadcastReceiver downloadProgressBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            long id = intent.getLongExtra(DownloadService.PARAMETER_PAPER_DB_ID_LONG, -1);
            int progressValue = intent.getIntExtra(DownloadService.PARAMETER_PAPER_PROGRESS_INT, 0);
            if (paperId == id)
            {
                setProgress(progressValue);
            }
        }
    };
    
    public long getPaperId() {
        return paperId;
    }
    
    public void setPaperId(long paperId) {
        this.paperId = paperId;
    }
    
    }
    

    I just use it as a normal custom view in my XML Layout.
    In the Adapter i set the id of my content to give the receiver the data just to setprogress if its the right content.

    At the end, my problem is solved, the progress is updated without the need to call notifydatasetchanged. Yeah!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm french, sorry for my spelling mistakes... I have a page containing a fancybox
i'm from poland so sorry for word mistakes. what's my problem? i've got array
(Sorry for my mistakes in spelling) output came from .cvs file First Name,Last Name,Main-Email,Current
Firt of all, I'm very sorry if I have some mistakes in English. <select
sorry about input mistakes, english its not my mother lang. I have this code
I have such class (sorry about posible mistakes, i'm writing it right here.) Class
I am new to the asp.net, and sorry for grammar mistakes. I have 3
I'm a beginner in Sqlite, so sorry if I made some stupid mistakes :D
I could use some help with a problem I've been having: I've started building
I have some code here (Sorry because my code is too long but I

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.