[null,null,["最后更新时间 (UTC):2018-05-03。"],[],[],null,["# Tinder solves dating-app pain points with Android Architecture Components\n\n[Tinder](https://tinder.com) is the world's most popular app for\nmeeting new people. Known for changing how people meet and date, it empowers\nusers to swipe right to connect and chat with others. Tinder sparks over 26 million\nmatches a day, with more than 20 billion matches made since their launch in\n2012.\n\nThe company needed to scale up the\n[app](https://play.google.com/store/apps/details?id=com.tinder)\nquickly, based on user demand, but their database implementation was left over\nfrom their early days, making it increasingly more complicated to expand upon.\nThey also had a view-heavy architecture to reduce lifecycle complexities, but\nneeded to know which lifecycle events were specific to an activity. They lacked\na consistent framework for handling tasks such as marshalling\n[`Cursor`](/reference/android/database/Cursor) objects into domain objects, making\ndatabase migrations, or consistently performing queries.\n\nWhat they did\n-------------\n\n**Figure 1:** A photo of a photographer on Tinder\n\nTinder turned to [Android Architecture\nComponents](/topic/libraries/architecture) for solutions for upgrading their\ncode. They used [`Lifecycle`](/reference/androidx/lifecycle/Lifecycle) to\nlet a [`View`](/reference/android/view/View) observe its host activity's\nlifecycle, and they used [`LifecycleObserver`](/reference/androidx/lifecycle/LifecycleObserver)\nto facilitate a decentralized plugin architecture and to prevent bloat in\n[`Presenter`](/reference/androidx/leanback/widget/Presenter),\n[`Activity`](/reference/android/app/Activity), and [`View`](/reference/android/view/View)\nobjects. The [Room persistence library](/topic/libraries/architecture/room)\nprovided a turnkey method for defining, managing, and querying their local\ndatabase.\n\nThe Tinder development team was able to implement the\n[`LifecycleObserver`](/reference/androidx/lifecycle/LifecycleObserver) and\nplugin architecture in only two weeks, while seamlessly implementing Room for\ntheir internal Ads SDK took just two days.\n\u003e \"We no longer had to invest significant time managing the Activity Lifecycle\n\u003e inside of plugins or views,\" says Andy Lawton, Head of Android at Tinder.\n\u003e \"Room's design is well- thought-out and makes our persistence layer easy to\n\u003e implement. Using Room for the internal Ads SDK probably saved a week of time\n\u003e in upfront development.\"\n\nResults\n-------\n\nTinder was so pleased with their results with their Ads SDK that they're\nmigrating their entire database layer to Room. Testing was easy, and Room's\nprotection against forgetting to unregister something reduced memory leaks.\nAndroid Architecture Components is also helping to produce smaller memory\nfootprints.\n\u003e \"Android Architecture Components has provided a prescription for solving many\n\u003e of the pain points that developers face at all different scales,\" Lawton says.\n\u003e \"Through the use of lifecycle-aware components, Tinder has managed to improve\n\u003e developer productivity, testability, and modularity, while being conducive to\n\u003e a view-first architecture. Room eliminates the need for other solutions for\n\u003e managing SQLite, and turns database management and querying into an exercise\n\u003e in configuration.\"\n\nMetric\n------\n\n**500+** lines of code removed from `MainActivity` via\n[`LifecycleObserver`](/reference/androidx/lifecycle/LifecycleObserver) /\nplugin architecture\n\nGet started\n-----------\n\nAndroid Architecture Components is open to all developers as part of Android\nJetpack. [Get started with Android Architecture\nComponents](/topic/libraries/architecture)."]]