Skip to content

Commit facea4e

Browse files
committed
"Initial commit"
1 parent b28ed81 commit facea4e

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

app/src/main/java/com/wuyr/pathlayoutmanagertest/MainActivity.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import android.view.View;
1313
import android.widget.CompoundButton;
1414
import android.widget.SeekBar;
15+
import android.widget.Switch;
1516
import android.widget.TextView;
1617
import android.widget.Toast;
1718

@@ -57,6 +58,11 @@ this, findViewById(R.id.drawer), findViewById(R.id.toolbar),
5758

5859
findViewById(R.id.card).setEnabled(false);
5960
findViewById(R.id.normal).setEnabled(false);
61+
62+
((Switch)findViewById( R.id.orientation)).setOnCheckedChangeListener(this);
63+
((Switch)findViewById( R.id.direction_fixed)).setOnCheckedChangeListener(this);
64+
((Switch)findViewById( R.id.auto_select)).setOnCheckedChangeListener(this);
65+
6066
((SeekBar) findViewById(R.id.item_offset)).setOnSeekBarChangeListener(this);
6167
((SeekBar) findViewById(R.id.auto_select_fraction)).setOnSeekBarChangeListener(this);
6268
}
@@ -74,7 +80,7 @@ public void handleOnClick(View view) {
7480
if (path != null && !path.isEmpty()) {
7581
mCanvasView.setVisibility(View.INVISIBLE);
7682
mTrackView.setPath(mCanvasView.getPath());
77-
mTrackView.setVisibility(View.VISIBLE);
83+
// mTrackView.setVisibility(View.VISIBLE);
7884
mPathLayoutManager.updatePath(mCanvasView.getPath());
7985
}
8086
break;
@@ -154,7 +160,7 @@ public void handleOnClick(View view) {
154160
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
155161
switch (buttonView.getId()) {
156162
case R.id.orientation:
157-
mPathLayoutManager.setOrientation(isChecked ? RecyclerView.VERTICAL : RecyclerView.HORIZONTAL);
163+
mPathLayoutManager.setOrientation(isChecked ? RecyclerView.HORIZONTAL : RecyclerView.VERTICAL);
158164
break;
159165
case R.id.direction_fixed:
160166
mPathLayoutManager.setItemDirectionFixed(isChecked);

app/src/main/java/com/wuyr/pathlayoutmanagertest/PathLayoutManager.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,10 @@ private int findClosestPosition() {
706706
}
707707

708708
public void setAutoSelectFraction(@FloatRange(from = 0F, to = 1F) float position) {
709-
mAutoSelectFraction = position;
709+
if (mAutoSelectFraction != position) {
710+
mAutoSelectFraction = position;
711+
requestLayout();
712+
}
710713
}
711714

712715
public void setAutoSelect(boolean isAutoSelect) {
@@ -722,6 +725,11 @@ public void setItemScaleRatio(float... ratios) {
722725
if (ratios.length == 0) {
723726
ratios = new float[]{1, 1};
724727
}
728+
for (float tmp : ratios) {
729+
if (tmp < 0) {
730+
throw new IllegalArgumentException("Array value can not be negative!");
731+
}
732+
}
725733
if (mScaleRatio != ratios) {
726734
if (ratios.length < 2 || ratios.length % 2 != 0) {
727735
throw new IllegalArgumentException("Array length no match!");

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
4-
xmlns:tools="http://schemas.android.com/tools"
54
android:id="@+id/drawer"
65
android:layout_width="match_parent"
76
android:layout_height="match_parent">
87

98
<LinearLayout
109
android:layout_width="match_parent"
1110
android:layout_height="match_parent"
11+
android:background="#eee"
1212
android:orientation="vertical">
1313

1414
<android.support.v7.widget.Toolbar
1515
android:id="@+id/toolbar"
1616
android:layout_width="match_parent"
1717
android:layout_height="wrap_content"
1818
android:background="@color/colorPrimary"
19-
app:title="@string/app_name"
20-
android:theme="@style/AppTheme.AppBarOverlay"/>
19+
android:theme="@style/AppTheme.AppBarOverlay"
20+
app:title="@string/app_name" />
2121

2222
<FrameLayout
2323
android:layout_width="match_parent"

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:background="#eee"
45
android:id="@+id/root_view"
5-
android:layout_width="wrap_content"
6+
android:layout_width="match_parent"
67
android:layout_height="wrap_content">
78

89
<android.support.v7.widget.CardView
910
android:layout_width="wrap_content"
1011
android:layout_height="wrap_content"
1112
android:foreground="@drawable/background"
12-
android:visibility="invisible"
13-
app:cardBackgroundColor="@color/colorAccent"
13+
app:cardBackgroundColor="@android:color/white"
1414
app:cardCornerRadius="4dp"
1515
app:cardElevation="4dp"
1616
app:cardUseCompatPadding="true"

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
android:layout_height="wrap_content"
66
android:layout_gravity="start"
77
android:background="@android:color/white"
8+
android:clickable="true"
9+
android:focusable="true"
810
android:padding="4dp">
911

1012
<Button
@@ -228,8 +230,8 @@
228230
<Button
229231
android:id="@+id/apply_scale_ratio"
230232
android:layout_width="match_parent"
231-
android:onClick="handleOnClick"
232233
android:layout_height="wrap_content"
234+
android:onClick="handleOnClick"
233235
android:text="apply scale ratios"
234236
app:layout_constraintTop_toBottomOf="@+id/scale_ratio_text" />
235237

0 commit comments

Comments
 (0)