Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kkane098 committed Nov 30, 2019
2 parents 66b22f5 + 54550e2 commit 3ba9998
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.content.pm.PackageManager
import android.media.AudioManager
import android.os.Build
import android.os.Bundle
import android.text.Editable
import android.text.TextUtils
import android.util.Log
import android.view.LayoutInflater
Expand All @@ -17,7 +18,6 @@ import android.widget.*
import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat.checkSelfPermission
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProviders
import com.example.ContextAwareRinger.*
import com.example.ContextAwareRinger.Data.LocationData
import com.example.ContextAwareRinger.Data.LocationDataListAdapter
Expand Down Expand Up @@ -156,16 +156,6 @@ class LocationsActivity(private val volumeMap: MutableMap<String, Int>) : Fragme
locationTitle!!.setText(location.name)
radiusEditText!!.setText(location.radius.toInt().toString())

val nameObserver = Observer { name: String? ->
Log.i(TAG, "Location updated")
if (name != null) {

locationTitle?.setText(name)
}
}

ViewModelProviders.of(activity!!).get(TimeViewModel::class.java).name.observe(this, nameObserver)

when(location.ringerMode){
AudioManager.RINGER_MODE_VIBRATE -> {
val vibrateButton = dialogView.findViewById<RadioButton>(R.id.radioButton2)
Expand Down Expand Up @@ -230,7 +220,6 @@ class LocationsActivity(private val volumeMap: MutableMap<String, Int>) : Fragme
//TODO: Store location data in the file system
Log.i(TAG, "submitting")
b.dismiss()

//TODO: Update the location
deleteLocation(location)
updateLocation(title, mPlaceName!!, radius, mLat!!, mLong!!, location.fenceKey, ringerMode, position)
Expand Down Expand Up @@ -270,23 +259,14 @@ class LocationsActivity(private val volumeMap: MutableMap<String, Int>) : Fragme
val b = dialogBuilder.create()
b.show()


//Get the UI components that contain information used to create a LocationData object
val buttonSubmit = dialogView.findViewById<Button>(R.id.buttonSubmit)
val locationTitle: EditText? = dialogView.findViewById(R.id.locationTitle)
val radiusEditText: EditText? = dialogView.findViewById(R.id.radiusEditText)
val radioGroup: RadioGroup = dialogView.findViewById(R.id.volumeRadioGroup)
val buttonLocation: Button = dialogView.findViewById(R.id.place_autocomplete_button)

val nameObserver = Observer { name: String? ->
Log.i(TAG, "Location updated")
if (name != null) {

locationTitle?.setText(name)
}
}

ViewModelProviders.of(activity!!).get(TimeViewModel::class.java).name.observe(this, nameObserver)

buttonLocation.setOnClickListener {
processClick()
}
Expand Down Expand Up @@ -377,8 +357,6 @@ class LocationsActivity(private val volumeMap: MutableMap<String, Int>) : Fragme
mLong = p.latLng?.longitude
mPlaceName = p.name

ViewModelProviders.of(activity!!).get(TimeViewModel::class.java).name.value = p.name

Toast.makeText(context!!, "You chose $mPlaceName", Toast.LENGTH_LONG).show()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ import androidx.lifecycle.ViewModel
class TimeViewModel : ViewModel() {
var hour = MutableLiveData<Int>()
var minute = MutableLiveData<Int>()
var name = MutableLiveData<String>()
}

0 comments on commit 3ba9998

Please sign in to comment.