package com.cascade;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import com.cascade.DrawableManager.ImageCallback;
public class TestCascadeActivity extends Activity {
private static final String TAG = "TestCascadeActivity";
private LinearLayout llCcasecade;
private LinearLayout lvCasecade1;
private LinearLayout lvCasecade2;
private LinearLayout lvCasecade3;
private Display display;
private AssetManager assetManager;
private List<String> iamgePaths;
private static final String imgspath = "imgs";
private int casecadeWidth;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
display = this.getWindowManager().getDefaultDisplay();
casecadeWidth = display.getWidth()/3;
assetManager = this.getAssets();
findView();
}
private void findView(){
llCcasecade = (LinearLayout)this.findViewById(R.id.llCcasecade);
lvCasecade1 = (LinearLayout)this.findViewById(R.id.casecade1);
lvCasecade2 = (LinearLayout)this.findViewById(R.id.casecade2);
lvCasecade3 = (LinearLayout)this.findViewById(R.id.casecade3);
LayoutParams lp1 = lvCasecade1.getLayoutParams();
lp1.width = casecadeWidth;
lvCasecade1.setLayoutParams(lp1);
LayoutParams lp2 = lvCasecade2.getLayoutParams();
lp2.width = casecadeWidth;
lvCasecade2.setLayoutParams(lp2);
LayoutParams lp3 = lvCasecade3.getLayoutParams();
lp3.width = casecadeWidth;
lvCasecade3.setLayoutParams(lp3);
try {
iamgePaths = Arrays.asList(assetManager.list("imgs"));
} catch (IOException e) {
e.printStackTrace();
}
int j = 0;
for (int i = 0; i < iamgePaths.size(); i++) {
addImgToCasecade(iamgePaths.get(i), j);
j++;
if(j>=3) j = 0;
}
}
private void addImgToCasecade(String filename,int j){
ImageView iv = (ImageView)LayoutInflater.from(this).inflate(R.layout.item, null);
if(j==0){
lvCasecade1.addView(iv);
}else if(j==1){
lvCasecade2.addView(iv);
}else{
lvCasecade3.addView(iv);
}
String imgPath = imgspath+"/"+filename;
iv.setTag(imgPath);
Drawable drawable = DrawableManager.getInstance().fetchDrawableOnThread(imgPath, assetManager, new ImageCallback() {
@Override
public void imageLoaded(Drawable imageDrawable, String imageUrl) {
ImageView iv = (ImageView)llCcasecade.findViewWithTag(imageUrl);
if(iv!=null && imageDrawable!=null){
int oldwidth = imageDrawable.getIntrinsicWidth();
int oldheight = imageDrawable.getIntrinsicHeight();
LayoutParams lp = iv.getLayoutParams();
lp.height = (oldheight * casecadeWidth)/oldwidth;
iv.setPadding(0, 2, 0, 0);
iv.setLayoutParams(lp);
iv.setImageDrawable(imageDrawable);
}
}
});
if(drawable!=null){
int oldwidth = drawable.getIntrinsicWidth();
int oldheight = drawable.getIntrinsicHeight();
LayoutParams lp = iv.getLayoutParams();
lp.height = (oldheight * casecadeWidth)/oldwidth;
iv.setPadding(0, 2, 0, 0);
iv.setLayoutParams(lp);
iv.setImageDrawable(drawable);
}
}
}
Soft_Leader
- 粉丝: 1510
- 资源: 2850
最新资源
- 基于数值积分和摄动方法的建筑装饰金箔使用量计算-Mathematica
- matlab:双或三方演化博弈,lotka-Volterra 1.双方演化博弈:代分析稳定点分析,代绘制相位图,matlab仿真图代码 2.三方演化博弈:代分析稳定点分析,代绘制相位图,matlab仿
- 基于模型预测控制(mpc)的车辆道,车辆轨迹跟踪,道轨迹为五次多项式,matlab与carsim联防控制
- SQL Server数据库实验:表的插入、修改和删除操作实践
- 2011-2020年各省城镇单位就业人员数据.xlsx
- Java windows GUI 案例 简单的飞机售票系统 课程设计
- 基于模型预测控制的楼宇负荷需求响应研究 参考文档:《Model Predictive Control of Thermal Storage for Demand Response》完全复现 主要内容:
- eclipse-sts-2021-03-R-win32-x86-64.rar
- Python的Mongodb操作代码
- 光伏电池PV建模,基于Boost Buck电路实现最大功率追踪MPPT,包括扰动观察法,电导增量法,改进型电导增量法,滑模变结构法等控制算法,模型仿真效果较好,适合借鉴学习 图片为模型图,功率波形
- 交直流混合微网程序matlab 采用拉丁超立方抽样和多场景缩减,考虑风光等随机性建模,利用粒子群算法,计算得到三个微网的优化程序,程序运行稳定,有详细资料 这段代码是一个多目标优化算法的实现,主要用
- 云链客服需要注意的事项
- Microsoft Edge111
- 云链客服需要注意的事项
- 三相桥式两电平逆变器的SVPWM调制和三相T型三电平逆变器的SVPWM模型和说明文档 对比着看绝对有助于你理解SVPWM调制方法 支持MATLAB2017b以上的版本
- mongodb-windows-x86-64-7.0.15-signed.msi
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