Create GridLayoutManager for TimersFragment in landscape
This commit is contained in:
parent
be9aca1ede
commit
2dc411f999
@ -3,9 +3,12 @@ package com.philliphsu.clock2.timers;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
||||
import com.philliphsu.clock2.AsyncTimersTableUpdateHandler;
|
||||
import com.philliphsu.clock2.RecyclerViewFragment;
|
||||
@ -19,6 +22,8 @@ public class TimersFragment extends RecyclerViewFragment<
|
||||
TimerViewHolder,
|
||||
TimerCursor,
|
||||
TimersCursorAdapter> {
|
||||
private static final int LANDSCAPE_LAYOUT_COLUMNS = 2;
|
||||
|
||||
public static final int REQUEST_CREATE_TIMER = 0;
|
||||
|
||||
private AsyncTimersTableUpdateHandler mAsyncTimersTableUpdateHandler;
|
||||
@ -67,6 +72,16 @@ public class TimersFragment extends RecyclerViewFragment<
|
||||
return new TimersCursorAdapter(this, mAsyncTimersTableUpdateHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RecyclerView.LayoutManager getLayoutManager() {
|
||||
switch (getResources().getConfiguration().orientation) {
|
||||
case Configuration.ORIENTATION_LANDSCAPE:
|
||||
return new GridLayoutManager(getActivity(), LANDSCAPE_LAYOUT_COLUMNS);
|
||||
default:
|
||||
return super.getLayoutManager();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Loader<TimerCursor> onCreateLoader(int id, Bundle args) {
|
||||
return new TimersListCursorLoader(getActivity());
|
||||
|
||||
84
app/src/main/res/layout-land/item_timer.xml
Normal file
84
app/src/main/res/layout-land/item_timer.xml
Normal file
@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="Label"
|
||||
android:textSize="17sp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"/>
|
||||
|
||||
<com.philliphsu.clock2.timers.CountdownChronometer
|
||||
android:id="@+id/duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/label"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:textSize="45sp"
|
||||
android:layout_marginBottom="8dp"/>
|
||||
<!--TODO: Consider removing this bottom margin, because the seekbar
|
||||
is rendering with HUGE top and bottom padding already. -->
|
||||
|
||||
<!--The default style has padding start and end, so we remove both-->
|
||||
<com.philliphsu.clock2.UntouchableSeekBar
|
||||
android:id="@+id/seek_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/duration"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:splitTrack="false"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/add_one_minute"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:src="@drawable/ic_half_day_1_24dp"
|
||||
android:background="?selectableItemBackground"
|
||||
android:layout_below="@id/seek_bar"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginStart="8dp"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/start_pause"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:src="@drawable/ic_half_day_1_24dp"
|
||||
android:background="?selectableItemBackground"
|
||||
android:layout_below="@id/seek_bar"
|
||||
android:layout_centerHorizontal="true"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/stop"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:src="@drawable/ic_half_day_1_24dp"
|
||||
android:background="?selectableItemBackground"
|
||||
android:layout_below="@id/seek_bar"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="8dp"/>
|
||||
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="8dp"
|
||||
android:layout_below="@id/stop"/>
|
||||
|
||||
<!--<View style="@style/Divider.Horizontal"
|
||||
android:layout_below="@id/space"/>-->
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</android.support.v7.widget.CardView>
|
||||
@ -4,4 +4,6 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical"/>
|
||||
android:scrollbars="vertical"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingTop="8dp"/>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user