diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index e7b4ab6..6c5db62 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/.idea/misc.xml b/.idea/misc.xml index 5e73d4b..653aa67 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -27,7 +27,7 @@ - + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9c8622b..ff5dbf9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,15 +3,14 @@ package="dpm.location.tracker"> - @@ -31,6 +30,8 @@ android:name=".LocationUpdatesService" android:label="My Job Service Update " android:permission="android.permission.BIND_JOB_SERVICE" /> + + \ No newline at end of file diff --git a/app/src/main/java/dpm/location/tracker/JobServiceDemoActivity.kt b/app/src/main/java/dpm/location/tracker/JobServiceDemoActivity.kt index 5ee527f..c20153e 100644 --- a/app/src/main/java/dpm/location/tracker/JobServiceDemoActivity.kt +++ b/app/src/main/java/dpm/location/tracker/JobServiceDemoActivity.kt @@ -19,10 +19,15 @@ import android.support.v7.widget.Toolbar import android.util.Log import android.view.Menu import android.view.MenuItem +import android.widget.ListView import android.widget.TextView +import android.widget.Toast +import dpm.location.tracker.room.LocationAdapter import dpm.location.tracker.room.LocationDb import dpm.location.tracker.room.LocationRepository -import dpm.location.tracker.room.storedLoctation +import dpm.location.tracker.room.StoredLoctation +import kotlinx.android.synthetic.main.content_job_service_demo.delete_data +import kotlinx.android.synthetic.main.content_job_service_demo.show_results import org.jetbrains.anko.doAsync import org.jetbrains.anko.uiThread import java.text.DateFormat @@ -35,6 +40,8 @@ class JobServiceDemoActivity : AppCompatActivity(), NavigationView.OnNavigationI // as google doc says // Handler for incoming messages from the service. + private var listView: ListView? = null + private val mAdapter: LocationAdapter? = null private var mHandler: IncomingMessageHandler? = null private val db: LocationDb @@ -52,181 +59,201 @@ class JobServiceDemoActivity : AppCompatActivity(), NavigationView.OnNavigationI val obj = msg.obj as Location val currentDateTimeString = DateFormat.getDateTimeInstance().format(Date()) locationMsg!!.text = "LAT : " + obj.latitude + "\nLNG : " + obj.longitude + "\n\n" + obj.toString() + " \n\n\nLast updated- " + currentDateTimeString + val location = StoredLoctation() + location.lat = obj.latitude + location.lon = obj.longitude + val list = ArrayList() + list.add(location) + doAsync { + db.locationDao().insertAll(list) + uiThread { + + } + } } } } } - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_job_service_demo) - val toolbar = findViewById(R.id.toolbar) - setSupportActionBar(toolbar) - //room + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_job_service_demo) + val toolbar = findViewById(R.id.toolbar) + setSupportActionBar(toolbar) - val list = ArrayList() - for (i in 0..9) { - val location = storedLoctation() - location.lat = "2" - location.lon = "1" - list.add(location) - } - doAsync { - val products = db.locationDao().all - uiThread { + //room - } - } + // List products = LocationRepository.get().getDB().locationDao().getAll(); - doAsync { - val products = db.locationDao().all - uiThread { + val drawer = findViewById(R.id.drawer_layout) + val toggle = ActionBarDrawerToggle( + this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) + drawer.addDrawerListener(toggle) + toggle.syncState() - } + val navigationView = findViewById(R.id.nav_view) + navigationView.setNavigationItemSelectedListener(this) + + drawer.setDrawerLockMode(LOCK_MODE_LOCKED_CLOSED) + + locationMsg = findViewById(R.id.location) + + mHandler = IncomingMessageHandler() + requestPermissions() + bindListeners() } - // List products = LocationRepository.get().getDB().locationDao().getAll(); + override fun onStart() { + super.onStart() + } - val drawer = findViewById(R.id.drawer_layout) - val toggle = ActionBarDrawerToggle( - this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) - drawer.addDrawerListener(toggle) - toggle.syncState() + override fun onDestroy() { + super.onDestroy() + mHandler = null + } - val navigationView = findViewById(R.id.nav_view) - navigationView.setNavigationItemSelectedListener(this) + /** + * Callback received when a permissions request has been completed. + */ + override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, + grantResults: IntArray) { + Log.i(TAG, "onRequestPermissionResult") + if (requestCode == REQUEST_PERMISSIONS_REQUEST_CODE) { + if (grantResults.size <= 0) { + // If user interaction was interrupted, the permission request is cancelled and you + // receive empty arrays. + Log.i(TAG, "User interaction was cancelled.") + finish() + } else if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { + // can be schedule in this way also + // Utils.scheduleJob(this, LocationUpdatesService.class); + //doing this way to communicate via messenger + // Start service and provide it a way to communicate with this class. + val startServiceIntent = Intent(this, LocationUpdatesService::class.java) + val messengerIncoming = Messenger(mHandler) + startServiceIntent.putExtra(MESSENGER_INTENT_KEY, messengerIncoming) + startService(startServiceIntent) + } else { + // Permission denied. + finish() + } + } + } + fun bindListeners(){ + delete_data.setOnClickListener { deleteDb() } + show_results.setOnClickListener { showResults() } + } - drawer.setDrawerLockMode(LOCK_MODE_LOCKED_CLOSED) + private fun showResults() { + startActivity(Intent(this, ListViewActivity::class.java)) +// doAsync { +// val products = db.locationDao().all +// +// uiThread { +// +// } +// } - locationMsg = findViewById(R.id.location) - mHandler = IncomingMessageHandler() - requestPermissions() } - override fun onStart() { - super.onStart() - } + private fun deleteDb() { + doAsync { + //val products = db.locationDao().nukeTable() + uiThread { - override fun onDestroy() { - super.onDestroy() - mHandler = null + } + + } + Toast.makeText(applicationContext,"Database deleted",Toast.LENGTH_LONG).show() } - /** - * Callback received when a permissions request has been completed. - */ - override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, - grantResults: IntArray) { - Log.i(TAG, "onRequestPermissionResult") - if (requestCode == REQUEST_PERMISSIONS_REQUEST_CODE) { - if (grantResults.size <= 0) { - // If user interaction was interrupted, the permission request is cancelled and you - // receive empty arrays. - Log.i(TAG, "User interaction was cancelled.") - finish() - } else if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { - // can be schedule in this way also - // Utils.scheduleJob(this, LocationUpdatesService.class); - //doing this way to communicate via messenger - // Start service and provide it a way to communicate with this class. - val startServiceIntent = Intent(this, LocationUpdatesService::class.java) - val messengerIncoming = Messenger(mHandler) - startServiceIntent.putExtra(MESSENGER_INTENT_KEY, messengerIncoming) - startService(startServiceIntent) + override fun onBackPressed() { + val drawer = findViewById(R.id.drawer_layout) + if (drawer.isDrawerOpen(GravityCompat.START)) { + drawer.closeDrawer(GravityCompat.START) } else { - // Permission denied. - finish() + super.onBackPressed() } } - } - override fun onBackPressed() { - val drawer = findViewById(R.id.drawer_layout) - if (drawer.isDrawerOpen(GravityCompat.START)) { - drawer.closeDrawer(GravityCompat.START) - } else { - super.onBackPressed() + override fun onCreateOptionsMenu(menu: Menu): Boolean { + // Inflate the menu; this adds items to the action bar if it is present. + menuInflater.inflate(R.menu.job_service_demo, menu) + return true } - } - override fun onCreateOptionsMenu(menu: Menu): Boolean { - // Inflate the menu; this adds items to the action bar if it is present. - menuInflater.inflate(R.menu.job_service_demo, menu) - return true - } + override fun onNavigationItemSelected(item: MenuItem): Boolean { + // Handle navigation view item clicks here. + val id = item.itemId - override fun onNavigationItemSelected(item: MenuItem): Boolean { - // Handle navigation view item clicks here. - val id = item.itemId + if (id == R.id.nav_camera) { + // Handle the camera action + } else if (id == R.id.nav_gallery) { - if (id == R.id.nav_camera) { - // Handle the camera action - } else if (id == R.id.nav_gallery) { + } else if (id == R.id.nav_slideshow) { - } else if (id == R.id.nav_slideshow) { + } else if (id == R.id.nav_manage) { - } else if (id == R.id.nav_manage) { + } else if (id == R.id.nav_share) { - } else if (id == R.id.nav_share) { + } else if (id == R.id.nav_send) { - } else if (id == R.id.nav_send) { + } + val drawer = findViewById(R.id.drawer_layout) + drawer.closeDrawer(GravityCompat.START) + return true } - val drawer = findViewById(R.id.drawer_layout) - drawer.closeDrawer(GravityCompat.START) - return true - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. - val id = item.itemId + override fun onOptionsItemSelected(item: MenuItem): Boolean { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + val id = item.itemId - return if (id == R.id.action_settings) { - true - } else super.onOptionsItemSelected(item) - } + return if (id == R.id.action_settings) { + true + } else super.onOptionsItemSelected(item) + } - private fun requestPermissions() { - val shouldProvideRationale = ActivityCompat.shouldShowRequestPermissionRationale(this, - Manifest.permission.ACCESS_FINE_LOCATION) - - // Provide an additional rationale to the user. This would happen if the user denied the - // request previously, but didn't check the "Don't ask again" checkbox. - if (shouldProvideRationale) { - Log.i(TAG, "Displaying permission rationale to provide additional context.") - // Request permission - ActivityCompat.requestPermissions(this@JobServiceDemoActivity, - arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), - REQUEST_PERMISSIONS_REQUEST_CODE) - } else { - Log.i(TAG, "Requesting permission") - // Request permission. It's possible this can be auto answered if device policy - // sets the permission in a given state or the user denied the permission - // previously and checked "Never ask again". - ActivityCompat.requestPermissions(this@JobServiceDemoActivity, - arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), - REQUEST_PERMISSIONS_REQUEST_CODE) + private fun requestPermissions() { + val shouldProvideRationale = ActivityCompat.shouldShowRequestPermissionRationale(this, + Manifest.permission.ACCESS_FINE_LOCATION) + + // Provide an additional rationale to the user. This would happen if the user denied the + // request previously, but didn't check the "Don't ask again" checkbox. + if (shouldProvideRationale) { + Log.i(TAG, "Displaying permission rationale to provide additional context.") + // Request permission + ActivityCompat.requestPermissions(this@JobServiceDemoActivity, + arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), + REQUEST_PERMISSIONS_REQUEST_CODE) + } else { + Log.i(TAG, "Requesting permission") + // Request permission. It's possible this can be auto answered if device policy + // sets the permission in a given state or the user denied the permission + // previously and checked "Never ask again". + ActivityCompat.requestPermissions(this@JobServiceDemoActivity, + arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), + REQUEST_PERMISSIONS_REQUEST_CODE) + } } - } - companion object { + companion object { - private val TAG = JobServiceDemoActivity::class.java.simpleName + private val TAG = JobServiceDemoActivity::class.java.simpleName - /** - * Code used in requesting runtime permissions. - */ - private val REQUEST_PERMISSIONS_REQUEST_CODE = 34 + /** + * Code used in requesting runtime permissions. + */ + private val REQUEST_PERMISSIONS_REQUEST_CODE = 34 - val MESSENGER_INTENT_KEY = "msg-intent-key" + val MESSENGER_INTENT_KEY = "msg-intent-key" - private val DATABASE_NAME = "LocaionDB" + private val DATABASE_NAME = "LocaionDB" + } } -} diff --git a/app/src/main/java/dpm/location/tracker/JobServiceDemoActivity.kt___jb_tmp___ b/app/src/main/java/dpm/location/tracker/JobServiceDemoActivity.kt___jb_tmp___ deleted file mode 100644 index 5ee527f..0000000 --- a/app/src/main/java/dpm/location/tracker/JobServiceDemoActivity.kt___jb_tmp___ +++ /dev/null @@ -1,232 +0,0 @@ -package dpm.location.tracker - -import android.Manifest -import android.content.Intent -import android.content.pm.PackageManager -import android.location.Location -import android.os.Bundle -import android.os.Handler -import android.os.Message -import android.os.Messenger -import android.support.design.widget.NavigationView -import android.support.v4.app.ActivityCompat -import android.support.v4.view.GravityCompat -import android.support.v4.widget.DrawerLayout -import android.support.v4.widget.DrawerLayout.LOCK_MODE_LOCKED_CLOSED -import android.support.v7.app.ActionBarDrawerToggle -import android.support.v7.app.AppCompatActivity -import android.support.v7.widget.Toolbar -import android.util.Log -import android.view.Menu -import android.view.MenuItem -import android.widget.TextView -import dpm.location.tracker.room.LocationDb -import dpm.location.tracker.room.LocationRepository -import dpm.location.tracker.room.storedLoctation -import org.jetbrains.anko.doAsync -import org.jetbrains.anko.uiThread -import java.text.DateFormat -import java.util.ArrayList -import java.util.Date - -class JobServiceDemoActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener { - - private var locationMsg: TextView? = null - - // as google doc says - // Handler for incoming messages from the service. - private var mHandler: IncomingMessageHandler? = null - - private val db: LocationDb - get() = (application as LocationRepository).db - - internal inner class IncomingMessageHandler : Handler() { - - override fun handleMessage(msg: Message) { - Log.i(TAG, "handleMessage..." + msg.toString()) - - super.handleMessage(msg) - - when (msg.what) { - LocationUpdatesService.LOCATION_MESSAGE -> { - val obj = msg.obj as Location - val currentDateTimeString = DateFormat.getDateTimeInstance().format(Date()) - locationMsg!!.text = "LAT : " + obj.latitude + "\nLNG : " + obj.longitude + "\n\n" + obj.toString() + " \n\n\nLast updated- " + currentDateTimeString - } - } - } - } - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_job_service_demo) - val toolbar = findViewById(R.id.toolbar) - setSupportActionBar(toolbar) - - //room - - val list = ArrayList() - for (i in 0..9) { - val location = storedLoctation() - location.lat = "2" - location.lon = "1" - list.add(location) - } - doAsync { - val products = db.locationDao().all - uiThread { - - } - } - - doAsync { - val products = db.locationDao().all - uiThread { - - } - } - - // List products = LocationRepository.get().getDB().locationDao().getAll(); - - val drawer = findViewById(R.id.drawer_layout) - val toggle = ActionBarDrawerToggle( - this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) - drawer.addDrawerListener(toggle) - toggle.syncState() - - val navigationView = findViewById(R.id.nav_view) - navigationView.setNavigationItemSelectedListener(this) - - drawer.setDrawerLockMode(LOCK_MODE_LOCKED_CLOSED) - - locationMsg = findViewById(R.id.location) - - mHandler = IncomingMessageHandler() - - requestPermissions() - } - - override fun onStart() { - super.onStart() - } - - override fun onDestroy() { - super.onDestroy() - mHandler = null - } - - /** - * Callback received when a permissions request has been completed. - */ - override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, - grantResults: IntArray) { - Log.i(TAG, "onRequestPermissionResult") - if (requestCode == REQUEST_PERMISSIONS_REQUEST_CODE) { - if (grantResults.size <= 0) { - // If user interaction was interrupted, the permission request is cancelled and you - // receive empty arrays. - Log.i(TAG, "User interaction was cancelled.") - finish() - } else if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { - // can be schedule in this way also - // Utils.scheduleJob(this, LocationUpdatesService.class); - //doing this way to communicate via messenger - // Start service and provide it a way to communicate with this class. - val startServiceIntent = Intent(this, LocationUpdatesService::class.java) - val messengerIncoming = Messenger(mHandler) - startServiceIntent.putExtra(MESSENGER_INTENT_KEY, messengerIncoming) - startService(startServiceIntent) - } else { - // Permission denied. - finish() - } - } - } - - override fun onBackPressed() { - val drawer = findViewById(R.id.drawer_layout) - if (drawer.isDrawerOpen(GravityCompat.START)) { - drawer.closeDrawer(GravityCompat.START) - } else { - super.onBackPressed() - } - } - - override fun onCreateOptionsMenu(menu: Menu): Boolean { - // Inflate the menu; this adds items to the action bar if it is present. - menuInflater.inflate(R.menu.job_service_demo, menu) - return true - } - - override fun onNavigationItemSelected(item: MenuItem): Boolean { - // Handle navigation view item clicks here. - val id = item.itemId - - if (id == R.id.nav_camera) { - // Handle the camera action - } else if (id == R.id.nav_gallery) { - - } else if (id == R.id.nav_slideshow) { - - } else if (id == R.id.nav_manage) { - - } else if (id == R.id.nav_share) { - - } else if (id == R.id.nav_send) { - - } - - val drawer = findViewById(R.id.drawer_layout) - drawer.closeDrawer(GravityCompat.START) - return true - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. - val id = item.itemId - - - return if (id == R.id.action_settings) { - true - } else super.onOptionsItemSelected(item) - } - - private fun requestPermissions() { - val shouldProvideRationale = ActivityCompat.shouldShowRequestPermissionRationale(this, - Manifest.permission.ACCESS_FINE_LOCATION) - - // Provide an additional rationale to the user. This would happen if the user denied the - // request previously, but didn't check the "Don't ask again" checkbox. - if (shouldProvideRationale) { - Log.i(TAG, "Displaying permission rationale to provide additional context.") - // Request permission - ActivityCompat.requestPermissions(this@JobServiceDemoActivity, - arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), - REQUEST_PERMISSIONS_REQUEST_CODE) - } else { - Log.i(TAG, "Requesting permission") - // Request permission. It's possible this can be auto answered if device policy - // sets the permission in a given state or the user denied the permission - // previously and checked "Never ask again". - ActivityCompat.requestPermissions(this@JobServiceDemoActivity, - arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), - REQUEST_PERMISSIONS_REQUEST_CODE) - } - } - - companion object { - - private val TAG = JobServiceDemoActivity::class.java.simpleName - - /** - * Code used in requesting runtime permissions. - */ - private val REQUEST_PERMISSIONS_REQUEST_CODE = 34 - - val MESSENGER_INTENT_KEY = "msg-intent-key" - - private val DATABASE_NAME = "LocaionDB" - } -} diff --git a/app/src/main/java/dpm/location/tracker/ListViewActivity.kt b/app/src/main/java/dpm/location/tracker/ListViewActivity.kt new file mode 100644 index 0000000..db156d7 --- /dev/null +++ b/app/src/main/java/dpm/location/tracker/ListViewActivity.kt @@ -0,0 +1,41 @@ +package dpm.location.tracker + +import android.os.Bundle +import android.support.v7.app.AppCompatActivity +import android.widget.ArrayAdapter +import android.widget.ListView +import dpm.location.tracker.room.LocationDb +import dpm.location.tracker.room.LocationRepository +import dpm.location.tracker.room.StoredLoctation +import org.jetbrains.anko.doAsync +import org.jetbrains.anko.uiThread +import java.util.ArrayList + +class ListViewActivity : AppCompatActivity() { + + var itemsAdapter : ArrayAdapter? =null + + private val db: LocationDb by lazy { + (application as LocationRepository).db + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_list_view) + + val list = ArrayList() + val location = StoredLoctation() + + val listView = findViewById(R.id.location_listview) as ListView + itemsAdapter = ArrayAdapter(this, R.layout.single_item) + listView.setAdapter(itemsAdapter) + + + doAsync { + val products = db.locationDao().all + uiThread { + itemsAdapter?.addAll(products) + } + } + } +} diff --git a/app/src/main/java/dpm/location/tracker/room/Dao.java b/app/src/main/java/dpm/location/tracker/room/Dao.java index 87d64ba..dbb280c 100644 --- a/app/src/main/java/dpm/location/tracker/room/Dao.java +++ b/app/src/main/java/dpm/location/tracker/room/Dao.java @@ -8,13 +8,16 @@ @android.arch.persistence.room.Dao public interface Dao { - @Query("SELECT * FROM storedLoctation") - List getAll(); + @Query("SELECT * FROM StoredLoctation") + List getAll(); @Insert - void insertAll(List location); + void insertAll(List location); @Update - void update(storedLoctation location); + void update(StoredLoctation location); + + @Query("DELETE FROM StoredLoctation") + public void nukeTable(); } diff --git a/app/src/main/java/dpm/location/tracker/room/LocationAdapter.kt b/app/src/main/java/dpm/location/tracker/room/LocationAdapter.kt new file mode 100644 index 0000000..cd9ae15 --- /dev/null +++ b/app/src/main/java/dpm/location/tracker/room/LocationAdapter.kt @@ -0,0 +1,34 @@ +package dpm.location.tracker.room + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ArrayAdapter +import android.support.annotation.LayoutRes +import dpm.location.tracker.R + +class LocationAdapter(context: Context?, resource: Int) : ArrayAdapter(context, resource) { + private var mContext: Context?=null + private var locationList = ArrayList() + + fun MovieAdapter(context: Context, @LayoutRes list: ArrayList) { + mContext = context + locationList = list + } + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View? { + var listItem = convertView + if (listItem == null) + listItem = LayoutInflater.from(mContext).inflate(R.layout.single_item, parent, false) + + val currentLocation = locationList.get(position) + + //val textbox = listItem?.findViewById(R.id.text1) as TextView\ +// text1.setText("") + + + return listItem + } + +} diff --git a/app/src/main/java/dpm/location/tracker/room/LocationDb.java b/app/src/main/java/dpm/location/tracker/room/LocationDb.java index ba1aae1..51a2642 100644 --- a/app/src/main/java/dpm/location/tracker/room/LocationDb.java +++ b/app/src/main/java/dpm/location/tracker/room/LocationDb.java @@ -3,7 +3,7 @@ import android.arch.persistence.room.Database; import android.arch.persistence.room.RoomDatabase; -@Database(entities = {storedLoctation.class},version = 1,exportSchema = false) +@Database(entities = {StoredLoctation.class},version = 1,exportSchema = false) public abstract class LocationDb extends RoomDatabase { public abstract Dao locationDao(); } diff --git a/app/src/main/java/dpm/location/tracker/room/storedLoctation.java b/app/src/main/java/dpm/location/tracker/room/StoredLoctation.java similarity index 59% rename from app/src/main/java/dpm/location/tracker/room/storedLoctation.java rename to app/src/main/java/dpm/location/tracker/room/StoredLoctation.java index 752309e..abeb882 100644 --- a/app/src/main/java/dpm/location/tracker/room/storedLoctation.java +++ b/app/src/main/java/dpm/location/tracker/room/StoredLoctation.java @@ -3,18 +3,19 @@ import android.arch.persistence.room.ColumnInfo; import android.arch.persistence.room.Entity; import android.arch.persistence.room.PrimaryKey; -import android.location.Location; +import java.util.Locale; @Entity -public class storedLoctation { +public class StoredLoctation { + @PrimaryKey(autoGenerate = true) private int id; @ColumnInfo(name = "Lat") - private String lat; + private Double lat; @ColumnInfo(name = "Long") - private String lon; + private Double lon; public int getId() { return id; @@ -24,20 +25,24 @@ public void setId(int id) { this.id = id; } - public String getLat() { + public Double getLat() { return lat; } - public void setLat(String lat) { + public void setLat(Double lat) { this.lat = lat; } - public String getLon() { + public Double getLon() { return lon; } - public void setLon(String lon) { + public void setLon(Double lon) { this.lon = lon; } + @Override + public String toString() { + return String.format(Locale.getDefault(), "%f, %f", getLat(), getLon()); + } } diff --git a/app/src/main/res/layout/activity_list_view.xml b/app/src/main/res/layout/activity_list_view.xml new file mode 100644 index 0000000..7fba50f --- /dev/null +++ b/app/src/main/res/layout/activity_list_view.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/app/src/main/res/layout/app_bar_job_service_demo.xml b/app/src/main/res/layout/app_bar_job_service_demo.xml index 481213e..8bbe40a 100644 --- a/app/src/main/res/layout/app_bar_job_service_demo.xml +++ b/app/src/main/res/layout/app_bar_job_service_demo.xml @@ -22,4 +22,6 @@ + + diff --git a/app/src/main/res/layout/content_job_service_demo.xml b/app/src/main/res/layout/content_job_service_demo.xml index 6c65874..623f536 100644 --- a/app/src/main/res/layout/content_job_service_demo.xml +++ b/app/src/main/res/layout/content_job_service_demo.xml @@ -31,4 +31,26 @@ app:layout_constraintRight_toRightOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + +