2017-10-31 09:50:22 -07:00
|
|
|
#define EFL_EO_API_SUPPORT 1
|
|
|
|
#define EFL_BETA_API_SUPPORT 1
|
2017-10-26 03:20:38 -07:00
|
|
|
|
|
|
|
#include <Eina.h>
|
2017-11-15 10:22:44 -08:00
|
|
|
#include <Efl_Core.h>
|
2017-10-26 03:20:38 -07:00
|
|
|
|
2017-11-15 10:22:44 -08:00
|
|
|
/*
|
2017-12-12 02:45:30 -08:00
|
|
|
* This helper method triggers lifecycle events for the purpose of this demo.
|
|
|
|
* efl_pause and efl_resume may never be called for your application, depending
|
|
|
|
* on your environment, therefore this demo triggers them directly to show how
|
|
|
|
* you can respond.
|
2017-10-26 03:20:38 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2017-12-12 02:45:30 -08:00
|
|
|
_lifecycle_simulation(void *data, const Efl_Event *ev EINA_UNUSED)
|
2017-10-26 03:20:38 -07:00
|
|
|
{
|
|
|
|
Efl_Loop *loop = data;
|
2017-12-12 02:45:30 -08:00
|
|
|
static int called = 0;
|
2017-10-26 03:20:38 -07:00
|
|
|
|
2017-12-12 02:45:30 -08:00
|
|
|
switch (called)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
// First call, pause the application
|
|
|
|
efl_event_callback_call(loop, EFL_LOOP_EVENT_PAUSE, NULL);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
// Second call, resume the application
|
|
|
|
efl_event_callback_call(loop, EFL_LOOP_EVENT_RESUME, NULL);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Last call, exit the application
|
|
|
|
efl_exit(0);
|
|
|
|
}
|
2017-10-26 03:20:38 -07:00
|
|
|
|
2017-12-12 02:45:30 -08:00
|
|
|
called++;
|
2017-10-26 03:20:38 -07:00
|
|
|
}
|
|
|
|
|
2017-11-30 02:47:40 -08:00
|
|
|
EAPI_MAIN void
|
2017-10-26 03:20:38 -07:00
|
|
|
efl_pause(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
|
|
|
|
{
|
|
|
|
printf("Lifecycle: paused\n");
|
|
|
|
}
|
|
|
|
|
2017-11-30 02:47:40 -08:00
|
|
|
EAPI_MAIN void
|
2017-10-26 03:20:38 -07:00
|
|
|
efl_resume(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
|
|
|
|
{
|
|
|
|
printf("Lifecycle: resumed\n");
|
|
|
|
}
|
2017-11-15 10:22:44 -08:00
|
|
|
|
2017-11-30 02:47:40 -08:00
|
|
|
EAPI_MAIN void
|
2017-10-26 03:20:38 -07:00
|
|
|
efl_terminate(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
|
|
|
|
{
|
|
|
|
printf("Lifecycle: terminated\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI_MAIN void
|
|
|
|
efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
|
|
|
|
{
|
|
|
|
printf("Lifecycle: launched\n");
|
|
|
|
|
2017-12-12 02:45:30 -08:00
|
|
|
// The timer function will trigger the chain of simulated events to show
|
|
|
|
// how an app could respond to system lifecycle events.
|
|
|
|
efl_add(EFL_LOOP_TIMER_CLASS, ev->object,
|
|
|
|
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, _lifecycle_simulation, ev->object),
|
|
|
|
efl_loop_timer_interval_set(efl_added, 1.0));
|
2017-10-26 03:20:38 -07:00
|
|
|
}
|
|
|
|
EFL_MAIN_EX()
|
|
|
|
|