B4A Library CustomRSSView

Discussion in 'Additional libraries, classes and official updates' started by NJDude, Jun 24, 2014.

Similar threads

B4A Tutorial XML Parsing with the XmlSax library
B4A Question "Quote of the day" widget demo
B4A Question RSS feed question
B4A Question Combine 2 rss-feeds
B4A Question Rss Feed help
  1. NJDude

    NJDude Expert Licensed User

    This library will allow you to display RSS feeds "Magazine Style" on a nice custom view.

    Requirements:

    - B4A 3.8

    - Internet connection

    How to install:

    - Copy the CustomRSSView.jar and CustomRSSView.xml to your additional libraries directory.

    Usage:

    Code:
    Private rssView As CustomRSSView

    'Initialize the CustomRSSView
    rssView.Initialize(Activity, Me, "rssView"50dip100%y - 50dip)

    'Enter the URL of the RSS feed you want to parse
    rssView.ParseRSS("http://www.basic4ppc.com/android/forum/forums/-/index.rss")
    If you want to parse local feeds, do this:
    Code:
    rssView.ParseOfflineRSS(File.DirAssets, "MagazineStyleTemplate.xml")
    That's it!


    Notes:

    1- This library process only valid XML feeds and extracts the following fields: Title, Author, Description, Link, Image and PubDate.

    2- If you want to parse XML feeds which might not be compliant or you want to extract other fields you will have to do it yourself and add the data to the view, there's a method to do that.

    3- On some Android versions the images might not show. - Fixed.

    4- Included a simple XML template to create a magazine style feed.


    Check the attached sample for more details.


    Screenshots:


    [​IMG]


    [​IMG]


    [​IMG]
     

    Attached Files:

    Last edited: Dec 5, 2014
    AnandGupta, peiman, Mashiane and 14 others like this.
  2. asales

    asales Well-Known Member Licensed User

    Very cool but I don't see the pictures in the offline sample. Only Title, Author, Description, Link and PubDate.
     

    Attached Files:

  3. NJDude

    NJDude Expert Licensed User

    I mentioned that on the notes above. It's a bug on certain versions of Android, (I'll have to find a fix).

    Just curious, what Android version you have?
     
    Last edited: Jun 24, 2014
    thedesolatesoul likes this.
  4. asales

    asales Well-Known Member Licensed User

    I tested in Galaxy Player with Android 2.3.6 and Sony Xperia Mini with 4.0.4.
    The size of images is big. Could not be the problem?
     
  5. NJDude

    NJDude Expert Licensed User

    Ok, I have re-uploaded the library and fixed the bug (missing images on certain versions of Android).
     
    Last edited: Jun 24, 2014
    thedesolatesoul and asales like this.
  6. asales

    asales Well-Known Member Licensed User

    Works fine. Thanks. You is really an expert.
     
  7. eSolution

    eSolution Member Licensed User

    Thanks bro, I was looking for something like this!
     
  8. asales

    asales Well-Known Member Licensed User

    Hi NJDude.

    How I can do this?
     
  9. NJDude

    NJDude Expert Licensed User

    To do that you will have to use the XMLSAX library to parse the XML yourself and then add the parsed fields using a CustomRSSView method called AddToRSSView.
     
    thedesolatesoul and asales like this.
  10. asales

    asales Well-Known Member Licensed User

    Is possible translate the labels: Author and Published?
     
  11. NJDude

    NJDude Expert Licensed User

    I will change the lib and remove those pre-defined labels.
     
    Last edited: Jul 1, 2014
    asales and thedesolatesoul like this.
  12. eSolution

    eSolution Member Licensed User

    NJDude, there is a doc with all the methods of the library? :D How can I modify the design if I want to? (may be colors, backgrounds, fonts size and so on...) I love what the lib can do and it solved in 20 min a problem that I tried to solve in the last 3 weeks using other app making software ... B4A is so far the most versatile solution and the community is awesome!! :D
     
  13. NJDude

    NJDude Expert Licensed User

    The intellisense will show all the available methods, they are pretty much self explanatory, regarding modifying the design, that depends on how the XML is created, the sample shows the most common one, and the XML included is the "Magazine Style", other than that, just the colors can be changed (fonts, and backgrounds), it's just a simple RSS view.
     
    thedesolatesoul and eSolution like this.
  14. NJDude

    NJDude Expert Licensed User

    The new version attached to the first post will allow you to define those fields.
     
    eSolution, asales and thedesolatesoul like this.
  15. asales

    asales Well-Known Member Licensed User

    Thanks. Excelent.
    Another suggestion for future versions: possibility of change the text size of field Title.
     
  16. joop

    joop Active Member Licensed User

    Works great .

    NJdude ,is it possible to load an image from File.DirAssets , instead from
    a web link with this lib ,so it can be used when there is no internet available.

    Or can this be done with rssView.AddToRSSView("","","test.png","","","")
    or something like that ?
     
  17. NJDude

    NJDude Expert Licensed User

    Yes, you can do something like this:
    Code:
    ...

    MyPic = 
    "file:///android_asset/test.png"

    ...

    rssView.AddToRSSView(
    """", MyPic, """""")
    Note that the image names MUST be all lowercase.
     
    Last edited: Jul 17, 2014
    thedesolatesoul likes this.
  18. joop

    joop Active Member Licensed User

    Thanks ! , I tried AddToRSSView but I think I am doing something wrong ..

    Code:
    Sub ParseOfflineButton_Click

    Dim Mypic As String
    Mypic = 
    "file:///android_asset/test.jpg"


        
    ProgressDialogShow("Fetching...")

                    
    'Enter the direcrory and file name of the feed to parse
                    rssView.ParseOfflineRSS(File.DirAssets, "magazinestyletemplate.xml")
                    rssView.AddToRSSView(
    "","",Mypic,"","","")
           
    End Sub
    It gives a Runtime Exeption Object should first be initialized (List).
     
  19. NJDude

    NJDude Expert Licensed User

    You need to "prepare" the view to receive data, and then show it:
    Code:
    rssView.PrepareRSSView

    rssView.AddToRSSView(
    "","",Mypic,"","","")

    rssView.ShowRSSView
    If you want to parse the XML in assets then the reference to ALL the pictures in the XML should be file:///android_asset/<PIC_NAME>, what you have done will not work.
     
    joop and thedesolatesoul like this.
  20. joop

    joop Active Member Licensed User

    Thanks NJDude i've got it working now , in the XML-file and with AddToRSSView .
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice