Skip to content

Commit

Permalink
style: 优化
Browse files Browse the repository at this point in the history
  • Loading branch information
jack committed Feb 2, 2019
1 parent 8c61d5d commit 480be54
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
27 changes: 16 additions & 11 deletions src/com/hi/dhl/AndroidUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,36 @@
public class AndroidUtils {

/**
* sdk 配置的路径
* 动态获取本地Android SDK的路径
*
* @param project
* @return
*/
public static String getApkLocalProperties(Project project){
public static String getApkLocalProperties(Project project) {

String sdkPath = "";
try {
String path = project.getBasePath() + File.separator + "local.properties";

Properties properties = new Properties();
InputStream inputStream = new FileInputStream(path);
properties.load( inputStream );
try {

String path = project.getBasePath() + File.separator + "local.properties";

Properties properties = new Properties();
InputStream inputStream = new FileInputStream(path);
properties.load(inputStream);

sdkPath = properties.getProperty("sdk.dir");
}catch (Exception e){
sdkPath = properties.getProperty("sdk.dir");
} catch (Exception e) {

}
}
return sdkPath;
}

/**
* 获取不同平台的 win、mac etc;
*
* @return
*/
public static String getPlatformName(){
public static String getPlatformName() {
String osName = System.getProperty("os.name");
return osName;
}
Expand Down
9 changes: 6 additions & 3 deletions src/com/hi/dhl/Monitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@
* desc : 插件启动入口
* </pre>
*/
public class Monitor extends AnAction{
public class Monitor extends AnAction {

@Override
public void actionPerformed(AnActionEvent anActionEvent) {

try {

Project project = anActionEvent.getData(PlatformDataKeys.PROJECT);

String os = AndroidUtils.getPlatformName();
String sdkPath = AndroidUtils.getApkLocalProperties(project);
if (os.toLowerCase().startsWith("win")) {
sdkPath += File.separator+"tools"+File.separator+"monitor.bat";
sdkPath += File.separator + "tools" + File.separator + "monitor.bat";
} else {
sdkPath += File.separator+"tools"+File.separator+"monitor";
sdkPath += File.separator + "tools" + File.separator + "monitor";
}

Runtime.getRuntime().exec(sdkPath);
Expand Down

0 comments on commit 480be54

Please sign in to comment.