Skip to content
This repository was archived by the owner on Aug 22, 2024. It is now read-only.

Commit 6fcc017

Browse files
committed
[UPDATE] Refined the resource list.
1 parent f9177f5 commit 6fcc017

File tree

8 files changed

+61
-8
lines changed

8 files changed

+61
-8
lines changed

.idea/assetWizardSettings.xml

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/hossainkhan/android/demo/data/LayoutDataStore.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class LayoutDataStore @Inject constructor(
204204
*/
205205
LayoutInformation(
206206
layoutResourceId = R.layout.activity_learning_resource,
207-
thumbnailResourceId = R.drawable.poster_angry_birds,
207+
thumbnailResourceId = R.drawable.ic_book_128dp,
208208
title = "Resources",
209209
description = "XYZ")
210210

app/src/main/java/com/hossainkhan/android/demo/ui/resource/LearningResourceActivity.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ package com.hossainkhan.android.demo.ui.resource
1919
import android.content.ActivityNotFoundException
2020
import android.content.Intent
2121
import android.net.Uri
22-
import androidx.appcompat.app.AppCompatActivity
2322
import android.os.Bundle
23+
import androidx.appcompat.app.AppCompatActivity
2424
import androidx.databinding.DataBindingUtil
2525
import androidx.lifecycle.Observer
2626
import androidx.lifecycle.ViewModelProvider
@@ -48,6 +48,9 @@ class LearningResourceActivity : AppCompatActivity() {
4848
binding = DataBindingUtil.setContentView(this, R.layout.activity_learning_resource)
4949

5050
viewModel = ViewModelProvider(this, viewModelFactory).get(LearningResourceViewModel::class.java)
51+
binding.lifecycleOwner = this
52+
binding.viewModel = viewModel
53+
5154
setupData(binding.recyclerView)
5255
}
5356

app/src/main/java/com/hossainkhan/android/demo/ui/resource/LearningResourceViewModel.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.hossainkhan.android.demo.ui.resource
1818

19+
import androidx.databinding.ObservableField
1920
import androidx.lifecycle.LiveData
2021
import androidx.lifecycle.MutableLiveData
2122
import androidx.lifecycle.ViewModel
@@ -28,6 +29,8 @@ import javax.inject.Inject
2829
class LearningResourceViewModel @Inject constructor(
2930
firestore: FirebaseFirestore
3031
) : ViewModel() {
32+
val isLoading = ObservableField(true)
33+
3134
private val _data = MutableLiveData<List<ResourceInfo>>()
3235
val data: LiveData<List<ResourceInfo>> = _data
3336

@@ -44,9 +47,12 @@ class LearningResourceViewModel @Inject constructor(
4447
Timber.i("Resource: $x")
4548
resourceData.add(x)
4649
}
50+
isLoading.set(false)
4751
_data.value = resourceData
52+
4853
}
4954
.addOnFailureListener { exception ->
55+
isLoading.set(false)
5056
Timber.w(exception, "Error getting documents.")
5157
}
5258
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!--
2+
~ Copyright (c) 2019 Hossain Khan
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
17+
<vector android:height="128dp" android:tint="#51ACBB"
18+
android:viewportHeight="24.0" android:viewportWidth="24.0"
19+
android:width="128dp" xmlns:android="http://schemas.android.com/apk/res/android">
20+
<path android:fillColor="#FF000000" android:pathData="M18,2H6c-1.1,0 -2,0.9 -2,2v16c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V4c0,-1.1 -0.9,-2 -2,-2zM6,4h5v8l-2.5,-1.5L6,12V4z"/>
21+
</vector>

app/src/main/res/layout/activity_learning_resource.xml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,29 @@
3030
app:layout_constraintBottom_toBottomOf="parent"
3131
app:layout_constraintLeft_toLeftOf="parent"
3232
app:layout_constraintRight_toRightOf="parent"
33-
tools:listitem="@layout/list_item_resource_tech_talk"
33+
app:layout_constraintTop_toTopOf="parent"
34+
tools:listitem="@layout/list_item_resource_tech_talk" />
35+
36+
<ProgressBar
37+
android:id="@+id/loading_indicator"
38+
style="?android:attr/progressBarStyle"
39+
android:layout_width="wrap_content"
40+
android:layout_height="wrap_content"
41+
android:visibility="@{safeUnbox(viewModel.isLoading)? View.VISIBLE : View.GONE}"
42+
app:layout_constraintBottom_toBottomOf="parent"
43+
app:layout_constraintEnd_toEndOf="parent"
44+
app:layout_constraintHorizontal_bias="0.5"
45+
app:layout_constraintStart_toStartOf="parent"
3446
app:layout_constraintTop_toTopOf="parent" />
3547

3648
</androidx.constraintlayout.widget.ConstraintLayout>
49+
50+
<data>
51+
52+
<import type="android.view.View" />
53+
54+
<variable
55+
name="viewModel"
56+
type="com.hossainkhan.android.demo.ui.resource.LearningResourceViewModel" />
57+
</data>
3758
</layout>

app/src/main/res/layout/list_item_resource_tech_talk.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
android:layout_height="wrap_content"
6363
android:layout_marginTop="@dimen/material_content_distance_small"
6464
android:layout_marginBottom="@dimen/material_vertical_margin"
65-
android:text="@{data.formattedDate}"
65+
android:text="@{@string/tech_talk_publish_date(data.formattedDate)}"
6666
app:layout_constraintBottom_toBottomOf="parent"
6767
app:layout_constraintStart_toStartOf="@+id/guideline_vertical_start"
6868
app:layout_constraintTop_toBottomOf="@+id/resource_summary"

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424

2525
<string name="additional_resource_title">External Resources</string>
2626
<string name="tech_talk_author_and_venue">by %1$s at %2$s</string>
27+
<string name="tech_talk_publish_date">Published on %1$s</string>
2728

2829
</resources>

0 commit comments

Comments
 (0)