German RSS_Reader Erweiterung

ralfkammel

Member
Licensed User
Longtime User
Hallo zusammen,

ich wollte nur mal eben für meinen Kollegen einen Kleinen RSS-Reader für sein Schreibtischtablett
zusammenschreiben.
Hab mir das Beispiel RSS_Reader.zip runtergeladen...

http://www.b4x.com/android/forum/threads/rss-feed.15382/#post87266

Den Feed geändert und es funktioniert.

Jetzt möchte ich allerdings noch zusätzlich, da ja genug Platz auf dem Schirm ist auch noch

die aktuelle Uhrzeit und das Datum anzeigen lassen - einmal klappt es ja, aber ich kann die Uhrzeit nicht kontinuierlich aktualisieren.

Wenn ich die Routine mit der Uhrzeit laufen lasse, wird der RSS-Feed nicht eingelesen und wenn der RSS-Feed klappt wird die Uhrzeit nicht aktualisiert.

Was mache ich falsch?

B4X:
#Region Project Attributes
    #FullScreen: True
    #IncludeTitle: True
    #ApplicationLabel: BD-iClock
    #VersionCode: 0
    #VersionName: 0.0
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: true
#End Region
 
'Activity module
 
Sub Process_Globals
    'These global variables will be declared once when the application starts.
      'These variables can be accessed from all modules.   
    Dim Parser As SaxParser
    Dim web As PhoneIntents
    Dim hc As HttpClient
    Dim req As HttpRequest
    Dim PubDate As String
End Sub
 
Sub Globals
    Dim RSS As ListView
    Dim Title, Link, Description As String
    Dim Label1 As Label
    Dim Label2 As Label
    Dim Label3 As Label
    Dim DATUM As String
    Dim ZEIT As String
    Dim NOW As Long
    Dim JA As Boolean
    Dim ENDE As Button
End Sub
 
Sub Activity_Create(FirstTime As Boolean)
    JA=True
    DateTime.DateFormat="dd.MM.yyyy"
    Activity.LoadLayout("Main")
    Wait1(3)
    Parser.Initialize
    hc.Initialize("hc")
    req.InitializeGet("http://www.tagesschau.de/newsticker.rdf")
    hc.Execute(req, 1)
    DoEvents
    Do While JA=True
        show_time
        DoEvents
        Wait1(1)
    Loop   
End Sub
 
 
Sub Activity_Resume
    Do While JA=True   
        show_time
        DoEvents
        Wait1(1)
    Loop   
End Sub
 
Sub Activity_Pause(UserClosed As Boolean)
 
End Sub
 
 
Sub RSS_ItemClick(Position As Int, Value As Object)
    StartActivity(web.OpenBrowser(Value)) 'Open the browser with the link
End Sub
 
 
Sub hc_ResponseSuccess(Response As HttpResponse, TaskId As Int)
    Response.GetAsynchronously("GetRSS",    File.OpenOutput(File.DirDefaultExternal, "RSS.xml", False), True, TaskId)
End Sub
 
Sub hc_ResponseError(Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
    If Response <> Null Then
        Msgbox("Error: " & Response.GetString("UTF8"), "Connection Error")
        Response.Release
    End If
End Sub
 
Sub GetRSS_StreamFinish(Success As Boolean, TaskId As Int)
    If Success = False Then
        Msgbox(LastException.Message, "Error")
          Return
    End If
    Dim In As InputStream
    In = File.OpenInput(File.DirDefaultExternal, "RSS.xml")
    Parser.Parse(In, "Parser")
    In.Close
End Sub
 
Sub Parser_StartElement(Uri As String, Name As String, Attributes As Attributes)
 
End Sub
 
Sub Parser_EndElement(Uri As String, Name As String, Text As StringBuilder)
    If Parser.Parents.IndexOf("item") > -1 Then
    If Name = "title" Then
        Title = Text.ToString
        Else If Name = "link" Then
            Link = Text.ToString
        Else If Name = "pubdate" Then
            PubDate = Text.ToString
        Else If Name = "description" Then
            Description = Text.ToString
        End If
    End If
    If Name = "item" Then
        RSS.TwoLinesLayout.Label.Gravity = Gravity.TOP
        RSS.TwoLinesLayout.Label.TextSize = 9dip
        RSS.TwoLinesLayout.Label.Height =100dip
        RSS.TwoLinesLayout.ItemHeight = 100dip
        RSS.TwoLinesLayout.SecondLabel.TextSize = 8dip
        RSS.TwoLinesLayout.SecondLabel.Height = 100dip   
        RSS.AddTwoLines2(Title, Description, Link)
    End If
End Sub
 
 
Sub Wait1(Seconds As Int)
  'Sleep for defined seconds
  Dim Ti As Long
  Ti = DateTime.NOW + (Seconds * 1000)
  Do While DateTime.NOW < Ti
      DoEvents
  Loop
End Sub
 
Sub show_time()
    NOW = DateTime.NOW
    DATUM=DateTime.Date(NOW)
    ZEIT= DateTime.Time (NOW)
    Label1.Text  = ZEIT
    Label2.Text  = ZEIT
    Label3.Text  = DATUM
End Sub
 

rboeck

Well-Known Member
Licensed User
Longtime User
Die verwendete Logik ist eher suboptimal...
Probiere mal, das Ganze mit zwei Timern zu lösen, um die Dauerschleifen mit Doevents einzusparen.
 
Top