超好学习网站:http://dreamrunner.org/wiki/public_html/index.html

算法与数据结构专业指南
本文提供了一系列关于算法设计与分析、数据结构、编程语言、操作系统、云计算等领域的专业资源和书籍推荐,帮助读者深入理解计算机科学的核心概念并提升技能。

index

Date: 2013-04-14T23:16+0800

Author: Shi Shougang

Org version 7.9.3f with Emacs version 24

Validate XHTML 1.0
interface MenuClass { icon: string; title: string; } interface ProductClass { icon: string; title: string; } interface HomeNewClass { image: string; name: string; price: number; } interface goodsClass { originPrice: number; retailPrice: number; name: string; goodsBrief: string; icon: string; tag: string; } interface UserStory { image: string; content: string; } interface Particle { x: number; y: number; size: number; opacity: number; speedX: number; speedY: number; } @Entry @Component export struct Home { @State swiperList: ResourceStr[] = [$r('app.media.banner2'), $r('app.media.banner1')]; @State menuList: MenuClass[] = [ { icon: 'menu1', title: '今日爆款' }, { icon: 'menu2', title: '好物分享' }, { icon: 'menu3', title: '推荐购买' }, { icon: 'menu4', title: '购物心得' }, { icon: 'menu5', title: '直播专区' }, { icon: 'menu6', title: '签到中心' }, { icon: 'menu7', title: '值得购买' }, { icon: 'menu8', title: '每日优惠' }, { icon: 'menu9', title: '充值中心' }, { icon: 'menu10', title: '我的客服' } ]; @State productList: ProductClass[] = [ { icon: 'product1', title: '直播' }, { icon: 'product2', title: '推荐' }, { icon: 'product3', title: '补贴' }, { icon: 'product4', title: '推荐' }, ]; @State homeNewList: HomeNewClass[] = [ { image: 'product11', name: '行李牌', price: 12.80 }, { image: 'product12', name: '后陡门58号毛毯', price: 68.80 }, { image: 'product13', name: '限定帆布包', price: 77.00 }, { image: 'product14', name: '红包桶背背', price: 29.80 }, ]; @State GoodsList: goodsClass[] = [ { originPrice:1188888.00, retailPrice: 12.80, name: '行李牌', goodsBrief: '[十个勤天] 少年同款官方正品售出 2.0夜光版', icon: 'top1', tag: 'TOP1' }, { retailPrice: 28.8, originPrice: 1188888.00, name: '蛇来运转日历', goodsBrief: '[十个勤天]有了日历,再也不怕记不住,爸妈放心', icon: 'top2', tag: 'TOP2' }, { retailPrice: 49.8, originPrice: 1188888.00, name: '后陡门牌手账', goodsBrief: '轻松看书、社交、办公、舒适放松', icon: 'top3', tag: 'TOP3' }, { retailPrice: 39.80, originPrice: 1188888.00, name: '发财小手', goodsBrief: '[十个勤天]麻辣猪蹄 酱香猪蹄 熟肉制品', icon: 'top4', tag: 'TOP4' }, { retailPrice: 12.8, originPrice: 1188888.00, name: '烧椒酱', goodsBrief: '[十个勤天]泡面的好搭档 三子同款', icon: 'top5', tag: 'TOP5' } ]; // 新增状态 @State isRefreshing: boolean = false; @State isLoadingMore: boolean = false; @State pageNum: number = 1; @State hasMoreData: boolean = true; // 动态背景粒子 @State particles: Particle[] = []; @State particleCount: number = 20; // 节日/节气装饰 @State festivalDecoration: ResourceStr | null = null; // 数据可视化 @State userCount: number = 128000; @State satisfactionRate: number = 96; @State productCount: number = 5800; // 用户故事 @State userStories: UserStory[] = [ { image: 'user1', content: '带着行李牌去旅行,轻便又实用,朋友都问我要链接!' }, { image: 'user2', content: '毛毯质量好,冬天盖着特别暖和,推荐给大家!' }, { image: 'user3', content: '烧椒酱拌面太好吃了,已经回购三次,下饭神器!' } ]; // 品牌标语 @State slogans: string[] = [ "让好物温暖每个日常", "用心选择,品质生活", "小物件,大幸福" ]; @State currentSloganIndex: number = 0; aboutToAppear() { this.initParticles(); this.startSloganAnimation(); } // 初始化动态背景粒子 initParticles() { for (let i = 0; i < this.particleCount; i++) { this.particles.push({ x: Math.random() * 100, y: Math.random() * 100, size: Math.random() * 3 + 1, opacity: Math.random() * 0.5 + 0.3, speedX: (Math.random() - 0.5) * 0.5, speedY: Math.random() * 0.5 + 0.1 }); } // 粒子动画 setInterval(() => { for (let i = 0; i < this.particleCount; i++) { const particle = this.particles[i]; particle.x += particle.speedX; particle.y += particle.speedY; if (particle.x > 100) particle.x = 0; if (particle.x < 0) particle.x = 100; if (particle.y > 100) particle.y = 0; // 浅拷贝更新状态 this.particles = [...this.particles]; } }, 30); } // 品牌标语动画 startSloganAnimation() { setInterval(() => { this.currentSloganIndex = (this.currentSloganIndex + 1) % this.slogans.length; }, 3000); } @Builder productBuilder(item: ProductClass) { Stack({ alignContent: Alignment.TopStart }) { Image($r(`app.media.${item.icon}`)).width('49%') Text(item.title) .fontColor('#fff') .backgroundColor(Color.Red) .fontWeight(600) .padding({ left: 5, top: 8, right: 5, bottom: 8 }) .borderRadius(5) .margin(5) } .margin({ bottom: 5 }) } @Builder sloganAnimation() { Stack() { Text(this.slogans[this.currentSloganIndex]) .fontSize(22) .fontWeight(FontWeight.Bold) .fontColor('#333') .backgroundColor('#f9f9f9') .width('100%') .height(60) .textAlign(TextAlign.Center) .borderRadius(10) .opacity(1) // .animation({ // type: AnimationType.Opacity, // duration: 1000, // curve: Curve.Linear // }) } .width('100%') .height(60) } @Builder dynamicBackground() { Stack() { ForEach(this.particles, (particle: Particle, index: number) => { Circle() .fill('#f60') .width(particle.size) .height(particle.size) .opacity(particle.opacity) .position({ x: particle.x, y: particle.y }) }) } .width('100%') .height('100%') .position({ x: 0, y: 0 }) .zIndex(-1) .opacity(0.3) } build() { Stack() { // 动态背景 this.dynamicBackground() // 主内容 Scroll() { Column({ space: 10 }) { // 搜索框 Search({ placeholder: '请输入关键词' }) .backgroundColor('#f5f5f5') .margin({ top: 10, bottom: 5 }) // 节日装饰 if (this.festivalDecoration) { Image(this.festivalDecoration) .width('100%') .height(50) .objectFit(ImageFit.Contain) .margin({ bottom: 5 }) } // 轮播图 Swiper() { ForEach(this.swiperList, (item: ResourceStr) => { Image(item) }) } .width('100%') .height(120) .autoPlay(true) .interval(2000) // 功能按钮区 Grid() { ForEach(this.menuList, (item: MenuClass) => { GridItem() { Column({ space: 8 }) { Image($r(`app.media.${item.icon}`)).width(45) Text(item.title).fontSize(14) } } .border({ width: 1, color: '#eee' }) }) } .width('100%') .height(180) .columnsTemplate('1fr 1fr 1fr 1fr 1fr') .columnsGap(5) .rowsGap(5) // 产品展示区 Flex({ wrap: FlexWrap.Wrap, justifyContent: FlexAlign.SpaceBetween }) { ForEach(this.productList, (item: ProductClass) => { this.productBuilder(item) }) } .width('100%') // 每周上新 Divider().border({ width: 3, color: '#999' }).width('40%').borderRadius(10) Text('每周上新').fontSize(30).fontWeight(700).margin({ top: 10, bottom: 10 }) Flex({ wrap: FlexWrap.Wrap, justifyContent: FlexAlign.SpaceBetween }) { ForEach(this.homeNewList, (item: HomeNewClass) => { Column({ space: 8 }) { Image($r(`app.media.${item.image}`)).width('49%') Text(item.name) Text() { Span('¥').fontColor('#f60') Span(item.price.toString()) } } }) } // 人气推荐 Text('人气推荐').fontSize(30).fontWeight(700).margin({ top: 10, bottom: 10 }) List({ space: 10 }) { ForEach(this.GoodsList, (item: goodsClass) => { ListItem() { Row() { Stack({ alignContent: Alignment.TopStart }) { Image($r(`app.media.${item.icon}`)).width(100).borderRadius(8) Text(item.tag) .fontColor('#ffffffff') .backgroundColor('#f60') .padding({ left: 5, right: 5 }) .borderRadius({ topRight: 8, bottomRight: 8 }) .margin({ top: 10 }) } Column({ space: 10 }) { Text(item.name).fontWeight(FontWeight.Bold).fontSize(18) Text(item.goodsBrief).fontColor('#999') Text() { Span('¥').fontColor('#f60') Span(item.retailPrice.toString()).fontWeight(FontWeight.Bold).fontSize(18) Span('¥'+item.originPrice.toString()).fontColor('#999').fontSize(14) .decoration({ type: TextDecorationType.LineThrough, color: '#ff323232' }) } } .layoutWeight(1) .alignItems(HorizontalAlign.Start) } } }) if (this.isLoadingMore) { ListItem() { Row() { LoadingProgress() Text('加载中...').fontSize(14).margin({ left: 10 }) } .justifyContent(FlexAlign.Center) .height(50) } } else if (!this.hasMoreData) { ListItem() { Text('没有更多数据了').fontSize(14).fontColor('#999') .width('100%') .textAlign(TextAlign.Center) .height(50) } } } .onReachEnd(() => { if (!this.isLoadingMore && this.hasMoreData) { this.isLoadingMore = true; setTimeout(() => { this.isLoadingMore = false; this.hasMoreData = false; }, 1500); } }) // 品牌标语 this.sloganAnimation() } .width('100%') .padding({ left: 10, right: 10 }) } .scrollBar(BarState.Off) .width('100%') .height('100%') } .width('100%') .height('100%') } } // interface MenuClass { // icon: string; // title: string; // } // // interface ProductClass { // icon: string; // title: string; // } // interface HomeNewClass { // image: string; // name: string; // price: number; // } // interface goodsClass{ // originPrice:number // retailPrice:number // name:string // goodsBrief:string // icon:string // tag:string // } // @Entry // @Component // export struct Home { // swiperList: ResourceStr[] = [$r('app.media.banner2'), $r('app.media.banner1')]; // menuList: MenuClass[] = [ // { icon: 'menu1', title: '今日爆款' }, // { icon: 'menu2', title: '好物分享' }, // { icon: 'menu3', title: '推荐购买' }, // { icon: 'menu4', title: '购物心得' }, // { icon: 'menu5', title: '直播专区' }, // { icon: 'menu6', title: '签到中心' }, // { icon: 'menu7', title: '值得购买' }, // { icon: 'menu8', title: '每日优惠' }, // { icon: 'menu9', title: '充值中心' }, // { icon: 'menu10', title: '我的客服' } // ]; // productList: ProductClass[] = [ // { icon: 'product1', title: '直播' }, // { icon: 'product2', title: '推荐' }, // { icon: 'product3', title: '补贴' }, // { icon: 'product4', title: '推荐' }, // ]; // homeNewList: HomeNewClass[] = [ // { // image: 'product11', // name: '行李牌', //卡套挂件 2.0夜光版 // price: 12.80 // }, // { // image: 'product12', // name: '后陡门58号毛毯', //春季版 // price: 68.80 // }, // { // image: 'product13', // name: '限定帆布包', // price: 77.00 // }, // { // image: 'product14', // name: '红包桶背背', // price: 29.80 // }, // // ]; // GoodsList:goodsClass[] = [ // { // originPrice:1188888.00, // retailPrice: 12.80, // name: '行李牌', // goodsBrief: '[十个勤天] 少年同款官方正品售出 2.0夜光版', // icon: 'top1', // tag: 'TOP1' // }, // { // retailPrice: 28.8, // originPrice: 1188888.00, // name: '蛇来运转日历', // goodsBrief: '[十个勤天]有了日历,再也不怕记不住,爸妈放心', // icon: 'top2', // tag: 'TOP2' // }, // { // retailPrice: 49.8, // originPrice: 1188888.00, // name: '后陡门牌手账', // goodsBrief: '轻松看书、社交、办公、舒适放松', // icon: 'top3', // tag: 'TOP3' // }, // { // retailPrice: 39.80, // originPrice: 1188888.00, // name: '发财小手', // goodsBrief: '[十个勤天]麻辣猪蹄 酱香猪蹄 熟肉制品', // icon: 'top4', // tag: 'TOP4' // }, // { // retailPrice: 12.8, // originPrice: 1188888.00, // name: '烧椒酱', // goodsBrief: '[十个勤天]泡面的好搭档 三子同款', // icon: 'top5', // tag: 'TOP5' // } // ] // // @Builder // productBuilder(item: ProductClass) { // Stack({ // alignContent: Alignment.TopStart // }) { // Image($r(`app.media.${item.icon}`)).width('49%') // Text(item.title) // .fontColor('#fff') // .backgroundColor(Color.Red) // .fontWeight(600) // .padding({ // left: 5, // top: 8, // right: 5, // bottom: 8 // }) // .borderRadius(5) // .margin(5) // } // // 下外边距 // .margin({ bottom: 5 }) // } // // build() { // // Text('此处是首页页面').fontSize(30) // Scroll() { // // 只能包含一个子组件 // Column({ space: 10 }) { // // -----------------1--搜索框--------------------- // Search({ placeholder: '请输入关键词' }) // // ----------------2--轮播图---------------------- // Swiper() { // ForEach(this.swiperList, (item: ResourceStr) => { // Image(item) // }) // } // // 设置轮播图尺寸,实现内容自动拉伸 // .width('100%') // .height(120) // // 开启自动播放 // .autoPlay(true) // // 播放间隔 // .interval(2000) // // //-------------3--功能按钮区------------------------ // Grid() { // ForEach(this.menuList, (item: MenuClass) => { // GridItem() { // // 能否优化?使用@Builder // Column({ space: 8 }) { // // 上图 // Image($r(`app.media.${item.icon}`)).width(50) // //下文 // Text(item.title) // } // } // .border({ width: 1, color: '#eee' }) // }) // } // .width('100%') // .height(180) // // .backgroundColor('#ccc') // .columnsTemplate('1fr 1fr 1fr 1fr 1fr') // // .rowsTemplate('1fr 1fr') // .columnsGap(5) // .rowsGap(5) // // // //--------4-产品展示区---------------------- // Flex({ // wrap: FlexWrap.Wrap, //换行 // justifyContent: FlexAlign.SpaceBetween // // }) { // // 子组件 // // // 层叠布局 // ForEach(this.productList, (item: ProductClass) => { // /* Stack({ // alignContent:Alignment.TopStart // }){ // Image($r(`app.media.${item.icon}`)).width('49%') // Text(item.title) // .fontColor('#fff') // .backgroundColor(Color.Red) // .fontWeight(600) // .padding({left:5,top:8,right:5,bottom:8}) // .borderRadius(5) // .margin(5) // } // // 下外边距 // .margin({bottom:5})*/ // this.productBuilder(item) // }) // // /* Stack(){ // Image($r('app.media.product2')).width('49%') // } // Stack(){ // Image($r('app.media.product3')).width('49%') // } // Stack(){ // Image($r('app.media.product4')).width('49%') // }*/ // } // .width('100%') // // // // // ------------------5--每周上新------------------------------------ // // 分割线 // Divider().border({ width: 3, color: '#999' }).width('40%').borderRadius(10) // Text('每周上新').fontSize(30).fontWeight(700).margin({ top: 10, bottom: 10 }) // Flex({ // wrap: FlexWrap.Wrap, //换行 // justifyContent: FlexAlign.SpaceBetween // // }) { // ForEach(this.homeNewList, (item: HomeNewClass) => { // Column({ space: 8 }) { // Image($r(`app.media.${item.image}`)).width('49%') // Text(item.name) // Text() { // Span('¥').fontColor('#f60') // Span(item.price.toString()) // } // } // }) // // } // // interface goodsClass{ // // originPrice:number // // retailPrice:number // // name:string // // goodsBrief:string // // icon:string // // tag:string // // } // // ------------------6--人气推荐------------------------------------ // Text('人气推荐').fontSize(30).fontWeight(700).margin({ top: 10, bottom: 10 }) // List({space:10}){ // ForEach(this.GoodsList, (item: goodsClass) => { // ListItem(){ // // Row(){ // Stack({alignContent:Alignment.TopStart}){ // Image($r(`app.media.${item.icon}`)).width(100).borderRadius(8) // Text(item.tag) // .fontColor('#ffffffff') // .backgroundColor('#f60') // .padding({left:5,right:5}) // .borderRadius({topRight:8,bottomRight:8}) // .margin({top:10}) // } // Column({space:10}){ // Text(item.name).fontWeight(FontWeight.Bold).fontSize(18) // Text(item.goodsBrief).fontColor('#999') // Text(){ // Span('¥').fontColor('#f60') // Span(item.retailPrice.toString()).fontWeight(FontWeight.Bold).fontSize(18) // // Span('¥').fontColor('#999').fontSize(12).decoration({type:TextDecorationType.LineThrough,color:'#000'}) // Span('¥'+item.originPrice.toString()).fontColor('#999').fontSize(14) // .decoration({type:TextDecorationType.LineThrough,color:'#ff323232'}) // } // } // .layoutWeight(1) // .alignItems(HorizontalAlign.Start) // } // } // // }) // // Row(){ // // //左侧图片 // // Stack({alignContent:Alignment.TopStart}){ // // Image($r('app.media.product11')).width(100).borderRadius(8) // // Text('Top1') // // .fontColor('#ffffffff') // // .backgroundColor('#f60') // // .padding({left:5,right:5}) // // .borderRadius({topRight:8,bottomRight:8}) // // .margin({top:10}) // // } // // //右侧文本 // // Column({space:10}){ // // Text('111').fontWeight(FontWeight.Bold).fontSize(18) // // Text('141').fontColor('#999') // // Text(){ // // Span('¥299').fontWeight(FontWeight.Bold) // // Span('¥399').fontColor('#999').fontSize(12) // // } // // } // // .layoutWeight(1) // // .alignItems(HorizontalAlign.Start) // // } // } // // .width('100%') // // .height(100) // // .backgroundColor('#999') // // } // } // // .scrollBar(BarState.Off) // .width('100%') // .height('100%') // // // .height('100%') // // Column 一般不设置高度,目的是由内容自适应撑开 // // } // // 去除滚动条 // // // // .backgroundColor('#8cd3ec') // // // }以上是首页,我想给每个商品制作商品详情页,我做的是鸿蒙
06-24
内容概要:本文以一款电商类Android应用为案例,系统讲解了在Android Studio环境下进行性能优化的全过程。文章首先分析了常见的性能问题,如卡顿、内存泄漏和启动缓慢,并深入探讨其成因;随后介绍了Android Studio提供的三大性能分析工具——CPU Profiler、Memory Profiler和Network Profiler的使用方法;接着通过实际项目,详细展示了从代码、布局、内存到图片四个维度的具体优化措施,包括异步处理网络请求、算法优化、使用ConstraintLayout减少布局层级、修复内存泄漏、图片压缩与缓存等;最后通过启动时间、帧率和内存占用的数据对比,验证了优化效果显著,应用启动时间缩短60%,帧率提升至接近60fps,内存占用明显下降并趋于稳定。; 适合人群:具备一定Android开发经验,熟悉基本组件和Java/Kotlin语言,工作1-3年的移动端研发人员。; 使用场景及目标:①学习如何使用Android Studio内置性能工具定位卡顿、内存泄漏和启动慢等问题;②掌握从代码、布局、内存、图片等方面进行综合性能优化的实战方法;③提升应用用户体验,增强应用稳定性与竞争力。; 阅读建议:此资源以真实项目为背景,强调理论与实践结合,建议读者边阅读边动手复现文中提到的工具使用和优化代码,并结合自身项目进行性能检测与调优,深入理解每项优化背后的原理。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值