强迫证重证者,有见过如此打Log的android代码吗,谈苦逼程序员之快速打Log方法

package com.zjg.youhuodong;


import java.io.File;
import java.util.ArrayList;


import android.app.ActionBar;
import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;


import com.zjg.CityParser;
import com.zjg.TreeNode;
import com.zjg.android.AndroidThreadPool;
import com.zjg.android.DetailedLog;
import com.zjg.android.ExceptionCatchService;
import com.zjg.youhuodong.beans.City;


public class ActivitySelectCity extends ListActivity {


// log_begin
private static final DetailedLog Log = new DetailedLog();
private static final String LOG_TAG = Common.LOG_TAG;
// log_end


// 线程id
private static final int THREAD_ID = 0;


// 自动定位按钮
private Button btnAutoLocation = null;


// 城市树形目录及其组织的列表
private TreeNode<City> cityTree = null;
private Object cityTreeSyncLock = new Object();
private ArrayList<TreeNode<City>> cityTreeNodeList = null;


// 选择的城市
private City city = null;


// 城市列表控件适配器
private CityListAdapter cityListAdapter = null;


private EditText etCurrentCityValue = null;
private EditText etChangeTheCityValue = null;


// 位置
private LocationManager locationManager = null;
private LocationListener locationListener = null;
private Location location = null;
private Object locationSyncLock = new Object();


// 数据库文件
private File databaseFile = null;
private Object databaseFileSyncLock = new Object();


// 自动定位城市的执行体
private AndroidThreadPool.Task autoLocationCityTask = new AndroidThreadPool.Task() {
private ProgressDialog progressDialog = null;
private City result = null;
private String details = "";


@Override
public void run() {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG, this + "::public void run() {");
// log_end


result = null;
details = "";


// 自动定位任务开始,post到主线程,执行一些初始操作
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG, this + "::public void run() {");
// log_end


// 设置自动定位按钮为不可用状态
btnAutoLocation.setEnabled(false);
// log_begin
Log.i(LOG_TAG, this
+ "::btnAutoLocation.setEnabled(false);");
// log_end


// 启动等待对话框
progressDialog = ProgressDialog.show(
ActivitySelectCity.this,
getResources().getText(R.string.app_name),
"请稍等,正在定位所在城市……");
// log_begin
Log.i(LOG_TAG, this
+ "::progressDialog = ProgressDialog.show();");
// log_end


// 对话框可以被back键关闭
progressDialog.setCancelable(true);
// log_begin
Log.i(LOG_TAG, this
+ "::progressDialog.setCancelable(true);");
// log_end


// 设置等待对话框关闭事件监听器
progressDialog
.setOnDismissListener(new OnDismissListener() {


@Override
public void onDismiss(DialogInterface dialog) {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG,
this
+ "::public void onDismiss(DialogInterface dialog) {");
// log_end


// 对话框被关闭时,停止线程
AndroidThreadPool.getInstance().stopThread(
THREAD_ID);
// log_begin
Log.i(LOG_TAG,
this
+ "::AndroidThreadPool.getInstance().stopThread(THREAD_ID);");
// log_end


}
});
// log_begin
Log.i(LOG_TAG, this + "::});");
// log_end


}
});
// log_begin
Log.i(LOG_TAG, this + "::});");
// log_end


// location == null,并且任务还没有被停止,则等待500毫秒,最多等待5次共2500毫秒
int count = 0;
int maxCount = 5;
int wait_time = 500;
while (location == null && !isStop() && count++ < maxCount) {
// log_begin
Log.i(LOG_TAG,
this
+ "::while (location == null && !isStop() && count++ < maxCount) {>>location="
+ location + ",isStop()=" + isStop()
+ ",count=" + count + ",maxCount=" + maxCount);
// log_end
synchronized (locationSyncLock) {
// log_begin
Log.i(LOG_TAG, this + "::synchronized (locationSyncLock) {");
// log_end
if (location == null) {
// log_begin
Log.i(LOG_TAG, this + "::if (location == null) {");
// log_end
try {
// log_begin
Log.i(LOG_TAG, this
+ "::locationSyncLock.wait(wait_time);");
// log_end
locationSyncLock.wait(wait_time);
} catch (InterruptedException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
ExceptionCatchService.exceptionCatch(
getApplicationContext(), e);
}
}
}
}
if (location == null) {
// log_begin
Log.i(LOG_TAG, this + "::if (location == null) {");
// log_end
details = "没有获得设备位置坐标,可能是设备没有此功能或信号不稳定。";
// log_begin
Log.i(LOG_TAG, this
+ "::details = \"没有获得设备位置坐标,可能是设备没有此功能或信号不稳定。\";");
// log_end


return;
}


// 得到设备所在位置的一个经、纬坐标
double lat = location.getLatitude();
// log_begin
Log.i(LOG_TAG, this
+ "::double lat = location.getLatitude();>>lat=" + lat);
// log_end
double lng = location.getLongitude();
// log_begin
Log.i(LOG_TAG, this
+ "::double lng = location.getLongitude();>>lng=" + lng);
// log_end


