mirror of
https://github.com/HamletDuFromage/aio-switch-updater.git
synced 2024-11-28 20:32:06 +00:00
Fixed crashes when trying to focus empty lists https://github.com/HamletDuFromage/aio-switch-updater/issues/82
This commit is contained in:
parent
5d436c5b8e
commit
271e2ae78c
5 changed files with 27 additions and 4 deletions
|
@ -8,6 +8,8 @@ class AmsTab : public brls::List
|
||||||
brls::ListItem* listItem;
|
brls::ListItem* listItem;
|
||||||
brls::Label *notFound;
|
brls::Label *notFound;
|
||||||
brls::Label *description;
|
brls::Label *description;
|
||||||
|
int size;
|
||||||
public:
|
public:
|
||||||
AmsTab();
|
AmsTab();
|
||||||
|
brls::View* getDefaultFocus() override;
|
||||||
};
|
};
|
|
@ -11,7 +11,9 @@ class ListDownloadTab : public brls::List
|
||||||
brls::Label *notFound;
|
brls::Label *notFound;
|
||||||
brls::Label *description;
|
brls::Label *description;
|
||||||
brls::Label *cheatSlipLabel;
|
brls::Label *cheatSlipLabel;
|
||||||
|
int size;
|
||||||
public:
|
public:
|
||||||
ListDownloadTab(const archiveType type);
|
ListDownloadTab(const archiveType type);
|
||||||
|
brls::View* getDefaultFocus() override;
|
||||||
|
|
||||||
};
|
};
|
|
@ -1,5 +1,4 @@
|
||||||
#include "ams_tab.hpp"
|
#include "ams_tab.hpp"
|
||||||
#include <string>
|
|
||||||
#include "download.hpp"
|
#include "download.hpp"
|
||||||
#include "extract.hpp"
|
#include "extract.hpp"
|
||||||
#include "confirm_page.hpp"
|
#include "confirm_page.hpp"
|
||||||
|
@ -7,6 +6,7 @@
|
||||||
#include "worker_page.hpp"
|
#include "worker_page.hpp"
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
#include "current_cfw.hpp"
|
#include "current_cfw.hpp"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace i18n = brls::i18n;
|
namespace i18n = brls::i18n;
|
||||||
using namespace i18n::literals;
|
using namespace i18n::literals;
|
||||||
|
@ -21,7 +21,8 @@ AmsTab::AmsTab() :
|
||||||
operation += "menus/main/ams"_i18n;
|
operation += "menus/main/ams"_i18n;
|
||||||
links = download::getLinks(AMS_URL);
|
links = download::getLinks(AMS_URL);
|
||||||
|
|
||||||
if(links.size()){
|
this->size = links.size();
|
||||||
|
if(this->size){
|
||||||
auto hekate_link = download::getLinks(HEKATE_URL);
|
auto hekate_link = download::getLinks(HEKATE_URL);
|
||||||
std::string hekate_url = hekate_link[0].second;
|
std::string hekate_url = hekate_link[0].second;
|
||||||
std::string text_hekate = "menus/common/download"_i18n + hekate_link[0].first;
|
std::string text_hekate = "menus/common/download"_i18n + hekate_link[0].first;
|
||||||
|
@ -72,3 +73,11 @@ AmsTab::AmsTab() :
|
||||||
this->addView(notFound);
|
this->addView(notFound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
brls::View* AmsTab::getDefaultFocus()
|
||||||
|
{
|
||||||
|
if(this->size)
|
||||||
|
return this->brls::List::getDefaultFocus();
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
|
}
|
|
@ -78,7 +78,8 @@ ListDownloadTab::ListDownloadTab(const archiveType type) :
|
||||||
|
|
||||||
this->addView(description);
|
this->addView(description);
|
||||||
|
|
||||||
if(links.size()){
|
this->size = links.size();
|
||||||
|
if(this->size){
|
||||||
for (const auto& link : links){
|
for (const auto& link : links){
|
||||||
std::string url = link.second;
|
std::string url = link.second;
|
||||||
std::string text("menus/common/download"_i18n + link.first + "menus/common/from"_i18n + url);
|
std::string text("menus/common/download"_i18n + link.first + "menus/common/from"_i18n + url);
|
||||||
|
@ -126,6 +127,7 @@ ListDownloadTab::ListDownloadTab(const archiveType type) :
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
this->addView(cheatSlipLabel);
|
this->addView(cheatSlipLabel);
|
||||||
|
this->size += 1;
|
||||||
cheatslipsItem = new brls::ListItem("menus/cheats/get_cheatslips"_i18n);
|
cheatslipsItem = new brls::ListItem("menus/cheats/get_cheatslips"_i18n);
|
||||||
cheatslipsItem->setHeight(LISTITEM_HEIGHT);
|
cheatslipsItem->setHeight(LISTITEM_HEIGHT);
|
||||||
cheatslipsItem->getClickEvent()->subscribe([&](brls::View* view) {
|
cheatslipsItem->getClickEvent()->subscribe([&](brls::View* view) {
|
||||||
|
@ -182,3 +184,11 @@ ListDownloadTab::ListDownloadTab(const archiveType type) :
|
||||||
this->addView(cheatslipsItem);
|
this->addView(cheatslipsItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
brls::View* ListDownloadTab::getDefaultFocus()
|
||||||
|
{
|
||||||
|
if(this->size)
|
||||||
|
return this->brls::List::getDefaultFocus();
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
|
}
|
Loading…
Reference in a new issue