Permalink
Browse files

refine code according to checkstyle

  • Loading branch information...
andrewleo committed Feb 28, 2013
1 parent 87558e2 commit 2533df9321220ec9aea42581f7e7d4e39d338b7c
@@ -54,16 +54,15 @@
import com.netease.qa.emmagee.R;
/**
* Main Page of Emmagee.
* @author andrewleo
* Main Page of Emmagee
*
*/
public class MainPageActivity extends Activity {
private final String LOG_TAG = "Emmagee-"
private static final String LOG_TAG = "Emmagee-"
+ MainPageActivity.class.getSimpleName();
private final int TIMEOUT = 20000;
private static final int TIMEOUT = 20000;
private List<Programe> processList;
private ProcessInfo processInfo;
@@ -265,6 +264,9 @@ public void onClick(DialogInterface dialog,
List<Programe> programe;
int tempPosition = -1;
/**
* save status of all installed processes
*/
class Viewholder {
TextView txtAppName;
ImageView imgViAppIcon;
@@ -36,9 +36,13 @@
import com.netease.qa.emmagee.R;
/**
* Setting Page of Emmagee
*
*/
public class SettingsActivity extends Activity {
private final String LOG_TAG = "Emmagee-"
private static final String LOG_TAG = "Emmagee-"
+ SettingsActivity.class.getSimpleName();
private CheckBox chkFloat;
@@ -64,13 +68,13 @@ public void onCreate(Bundle savedInstanceState) {
try {
raf = new RandomAccessFile(settingTempFile, "r");
String f = raf.readLine();
if (f == null || (f != null && f.equals(""))) {
if (f == null || ("".equals(f))) {
time = "5";
} else {
time = f;
}
String tag = raf.readLine();
if (tag != null && tag.equals("false")) {
if ("false".equals(tag)) {
floatingTag = false;
}
raf.close();
@@ -92,7 +96,7 @@ public void onClick(View v) {
Toast.makeText(SettingsActivity.this, "输入数据无效,请重新输入",
Toast.LENGTH_LONG).show();
edtTime.setText("");
} else if (time.equals("") || Long.parseLong(time) == 0) {
} else if ("".equals(time) || Long.parseLong(time) == 0) {
Toast.makeText(SettingsActivity.this, "输入数据为空,请重新输入",
Toast.LENGTH_LONG).show();
edtTime.setText("");
@@ -53,6 +53,10 @@
import com.netease.qa.emmagee.utils.MyApplication;
import com.netease.qa.emmagee.R;
/**
* Service running in background
*
*/
public class EmmageeService extends Service {
private final static String LOG_TAG = "Emmagee-"
@@ -151,7 +155,7 @@ private void readSettingInfo(Intent intent) {
RandomAccessFile raf = new RandomAccessFile(new File(
settingTempFile), "r");
time = raf.readLine();
isFloating = raf.readLine().equals("true") ? true : false;
isFloating = ("true".equals(raf.readLine())) ? true : false;
raf.close();
} catch (IOException e) {
time = "5";
@@ -322,8 +326,8 @@ private void dataRefresh() {
processCpuRatio = processInfo.get(0);
totalCpuRatio = processInfo.get(1);
trafficSize = processInfo.get(2);
if (trafficSize != null && !trafficSize.equals("")
&& !trafficSize.equals("-1")) {
if ("".equals(trafficSize)
&& !("-1".equals(trafficSize))) {
tempTraffic = Integer.parseInt(trafficSize);
if (tempTraffic > 1024) {
isMb = true;
@@ -336,7 +340,7 @@ private void dataRefresh() {
+ freeMemoryKb + "MB");
txtTotalMem.setText("占用CPU:" + processCpuRatio + "%"
+ ",总体CPU:" + totalCpuRatio + "%");
if (trafficSize.equals("-1")) {
if ("-1".equals(trafficSize)) {
txtTraffic.setText("本程序或本设备不支持流量统计");
} else if (isMb)
txtTraffic.setText("消耗流量:" + fomart.format(trafficMb)
@@ -29,6 +29,10 @@
import android.content.Context;
import android.util.Log;
/**
* operate CPU information
*
*/
public class CpuInfo {
private static final String LOG_TAG = "Emmagee-"
@@ -46,7 +50,7 @@
private long lastestTraffic;
private long traffic;
private TrafficInfo trafficInfo;
private ArrayList<String> CpuUsedRatio;
private ArrayList<String> cpuUsedRatio;
private long totalCpu2;
private long processCpu2;
private long idleCpu2;
@@ -61,7 +65,7 @@ public CpuInfo(Context context, int pid, String uid) {
formatterFile = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
mi = new MemoryInfo();
totalMemorySize = mi.getTotalMemory();
CpuUsedRatio = new ArrayList<String>();
cpuUsedRatio = new ArrayList<String>();
}
/**
@@ -141,7 +145,7 @@ public String getCpuName() {
fomart.setMinimumFractionDigits(2);
readCpuStat();
CpuUsedRatio.clear();
cpuUsedRatio.clear();
try {
Calendar cal = Calendar.getInstance();
@@ -160,7 +164,8 @@ public String getCpuName() {
processCpuRatio = fomart
.format(100 * ((double) (processCpu - processCpu2) / (double) (totalCpu - totalCpu2)));
totalCpuRatio = fomart
.format(100 * ((double) ((totalCpu - idleCpu) - (totalCpu2 - idleCpu2)) / (double) (totalCpu - totalCpu2)));
.format(100 * ((double) ((totalCpu - idleCpu) - (totalCpu2 - idleCpu2))
/ (double) (totalCpu - totalCpu2)));
long pidMemory = mi.getPidMemorySize(pid, context);
String pMemory = fomart.format((double) pidMemory / 1024);
long freeMemory = mi.getFreeMemorySize(context);
@@ -186,14 +191,14 @@ public String getCpuName() {
totalCpu2 = totalCpu;
processCpu2 = processCpu;
idleCpu2 = idleCpu;
CpuUsedRatio.add(processCpuRatio);
CpuUsedRatio.add(totalCpuRatio);
CpuUsedRatio.add(String.valueOf(traffic));
cpuUsedRatio.add(processCpuRatio);
cpuUsedRatio.add(totalCpuRatio);
cpuUsedRatio.add(String.valueOf(traffic));
} catch (IOException e) {
e.printStackTrace();
// PttService.closeOpenedStream()
}
return CpuUsedRatio;
return cpuUsedRatio;
}
@@ -25,6 +25,10 @@
import android.os.Debug;
import android.util.Log;
/**
* operate memory information
*
*/
public class MemoryInfo {
private static final String LOG_TAG = "Emmagee-"
@@ -100,7 +104,7 @@ public int getPidMemorySize(int pid, Context context) {
/**
* get the sdk version of phone.
*
*
* @return sdk version
*/
public String getSDKVersion() {
@@ -109,7 +113,7 @@ public String getSDKVersion() {
/**
* get phone type.
*
*
* @return phone type
*/
public String getPhoneType() {
@@ -19,8 +19,12 @@
import android.app.Application;
import android.view.WindowManager;
/**
* my application class
*
*/
public class MyApplication extends Application {
private WindowManager.LayoutParams wmParams = new WindowManager.LayoutParams();
public WindowManager.LayoutParams getMywmParams() {
@@ -28,12 +28,16 @@
import android.content.pm.PackageManager;
import android.util.Log;
/**
* get information of processes
*
*/
public class ProcessInfo {
private final String LOG_TAG = "Emmagee-"
private static final String LOG_TAG = "Emmagee-"
+ ProcessInfo.class.getSimpleName();
private final String PACKAGE_NAME = "com.netease.qa.emmagee";
private static final String PACKAGE_NAME = "com.netease.qa.emmagee";
/**
* get information of all running processes,including package name ,process
@@ -18,6 +18,11 @@
import android.graphics.drawable.Drawable;
/**
* details of installed processes ,including
* icon,packagename,pid,uid,processname
*
*/
public class Programe {
private Drawable icon;
private String processName;
@@ -22,6 +22,10 @@
import android.util.Log;
/**
* information of network traffic
*
*/
public class TrafficInfo {
private static final String LOG_TAG = "Emmagee-"
@@ -72,6 +76,6 @@ public long getTrafficInfo() {
if (rcvTraffic == -1 || sndTraffic == -1) {
return -1;
} else
return (rcvTraffic + sndTraffic);
return rcvTraffic + sndTraffic;
}
}

0 comments on commit 2533df9

Please sign in to comment.