From: subhransu mohanty Date: Wed, 13 Mar 2019 10:13:15 +0000 (+0900) Subject: rlottie/example: sort the resource list before displaying. X-Git-Tag: submit/tizen/20190318.043137~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=099b567198651326f9af186e1f9bcd7147fa371c;p=platform%2Fcore%2Fuifw%2Flottie-player.git rlottie/example: sort the resource list before displaying. Change-Id: Ida87b1a7f4f353b236b0009f8538a436cfee5014 --- diff --git a/example/evasapp.cpp b/example/evasapp.cpp index c9170b8..943fbba 100644 --- a/example/evasapp.cpp +++ b/example/evasapp.cpp @@ -18,6 +18,7 @@ #include "evasapp.h" #include +#include static void _on_resize(Ecore_Evas *ee) @@ -132,6 +133,9 @@ EvasApp::jsonFiles(const std::string &dirName, bool recurse) } closedir(d); } + + std::sort(result.begin(), result.end(), [](auto & a, auto &b){return a < b;}); + return result; } diff --git a/example/lottieviewer.cpp b/example/lottieviewer.cpp index 92f90bb..2d6bd40 100644 --- a/example/lottieviewer.cpp +++ b/example/lottieviewer.cpp @@ -18,6 +18,7 @@ #include #include "lottieview.h" +#include "evasapp.h" #include #include #include @@ -147,10 +148,7 @@ create_layout(Evas_Object *parent, const char *file) //LOTTIEVIEW LottieView *view = new LottieView(evas_object_evas_get(layout), renderMode); - std::string filePath = DEMO_DIR; - filePath +=file; - - view->setFilePath(filePath.c_str()); + view->setFilePath(file); view->setSize(500, 500); //IMAGE from LOTTIEVIEW @@ -205,7 +203,9 @@ static char * _gl_text_get(void *data, Evas_Object *obj, const char *part) { ItemData *id = (ItemData *) data; - return strdup(jsonFiles[id->index].c_str()); + const char *ptr = strrchr(jsonFiles[id->index].c_str(), '/'); + int len = int(ptr + 1 - jsonFiles[id->index].c_str()); // +1 to include '/' + return strdup(jsonFiles[id->index].substr(len).c_str()); } static void @@ -219,8 +219,7 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED) Evas_Object *win, *nf, *genlist; Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new(); ItemData *itemData; - DIR *dir; - struct dirent *ent; + if (argc > 1) { if (!strcmp(argv[1], "--disable-render")) @@ -249,17 +248,7 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED) itc->func.text_get = _gl_text_get; itc->func.del = _gl_del; - std::string rscPath = DEMO_DIR; - - dir = opendir(rscPath.c_str()); - while ((ent = readdir(dir)) != NULL) { - if (!strncmp(ent->d_name + (strlen(ent->d_name) - 4), "json", 4)) { - jsonFiles.push_back(ent->d_name); - } - } - closedir(dir); - - std::sort(jsonFiles.begin(), jsonFiles.end(), [](auto & a, auto &b){return a < b;}); + jsonFiles = EvasApp::jsonFiles(DEMO_DIR); for (uint i = 0; i < jsonFiles.size(); i++) { itemData = (ItemData *)calloc(sizeof(ItemData), 1);