Added Announcement detail page
This commit is contained in:
@@ -45,7 +45,6 @@ public class ModulesFragment extends Fragment {
|
||||
public static ModulesFragment newInstance() {
|
||||
ModulesFragment fragment = new ModulesFragment();
|
||||
Bundle args = new Bundle();
|
||||
/*args.putInt(ARG_COLUMN_COUNT, columnCount);*/
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
@@ -53,10 +52,6 @@ public class ModulesFragment extends Fragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
/*if (getArguments() != null) {
|
||||
mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT);
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
package de.sebse.fuplanner.fragments.moddetails;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseExpandableListAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import de.sebse.fuplanner.R;
|
||||
import de.sebse.fuplanner.services.KVV.types.Announcement;
|
||||
import de.sebse.fuplanner.services.KVV.types.Modules;
|
||||
import de.sebse.fuplanner.tools.Conversion;
|
||||
import de.sebse.fuplanner.tools.ui.ItemViewHolder;
|
||||
import de.sebse.fuplanner.tools.ui.StringViewHolder;
|
||||
|
||||
public class ModDetailAnnounceAdapter extends BaseExpandableListAdapter {
|
||||
|
||||
private Modules.Module mModule = null;
|
||||
|
||||
@Override
|
||||
public String getChild(int groupPosition, int childPosititon) {
|
||||
return this.getGroup(groupPosition).getBody();
|
||||
}
|
||||
|
||||
@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(Conversion.getModifiedDateTime(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) {
|
||||
this.mModule = module;
|
||||
this.setModule();
|
||||
}
|
||||
|
||||
public void setModule() {
|
||||
this.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,22 @@
|
||||
package de.sebse.fuplanner.fragments.moddetails;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ExpandableListView;
|
||||
|
||||
import de.sebse.fuplanner.MainActivity;
|
||||
import de.sebse.fuplanner.R;
|
||||
import de.sebse.fuplanner.services.KVV.KVV;
|
||||
import de.sebse.fuplanner.services.KVV.types.Modules;
|
||||
import de.sebse.fuplanner.tools.logging.Logger;
|
||||
|
||||
/**
|
||||
@@ -24,6 +32,8 @@ public class ModDetailAnnounceFragment extends Fragment {
|
||||
// TODO: Rename and change types of parameters
|
||||
private int mItemPos;
|
||||
private Logger log = new Logger(this);
|
||||
private ModDetailAnnounceAdapter adapter;
|
||||
private SwipeRefreshLayout swipeLayout;
|
||||
|
||||
|
||||
public ModDetailAnnounceFragment() {
|
||||
@@ -58,7 +68,41 @@ public class ModDetailAnnounceFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_mod_detail_announce, container, false);
|
||||
View view = inflater.inflate(R.layout.fragment_mod_detail_announce, container, false);
|
||||
// Set the adapter
|
||||
Context context = view.getContext();
|
||||
ExpandableListView expandableListView = view.findViewById(R.id.list);
|
||||
//expandableListView.setLayoutManager(new LinearLayoutManager(context));
|
||||
adapter = new ModDetailAnnounceAdapter();
|
||||
expandableListView.setAdapter(adapter);
|
||||
|
||||
// Getting SwipeContainerLayout
|
||||
swipeLayout = view.findViewById(R.id.swipe_container);
|
||||
// Adding Listener
|
||||
swipeLayout.setOnRefreshListener(() -> refresh(true));
|
||||
refresh(false);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void refresh(boolean forceRefresh) {
|
||||
if (getActivity() != null) {
|
||||
KVV kvv = ((MainActivity) getActivity()).getKVV();
|
||||
kvv.getModuleList((Modules success) -> {
|
||||
Modules.Module module = success.get(mItemPos);
|
||||
adapter.setModule(module);
|
||||
kvv.getModuleAnnouncements(module, success1 -> {
|
||||
adapter.setModule();
|
||||
swipeLayout.setRefreshing(false);
|
||||
}, error -> {
|
||||
swipeLayout.setRefreshing(false);
|
||||
log.e(error);
|
||||
});
|
||||
}, error -> {
|
||||
swipeLayout.setRefreshing(false);
|
||||
log.e(error);
|
||||
}, forceRefresh);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package de.sebse.fuplanner.tools.ui;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import de.sebse.fuplanner.R;
|
||||
|
||||
public class StringViewHolder extends CustomViewHolder {
|
||||
public final TextView mString;
|
||||
|
||||
public StringViewHolder(View view) {
|
||||
super(view);
|
||||
mString = view.findViewById(R.id.string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " '" + mString.getText() + "'";
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<android.support.v4.widget.SwipeRefreshLayout
|
||||
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/swipe_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".fragments.moddetails.ModDetailAnnounceFragment">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:layout_height="match_parent">
|
||||
<ExpandableListView
|
||||
android:id="@+id/list"
|
||||
android:name=".fragments.moddetails.ModDetailAnnounceFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/lorem_ipsum_100" />
|
||||
|
||||
</FrameLayout>
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
|
||||
tools:context=".fragments.moddetails.ModDetailAnnounceFragment"
|
||||
tools:listitem="@layout/list_all_caption" />
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
||||
15
app/src/main/res/layout/list_all_string.xml
Normal file
15
app/src/main/res/layout/list_all_string.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="5dip" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/string"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:typeface="sans"
|
||||
tools:text="Test this new stuff!" />
|
||||
</RelativeLayout>
|
||||
Reference in New Issue
Block a user