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;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Typeface;
|
||||
@ -8,14 +9,16 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import pl.szczodrzynski.edziennik.R;
|
||||
import pl.szczodrzynski.edziennik.databinding.RowAnnouncementsItemBinding;
|
||||
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> {
|
||||
|
||||
@ -51,7 +54,7 @@ public class AnnouncementsAdapter extends RecyclerView.Adapter<AnnouncementsAdap
|
||||
AnnouncementFull item = announcementList.get(groupPosition);
|
||||
RowAnnouncementsItemBinding b = holder.b;
|
||||
|
||||
b.announcementsItemCard.setOnClickListener((v -> {
|
||||
b.announcementsItem.setOnClickListener((v -> {
|
||||
if (onClick != null) {
|
||||
onClick.onClick(v, item);
|
||||
}
|
||||
@ -59,7 +62,7 @@ public class AnnouncementsAdapter extends RecyclerView.Adapter<AnnouncementsAdap
|
||||
b.announcementsItemSender.setText(item.teacherFullName);
|
||||
b.announcementsItemTitle.setText(item.subject);
|
||||
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) {
|
||||
b.announcementsItemTitle.setBackground(context.getResources().getDrawable(R.drawable.bg_rounded_8dp));
|
||||
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.setBackground(null);
|
||||
}
|
||||
|
||||
Bitmap profileImage = MessagesUtils.getProfileImage(48, 24, 18, 12, 1, item.teacherFullName);
|
||||
b.announcementsItemImage.setImageBitmap(profileImage);
|
||||
}
|
||||
|
||||
class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
@ -22,6 +22,7 @@ import pl.szczodrzynski.edziennik.MainActivity;
|
||||
import pl.szczodrzynski.edziennik.R;
|
||||
import pl.szczodrzynski.edziennik.databinding.DialogAnnouncementBinding;
|
||||
import pl.szczodrzynski.edziennik.databinding.FragmentAnnouncementsBinding;
|
||||
import pl.szczodrzynski.edziennik.utils.SimpleDividerItemDecoration;
|
||||
import pl.szczodrzynski.edziennik.utils.Themes;
|
||||
import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetPrimaryItem;
|
||||
|
||||
@ -77,9 +78,7 @@ public class AnnouncementsFragment extends Fragment {
|
||||
recyclerView = b.announcementsView;
|
||||
recyclerView.setHasFixedSize(true);
|
||||
recyclerView.setLayoutManager(linearLayoutManager);
|
||||
|
||||
|
||||
|
||||
recyclerView.addItemDecoration(new SimpleDividerItemDecoration(view.getContext()));
|
||||
|
||||
app.db.announcementDao().getAll(App.profileId).observe(this, announcements -> {
|
||||
if (app == null || app.profile == null || activity == null || b == null || !isAdded())
|
||||
|
@ -12,7 +12,6 @@ import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.recyclerview.widget.DividerItemDecoration.HORIZONTAL
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
@ -71,9 +70,8 @@ class NotificationsFragment : Fragment() {
|
||||
b.notificationsView.adapter = adapter
|
||||
b.notificationsView.apply {
|
||||
setHasFixedSize(true)
|
||||
layoutManager = LinearLayoutManager(context).apply {
|
||||
addItemDecoration(SimpleDividerItemDecoration(context))
|
||||
}
|
||||
layoutManager = LinearLayoutManager(context)
|
||||
addItemDecoration(SimpleDividerItemDecoration(context))
|
||||
}
|
||||
}
|
||||
adapter.notifyDataSetChanged()
|
||||
@ -87,4 +85,4 @@ class NotificationsFragment : Fragment() {
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,104 +3,92 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<LinearLayout
|
||||
android:id="@+id/announcementsItem"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:padding="8dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/announcementsItemCard"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
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">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<ImageView
|
||||
android:id="@+id/announcementsItemImage"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:srcCompat="@tools:sample/avatars" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/announcementsItemImage"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:srcCompat="@tools:sample/avatars" />
|
||||
<TextView
|
||||
android:id="@+id/announcementsItemSender"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toStartOf="@+id/announcementsItemDate"
|
||||
app:layout_constraintStart_toEndOf="@+id/announcementsItemImage"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Janusz Kowalski" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/announcementsItemSender"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toStartOf="@+id/announcementsItemDate"
|
||||
app:layout_constraintStart_toEndOf="@+id/announcementsItemImage"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Janusz Kowalski" />
|
||||
<TextView
|
||||
android:id="@+id/announcementsItemTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/announcementsItemImage"
|
||||
app:layout_constraintTop_toBottomOf="@+id/announcementsItemSender"
|
||||
tools:text="kocham moją konsolkę gmailową" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/announcementsItemTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/announcementsItemImage"
|
||||
app:layout_constraintTop_toBottomOf="@+id/announcementsItemSender"
|
||||
tools:text="mój sposób na czytanie wiadomości" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/announcementsItemText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:autoLink="all"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/NavView.TextView.Helper"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/announcementsItemImage"
|
||||
app:layout_constraintTop_toBottomOf="@+id/announcementsItemTitle"
|
||||
tools:text="mam sposób na czytanie wiadomości tak żebyście tego nie widzieli i potem myślicie że mam 263 nieprzeczytane wiadomości" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/announcementsItemDate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="18 lut 2018 - 25 mar 2018" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
<TextView
|
||||
android:id="@+id/announcementsItemText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:autoLink="all"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/NavView.TextView.Helper"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/announcementsItemImage"
|
||||
app:layout_constraintTop_toBottomOf="@+id/announcementsItemTitle"
|
||||
tools:text="mam sposób na czytanie wiadomości tak żebyście tego nie widzieli i potem myślicie że mam 263 nieprzeczytane wiadomości" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/announcementsItemDate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="18 lut 2018" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
||||
</layout>
|
||||
</layout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user