{"id":417877,"date":"2024-06-30T01:49:06","date_gmt":"2024-06-30T01:49:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=417877"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-30T01:49:06","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=417877","title":{"rendered":"<span>\u0420\u0430\u0437\u0431\u043e\u0440 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u0430\u043c\u0438<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c \u0438\u0434\u0435\u044f \u0440\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0441 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u043c\u044b \u0441 \u0434\u0440\u0443\u0437\u044c\u044f\u043c\u0438 \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u043b\u0438 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0443 \u043f\u043e\u0434\u0430\u0440\u043a\u0438 \u0432 \u0412\u041a (\u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0440\u043e\u0432\u0435\u0440\u044b) \u0438 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044f\u043b\u0438 \u043a \u043d\u0438\u043c \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u044b. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0448\u0443\u0442\u043e\u043a \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043b\u0438\u0447\u043d\u043e \u0431\u044b\u043b \u0441\u0430\u0439\u0442 <a href=\"https:\/\/baneks.ru\/\" rel=\"noopener noreferrer nofollow\">https:\/\/baneks.ru\/<\/a>. \u041d\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043d\u0435\u0433\u043e \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u044b \u0431\u044b\u043b\u043e \u0434\u043e \u0436\u0443\u0442\u0438 \u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e, \u043f\u043b\u044e\u0441 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u0432\u0448\u0438\u0435\u0441\u044f. \u0421 \u044d\u0442\u043e\u0433\u043e \u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0430:<\/p>\n<ol>\n<li>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u0432\u0448\u0438\u0445\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<\/li>\n<\/ol>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/h2>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043a\u0430\u043a \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0442\u0430\u043a \u0438 \u043f\u0430\u0440\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0445:<\/p>\n<h4>Network<\/h4>\n<pre><code class=\"kotlin\">implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.5.0' implementation 'com.squareup.retrofit2:converter-scalars:2.9.0' implementation 'com.google.code.gson:gson:2.8.9' implementation 'org.jsoup:jsoup:1.13.1'<\/code><\/pre>\n<p>\u0422.\u043a. \u043d\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a API \u0441\u0430\u0439\u0442\u0430, \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432 \u043f\u0430\u0440\u0441\u0438\u043b\u0441\u044f HTML \u043a\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/jsoup.org\/\" rel=\"noopener noreferrer nofollow\">jsoup<\/a>. \u0414\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f <a href=\"https:\/\/square.github.io\/retrofit\/\" rel=\"noopener noreferrer nofollow\">retrofit<\/a>.<\/p>\n<h4>Database<\/h4>\n<pre><code class=\"kotlin\">implementation \"androidx.room:room-runtime:2.4.3\" kapt \"androidx.room:room-compiler:2.4.3\"<\/code><\/pre>\n<p>Room \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u0432\u0448\u0438\u0445\u0441\u044f \u0430\u043d\u0435\u043a\u043e\u0432 \u043f\u0443\u0442\u0451\u043c \u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0411\u0414 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435<\/p>\n<h4>DI<\/h4>\n<pre><code class=\"kotlin\">implementation \"com.google.dagger:hilt-android:2.44\" kapt \"com.google.dagger:hilt-compiler:2.44\"<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 DI \u0431\u044b\u043b \u0432\u0437\u044f\u0442 Hilt \u043a\u0430\u043a \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0430\u044f \u043f\u043e\u0434 \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430.<\/p>\n<h4>Design<\/h4>\n<pre><code class=\"kotlin\">implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.appcompat:appcompat:1.5.1' implementation 'com.google.android.material:material:1.7.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.recyclerview:recyclerview:1.2.1' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'androidx.fragment:fragment-ktx:1.5.4' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0'  implementation('com.mikepenz.materialdrawer:library:0.9.5@aar') {     transitive = true }<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u043f\u043e\u043c\u0438\u043c\u043e Jetpack-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u041c\u0430\u0439\u043a\u0430 \u041f\u0435\u043d\u0437\u0430 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 Material Drawer, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043a\u0430\u043a \u0431\u043e\u043a\u043e\u0432\u043e\u0435 \u043c\u0435\u043d\u044e \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<h2>\u0420\u0430\u0437\u0431\u043e\u0440 \u043a\u043e\u0434\u0430<\/h2>\n<p>\u0420\u0430\u0437\u0431\u043e\u0440 \u043a\u043e\u0434\u0430 \u0431\u0443\u0434\u0435\u043c \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u043d\u0435 \u0432\u0435\u0441\u044c, \u043b\u0438\u0448\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b.<\/p>\n<pre><code class=\"kotlin\">@AndroidEntryPoint class MainActivity : AppCompatActivity() {     override fun onCreate(savedInstanceState: Bundle?) {         super.onCreate(savedInstanceState)         setContentView(R.layout.activity_main)         val (toolbar: Toolbar, fragmentContainer) = createToolbar()         createDrawer(toolbar, fragmentContainer)         initialize(savedInstanceState, fragmentContainer)     }      private fun initialize(savedInstanceState: Bundle?, fragmentContainer: Int) {         val isFragmentContainerEmpty = (savedInstanceState == null)         if (isFragmentContainerEmpty) {             supportFragmentManager.commit {                 setReorderingAllowed(true)                 add(fragmentContainer, JokeListFragment.get())                 addToBackStack(\"joke_list\")             }         }     }      private fun createToolbar(): Pair&lt;Toolbar, Int> {         val toolbar: Toolbar = findViewById&lt;View>(R.id.toolbar) as Toolbar         toolbar.setTitle(R.string.drawer_item_random_joke)         setSupportActionBar(toolbar)         supportActionBar!!.setDisplayHomeAsUpEnabled(true)         val fragmentContainer = R.id.fragmentContainer         return Pair(toolbar, fragmentContainer)     }      private fun createDrawer(toolbar: Toolbar, fragmentContainer: Int) {         Drawer()             .withActivity(this)             .withToolbar(toolbar)             .withActionBarDrawerToggle(true)             .withHeader(R.layout.drawer_header)             .addDrawerItems(                 PrimaryDrawerItem().withName(R.string.drawer_item_random_joke)                     .withIcon(getDrawable(R.drawable.random)),                 PrimaryDrawerItem().withName(R.string.drawer_item_like)                     .withIcon(getDrawable(R.drawable.heart)),                 PrimaryDrawerItem().withName(R.string.drawer_item_best_joke)                     .withIcon(getDrawable(R.drawable.crown))             )             .withOnDrawerItemClickListener { _, _, position, _, _ ->                 when (position) {                     1 -> {                         supportFragmentManager.commit {                             setReorderingAllowed(true)                             replace(fragmentContainer, JokeListFragment.get())                             addToBackStack(\"joke_list\")                             toolbar.setTitle(R.string.drawer_item_random_joke)                         }                     }                     2 -> {                         supportFragmentManager.commit {                             setReorderingAllowed(true)                             replace(fragmentContainer, LikeListFragment.newInstance())                             addToBackStack(\"like_list\")                         }                         toolbar.setTitle(R.string.drawer_item_like)                     }                     3 -> {                         supportFragmentManager.commit {                             setReorderingAllowed(true)                             replace(fragmentContainer, BestListFragment.get())                             addToBackStack(\"best_list\")                         }                         toolbar.setTitle(R.string.drawer_item_best_joke)                     }                 }             }             .build()     } }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c <code>MainActivity<\/code> \u0441 \u043f\u0430\u043d\u0435\u043b\u044c\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 (<code>Toolbar<\/code>) \u0438 \u0431\u043e\u043a\u043e\u0432\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u044c\u044e (<code>Navigation Drawer<\/code>). \u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0431\u043e\u043a\u043e\u0432\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043c\u0435\u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 <code>fragmentContainer<\/code> \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u043f\u0430\u043d\u0435\u043b\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0431\u043e\u043a\u043e\u0432\u0443\u044e \u043f\u0430\u043d\u0435\u043b\u044c \u0438 \u043a\u043d\u043e\u043f\u043a\u0443 &#171;\u0434\u043e\u043c\u043e\u0439&#187; \u043d\u0430 \u043f\u0430\u043d\u0435\u043b\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u043d\u0430\u0437\u0430\u0434.  <\/p>\n<pre><code class=\"kotlin\">private const val VIEW_TYPE_ITEM = 0 private const val VIEW_TYPE_LOAD = 1  class JokeAdapter(private val onItemClicked: (Joke, ToggleButton) -> Unit) :     ListAdapter&lt;Joke, ViewHolder>(JokeDiffCallback()) {      private class LoadHolder(view: View) : ViewHolder(view)      override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {         return if (viewType == VIEW_TYPE_ITEM) {             val view =                 LayoutInflater.from(parent.context)                     .inflate(R.layout.joke_list_item, parent, false)             JokeHolder(view){                 onItemClicked(currentList[it], view.findViewById(R.id.like_button))             }         } else {             val view =                 LayoutInflater.from(parent.context)                     .inflate(R.layout.progress_loading, parent, false)             LoadHolder(view)         }     }      override fun onBindViewHolder(holder: ViewHolder, position: Int) {         if (holder is JokeHolder) {             val joke = getItem(position)             holder.bind(joke)         }      }      fun addLoadingView() {         submitList(ArrayList(currentList + null))         notifyItemInserted(currentList.lastIndex)     }      fun deleteLoadingView() {         if (currentList.size != 0) {             submitList(ArrayList(currentList - currentList.last()))             notifyItemRemoved(currentList.size)         }     }      override fun getItemViewType(position: Int): Int {         return if (getItem(position) == null) {             VIEW_TYPE_LOAD         } else {             VIEW_TYPE_ITEM         }     } }<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 <code>JokeAdapter<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043f\u0438\u0441\u043a\u0430 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432 \u0441 <code>RecyclerView<\/code> \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438.<\/p>\n<p>\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u0430\u0439\u043b\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0432\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b: <code>VIEW_TYPE_ITEM<\/code> \u0438 <code>VIEW_TYPE_LOAD<\/code>. \u041e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u0432 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0435. <code>VIEW_TYPE_ITEM<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u043f\u0438\u0441\u043a\u0430 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432, \u0430 <code>VIEW_TYPE_LOAD<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438.<\/p>\n<p>\u041a\u043b\u0430\u0441\u0441 <code>JokeAdapter<\/code> \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 <code>ListAdapter<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u043e\u043c <code>RecyclerView.Adapter<\/code> \u0438 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0410\u0434\u0430\u043f\u0442\u0435\u0440 \u0438\u043c\u0435\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 <code>LoadHolder<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 <code>ViewHolder<\/code> \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0412 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u043b\u044f\u043c\u0431\u0430, \u0442.\u043a. \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e \u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445.<\/p>\n<pre><code class=\"kotlin\">class JokeHolder(view: View, onItemClicked: (Int) -> Unit) : RecyclerView.ViewHolder(view),     View.OnLongClickListener {      val context = view.context     @Inject     lateinit var repository: JokeRepository     private var clipboard: ClipboardManager =         context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager     private val jokeText: TextView = view.findViewById(R.id.joke_text)     private val likeButton: ToggleButton = view.findViewById(R.id.like_button)     private lateinit var joke: Joke      init {         jokeText.setOnLongClickListener(this)         likeButton.setOnClickListener {             onItemClicked(bindingAdapterPosition)         }     }      fun bind(joke: Joke) {         this.joke = joke         jokeText.text = joke.text         likeButton.isChecked = joke.isLiked     }      override fun onLongClick(p0: View?): Boolean {         val clip = ClipData.newPlainText(\"Text of joke\", jokeText.text)         clipboard.setPrimaryClip(clip)         Toast.makeText(context, \"Text copied\", Toast.LENGTH_SHORT).show()         return true     } }<\/code><\/pre>\n<p>\u041a\u043b\u0430\u0441\u0441 <code>JokeHolder<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 <code>ViewHolder<\/code> \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432 \u0432 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0435 <code>JokeAdapter<\/code>. \u041e\u043d \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 <code>RecyclerView.ViewHolder<\/code> \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>View.OnLongClickListener<\/code> \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u043e\u043b\u0433\u043e\u0433\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u043f\u0438\u0441\u043a\u0430.  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>onLongClick<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0434\u043e\u043b\u0433\u043e\u043c \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 <code>jokeText<\/code>. \u041e\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442 <code>ClipData<\/code> \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u0430 \u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e \u0432 \u0431\u0443\u0444\u0435\u0440 \u043e\u0431\u043c\u0435\u043d\u0430. \u0417\u0430\u0442\u0435\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0435\u043a\u0441\u0442\u0430.  <\/p>\n<pre><code class=\"kotlin\">@Singleton class JokeFetcher @Inject constructor(private val jokeApi: JokeApi) {     suspend fun fetchJokeByNumberAsync(numberOfJoke: Int): Deferred&lt;Joke> {         return CoroutineScope(Dispatchers.IO).async {             try {                 val textOfJoke =                     jokeApi.getRandomJoke(numberOfJoke).body().toString().getJokeFromResponse()                 Joke(textOfJoke, numberOfJoke)             } catch (e: Exception) {                 Joke(\"Default\", 0)             }         }     }      private fun String.getJokeFromResponse(): String {         return this             .substringAfter(\"\"\"name=\"description\" content=\"\"\"\")             .substringBefore(\"\"\"\">\"\"\")     }      fun getBestJokesListAsync(): Deferred&lt;List&lt;Int>> {         return CoroutineScope(Dispatchers.IO).async {             try {                 val response = Jsoup.connect(\"https:\/\/baneks.ru\/top\").get()                 val list = response.select(\"article\").select(\"a\")                     .map { it.attr(\"href\")}                     .map { it.substringAfter(\"\/\").toInt()}                 list             } catch (e: Exception) {                 Log.d(TAG, \"getBestJokesListAsync error\",e)                 MutableList(0) { 0 }             }         }     } }<\/code><\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>fetchJokeByNumberAsync<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u0430 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u043d\u043e\u043c\u0435\u0440\u0443. \u041e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 (<code>Deferred&lt;Joke><\/code>). \u0412\u043d\u0443\u0442\u0440\u0438 \u0441\u043e\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u043a <code>jokeApi<\/code> \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <code>jokeApi.getRandomJoke(numberOfJoke)<\/code>. \u0417\u0430\u0442\u0435\u043c \u0438\u0437 \u043e\u0442\u0432\u0435\u0442\u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0441\u0442 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>getJokeFromResponse()<\/code>, \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442 <code>Joke<\/code> \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0438 \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u0430. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u0443\u0434\u0430\u043b\u0441\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442 <code>Joke<\/code> \u0441 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>getBestJokesListAsync<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0432\u0435\u0431-\u0441\u043a\u0440\u0430\u043f\u0438\u043d\u0433 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Jsoup \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u044b \u0441 \u0441\u0430\u0439\u0442\u0430. \u0417\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u0441\u044b\u043b\u043e\u043a, \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0445 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u044d\u0442\u0438\u0445 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 \u0432 \u0432\u0438\u0434\u0435 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 (<code>Deferred&lt;List&lt;Int>><\/code>). \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 \u0441\u043a\u0440\u0430\u043f\u0438\u043d\u0433 \u043d\u0435 \u0443\u0434\u0430\u043b\u0441\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a.<\/p>\n<p>\u041f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>getJokeFromResponse<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u0430 \u0438\u0437 \u043e\u0442\u0432\u0435\u0442\u0430 API. \u041e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u0442\u0440\u043e\u043a\u0438 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u0430.<\/p>\n<pre><code class=\"kotlin\">private const val TAG = \"BestListFragment\" private const val LOAD_THRESHOLD = 3  @AndroidEntryPoint class BestListFragment : Fragment() {     private val bestListViewModel: BestListViewModel by viewModels()     private lateinit var recyclerView: RecyclerView     @Inject     lateinit var repository: JokeRepository     private var isLoading = false      private var adapter: JokeAdapter = JokeAdapter { joke, likeBtn ->         val newJoke = Joke(joke.text, joke.number, isLiked = true)         repository.likeJoke(newJoke)         if (likeBtn.isChecked) {             repository.likeJoke(joke)             joke.isLiked = true             adapterChange(joke)         } else {             repository.dislikeJoke(joke)             joke.isLiked = false             adapterChange(joke)         }     }      fun adapterChange(joke: Joke) {         adapter.notifyItemChanged(adapter.currentList.indexOf(joke))     }      private lateinit var layoutManager: LinearLayoutManager      override fun onCreateView(         inflater: LayoutInflater,         container: ViewGroup?,         savedInstanceState: Bundle?     ): View? {         val view = inflater.inflate(R.layout.fragment_best_list, container, false)         createRecyclerView(view)         return view     }      private fun createRecyclerView(view: View) {         recyclerView = view.findViewById(R.id.best_joke_recycler_view)         layoutManager = LinearLayoutManager(context)         recyclerView.layoutManager = layoutManager         recyclerView.adapter = adapter         addScrollerListener()     }      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {         super.onViewCreated(view, savedInstanceState)         createListeners()     }      private fun createListeners() {         bestListViewModel.jokeLiveData.observe(             viewLifecycleOwner         ) { jokes ->             adapter.submitList(ArrayList(jokes))             Log.d(TAG, jokes.size.toString())         }          bestListViewModel.isLoadingLiveData.observe(             viewLifecycleOwner         ) { isLoading ->             this.isLoading = isLoading             if (isLoading) {                 adapter.addLoadingView()             } else {                 adapter.deleteLoadingView()             }         }          bestListViewModel.jokesFromDBLiveData.observe(             viewLifecycleOwner         ) { list ->             if (list.isNotEmpty() &amp;&amp; adapter.currentList.isNotEmpty()) {                 adapter.currentList.forEach {                     if (it != null) it.isLiked = it in list                 }             } else {                 adapter.currentList.forEach {                     if (it != null) it.isLiked = false                 }             }             adapter.notifyDataSetChanged()         }     }      private fun addScrollerListener() {         recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {             override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {                 super.onScrolled(recyclerView, dx, dy)                 if (!isLoading) {                     if (layoutManager.findLastVisibleItemPosition() ==                         adapter.currentList.size - LOAD_THRESHOLD                     ) {                         bestListViewModel.getBestJokeList()                     }                 }             }         })     }      companion object {         private var INSTANCE: BestListFragment? = null          fun initialize() {             if (INSTANCE == null) {                 INSTANCE = BestListFragment()             }         }          fun get(): BestListFragment {             return INSTANCE ?: throw IllegalStateException(\"JokeRepository must be initialized\")         }     } }<\/code><\/pre>\n<p>\u041a\u043b\u0430\u0441\u0441 <code>BestListFragment<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043b\u0443\u0447\u0448\u0438\u0445 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432.<\/p>\n<p>\u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430 <code>TAG<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043c\u0435\u0442\u043a\u0443 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438. \u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430 <code>LOAD_THRESHOLD<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u043e\u0440\u043e\u0433 \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0438, \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432.<\/p>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 <code>BestListFragment<\/code> \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. <code>bestListViewModel<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <code>BestListViewModel<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. <code>repository<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <code>JokeRepository<\/code>, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. <code>isLoading<\/code> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p><code>adapter<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <code>JokeAdapter<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432 \u0441 <code>RecyclerView<\/code>. \u041e\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>onItemClicked<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 &#171;like&#187; \u0434\u043b\u044f \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u0430. \u0412\u043d\u0443\u0442\u0440\u0438 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u0430 \u0441 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c <code>isLiked<\/code> \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b <code>likeJoke<\/code> \u0438\u043b\u0438 <code>dislikeJoke<\/code> \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f. \u0417\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u043f\u0443\u0442\u0435\u043c \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>adapterChange<\/code>.<\/p>\n<p><code>createRecyclerView<\/code> \u0441\u043e\u0437\u0434\u0430\u0435\u0442 <code>RecyclerView<\/code> \u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u0435\u0433\u043e. \u041e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>LinearLayoutManager<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u043a\u0438, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0438.<\/p>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 <code>onViewCreated<\/code> \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0438 \u0434\u043b\u044f <code>jokeLiveData<\/code>, <code>isLoadingLiveData<\/code> \u0438 <code>jokesFromDBLiveData<\/code> \u0438\u0437 <code>bestListViewModel<\/code>. \u041a\u043e\u0433\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0435.<\/p>\n<p><code>addScrollerListener<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0438 \u043a <code>RecyclerView<\/code>. \u041f\u0440\u0438 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 \u043f\u043e\u0440\u043e\u0433\u0430 \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0438 \u0438 \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 <code>bestListViewModel<\/code>.<\/p>\n<p>\u0412 \u043a\u043e\u043c\u043f\u0430\u043d\u044c\u043e\u043d\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b <code>initialize<\/code> \u0438 <code>get<\/code> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 <code>BestListFragment<\/code>. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430.<\/p>\n<pre><code class=\"kotlin\">private const val TAG = \"BestListViewModel\"  @HiltViewModel class BestListViewModel @Inject constructor(     private val repository: JokeRepository,     private val jokeFetcher: JokeFetcher ) : ViewModel() {     private val _jokeLiveData: MutableLiveData&lt;MutableList&lt;Joke>> = MutableLiveData()     val jokeLiveData: LiveData&lt;MutableList&lt;Joke>> = _jokeLiveData      private val _isLoadingLiveData: MutableLiveData&lt;Boolean> = MutableLiveData()     val isLoadingLiveData: LiveData&lt;Boolean> = _isLoadingLiveData      val jokesFromDBLiveData: LiveData&lt;List&lt;Joke>> = repository.getLikeJokes()      var currentJokeList = mutableListOf&lt;Joke>()      private var alreadyLoaded = 0     private var buffer = 7      init {         getBestJokeList()     }      fun getBestJokeList() {         MainScope().launch {             _isLoadingLiveData.value = true             var listOfBestJokeNumbers = jokeFetcher.getBestJokesListAsync().await()             listOfBestJokeNumbers = listOfBestJokeNumbers                 .filter { it !in listOfBestJokeNumbers.take(alreadyLoaded) }             alreadyLoaded += buffer             for (currentNumber in listOfBestJokeNumbers.take(buffer)) {                 val newJoke = jokeFetcher.fetchJokeByNumberAsync(currentNumber).await()                 currentJokeList.add(newJoke)             }             _isLoadingLiveData.value = false             _jokeLiveData.value = currentJokeList         }     } }<\/code><\/pre>\n<p>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>jokesFromDBLiveData<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 <code>LiveData<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <code>getLikeJokes()<\/code> \u0438\u0437 <code>repository<\/code>.<\/p>\n<p>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>currentJokeList<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432.<\/p>\n<p>\u0412 \u0431\u043b\u043e\u043a\u0435 <code>init<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 <code>getBestJokeList()<\/code> \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432.<\/p>\n<p> \u0412\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 <code>_isLoadingLiveData<\/code>, \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u043a <code>jokeFetcher<\/code> \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043b\u0443\u0447\u0448\u0438\u0445 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 <code>jokeFetcher.getBestJokesListAsync().await()<\/code>. \u0417\u0430\u0442\u0435\u043c \u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0443\u0436\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u044b, \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0446\u0438\u043a\u043b \u043f\u043e \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u043c\u0441\u044f \u0447\u0438\u0441\u043b\u0430\u043c \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u043a <code>jokeFetcher<\/code> \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <code>jokeFetcher.fetchJokeByNumberAsync(currentNumber).await()<\/code>, \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0430\u043d\u0435\u043a\u0434\u043e\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 <code>currentJokeList<\/code>. \u041f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0446\u0438\u043a\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>jokeLiveData<\/code> \u0441 <code>currentJokeList<\/code>.  <\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043a\u0440\u0430\u0442\u043a\u0438\u0439 (\u043c\u043e\u0436\u0435\u0442 \u0438 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043e\u0431\u0437\u043e\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f). \u0421 \u043f\u043e\u043b\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043d\u0430 GitHub.<\/p>\n<p><a href=\"https:\/\/github.com\/K0RGA\/Aneckdoter\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/K0RGA\/Aneckdoter<\/a><\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1b1\/d3f\/c3d\/1b1d3fc3d5bb52532511f3d5bb437c55.gif\" width=\"320\" height=\"672\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1b1\/d3f\/c3d\/1b1d3fc3d5bb52532511f3d5bb437c55.gif\"\/><\/figure>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/746726\/\"> https:\/\/habr.com\/ru\/articles\/746726\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c \u0438\u0434\u0435\u044f \u0440\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0441 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u043c\u044b \u0441 \u0434\u0440\u0443\u0437\u044c\u044f\u043c\u0438 \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u043b\u0438 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0443 \u043f\u043e\u0434\u0430\u0440\u043a\u0438 \u0432 \u0412\u041a (\u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0440\u043e\u0432\u0435\u0440\u044b) \u0438 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044f\u043b\u0438 \u043a \u043d\u0438\u043c \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u044b. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0448\u0443\u0442\u043e\u043a \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043b\u0438\u0447\u043d\u043e \u0431\u044b\u043b \u0441\u0430\u0439\u0442 <a href=\"https:\/\/baneks.ru\/\" rel=\"noopener noreferrer nofollow\">https:\/\/baneks.ru\/<\/a>. \u041d\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043d\u0435\u0433\u043e \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u044b \u0431\u044b\u043b\u043e \u0434\u043e \u0436\u0443\u0442\u0438 \u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e, \u043f\u043b\u044e\u0441 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u0432\u0448\u0438\u0435\u0441\u044f. \u0421 \u044d\u0442\u043e\u0433\u043e \u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0430:<\/p>\n<ol>\n<li>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u0432\u0448\u0438\u0445\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<\/li>\n<\/ol>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/h2>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043a\u0430\u043a \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0442\u0430\u043a \u0438 \u043f\u0430\u0440\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0445:<\/p>\n<h4>Network<\/h4>\n<pre><code class=\"kotlin\">implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.5.0' implementation 'com.squareup.retrofit2:converter-scalars:2.9.0' implementation 'com.google.code.gson:gson:2.8.9' implementation 'org.jsoup:jsoup:1.13.1'<\/code><\/pre>\n<p>\u0422.\u043a. \u043d\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a API \u0441\u0430\u0439\u0442\u0430, \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432 \u043f\u0430\u0440\u0441\u0438\u043b\u0441\u044f HTML \u043a\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/jsoup.org\/\" rel=\"noopener noreferrer nofollow\">jsoup<\/a>. \u0414\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f <a href=\"https:\/\/square.github.io\/retrofit\/\" rel=\"noopener noreferrer nofollow\">retrofit<\/a>.<\/p>\n<h4>Database<\/h4>\n<pre><code class=\"kotlin\">implementation \"androidx.room:room-runtime:2.4.3\" kapt \"androidx.room:room-compiler:2.4.3\"<\/code><\/pre>\n<p>Room \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u0432\u0448\u0438\u0445\u0441\u044f \u0430\u043d\u0435\u043a\u043e\u0432 \u043f\u0443\u0442\u0451\u043c \u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0411\u0414 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435<\/p>\n<h4>DI<\/h4>\n<pre><code class=\"kotlin\">implementation \"com.google.dagger:hilt-android:2.44\" kapt \"com.google.dagger:hilt-compiler:2.44\"<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 DI \u0431\u044b\u043b \u0432\u0437\u044f\u0442 Hilt \u043a\u0430\u043a \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0430\u044f \u043f\u043e\u0434 \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430.<\/p>\n<h4>Design<\/h4>\n<pre><code class=\"kotlin\">implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.appcompat:appcompat:1.5.1' implementation 'com.google.android.material:material:1.7.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.recyclerview:recyclerview:1.2.1' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'androidx.fragment:fragment-ktx:1.5.4' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0'  implementation('com.mikepenz.materialdrawer:library:0.9.5@aar') {     transitive = true }<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u043f\u043e\u043c\u0438\u043c\u043e Jetpack-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u041c\u0430\u0439\u043a\u0430 \u041f\u0435\u043d\u0437\u0430 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 Material Drawer, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043a\u0430\u043a \u0431\u043e\u043a\u043e\u0432\u043e\u0435 \u043c\u0435\u043d\u044e \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<h2>\u0420\u0430\u0437\u0431\u043e\u0440 \u043a\u043e\u0434\u0430<\/h2>\n<p>\u0420\u0430\u0437\u0431\u043e\u0440 \u043a\u043e\u0434\u0430 \u0431\u0443\u0434\u0435\u043c \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u043d\u0435 \u0432\u0435\u0441\u044c, \u043b\u0438\u0448\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b.<\/p>\n<pre><code class=\"kotlin\">@AndroidEntryPoint class MainActivity : AppCompatActivity() {     override fun onCreate(savedInstanceState: Bundle?) {         super.onCreate(savedInstanceState)         setContentView(R.layout.activity_main)         val (toolbar: Toolbar, fragmentContainer) = createToolbar()         createDrawer(toolbar, fragmentContainer)         initialize(savedInstanceState, fragmentContainer)     }      private fun initialize(savedInstanceState: Bundle?, fragmentContainer: Int) {         val isFragmentContainerEmpty = (savedInstanceState == null)         if (isFragmentContainerEmpty) {             supportFragmentManager.commit {                 setReorderingAllowed(true)                 add(fragmentContainer, JokeListFragment.get())                 addToBackStack(\"joke_list\")             }         }     }      private fun createToolbar(): Pair&lt;Toolbar, Int> {         val toolbar: Toolbar = findViewById&lt;View>(R.id.toolbar) as Toolbar         toolbar.setTitle(R.string.drawer_item_random_joke)         setSupportActionBar(toolbar)         supportActionBar!!.setDisplayHomeAsUpEnabled(true)         val fragmentContainer = R.id.fragmentContainer         return Pair(toolbar, fragmentContainer)     }      private fun createDrawer(toolbar: Toolbar, fragmentContainer: Int) {         Drawer()             .withActivity(this)             .withToolbar(toolbar)             .withActionBarDrawerToggle(true)             .withHeader(R.layout.drawer_header)             .addDrawerItems(                 PrimaryDrawerItem().withName(R.string.drawer_item_random_joke)                     .withIcon(getDrawable(R.drawable.random)),                 PrimaryDrawerItem().withName(R.string.drawer_item_like)                     .withIcon(getDrawable(R.drawable.heart)),                 PrimaryDrawerItem().withName(R.string.drawer_item_best_joke)                     .withIcon(getDrawable(R.drawable.crown))             )             .withOnDrawerItemClickListener { _, _, position, _, _ ->                 when (position) {                     1 -> {                         supportFragmentManager.commit {                             setReorderingAllowed(true)                             replace(fragmentContainer, JokeListFragment.get())                             addToBackStack(\"joke_list\")                             toolbar.setTitle(R.string.drawer_item_random_joke)                         }                     }                     2 -> {                         supportFragmentManager.commit {                             setReorderingAllowed(true)                             replace(fragmentContainer, LikeListFragment.newInstance())                             addToBackStack(\"like_list\")                         }                         toolbar.setTitle(R.string.drawer_item_like)                     }                     3 -> {                         supportFragmentManager.commit {                             setReorderingAllowed(true)                             replace(fragmentContainer, BestListFragment.get())                             addToBackStack(\"best_list\")                         }                         toolbar.setTitle(R.string.drawer_item_best_joke)                     }                 }             }             .build()     } }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c <code>MainActivity<\/code> \u0441 \u043f\u0430\u043d\u0435\u043b\u044c\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 (<code>Toolbar<\/code>) \u0438 \u0431\u043e\u043a\u043e\u0432\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u044c\u044e (<code>Navigation Drawer<\/code>). \u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0431\u043e\u043a\u043e\u0432\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043c\u0435\u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 <code>fragmentContainer<\/code> \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u043f\u0430\u043d\u0435\u043b\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0431\u043e\u043a\u043e\u0432\u0443\u044e \u043f\u0430\u043d\u0435\u043b\u044c \u0438 \u043a\u043d\u043e\u043f\u043a\u0443 &#171;\u0434\u043e\u043c\u043e\u0439&#187; \u043d\u0430 \u043f\u0430\u043d\u0435\u043b\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u043d\u0430\u0437\u0430\u0434.  <\/p>\n<pre><code class=\"kotlin\">private const val VIEW_TYPE_ITEM = 0 private const val VIEW_TYPE_LOAD = 1  class JokeAdapter(private val onItemClicked: (Joke, ToggleButton) -> Unit) :     ListAdapter&lt;Joke, ViewHolder>(JokeDiffCallback()) {      private class LoadHolder(view: View) : ViewHolder(view)      override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {         return if (viewType == VIEW_TYPE_ITEM) {             val view =                 LayoutInflater.from(parent.context)                     .inflate(R.layout.joke_list_item, parent, false)             JokeHolder(view){                 onItemClicked(currentList[it], view.findViewById(R.id.like_button))             }         } else {             val view =                 LayoutInflater.from(parent.context)                     .inflate(R.layout.progress_loading, parent, false)             LoadHolder(view)         }     }      override fun onBindViewHolder(holder: ViewHolder, position: Int) {         if (holder is JokeHolder) {             val joke = getItem(position)             holder.bind(joke)         }      }      fun addLoadingView() {         submitList(ArrayList(currentList + null))         notifyItemInserted(currentList.lastIndex)     }      fun deleteLoadingView() {         if (currentList.size != 0) {             submitList(ArrayList(currentList - currentList.last()))             notifyItemRemoved(currentList.size)         }     }      override fun getItemViewType(position: Int): Int {         return if (getItem(position) == null) {             VIEW_TYPE_LOAD         } else {             VIEW_TYPE_ITEM         }     } }<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 <code>JokeAdapter<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043f\u0438\u0441\u043a\u0430 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432 \u0441 <code>RecyclerView<\/code> \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438.<\/p>\n<p>\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u0430\u0439\u043b\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0432\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b: <code>VIEW_TYPE_ITEM<\/code> \u0438 <code>VIEW_TYPE_LOAD<\/code>. \u041e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u0432 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0435. <code>VIEW_TYPE_ITEM<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u043f\u0438\u0441\u043a\u0430 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432, \u0430 <code>VIEW_TYPE_LOAD<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438.<\/p>\n<p>\u041a\u043b\u0430\u0441\u0441 <code>JokeAdapter<\/code> \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 <code>ListAdapter<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u043e\u043c <code>RecyclerView.Adapter<\/code> \u0438 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0410\u0434\u0430\u043f\u0442\u0435\u0440 \u0438\u043c\u0435\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 <code>LoadHolder<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 <code>ViewHolder<\/code> \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0412 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u043b\u044f\u043c\u0431\u0430, \u0442.\u043a. \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e \u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445.<\/p>\n<pre><code class=\"kotlin\">class JokeHolder(view: View, onItemClicked: (Int) -> Unit) : RecyclerView.ViewHolder(view),     View.OnLongClickListener {      val context = view.context     @Inject     lateinit var repository: JokeRepository     private var clipboard: ClipboardManager =         context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager     private val jokeText: TextView = view.findViewById(R.id.joke_text)     private val likeButton: ToggleButton = view.findViewById(R.id.like_button)     private lateinit var joke: Joke      init {         jokeText.setOnLongClickListener(this)         likeButton.setOnClickListener {             onItemClicked(bindingAdapterPosition)         }     }      fun bind(joke: Joke) {         this.joke = joke         jokeText.text = joke.text         likeButton.isChecked = joke.isLiked     }      override fun onLongClick(p0: View?): Boolean {         val clip = ClipData.newPlainText(\"Text of joke\", jokeText.text)         clipboard.setPrimaryClip(clip)         Toast.makeText(context, \"Text copied\", Toast.LENGTH_SHORT).show()         return true     } }<\/code><\/pre>\n<p>\u041a\u043b\u0430\u0441\u0441 <code>JokeHolder<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 <code>ViewHolder<\/code> \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u0430\u043d\u0435\u043a\u0434\u043e\u0442\u043e\u0432 \u0432 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0435 <code>JokeAdapter<\/code>. \u041e\u043d \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 <code>RecyclerView.ViewHolder<\/code> \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>View.OnLongClickListener<\/code> \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u043e\u043b\u0433\u043e\u0433\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u043f\u0438\u0441\u043a\u0430.  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>onLongClick<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0434\u043e\u043b\u0433\u043e\u043c \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 <code>jokeText<\/code>. \u041e\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442 <code>ClipD<\/code><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-417877","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/417877","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=417877"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/417877\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=417877"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=417877"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=417877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}