Permalink
Browse files

Merge pull request #1642 from Montellese/avoid_empty_lists

media library: avoid empty listings after an update/refresh by going one level up in the hierarchy
  • Loading branch information...
2 parents c2037d1 + 7274688 commit e01f929f4cb747bcf04ae3d42031b4bc6ccacfcd @Montellese Montellese committed Oct 23, 2012
Showing with 39 additions and 3 deletions.
  1. +11 −1 language/English/strings.po
  2. +28 −2 xbmc/windows/GUIMediaWindow.cpp
View
12 language/English/strings.po
@@ -3578,7 +3578,17 @@ msgctxt "#2050"
msgid "Runtime"
msgstr ""
-#empty strings from id 2051 to 2099
+#empty strings from id 2051 to 2079
+
+msgctxt "#2080"
+msgid "Empty list"
+msgstr ""
+
+msgctxt "#2081"
+msgid "Went back to parent list because the active list has been emptied"
+msgstr ""
+
+#empty strings from id 2082 to 2099
msgctxt "#2100"
msgid "Script failed! : %s"
View
30 xbmc/windows/GUIMediaWindow.cpp
@@ -64,6 +64,7 @@
#include "interfaces/python/XBPython.h"
#endif
#include "interfaces/Builtins.h"
+#include "dialogs/GUIDialogKaiToast.h"
#include "dialogs/GUIDialogMediaFilter.h"
#include "filesystem/SmartPlaylistDirectory.h"
#if defined(TARGET_ANDROID)
@@ -870,7 +871,24 @@ bool CGUIMediaWindow::Refresh(bool clearCache /* = false */)
if (clearCache)
m_vecItems->RemoveDiscCache(GetID());
- return Update(strCurrentDirectory);
+ // get the original number of items
+ int oldCount = m_filter.IsEmpty() ? m_vecItems->Size() : m_unfilteredItems->Size();
+ if (!Update(strCurrentDirectory))
+ return false;
+
+ // check if we previously had at least 1 item
+ // in the list and whether it now went down to 0
+ // if there are no more items to show after the update
+ // we go one level up in the hierachry to not show an
+ // empty list
+ if (oldCount > 0 &&
+ (m_filter.IsEmpty() ? m_vecItems->Size() : m_unfilteredItems->Size()) <= 0)
+ {
+ CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(2080), g_localizeStrings.Get(2081));
+ GoParentFolder();
+ }
+
+ return true;
}
// \brief This function will be called by Update() before the
@@ -1132,7 +1150,15 @@ void CGUIMediaWindow::GoParentFolder()
// if vector is not empty, pop parent
// if vector is empty, parent is root source listing
strParent = m_history.RemoveParentPath();
- Update(strParent);
+ if (!Update(strParent))
+ return;
+
+ // No items to show so go another level up
+ if (!m_vecItems->GetPath().empty() && (m_filter.IsEmpty() ? m_vecItems->Size() : m_unfilteredItems->Size()) <= 0)
+ {
+ CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(2080), g_localizeStrings.Get(2081));
+ GoParentFolder();
+ }
}
// \brief Override the function to change the default behavior on how

0 comments on commit e01f929

Please sign in to comment.