// cityTree == null,并且任务还没有被停止,则等待500毫秒,最多等待10次共5000毫秒
count = 0;
maxCount = 10;
wait_time = 500;
while (cityTree == null && !isStop() && count++ < maxCount) {
// log_begin
Log.i(LOG_TAG,
this
+ "::while (cityTree == null && !isStop() && count++ < maxCount) {>>cityTree="
+ cityTree + ",isStop()=" + isStop()
+ ",count=" + count + ",maxCount=" + maxCount);
// log_end
synchronized (cityTreeSyncLock) {
// log_begin
Log.i(LOG_TAG, this + "::synchronized (cityTreeSyncLock) {");
// log_end
if (cityTree == null) {
// log_begin
Log.i(LOG_TAG, this + "::if (cityTree == null) {");
// log_end
try {
// log_begin
Log.i(LOG_TAG, this
+ "::cityTreeSyncLock.wait(wait_time);");
// log_end
cityTreeSyncLock.wait(wait_time);
} catch (InterruptedException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
ExceptionCatchService.exceptionCatch(
getApplicationContext(), e);
}
}
}
}
if (cityTree == null) {
// log_begin
Log.i(LOG_TAG, this + "::if (cityTree == null) {");
// log_end
details = "城市数据没有载入。";
// log_begin
Log.i(LOG_TAG, this + "::details = \"城市数据没有载入。\";");
// log_end
return;
}


synchronized (cityTreeSyncLock) {
// log_begin
Log.i(LOG_TAG, this + "::synchronized (cityTreeSyncLock) {");
// log_end
if (cityTree != null) {
// log_begin
Log.i(LOG_TAG, this + "::if (cityTree != null) {");
// log_end
double resultDeviation = Double.MAX_VALUE;
// log_begin
Log.i(LOG_TAG,
this
+ "::double resultDeviation = Double.MAX_VALUE;>>resultDeviation="
+ resultDeviation);
// log_end
double deviation = Double.MAX_VALUE;
// log_begin
Log.i(LOG_TAG,
this
+ "::double deviation = Double.MAX_VALUE;>>deviation="
+ deviation);
// log_end
double tmpLatitude = 0.0;
double tmpLongitude = 0.0;
for (int i = 0, cityCount = cityTree.getAllNodeCount(); i < cityCount; i++) {
// log_begin
Log.i(LOG_TAG,
this
+ "::for (int i = 0, cityCount = cityTree.getAllNodeCount(); i < cityCount; i++) {>>i="
+ i + ",cityCount=" + cityCount);
// log_end
if (isStop()) {
// log_begin
Log.i(LOG_TAG, this + "::if (isStop()) {");
// log_end
result = null;
// log_begin
Log.i(LOG_TAG, this + "::result = null;");
// log_end
break;
}
TreeNode<City> tmpNode = cityTree.getNode(i);
// log_begin
Log.i(LOG_TAG,
this
+ "::TreeNode<City> tmpNode = cityTree.getNode(i);");
// log_end
if (tmpNode.isEndmost()) {
// log_begin
Log.i(LOG_TAG, this
+ "::if (tmpNode.isEndmost()) {");
// log_end
tmpLatitude = tmpNode.getData().getLatitude();
// log_begin
Log.i(LOG_TAG,
this
+ "::tmpLatitude = tmpNode.getData().getLatitude();>>tmpLatitude="
+ tmpLatitude);
// log_end
tmpLongitude = tmpNode.getData().getLongitude();
// log_begin
Log.i(LOG_TAG,
this
+ "::tmpLongitude = tmpNode.getData().getLongitude();>>tmpLongitude="
+ tmpLongitude);
// log_end
deviation = Math.sqrt(Math
.pow(lat - tmpLatitude, 2)
+ Math.pow(lng - tmpLongitude, 2));
// log_begin
Log.i(LOG_TAG,
this
+ "::deviation = Math.sqrt(Math.pow(lat - tmpLatitude, 2) + Math.pow(lng - tmpLongitude, 2));>>deviation="
+ deviation);
// log_end
if (deviation < resultDeviation) {
// log_begin
Log.i(LOG_TAG,
this
+ "::if (deviation < resultDeviation) {>>deviation="
+ deviation
+ ",resultDeviation="
+ resultDeviation);
// log_end
resultDeviation = deviation;
// log_begin
Log.i(LOG_TAG, this
+ "::resultDeviation = deviation;");
// log_end
result = tmpNode.getData();
// log_begin
Log.i(LOG_TAG,
this
+ "::result = tmpNode.getData();>>result="
+ result);
// log_end


}
}
}
}
}
}


@Override
public void onComplete() {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG, this + "::public void onComplete() {");
// log_end


if (result != null) {
// log_begin
Log.i(LOG_TAG, this + "::if (result != null) {");
// log_end
city = result;
// log_begin
Log.i(LOG_TAG, this + "::city = result;");
// log_end


// 向用户显示定位城市的结果
etChangeTheCityValue.setText(city.getFullName());
// log_begin
Log.i(LOG_TAG,
this
+ "::etChangeTheCityValue.setText(city.getFullName());>>city.getFullName()="
+ city.getFullName());
// log_end


} else {
// log_begin
Log.i(LOG_TAG, this + "::if (result != null) { } else {");
// log_end
Toast.makeText(ActivitySelectCity.this, "定位失败!详情:" + details,
Toast.LENGTH_SHORT).show();
// log_begin
Log.i(LOG_TAG,
this
+ "::Toast.makeText(ActivitySelectCity.this, \"定位失败!详情:\" + details, Toast.LENGTH_SHORT).show();>>details="
+ details);
// log_end
}


