[FL-3422] Loader: exit animation fix (#2860)
Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
25ec09c7eb
commit
dcb49c540f
@ -38,6 +38,11 @@ typedef struct {
|
|||||||
FuriString* fap_path;
|
FuriString* fap_path;
|
||||||
DialogsApp* dialogs;
|
DialogsApp* dialogs;
|
||||||
Storage* storage;
|
Storage* storage;
|
||||||
|
Loader* loader;
|
||||||
|
|
||||||
|
Gui* gui;
|
||||||
|
ViewHolder* view_holder;
|
||||||
|
Loading* loading;
|
||||||
} LoaderApplicationsApp;
|
} LoaderApplicationsApp;
|
||||||
|
|
||||||
static LoaderApplicationsApp* loader_applications_app_alloc() {
|
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->fap_path = furi_string_alloc_set(EXT_PATH("apps"));
|
||||||
app->dialogs = furi_record_open(RECORD_DIALOGS);
|
app->dialogs = furi_record_open(RECORD_DIALOGS);
|
||||||
app->storage = furi_record_open(RECORD_STORAGE);
|
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;
|
return app;
|
||||||
} //-V773
|
} //-V773
|
||||||
|
|
||||||
static void loader_applications_app_free(LoaderApplicationsApp* loader_applications_app) {
|
static void loader_applications_app_free(LoaderApplicationsApp* app) {
|
||||||
furi_assert(loader_applications_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_DIALOGS);
|
||||||
furi_record_close(RECORD_STORAGE);
|
furi_record_close(RECORD_STORAGE);
|
||||||
furi_string_free(loader_applications_app->fap_path);
|
furi_string_free(app->fap_path);
|
||||||
free(loader_applications_app);
|
free(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool loader_applications_item_callback(
|
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) {
|
static void loader_applications_start_app(LoaderApplicationsApp* app) {
|
||||||
// start loading animation
|
const char* name = furi_string_get_cstr(app->fap_path);
|
||||||
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);
|
|
||||||
|
|
||||||
// load app
|
// load app
|
||||||
FuriThreadId thread_id = furi_thread_get_current_id();
|
FuriThreadId thread_id = furi_thread_get_current_id();
|
||||||
Loader* loader = furi_record_open(RECORD_LOADER);
|
|
||||||
FuriPubSubSubscription* subscription =
|
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) {
|
if(status == LoaderStatusOk) {
|
||||||
furi_thread_flags_wait(APPLICATION_STOP_EVENT, FuriFlagWaitAny, FuriWaitForever);
|
furi_thread_flags_wait(APPLICATION_STOP_EVENT, FuriFlagWaitAny, FuriWaitForever);
|
||||||
}
|
}
|
||||||
|
|
||||||
furi_pubsub_unsubscribe(loader_get_pubsub(loader), subscription);
|
furi_pubsub_unsubscribe(loader_get_pubsub(app->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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t loader_applications_thread(void* p) {
|
static int32_t loader_applications_thread(void* p) {
|
||||||
LoaderApplications* loader_applications = 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)) {
|
// start loading animation
|
||||||
loader_applications_start_app(furi_string_get_cstr(loader_applications_app->fap_path));
|
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) {
|
if(loader_applications->closed_cb) {
|
||||||
loader_applications->closed_cb(loader_applications->context);
|
loader_applications->closed_cb(loader_applications->context);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user