Skip to content

Commit

Permalink
加入isInEditMode解决布局无法预览的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
AItsuki committed Sep 8, 2018
1 parent 6813142 commit 9323631
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
1 change: 0 additions & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ group='com.github.aitsuki'

android {
compileSdkVersion 28
buildToolsVersion '27.0.3'

defaultConfig {
minSdkVersion 15
Expand Down
7 changes: 7 additions & 0 deletions library/src/main/java/com/aitsuki/swipe/SwipeItemLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public SwipeItemLayout(Context context, AttributeSet attrs, int defStyleAttr) {
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (isInEditMode()) {
return;
}
updateMenu();
}

Expand Down Expand Up @@ -229,6 +232,10 @@ private void checkCanDragged(MotionEvent ev) {
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
super.addView(child, index, params);
if (isInEditMode()) {
return;
}

LayoutParams lp = (LayoutParams) child.getLayoutParams();
int gravity = GravityCompat.getAbsoluteGravity(lp.gravity, ViewCompat.getLayoutDirection(child));
switch (gravity) {
Expand Down

0 comments on commit 9323631

Please sign in to comment.