Announcement list design update
This commit is contained in:
@@ -6,103 +6,25 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.BaseExpandableListAdapter;
|
import android.widget.BaseExpandableListAdapter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import de.sebse.fuplanner.R;
|
import de.sebse.fuplanner.R;
|
||||||
import de.sebse.fuplanner.services.KVV.types.Announcement;
|
import de.sebse.fuplanner.services.KVV.types.Announcement;
|
||||||
|
import de.sebse.fuplanner.services.KVV.types.Assignment;
|
||||||
import de.sebse.fuplanner.services.KVV.types.Modules;
|
import de.sebse.fuplanner.services.KVV.types.Modules;
|
||||||
|
import de.sebse.fuplanner.tools.Preferences;
|
||||||
import de.sebse.fuplanner.tools.UtilsDate;
|
import de.sebse.fuplanner.tools.UtilsDate;
|
||||||
|
import de.sebse.fuplanner.tools.ui.AnnouncementViewHolder;
|
||||||
import de.sebse.fuplanner.tools.ui.ItemViewHolder;
|
import de.sebse.fuplanner.tools.ui.ItemViewHolder;
|
||||||
|
import de.sebse.fuplanner.tools.ui.MealViewHolder;
|
||||||
import de.sebse.fuplanner.tools.ui.StringViewHolder;
|
import de.sebse.fuplanner.tools.ui.StringViewHolder;
|
||||||
|
|
||||||
class ModDetailAnnounceAdapter extends BaseExpandableListAdapter {
|
class ModDetailAnnounceAdapter extends RecyclerView.Adapter<AnnouncementViewHolder> {
|
||||||
|
|
||||||
private Modules.Module mModule = null;
|
@Nullable private Modules.Module mModule = null;
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getChild(int groupPosition, int childPosition) {
|
|
||||||
StringBuilder s = new StringBuilder(this.getGroup(groupPosition).getBody());
|
|
||||||
ArrayList<String> urls = this.getGroup(groupPosition).getUrls();
|
|
||||||
for (int j =0; j<urls.size(); j++){
|
|
||||||
s.append("\n");
|
|
||||||
s.append(urls.get(j));
|
|
||||||
}
|
|
||||||
return s.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getChildId(int groupPosition, int childPosition) {
|
|
||||||
return childPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getChildView(int groupPosition, final int childPosition,
|
|
||||||
boolean isLastChild, View convertView, ViewGroup parent) {
|
|
||||||
|
|
||||||
final String childText = getChild(groupPosition, childPosition);
|
|
||||||
|
|
||||||
if (convertView == null) {
|
|
||||||
convertView = LayoutInflater.from(parent.getContext())
|
|
||||||
.inflate(R.layout.list_all_string, parent, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
StringViewHolder itemHolder = new StringViewHolder(convertView);
|
|
||||||
itemHolder.mString.setText(childText);
|
|
||||||
|
|
||||||
return convertView;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getChildrenCount(int groupPosition) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Announcement getGroup(int groupPosition) {
|
|
||||||
if (this.mModule != null && this.mModule.announcements != null)
|
|
||||||
return this.mModule.announcements.get(groupPosition);
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getGroupCount() {
|
|
||||||
if (this.mModule != null && this.mModule.announcements != null)
|
|
||||||
return this.mModule.announcements.size();
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getGroupId(int groupPosition) {
|
|
||||||
return groupPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getGroupView(int groupPosition, boolean isExpanded,
|
|
||||||
View convertView, ViewGroup parent) {
|
|
||||||
Announcement announce = getGroup(groupPosition);
|
|
||||||
if (convertView == null) {
|
|
||||||
convertView = LayoutInflater.from(parent.getContext())
|
|
||||||
.inflate(R.layout.list_all_items, parent, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemViewHolder itemHolder = new ItemViewHolder(convertView);
|
|
||||||
itemHolder.mTitle.setText(announce.getTitle());
|
|
||||||
itemHolder.mSubLeft.setText(announce.getCreatedBy());
|
|
||||||
itemHolder.mSubRight.setText(UtilsDate.getModifiedDateTime(parent.getContext(), announce.getCreatedOn()));
|
|
||||||
|
|
||||||
return convertView;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasStableIds() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isChildSelectable(int groupPosition, int childPosition) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModule(Modules.Module module) {
|
public void setModule(Modules.Module module) {
|
||||||
this.mModule = module;
|
this.mModule = module;
|
||||||
@@ -112,4 +34,50 @@ class ModDetailAnnounceAdapter extends BaseExpandableListAdapter {
|
|||||||
public void setModule() {
|
public void setModule() {
|
||||||
this.notifyDataSetChanged();
|
this.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public AnnouncementViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
|
||||||
|
View view = LayoutInflater.from(viewGroup.getContext())
|
||||||
|
.inflate(R.layout.list_announcement_items, viewGroup, false);
|
||||||
|
return new AnnouncementViewHolder(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull AnnouncementViewHolder holder, int position) {
|
||||||
|
holder.reset();
|
||||||
|
Announcement item = getAnnouncement(position);
|
||||||
|
holder.mTitle.setText(item.getTitle());
|
||||||
|
holder.mSubTitle.setText(UtilsDate.getModifiedDateTime(holder.mView.getContext(), item.getCreatedOn()));
|
||||||
|
|
||||||
|
StringBuilder string = new StringBuilder();
|
||||||
|
string.append(item.getBody());
|
||||||
|
List<String> notes = item.getUrls();
|
||||||
|
for (int i1 = 0, notesSize = notes.size(); i1 < notesSize; i1++) {
|
||||||
|
if (i1 != 0)
|
||||||
|
string.append("\n");
|
||||||
|
String s = notes.get(i1);
|
||||||
|
string.append(" - ").append(s);
|
||||||
|
}
|
||||||
|
holder.mNotes.setText(string.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
if (mModule != null && mModule.announcements != null)
|
||||||
|
return mModule.announcements.size();
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemViewType(int position) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Announcement getAnnouncement(int index) {
|
||||||
|
if (mModule != null && mModule.announcements != null)
|
||||||
|
return mModule.announcements.get(index);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ import android.widget.ExpandableListView;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
import de.sebse.fuplanner.MainActivity;
|
import de.sebse.fuplanner.MainActivity;
|
||||||
import de.sebse.fuplanner.R;
|
import de.sebse.fuplanner.R;
|
||||||
@@ -61,9 +62,9 @@ public class ModDetailAnnounceFragment extends Fragment {
|
|||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View view = inflater.inflate(R.layout.fragment_expandable_list_view, container, false);
|
View view = inflater.inflate(R.layout.fragment_recycler_view, container, false);
|
||||||
// Set the adapter
|
// Set the adapter
|
||||||
ExpandableListView expandableListView = view.findViewById(R.id.list);
|
RecyclerView expandableListView = view.findViewById(R.id.list);
|
||||||
adapter = new ModDetailAnnounceAdapter();
|
adapter = new ModDetailAnnounceAdapter();
|
||||||
expandableListView.setAdapter(adapter);
|
expandableListView.setAdapter(adapter);
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import androidx.annotation.NonNull;
|
|||||||
import de.sebse.fuplanner.services.KVV.types.LoginToken;
|
import de.sebse.fuplanner.services.KVV.types.LoginToken;
|
||||||
import de.sebse.fuplanner.services.KVV.types.Modules;
|
import de.sebse.fuplanner.services.KVV.types.Modules;
|
||||||
import de.sebse.fuplanner.tools.MainActivityListener;
|
import de.sebse.fuplanner.tools.MainActivityListener;
|
||||||
import de.sebse.fuplanner.tools.logging.Logger;
|
|
||||||
import de.sebse.fuplanner.tools.network.NetworkCallback;
|
import de.sebse.fuplanner.tools.network.NetworkCallback;
|
||||||
import de.sebse.fuplanner.tools.network.NetworkErrorCallback;
|
import de.sebse.fuplanner.tools.network.NetworkErrorCallback;
|
||||||
|
|
||||||
@@ -26,7 +25,6 @@ public class KVV {
|
|||||||
private final ArrayList<LastTokenCallback> updatingList;
|
private final ArrayList<LastTokenCallback> updatingList;
|
||||||
private final HashMap<String, Object> addons = new HashMap<>();
|
private final HashMap<String, Object> addons = new HashMap<>();
|
||||||
private final MainActivityListener mListener;
|
private final MainActivityListener mListener;
|
||||||
private Logger log = new Logger(this);
|
|
||||||
|
|
||||||
public KVV(Context context) {
|
public KVV(Context context) {
|
||||||
mListener = (MainActivityListener) context;
|
mListener = (MainActivityListener) context;
|
||||||
@@ -35,7 +33,6 @@ public class KVV {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLoggedIn() {
|
public boolean isLoggedIn() {
|
||||||
log.d(this.lastToken, new KVVLogin(this.context).easyLogin());
|
|
||||||
return this.lastToken != null;
|
return this.lastToken != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package de.sebse.fuplanner.tools.ui;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import de.sebse.fuplanner.R;
|
||||||
|
|
||||||
|
public class AnnouncementViewHolder extends ExpandableCardViewHolder {
|
||||||
|
public final TextView mTitle;
|
||||||
|
public final TextView mSubTitle;
|
||||||
|
public final TextView mNotes;
|
||||||
|
|
||||||
|
|
||||||
|
public AnnouncementViewHolder(View view) {
|
||||||
|
super(view);
|
||||||
|
View outerView = getOuterView();
|
||||||
|
View innerView = getInnerView();
|
||||||
|
mTitle = outerView.findViewById(R.id.title);
|
||||||
|
mSubTitle = outerView.findViewById(R.id.sub_title);
|
||||||
|
mNotes = innerView.findViewById(R.id.notes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + " '" + mTitle.getText() + "' '" + mSubTitle.getText() + "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
11
app/src/main/res/layout/list_announcement_body.xml
Normal file
11
app/src/main/res/layout/list_announcement_body.xml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="20dp">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
style="@style/FUTheme.itemValue"
|
||||||
|
android:id="@+id/notes"/>
|
||||||
|
</RelativeLayout>
|
||||||
18
app/src/main/res/layout/list_announcement_header.xml
Normal file
18
app/src/main/res/layout/list_announcement_header.xml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="15dp">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
style="@style/FUTheme.itemTitle" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/sub_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/title"
|
||||||
|
style="@style/FUTheme.itemValue" />
|
||||||
|
</RelativeLayout>
|
||||||
15
app/src/main/res/layout/list_announcement_items.xml
Normal file
15
app/src/main/res/layout/list_announcement_items.xml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<de.sebse.fuplanner.tools.ui.cardview.ExpandableCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/profile"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="4dp"
|
||||||
|
app:animationDuration="300"
|
||||||
|
app:inner_view="@layout/list_announcement_body"
|
||||||
|
app:outer_view="@layout/list_announcement_header"
|
||||||
|
app:startExpanded="false" />
|
||||||
|
<!--
|
||||||
|
|
||||||
|
app:icon="@drawable/ic_event"
|
||||||
|
-->
|
||||||
Reference in New Issue
Block a user