zoukankan      html  css  js  c++  java
  • 团队冲刺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);
  • 相关阅读:
    ubuntu下minicom和usb串口转接
    linux下 驱动模块编译步骤
    linux下的压缩解压命令
    GitLab 数据备份和恢复
    GitLab 项目创建后地址由Localhost改为实际IP的方法
    GitLab-Runner 安装配置
    GitLab 的安装及汉化
    用yum rpm 快速安装zabbix agent
    RabbitMQ的用户管理方法
    Linux下安装部署RabbitMQ
  • 原文地址:https://www.cnblogs.com/chenghaixiang/p/14914728.html
Copyright © 2011-2022 走看看