Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Apr 8th, 2020 129 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.example.todo
  2.  
  3. import android.app.Activity
  4. import android.content.Context
  5. import androidx.appcompat.app.AppCompatActivity
  6. import android.os.Bundle
  7. import android.util.Log
  8. import android.view.Gravity
  9. import android.view.View
  10. import android.view.inputmethod.InputMethodManager
  11. import android.widget.Toast
  12. import androidx.lifecycle.Observer
  13. import androidx.lifecycle.ViewModelProvider
  14. import androidx.recyclerview.widget.LinearLayoutManager
  15. import androidx.recyclerview.widget.RecyclerView
  16. import kotlinx.android.synthetic.main.activity_main.*
  17. import java.util.ArrayList
  18.  
  19. class MainActivity : AppCompatActivity() {
  20.  
  21.     private lateinit var recyclerView: RecyclerView
  22.     private lateinit var viewAdapter: RecyclerView.Adapter<*>
  23.     private lateinit var viewManager: RecyclerView.LayoutManager
  24.     private lateinit var viewModel : Model
  25.  
  26.     override fun onCreate(savedInstanceState: Bundle?) {
  27.  
  28.         super.onCreate(savedInstanceState)
  29.         setContentView(R.layout.activity_main)
  30.  
  31.         viewModel = ViewModelProvider(this).get(Model::class.java)
  32.         viewManager  = LinearLayoutManager(this)
  33.         viewAdapter  = TodoAdapter(viewModel)
  34.         recyclerView = myRycyle // from id activity_main
  35.  
  36.         recyclerView.apply {
  37.             layoutManager = viewManager
  38.             adapter = viewAdapter
  39.         }
  40.  
  41.  
  42.         buttonNew.setOnClickListener{ view->
  43.             val data = newTodo.text.toString()
  44.             if (data.trim().length > 0){
  45.                 viewModel.newTodo(newTodo.text.toString())
  46.                 hideKeyboard(view)
  47.                 newTodo.setText(null)
  48.             }
  49.             else{
  50.                 var toast =  Toast.makeText(this,"Tidak Boleh Kosong",Toast.LENGTH_SHORT)
  51.                 toast.setGravity(Gravity.TOP,0,100)
  52.                 toast.show()
  53.             }
  54.         }
  55.  
  56.     }
  57.     fun Context.hideKeyboard(view: View) {
  58.         val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
  59.         inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
  60.     }
  61. }
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