Giter Site home page Giter Site logo

Comments (35)

pchmn avatar pchmn commented on June 10, 2024 4

Ok sorry for the delay.

Yeah you're right @DreamCatcha, an iterator must be used when removing item from a list while iterating over it. My loop wasn't correct. I made the changes.

Hope this one will work, here the apk

from materialchipsinput.

rayliverified avatar rayliverified commented on June 10, 2024

The earliest error occurs at Line 45 in ContactListActivity.java.
Error:

04-25 23:44:55.373 14712-14712/com.pchmn.sample.materialchipsinput W/System.err: at com.pchmn.sample.materialchipsinput.ContactListActivity.onCreate(ContactListActivity.java:45)

Code:

        // get contact list
        new RxPermissions(this)
                .request(Manifest.permission.READ_CONTACTS)
                .subscribe(granted -> {
                    if(granted && mContactList.size() == 0)
                        getContactList();
                });

from materialchipsinput.

pchmn avatar pchmn commented on June 10, 2024

I didn't specify an onError handler, and I think that's why the exception occurred.
Please test this new sample apk with the fix, and tell me if it works :
https://github.com/pchmn/MaterialChipsInput/raw/master/docs/material-chips-input-sample-v1.0.4_2.apk

from materialchipsinput.

rayliverified avatar rayliverified commented on June 10, 2024

The problem still persists with the same error log. What is RXPermissions? I have never seen it before and I don't know what it does.

from materialchipsinput.

pchmn avatar pchmn commented on June 10, 2024

RxPermissions is a RxJava library for Android M runtime permissions. Here it is used to get read contacts permission.

So I looked at the logs you put, and the error is apparently caused by the fact that the contact list is null, but it seems weird.

It's difficult to debug without your phone haha. Test this apk and tell me if you see a toast message :
https://github.com/pchmn/MaterialChipsInput/raw/dev/docs/material-chips-input-sample-v1.0.4_3.apk

from materialchipsinput.

rayliverified avatar rayliverified commented on June 10, 2024

Sorry, there is no toast message before the app crashes. This is really weird, why would the app crash after requesting permissions? Only after permissions are granted does the app fail. If permissions are not granted, the app fails only after the "Enter a name" box loses focus. If permissions are granted, clicking on
"Contact List Example" fails immediately.

Don't worry about it too much. Please only make it an issue if someelse reports this behavior too! Thanks for trying to debug this issue.

from materialchipsinput.

pchmn avatar pchmn commented on June 10, 2024

Yes it's weird, maybe it is because of RxPermissions library. I will try to use the "normal way" of asking permission to see if it works better.

You don't have any issues on other apps with your Xperia ?

from materialchipsinput.

rayliverified avatar rayliverified commented on June 10, 2024

Not so far. My old development device bootlooped and this new phone isn't even a week old. All my apps are working correctly so far. I am not sure that requesting permissions than normally would solve the thought of it because the permission request dialogue appears correctly. Low priority issue until someone can confirm it's not specific to me. Very weird!

from materialchipsinput.

pchmn avatar pchmn commented on June 10, 2024

Ok we'll see if anyone else will have the same issue.

from materialchipsinput.

 avatar commented on June 10, 2024

I have the same issue and I'm on an Xperia Z3, same permissions issue thought to be the problem. I have found its

getContactList();

and the line;

// pass contact list to chips input
mChipsInput.setFilterableList(mContactList);

Then

setFilterableList(List<? extends ChipInterface> list)

// and crashes on this line
mFilterableListView.build(mChipList, this, mFilterableListBackgroundColor, mFilterableListTextColor);

both mFilterableListBackgroundColor, mFilterableListTextColor are null values, not sure if that's the issue

from materialchipsinput.

pchmn avatar pchmn commented on June 10, 2024

Ok so maybe the problem has to do with RxPermissions. I will make a sample app without this library and post the apk on this conversation. We'll see if it is better

from materialchipsinput.

 avatar commented on June 10, 2024

I've traced it back to the FilterableAdapter constructor and the following code

Collections.sort(chipList, new Comparator<ChipInterface>() {
            @Override
            public int compare(ChipInterface o1, ChipInterface o2) {
                Collator collator = Collator.getInstance(Locale.getDefault()); // <-- here
                collator.setStrength(Collator.PRIMARY);
                return collator.compare(o1.getLabel(), o2.getLabel());
            }
        });

its iterates through many of my 300+ contacts then crashes, I have a feeling its too time consuming for the amount of contacts, out of my league here lol

from materialchipsinput.

pchmn avatar pchmn commented on June 10, 2024

Yeah ok thanks, maybe this is the sorting which is the responsible, and not RxPermissions haha. I don't know why I put the Collator inside the compare() function, it is recreated on each iteration, not very good.

This evening I will post an apk with the changes, hoping it will resolve the issue.

from materialchipsinput.

 avatar commented on June 10, 2024

Not a problem ;)

Edit:
It works when I sublist the contact list to around 100, so we are on the right track

chipList = chipList.subList(0, 100);

from materialchipsinput.

rayliverified avatar rayliverified commented on June 10, 2024

