free.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #include <alloc/free.h>
  2. #include <callback/loader.h>
  3. void free_all(bool should_free_variable_item_list, bool should_free_submenu, void *context)
  4. {
  5. FlipSocialApp *app = (FlipSocialApp *)context;
  6. furi_check(app, "FlipSocialApp is NULL");
  7. if (should_free_submenu)
  8. {
  9. flip_social_free_explore();
  10. free_submenu();
  11. }
  12. if (should_free_variable_item_list)
  13. {
  14. free_variable_item_list();
  15. }
  16. free_text_input();
  17. flip_social_free_friends();
  18. flip_social_free_messages();
  19. flip_social_free_feed_view();
  20. flip_social_free_compose_dialog();
  21. flip_social_free_explore_dialog();
  22. flip_social_free_friends_dialog();
  23. flip_social_free_messages_dialog();
  24. flip_feed_info_free();
  25. free_about_widget(true);
  26. free_about_widget(false);
  27. if (went_to_friends)
  28. {
  29. // flipper_http_deinit();
  30. went_to_friends = false;
  31. }
  32. // free Derek's loader
  33. loader_view_free(app);
  34. }
  35. void free_text_input()
  36. {
  37. if (app_instance->text_input)
  38. {
  39. uart_text_input_free(app_instance->text_input);
  40. app_instance->text_input = NULL;
  41. view_dispatcher_remove_view(app_instance->view_dispatcher, FlipSocialViewTextInput);
  42. }
  43. }
  44. void flip_social_free_explore_dialog()
  45. {
  46. if (app_instance->dialog_explore)
  47. {
  48. dialog_ex_free(app_instance->dialog_explore);
  49. app_instance->dialog_explore = NULL;
  50. view_dispatcher_remove_view(app_instance->view_dispatcher, FlipSocialViewExploreDialog);
  51. }
  52. }
  53. void flip_social_free_friends_dialog()
  54. {
  55. if (app_instance->dialog_friends)
  56. {
  57. dialog_ex_free(app_instance->dialog_friends);
  58. app_instance->dialog_friends = NULL;
  59. view_dispatcher_remove_view(app_instance->view_dispatcher, FlipSocialViewFriendsDialog);
  60. }
  61. }
  62. void flip_social_free_messages_dialog()
  63. {
  64. if (app_instance->dialog_messages)
  65. {
  66. dialog_ex_free(app_instance->dialog_messages);
  67. app_instance->dialog_messages = NULL;
  68. view_dispatcher_remove_view(app_instance->view_dispatcher, FlipSocialViewMessagesDialog);
  69. return;
  70. }
  71. }
  72. void flip_social_free_compose_dialog()
  73. {
  74. if (app_instance->dialog_compose)
  75. {
  76. dialog_ex_free(app_instance->dialog_compose);
  77. app_instance->dialog_compose = NULL;
  78. view_dispatcher_remove_view(app_instance->view_dispatcher, FlipSocialViewComposeDialog);
  79. }
  80. }
  81. void flip_social_free_feed_view()
  82. {
  83. if (app_instance->view_feed)
  84. {
  85. view_free(app_instance->view_feed);
  86. app_instance->view_feed = NULL;
  87. view_dispatcher_remove_view(app_instance->view_dispatcher, FlipSocialViewLoggedInFeed);
  88. }
  89. }
  90. void free_about_widget(bool is_logged_in)
  91. {
  92. if (is_logged_in && app_instance->widget_logged_in_about)
  93. {
  94. widget_free(app_instance->widget_logged_in_about);
  95. app_instance->widget_logged_in_about = NULL;
  96. view_dispatcher_remove_view(app_instance->view_dispatcher, FlipSocialViewLoggedInSettingsAbout);
  97. }
  98. if (!is_logged_in && app_instance->widget_logged_out_about)
  99. {
  100. widget_free(app_instance->widget_logged_out_about);
  101. app_instance->widget_logged_out_about = NULL;
  102. view_dispatcher_remove_view(app_instance->view_dispatcher, FlipSocialViewLoggedOutAbout);
  103. }
  104. }
  105. void flip_social_free_friends(void)
  106. {
  107. if (!flip_social_friends)
  108. {
  109. return;
  110. }
  111. free(flip_social_friends);
  112. flip_social_friends = NULL;
  113. }
  114. void flip_feed_info_free(void)
  115. {
  116. if (!flip_feed_info)
  117. {
  118. return;
  119. }
  120. free(flip_feed_info);
  121. flip_feed_info = NULL;
  122. }
  123. void free_variable_item_list(void)
  124. {
  125. if (app_instance->variable_item_list)
  126. {
  127. variable_item_list_free(app_instance->variable_item_list);
  128. app_instance->variable_item_list = NULL;
  129. view_dispatcher_remove_view(app_instance->view_dispatcher, FlipSocialViewVariableItemList);
  130. }
  131. }
  132. void free_submenu(void)
  133. {
  134. if (!app_instance)
  135. {
  136. return;
  137. }
  138. if (app_instance->submenu)
  139. {
  140. submenu_free(app_instance->submenu);
  141. app_instance->submenu = NULL;
  142. view_dispatcher_remove_view(app_instance->view_dispatcher, FlipSocialViewSubmenu);
  143. }
  144. }