mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-03 01:29:33 +00:00
RCApp: navigation drawer mark selected item
This commit is contained in:
1 parent
8480849333
commit
6984bb908f
9 files changed
+88
-13
No files matched your search
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- Dark Theme -->
|
||||
<item
|
||||
android:drawable="@color/dark_sap_gray"
|
||||
android:maxLevel="0" />
|
||||
<item
|
||||
android:drawable="@color/constant_sap_yellow_1"
|
||||
android:maxLevel="1" />
|
||||
|
||||
<!-- Light Theme -->
|
||||
<item
|
||||
android:drawable="@color/dark_sap_gray"
|
||||
android:maxLevel="10" />
|
||||
<item
|
||||
android:drawable="@color/constant_sap_yellow_1"
|
||||
android:maxLevel="11" />
|
||||
|
||||
</level-list>
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
<solid android:color="@color/constant_sap_yellow_1" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:bottom="1.5dp">
|
||||
<item android:bottom="2dp">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/dark_black" />
|
||||
</shape>
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
<solid android:color="@color/constant_sap_yellow_1" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:bottom="1.5dp">
|
||||
<item android:bottom="2dp">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/light_black" />
|
||||
</shape>
|
||||
|
||||
@@ -63,10 +63,15 @@
|
||||
android:id="@+id/panel_left"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="2dp"
|
||||
android:layout_toLeftOf="@id/panel_right"
|
||||
android:layout_toStartOf="@id/panel_right">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/race_marker"
|
||||
android:layout_width="@dimen/thick_line"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/marker_race"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/race_flag"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -114,8 +119,8 @@
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginLeft="@dimen/default_margin"
|
||||
android:layout_marginStart="@dimen/default_margin"
|
||||
android:layout_toLeftOf="@id/race_flag"
|
||||
android:layout_toStartOf="@id/race_flag"
|
||||
android:orientation="vertical">
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/nav_drawer_header" />
|
||||
android:src="@color/constant_black" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
|
||||
-4
@@ -41,14 +41,10 @@ import com.sap.sailing.racecommittee.app.ui.fragments.panels.TimePanelFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.raceinfo.RaceInfoListener;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.raceinfo.WindFragment;
|
||||
import com.sap.sailing.racecommittee.app.utils.ThemeHelper;
|
||||
import com.sap.sailing.racecommittee.app.utils.TickListener;
|
||||
import com.sap.sailing.racecommittee.app.utils.TickSingleton;
|
||||
import com.sap.sailing.racecommittee.app.utils.TimeUtils;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collection;
|
||||
|
||||
public class RacingActivity extends SessionActivity implements RaceInfoListener, RaceListCallbacks, OnClickListener {
|
||||
|
||||
+47
-3
@@ -11,6 +11,7 @@ import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
@@ -33,6 +34,7 @@ import com.sap.sailing.racecommittee.app.domain.impl.BoatClassSeriesFleet;
|
||||
import com.sap.sailing.racecommittee.app.ui.adapters.racelist.RaceFilter.FilterSubscriber;
|
||||
import com.sap.sailing.racecommittee.app.ui.utils.FlagsResources;
|
||||
import com.sap.sailing.racecommittee.app.utils.ColorHelper;
|
||||
import com.sap.sailing.racecommittee.app.utils.ThemeHelper;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
|
||||
@@ -60,6 +62,7 @@ public class ManagedRaceListAdapter extends ArrayAdapter<RaceListDataType> imple
|
||||
private Resources mResources;
|
||||
private List<RaceListDataType> mShownViewItems;
|
||||
|
||||
private ImageView marker;
|
||||
private ImageView update_badge;
|
||||
private LinearLayout race_flag;
|
||||
private TextView time;
|
||||
@@ -74,6 +77,8 @@ public class ManagedRaceListAdapter extends ArrayAdapter<RaceListDataType> imple
|
||||
private ImageView arrow_direction;
|
||||
private SimpleDateFormat dateFormat;
|
||||
|
||||
private RaceListDataType mSelectedRace;
|
||||
|
||||
public ManagedRaceListAdapter(Context context, List<RaceListDataType> viewItems,
|
||||
JuryFlagClickedListener juryListener) {
|
||||
super(context, 0);
|
||||
@@ -187,6 +192,15 @@ public class ManagedRaceListAdapter extends ArrayAdapter<RaceListDataType> imple
|
||||
final RaceListDataTypeRace race = (RaceListDataTypeRace) raceListElement;
|
||||
resetValues(convertView);
|
||||
|
||||
if (convertView != null) {
|
||||
if (mSelectedRace != null && mSelectedRace.equals(race)) {
|
||||
setMarker(1 - getLevel());
|
||||
convertView.setBackgroundColor(ColorHelper.getThemedColor(getContext(), R.attr.sap_gray_black_20));
|
||||
} else {
|
||||
convertView.setBackgroundColor(ColorHelper.getThemedColor(getContext(), R.attr.sap_gray));
|
||||
}
|
||||
}
|
||||
|
||||
group_name.setText(race.getRace().getSeries().getName());
|
||||
if (!TextUtils.isEmpty(race.getRaceName())) {
|
||||
if (race.getRace().getFleet() != null) {
|
||||
@@ -195,8 +209,6 @@ public class ManagedRaceListAdapter extends ArrayAdapter<RaceListDataType> imple
|
||||
race_name.setText(race.getRaceName());
|
||||
}
|
||||
SpannableString raceName = new SpannableString(race_name.getText());
|
||||
StyleSpan boldStyleSpan = new StyleSpan(Typeface.BOLD);
|
||||
raceName.setSpan(boldStyleSpan, 0, raceName.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
race_name.setText(raceName);
|
||||
}
|
||||
RaceState state = race.getRace().getState();
|
||||
@@ -205,7 +217,13 @@ public class ManagedRaceListAdapter extends ArrayAdapter<RaceListDataType> imple
|
||||
race_started.setText(mResources.getString(R.string.race_started,
|
||||
dateFormat.format(state.getStartTime().asDate())));
|
||||
if (state.getFinishedTime() == null) {
|
||||
time.setText(getDuration(state.getStartTime().asDate(), Calendar.getInstance().getTime()));
|
||||
String duration = getDuration(state.getStartTime().asDate(), Calendar.getInstance().getTime());
|
||||
time.setText(duration);
|
||||
float textSize = getContext().getResources().getDimension(R.dimen.textSize_40);
|
||||
if (!TextUtils.isEmpty(duration) && duration.length() >= 6) {
|
||||
textSize = getContext().getResources().getDimension(R.dimen.textSize_32);
|
||||
}
|
||||
time.setTextSize(textSize);
|
||||
}
|
||||
}
|
||||
if (state.getFinishedTime() != null) {
|
||||
@@ -249,7 +267,12 @@ public class ManagedRaceListAdapter extends ArrayAdapter<RaceListDataType> imple
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelectedRace(RaceListDataType id) {
|
||||
mSelectedRace = id;
|
||||
}
|
||||
|
||||
private void findViews(View convertView) {
|
||||
marker = ViewHolder.get(convertView, R.id.race_marker);
|
||||
arrow_direction = ViewHolder.get(convertView, R.id.arrow_direction);
|
||||
current_flag = ViewHolder.get(convertView, R.id.current_flag);
|
||||
group_name = ViewHolder.get(convertView, R.id.group_name);
|
||||
@@ -293,6 +316,7 @@ public class ManagedRaceListAdapter extends ArrayAdapter<RaceListDataType> imple
|
||||
if (group_name != null) {
|
||||
group_name.setTextColor(ColorHelper.getThemedColor(getContext(), R.attr.sap_light_gray));
|
||||
}
|
||||
setMarker(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,4 +347,24 @@ public class ManagedRaceListAdapter extends ArrayAdapter<RaceListDataType> imple
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setMarker(int level) {
|
||||
if (marker != null) {
|
||||
Drawable drawable = marker.getDrawable();
|
||||
if (drawable != null) {
|
||||
drawable.setLevel(level + ThemeHelper.getThemeOffset(getContext()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getLevel() {
|
||||
int level = 0;
|
||||
if (marker != null) {
|
||||
Drawable drawable = marker.getDrawable();
|
||||
if (drawable != null) {
|
||||
level = drawable.getLevel();
|
||||
}
|
||||
}
|
||||
return level;
|
||||
}
|
||||
}
|
||||
+1
@@ -283,6 +283,7 @@ public class RaceListFragment extends LoggableFragment implements OnItemClickLis
|
||||
ExLog.i(getActivity(), TAG, "Touched " + mAdapter.getItem(position).toString());
|
||||
|
||||
mDrawerLayout.closeDrawers();
|
||||
mAdapter.setSelectedRace(mAdapter.getItem(position));
|
||||
mCallbacks.onRaceListItemSelected(mAdapter.getItem(position));
|
||||
}
|
||||
|
||||
|
||||
+9
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.racecommittee.app.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import com.sap.sailing.racecommittee.app.AppConstants;
|
||||
import com.sap.sailing.racecommittee.app.AppPreferences;
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
@@ -15,4 +16,12 @@ public class ThemeHelper {
|
||||
activity.setTheme(R.style.AppTheme_Dark);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getThemeOffset(Context context) {
|
||||
int offset = 0;
|
||||
if (AppConstants.LIGHT_THEME.equals(AppPreferences.on(context).getTheme())) {
|
||||
offset = 10;
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user