Added Announcement detail page

This commit is contained in:
Caesar2011
2018-07-05 23:35:44 +02:00
parent 264240b35d
commit 4ca7654f94
10 changed files with 208 additions and 18 deletions

2
.idea/misc.xml generated
View File

@@ -25,5 +25,5 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8 (2)" project-jdk-type="JavaSDK" />
</project>

2
.idea/modules.xml generated
View File

@@ -2,7 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/FUPlanner.iml" filepath="$PROJECT_DIR$/FUPlanner.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/FUPlanner.iml" filepath="$PROJECT_DIR$/.idea/FUPlanner.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>

1
.idea/vcs.xml generated
View File

@@ -2,5 +2,6 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@@ -34,7 +34,7 @@ dependencies {
})
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.volley:volley:1.0.0'
//noinspection GradleDependency
implementation 'com.google.android.gms:play-services-auth:15.0.0'
@@ -47,5 +47,7 @@ dependencies {
implementation 'org.jetbrains:annotations-java5:15.0'
implementation 'com.github.alamkanak:android-week-view:1.2.6'
implementation 'com.ms-square:expandableTextView:0.1.4'
// https://github.com/bignerdranch/expandable-recycler-view
implementation 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1'
implementation files('libs/jericho-html-3.4.jar')
}

View File

@@ -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

View File

@@ -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();
}
}

View File

@@ -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);
}
}
}

View File

@@ -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() + "'";
}
}

View File

@@ -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">
<ExpandableListView
android:id="@+id/list"
android:name=".fragments.moddetails.ModDetailAnnounceFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.moddetails.ModDetailAnnounceFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
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>

View 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>