Example #1
0
 def processPosts(self, request, result, *args, **kwargs):
     """Processes data into postCells and puts them into homeScreen's ScrollView"""
     
     self.ids.homescr_output.clear_widgets()
     
     i = 0
     connectionError = False
     try:
         jsonResponse = json.loads(result)
         jsonData = jsonResponse["Data"]
         
         for post in jsonData:
             Title = post['Title']
             Caption = post['Caption']
             Location = post['Location']
             Votes = post['Votes']
             Userid = post['Userid']
             Postid = post['Postid']
             Timestamp = post['Timestamp']
             MediaType = post['MediaType']
             Previousvote = post['Previousvote']
             
             
             source_url = App.get_running_app().backend + Location
             if int(MediaType) == 0:
                 img = imageButton(source=App.get_running_app().backend + "uploads/{}/thumbnails/{}".format(Location.split('/')[1], Location.split('/')[2]))
             elif int(MediaType) == 1:
                 img = imageButtonLocal(source="data/videoplaceholder.png")
                 
             if i%2 == 0:
                 postFormat = postCell(Postid, Title, Votes, Previousvote, img, source_url, Timestamp, MediaType, Caption, True)
             else:
                 postFormat = postCell(Postid, Title, Votes, Previousvote, img, source_url, Timestamp, MediaType, Caption, False)
         
             self.ids.homescr_output.add_widget(postFormat)
             i += 1
             
             self.postCount = i
     
             self.updatePageArrows()
         self.ids.homescr_output.add_widget(FloatLayout())
         self.ids.homescr_output.add_widget(FloatLayout())
     except:
         self.overlayMessage(3)
         connectionError = True
     
     if connectionError == False:
         if i > 0:
             self.overlayMessage(1)
         else:
             self.overlayMessage(2)
Example #2
0
def getReplyScreen(postid, title, voteCount, previousvote, img, source_url, timestamp, mediaType, caption):
    """Creates and switches to the reply screen of a given post"""
    
    if App.get_running_app().manager.has_screen("reply_" + postid) is False:
        
        img2 = imageButton(source=img.source)
        originalPost = postCell(postid, title, voteCount, previousvote, img2, source_url, timestamp, mediaType, caption, True)
        
        scrn = replyScreen()
        scrn.defineVals(postid, originalPost)
        scrn.name = "reply_" + postid
        App.get_running_app().manager.add_widget(scrn)
        
    App.get_running_app().changeScreen("reply_" + postid)
    App.get_running_app().manager.get_screen("reply_" + postid).setOP()
    Clock.schedule_once(App.get_running_app().manager.get_screen("reply_" + postid).display, 0.5)