SHARE
TWEET

Untitled

a guest May 16th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.nea.neaquran
  2.  
  3. import android.os.Bundle
  4. import com.nea.neaquran.Entities.Models.Quran
  5. import com.nea.neaquran.Modules.Database.DatabaseHelper
  6. import com.nea.neaquran.Modules.Database.DatabasePresenter
  7. import com.nea.neaquran.Modules.Database.DatabaseView
  8. import com.nea.neaquran.Support.Utils.Adapter
  9. import com.nea.neaquran.ViewHolders.VerseViewHolder
  10. import androidx.appcompat.app.AppCompatActivity
  11. import androidx.recyclerview.widget.LinearLayoutManager
  12. import kotlinx.android.synthetic.main.activity_list_verse.*
  13.  
  14. class ListVerseActivity : AppCompatActivity(), DatabaseView{
  15.  
  16.  
  17.     lateinit var  adapter: Adapter<Quran, VerseViewHolder>
  18.     lateinit var bundle: Bundle
  19.  
  20.     var presenter = DatabasePresenter(DatabaseHelper(this), this)
  21.     var surahTitle = ""
  22.     var surahId = 1
  23.     var verseId = 1
  24.     override fun onCreate(savedInstanceState: Bundle?) {
  25.         super.onCreate(savedInstanceState)
  26.         setContentView(R.layout.activity_list_verse)
  27.         setToolbar()
  28.  
  29.  
  30.         bundle = intent.extras
  31.         surahTitle = bundle.getString("surahTitle")
  32.         surahId = bundle.getInt("surahId")
  33.         verseId = bundle.getInt("verseId")
  34.  
  35.         presenter.getDataBySurahId(surahId)
  36.  
  37.         text_title_surah.text = surahTitle
  38.  
  39.     }
  40.  
  41.     fun setToolbar(){
  42.         setSupportActionBar(toolbar)
  43.         supportActionBar!!.setDisplayShowTitleEnabled(false)
  44.         supportActionBar!!.setDisplayHomeAsUpEnabled(true)
  45.         supportActionBar!!.setDisplayShowHomeEnabled(true)
  46.     }
  47.  
  48.     override fun onSupportNavigateUp(): Boolean {
  49.         onBackPressed()
  50.         return true
  51.     }
  52.  
  53.     override fun successGetDataBySurahId(list: List<Quran>) {
  54.         setList(list)
  55.     }
  56.  
  57.     fun setList(list: List<Quran>) {
  58.  
  59.  
  60.         val manager = LinearLayoutManager(this)
  61.         adapter = object : Adapter<Quran, VerseViewHolder>(R.layout.list_verse, VerseViewHolder::class.java,
  62.                 Quran::class.java, list) {
  63.             override fun bindView(holder: VerseViewHolder, tipeData: Quran, position: Int) {
  64.                 holder.onBind(tipeData)
  65.  
  66.             }
  67.         }
  68.  
  69.         list_verse.layoutManager = manager
  70.         list_verse.adapter = adapter
  71.     }
  72. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top