mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-26 22:40:25 +00:00
[FL-3422] Loader: exit animation fix (#2860)
Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
25ec09c7eb
commit
dcb49c540f
1 changed files with 39 additions and 28 deletions
|
@ -38,6 +38,11 @@ typedef struct {
|
|||
FuriString* fap_path;
|
||||
DialogsApp* dialogs;
|
||||
Storage* storage;
|
||||
Loader* loader;
|
||||
|
||||
Gui* gui;
|
||||
ViewHolder* view_holder;
|
||||
Loading* loading;
|
||||
} LoaderApplicationsApp;
|
||||
|
||||
static LoaderApplicationsApp* loader_applications_app_alloc() {
|
||||
|
@ -45,15 +50,30 @@ static LoaderApplicationsApp* loader_applications_app_alloc() {
|
|||
app->fap_path = furi_string_alloc_set(EXT_PATH("apps"));
|
||||
app->dialogs = furi_record_open(RECORD_DIALOGS);
|
||||
app->storage = furi_record_open(RECORD_STORAGE);
|
||||
app->loader = furi_record_open(RECORD_LOADER);
|
||||
|
||||
app->gui = furi_record_open(RECORD_GUI);
|
||||
app->view_holder = view_holder_alloc();
|
||||
app->loading = loading_alloc();
|
||||
|
||||
view_holder_attach_to_gui(app->view_holder, app->gui);
|
||||
view_holder_set_view(app->view_holder, loading_get_view(app->loading));
|
||||
|
||||
return app;
|
||||
} //-V773
|
||||
|
||||
static void loader_applications_app_free(LoaderApplicationsApp* loader_applications_app) {
|
||||
furi_assert(loader_applications_app);
|
||||
static void loader_applications_app_free(LoaderApplicationsApp* app) {
|
||||
furi_assert(app);
|
||||
|
||||
view_holder_free(app->view_holder);
|
||||
loading_free(app->loading);
|
||||
furi_record_close(RECORD_GUI);
|
||||
|
||||
furi_record_close(RECORD_LOADER);
|
||||
furi_record_close(RECORD_DIALOGS);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
furi_string_free(loader_applications_app->fap_path);
|
||||
free(loader_applications_app);
|
||||
furi_string_free(app->fap_path);
|
||||
free(app);
|
||||
}
|
||||
|
||||
static bool loader_applications_item_callback(
|
||||
|
@ -96,47 +116,38 @@ static void loader_pubsub_callback(const void* message, void* context) {
|
|||
}
|
||||
}
|
||||
|
||||
static void loader_applications_start_app(const char* name) {
|
||||
// start loading animation
|
||||
Gui* gui = furi_record_open(RECORD_GUI);
|
||||
ViewHolder* view_holder = view_holder_alloc();
|
||||
Loading* loading = loading_alloc();
|
||||
|
||||
view_holder_attach_to_gui(view_holder, gui);
|
||||
view_holder_set_view(view_holder, loading_get_view(loading));
|
||||
view_holder_start(view_holder);
|
||||
static void loader_applications_start_app(LoaderApplicationsApp* app) {
|
||||
const char* name = furi_string_get_cstr(app->fap_path);
|
||||
|
||||
// load app
|
||||
FuriThreadId thread_id = furi_thread_get_current_id();
|
||||
Loader* loader = furi_record_open(RECORD_LOADER);
|
||||
FuriPubSubSubscription* subscription =
|
||||
furi_pubsub_subscribe(loader_get_pubsub(loader), loader_pubsub_callback, thread_id);
|
||||
furi_pubsub_subscribe(loader_get_pubsub(app->loader), loader_pubsub_callback, thread_id);
|
||||
|
||||
LoaderStatus status = loader_start_with_gui_error(loader, name, NULL);
|
||||
LoaderStatus status = loader_start_with_gui_error(app->loader, name, NULL);
|
||||
|
||||
if(status == LoaderStatusOk) {
|
||||
furi_thread_flags_wait(APPLICATION_STOP_EVENT, FuriFlagWaitAny, FuriWaitForever);
|
||||
}
|
||||
|
||||
furi_pubsub_unsubscribe(loader_get_pubsub(loader), subscription);
|
||||
furi_record_close(RECORD_LOADER);
|
||||
|
||||
// stop loading animation
|
||||
view_holder_stop(view_holder);
|
||||
view_holder_free(view_holder);
|
||||
loading_free(loading);
|
||||
furi_record_close(RECORD_GUI);
|
||||
furi_pubsub_unsubscribe(loader_get_pubsub(app->loader), subscription);
|
||||
}
|
||||
|
||||
static int32_t loader_applications_thread(void* p) {
|
||||
LoaderApplications* loader_applications = p;
|
||||
LoaderApplicationsApp* loader_applications_app = loader_applications_app_alloc();
|
||||
LoaderApplicationsApp* app = loader_applications_app_alloc();
|
||||
|
||||
while(loader_applications_select_app(loader_applications_app)) {
|
||||
loader_applications_start_app(furi_string_get_cstr(loader_applications_app->fap_path));
|
||||
// start loading animation
|
||||
view_holder_start(app->view_holder);
|
||||
|
||||
while(loader_applications_select_app(app)) {
|
||||
loader_applications_start_app(app);
|
||||
}
|
||||
|
||||
loader_applications_app_free(loader_applications_app);
|
||||
// stop loading animation
|
||||
view_holder_stop(app->view_holder);
|
||||
|
||||
loader_applications_app_free(app);
|
||||
|
||||
if(loader_applications->closed_cb) {
|
||||
loader_applications->closed_cb(loader_applications->context);
|
||||
|
|
Loading…
Reference in a new issue