Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.iml
.gradle
/local.properties
/.idea
/.idea/workspace.xml
/.idea/libraries
.DS_Store
Expand Down
116 changes: 0 additions & 116 deletions .idea/codeStyles/Project.xml

This file was deleted.

22 changes: 0 additions & 22 deletions .idea/gradle.xml

This file was deleted.

48 changes: 0 additions & 48 deletions .idea/misc.xml

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/modules.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

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

This file was deleted.

4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ buildscript {

repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.6.1'


// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -20,6 +21,7 @@ allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
google()
}
}

Expand Down
2 changes: 1 addition & 1 deletion floatwindow/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:appcompat-v7:26.1.0'
testCompile 'junit:junit:4.12'
}

Expand Down
37 changes: 32 additions & 5 deletions floatwindow/src/main/java/com/yhao/floatwindow/FloatWindow.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.yhao.floatwindow;

import android.animation.TimeInterpolator;
import android.app.Application;
import android.content.ComponentCallbacks;
import android.content.Context;
import android.content.res.Configuration;
import android.support.annotation.LayoutRes;
import android.support.annotation.MainThread;
import android.support.annotation.NonNull;
Expand All @@ -20,13 +23,35 @@

public class FloatWindow {

private FloatWindow() {
private FloatWindow(Context applicationContext) {
Application application = (Application) applicationContext;
application.registerComponentCallbacks(new ComponentCallbacks() {
@Override
public void onConfigurationChanged(Configuration configuration) {
// 屏幕方向变化
Util.orientationChanged();

int ori = configuration.orientation;
for (IFloatWindow window : mFloatWindowMap.values()) {
if (window != null) {
window.orientationChanged(ori);
}
}
}

@Override
public void onLowMemory() {

}
});
}

private static final String mDefaultTag = "default_float_window_tag";

private static Map<String, IFloatWindow> mFloatWindowMap;

private static FloatWindow sInstance;

public static IFloatWindow get() {
return get(mDefaultTag);
}
Expand All @@ -35,11 +60,13 @@ public static IFloatWindow get(@NonNull String tag) {
return mFloatWindowMap == null ? null : mFloatWindowMap.get(tag);
}

private static B mBuilder = null;

@MainThread
public static B with(@NonNull Context applicationContext) {
return mBuilder = new B(applicationContext);
public synchronized static B with(@NonNull Context applicationContext) {
if (sInstance == null) {
sInstance = new FloatWindow(applicationContext);
}

return new B(applicationContext);
}

public static void destroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ public abstract class IFloatWindow {
public abstract View getView();

abstract void dismiss();

abstract void orientationChanged(int ori);
}
Loading