btnAutoLocation.setEnabled(true);
// log_begin
Log.i(LOG_TAG, this + "::btnAutoLocation.setEnabled(true);");
// log_end
progressDialog.dismiss();
// log_begin
Log.i(LOG_TAG, this + "::progressDialog.dismiss();");
// log_end
}


@Override
public void onStop() {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG, this + "::public void onStop() {");
// log_end


Toast.makeText(ActivitySelectCity.this, "定位被终止!",
Toast.LENGTH_SHORT).show();
// log_begin
Log.i(LOG_TAG,
this
+ "::Toast.makeText(ActivitySelectCity.this, \"定位被终止!\", Toast.LENGTH_SHORT).show();");
// log_end


btnAutoLocation.setEnabled(true);
// log_begin
Log.i(LOG_TAG, this + "::btnAutoLocation.setEnabled(true);");
// log_end
}


@Override
public int getRunThreadId() {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG, this + "::public int getRunThreadId() {");
// log_end


return THREAD_ID;
}
};


// 载入城市列表的执行体
private AndroidThreadPool.Task loadCityTreeTask = new AndroidThreadPool.Task() {
private boolean succeed = false;
private ProgressDialog progressDialog = null;


@Override
public void run() {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG, this + "::public void run() {");
// log_end


succeed = false;
// log_begin
Log.i(LOG_TAG, this + "::succeed = false;");
// log_end


// 自动定位任务开始,post到主线程,执行一些初始操作
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG, this + "::public void run() {");
// log_end


// 启动等待对话框
progressDialog = ProgressDialog.show(
ActivitySelectCity.this,
getResources().getText(R.string.app_name),
"请稍等,正在加载城市数据……");
// log_begin
Log.i(LOG_TAG, this
+ "::progressDialog = ProgressDialog.show();");
// log_end


// 对话框可以被back键关闭
progressDialog.setCancelable(true);
// log_begin
Log.i(LOG_TAG, this
+ "::progressDialog.setCancelable(true);");
// log_end


// 设置等待对话框关闭事件监听器
progressDialog
.setOnDismissListener(new OnDismissListener() {


@Override
public void onDismiss(DialogInterface dialog) {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG,
this
+ "::public void onDismiss(DialogInterface dialog) {");
// log_end


// 对话框被关闭时,停止线程
AndroidThreadPool.getInstance().stopThread(
loadCityTreeTask.getRunThreadId());
// log_begin
Log.i(LOG_TAG,
this
+ "::AndroidThreadPool.getInstance().stopThread(THREAD_ID);");
// log_end


}
});
// log_begin
Log.i(LOG_TAG, this + "::});");
// log_end


}
});
// log_begin
Log.i(LOG_TAG, this + "::});");
// log_end


// databaseFile == null,并且任务还没有被停止,则等待500毫秒,最多等待5次共2500毫秒
int count = 0;
int maxCount = 5;
int wait_time = 500;
while (databaseFile == null && !isStop() && count++ < maxCount) {
// log_begin
Log.i(LOG_TAG,
this
+ "::while (databaseFile == null && !isStop() && count++ < maxCount) {");
// log_end


synchronized (databaseFileSyncLock) {
// log_begin
Log.i(LOG_TAG, this
+ "::synchronized (databaseFileSyncLock) {");
// log_end
if (databaseFile == null) {
// log_begin
Log.i(LOG_TAG, this + "::if (databaseFile == null) {");
// log_end
try {
// log_begin
Log.i(LOG_TAG, this
+ "::databaseFileSyncLock.wait(wait_time);");
// log_end
databaseFileSyncLock.wait(wait_time);


} catch (InterruptedException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
ExceptionCatchService.exceptionCatch(
getApplicationContext(), e);


}
}
}
}


SQLiteDatabase database = null;
Cursor cur = null;
if (databaseFile != null) {
// log_begin
Log.i(LOG_TAG, this + "::if (databaseFile != null) {");
// log_end


database = YouhuodongDB.getDatabase(databaseFile); // 实例数据库
// log_begin
Log.i(LOG_TAG,
this
+ "::database = YouhuodongDB.getDatabase(databaseFile);");
// log_end


cur = database
.rawQuery(
"select * from "
+ YouhuodongDB.CityTable.NAME
+ " where "
+ YouhuodongDB.CityTable.FIELDS[YouhuodongDB.CityTable.FIELD_DEPRECATED]
+ " = ?", new String[] { "0" });
// log_begin
Log.i(LOG_TAG,
this
+ "::cur = database"
+ ".rawQuery("
+ " \"select * from \""
+ " + YouhuodongDB.CityTable.NAME"
+ " + \" where \""
+ " + YouhuodongDB.CityTable.FIELDS[YouhuodongDB.CityTable.FIELD_DEPRECATED]"
+ " + \" = ?\", new String[] { \"0\" });");
// log_end
}


