forked from github/szkolny
[UI/Announcements] Make better announcements look.
This commit is contained in:
parent
e7db4e9326
commit
c1ca104021
@ -1,6 +1,7 @@
|
|||||||
package pl.szczodrzynski.edziennik.ui.modules.announcements;
|
package pl.szczodrzynski.edziennik.ui.modules.announcements;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
@ -8,14 +9,16 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.databinding.DataBindingUtil;
|
import androidx.databinding.DataBindingUtil;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import pl.szczodrzynski.edziennik.R;
|
import pl.szczodrzynski.edziennik.R;
|
||||||
import pl.szczodrzynski.edziennik.databinding.RowAnnouncementsItemBinding;
|
|
||||||
import pl.szczodrzynski.edziennik.data.db.modules.announcements.AnnouncementFull;
|
import pl.szczodrzynski.edziennik.data.db.modules.announcements.AnnouncementFull;
|
||||||
|
import pl.szczodrzynski.edziennik.databinding.RowAnnouncementsItemBinding;
|
||||||
|
import pl.szczodrzynski.edziennik.ui.modules.messages.MessagesUtils;
|
||||||
|
|
||||||
public class AnnouncementsAdapter extends RecyclerView.Adapter<AnnouncementsAdapter.ViewHolder> {
|
public class AnnouncementsAdapter extends RecyclerView.Adapter<AnnouncementsAdapter.ViewHolder> {
|
||||||
|
|
||||||
@ -51,7 +54,7 @@ public class AnnouncementsAdapter extends RecyclerView.Adapter<AnnouncementsAdap
|
|||||||
AnnouncementFull item = announcementList.get(groupPosition);
|
AnnouncementFull item = announcementList.get(groupPosition);
|
||||||
RowAnnouncementsItemBinding b = holder.b;
|
RowAnnouncementsItemBinding b = holder.b;
|
||||||
|
|
||||||
b.announcementsItemCard.setOnClickListener((v -> {
|
b.announcementsItem.setOnClickListener((v -> {
|
||||||
if (onClick != null) {
|
if (onClick != null) {
|
||||||
onClick.onClick(v, item);
|
onClick.onClick(v, item);
|
||||||
}
|
}
|
||||||
@ -59,7 +62,7 @@ public class AnnouncementsAdapter extends RecyclerView.Adapter<AnnouncementsAdap
|
|||||||
b.announcementsItemSender.setText(item.teacherFullName);
|
b.announcementsItemSender.setText(item.teacherFullName);
|
||||||
b.announcementsItemTitle.setText(item.subject);
|
b.announcementsItemTitle.setText(item.subject);
|
||||||
b.announcementsItemText.setText(item.text);
|
b.announcementsItemText.setText(item.text);
|
||||||
b.announcementsItemDate.setText(item.startDate.getFormattedString()+(item.endDate == null ? "" : " - "+item.endDate.getFormattedString()));
|
b.announcementsItemDate.setText(item.startDate.getFormattedString());
|
||||||
if (!item.seen) {
|
if (!item.seen) {
|
||||||
b.announcementsItemTitle.setBackground(context.getResources().getDrawable(R.drawable.bg_rounded_8dp));
|
b.announcementsItemTitle.setBackground(context.getResources().getDrawable(R.drawable.bg_rounded_8dp));
|
||||||
b.announcementsItemTitle.getBackground().setColorFilter(new PorterDuffColorFilter(0x692196f3, PorterDuff.Mode.MULTIPLY));
|
b.announcementsItemTitle.getBackground().setColorFilter(new PorterDuffColorFilter(0x692196f3, PorterDuff.Mode.MULTIPLY));
|
||||||
@ -70,6 +73,9 @@ public class AnnouncementsAdapter extends RecyclerView.Adapter<AnnouncementsAdap
|
|||||||
b.announcementsItemTitle.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
|
b.announcementsItemTitle.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
|
||||||
b.announcementsItemTitle.setBackground(null);
|
b.announcementsItemTitle.setBackground(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bitmap profileImage = MessagesUtils.getProfileImage(48, 24, 18, 12, 1, item.teacherFullName);
|
||||||
|
b.announcementsItemImage.setImageBitmap(profileImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ViewHolder extends RecyclerView.ViewHolder {
|
class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
@ -22,6 +22,7 @@ import pl.szczodrzynski.edziennik.MainActivity;
|
|||||||
import pl.szczodrzynski.edziennik.R;
|
import pl.szczodrzynski.edziennik.R;
|
||||||
import pl.szczodrzynski.edziennik.databinding.DialogAnnouncementBinding;
|
import pl.szczodrzynski.edziennik.databinding.DialogAnnouncementBinding;
|
||||||
import pl.szczodrzynski.edziennik.databinding.FragmentAnnouncementsBinding;
|
import pl.szczodrzynski.edziennik.databinding.FragmentAnnouncementsBinding;
|
||||||
|
import pl.szczodrzynski.edziennik.utils.SimpleDividerItemDecoration;
|
||||||
import pl.szczodrzynski.edziennik.utils.Themes;
|
import pl.szczodrzynski.edziennik.utils.Themes;
|
||||||
import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetPrimaryItem;
|
import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetPrimaryItem;
|
||||||
|
|
||||||
@ -77,9 +78,7 @@ public class AnnouncementsFragment extends Fragment {
|
|||||||
recyclerView = b.announcementsView;
|
recyclerView = b.announcementsView;
|
||||||
recyclerView.setHasFixedSize(true);
|
recyclerView.setHasFixedSize(true);
|
||||||
recyclerView.setLayoutManager(linearLayoutManager);
|
recyclerView.setLayoutManager(linearLayoutManager);
|
||||||
|
recyclerView.addItemDecoration(new SimpleDividerItemDecoration(view.getContext()));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app.db.announcementDao().getAll(App.profileId).observe(this, announcements -> {
|
app.db.announcementDao().getAll(App.profileId).observe(this, announcements -> {
|
||||||
if (app == null || app.profile == null || activity == null || b == null || !isAdded())
|
if (app == null || app.profile == null || activity == null || b == null || !isAdded())
|
||||||
|
@ -12,7 +12,6 @@ import android.view.ViewGroup
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.recyclerview.widget.DividerItemDecoration.HORIZONTAL
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
||||||
import pl.szczodrzynski.edziennik.App
|
import pl.szczodrzynski.edziennik.App
|
||||||
@ -71,11 +70,10 @@ class NotificationsFragment : Fragment() {
|
|||||||
b.notificationsView.adapter = adapter
|
b.notificationsView.adapter = adapter
|
||||||
b.notificationsView.apply {
|
b.notificationsView.apply {
|
||||||
setHasFixedSize(true)
|
setHasFixedSize(true)
|
||||||
layoutManager = LinearLayoutManager(context).apply {
|
layoutManager = LinearLayoutManager(context)
|
||||||
addItemDecoration(SimpleDividerItemDecoration(context))
|
addItemDecoration(SimpleDividerItemDecoration(context))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
adapter.notifyDataSetChanged()
|
adapter.notifyDataSetChanged()
|
||||||
|
|
||||||
if (notifications != null && notifications.isNotEmpty()) {
|
if (notifications != null && notifications.isNotEmpty()) {
|
||||||
|
@ -3,23 +3,13 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/announcementsItem"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:padding="8dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:id="@+id/announcementsItemCard"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="8dp"
|
|
||||||
app:cardElevation="4dp"
|
|
||||||
app:cardCornerRadius="5dp"
|
|
||||||
android:background="?selectableItemBackground"
|
|
||||||
android:paddingLeft="10dp"
|
|
||||||
android:paddingTop="5dp"
|
|
||||||
android:paddingRight="10dp"
|
|
||||||
android:paddingBottom="3dp">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
@ -39,8 +29,8 @@
|
|||||||
android:id="@+id/announcementsItemSender"
|
android:id="@+id/announcementsItemSender"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="16dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_marginRight="8dp"
|
android:layout_marginRight="8dp"
|
||||||
@ -57,8 +47,8 @@
|
|||||||
android:id="@+id/announcementsItemTitle"
|
android:id="@+id/announcementsItemTitle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="20dp"
|
android:layout_height="20dp"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="16dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_marginRight="8dp"
|
android:layout_marginRight="8dp"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
@ -68,14 +58,14 @@
|
|||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@+id/announcementsItemImage"
|
app:layout_constraintStart_toEndOf="@+id/announcementsItemImage"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/announcementsItemSender"
|
app:layout_constraintTop_toBottomOf="@+id/announcementsItemSender"
|
||||||
tools:text="mój sposób na czytanie wiadomości" />
|
tools:text="kocham moją konsolkę gmailową" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/announcementsItemText"
|
android:id="@+id/announcementsItemText"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="16dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_marginRight="8dp"
|
android:layout_marginRight="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
@ -98,9 +88,7 @@
|
|||||||
android:layout_marginRight="8dp"
|
android:layout_marginRight="8dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:text="18 lut 2018 - 25 mar 2018" />
|
tools:text="18 lut 2018" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</layout>
|
</layout>
|
Loading…
x
Reference in New Issue
Block a user