WEB开发网
开发学院手机开发Android 开发 Android 用代理模式处理海量高频数据更新 阅读

Android 用代理模式处理海量高频数据更新

 2010-12-18 08:04:10 来源:WEB开发网   
核心提示:return; //no need to update for the view}if(color<=0) {current.setBackgroundDrawable(null);current.setText(((CommonDefn.DoThingsReturn)handlerId).cmd.toStrin

return; //no need to update for the view

}

if(color<=0) {

current.setBackgroundDrawable(null);

current.setText(((CommonDefn.DoThingsReturn)handlerId).cmd.toString());

}

else {

current.setBackgroundColor( color);

}

current.postInvalidate();

}

}

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

final TextView tv = (TextView)findViewById(R.id.txtview);

new Thread() {

java.util.Random rand = new java.util.Random();

long lastUpdate = System.currentTimeMillis();

public void run() {

while(!Thread.interrupted() || !TestActivity.this.isFinishing()) {

//模拟高频更新数据

if( System.currentTimeMillis() - lastUpdate < 2000l) { //设置两次动画的最少间隔时间

continue;

}

else

lastUpdate = System.currentTimeMillis();

CommonDefn.DoThingsReturn updateWrapper = new CommonDefn.DoThingsReturn(String.valueOf(rand.nextInt()) , tv,0);

ColorRefreshTask refresh = new ColorRefreshTask(TestActivity.this,CommonDefn.HIGHLIGHT_BACKGROUND_COLOR_INDEX, updateWrapper);

_messageHandler.postDelayed(refresh, 200); //ready to for the current updating

}

}

}.start();

}

}

这也也打包了,需要的可以看一下。


  点击下载:php?id=1364" rel="nofollow">源码下载

上一页  1 2 3 4 5 6 

Tags:Android 代理 模式

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接