Good to see that I'm not crazy :D

from materialchipsinput.

pchmn avatar pchmn commented on June 10, 2024

You're not crazy haha.
I made the changes, here is the apk.
Tell me if it works.

from materialchipsinput.

 avatar commented on June 10, 2024

The app wouldn't install on my phone for some reason, did you just change the sorting code?

from materialchipsinput.

pchmn avatar pchmn commented on June 10, 2024

Yeah I think it's because I built the apk on a different computer, so the signed key of the apk is different. Please just uninstall the app from your phone, then install the apk I posted.

from materialchipsinput.

 avatar commented on June 10, 2024

I did uninstall the original but it still failed

from materialchipsinput.

pchmn avatar pchmn commented on June 10, 2024

Well that's weird. And you can install previous apks without failing ? This is just the last apk that fails ?

Because yes I just changed the sorting code

from materialchipsinput.

 avatar commented on June 10, 2024

I only ever built the app in android studio to my phone, never previously used the apk's

from materialchipsinput.

pchmn avatar pchmn commented on June 10, 2024

Yes but now I make my changes on a different branch before merge it to the master. And I suppose that you forked or cloned the master branch, so the changes are not effective.

Did you try to install directly the last apk I posted on this conversation ?

from materialchipsinput.

 avatar commented on June 10, 2024

I haven't forked it, I will look for your changes and test that in a few moments, Yeah I tried your apk for the first time from this conversation.

from materialchipsinput.

 avatar commented on June 10, 2024

Ok I have 365 contacts in the list, when it gets to your sorting its crashing because its finding nulls in o1.getLabel(), o2.getLabel()

 mComparator = new Comparator<ChipInterface>() {
            @Override
            public int compare(ChipInterface o1, ChipInterface o2) {
                return mCollator.compare(o1.getLabel(), o2.getLabel());
            }
        };

So I ran the following code to eliminate the nulls just before the compare

List<ChipInterface> deleteCandidates = new ArrayList<>();
for (ChipInterface chip : chipList) {
     if (chip.getLabel() == null) {
         deleteCandidates.add(chip);
     }
}
chipList.removeAll(deleteCandidates);

and it works as fully expected, turns out, when I go into my contact list on the phone, at the very bottom of the list there are several entries flagged as "unknown" which I cant delete for some reason but seems to be added by outlook app. Might be good to filter these out of the list anyway for others who have rogue apps messing with their contact lists lol

from materialchipsinput.

pchmn avatar pchmn commented on June 10, 2024

Ah great, that's why the app crashes, good job. I didn't know that's it possible to have a contact without a name !

I made the changes you suggest, and test it and it seems to work. If you could test this apk.

If it works we will be able to close this issue, finally !

from materialchipsinput.

 avatar commented on June 10, 2024

its crashing with your loop, presumably missing one via index changes

int count = 0;
for(ChipInterface chipInterface: chipList) {
    if(chipInterface.getLabel() == null)
        chipList.remove(count);
    count++;
}

but works with this one

List<ChipInterface> deleteCandidates = new ArrayList<>();
for (ChipInterface chip : chipList) {
    if (chip.getLabel() == null) {
        deleteCandidates.add(chip);
    }
}
chipList.removeAll(deleteCandidates);

I saw the nulls are random in the list and in groups at places, so whether your loop is skipping over one somewhere when the indexes of them change when the first is removed I'm not sure.

from materialchipsinput.

rayliverified avatar rayliverified commented on June 10, 2024

Unfortunately, the last apk still crashes with the same error. I am not that familiar with RxJava so I'm sorry for not being able to do much 🤷‍♂️

from materialchipsinput.

 avatar commented on June 10, 2024

@searchy2 check your phones contact list to see if there are entries at the end of the list listed as "unknown", this is the reason for the error on mine

from materialchipsinput.

rayliverified avatar rayliverified commented on June 10, 2024

Hmm, there are some unknowns! I think this is an Xperia specific quirk as my previous phone had no unknowns.
screenshot_20170507-202029

from materialchipsinput.

 avatar commented on June 10, 2024

When you click on an unknown I find it to have my email from outlook in there, strange issue, and doesn't delete...

from materialchipsinput.

rayliverified avatar rayliverified commented on June 10, 2024

My unknown contacts have nothing in them. No emails, no nothing! I am able to delete them however so there's that. Let me delete all my known contacts and then load up Material Chips to see if it fixes the crashing.

from materialchipsinput.

rayliverified avatar rayliverified commented on June 10, 2024

I just tried deleting the unknowns and then using Material Chips. Still crashes :( Guess the unknowns are not the issue here.

from materialchipsinput.

rayliverified avatar rayliverified commented on June 10, 2024

No more crashes :D Great work @pchmn and @DreamCatcha

@DreamCatcha if you can confirm that there are no crashes with Unknown contacts, this issue can finally be closed 😆

from materialchipsinput.

 avatar commented on June 10, 2024

Yep that works fine now, thanks mate

from materialchipsinput.

rayliverified avatar rayliverified commented on June 10, 2024

Nice! Great library with great support; so happy to see this problem fixed!

from materialchipsinput.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.