Blackberry, searching contacts from list - eclipse

I want to add an Search Box in list Field. so that When i Enter a letter, then it will show the names starting with the letter 'A' , and so on. Iam using Vector to save the list of contacts same as the image shown :

If you want to select from the Contacts, use the ContactList.choose() method.
DO NOT try to iterate through the entire contacts your self every time. Remember there are lot of people having thousands of contacts and your code will be very unresponsive.
See: https://stackoverflow.com/a/4436816/371534
However, if you want to have 'filter as you type' kind of functionality with some other data, use the KeywordFilterField. You can get a sample code for it in the BlackBerry JDK samples.

Set a FieldChangeListener (or listen for alphanumeric key presses) to your EditField. Then refresh the list each time. Filtering on entries starting with the string contained in the EditField.
I wrote this on a pc without the Blackberry plugin installed, so couldn't test it, but it should be something like this.
String prefix = editField.getText();
Enumeration e = list.items();
while(e.hasMoreElements())
{
PIMItem item = (PIMItem) e.nextElement();
String name = item.getString(PIMItem.NAME,0);
if (name.startsWith(prefix))
{
//TODO display on screen
}
}

Related

Dart Phone class search with flutter_contacts

I created a function (using flutter_contacts) that searches contacts on my Phone based on a given contact cell number (input - cellnumber) :
Contact? contact = contacts.firstWhereOrNull((c) => c.phones.contains(Phone(cellnumber)));
It works completely ok when I search for a number without "+" sign (e.g. 12345) and the contact in the contact list has a number without "+" (e.g. 12345).
But it doesn't work when I search for a number with "+" sign (e.g. +12345) and the contact has a number with plus (e.g. +12345).
Anyone knows why is that and how to fix it?
If you look at the code you will see that for the Phone class to be equal to another, there needs to be more components to match than just the phone number.
So to check for phone numbers only, you need to roll your own coparison:
Contact? contact = contacts.firstWhereOrNull((c) => c.phones.any((phone) => phone.number == cellNumber);
If this still does not match, print all the contacts to debug it. I have no idea what your contact list contains or why it would not match.
There is a normalizedNumber property, maybe you need to use that instead to figure out if someone used formatting like "+1 (234) 567-8900".

How to display Icon from package using name from String?

I want to display Icon based on it's name parsed from external source. Now i have several newsfeeds integrated in app, like this:
myPages.add(new Subpage(0, "Main", FontAwesome5Regular.newspaper, "http://url.one"));
myPages.add(new Subpage(1, "Buses", MaterialCommunityIcons.bus_multiple, "http://url.one"));
where 3-d argument of SubPage constructor is IconData. 
I want to generate so much pages as needed, based on CSV. I want to place in CSV lines like
0, Main, FontAwesome5Regular.newspaper, "http://url.one"
1, Buses, MaterialCommunityIcons.bus_multiple, "http://url.two"
I have no problems with parsing csv, but I don't understand how to convert parsed String "FontAwesome5Regular.newspaper" to IconData needed by constructor of Subpage.
It would be great to get solution without async/await, catching error, etc, cause I'm really sure, that CSV contains no errors, all strings are valid, all classes are available
Thank you for any ideas!
You could use 'dart:mirrors' library for that, but, unfortunately, library isn't available in flutter, so you can't access classes' static properties using their names as string. You can do it like this:
IconData getIconData(String str) {
switch (str) {
case "FontAwesome5Regular.newspaper": return FontAwesome5Regular.newspaper;
case "MaterialCommunityIcons.bus_multiple": return MaterialCommunityIcons.bus_multiple;
default: return null;
}
}
great workaroud from Richard Heap:
Can you change your CSV? Let's say you want to send an umbrella icon. Rather than "MaterialIcons.beach_access" send "MaterialIcons" in one column and "60222" in another. Parse the 60222 into a int: var codePoint = int.parse(cp); and make your icon as var icon = IconData(codePoint, fontFamily: ff);
– Richard Heap 2 hours ago

How can you filter search by matching String to a field in Algolia?

I'm trying to create filters for a search on an Android app where a specific field in Algolia must exactly match the given String in order to come up as a hit. For example if Algolia has a field like "foo" and I only want to return hits where "foo" is equal to "bar", then I would expect that I would have to use a line of code like this:
query.setFilters("foo: \"bar\"");
Any guesses as to why this isn't working like I see in the examples or how to do so?
Ah, I thought that attributesForFaceting was done by setting what was searchable or not. It was on a different page within the dashboard than I was previously using. Thanks #pixelastic.

Non case sensitive search for usernames using Swift and Parse

I am writing an app and one feature I am working on is to allow users to search for users in the search bar. At the moment it works, however the search is case sensitive. I was wondering if there is anyway to make the search non-case sensitive? For example, when I did a similar thing in PHP, I would do something like this:
$searchTerm = strtolower($searchTerm);
I would then compare it to the username converted to lower case too.
Here is the kind of thing I am using right now:
var findUsers:PFQuery = PFUser.query()
if !name.isEmpty{
findUsers.whereKey("username", containsString: name) //name is what the user entered
}
Instead of using contains string use matchesRegex: "(?i)(name)"

BlackBerry 10 - Photos from partial contact

I am developing an application that needs to list all contacts in the phone's contacts list. Each cell needs to have the name of the contact and the corresponding photo (primaryPhoto).
I can do this, by fetching contactDetails for each contact. However, if the contacts list has a huge number of elements, this process is too slow. To handle this problem, I am not fetching the contact details and I am using the partial contacts retreived by
contacts = m_contactService->contacts(filter);
The only problem is that this list doesn't contain any photo! And I need the primaryPhoto available.
Is there a way to get the primaryPhoto from a partialContact without the need to fecth all contact details?
Thanks for your help
Implement the following after you get the list of contacts from this returned from the search filter
note: this is not pure C++, do not use this verbatim!
foreach contact in contacts
m_CPhoto = contact->primaryPhoto(); //returns the ContactPhoto id
// if necessary...
m_cPhotoList << m_CPhoto; // you can do this since this would be a list of ids
// to display the actual photo in your list view
m_CPhoto->smallPhoto();
// I only use 'small' since this is a list view; you may use 'original' or 'large'