CourseByMarks phone layout

This commit is contained in:
Peter Siegmund committed 2015-10-19 17:16:24 +02:00
1 parent 8326b32819
commit b37df2ddf1
23 files changed
+453 -160

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

@@ -5,8 +5,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:padding="@dimen/default_padding_half"
android:orientation="vertical">
android:orientation="vertical"
android:padding="@dimen/default_padding_half">
<ImageView
android:id="@+id/cell_image"
@@ -21,10 +21,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="@dimen/default_padding_half"
android:singleLine="true"
android:textAppearance="?textXXSmall"
android:textColor="?white"
android:textIsSelectable="false"
android:textAppearance="?textXXSmall"
tools:text="Black Cylinder"
android:singleLine="true"/>
tools:text="Black Cylinder"/>
</LinearLayout>
@@ -3,98 +3,114 @@
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:layout_height="wrap_content"
android:background="@color/constant_white">
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:orientation="vertical"
tools:ignore="UseCompoundDrawables">
<LinearLayout
android:id="@+id/column_left"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:gravity="center"
android:orientation="vertical">
android:paddingBottom="@dimen/default_margin_half"
android:paddingTop="@dimen/default_margin_half">
<ImageView
android:id="@+id/column_left_image"
android:layout_width="wrap_content"
<LinearLayout
android:id="@+id/column_left"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:contentDescription="@string/markImage"
android:layout_gravity="center"
android:layout_weight="4"
android:gravity="center"
tools:src="@drawable/buoy_dark_orange"/>
android:orientation="vertical">
<ImageView
android:id="@+id/column_left_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/markImage"
android:gravity="center"
tools:src="@drawable/buoy_shadow"/>
<TextView
android:id="@+id/column_left_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:singleLine="true"
android:textAppearance="?textXXSmall"
android:textColor="?white"
android:textIsSelectable="false"
tools:text="Pin End"/>
</LinearLayout>
<TextView
android:id="@+id/column_left_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:singleLine="true"
android:textAppearance="?textXXSmall"
android:textColor="?white"
android:textIsSelectable="false"
tools:text="Pin End"/>
</LinearLayout>
<TextView
android:id="@+id/rounding_direction"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:background="@drawable/circle"
android:gravity="center"
android:singleLine="true"
android:textAppearance="?textSmall"
android:textColor="?white"
android:textIsSelectable="false"
tools:text="G"/>
<LinearLayout
android:id="@+id/column_right"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:gravity="center_horizontal|center_vertical"
android:orientation="vertical">
<ImageView
android:id="@+id/column_right_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/markImage"
android:gravity="center"
tools:src="@drawable/buoy_dark_orange"/>
<TextView
android:id="@+id/column_right_text"
android:layout_width="match_parent"
android:id="@+id/rounding_direction"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="2"
android:background="@drawable/circle"
android:gravity="center"
android:padding="5dp"
android:singleLine="true"
android:textAppearance="?textXXSmall"
android:textAppearance="?textSmall"
android:textColor="?white"
android:textIsSelectable="false"
tools:text="Startboat"/>
tools:text="G"/>
<LinearLayout
android:id="@+id/column_right"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="4"
android:gravity="center_horizontal|center_vertical"
android:orientation="vertical">
<ImageView
android:id="@+id/column_right_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/markImage"
android:gravity="center"
tools:src="@drawable/buoy_shadow"/>
<TextView
android:id="@+id/column_right_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:padding="5dp"
android:singleLine="true"
android:textAppearance="?textXXSmall"
android:textColor="?white"
android:textIsSelectable="false"
tools:text="Startboat"/>
</LinearLayout>
<RelativeLayout
android:id="@id/drag_handle"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_gravity="center_vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/dragster"
android:contentDescription="@string/drag_handle_description"/>
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:id="@id/drag_handle"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_gravity="center_vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/dragster"
android:contentDescription="@string/drag_handle_description"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/thin_line"
android:background="?sap_gray_white_20"/>
</LinearLayout>
</FrameLayout>
@@ -191,12 +191,6 @@
android:textAppearance="?textPanelCaption"
tools:text="4 + 3 = 7 Minuten"/>
</RelativeLayout>
<ImageView
android:layout_width="@dimen/thin_line"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:src="?white"/>
</RelativeLayout>
</LinearLayout>
@@ -35,21 +35,21 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/start_procedure"
android:textAppearance="?textPanelHeader"
android:layout_gravity="center"/>
android:textAppearance="?textPanelHeader"/>
<ImageView
android:id="@+id/start_procedure_lock"
android:layout_width="@dimen/side_button_lockSize"
android:layout_height="@dimen/side_button_lockSize"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/lock_margin"
android:layout_marginRight="@dimen/lock_margin"
android:src="?lock_outline"
android:tint="?sap_light_gray"
android:visibility="gone"
tools:visibility="visible"
android:layout_gravity="center"/>
tools:visibility="visible"/>
</LinearLayout>
<RelativeLayout
@@ -94,21 +94,21 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/course"
android:textAppearance="?textPanelHeader"
android:layout_gravity="center"/>
android:textAppearance="?textPanelHeader"/>
<ImageView
android:id="@+id/course_lock"
android:layout_width="@dimen/side_button_lockSize"
android:layout_height="@dimen/side_button_lockSize"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/lock_margin"
android:layout_marginRight="@dimen/lock_margin"
android:src="?lock_outline"
android:tint="?sap_light_gray"
android:visibility="gone"
tools:visibility="visible"
android:layout_gravity="center"/>
tools:visibility="visible"/>
</LinearLayout>
<RelativeLayout
@@ -152,21 +152,21 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/wind"
android:textAppearance="?textPanelHeader"
android:layout_gravity="center"/>
android:textAppearance="?textPanelHeader"/>
<ImageView
android:id="@+id/wind_lock"
android:layout_width="@dimen/side_button_lockSize"
android:layout_height="@dimen/side_button_lockSize"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/lock_margin"
android:layout_marginRight="@dimen/lock_margin"
android:src="?lock_outline"
android:tint="?sap_light_gray"
android:visibility="gone"
tools:visibility="visible"
android:layout_gravity="center"/>
tools:visibility="visible"/>
</LinearLayout>
<RelativeLayout
@@ -179,7 +179,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:drawableTop="?wind_off"
android:gravity="center"
android:text="@string/wind_no_data"
android:textAppearance="?textPanelCaption"/>
@@ -210,21 +209,21 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/start_procedure_more"
android:textAppearance="?textPanelHeader"
android:layout_gravity="center"/>
android:textAppearance="?textPanelHeader"/>
<ImageView
android:id="@+id/start_procedure_more_lock"
android:layout_width="@dimen/side_button_lockSize"
android:layout_height="@dimen/side_button_lockSize"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/lock_margin"
android:layout_marginRight="@dimen/lock_margin"
android:src="?lock_outline"
android:tint="?sap_light_gray"
android:visibility="gone"
tools:visibility="visible"
android:layout_gravity="center"/>
tools:visibility="visible"/>
</LinearLayout>
<RelativeLayout
@@ -236,8 +235,8 @@
android:id="@+id/start_procedure_more_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="?keyboard_control_36dp"
android:layout_centerInParent="true"/>
android:layout_centerInParent="true"
android:src="?keyboard_control_36dp"/>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
@@ -22,6 +22,7 @@
android:src="?chevron_left_24dp"/>
<TextView
android:id="@+id/header_caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
@@ -0,0 +1,132 @@
<?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="match_parent"
android:orientation="vertical">
<include
android:id="@+id/header"
layout="@layout/race_schedule_course_header"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/header"
android:background="?sap_gray_black_30">
<RelativeLayout
android:id="@+id/selection"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?sap_gray_black_30"
android:visibility="gone">
<android.support.v7.widget.RecyclerView
android:id="@+id/chooser"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/course_prev"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<FrameLayout
android:id="@+id/load_prev"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:paddingBottom="@dimen/side_padding"
android:paddingLeft="@dimen/side_padding"
android:paddingRight="@dimen/side_padding"
android:paddingTop="@dimen/side_padding">
<Button
android:id="@+id/takeHistoryCourse"
style="?button"
android:layout_width="@dimen/default_button_width"
android:layout_height="@dimen/default_button_height"
android:layout_gravity="center"
android:paddingLeft="@dimen/side_padding"
android:paddingRight="@dimen/side_padding"
android:text="@string/take_previous_short"
android:textSize="@dimen/textSize_18"/>
</FrameLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/previous_course"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/load_prev"
android:layout_margin="@dimen/side_padding"
android:gravity="center"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/course_new"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<android.support.v7.widget.RecyclerView
android:id="@+id/assets"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/side_padding"
android:horizontalSpacing="10dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/course_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<FrameLayout
android:id="@+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:paddingBottom="@dimen/side_padding"
android:paddingLeft="@dimen/side_padding"
android:paddingRight="@dimen/side_padding"
android:paddingTop="@dimen/side_padding">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<Button
android:id="@+id/publishCourse"
style="?button"
android:layout_width="@dimen/default_button_width"
android:layout_height="@dimen/default_button_height"
android:layout_marginBottom="@dimen/side_padding"
android:text="@string/publish"
android:textSize="@dimen/textSize_18"/>
<Button
android:id="@+id/unpublishCourse"
style="?button"
android:layout_width="@dimen/default_button_width"
android:layout_height="@dimen/default_button_height"
android:text="@string/unpublish"
android:textSize="@dimen/textSize_18"/>
</LinearLayout>
</FrameLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/new_course"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/bottom_bar"/>
</RelativeLayout>
</FrameLayout>
</RelativeLayout>
@@ -21,8 +21,9 @@
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="@dimen/default_margin"
android:layout_marginLeft="@dimen/default_margin"
android:layout_marginBottom="@dimen/side_padding"
android:layout_marginLeft="@dimen/side_padding"
android:layout_marginRight="@dimen/side_padding"
android:text="@string/login_text"
android:textColor="@color/constant_white"
android:textSize="@dimen/textSize_32" />
@@ -91,6 +91,7 @@
<string name="publish">Veröffentlichen</string>
<string name="unpublish">Zurücknehmen</string>
<string name="take_previous">Vorherigen Kurs übernehmen</string>
<string name="take_previous_short">übernehmen</string>
<string name="markImage">Bild der Bahnmarke</string>
<string name="cancel">Abbrechen</string>
<string name="retry">Wiederholen</string>
@@ -448,5 +449,8 @@
<string name="gate_time_schedule_short">%d Minuten</string>
<string name="not_available">N/A</string>
<string name="accuracy_timestamp">(vor %s)</string>
<string name="prev_course">Vorheriger Kurs</string>
<string name="new_course">Neuer Kurs</string>
<string name="layout_course">Kurs Layout</string>
</resources>
@@ -3,5 +3,6 @@
<item name="race_list_header" type="layout">@layout/race_list_header_small</item>
<item name="race_list_list" type="layout">@layout/race_list_list_top</item>
<item name="race_schedule_course_marks" type="layout">@layout/race_schedule_course_marks_large</item>
</resources>
@@ -6,5 +6,6 @@
<item name="race_main" type="layout">@layout/race_main_small</item>
<item name="race_panel_flags" type="layout">@layout/race_panel_flags_hor</item>
<item name="race_panel_setup" type="layout">@layout/race_panel_setup_hor</item>
<item name="race_schedule_course_marks" type="layout">@layout/race_schedule_course_marks_small</item>
</resources>
@@ -6,5 +6,6 @@
<item name="race_main" type="layout">@layout/race_main_large</item>
<item name="race_panel_flags" type="layout">@layout/race_panel_flags_ver</item>
<item name="race_panel_setup" type="layout">@layout/race_panel_setup_ver</item>
<item name="race_schedule_course_marks" type="layout">@layout/race_schedule_course_marks_large</item>
</resources>
@@ -3,7 +3,7 @@
<dimen name="navigation_drawer_cell_height">80dp</dimen>
<dimen name="navigation_drawer_image_height">120dp</dimen>
<dimen name="navigation_drawer_width">380dp</dimen>
<dimen name="navigation_drawer_width">320dp</dimen>
<dimen name="navigation_drawer_right_box">150dp</dimen>
<dimen name="navigation_drawer_left_padding">12dp</dimen>
@@ -9,6 +9,7 @@
<item name="race_main" type="layout">@layout/race_main_small</item>
<item name="race_panel_flags" type="layout">@layout/race_panel_flags_hor</item>
<item name="race_panel_setup" type="layout">@layout/race_panel_setup_hor</item>
<item name="race_schedule_course_marks" type="layout">@layout/race_schedule_course_marks_small</item>
<item name="toolbar_racing_activity" type="layout">@layout/toolbar</item>
</resources>
@@ -102,6 +102,7 @@
<string name="publish">Publish</string>
<string name="unpublish">Unpublish</string>
<string name="take_previous">Use previous course</string>
<string name="take_previous_short">Use this</string>
<string name="markImage">Mark image</string>
<string name="cancel">Cancel</string>
<string name="retry">Retry</string>
@@ -472,5 +473,8 @@
<string name="accuracy_value" translatable="false"><![CDATA[~ %.0fm]]></string>
<string name="accuracy_timestamp">(since %s)</string>
<string name="time_ago" translatable="false">%1$dh %2$02d\' %3$02d\"</string>
<string name="prev_course">Previous Course</string>
<string name="new_course">New Course</string>
<string name="layout_course">Course Layout</string>
</resources>
@@ -2,13 +2,13 @@ package com.sap.sailing.racecommittee.app.domain.impl;
import android.graphics.drawable.Drawable;
public class MainScheduleItem {
public class SelectionItem {
private String mCaption;
private String mValue;
private Drawable mDrawable;
private Runnable mRunnable;
public MainScheduleItem(String caption, String value, Drawable drawable, Runnable runnable) {
public SelectionItem(String caption, String value, Drawable drawable, Runnable runnable) {
mCaption = caption;
mDrawable = drawable;
mValue = value;
@@ -12,15 +12,15 @@ import android.widget.TextView;
import com.sap.sailing.android.shared.util.ViewHelper;
import com.sap.sailing.racecommittee.app.R;
import com.sap.sailing.racecommittee.app.domain.impl.MainScheduleItem;
import com.sap.sailing.racecommittee.app.domain.impl.SelectionItem;
public class MainScheduleAdapter extends RecyclerView.Adapter<MainScheduleAdapter.ViewHolder> {
public class SelectionAdapter extends RecyclerView.Adapter<SelectionAdapter.ViewHolder> {
private Context mContext;
private List<MainScheduleItem> mItems;
private List<SelectionItem> mItems;
private ItemClick mListener;
public MainScheduleAdapter(Context context, List<MainScheduleItem> items, ItemClick listener) {
public SelectionAdapter(Context context, List<SelectionItem> items, ItemClick listener) {
mContext = context;
mItems = items;
mListener = listener;
@@ -28,13 +28,13 @@ public class MainScheduleAdapter extends RecyclerView.Adapter<MainScheduleAdapte
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mContext).inflate(R.layout.race_schedule_list_item, parent, false);
View view = LayoutInflater.from(mContext).inflate(R.layout.selection_list_item, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
final MainScheduleItem item = mItems.get(position);
final SelectionItem item = mItems.get(position);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
@@ -255,10 +255,6 @@ public class CourseElementAdapter extends BaseDraggableSwipeAdapter<CourseElemen
public ViewHolder(View itemView) {
super(itemView);
if (mEditable) {
itemView.setOnLongClickListener(this);
}
container = ViewHelper.get(itemView, R.id.container);
dragHandle = ViewHelper.get(itemView, R.id.drag_handle);
leftText = ViewHelper.get(itemView, R.id.column_left_text);
@@ -266,6 +262,10 @@ public class CourseElementAdapter extends BaseDraggableSwipeAdapter<CourseElemen
roundingDirection = ViewHelper.get(itemView, R.id.rounding_direction);
rightText = ViewHelper.get(itemView, R.id.column_right_text);
rightImage = ViewHelper.get(itemView, R.id.column_right_image);
if (mEditable && roundingDirection != null) {
roundingDirection.setOnLongClickListener(this);
}
}
@Override
@@ -54,11 +54,10 @@ public abstract class CourseFragment extends BaseFragment {
}
switch (getArguments().getInt(START_MODE, START_MODE_PRESETUP)) {
case START_MODE_PLANNED:
if (AppUtils.with(getActivity()).isLand()) {
if (AppUtils.with(getActivity()).isLand() && AppUtils.with(getActivity()).isTablet()) {
header.setVisibility(View.GONE);
}
break;
}
}
}
@@ -10,6 +10,9 @@ import android.content.Loader;
import android.graphics.drawable.NinePatchDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.IdRes;
import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.GridLayoutManager;
@@ -19,7 +22,8 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator;
@@ -44,6 +48,8 @@ import com.sap.sailing.racecommittee.app.data.InMemoryDataStore;
import com.sap.sailing.racecommittee.app.data.ReadonlyDataManager;
import com.sap.sailing.racecommittee.app.data.clients.LoadClient;
import com.sap.sailing.racecommittee.app.domain.impl.CourseListDataElementWithIdImpl;
import com.sap.sailing.racecommittee.app.domain.impl.SelectionItem;
import com.sap.sailing.racecommittee.app.ui.adapters.SelectionAdapter;
import com.sap.sailing.racecommittee.app.ui.adapters.coursedesign.CourseElementAdapter;
import com.sap.sailing.racecommittee.app.ui.adapters.coursedesign.CourseElementAdapter.ElementLongClick;
import com.sap.sailing.racecommittee.app.ui.adapters.coursedesign.CourseElementAdapter.EventListener;
@@ -57,7 +63,7 @@ import com.sap.sailing.racecommittee.app.utils.ThemeHelper;
import com.sap.sse.common.Util;
import com.sap.sse.common.impl.MillisecondsTimePoint;
public class CourseFragmentMarks extends CourseFragment implements MarkClick, ElementLongClick, EventListener {
public class CourseFragmentMarks extends CourseFragment implements MarkClick, ElementLongClick, EventListener, SelectionAdapter.ItemClick {
private RecyclerViewDragDropManager mDragDropManager;
private RecyclerViewSwipeManager mSwipeManager;
@@ -66,12 +72,16 @@ public class CourseFragmentMarks extends CourseFragment implements MarkClick, El
private ArrayList<CourseListDataElementWithIdImpl> mHistory;
private ArrayList<CourseListDataElementWithIdImpl> mElements;
private ArrayList<Mark> mMarks;
private ArrayList<SelectionItem> mItems;
private RecyclerView mHistoryCourse;
private RecyclerView mCurrentCourse;
private RecyclerView mMarkGrid;
private CourseElementAdapter mHistoryAdapter;
private SelectionAdapter mAdapter;
private RecyclerView.Adapter<CourseElementAdapter.ViewHolder> mCourseAdapter;
private CourseMarkAdapter mMarkAdapter;
private ArrayList<RelativeLayout> mLayouts;
private TextView mHeaderCaption;
private int mId;
public CourseFragmentMarks() {
@@ -81,6 +91,7 @@ public class CourseFragmentMarks extends CourseFragment implements MarkClick, El
mHistory = new ArrayList<>();
mElements = new ArrayList<>();
mMarks = new ArrayList<>();
mLayouts = new ArrayList<>();
}
public static CourseFragmentMarks newInstance(@START_MODE_VALUES int startMode) {
@@ -93,20 +104,49 @@ public class CourseFragmentMarks extends CourseFragment implements MarkClick, El
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.race_schedule_course_marks, container, false);
View layout = inflater.inflate(R.layout.race_schedule_course_marks, container, false);
LinearLayout headerText = ViewHelper.get(view, R.id.header_text);
if (headerText != null) {
headerText.setOnClickListener(new View.OnClickListener() {
mHeaderCaption = ViewHelper.get(layout, R.id.header_caption);
@Override
public void onClick(View v) {
openMainScheduleFragment();
}
});
RelativeLayout selection = ViewHelper.get(layout, R.id.selection);
if (selection != null) {
mLayouts.add(selection);
RecyclerView chooser = ViewHelper.get(layout, R.id.chooser);
if (chooser != null) {
mItems = new ArrayList<>();
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mAdapter = new SelectionAdapter(getActivity(), mItems, this);
chooser.setLayoutManager(layoutManager);
chooser.setOverScrollMode(View.OVER_SCROLL_IF_CONTENT_SCROLLS);
chooser.setAdapter(mAdapter);
Runnable prevRunnable = new Runnable() {
@Override
public void run() {
showCourseLayout(R.id.course_prev, R.string.prev_course);
}
};
SelectionItem prevCourse = new SelectionItem(getString(R.string.prev_course), null, null, prevRunnable);
mItems.add(prevCourse);
Runnable newRunnable = new Runnable() {
@Override
public void run() {
showCourseLayout(R.id.course_new, R.string.new_course);
}
};
SelectionItem newCourse = new SelectionItem(getString(R.string.new_course), null, null, newRunnable);
mItems.add(newCourse);
}
}
mHistoryCourse = (RecyclerView) view.findViewById(R.id.previous_course);
RelativeLayout coursePrev = ViewHelper.get(layout, R.id.course_prev);
if (coursePrev != null) {
mLayouts.add(coursePrev);
}
mHistoryCourse = (RecyclerView) layout.findViewById(R.id.previous_course);
if (mHistoryCourse != null) {
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
mHistoryCourse.setLayoutManager(layoutManager);
@@ -115,7 +155,11 @@ public class CourseFragmentMarks extends CourseFragment implements MarkClick, El
mHistoryCourse.setAdapter(mHistoryAdapter);
}
mCurrentCourse = (RecyclerView) view.findViewById(R.id.new_course);
RelativeLayout courseLayout = ViewHelper.get(layout, R.id.course_layout);
if (courseLayout != null) {
mLayouts.add(courseLayout);
}
mCurrentCourse = ViewHelper.get(layout, R.id.new_course);
if (mCurrentCourse != null) {
mGuardManager = new RecyclerViewTouchActionGuardManager();
mGuardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
@@ -133,12 +177,12 @@ public class CourseFragmentMarks extends CourseFragment implements MarkClick, El
adapter.setListener(this);
adapter.setEventListener(this);
@SuppressWarnings("unchecked") RecyclerView.Adapter<CourseElementAdapter.ViewHolder> dragAdapter = mDragDropManager
.createWrappedAdapter(adapter);
@SuppressWarnings("unchecked")
RecyclerView.Adapter<CourseElementAdapter.ViewHolder> dragAdapter = mDragDropManager.createWrappedAdapter(adapter);
mCourseAdapter = dragAdapter;
@SuppressWarnings("unchecked") RecyclerView.Adapter<CourseElementAdapter.ViewHolder> swipeManager = mSwipeManager
.createWrappedAdapter(mCourseAdapter);
@SuppressWarnings("unchecked")
RecyclerView.Adapter<CourseElementAdapter.ViewHolder> swipeManager = mSwipeManager.createWrappedAdapter(mCourseAdapter);
mCourseAdapter = swipeManager;
mCurrentCourse.setLayoutManager(layoutManager);
@@ -155,20 +199,30 @@ public class CourseFragmentMarks extends CourseFragment implements MarkClick, El
mDragDropManager.attachRecyclerView(mCurrentCourse);
}
mMarkGrid = (RecyclerView) view.findViewById(R.id.assets);
RelativeLayout courseNew = ViewHelper.get(layout, R.id.course_new);
if (courseNew != null) {
mLayouts.add(courseNew);
}
mMarkGrid = (RecyclerView) layout.findViewById(R.id.assets);
if (mMarkGrid != null) {
GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), 3);
mMarkGrid.setLayoutManager(layoutManager);
mMarkGrid
.addItemDecoration(new ItemStrokeDecoration(getActivity().getResources().getDimensionPixelSize(R.dimen.obesity_line), getActivity()
.getResources().getDimensionPixelSize(R.dimen.thin_line), ThemeHelper.getColor(getActivity(), R.attr.sap_light_gray)));
.getResources().getDimensionPixelSize(R.dimen.thin_line), ThemeHelper.getColor(getActivity(), R.attr.sap_gray_white_20)));
mMarkAdapter = new CourseMarkAdapter(getActivity(), mMarks, ESSMarkImageHelper.getInstance(getActivity()));
mMarkAdapter.setListener(this);
mMarkGrid.setAdapter(mMarkAdapter);
}
return view;
return layout;
}
private void showCourseLayout(@IdRes int layout, @StringRes int stringId) {
showLayout(layout);
setHeaderCaption(stringId);
}
@Override
@@ -185,8 +239,14 @@ public class CourseFragmentMarks extends CourseFragment implements MarkClick, El
fillPreviousCourseElementsWithLastPublishedCourseDesign();
if (getView() != null) {
Button takePreviousButton = (Button) getView().findViewById(R.id.takeHistoryCourse);
takePreviousButton.setOnClickListener(new View.OnClickListener() {
if (mHistory.isEmpty()) {
showCourseLayout(R.id.course_new, R.string.new_course);
} else {
showCourseLayout(R.id.selection, 0);
}
Button takePrevious = (Button) getView().findViewById(R.id.takeHistoryCourse);
takePrevious.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
@@ -203,8 +263,8 @@ public class CourseFragmentMarks extends CourseFragment implements MarkClick, El
}
});
Button publishButton = (Button) getView().findViewById(R.id.publishCourse);
publishButton.setOnClickListener(new View.OnClickListener() {
Button publish = (Button) getView().findViewById(R.id.publishCourse);
publish.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
@@ -227,8 +287,8 @@ public class CourseFragmentMarks extends CourseFragment implements MarkClick, El
}
});
Button unpublishButton = (Button) getView().findViewById(R.id.unpublishCourse);
unpublishButton.setOnClickListener(new View.OnClickListener() {
Button unpublish = (Button) getView().findViewById(R.id.unpublishCourse);
unpublish.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
@@ -358,6 +418,9 @@ public class CourseFragmentMarks extends CourseFragment implements MarkClick, El
if (twoMarksCourseElement != null) {
twoMarksCourseElement.setRightMark(mark);
mCourseAdapter.notifyDataSetChanged();
if (mLayouts.size() != 0) {
showCourseLayout(R.id.course_layout, R.string.layout_course);
}
} else {
addNewCourseElementToList(mark);
}
@@ -389,6 +452,9 @@ public class CourseFragmentMarks extends CourseFragment implements MarkClick, El
public void onClick(DialogInterface dialog, int position) {
PassingInstruction pickedDirection = PassingInstruction.relevantValues()[position];
onPassingInstructionPicked(courseElement, pickedDirection);
if (mLayouts.size() != 0) {
showCourseLayout(R.id.course_layout, R.string.layout_course);
}
}
});
builder.create().show();
@@ -442,6 +508,9 @@ public class CourseFragmentMarks extends CourseFragment implements MarkClick, El
mElements.clear();
mElements.addAll(mHistory);
mCourseAdapter.notifyDataSetChanged();
if (mLayouts.size() != 0) {
showCourseLayout(R.id.course_layout, R.string.layout_course);
}
}
protected CourseBase convertCourseElementsToACourseData() throws IllegalStateException, IllegalArgumentException {
@@ -508,4 +577,73 @@ public class CourseFragmentMarks extends CourseFragment implements MarkClick, El
public void onItemRemoved(int position) {
// do nothing - later maybe show "undo" or something
}
@Override
public void onItemClick(Runnable runnable) {
if (runnable != null) {
Handler handler = new Handler();
handler.post(runnable);
}
}
@Override
protected void goHome() {
if (mLayouts.size() == 0) {
super.goHome();
} else {
switch (getCurrentFrame()) {
case R.id.course_prev:
showCourseLayout(R.id.selection, 0);
break;
case R.id.course_new:
if (mHistory.isEmpty()) {
super.goHome();
} else {
showCourseLayout(R.id.selection, 0);
}
break;
case R.id.course_layout:
showCourseLayout(R.id.course_new, R.string.new_course);
break;
default:
super.goHome();
break;
}
}
}
private void showLayout(@IdRes int id) {
for (View layout : mLayouts) {
layout.setVisibility(View.GONE);
if (layout.getId() == id) {
layout.setVisibility(View.VISIBLE);
}
}
}
private
@IdRes
int getCurrentFrame() {
int id = 0;
for (View layout : mLayouts) {
if (layout.getVisibility() == View.VISIBLE) {
id = layout.getId();
break;
}
}
return id;
}
private void setHeaderCaption(@StringRes int id) {
if (mHeaderCaption != null) {
if (id != 0) {
mHeaderCaption.setText(String.format("%s - %s", getString(R.string.course), getString(id)));
} else {
mHeaderCaption.setText(getString(R.string.course));
}
}
}
}
@@ -26,9 +26,9 @@ import com.sap.sailing.domain.common.racelog.RacingProcedureType;
import com.sap.sailing.racecommittee.app.R;
import com.sap.sailing.racecommittee.app.data.DataManager;
import com.sap.sailing.racecommittee.app.domain.ManagedRace;
import com.sap.sailing.racecommittee.app.domain.impl.MainScheduleItem;
import com.sap.sailing.racecommittee.app.domain.impl.SelectionItem;
import com.sap.sailing.racecommittee.app.ui.activities.RacingActivity;
import com.sap.sailing.racecommittee.app.ui.adapters.MainScheduleAdapter;
import com.sap.sailing.racecommittee.app.ui.adapters.SelectionAdapter;
import com.sap.sailing.racecommittee.app.ui.fragments.RaceFragment;
import com.sap.sailing.racecommittee.app.ui.fragments.chooser.RaceInfoFragmentChooser;
import com.sap.sailing.racecommittee.app.ui.utils.FlagsResources;
@@ -38,7 +38,7 @@ import com.sap.sse.common.Duration;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.impl.MillisecondsTimePoint;
public class MainScheduleFragment extends BaseFragment implements View.OnClickListener, MainScheduleAdapter.ItemClick {
public class MainScheduleFragment extends BaseFragment implements View.OnClickListener, SelectionAdapter.ItemClick {
public static final String START_TIME = "startTime";
public static final String DEPENDENT_RACE = "dependentRace";
@@ -46,10 +46,10 @@ public class MainScheduleFragment extends BaseFragment implements View.OnClickLi
private static final String TAG = MainScheduleFragment.class.getName();
private MainScheduleAdapter mAdapter;
private ArrayList<MainScheduleItem> mItems;
private MainScheduleItem mItemStartTime;
private MainScheduleItem mItemStartWind;
private SelectionAdapter mAdapter;
private ArrayList<SelectionItem> mItems;
private SelectionItem mItemStartTime;
private SelectionItem mItemStartWind;
private String mStartTimeString;
private SimpleRaceLogIdentifier mRaceId;
@@ -81,7 +81,7 @@ public class MainScheduleFragment extends BaseFragment implements View.OnClickLi
RecyclerView raceData = ViewHelper.get(layout, R.id.race_data);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mAdapter = new MainScheduleAdapter(getActivity(), mItems, this);
mAdapter = new SelectionAdapter(getActivity(), mItems, this);
raceData.setLayoutManager(layoutManager);
raceData.setOverScrollMode(View.OVER_SCROLL_IF_CONTENT_SCROLLS);
raceData.setAdapter(mAdapter);
@@ -123,7 +123,7 @@ public class MainScheduleFragment extends BaseFragment implements View.OnClickLi
openFragment(CourseFragment.newInstance(START_MODE_PRESETUP, getRace()));
}
};
MainScheduleItem courseItem = new MainScheduleItem(getString(R.string.course), null, null, runnable);
SelectionItem courseItem = new SelectionItem(getString(R.string.course), null, null, runnable);
if (getRaceState().getCourseDesign() != null) {
courseItem.setValue(getCourseName());
}
@@ -137,7 +137,7 @@ public class MainScheduleFragment extends BaseFragment implements View.OnClickLi
openFragment(WindFragment.newInstance(START_MODE_PRESETUP));
}
};
mItemStartWind = new MainScheduleItem(getString(R.string.wind), null, null, runnable);
mItemStartWind = new SelectionItem(getString(R.string.wind), null, null, runnable);
mItems.add(mItemStartWind);
}
@@ -150,7 +150,7 @@ public class MainScheduleFragment extends BaseFragment implements View.OnClickLi
openFragment(StartProcedureFragment.newInstance(START_MODE_PRESETUP));
}
};
mItems.add(new MainScheduleItem(getString(R.string.start_procedure), mRacingProcedureType.toString(), null, runnableProcedure));
mItems.add(new SelectionItem(getString(R.string.start_procedure), mRacingProcedureType.toString(), null, runnableProcedure));
if (RacingProcedureType.RRS26.equals(mRacingProcedureType)) {
// LineStart
RRS26RacingProcedure procedure = getRaceState().getTypedRacingProcedure();
@@ -162,7 +162,7 @@ public class MainScheduleFragment extends BaseFragment implements View.OnClickLi
}
};
Drawable drawable = FlagsResources.getFlagDrawable(getActivity(), flag.name(), mFlagSize);
mItems.add(new MainScheduleItem(getString(R.string.start_mode), flag.name(), drawable, runnableMode));
mItems.add(new SelectionItem(getString(R.string.start_mode), flag.name(), drawable, runnableMode));
} else if (RacingProcedureType.GateStart.equals(mRacingProcedureType)) {
// GateStart
GateStartRacingProcedure procedure = getRaceState().getTypedRacingProcedure();
@@ -173,7 +173,7 @@ public class MainScheduleFragment extends BaseFragment implements View.OnClickLi
openFragment(GateStartPathFinderFragment.newInstance(START_MODE_PRESETUP));
}
};
mItems.add(new MainScheduleItem(getString(R.string.gate_start_pathfinder), procedure.getPathfinder(), null, runnablePathfinder));
mItems.add(new SelectionItem(getString(R.string.gate_start_pathfinder), procedure.getPathfinder(), null, runnablePathfinder));
Runnable runnableTiming = new Runnable() {
@Override
@@ -181,7 +181,7 @@ public class MainScheduleFragment extends BaseFragment implements View.OnClickLi
openFragment(GateStartTimingFragment.newInstance(START_MODE_PRESETUP));
}
};
mItems.add(new MainScheduleItem(getString(R.string.gate_start_timing), RaceHelper
mItems.add(new SelectionItem(getString(R.string.gate_start_timing), RaceHelper
.getGateTiming(getActivity(), procedure), null, runnableTiming));
}
}
@@ -216,7 +216,7 @@ public class MainScheduleFragment extends BaseFragment implements View.OnClickLi
openFragment(StartTimeFragment.newInstance(getArguments()));
}
};
mItemStartTime = new MainScheduleItem(getString(R.string.start_time), mStartTimeString, null, runnable);
mItemStartTime = new SelectionItem(getString(R.string.start_time), mStartTimeString, null, runnable);
mItems.add(mItemStartTime);
}