برنامه BeautyPlus خوانایی را تا 15 درصد با اجزای معماری اندروید افزایش می دهد
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
BeautyPlus که در سال 2013 معرفی شد، یکی از محبوبترین برنامههای ویرایش عکس در جهان است که توسط هنرمندان آرایش، عکاسان و عکاسان معمولی تلفن همراه استفاده میشود. حدود 50 میلیون نفر هر ماه از این برنامه برای ویرایش و افزودن فیلتر به سلفی ها، تصاویر و ویدیوهای خود استفاده می کنند. این برنامه که توسط شرکت فناوری چینی Xiamen Meitu توسعه یافته است (که مخصوصاً در مجموعه سلفی محبوب است) برای همه چیز از اصلاح رنگ پوست و روشن کردن لبخند گرفته تا ویژگی های لاغری و از بین بردن لکه ها، همه با چند کشیدن و کشیدن ساده استفاده می شود. کلیک می کند.
با توجه به اینکه این شرکت بهروزرسانیهای مکرر برنامه را انجام میدهد، به تعداد زیادی توسعهدهنده نیاز دارد. اما، با گذشت زمان، معماری زیربنایی بدون یکنواختی و وضوح رشد کرد. تیم در حال حرکت به راهی نیاز داشت تا توسعه دهندگان همکار خود را در جریان نگه دارند و در عین حال مدیریت چرخه عمر را ساده کرده و مسائل مربوط به به روز کردن رابط کاربری ناهمزمان را حل کنند.
شکل 1: نمونه جلسه ویرایش عکس در BeautyPlus
کاری که آنها انجام دادند
اجزای معماری اندروید ابزارهای مورد نیاز توسعهدهندگان را فراهم میکنند تا کد برنامه را مختصر، پایدار و آسانتر کنند تا مهندسان جدید هنگام نصب آنها را بخوانند.
از جمله مؤلفههایی که توسعهدهندگان BeautyPlus شروع به استفاده از آن کردند، ViewModel است که پردازش منطقی آسانتر را با بهروزرسانیهای فعالیت و قطعه امکانپذیر میسازد. ViewModel برای ذخیره و مدیریت دادههای مرتبط با رابط کاربری به روشی مبتنی بر چرخه حیات طراحی شده است که به چرخه حیات سایر اجزای برنامه احترام میگذارد.
آنها همچنین از مؤلفه LiveData ، یک کلاس دارنده داده قابل مشاهده که از چرخه حیات نیز آگاه است، استفاده کردند تا اطمینان حاصل شود که رابط کاربری با وضعیت داده مطابقت دارد. تیم استفاده از این اجزای معماری اندروید را آسان بدون مواجهه با هیچ مشکلی یافت و فواید آن به سرعت قابل توجه بود.
نتایج
به لطف اجزای معماری اندروید، اپلیکیشن BeautyPlus بلافاصله 5 درصد کد کمتری داشت و 15 درصد خواناتر بود. همچنین معماری یکپارچهتر بود و در زمان و تلاش توسعهدهندگان صرفهجویی میکرد و سرعت پیشرفت را برای توسعهدهندگان جدید آسانتر میکرد. علاوه بر این، نشت حافظه کمتری وجود داشت، تازهسازی دادهها آسانتر شد و توسعهدهندگان دیگر نگران بهروزرسانی رابط کاربری ناهمزمان نبودند.
ژنگ سونگین، مدیر ارشد توسعه میگوید: «وقتی از ViewModel و LiveData برای BeautyPlus استفاده کردیم، کد مختصر و خواناتر شد و معماری کد یکپارچه شد. "عملکرد چرخه عمر برنامه با خیال راحت مدیریت شد و ثبات نیز بهبود یافت."
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2018-05-05 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2018-05-05 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# BeautyPlus app increases readability by 15% with Android Architecture Components\n\nIntroduced in 2013,\n[BeautyPlus](https://play.google.com/store/apps/details?id=com.commsource.beautyplus)\nis one of the world's most popular photo-editing apps, used by makeup artists,\nphotographers, and ordinary mobile phone snappers. About 50 million people use\nthe app every month to edit and add filters to their selfies, pictures, and\nvideos. Developed by China's Xiamen Meitu Technology Co., Ltd., the app (which\nis particularly popular with the selfie set) is used for everything from\ncorrecting skin tone and brightening smiles to slimming features and airbrushing\naway blemishes, all with a few simple drags and clicks.\n\nGiven the company makes frequent updates to the app, it requires a large number\nof developers. But, over time, the underlying architecture grew to lack\nuniformity and clarity. The fast-moving team needed a way to keep their\ncollaborating developers in the loop while simplifying lifecycle management and\nresolving issues related to refreshing the asynchronous UI. \n**Figure 1:** A sample photo-editing session in BeautyPlus\n\nWhat they did\n-------------\n\n[Android Architecture Components](/topic/libraries/architecture) provided the\ntools that the developers needed to make the app's code concise, stable, and\neasier for new engineers to read as they onboard.\n\nAmong the components the BeautyPlus developers began using is\n[`ViewModel`](/topic/libraries/architecture/viewmodel), which enables easier\nlogic processing with activity and fragment updates. `ViewModel` is designed to\nstore and manage UI-related data in a lifecycle-conscious way that respects the\nlifecycle of other app components.\n\nThey also leveraged the [`LiveData`](/topic/libraries/architecture/livedata)\ncomponent, an observable data-holder class that's also lifecycle-aware to help\nensure that the UI matches the data state. The team found these Android\nArchitecture Components easy to use without encountering any problems---and the\nbenefits were quickly noticeable.\n\nResults\n-------\n\nThanks to Android Architecture Components, the BeautyPlus app immediately had 5%\nleaner code and was 15% more readable. The architecture was also more unified,\nsaving developers time and effort, and making it easier for new developers to\nget up to speed quickly. In addition, there were fewer memory leaks, refreshing\ndata became easier, and developers no longer had to worry about updating the\nasynchronous UI.\n\u003e \"When we used ViewModel and LiveData for BeautyPlus, the code became more\n\u003e concise and readable, and the architecture of the code was unified,\" says\n\u003e Zheng Songyin, senior development manager. \"The operation of the lifecycle of\n\u003e the app was managed safely, and the stability improved, too.\"\n\nGet started\n-----------\n\nAndroid Architecture Components is open to all developers. [Get\nstarted with Android Architecture Components](/topic/libraries/architecture)."]]