-
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
Showing
8 changed files
with
99 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/example/CQUPT/utils/AppUsageInfo.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,19 @@ | ||
package com.example.CQUPT.utils; | ||
|
||
public class AppUsageInfo { | ||
private final String appName; | ||
private final String usageTime; | ||
|
||
public AppUsageInfo(String appName, String usageTime) { | ||
this.appName = appName; | ||
this.usageTime = usageTime; | ||
} | ||
|
||
public String getAppName() { | ||
return appName; | ||
} | ||
|
||
public String getUsageTime() { | ||
return usageTime; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/com/example/CQUPT/utils/KeyboardUtils.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,30 @@ | ||
package com.example.CQUPT.utils; | ||
|
||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.view.View; | ||
import android.view.inputmethod.InputMethodManager; | ||
|
||
public class KeyboardUtils { | ||
public static void hideKeyboard(Activity activity) { | ||
if (activity == null) return; | ||
|
||
// 获取当前焦点的View | ||
View currentFocus = activity.getCurrentFocus(); | ||
if (currentFocus != null) { | ||
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); | ||
imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0); | ||
// 清除焦点 | ||
currentFocus.clearFocus(); | ||
} | ||
} | ||
|
||
public static void hideKeyboard(View view) { | ||
if (view == null) return; | ||
|
||
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); | ||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); | ||
// 清除焦点 | ||
view.clearFocus(); | ||
} | ||
} |
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