Commit e4a05f50 authored by Budi Kusmiantoro's avatar Budi Kusmiantoro Committed by Android (Google) Code Review
Browse files

Merge "Stopwatch lap list to continue behind FAB" into lmp-mr1-dev

parents b90d84c3 d746c180
......@@ -51,13 +51,12 @@
<ListView
android:id="@+id/laps_list"
android:layout_marginTop="32dip"
android:layout_marginBottom="48dip"
android:layout_marginStart="@dimen/stopwatch_list_margin_start"
android:layout_marginEnd="16dip"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="2"
android:layout_marginTop="8dip"
android:layout_marginBottom="8dip"
android:layout_gravity="center" />
<Space
android:id="@+id/end_space"
......
......@@ -16,32 +16,32 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginTop="4dip"
android:layout_marginBottom="4dip"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutDirection="ltr"
android:paddingTop="@dimen/body_font_padding"
android:paddingBottom="@dimen/body_font_padding"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/lap_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/sw_item_space"
android:layout_marginEnd="@dimen/sw_item_space"
android:gravity="start"
android:textAllCaps="false"
android:textAppearance="@style/SecondaryLabelTextAppearance" />
<TextView
android:id="@+id/lap_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/sw_item_space"
android:layout_marginEnd="@dimen/sw_item_space"
android:gravity="end"
android:textAllCaps="false"
android:textAppearance="@style/PrimaryLabelTextAppearance" />
<TextView
android:id="@+id/lap_total"
android:layout_height="wrap_content"
......@@ -49,5 +49,5 @@
android:gravity="end"
android:textAllCaps="false"
android:textAppearance="@style/PrimaryLabelTextAppearance" />
</LinearLayout>
</LinearLayout>
......@@ -61,9 +61,4 @@
android:layout_width="match_parent"
android:layout_height="0dip" />
<Space
android:layout_width="match_parent"
android:layout_height="@dimen/footer_button_size"
android:layout_margin="@dimen/footer_button_layout_margin" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<Space
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/stopwatch_list_bottom_spacing" />
......@@ -51,6 +51,7 @@
<dimen name="medium_font_size">48sp</dimen>
<dimen name="circle_size">232dip</dimen>
<dimen name="stopwatch_list_bottom_spacing">0dip</dimen>
<dimen name="world_clock_margin">8dp</dimen>
<dimen name="sw_padding_end">8dp</dimen>
......
......@@ -43,7 +43,7 @@
<dimen name="timer_circle_margin">48dp</dimen>
<dimen name="circle_size">360dip</dimen>
<dimen name="stopwatch_list_margin_start">128dip</dimen>
<dimen name="stopwatch_list_bottom_spacing">0dip</dimen>
<dimen name="world_clock_margin">48dp</dimen>
<dimen name="sw_padding_end">48dp</dimen>
......
......@@ -76,6 +76,8 @@
<dimen name="timer_circle_margin">96dp</dimen>
<dimen name="circle_size">400dp</dimen>
<!-- stopwatch_list_bottom_spacing = footer_button_size + footer_button_layout_margin -->
<dimen name="stopwatch_list_bottom_spacing">96dip</dimen>
<!-- Width of the clock, for use with alarm buttons. -->
<dimen name="alarm_alert_display_width">550dip</dimen>
......
......@@ -117,7 +117,8 @@
<dimen name="timer_circle_margin">32dp</dimen>
<dimen name="circle_size">280dp</dimen>
<dimen name="stopwatch_list_margin_start">64dip</dimen>
<!-- stopwatch_list_bottom_spacing = footer_button_size + footer_button_layout_margin -->
<dimen name="stopwatch_list_bottom_spacing">72dip</dimen>
<dimen name="sw_padding_end">32dp</dimen>
......
......@@ -82,6 +82,10 @@ public class StopwatchFragment extends DeskClockFragment
// Adapter for the ListView that shows the lap times.
class LapsListAdapter extends BaseAdapter {
private static final int VIEW_TYPE_LAP = 0;
private static final int VIEW_TYPE_SPACE = 1;
private static final int VIEW_TYPE_COUNT = 2;
ArrayList<Lap> mLaps = new ArrayList<Lap>();
private final LayoutInflater mInflater;
private final String[] mFormats;
......@@ -110,20 +114,34 @@ public class StopwatchFragment extends DeskClockFragment
return position;
}
@Override
public int getItemViewType(int position) {
return position < mLaps.size() ? VIEW_TYPE_LAP : VIEW_TYPE_SPACE;
}
@Override
public int getViewTypeCount() {
return VIEW_TYPE_COUNT;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (mLaps.size() == 0 || position >= mLaps.size()) {
if (getCount() == 0) {
return null;
}
Lap lap = getItem(position);
View lapInfo;
if (convertView != null) {
lapInfo = convertView;
} else {
lapInfo = mInflater.inflate(R.layout.lap_view, parent, false);
// Handle request for the Spacer at the end
if (getItemViewType(position) == VIEW_TYPE_SPACE) {
return convertView != null ? convertView
: mInflater.inflate(R.layout.stopwatch_spacer, parent, false);
}
final View lapInfo = convertView != null ? convertView
: mInflater.inflate(R.layout.lap_view, parent, false);
Lap lap = getItem(position);
lapInfo.setTag(lap);
TextView count = (TextView)lapInfo.findViewById(R.id.lap_number);
TextView count = (TextView) lapInfo.findViewById(R.id.lap_number);
count.setText(String.format(mLapFormat, mLaps.size() - position).toUpperCase());
setTimeText(lapInfo, lap);
......@@ -139,12 +157,13 @@ public class StopwatchFragment extends DeskClockFragment
@Override
public int getCount() {
return mLaps.size();
// Add 1 for the spacer if list is not empty
return mLaps.isEmpty() ? 0 : mLaps.size() + 1;
}
@Override
public Lap getItem(int position) {
if (mLaps.size() == 0 || position >= mLaps.size()) {
if (position >= mLaps.size()) {
return null;
}
return mLaps.get(position);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment