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);
  • 相关阅读:
    《译》准备做一些 AR/增强现实的 翻译
    (转)两张Firefox OS 系统截图
    Hello World!
    centos7安装docker
    linux用户及组相关命令
    Go 系列教程 ——第 30 篇:错误处理
    Go 系列教程 ——第 29 篇:Defer
    linux远程管理相关命令
    linux文件目录相关命令
    centos7安装mysql-8.0.15
  • 原文地址:https://www.cnblogs.com/chenghaixiang/p/14914728.html
Copyright © 2011-2022 走看看