package com.util;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class CodeCounter {
static long commentLine = 0;
static long whiteLine = 0;
static long normalLine = 0;
static long totalLine = 0;
static boolean comment = false;
public static void main(String[] args) {
File file = new File("D:\\MyEclipse\\Workspaces\\Util\\src\\com\\util\\Table.java"); // 在这里输入需要统计的文件夹路径
getChild(file);
System.out.println("有效代码行数: " + normalLine);
System.out.println("注释行数: " + commentLine);
System.out.println("空白行数: " + whiteLine);
System.out.println("总代码行数: " + totalLine);
}
private static void getChild(File child) { // 遍历子目录
if (child.getName().matches(".*\\.java$")) { // 只查询java文件
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(child));
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
String line = "";
try {
while ((line = br.readLine()) != null) {
parse(line);
}
} catch (IOException e) {
e.printStackTrace();
}
}
if (child.listFiles() != null) {
for (File f : child.listFiles()) {
getChild(f);
}
}
}
private static void parse(String line) {
line = line.trim();
totalLine++;
if (line.length() == 0) {
whiteLine++;
} else if (comment) {
commentLine++;
if (line.endsWith("*/")) {
comment = false;
} else if (line.matches(".*\\*/.+")) {
normalLine++;
comment = false;
}
} else if (line.startsWith("//")) {
commentLine++;
} else if (line.matches(".+//.*")) {
commentLine++;
normalLine++;
} else if (line.startsWith("/*") && line.matches(".+\\*/.+")) {
commentLine++;
normalLine++;
if (findPair(line)) {
comment = false;
} else {
comment = true;
}
} else if (line.startsWith("/*") && !line.endsWith("*/")) {
commentLine++;
comment = true;
} else if (line.startsWith("/*") && line.endsWith("*/")) {
commentLine++;
comment = false;
} else if (line.matches(".+/\\*.*") && !line.endsWith("*/")) {
commentLine++;
normalLine++;
if (findPair(line)) {
comment = false;
} else {
comment = true;
}
} else if (line.matches(".+/\\*.*") && line.endsWith("*/")) {
commentLine++;
normalLine++;
comment = false;
} else {
normalLine++;
}
}
private static boolean findPair(String line) { // 查找一行中/*与*/是否成对出现
int count1 = 0;
int count2 = 0;
Pattern p = Pattern.compile("/\\*");
Matcher m = p.matcher(line);
while (m.find()) {
count1++;
}
p = Pattern.compile("\\*/");
m = p.matcher(line);
while (m.find()) {
count2++;
}
return (count1 == count2);
}
}
1:点亮lcd
其实点亮lcd很简单必须保证以后几个步骤正确:
1:确认Lcd信息所在文件被编译进去,并且lcd 和board name里面注册一质,倘若这部正确,那么log里面应该有对应分辨率的一段framebuffer同时调到相对应的power_on函数。对于lcdc panel对应文件在lcdc_xx.c,对于mipi panel对应文件在mipi_xx.c(下序列操作)和mipi_xxxx.c(timing pll clk等初始化操作)。
2:仔细检查上电同时测量,同时enable28跟rgb对应gpio设为lcdc func。对于传统的lcd不需要RST操作只需拉高即可,对于mipi和需要下code的RGB panel需要RST高低高操作,这样code才生效。注意一般sleep out(0x11)和display on(0x29)之间需要mdelay(100)左右,貌似这个对于大部分panel是必须的。
3:如果以上操作正常同时序列正确,那么屏幕应该可以点亮。对于遇到的有以下问题:
a:屏幕呈现白色或者花瓶状态,说明lcd初始化成功,但是没有rgb刷过来。认真检查之后发现pclk时序不对,由于是新的平台所以设对以后,以后的屏就好办了。
b:FPC没有贴好也有可能导致屏幕不亮。
c:
2:深入分析
高通平台屏幕亮起来必须满足一下条件
Lcdc interface:
1:enable mdp core clk(max 200M)
2:enable pixel clk(pclk)(refer to panel spec)
3:enable 0-27gpio as lcdc func and power on
4:downloade code.(not necessary)
Mipi interface:
1:enable mdp core clk(max 200M)
2:enable bit clk(refer to panel spec),shoud set pll reg.
3:enable a series of dsi clk(du to display )
4:downloade code.
待写。
这次项目中实现了用户引导滑动图片,到最后一张图片的时候,我认为理想的是同时具备以下两点:
1)用户可以点击上面的“开始使用”这样的按钮可以进入主界面;
2)用户接着滑动下一个图片的手势而进入主界面;
3)用户在引导界面点击返回键的时候直接进入主界面;
增加“开始使用”按钮方式:
可以定义一个layout的xml再加载:一个LinearLayout,里面一个button。默认button是“gone”,
xml如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/guide_item"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="5" />
<Button
android:id="@+id/start"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/guide_start"
android:visibility="gone" >
</Button>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
button上下增加了textview,我是为了控制button在整个界面的位置。
引导的图片是其背景即可。
实现如下:
guide_activity.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<android.support.v4.view.ViewPager
android:id="@+id/guide_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>GuideActivity.java:
/**
* 引导界面
* @author maria
* 2012-07-19
*/
package com.maria.test;
import java.util.ArrayList;
import java.util.List;
import com.
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.DisplayMetrics;
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
public class GuideActivity extends Activity {
private ViewPager viewPager;
private List<View> mImageViews; // 滑动的图片集合
private int[] imageResId; // 图片ID
private int currentItem = 0; // 当前图片的索引号
private GestureDetector gestureDetector; // 用户滑动
/** 记录当前分页ID */
private int flaggingWidth;// 互动翻页所需滚动的长度是当前屏幕宽度的1/3
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.guide_activity);
gestureDetector = new GestureDetector(new GuideViewTouch());
// 获取分辨率
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
flaggingWidth = dm.widthPixels / 3;
imageResId = new int[] { R.drawable.guide_1, R.drawable.guide_2 };
mImageViews = new ArrayList<View>();
// 初始化图片资源
LayoutInflater viewInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// 0
View convertView0 = viewInflater.inflate(R.layout.guide_item, null);
LinearLayout linearLayout0 = (LinearLayout) convertView0
.findViewById(R.id.guide_item);
linearLayout0.setBackgroundResource(imageResId[0]);
mImageViews.add(linearLayout0);
// 1
View convertView1 = viewInflater.inflate(R.layout.guide_item, null);
LinearLayout linearLayout1 = (LinearLayout) convertView1
.findViewById(R.id.guide_item);
linearLayout1.setBackgroundResource(imageResId[1]);
Button btn = (Button) convertView1.findViewById(R.id.start);
btn.setVisibility(View.VISIBLE);
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
GoToMainActivity();
}
});
mImageViews.add(linearLayout1);
viewPager = (ViewPager) findViewById(R.id.guide_view);
viewPager.setAdapter(new MyAdapter());// 设置填充ViewPager页面的适配器
// 设置一个监听器,当ViewPager中的页面改变时调用
viewPager.setOnPageChangeListener(new MyPageChangeListener());
}
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
if (gestureDetector.onTouchEvent(event)) {
event.setAction(MotionEvent.ACTION_CANCEL);
}
return super.dispatchTouchEvent(event);
}
private class GuideViewTouch extends SimpleOnGestureListener {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
if (currentItem == 1) {
if (Math.abs(e1.getX() - e2.getX()) > Math.abs(e1.getY()
- e2.getY())
&& (e1.getX() - e2.getX() <= (-flaggingWidth) || e1
.getX() - e2.getX() >= flaggingWidth)) {
if (e1.getX() - e2.getX() >= flaggingWidth) {
GoToMainActivity();
return true;
}
}
}
return false;
}
}
/**
* 进入主界面
*/
void GoToMainActivity() {
Intent i = new Intent(GuideActivity.this, MainActivivty.class);
startActivity(i);
finish();
}
/**
* 当ViewPager中页面的状态发生改变时调用
*
* @author Administrator
*
*/
private class MyPageChangeListener implements OnPageChangeListener {
/**
* This method will be invoked when a new page becomes selected.
* position: Position index of the new selected page.
*/
public void onPageSelected(int position) {
currentItem = position;
}
public void onPageScrollStateChanged(int arg0) {
}
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
}
/**
* 填充ViewPager页面的适配器
*
* @author Administrator
*
*/
private class MyAdapter extends PagerAdapter {
@Override
public int getCount() {
return imageResId.length;
}
@Override
public Object instantiateItem(View arg0, int arg1) {
((ViewPager) arg0).addView(mImageViews.get(arg1));
return mImageViews.get(arg1);
}
@Override
public void destroyItem(View arg0, int arg1, Object arg2) {
((ViewPager) arg0).removeView((View) arg2);
}
@Override
public boolean isViewFromObject(View arg0, Object arg1) {
return arg0 == arg1;
}
@Override
public void restoreState(Parcelable arg0, ClassLoader arg1) {
}
@Override
public Parcelable saveState() {
return null;
}
@Override
public void startUpdate(View arg0) {
}
@Override
public void finishUpdate(View arg0) {
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (keyCode == KeyEvent.KEYCODE_BACK) {
GoToMainActivity();
return false;
}
return super.onKeyDown(keyCode, event);
}
}1楼xyz_lmn3天前 15:06顶