Skip to content

Commit

Permalink
media library: avoid empty listings after an update/refresh by going …
Browse files Browse the repository at this point in the history
…one level up in the hierarchy
  • Loading branch information
Montellese committed Oct 23, 2012
1 parent bb6d1c7 commit 7274688
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
12 changes: 11 additions & 1 deletion language/English/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -3348,7 +3348,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"
Expand Down
30 changes: 28 additions & 2 deletions xbmc/windows/GUIMediaWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -866,7 +867,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
Expand Down Expand Up @@ -1128,7 +1146,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
Expand Down

0 comments on commit 7274688

Please sign in to comment.