<commit_before>/*
 * Copyright (c) 2016-2018 ayatk.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.ayatk.biblio.ui.search

import android.arch.lifecycle.ViewModelProviders
import android.content.Context
import android.content.Intent
import android.databinding.DataBindingUtil
import android.os.Bundle
import android.support.v4.view.GravityCompat
import android.support.v7.app.ActionBarDrawerToggle
import android.support.v7.widget.DividerItemDecoration
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.RecyclerView.OnScrollListener
import android.support.v7.widget.SearchView
import android.view.Menu
import android.view.MenuItem
import android.view.View
import com.ayatk.biblio.R
import com.ayatk.biblio.databinding.ActivitySearchBinding
import com.ayatk.biblio.di.ViewModelFactory
import com.ayatk.biblio.model.Novel
import com.ayatk.biblio.ui.search.item.SearchResultItem
import com.ayatk.biblio.ui.util.helper.Navigator
import com.ayatk.biblio.ui.util.initBackToolbar
import com.ayatk.biblio.util.Result
import com.ayatk.biblio.util.ext.drawable
import com.ayatk.biblio.util.ext.observe
import com.ayatk.biblio.util.ext.setVisible
import com.xwray.groupie.GroupAdapter
import com.xwray.groupie.Section
import com.xwray.groupie.ViewHolder
import dagger.android.support.DaggerAppCompatActivity
import io.reactivex.Completable
import timber.log.Timber
import javax.inject.Inject

class SearchActivity : DaggerAppCompatActivity() {

  @Inject
  lateinit var viewModelFactory: ViewModelFactory

  private val viewModel: SearchViewModel by lazy {
    ViewModelProviders.of(this, viewModelFactory).get(SearchViewModel::class.java)
  }

  private val binding: ActivitySearchBinding by lazy {
    DataBindingUtil.setContentView<ActivitySearchBinding>(this, R.layout.activity_search)
  }

  private lateinit var searchView: SearchView

  private val searchSection = Section()
  private val onItemClickListener = { novel: Novel ->
    Navigator.navigateToDetail(this, novel)
  }
  private val onDownloadClickListener: (Novel) -> Completable = { novel: Novel ->
    viewModel.saveNovel(novel)
  }

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    overridePendingTransition(R.anim.activity_fade_enter, R.anim.activity_fade_exit)
    binding.setLifecycleOwner(this)
    binding.viewModel = viewModel

    initBackToolbar(this, binding.toolbar)

    initRecyclerView()

    binding.drawerLayout.addDrawerListener(
        object : ActionBarDrawerToggle(
            this, binding.drawerLayout, R.string.drawer_open,
            R.string.drawer_close
        ) {
          override fun onDrawerOpened(drawerView: View) {
            super.onDrawerOpened(drawerView)
            searchView.clearFocus()
          }
        }
    )

<commit_msg>無駄な行を消した<commit_after>/*
 * Copyright (c) 2016-2018 ayatk.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.ayatk.biblio.ui.search

import android.arch.lifecycle.ViewModelProviders
import android.content.Context
import android.content.Intent
import android.databinding.DataBindingUtil
import android.os.Bundle
import android.support.v4.view.GravityCompat
import android.support.v7.app.ActionBarDrawerToggle
import android.support.v7.widget.DividerItemDecoration
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.RecyclerView.OnScrollListener
import android.support.v7.widget.SearchView
import android.view.Menu
import android.view.MenuItem
import android.view.View
import com.ayatk.biblio.R
import com.ayatk.biblio.databinding.ActivitySearchBinding
import com.ayatk.biblio.di.ViewModelFactory
import com.ayatk.biblio.model.Novel
import com.ayatk.biblio.ui.search.item.SearchResultItem
import com.ayatk.biblio.ui.util.helper.Navigator
import com.ayatk.biblio.ui.util.initBackToolbar
import com.ayatk.biblio.util.Result
import com.ayatk.biblio.util.ext.drawable
import com.ayatk.biblio.util.ext.observe
import com.ayatk.biblio.util.ext.setVisible
import com.xwray.groupie.GroupAdapter
import com.xwray.groupie.Section
import com.xwray.groupie.ViewHolder
import dagger.android.support.DaggerAppCompatActivity
import io.reactivex.Completable
import timber.log.Timber
import javax.inject.Inject

class SearchActivity : DaggerAppCompatActivity() {

  @Inject
  lateinit var viewModelFactory: ViewModelFactory

  private val viewModel: SearchViewModel by lazy {
    ViewModelProviders.of(this, viewModelFactory).get(SearchViewModel::class.java)
  }

  private val binding: ActivitySearchBinding by lazy {
    DataBindingUtil.setContentView<ActivitySearchBinding>(this, R.layout.activity_search)
  }

  private lateinit var searchView: SearchView

  private val searchSection = Section()
  private val onItemClickListener = { novel: Novel ->
    Navigator.navigateToDetail(this, novel)
  }
  private val onDownloadClickListener: (Novel) -> Completable = { novel: Novel ->
    viewModel.saveNovel(novel)
  }

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    overridePendingTransition(R.anim.activity_fade_enter, R.anim.activity_fade_exit)
    binding.setLifecycleOwner(this)
    binding.viewModel = viewModel

    initBackToolbar(this, binding.toolbar)

    initRecyclerView()

    binding.drawerLayout.addDrawerListener(
        object : ActionBarDrawerToggle(
            this, binding.drawerLayout, R.string.drawer_open,
            R.string.drawer_close
        ) {
          override fun onDrawerOpened(drawerView: View) {
            super.onDrawerOpened(drawerView)
            searchView.clearFocus()
          }
        }
    )

{'fraction_non_alphanumeric': 0.08234946871310507, 'fraction_numerical': 0.005608028335301062, 'mean_word_length': 4.430288461538462, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3435475', 'n_tokens_mistral': 2077, 'n_tokens_neox': 1980, 'n_words': 450}