-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
haozi
committed
Apr 24, 2019
1 parent
79aaac9
commit 4378b0e
Showing
18 changed files
with
519 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Toastlib/src/main/java/com/android/toastlib/toast/ActivityCustomizeToast.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.android.toastlib.toast; | ||
|
||
import android.app.Application; | ||
import android.view.View; | ||
|
||
import com.android.toastlib.util.ActivityCustomizeToastHandler; | ||
|
||
public class ActivityCustomizeToast implements IToast{ | ||
// 吐司弹窗显示辅助类 | ||
private final ActivityCustomizeToastHandler mToastHelper; | ||
|
||
public ActivityCustomizeToast(Application application) { | ||
mToastHelper = new ActivityCustomizeToastHandler(application); | ||
} | ||
|
||
@Override | ||
public void cancel() { | ||
// 取消显示 | ||
mToastHelper.removeView(); | ||
} | ||
|
||
@Override | ||
public View getView() { | ||
return mToastHelper.getView(); | ||
} | ||
|
||
@Override | ||
public void showToast(CharSequence s) { | ||
mToastHelper.setMessage(s); | ||
if(mToastHelper.isToastShowing()) | ||
mToastHelper.sendHideToastMessage(s); | ||
else | ||
mToastHelper.sendShowToastMessage(s); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
Toastlib/src/main/java/com/android/toastlib/toast/TopCustomizeToast.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.android.toastlib.toast; | ||
|
||
import android.app.Application; | ||
import android.view.View; | ||
|
||
import com.android.toastlib.util.TopCustomizeToastHandler; | ||
|
||
public class TopCustomizeToast implements IToast{ | ||
private TopCustomizeToastHandler topToastHandler; | ||
public TopCustomizeToast(Application application){ | ||
topToastHandler = new TopCustomizeToastHandler(application); | ||
} | ||
|
||
@Override | ||
public void showToast(CharSequence s) { | ||
topToastHandler.setMessage(s); | ||
if(topToastHandler.isToastShowing()){ | ||
topToastHandler.sendHideToastMessage(s); | ||
}else { | ||
topToastHandler.sendShowToastMessage(s); | ||
} | ||
} | ||
|
||
@Override | ||
public void cancel() { | ||
topToastHandler.removeView(); | ||
} | ||
|
||
@Override | ||
public View getView() { | ||
return topToastHandler.getView(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
Toastlib/src/main/java/com/android/toastlib/util/ActivityCustomizeToastHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.android.toastlib.util; | ||
|
||
import android.app.Application; | ||
import android.graphics.PixelFormat; | ||
import android.view.Gravity; | ||
import android.view.WindowManager; | ||
|
||
public class ActivityCustomizeToastHandler extends BaseCustomToastHandler { | ||
private ActivityLifecycleCallback mWindowHelper; | ||
private String mPackageName; | ||
|
||
public ActivityCustomizeToastHandler(Application context) { | ||
super(context); | ||
init(context); | ||
} | ||
|
||
private void init(Application application) { | ||
mPackageName = application.getPackageName(); | ||
mWindowHelper = new ActivityLifecycleCallback(this, application); | ||
} | ||
|
||
@Override | ||
public WindowManager getWindowManager() { | ||
return mWindowHelper.getWindowManager(); | ||
} | ||
|
||
@Override | ||
public WindowManager.LayoutParams getWindowManagerLayoutParams() { | ||
WindowManager.LayoutParams params = new WindowManager.LayoutParams(); | ||
params.height = WindowManager.LayoutParams.WRAP_CONTENT; | ||
params.width = WindowManager.LayoutParams.MATCH_PARENT; | ||
params.format = PixelFormat.TRANSLUCENT; | ||
// params.windowAnimations = R.style.top_toast_style; | ||
params.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | ||
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | ||
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | ||
| WindowManager.LayoutParams.FLAG_FULLSCREEN | ||
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; | ||
params.packageName = mPackageName; | ||
// 重新初始化位置 | ||
params.gravity = Gravity.TOP; | ||
params.x = 0; | ||
params.y = 0; | ||
|
||
return params; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.