ArrayList<City> source = new ArrayList<City>();
// log_begin
Log.i(LOG_TAG, this
+ "::ArrayList<City> source = new ArrayList<City>();");
// log_end
if (cur != null && cur.getCount() > 0) {
// log_begin
Log.i(LOG_TAG, this
+ "::if (cur != null && cur.getCount() > 0) {>>cur="
+ cur);
// log_end


while (cur.moveToNext()) {// 直到返回false说明表中到了数据末尾
source.add(new City(
cur.getString(YouhuodongDB.CityTable.FIELD_ID),
cur.getString(YouhuodongDB.CityTable.FIELD_NAME),
cur.getString(YouhuodongDB.CityTable.FIELD_FULL_NAME),
Double.parseDouble(cur
.getString(YouhuodongDB.CityTable.FIELD_LONGITUDE)),
Double.parseDouble(cur
.getString(YouhuodongDB.CityTable.FIELD_LATITUDE))));
}


succeed = true;
// log_begin
Log.i(LOG_TAG, this + "::succeed = true;");
// log_end
}
// 把城市列表文件组织成树型列表
TreeNode<City> tmpCityTree = new TreeNode<City>();
// log_begin
Log.i(LOG_TAG, this
+ "::TreeNode<City> tmpCityTree = new TreeNode<City>();");
// log_end
tmpCityTree.createFormParser(new CityParser(source,
YouhuodongDB.CityTable.CITY_LEVEL_SEPARATOR_CHAR));
// log_begin
Log.i(LOG_TAG,
this
+ "::tmpCityTree.createFormParser(new CityParser(source, YouhuodongDB.CityTable.CITY_LEVEL_SEPARATOR_CHAR));");
// log_end
// 根结点为"中国"
tmpCityTree.setExpandingState(true);
// log_begin
Log.i(LOG_TAG, this + "::tmpCityTree.setExpandingState(true);");
// log_end
tmpCityTree.setData(new City("", "中国", "", 0, 0));
// log_begin
Log.i(LOG_TAG,
this
+ "::tmpCityTree.setData(new City(\"\", \"中国\", \"\", 0, 0));");
// log_end


// 对cityTree变量进行同步锁,防止与自动定位城市线程冲突
synchronized (cityTreeSyncLock) {
// log_begin
Log.i(LOG_TAG, this + "::synchronized (cityTreeSyncLock) {");
// log_end
cityTree = tmpCityTree;
// log_begin
Log.i(LOG_TAG, this + "::cityTree = tmpCityTree;");
// log_end
// 通知自动定位城市线程城市列表已载入完毕
cityTreeSyncLock.notify();
// log_begin
Log.i(LOG_TAG, this + "::cityTreeSyncLock.notify();");
// log_end


cityTreeNodeList = cityTree
.getVisibleNodeList(cityTreeNodeList);
// log_begin
Log.i(LOG_TAG,
this
+ "::cityTreeNodeList = cityTree.getVisibleNodeList(cityTreeNodeList);>>cityTreeNodeList="
+ cityTreeNodeList);
// log_end
}


if (database != null) {
// log_begin
Log.i(LOG_TAG, this + "::if (database != null) {");
// log_end


database.close();
// log_begin
Log.i(LOG_TAG, this + "::database.close();");
// log_end
}
}


@Override
public void onComplete() {


// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG, this + "::public void onComplete() {");
// log_end


progressDialog.dismiss();
// log_begin
Log.i(LOG_TAG, this + "::progressDialog.dismiss();");
// log_end


// 创建显示城市树型列表的视图控件的适配器
cityListAdapter = new CityListAdapter(ActivitySelectCity.this);
// log_begin
Log.i(LOG_TAG,
this
+ "::cityListAdapter = new CityListAdapter(ActivitySelectCity.this);>>cityListAdapter="
+ cityListAdapter);
// log_end


// 设置城市树型列表视图控件的适配器
ActivitySelectCity.this.setListAdapter(cityListAdapter);
// log_begin
Log.i(LOG_TAG,
this
+ "::ActivitySelectCity.this.setListAdapter(cityListAdapter);");
// log_end


Toast.makeText(getApplicationContext(),
succeed ? "载入城市数据成功!" : "载入城市数据失败!", Toast.LENGTH_SHORT)
.show();
// log_begin
Log.i(LOG_TAG,
this
+ "::Toast.makeText(getApplicationContext(), succeed ? \"载入城市数据成功!\" : \"载入城市数据!\", Toast.LENGTH_SHORT).show();>>succeed="
+ succeed);
// log_end
}


@Override
public int getRunThreadId() {
// log_begin
Log.i(LOG_TAG, this + "::public int getRunThreadId() {");
// log_end


// log_begin
Log.i(LOG_TAG, this + "::return Common.SQLITE_THREAD_ID;");
// log_end
return Common.SQLITE_THREAD_ID;
}


@Override
public void onStop() {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG, this + "::public void onStop() {");
// log_end


Toast.makeText(ActivitySelectCity.this, "载入城市数据被终止!",
Toast.LENGTH_SHORT).show();
// log_begin
Log.i(LOG_TAG,
this
+ "::Toast.makeText(ActivitySelectCity.this, \"载入城市数据被终止!\","
+ " Toast.LENGTH_SHORT).show();");
// log_end
}


};


@Override
protected void onCreate(Bundle savedInstanceState) {
// log_begin
Log.i(LOG_TAG,
this
+ "::protected void onCreate(Bundle savedInstanceState) {>>savedInstanceState="
+ savedInstanceState);
// log_end
super.onCreate(savedInstanceState);
// log_begin
Log.i(LOG_TAG, this
+ "::super.onCreate(savedInstanceState);>>savedInstanceState="
+ savedInstanceState);
// log_end
setContentView(R.layout.activity_select_city);
// log_begin
Log.i(LOG_TAG, this
+ "::setContentView(R.layout.activity_select_city);");
// log_end


synchronized (databaseFileSyncLock) {
// log_begin
Log.i(LOG_TAG, this + "::synchronized (databaseFileSyncLock) {");
// log_end
databaseFile = new File(
Common.getAppDir(this, Common.DATABASE_DIR),
Common.DATABASE_FILE);
// log_begin
Log.i(LOG_TAG,
this
+ "::databaseFile = new File(Common.getAppDir(this, Common.DATABASE_DIR), Common.DATABASE_FILE);");
// log_end
databaseFileSyncLock.notifyAll();
// log_begin
Log.i(LOG_TAG, this + "::databaseFileSyncLock.notifyAll();");
// log_end
}


if (cityTree == null) {
// log_begin
Log.i(LOG_TAG, this + "::if (cityTree == null) {");
// log_end


// log_begin
Log.i(LOG_TAG,
this
+ "::AndroidThreadPool.getInstance().execution(loadCityTreeTask);>>loadCityTreeTask="
+ loadCityTreeTask);
// log_end
AndroidThreadPool.getInstance().execution(loadCityTreeTask);
}


locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
// log_begin
Log.i(LOG_TAG,
this
+ "::locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);>>locationManager="
+ locationManager);
// log_end
locationListener = new LocationListener() {


@Override
public void onStatusChanged(String provider, int status,
Bundle extras) {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG,
this
+ "::public void onStatusChanged(String provider, int status, Bundle extras) {>>provider="
+ provider + ",status=" + status + ",extras="
+ extras);
// log_end


}


@Override
public void onProviderEnabled(String provider) {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG,
this
+ "::public void onProviderEnabled(String provider) {>>provider="
+ provider);
// log_end


}


@Override
public void onProviderDisabled(String provider) {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG,
this
+ "::public void onProviderDisabled(String provider) {>>provider="
+ provider);
// log_end


}


@Override
public void onLocationChanged(Location location) {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG,
this
+ "::public void onLocationChanged(Location location) {>>location="
+ location);
// log_end


ActivitySelectCity.this.location = location;
// log_begin
Log.i(LOG_TAG, this
+ "::ActivitySelectCity.this.location = location;");
// log_end
}
};


etCurrentCityValue = (EditText) findViewById(R.id.etCurrentCityValue);
// log_begin
Log.i(LOG_TAG,
this
+ "::etCurrentCityValue = (EditText) findViewById(R.id.etCurrentCityValue);>>etCurrentCityValue="
+ etCurrentCityValue);
// log_end
if (Common.currentCity != null) {
// log_begin
Log.i(LOG_TAG, this + "::if (Common.currentCity != null){");
// log_end


etCurrentCityValue.setText(Common.currentCity.getFullName());
// log_begin
Log.i(LOG_TAG,
this
+ "::etCurrentCityValue.setText(Common.currentCity.getFullName());");
}
// log_end
etChangeTheCityValue = (EditText) findViewById(R.id.etChangeTheCityValue);
// log_begin
Log.i(LOG_TAG,
this
+ "::etChangeTheCityValue = (EditText) findViewById(R.id.etChangeTheCityValue);>>etChangeTheCityValue="
+ etChangeTheCityValue);
// log_end


btnAutoLocation = (Button) findViewById(R.id.btnLocation);
// log_begin
Log.i(LOG_TAG,
this
+ "::btnAutoLocation = (Button) findViewById(R.id.btnLocation);>>btnAutoLocation="
+ btnAutoLocation);
// log_end
btnAutoLocation.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG, this + "::public void onClick(View v) {>>v=" + v);
// log_end


AndroidThreadPool.getInstance().execution(autoLocationCityTask);
// log_begin
Log.i(LOG_TAG,
this
+ "::AndroidThreadPool.getInstance().execution(autoLocationCityTask);>>autoLocationCityTask="
+ autoLocationCityTask);
// log_end
}
});
// log_begin
Log.i(LOG_TAG, this + "::});");
// log_end


((Button) findViewById(R.id.btnChangeCityOk))
.setOnClickListener(new OnClickListener() {


@Override
public void onClick(View v) {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG, this
+ "::public void onClick(View v) {>>v=" + v);
// log_end


if (city != null) {
// log_begin
Log.i(LOG_TAG, this + "::if (city != null) {");
// log_end
if (Common.currentCity == null
|| !city.getId().equals(
Common.currentCity.getId())) {
// log_begin
Log.i(LOG_TAG,
this
+ "::if (Common.currentCity == null || !city.getId().equals( Common.currentCity.getId())) {");
// log_end
Common.currentCity = city;
// log_begin
Log.i(LOG_TAG, this
+ "::Common.currentCity = city;");
// log_end
setResult(RESULT_OK, new Intent());
// log_begin
Log.i(LOG_TAG,
this
+ "::setResult(RESULT_OK, new Intent());");
// log_end
}
}
// log_begin
Log.i(LOG_TAG, this + "::finish();");
// log_end
finish();
}
});
// log_begin
Log.i(LOG_TAG, this + "::});");
// log_end


((Button) findViewById(R.id.btnChangeCityCancel))
.setOnClickListener(new OnClickListener() {


@Override
public void onClick(View v) {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG, this
+ "::public void onClick(View v) {>>v=" + v);
// log_end


// log_begin
Log.i(LOG_TAG, this + "::finish();");
// log_end
finish();
}
});
// log_begin
Log.i(LOG_TAG, this + "::});");
// log_end


setActionBar();
// log_begin
Log.i(LOG_TAG, this + "::setActionBar();");
// log_end
}


