View MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
private CardView cardView; | |
private Boolean isCollapsed = true; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); |
View PeopleActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PeopleActivity : AppCompatActivity() { | |
private val people = listOf( | |
Person(1, "Person 1", "Brazil"), | |
Person(2, "Person 2", "USA"), | |
Person(3, "Person 3", "Canada"), | |
Person(4, "Person 4", "Russia"), | |
Person(5, "Person 5", "Germany") | |
) |
View PeopleAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PeopleAdapter(private val people: List<Person>, private val listener: Listener) : | |
RecyclerView.Adapter<PeopleAdapter.ViewHolder>() { | |
private var selectedPerson: Person? = null | |
interface Listener { | |
fun onItemClicked(person: Person) | |
} | |
fun updateSelectedPerson(person: Person) { |
View RecyclerView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | |
holder.apply { | |
checkBox.isChecked = position == mCheckedPosition | |
checkBox.setOnClickListener { | |
if(position == mCheckedPosition) { | |
checkBox.isChecked = false | |
mCheckedPosition = -1 | |
} else { | |
mCheckedPosition = position | |
notifyDataSetChanged() |
View PeopleViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PeopleViewModel : ViewModel() { | |
private val selectedPerson = MutableLiveData<Person>() | |
fun setSelectedPerson(person: Person){ | |
selectedPerson.value = person | |
} | |
fun getSelectedPerson() = selectedPerson | |
} |
View group_retweet.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<android.support.constraint.Group | |
android:id="@+id/group_retweet" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
app:constraint_referenced_ids="retweet_top, retweet_user"/> |
View activity_main.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.constraint.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:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
tools:context=".MainActivity" | |
android:background="@color/mirage" | |
android:padding="16dp"> |
View comment.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ImageView | |
android:id="@+id/comment" | |
android:layout_width="21dp" | |
android:layout_height="21dp" | |
android:layout_marginTop="12dp" | |
android:src="@drawable/ic_comment" | |
android:tint="@color/gray" | |
app:layout_constraintTop_toBottomOf="@+id/text" |
View profile_image.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<de.hdodenhof.circleimageview.CircleImageView | |
android:id="@+id/profile_image" | |
android:layout_width="50dp" | |
android:layout_height="50dp" | |
android:layout_marginTop="8dp" | |
android:src="@drawable/profile_image" | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintLeft_toLeftOf="parent"/> |
View group_retweet.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<android.support.constraint.Group | |
android:id="@+id/group_retweet" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
app:constraint_referenced_ids="retweet_top, retweet_user"/> |
NewerOlder