My intention is to load HTML data into a textView as an ordered (1,2,3,4,.....n) list.But the UI shows always in bullet points rather than an ordered list. I have searched and tried to follow some solutions but nothing works. Your help would be amazing and much appreciated.
The procedure I followed is given underneath.
dataBinding.tvBody.text = HtmlCompat.fromHtml(
text,
HtmlCompat.FROM_HTML_SEPARATOR_LINE_BREAK_DIV,
)
Here the value of text is,
<div><b>Test Data Added Here For EN</b></div><ol><li>15% on discount on video consultation and tele consultation with family medicine doctor, nutritionist, gynecologist, physiotherapist, & dental surgeon.</li><li>15% discount on home sample collections on any pathological test & imaging test.</li><li>15% discount on the 1st visit with family medicine doctor’s fee.</li><li>5% discount on annual health checkups.</li></ol>
Related
I'm making an android app where user can find a book in his/her vicinity and buy it if interested. I am using firebase and geoqueries/geofire.
I want to make a SearchActivity where user can search a book by it's title in his/her vicinity.
my Firebase Database Structure looks like :
books
PushKey
g:
l:
0:
1:
name:"some book name"
If i try to query this with some book name, it works fine using :
myRef.orderByChild("name").equalTo("some book name").addChildEventListener()....//The rest of the code here...
If i try to query nearby books,then also it works fine using :
geoQuery = geoFire.queryAtLocation(myLocation, 10);
I'm stuck at combining these two.
How can i search for a specific book name only in the vicinity?
For example : I want to search a book whose name is "ABCD" and is in a radius of 10km.
OR
Search a book by name and tell which one is nearest(In case several books are uploaded with same name at different locations).
Is it possible to do so? If not, what workaround(maybe other than firebase, but has to cheap and affordable) can i opt for where i can achieve this desired result?
The Firebase Database can only query by a single property. The fact that GeoFire does something that is seemingly at odds with that (querying by longitude and latitude) is because it combines these values into a single property in a magical format called a geohash (the g property in your JSON).
Combining values into a single property is the only way to get Firebase to filter on multiple values. For example, you could prefix the g property with your book title to get some book name_geohashvalue and could then filter on that.
The two main problems with that:
This only works if you know the entire book title, you can do a prefix match on the title, as you'll already need to use the prefix match for the geohash.
This is not built in to GeoFire, so you will have to fork that library and build it yourself.
If you do try to do this yourself, and get stuck, we can try to help. But fair warning: this won't be trivial, and you'll need to understand how geohashes, geofire, and Firebase's query model work quite well. For an intro, I recommend watching the video of my talk on performing geoqueries on Firebase and Firestore.
If you want something a bit less involved, you have two main options:
Retrieve all nodes within range, and then filter for the book title client-side.
Store a separate GeoFire tree for each book title, so that you can initialize your GeoFire object based on the book title, and only get keys within range for that specific book title.
Between these two, I'd recommend starting with #1.
I'm working on a smart EditText where the user write a product and a price without any worries about formatting (e.g. "Pasta 0,50" or "0.50 tomato juice").
I'd like to separate the price from all the rest to have something like
String input = "Cheese 2,00 for Pizza";
String outputProduct = "Cheese for pizza";
String outputPrice = "2,00";
Usually it shouldn't be a thing, but I'm also considering of taking care if the price isn't at the very start or the very end of the string, so if it's in the middle.
I also have to deal with periods and comms in prices.. since not everyone use the same kind of format.
What I've tryed so far: answer from OscarRyz here but it seems to be not very related with what I'm trying to achieve.
Also seen some array operations but my problem is to get the actual length of the price.
Any help would be very appreciated!
First of all excuse me for my very bad English...
I'm a very very new developer and I'm confusing so much with search operation.
Actually I want to make a food and cooking app (with a lot of recipes and so on), and I want to add a search action to it, so the user could put multiple things (such as Ingredients) and the app show him the foods that have these things in their Ingredients.
Now I have two question.
First, how can I add tags to my "recipe activities" so when the ingredient typed app knows which recipes should showes? (My recipes are not in textview, they are all in imageviews).
Second, how can I completely separate the search keywords with ","? for finding the right recipes. (example: type "tomato", "chicken", "egg" and the app shows him/her the recipes that have these things in their Ingredients.)
I know you that now you are laughing so much for my gramer :), so after you laughted enough please answer my questions. Thank You SOOOOOOOOO MUUUUUUUUUCH.
You can use something like a map for every Recipe's ingredients a-la:
class Recipe
-name:String
-ingredients:Map < String, Quantity > or Set < String >
where Quantity represents all that nasty features used in culinary like spoons, cups, pinches.
Then you can search through keys of every recipe's ingredients. Name would be a tag you've mentioned.
You can read search string, parse it (e.g. into array with regular expression) and put into Set to avoid duplicates.
I am performing a search over Strings in an ArrayList. If the Term is found I need to highlight that term and return the a string with the word where the term is present plus a word before and after that word!
Example:
Term = “some”
Searched String = “This is my awesome test String!”
Result = “my awesome test” (“some” should be highlighted here)
First off I am useless with RegEx and wouldn’t know where to start and secondly I’m not sure how to highlight text in a ListView, there are 3 TextViews per Row and I pass an Array with Data objects to the Adapter. Can I just give the Data Object Spanndable’s for highlighting?!
After some trial and error and some help i got this which seems to do the trick
(^|\S*\s)\S*term\S*($|\s\S*)
We know that there are numbers with different length. In Europe we mostly have 9 digits numbers plus country code.
In North America we often find 10 digits numbers.
I am trying to get my head around an idea how to get a country code from a number that may be of different length.
Any ideas? Maybe you know some working libs that can do it?
The key facts:
The country code is always at the start of the number, so it is easy to find no matter the length of the number.
There is no overlap, as #Luis points out.
A (looks pretty) complete list of country codes is give here. If you sort them by length (shortest first) and run through the list comparing the first n digits with the list entries you will get the answer.
However, if you look at the list you wall see that there are various groups of codes. A more intelligent approach would note that:
All numbers beginning with 1 are US, Canada or other US related places in which case the next three digits tell you which.
7 is Khazakstan
Apart from 20, all country codes beginning with 2 are three digits.
and so on ...
Country codes are parsed left-to-right with deterministic endpoints similar to the idea of Huffman coding. ie, if you see a 1 first, stop, it's the US/Canada/related territories. If you see most other numbers besides 7 (Russia/Kazakhstan), keep going. Some of those numbers may terminate on the second value.
The list of country codes is here: http://www.howtocallabroad.com/codes.html
It should be trivial for you to take this and write your own string parser of a phone number in order to determine which country code is present.
(don't forget that if these are numbers from within a particular country, you also have to take that country's exit code into account, which is also on the page I linked)
Edit: Oh, I guess luis covered it. But Jakob is incorrect in his comment about Barbados. Barbados is the same country code as the US; the 246 is its local "area code" within the US/Canada's country code.
I assume that you are talking about phone number country codes. Country codes are defined by the ITU ( https://en.wikipedia.org/wiki/List_of_country_calling_codes ). The country codes can be 1, 2 or 3 digits. Your only alternative is to have a list of all country codes and parse it from there. Note that there is no overlap; for instance, +44 belongs to the UK, and no country starts with just 4.
UPDATE: The North American Area has 4 digit prefixes, not 1, composed of +1 and a NPA of 3 digit (http://en.wikipedia.org/wiki/North_American_Numbering_Plan). The same rule applies though, in that +1-NPA cannot be repeated. Barbados seems to be +1246, but no other country or region can start with +1246. You can get the list of all NPA from http://en.wikipedia.org/wiki/List_of_North_American_Numbering_Plan_area_codes