@Override
protected void onResume() {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG, this + "::protected void onResume() {");
// log_end
super.onResume();
// log_begin
Log.i(LOG_TAG, this + "::super.onResume();");
// log_end
Criteria criteria = new Criteria();
// log_begin
Log.i(LOG_TAG, this + "::Criteria criteria = new Criteria();");
// log_end


// 位置解析的精度,高或低,参数:
// Criteria.ACCURACY_FINE,精确模式;
// Criteria.ACCURACY_COARSE,模糊模式;
criteria.setAccuracy(Criteria.ACCURACY_FINE);
// log_begin
Log.i(LOG_TAG, this + "::criteria.setAccuracy(Criteria.ACCURACY_FINE);");
// log_end


// 是否提供海拔高度信息,是或否
criteria.setAltitudeRequired(false);
// log_begin
Log.i(LOG_TAG, this + "::criteria.setAltitudeRequired(false);");
// log_end


// 是否提供方向信息,是或否
criteria.setBearingRequired(false);
// log_begin
Log.i(LOG_TAG, this + "::criteria.setBearingRequired(false);");
// log_end


// 是否允许运营商计费,是或否
criteria.setCostAllowed(false);
// log_begin
Log.i(LOG_TAG, this + "::criteria.setCostAllowed(false);");
// log_end


// 电池消耗,无、低、中、高,参数:
// Criteria.NO_REQUIREMENT,
// Criteria.POWER_LOW,
// Criteria.POWER_MEDIUM, or Criteria.POWER_HIGH
criteria.setPowerRequirement(Criteria.POWER_LOW);
// log_begin
Log.i(LOG_TAG, this
+ "::criteria.setPowerRequirement(Criteria.POWER_LOW);");
// log_end


String strLocationProvider = locationManager.getBestProvider(criteria,
true);
// log_begin
Log.i(LOG_TAG,
this
+ "::String strLocationProvider = locationManager.getBestProvider(criteria, true);>>strLocationProvider="
+ strLocationProvider);
// log_end


if (strLocationProvider != null) {
// log_begin
Log.i(LOG_TAG, this + "::if (strLocationProvider != null) {");
// log_end


locationManager.requestLocationUpdates(strLocationProvider, 1000,
1, locationListener);
// log_begin
Log.i(LOG_TAG,
this
+ "::locationManager.requestLocationUpdates(strLocationProvider, 1000, 1, locationListener);>>locationListener="
+ locationListener);
// log_end
}
}


@Override
protected void onPause() {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG, this + "::protected void onPause() {");
// log_end


super.onPause();
// log_begin
Log.i(LOG_TAG, this + "::super.onPause();");
// log_end


locationManager.removeUpdates(locationListener);
// log_begin
Log.i(LOG_TAG, this
+ "::locationManager.removeUpdates(locationListener);");
// log_end
}


void setActionBar() {
// log_begin
Log.i(LOG_TAG, this + "::void setActionBar() {");
// log_end
ActionBar actionBar = getActionBar();
// log_begin
Log.i(LOG_TAG, this
+ "::ActionBar actionBar = getActionBar();>>actionBar="
+ actionBar);
// log_end
// 设置是否显示应用程序的图标
actionBar.setDisplayShowHomeEnabled(true);
// log_begin
Log.i(LOG_TAG, this + "::actionBar.setDisplayShowHomeEnabled(true);");
// log_end
// 将应用程序图标设置为可点击的按钮
// m_actionBar.setHomeButtonEnabled(true);
// 将应用程序图标设置为可点击的按钮,并且在图标上添加向左的箭头,该句代码起到了决定性作用
actionBar.setDisplayHomeAsUpEnabled(true);
// log_begin
Log.i(LOG_TAG, this + "::actionBar.setDisplayHomeAsUpEnabled(true);");
// log_end
}


@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG,
this
+ "::protected void onListItemClick(ListView l, View v, int position, long id) {>>l="
+ l + ",v=" + v + ",position=" + position + ",id=" + id);
// log_end


super.onListItemClick(l, v, position, id);
// log_begin
Log.i(LOG_TAG, this
+ "::super.onListItemClick(l, v, position, id);>>l=" + l
+ ",v=" + v + ",position=" + position + ",id=" + id);
// log_end


TreeNode<City> tmpCityTreeNode = cityTreeNodeList.get(position);
// log_begin
Log.i(LOG_TAG,
this
+ "::TreeNode<City> tmpCityTreeNode = cityTreeNodeList.get(position);");
// log_end
if (!tmpCityTreeNode.isEndmost()) {
// log_begin
Log.i(LOG_TAG, this + "::if (!tmpCityTreeNode.isEndmost()) {");
// log_end
tmpCityTreeNode.setExpandingState(!tmpCityTreeNode
.getExpandingState());
// log_begin
Log.i(LOG_TAG,
this
+ "::tmpCityTreeNode.setExpandingState(!tmpCityTreeNode.getExpandingState());");
// log_end
cityTreeNodeList = cityTree.getVisibleNodeList(cityTreeNodeList);
// log_begin
Log.i(LOG_TAG,
this
+ "::cityTreeNodeList = cityTree.getVisibleNodeList(cityTreeNodeList);");
// log_end
cityListAdapter.notifyDataSetChanged();
// log_begin
Log.i(LOG_TAG, this + "::cityListAdapter.notifyDataSetChanged();");
// log_end
} else {
// log_begin
Log.i(LOG_TAG, this
+ "::if (!tmpCityTreeNode.isEndmost()) { } else {");
// log_end
if (tmpCityTreeNode != null) {
// log_begin
Log.i(LOG_TAG, this + "::if (tmpCityTreeNode != null) {");
// log_end
city = tmpCityTreeNode.getData();
// log_begin
Log.i(LOG_TAG, this
+ "::city = tmpCityTreeNode.getData();>>city=" + city);
// log_end
etChangeTheCityValue.setText(city.getFullName());
// log_begin
Log.i(LOG_TAG,
this
+ "::etChangeTheCityValue.setText(city.getFullName());>>city.getFullName()="
+ city.getFullName());
// log_end
}
}
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
// log_begin
Log.i(LOG_TAG, this
+ "::public boolean onCreateOptionsMenu(Menu menu) {>>menu="
+ menu);
// log_end


