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

Commit 756d3b1

Browse files
committed
[ADDED] Sample movie screen with various usage of constraint layout rules.
1 parent 986ccc2 commit 756d3b1

13 files changed

+387
-1
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
<activity
3838
android:name="com.hossainkhan.android.demo.ui.layoutpreview.LayoutDimensionMinMaxActivity"
3939
android:parentActivityName="com.hossainkhan.android.demo.ui.browse.LayoutBrowseActivity" />
40+
<activity
41+
android:name="com.hossainkhan.android.demo.ui.functionaldemo.MovieDetailsPreviewActivity"
42+
android:parentActivityName="com.hossainkhan.android.demo.ui.browse.LayoutBrowseActivity" />
4043
</application>
4144

4245
</manifest>

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,24 @@ class LayoutDataStore @Inject constructor(
159159
title = "Virtual Helper: Group",
160160
description = "This class controls the visibility of a set of referenced widgets. " +
161161
"Widgets are referenced by being added to a comma separated list of ids.\n\n" +
162-
"For example you can link multiple views: `app:constraint_referenced_ids=\"viewId1,viewId2,viewId3\"` and control their visibility at once.")
162+
"For example you can link multiple views: `app:constraint_referenced_ids=\"viewId1,viewId2,viewId3\"` and control their visibility at once."),
163+
164+
/*
165+
* This is a demo of movie details page using various features of constraint layout.
166+
*
167+
* .-'-.
168+
* /` |__
169+
* /` _.--`-,-`
170+
* '-|` a '<-. []
171+
* \ _\__) \=`
172+
* C_ ` ,_/
173+
* | ;----'
174+
*/
175+
LayoutInformation(
176+
layoutResourceId = R.layout.demo_movie_details,
177+
thumbnailResourceId = R.drawable.spider_verse_poster,
178+
title = "Demo: Movie Details",
179+
description = "A demo screen containing movie details.")
163180

164181

165182
/*

app/src/main/java/com/hossainkhan/android/demo/di/ActivityBindingModule.kt

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

1717
package com.hossainkhan.android.demo.di
1818

19+
import com.hossainkhan.android.demo.ui.functionaldemo.MovieDetailsPreviewActivity
1920
import com.hossainkhan.android.demo.ui.layoutpreview.LayoutChainStyleActivity
2021
import com.hossainkhan.android.demo.ui.layoutpreview.LayoutDimensionMinMaxActivity
2122
import com.hossainkhan.android.demo.ui.layoutpreview.LayoutGuidelineBarrierActivity
@@ -73,4 +74,8 @@ abstract class ActivityBindingModule {
7374
@ActivityScope
7475
@ContributesAndroidInjector
7576
abstract fun layoutDimensionMinMaxActivity(): LayoutDimensionMinMaxActivity
77+
78+
@ActivityScope
79+
@ContributesAndroidInjector
80+
abstract fun layoutMovieDetailsPreviewActivity(): MovieDetailsPreviewActivity
7681
}

app/src/main/java/com/hossainkhan/android/demo/ui/browse/LayoutBrowseViewModel.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import androidx.lifecycle.ViewModel
2222
import com.hossainkhan.android.demo.R
2323
import com.hossainkhan.android.demo.data.AppDataStore
2424
import com.hossainkhan.android.demo.data.LayoutInformation
25+
import com.hossainkhan.android.demo.ui.functionaldemo.MovieDetailsPreviewActivity
2526
import com.hossainkhan.android.demo.ui.layoutpreview.LayoutChainStyleActivity
2627
import com.hossainkhan.android.demo.ui.layoutpreview.LayoutDimensionMinMaxActivity
2728
import com.hossainkhan.android.demo.ui.layoutpreview.LayoutGuidelineBarrierActivity
@@ -69,6 +70,9 @@ class LayoutBrowseViewModel(
6970
R.layout.preview_dimension_min_max -> {
7071
browseNavigator.loadLayoutPreview(LayoutDimensionMinMaxActivity::class.java, layoutResId)
7172
}
73+
R.layout.demo_movie_details -> {
74+
browseNavigator.loadLayoutPreview(MovieDetailsPreviewActivity::class.java, layoutResId)
75+
}
7276
else -> {
7377
// By default it loads the preview activity with the layout requested.
7478
browseNavigator.loadLayoutPreview(layoutResId)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
package com.hossainkhan.android.demo.ui.functionaldemo
18+
19+
import android.os.Bundle
20+
import android.view.View
21+
import android.widget.ImageButton
22+
import android.widget.Toast
23+
import com.hossainkhan.android.demo.R
24+
import com.hossainkhan.android.demo.ui.layoutpreview.LayoutPreviewBaseActivity
25+
26+
/**
27+
* Activity showcasing how visibility GONE affects constraints.
28+
*
29+
* See https://developer.android.com/reference/android/support/constraint/ConstraintLayout#VisibilityBehavior
30+
*/
31+
class MovieDetailsPreviewActivity : LayoutPreviewBaseActivity() {
32+
private val generalClickListener = View.OnClickListener { view ->
33+
Toast.makeText(view.context, "You tapped on ${view}", Toast.LENGTH_SHORT).show()
34+
}
35+
36+
override fun onCreate(savedInstanceState: Bundle?) {
37+
super.onCreate(savedInstanceState)
38+
39+
val ratingThumbsUp = findViewById<ImageButton>(R.id.rating_thumbs_up)
40+
val ratingThumbsDown = findViewById<ImageButton>(R.id.rating_thumbs_down)
41+
42+
applyToastListener(ratingThumbsUp, ratingThumbsDown)
43+
}
44+
45+
fun applyToastListener(vararg views: View) {
46+
views.forEach {
47+
it.setOnClickListener(generalClickListener)
48+
}
49+
}
50+
}
Loading
Loading
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:width="18dp"
19+
android:height="18dp"
20+
android:alpha="0.9"
21+
android:tint="#666666"
22+
android:viewportWidth="24.0"
23+
android:viewportHeight="24.0">
24+
<path
25+
android:fillColor="#FF000000"
26+
android:pathData="M16,11c1.66,0 2.99,-1.34 2.99,-3S17.66,5 16,5c-1.66,0 -3,1.34 -3,3s1.34,3 3,3zM8,11c1.66,0 2.99,-1.34 2.99,-3S9.66,5 8,5C6.34,5 5,6.34 5,8s1.34,3 3,3zM8,13c-2.33,0 -7,1.17 -7,3.5L1,19h14v-2.5c0,-2.33 -4.67,-3.5 -7,-3.5zM16,13c-0.29,0 -0.62,0.02 -0.97,0.05 1.16,0.84 1.97,1.97 1.97,3.45L17,19h6v-2.5c0,-2.33 -4.67,-3.5 -7,-3.5z" />
27+
</vector>
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:alpha="0.9" android:height="24dp" android:tint="#666666"
18+
android:viewportHeight="24.0" android:viewportWidth="24.0"
19+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
20+
<path android:fillColor="#FF000000" android:pathData="M14,10L2,10v2h12v-2zM14,6L2,6v2h12L14,6zM18,14v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zM2,16h8v-2L2,14v2z"/>
21+
</vector>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:width="18dp"
19+
android:height="18dp"
20+
android:alpha="0.9"
21+
android:tint="#666666"
22+
android:viewportWidth="24.0"
23+
android:viewportHeight="24.0">
24+
<path
25+
android:fillColor="#FF000000"
26+
android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z" />
27+
</vector>

0 commit comments

Comments
 (0)