mdkess / ProgressBarListView

53 stars 28 forks source link

issue with textview value update. #1

Open Slake07 opened 8 years ago

Slake07 commented 8 years ago

Hi, your code is working good. and I am also updating download percentage using textview. but when I use textview same as progressbar then both progressbar and textview not updating.. when I scroll listview then only it updates. help me with this.

pishguy commented 8 years ago

Hi. you must be update listview row when you are try to scroll that. thats is not very simple, try to undrestand this code:


    private BroadcastReceiver refreshListViewDownloadItems = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Bundle data             = intent.getExtras();
            int    download_item_id = 0, percent = 0, position = 0, group_id = 0, status = -1, download_position = -1;
            String stream_filename  = "", thumb_path = "";
            if (data != null) {
                percent = data.getInt("percent");
                status = data.getInt("status");
                position = data.getInt("position");
                group_id = data.getInt("group_id");
                stream_filename = data.getString("stream_filename");
                download_position = data.getInt("download_position");
                thumb_path = data.getString("thumb_path");
                updateView(download_item_id, position, percent, stream_filename, thumb_path, group_id, status, download_position);
            }
        }
    };
------------------------------------------------------------------------------------------------------------------------
private void updateView(int download_item_id, int position, int percent, final String stream_filename, final String thumb_path, int group_id, int status, int download_position) {

        View v = lv_message_content.getChildAt(position -lv_message_content.getFirstVisiblePosition());

        lv_message_content.getAdapter().getView(position, v, UI.lv_message_content);
        if (v == null) return;

        ImageView         imgv_image_item      = (ImageView) v.findViewById(R.id.imgv_image_item);
        NumberProgressBar numberProgressBar    = (NumberProgressBar) v.findViewById(R.id.npb_progressbar);

        ...
        ...
    }
Slake07 commented 8 years ago

This is totally different. I want to implement like progressbar implemented in this example.