// Inflate the menu; this adds items to the action bar if it is present.


// log_begin
Log.i(LOG_TAG, this + "::return true;");
// log_end
return true;


}


// 菜单项被选中时执行该方法
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// log_begin
Log.i(LOG_TAG,
this
+ "::public boolean onOptionsItemSelected(MenuItem item) {>>item="
+ item);
// log_end
if (item.isCheckable()) {
// log_begin
Log.i(LOG_TAG, this + "::if (item.isCheckable()) {");
// log_end
item.setChecked(true);
// log_begin
Log.i(LOG_TAG, this + "::item.setChecked(true);");
// log_end
}


// log_begin
Log.i(LOG_TAG, this + "::switch (item.getItemId()) {");
// log_end
switch (item.getItemId()) {
case android.R.id.home:
// log_begin
Log.i(LOG_TAG, this + "case android.R.id.home:");
// log_end


// 点击到我们ActionBar中设置的Home按钮
// Intent intent = new Intent(this, ActivityMain.class);
// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// startActivity(intent);


finish();
// log_begin
Log.i(LOG_TAG, this + "::finish();");
// log_end
break;


default:
// log_begin
Log.i(LOG_TAG, this + "::default:");
// log_end


break;
}


// log_begin
Log.i(LOG_TAG, this + "::return super.onOptionsItemSelected(item);");
// log_end
return super.onOptionsItemSelected(item);


}


class CityListAdapter extends BaseAdapter {
Context m_context;
Bitmap m_list_item_ico;
LayoutInflater m_inflater;


// 参数初始化
public CityListAdapter(Context context) {
// log_begin
Log.i(LOG_TAG, this
+ "::public CityListAdapter(Context context) {>>context="
+ context);
// log_end
m_context = context;
// log_begin
Log.i(LOG_TAG, this + "::m_context = context;");
// log_end


m_list_item_ico = BitmapFactory.decodeResource(
context.getResources(), R.drawable.location);
// log_begin
Log.i(LOG_TAG,
this
+ "::m_list_item_ico = BitmapFactory.decodeResource(context.getResources(), R.drawable.location);");
// log_end
m_inflater = LayoutInflater.from(context);
// log_begin
Log.i(LOG_TAG, this
+ "::m_inflater = LayoutInflater.from(context);");
// log_end
}


@Override
public int getCount() {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG, this + "::public int getCount() {");
// log_end


// log_begin
Log.i(LOG_TAG,
this
+ "::return cityTreeNodeList.size();>>cityTreeNodeList.size()="
+ cityTreeNodeList.size());
// log_end
return cityTreeNodeList.size();


}


@Override
public Object getItem(int position) {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG, this + "::public Object getItem(int position) {");
// log_end


// log_begin
Log.i(LOG_TAG, this
+ "::return cityTreeNodeList.get(position);>>position="
+ position);
// log_end
return cityTreeNodeList.get(position);


}


@Override
public long getItemId(int position) {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG, this + "::public long getItemId(int position) {");
// log_end


// log_begin
Log.i(LOG_TAG, this + "::return position;>>position=" + position);
// log_end
return position;


}


@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG,
this
+ "::public View getView(int position, View convertView, ViewGroup parent) {>>position="
+ position + ",convertView=" + convertView
+ ",parent=" + parent);
// log_end


