Added Announcement detail page
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -25,5 +25,5 @@
|
|||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</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>
|
</project>
|
||||||
2
.idea/modules.xml
generated
2
.idea/modules.xml
generated
@@ -2,7 +2,7 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<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" />
|
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
1
.idea/vcs.xml
generated
1
.idea/vcs.xml
generated
@@ -2,5 +2,6 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -34,7 +34,7 @@ dependencies {
|
|||||||
})
|
})
|
||||||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||||
implementation 'com.android.support:design: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'
|
implementation 'com.android.volley:volley:1.0.0'
|
||||||
//noinspection GradleDependency
|
//noinspection GradleDependency
|
||||||
implementation 'com.google.android.gms:play-services-auth:15.0.0'
|
implementation 'com.google.android.gms:play-services-auth:15.0.0'
|
||||||
@@ -47,5 +47,7 @@ dependencies {
|
|||||||
implementation 'org.jetbrains:annotations-java5:15.0'
|
implementation 'org.jetbrains:annotations-java5:15.0'
|
||||||
implementation 'com.github.alamkanak:android-week-view:1.2.6'
|
implementation 'com.github.alamkanak:android-week-view:1.2.6'
|
||||||
implementation 'com.ms-square:expandableTextView:0.1.4'
|
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')
|
implementation files('libs/jericho-html-3.4.jar')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ public class ModulesFragment extends Fragment {
|
|||||||
public static ModulesFragment newInstance() {
|
public static ModulesFragment newInstance() {
|
||||||
ModulesFragment fragment = new ModulesFragment();
|
ModulesFragment fragment = new ModulesFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
/*args.putInt(ARG_COLUMN_COUNT, columnCount);*/
|
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
@@ -53,10 +52,6 @@ public class ModulesFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
/*if (getArguments() != null) {
|
|
||||||
mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
package de.sebse.fuplanner.fragments.moddetails;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.Fragment;
|
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.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ExpandableListView;
|
||||||
|
|
||||||
|
import de.sebse.fuplanner.MainActivity;
|
||||||
import de.sebse.fuplanner.R;
|
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;
|
import de.sebse.fuplanner.tools.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,6 +32,8 @@ public class ModDetailAnnounceFragment extends Fragment {
|
|||||||
// TODO: Rename and change types of parameters
|
// TODO: Rename and change types of parameters
|
||||||
private int mItemPos;
|
private int mItemPos;
|
||||||
private Logger log = new Logger(this);
|
private Logger log = new Logger(this);
|
||||||
|
private ModDetailAnnounceAdapter adapter;
|
||||||
|
private SwipeRefreshLayout swipeLayout;
|
||||||
|
|
||||||
|
|
||||||
public ModDetailAnnounceFragment() {
|
public ModDetailAnnounceFragment() {
|
||||||
@@ -58,7 +68,41 @@ 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
|
||||||
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"?>
|
<?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"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/swipe_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
tools:context=".fragments.moddetails.ModDetailAnnounceFragment">
|
<ExpandableListView
|
||||||
|
android:id="@+id/list"
|
||||||
<!-- TODO: Update blank fragment layout -->
|
android:name=".fragments.moddetails.ModDetailAnnounceFragment"
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:text="@string/lorem_ipsum_100" />
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
</FrameLayout>
|
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