Skip to content

Commit 20231d8

Browse files
committed
Added dimensions and layouts to get us ready for SMRE part 2.
1 parent 055a8a9 commit 20231d8

6 files changed

Lines changed: 59 additions & 7 deletions

File tree

app/src/main/java/com/example/android/sunshine/app/DetailFragment.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import android.support.v4.app.LoaderManager;
2424
import android.support.v4.content.CursorLoader;
2525
import android.support.v4.content.Loader;
26-
import android.support.v4.view.MenuItemCompat;
2726
import android.support.v7.app.AppCompatActivity;
2827
import android.support.v7.widget.ShareActionProvider;
2928
import android.support.v7.widget.Toolbar;
@@ -50,7 +49,6 @@ public class DetailFragment extends Fragment implements LoaderManager.LoaderCall
5049

5150
private static final String FORECAST_SHARE_HASHTAG = " #SunshineApp";
5251

53-
private ShareActionProvider mShareActionProvider;
5452
private String mForecast;
5553
private Uri mUri;
5654

@@ -179,12 +177,15 @@ public Loader<Cursor> onCreateLoader(int id, Bundle args) {
179177
null
180178
);
181179
}
180+
getView().setVisibility(View.INVISIBLE);
182181
return null;
183182
}
184183

185184
@Override
186185
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
187186
if (data != null && data.moveToFirst()) {
187+
getView().setVisibility(View.VISIBLE);
188+
188189
// Read weather condition ID from cursor
189190
int weatherId = data.getInt(COL_WEATHER_CONDITION_ID);
190191

@@ -251,10 +252,6 @@ public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
251252
// We still need this for the share intent
252253
mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low);
253254

254-
// If onCreateOptionsMenu has already happened, we need to update the share intent now.
255-
if (mShareActionProvider != null) {
256-
mShareActionProvider.setShareIntent(createShareForecastIntent());
257-
}
258255
}
259256
AppCompatActivity activity = (AppCompatActivity)getActivity();
260257
Toolbar toolbarView = (Toolbar) getView().findViewById(R.id.toolbar);

app/src/main/res/layout-sw600dp/activity_main.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,11 @@
9292
android:layout_marginTop="?attr/actionBarSize"
9393
android:layout_alignStart="@id/layout_center"
9494
android:elevation="@dimen/appbar_elevation"
95+
android:layout_marginRight="@dimen/list_item_extra_padding"
96+
android:layout_marginEnd="@dimen/list_item_extra_padding"
9597
android:paddingRight="@dimen/abc_list_item_padding_horizontal_material"
9698
android:paddingEnd="@dimen/abc_list_item_padding_horizontal_material"
97-
android:paddingBottom="@dimen/abc_list_item_padding_horizontal_material"
99+
android:paddingBottom="@dimen/detail_container_bottom_margin"
98100
/>
99101

100102
</RelativeLayout>

app/src/main/res/layout/detail_today_grid.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
app:columnCount="2">
2424

2525
<android.support.v7.widget.Space
26+
android:layout_height="@dimen/detail_view_padding_vertical"
2627
app:layout_columnSpan="2"
2728
app:layout_columnWeight="1"
2829
app:layout_rowWeight="1" />
@@ -83,6 +84,7 @@
8384
tools:text="10" />
8485

8586
<android.support.v7.widget.Space
87+
android:layout_height="@dimen/detail_view_padding_vertical"
8688
app:layout_columnSpan="2"
8789
app:layout_columnWeight="1"
8890
app:layout_rowWeight="1" />
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!--
2+
Copyright (C) 2015 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<resources>
17+
<!-- Extra Padding - This one actually smaller on tablets -->
18+
<dimen name="detail_view_extra_padding">0dp</dimen>
19+
</resources>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright (C) 2015 The Android Open Source Project
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<resources>
18+
<!-- Extra List Item Margin (tablet-only) -->
19+
<dimen name="list_item_extra_padding">64dp</dimen>
20+
<dimen name="detail_view_padding_vertical">@dimen/abc_list_item_padding_horizontal_material</dimen>
21+
<dimen name="detail_view_padding">@dimen/abc_action_bar_default_height_material</dimen>
22+
23+
<dimen name="forecast_temperature_space">@dimen/abc_list_item_padding_horizontal_material</dimen>
24+
<dimen name="detail_container_bottom_margin">@dimen/abc_action_bar_default_height_material</dimen>
25+
26+
</resources>

app/src/main/res/values/dimens.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,10 @@
4343

4444
<!-- The amount we want the details view to overlap the app bar -->
4545
<dimen name="details_app_bar_overlap">24dp</dimen>
46+
47+
<!-- Help to make us tablet beautiful -->
48+
<dimen name="list_item_extra_padding">0dp</dimen>
49+
<dimen name="detail_view_padding">@dimen/abc_list_item_padding_horizontal_material</dimen>
50+
<dimen name="forecast_detail_padding_wide">16dp</dimen>
51+
<dimen name="detail_container_bottom_margin">@dimen/detail_view_padding</dimen>
4652
</resources>

0 commit comments

Comments
 (0)