Skip to content

Commit

Permalink
fix hide() method invalid and when drag outside of screen,the window …
Browse files Browse the repository at this point in the history
…disappeared
  • Loading branch information
lijiah committed Sep 12, 2018
1 parent 23d9b73 commit 9a26c8d
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 13 deletions.
Binary file added .idea/caches/build_file_checksums.ser
Binary file not shown.
29 changes: 29 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

2 changes: 1 addition & 1 deletion floatwindow/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ dependencies {
// JitPack Maven
apply plugin: 'com.github.dcendents.android-maven'
// Your Group
group='com.github.yhaolpz'
group='com.github.lijiahua'
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public void show() {

@Override
public void hide() {
if (once || !isShow) {
return;
}
// if (once || !isShow) {
// return;
// }
getView().setVisibility(View.INVISIBLE);
isShow = false;
if (mB.mViewStateListener != null) {
Expand Down Expand Up @@ -207,6 +207,15 @@ public boolean onTouch(View v, MotionEvent event) {
changeY = event.getRawY() - lastY;
newX = (int) (mFloatView.getX() + changeX);
newY = (int) (mFloatView.getY() + changeY);

if (newY < 0 - Util.getStatusBarHeight(mB.mApplicationContext)) {
newY = 0 - Util.getStatusBarHeight(mB.mApplicationContext);
}
int i = Util.getScreenHeight(mB.mApplicationContext) - Util.getStatusBarHeight(mB.mApplicationContext) - v.getHeight();
if (newY > i) {
newY = i;
}

mFloatView.updateXY(newX, newY);
if (mB.mViewStateListener != null) {
mB.mViewStateListener.onPositionUpdate(newX, newY);
Expand Down
10 changes: 10 additions & 0 deletions floatwindow/src/main/java/com/yhao/floatwindow/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ static int getScreenHeight(Context context) {
return sPoint.y;
}

static int getStatusBarHeight(Context context) {
int height = 0;
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
height = context.getResources().getDimensionPixelSize(resourceId);
}

return height;
}

static boolean isViewVisible(View view) {
return view.getGlobalVisibleRect(new Rect());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ public void onCreate() {
.setHeight(Screen.width, 0.2f)
.setX(Screen.width, 0.8f)
.setY(Screen.height, 0.3f)
.setMoveType(MoveType.slide,100,-100)
.setMoveType(MoveType.slide)
.setMoveStyle(500, new BounceInterpolator())
.setFilter(true, A_Activity.class, C_Activity.class)
.setViewStateListener(mViewStateListener)
.setPermissionListener(mPermissionListener)
.setDesktopShow(true)
.build();

//FloatWindow.get().hide();


imageView.setOnClickListener(new View.OnClickListener() {
@Override
Expand Down

0 comments on commit 9a26c8d

Please sign in to comment.