uknownothingsnow / CircleProgress

CircleProgress, DonutProgress, ArcProgress
3.81k stars 921 forks source link

ArcProgress in Listview #4

Open kraa opened 9 years ago

kraa commented 9 years ago

Hi I want to use ArcProgress in ListView. I'm declare ArcProgress in listview item layout and when I run my app I saw ArcProgress without arc and bottom text visible only for half. No matter what size of ArcProgress always the same. How can i solve this ? device-2014-11-28-064908

kraa commented 9 years ago

Download zip of 1.0.1 (update to version 1.0.1 from repo still not available). It fixed error with arc, but bottom text still visible for half of hight like in img in previous post.

uknownothingsnow commented 9 years ago

i will check it tonight, pls wait

uknownothingsnow commented 9 years ago

@kraa I can not reproduce your problem, also I add a listview demo in demo module, it works fine. Would you please give me a github link to reproduce your problem? thanks.

kraa commented 9 years ago

I can't give github link because it's not my app (commercial application).

But my case is very simple. In my activity layout I got ListView like this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="vertical" >
    <ListView
        android:id="@+id/officeList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:divider="@color/transparent"
        android:dividerHeight="0dp">
    </ListView>  
</LinearLayout>

And list item simplified looks like:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:custom="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:orientation="horizontal"
    android:layout_height="120dp"
    android:background="#F5F5F5">

    <com.github.lzyzsd.circleprogress.ArcProgress
        android:id="@+id/arc_progress"
        android:layout_width="96dp"
        android:layout_height="96dp"
        android:layout_gravity="center_vertical"
        android:gravity="center_vertical"
        android:background="@color/transparent"
        custom:arc_finished_color="#214193"
        custom:arc_unfinished_color="#F2EDFF"
        custom:arc_max="99"
        custom:arc_bottom_text="Дист."
        custom:arc_suffix_text="км"/>

</LinearLayout>

In ArrayAdapter i accept value to every progress. And in the end i've got this: device-2014-12-01-112921

And if not simplified list item:

device-2014-12-01-113203

uknownothingsnow commented 9 years ago

this is my list item layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:custom="http://schemas.android.com/apk/res-auto"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="120dp"
            android:background="#F5F5F5">

    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@android:id/text1"
              android:layout_width="200dp"
              android:layout_height="96dp"
              android:gravity="center_vertical"/>

    <com.github.lzyzsd.circleprogress.ArcProgress
        android:layout_alignParentRight="true"
        android:id="@+id/arc_progress"
        android:layout_width="96dp"
        android:layout_height="96dp"
        android:layout_gravity="center_vertical"
        android:gravity="center_vertical"
        android:background="@android:color/transparent"
        custom:arc_finished_color="#214193"
        custom:arc_unfinished_color="#F2EDFF"
        custom:arc_max="99"
        custom:arc_bottom_text="Дист."
        custom:arc_suffix_text="км"/>

</LinearLayout>

still can not reproduce image

I have updated example app the same as your code. You can get the latest code and check if it had this bug on your machine.

kraa commented 9 years ago

Your example work well on my device. But I found that if I used AsyncTask i get that strange behavior. For example this code gives that error:

public class TestActivity  extends Activity {
    LinkedList<Office> officeLst = new LinkedList<Office>();
    private ProgressDialog dialog;
    MainApplication app;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_office);
        app = (MainApplication)getApplication();

        new LoadTask().execute();
    }

    public class LoadTask extends AsyncTask{

        @Override
        protected Object doInBackground(Object[] objects) {
            officeLst = app.getAdapterToBis().gettbldbobranch(TestActivity.this);
            return null;
        }

        @Override
        protected void onPreExecute() {
            dialog = ProgressDialog.show(TestActivity.this, null, null);
            dialog.setContentView(R.layout.progress);
        }

        @Override
        protected void onPostExecute(Object result) {
            ListView officeLstView = (ListView) findViewById(R.id.officeList);
            officeLstView.setAdapter(new OfficeAdapter(officeLst));
            dialog.dismiss();
        }
    }

    public class OfficeAdapter extends ArrayAdapter {
        private LinkedList<Office> values;
        private ViewHolder holder;

        class ViewHolder {
            ArcProgress arcProgress;
        }

        public OfficeAdapter(LinkedList<Office> values) {
            super(TestActivity.this, 0, values);
            this.values = values;
        }

        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {
            final Office office = values.get(position);
            if (convertView == null) {
                LayoutInflater inflater = (LayoutInflater) TestActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                convertView = inflater.inflate(R.layout.office_row, parent, false);
                holder = new ViewHolder();
                holder.arcProgress = (ArcProgress)convertView.findViewById(R.id.arc_progress);
                convertView.setTag(holder);
            } else
                holder = (ViewHolder) convertView.getTag();

          //  holder.arcProgress.setProgress(99);
            return convertView;
        }

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return values.size();
        }

        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return values.get(position);
        }

        @Override
        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return position;
        }
    }
}

So in this simple example I get information from server in AsyncTask and send to custom ArrayAdapter.

But if I fill LinkedList officeLst in onCreate method with some information it's work good.

mallikarjuna023 commented 7 years ago

Guys, if you are facing same issue then build your app the check in mobile. I also faced same issue in android studio preview page. good thing is build and check it in your device

meshileya commented 7 years ago

i tried using the sample given, to display an image represented below..but, i am seeing a blank page..what could have been the cause pls? @lzyzsd image

mallikarjuna023 commented 7 years ago

Hello Dear, I think long ago i di d this one and even I add commends there only. currenty I am busy with some other work . please read description, if could't able to figure out then come back again . I will help you

On Tue, Jan 24, 2017 at 6:34 PM, meshileya notifications@github.com wrote:

i tried using the sample given, to display an image represented below..but, i am seeing a blank page..what could have been the cause pls? [image: image] https://cloud.githubusercontent.com/assets/13803856/22248233/ef2d777c-e23d-11e6-8e5a-4ad2a0ded857.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lzyzsd/CircleProgress/issues/4#issuecomment-274797477, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ4hpDCJAAXMJ7HOjhDSsBlE4wP9g0h6ks5rVfblgaJpZM4DBtEu .

-- Thanks & Regards Mallikarjuna N phone no-9482154305

meshileya commented 7 years ago

Thanks so much for your time, and i sincerely do appreciate your kind gesture.

although, i have read through the comment both in the code and some comments above..but, still yet to figure it out..will really appreciate your assistance

MESHILEYA ISRAEL

On 24 January 2017 at 18:54, mallikarjuna023 notifications@github.com wrote:

Hello Dear, I think long ago i di d this one and even I add commends there only. currenty I am busy with some other work . please read description, if could't able to figure out then come back again . I will help you

On Tue, Jan 24, 2017 at 6:34 PM, meshileya notifications@github.com wrote:

i tried using the sample given, to display an image represented below..but, i am seeing a blank page..what could have been the cause pls? [image: image] https://cloud.githubusercontent.com/assets/13803856/22248233/ef2d777c- e23d-11e6-8e5a-4ad2a0ded857.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lzyzsd/CircleProgress/issues/4# issuecomment-274797477, or mute the thread https://github.com/notifications/unsubscribe-auth/ AJ4hpDCJAAXMJ7HOjhDSsBlE4wP9g0h6ks5rVfblgaJpZM4DBtEu .

-- Thanks & Regards Mallikarjuna N phone no-9482154305

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lzyzsd/CircleProgress/issues/4#issuecomment-274882532, or mute the thread https://github.com/notifications/unsubscribe-auth/ANKhUA-ZvpOXkOOcYPSf6uEU9ZBN1RzIks5rVjrfgaJpZM4DBtEu .