Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
Dunbar
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PLN
Dunbar
Commits
294cff9c
Unverified
Commit
294cff9c
authored
5 years ago
by
PLN (Algolia)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: working friends master/details
parent
d73ffede
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
103 additions
and
59 deletions
+103
-59
FriendDetailActivity.kt
...src/main/java/fr/plnech/dunbar/ui/FriendDetailActivity.kt
+3
-3
FriendDetailFragment.kt
...src/main/java/fr/plnech/dunbar/ui/FriendDetailFragment.kt
+9
-6
FriendListActivity.kt
app/src/main/java/fr/plnech/dunbar/ui/FriendListActivity.kt
+7
-4
FriendsAdapter.kt
app/src/main/java/fr/plnech/dunbar/ui/FriendsAdapter.kt
+2
-3
friend_list.xml
app/src/main/res/layout-w900dp/friend_list.xml
+53
-30
contact_listitem.xml
app/src/main/res/layout/contact_listitem.xml
+0
-0
contacts_listview.xml
app/src/main/res/layout/contacts_listview.xml
+1
-1
content_contacts.xml
app/src/main/res/layout/content_contacts.xml
+2
-1
friend_detail.xml
app/src/main/res/layout/friend_detail.xml
+22
-8
friend_list.xml
app/src/main/res/layout/friend_list.xml
+4
-3
No files found.
app/src/main/java/fr/plnech/dunbar/ui/FriendDetailActivity.kt
View file @
294cff9c
...
...
@@ -32,9 +32,9 @@ class FriendDetailActivity : AppCompatActivity() {
supportFragmentManager
.
beginTransaction
()
.
add
(
R
.
id
.
friend_detail_container
,
FriendDetailFragment
().
apply
{
arguments
=
Bundle
().
apply
{
put
String
(
FriendDetailFragment
.
ARG_
ITEM
_ID
,
intent
.
get
StringExtra
(
FriendDetailFragment
.
ARG_ITEM_ID
)
put
Int
(
FriendDetailFragment
.
ARG_
FRIEND
_ID
,
intent
.
get
IntExtra
(
FriendDetailFragment
.
ARG_FRIEND_ID
,
-
1
)
)
}
})
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/fr/plnech/dunbar/ui/FriendDetailFragment.kt
View file @
294cff9c
...
...
@@ -28,11 +28,13 @@ class FriendDetailFragment : Fragment() {
super
.
onCreate
(
savedInstanceState
)
arguments
?.
let
{
if
(
it
.
containsKey
(
ARG_ITEM_ID
))
{
println
(
"Got args!"
)
if
(
it
.
containsKey
(
ARG_FRIEND_ID
))
{
// Load the dummy content specified by the fragment
// arguments. In a real-world scenario, use a Loader
// to load content from a content provider.
item
=
DummyContent
.
ITEM_MAP
[
it
.
getInt
(
ARG_ITEM_ID
)]
item
=
DummyContent
.
ITEM_MAP
[
it
.
getInt
(
ARG_FRIEND_ID
)]
println
(
"item: $item"
)
activity
?.
toolbar_layout
?.
title
=
item
?.
name
}
}
...
...
@@ -43,11 +45,12 @@ class FriendDetailFragment : Fragment() {
savedInstanceState
:
Bundle
?
):
View
?
{
val
rootView
=
inflater
.
inflate
(
R
.
layout
.
friend_detail
,
container
,
false
)
// Show the dummy content as text in a TextView.
item
?.
let
{
rootView
.
friend_detail
.
text
=
it
.
mapString
(
)
println
(
"Got friend: ${it.name}"
)
activity
?.
title
=
it
.
name
rootView
.
apply
{
friendData
.
text
=
it
.
mapString
()
}
}
return
rootView
...
...
@@ -58,6 +61,6 @@ class FriendDetailFragment : Fragment() {
* The fragment argument representing the item ID that this fragment
* represents.
*/
const
val
ARG_
ITEM
_ID
=
"item_id"
const
val
ARG_
FRIEND
_ID
=
"item_id"
}
}
This diff is collapsed.
Click to expand it.
app/src/main/java/fr/plnech/dunbar/ui/FriendListActivity.kt
View file @
294cff9c
...
...
@@ -83,7 +83,8 @@ class FriendListActivity : AppCompatActivity() {
contactsList
.
layoutManager
=
LinearLayoutManager
(
this
)
contactsList
.
setHasFixedSize
(
true
)
contactsList
.
adapter
=
adapter
`@
+
id
/
contactsTitle
`
.
text
=
getString
(
R
.
string
.
text_welcome
).
format
(
nbFriends
,
"friend"
.
plural
(
nbFriends
))
friends_title
.
text
=
getString
(
R
.
string
.
text_welcome
).
format
(
nbFriends
,
"friend"
.
plural
(
nbFriends
))
}
...
...
@@ -106,11 +107,12 @@ class FriendListActivity : AppCompatActivity() {
init
{
onClickListener
=
View
.
OnClickListener
{
v
->
val
item
=
v
.
tag
as
Friend
val
friend
=
v
.
tag
as
Friend
if
(
twoPane
)
{
val
fragment
=
FriendDetailFragment
().
apply
{
arguments
=
Bundle
().
apply
{
putString
(
FriendDetailFragment
.
ARG_ITEM_ID
,
"friend_${item.id}"
)
putInt
(
FriendDetailFragment
.
ARG_FRIEND_ID
,
friend
.
id
)
println
(
"Put arg: ${friend.id}"
)
}
}
parentActivity
.
supportFragmentManager
...
...
@@ -119,7 +121,8 @@ class FriendListActivity : AppCompatActivity() {
.
commit
()
}
else
{
val
intent
=
Intent
(
v
.
context
,
FriendDetailActivity
::
class
.
java
).
apply
{
putExtra
(
FriendDetailFragment
.
ARG_ITEM_ID
,
"friend_${item.id}"
)
putExtra
(
FriendDetailFragment
.
ARG_FRIEND_ID
,
friend
.
id
)
println
(
"Put arg: ${friend.id}"
)
}
v
.
context
.
startActivity
(
intent
)
}
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/fr/plnech/dunbar/ui/FriendsAdapter.kt
View file @
294cff9c
...
...
@@ -8,7 +8,7 @@ import android.widget.Toast
import
androidx.recyclerview.widget.RecyclerView
import
fr.plnech.dunbar.R
import
fr.plnech.dunbar.model.Friend
import
kotlinx.android.synthetic.main.contact.view.*
import
kotlinx.android.synthetic.main.contact
_listitem
.view.*
class
FriendsAdapter
(
...
...
@@ -22,7 +22,7 @@ class FriendsAdapter(
override
fun
getItemCount
():
Int
=
friends
.
size
override
fun
getItemViewType
(
position
:
Int
):
Int
=
R
.
layout
.
contact
override
fun
getItemViewType
(
position
:
Int
):
Int
=
R
.
layout
.
contact
_listitem
override
fun
onBindViewHolder
(
holder
:
FriendsViewHolder
,
position
:
Int
):
Unit
=
holder
.
bind
(
friends
[
position
])
...
...
@@ -85,5 +85,4 @@ class FriendsViewHolder(private val view: View) : RecyclerView.ViewHolder(view)
}
}
}
}
This diff is collapsed.
Click to expand it.
app/src/main/res/layout-w900dp/friend_list.xml
View file @
294cff9c
<?xml version="1.0" encoding="utf-8"?>
<
Linear
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<
androidx.constraintlayout.widget.Constraint
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_marginLeft=
"16dp"
android:layout_marginRight=
"16dp"
android:baselineAligned=
"false"
android:divider=
"?android:attr/dividerHorizontal"
android:orientation=
"horizontal"
android:showDividers=
"middle"
tools:context=
".ui.FriendListActivity"
>
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
>
<!--
This layout is a two-pane layout for the Friends
master/detail flow.
-->
<TextView
android:id=
"@+id/friends_title"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
android:layout_marginBottom=
"8dp"
android:textSize=
"24sp"
app:layout_constraintBottom_toTopOf=
"@id/panes"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.0"
tools:text=
"N friends on Dunbar"
/>
<androidx.recyclerview.widget.RecyclerView
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/friend_list"
android:name=
"fr.plnech.dunbar.FriendListFragment"
android:layout_width=
"@dimen/item_width"
<LinearLayout
android:id=
"@+id/panes"
app:layout_constraintTop_toBottomOf=
"@id/friends_title"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_marginLeft=
"16dp"
android:layout_marginRight=
"16dp"
app:layoutManager=
"LinearLayoutManager"
tools:context=
"fr.plnech.dunbar.ui.FriendListActivity"
tools:listitem=
"@layout/friend_list_content"
/>
android:baselineAligned=
"false"
android:divider=
"?android:attr/dividerHorizontal"
android:orientation=
"horizontal"
android:showDividers=
"middle"
tools:context=
".ui.FriendListActivity"
>
<FrameLayout
android:id=
"@+id/friend_detail_container"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"3"
/>
<!--
This layout is a two-pane layout for the Friends
master/detail flow.
-->
<androidx.recyclerview.widget.RecyclerView
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/friend_list"
android:name=
"fr.plnech.dunbar.FriendListFragment"
android:layout_width=
"@dimen/item_width"
android:layout_height=
"match_parent"
android:layout_marginLeft=
"16dp"
android:layout_marginRight=
"16dp"
app:layoutManager=
"LinearLayoutManager"
tools:context=
"fr.plnech.dunbar.ui.FriendListActivity"
tools:listitem=
"@layout/friend_list_content"
/>
<FrameLayout
android:id=
"@+id/friend_detail_container"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"3"
/>
</LinearLayout>
\ No newline at end of file
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
This diff is collapsed.
Click to expand it.
app/src/main/res/layout/contact.xml
→
app/src/main/res/layout/contact
_listitem
.xml
View file @
294cff9c
File moved
This diff is collapsed.
Click to expand it.
app/src/main/res/layout/contacts.xml
→
app/src/main/res/layout/contacts
_listview
.xml
View file @
294cff9c
...
...
@@ -2,6 +2,6 @@
<ListView
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/contact_list_item"
tools:listitem=
"@layout/contact"
tools:listitem=
"@layout/contact
_listitem
"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
This diff is collapsed.
Click to expand it.
app/src/main/res/layout/content_contacts.xml
View file @
294cff9c
...
...
@@ -31,7 +31,7 @@
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/contactsTitle"
tools:listitem=
"@layout/contact"
tools:listitem=
"@layout/contact
_listitem
"
tools:text=
"@tools:sample/last_names"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
app/src/main/res/layout/friend_detail.xml
View file @
294cff9c
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android=
"http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/friend_detail"
style=
"?android:attr/textAppearanceLarge"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:padding=
"16dp"
android:textIsSelectable=
"true"
tools:context=
".ui.FriendDetailFragment"
/>
\ No newline at end of file
android:layout_height=
"wrap_content"
android:layout_marginTop=
"24dp"
>
<TextView
android:id=
"@+id/friendData"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"8dp"
android:layout_marginEnd=
"15dp"
android:focusable=
"false"
android:focusableInTouchMode=
"false"
android:gravity=
"end"
android:textAppearance=
"@style/TextAppearance.AppCompat.Subhead"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
tools:text=
"2 interactions, last 1 hour ago"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
This diff is collapsed.
Click to expand it.
app/src/main/res/layout/friend_list.xml
View file @
294cff9c
...
...
@@ -6,10 +6,10 @@
android:layout_height=
"match_parent"
app:layout_behavior=
"@string/appbar_scrolling_view_behavior"
tools:context=
".ui.ContactsActivity"
tools:showIn=
"@layout/activity_friends"
>
tools:showIn=
"@layout/activity_friends
_list
"
>
<TextView
android:id=
"@+id/
contactsT
itle"
android:id=
"@+id/
friends_t
itle"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
...
...
@@ -31,5 +31,5 @@
android:layout_marginRight=
"16dp"
app:layoutManager=
"LinearLayoutManager"
tools:context=
".ui.FriendListActivity"
tools:listitem=
"@layout/contact"
/>
tools:listitem=
"@layout/contact
_listitem
"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment