diff --git a/app/build.gradle b/app/build.gradle index 2128039..d1a77e5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -101,6 +101,7 @@ dependencies { implementation 'net.danlew:android.joda:2.9.9.4' implementation 'org.greenrobot:eventbus:3.1.1' + implementation 'android.arch.lifecycle:livedata:1.1.1' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 641759d..29f86bb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -13,6 +13,11 @@ android:supportsRtl="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true"> + + () { + + override lateinit var viewModel : CustomerViewModel + + override fun attachBaseContext(newBase: Context) { + super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase)) + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_profile) + + viewModel = getViewModel(CustomerViewModel::class.java) + title = "Profile" + + customer() + + + } + + + private fun customer() { + viewModel.currentCustomer().observe(this, Observer { + response-> + when (response!!.status()){ + Status.LOADING ->{ + showLoading("Retrieve customer details", "This will only take a short while") + } + + Status.SUCCESS ->{ + stopShowingLoading() + var customer = response.data()[0] + + + } + + Status.ERROR ->{ + stopShowingLoading() + Toast.makeText(baseContext, response.error().message.toString(), Toast.LENGTH_LONG).show() + } + + Status.EMPTY ->{ + stopShowingLoading() + } + + } + }) + + } + +} diff --git a/app/src/main/res/layout/activity_profile.xml b/app/src/main/res/layout/activity_profile.xml new file mode 100644 index 0000000..4690851 --- /dev/null +++ b/app/src/main/res/layout/activity_profile.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/content_profile.xml b/app/src/main/res/layout/content_profile.xml new file mode 100644 index 0000000..8308be1 --- /dev/null +++ b/app/src/main/res/layout/content_profile.xml @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 46bc7f1..af66cd7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -36,5 +36,12 @@ BasicCustomerDetailsActivity BillingAddressActivity ShippingAddressActivity + ProfileActivity + + 953 Market\n + San Fransisco, CA 90248 \n + United States \n + (555) 555 555 +