团队冲刺2.7
1.评论区继续了解
部分代码:
title = getIntent().getStringExtra("title");
author_name = getIntent().getStringExtra("author_name");
date = getIntent().getStringExtra("date");
pic_url = getIntent().getStringExtra("pic_url");
content_url = getIntent().getStringExtra("content_url");
num = getIntent().getIntExtra("num",1);
//初始化布局
Toolbar toolbar = (Toolbar) findViewById(R.id.browse_toolbar);
setSupportActionBar(toolbar);
browseDL = (DrawerLayout) findViewById(R.id.browse_drawer);
ActionBar actionBar = getSupportActionBar();
if (actionBar!=null){
actionBar.setDisplayHomeAsUpEnabled(true);
}
webView = (WebView)findViewById(R.id.webView);
FAB = (FloatingActionButton) findViewById(R.id.float_collection);
if (num%2==0){
ColorStateList colorStateList = ContextCompat.getColorStateList(getApplicationContext(),R.color.colorPrimary);
FAB.setBackgroundTintList(colorStateList);
}
//收藏
news = DataSupport.findAll(Colltects.class);
FAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (num%2==1){
ColorStateList colorStateList = ContextCompat.getColorStateList(getApplicationContext(),R.color.colorPrimary);
FAB.setBackgroundTintList(colorStateList);
num++;
for (Colltects conew:news){
if (title.equals(conew.getTitle())&&author_name.equals(conew.getAuthor_name())){
flag = false;
Toast.makeText(BrowseNewsActivity.this, "已收藏", Toast.LENGTH_SHORT).show();
}
}
if (flag){
Colltects coll = new Colltects(title,author_name,date,content_url);
coll.save();
Toast.makeText(BrowseNewsActivity.this, "已收藏", Toast.LENGTH_SHORT).show();
}
}else {
ColorStateList colorStateList = ContextCompat.getColorStateList(getApplicationContext(),R.color.colorAccent);
FAB.setBackgroundTintList(colorStateList);
num++;
DataSupport.deleteAll(Colltects.class,"title = ? and author_name = ?",title,author_name);
Toast.makeText(BrowseNewsActivity.this, "取消收藏", Toast.LENGTH_SHORT).show();
}
}
});
webView.loadUrl(content_url);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App