// TODO Auto-generated method stub
ViewHolder viewHolder = null;
// log_begin
Log.i(LOG_TAG, this + "::ViewHolder viewHolder = null;");
// log_end
if (convertView == null) {
// log_begin
Log.i(LOG_TAG, this + "::if (convertView == null) {");
// log_end
convertView = m_inflater.inflate(R.layout.city_list_item, null);
// log_begin
Log.i(LOG_TAG,
this
+ "::convertView = m_inflater.inflate(R.layout.city_list_item, null);");
// log_end
viewHolder = new ViewHolder();
// log_begin
Log.i(LOG_TAG, this + "::viewHolder = new ViewHolder();");
// log_end
viewHolder.m_tvCityTreeListItemIndent = (TextView) convertView
.findViewById(R.id.tvIndent);
// log_begin
Log.i(LOG_TAG, this + "::.findViewById(R.id.tvIndent);");
// log_end
viewHolder.m_tvCityTreeListItemTitle = (TextView) convertView
.findViewById(R.id.tvTitle);
// log_begin
Log.i(LOG_TAG, this + "::.findViewById(R.id.tvTitle);");
// log_end
viewHolder.m_imvCityTreeListItemIco = (ImageView) convertView
.findViewById(R.id.imvIco);
// log_begin
Log.i(LOG_TAG, this + "::.findViewById(R.id.imvIco);");
// log_end
convertView.setTag(viewHolder);
// log_begin
Log.i(LOG_TAG, this + "::convertView.setTag(viewHolder);");
// log_end
} else {
// log_begin
Log.i(LOG_TAG, this + "::} else {");
// log_end
viewHolder = (ViewHolder) convertView.getTag();
// log_begin
Log.i(LOG_TAG, this
+ "::viewHolder = (ViewHolder) convertView.getTag();");
// log_end
}
String indent = "";
String prefix = "";
// log_begin
Log.i(LOG_TAG, this + "::String indent = \"\";");
// log_end
for (int i = 0; i < cityTreeNodeList.get(position).getDepthLevel(); i++) {
// log_begin
Log.i(LOG_TAG,
this
+ "::for (int i = 0; i < cityTreeNodeList.get(position).getDepthLevel(); i++) {");
// log_end
indent += "    ";
// log_begin
Log.i(LOG_TAG, this + "::indent += \"    \";");
// log_end
}
if (!cityTreeNodeList.get(position).isEndmost()) {
// log_begin
Log.i(LOG_TAG,
this
+ "::if (!cityTreeNodeList.get(position).isEndmost()) {");
// log_end


LayoutParams lp = viewHolder.m_imvCityTreeListItemIco
.getLayoutParams();
// log_begin
Log.i(LOG_TAG, this + "::.getLayoutParams();");
// log_end
lp.width = 0;
// log_begin
Log.i(LOG_TAG, this + "::lp.width = 0;");
// log_end
viewHolder.m_imvCityTreeListItemIco.setLayoutParams(lp);
// log_begin
Log.i(LOG_TAG,
this
+ "::viewHolder.m_imvCityTreeListItemIco.setLayoutParams(lp);");
// log_end


if (cityTreeNodeList.get(position).getExpandingState()) {
// log_begin
Log.i(LOG_TAG,
this
+ "::if (cityTreeNodeList.get(position).getExpandingState()) {");
// log_end
prefix = "-";
// log_begin
Log.i(LOG_TAG, this + "::indent += \"-\";");
// log_end
} else {
// log_begin
Log.i(LOG_TAG, this + "::} else {");
// log_end
prefix = "+";
// log_begin
Log.i(LOG_TAG, this + "::indent += " + ";");
// log_end
}
} else {
// log_begin
Log.i(LOG_TAG, this + "::} else {");
// log_end


LayoutParams lp = viewHolder.m_imvCityTreeListItemIco
.getLayoutParams();
// log_begin
Log.i(LOG_TAG, this + "::.getLayoutParams();");
// log_end
lp.width = m_list_item_ico.getWidth();
// log_begin
Log.i(LOG_TAG, this
+ "::lp.width = m_list_item_ico.getWidth();");
// log_end
viewHolder.m_imvCityTreeListItemIco.setLayoutParams(lp);
// log_begin
Log.i(LOG_TAG,
this
+ "::viewHolder.m_imvCityTreeListItemIco.setLayoutParams(lp);");
// log_end
viewHolder.m_imvCityTreeListItemIco
.setImageBitmap(m_list_item_ico);
// log_begin
Log.i(LOG_TAG, this + "::.setImageBitmap(m_list_item_ico);");
// log_end
}
LayoutParams lp = viewHolder.m_imvCityTreeListItemIco
.getLayoutParams();
// log_begin
Log.i(LOG_TAG, this + "::.getLayoutParams();");
// log_end
lp.height = m_list_item_ico.getHeight();
// log_begin
Log.i(LOG_TAG, this + "::lp.height = m_list_item_ico.getHeight();");
// log_end
viewHolder.m_imvCityTreeListItemIco.setLayoutParams(lp);
// log_begin
Log.i(LOG_TAG,
this
+ "::viewHolder.m_imvCityTreeListItemIco.setLayoutParams(lp);");
// log_end


viewHolder.m_tvCityTreeListItemIndent.setText(indent);
// log_begin
Log.i(LOG_TAG,
this
+ "::viewHolder.m_tvCityTreeListItemIndent.setText(indent);");
// log_end
if (cityTreeNodeList.get(position).getData() != null) {
// log_begin
Log.i(LOG_TAG,
this
+ "::if (cityTreeNodeList.get(position).getData() != null) {");
// log_end
viewHolder.m_tvCityTreeListItemTitle.setText(prefix
+ cityTreeNodeList.get(position).getData().getName());
// log_begin
Log.i(LOG_TAG, this + "::.get(position).getData().getName());");
// log_end
} else {
// log_begin
Log.i(LOG_TAG, this + "::} else {");
// log_end
viewHolder.m_tvCityTreeListItemTitle.setText("");
// log_begin
Log.i(LOG_TAG,
this
+ "::viewHolder.m_tvCityTreeListItemTitle.setText(\"\");");
// log_end
}


// log_begin
Log.i(LOG_TAG, this + "::return convertView;");
// log_end
return convertView;


}


class ViewHolder {
TextView m_tvCityTreeListItemIndent;
ImageView m_imvCityTreeListItemIco;
TextView m_tvCityTreeListItemTitle;


}
}


@Override
protected void onDestroy() {
// TODO 自动生成的方法存根
// log_begin
Log.i(LOG_TAG, this + "::protected void onDestroy() {");
// log_end


super.onDestroy();
// log_begin
Log.i(LOG_TAG, this + "::super.onDestroy();");
// log_end
}


}


借助excel、word、记事本等工具为android代码快速打Log。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值