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);
  • 相关阅读:
    并发编程-process对象的其他属性方法
    Python json格式处理
    msf制作反弹shell
    Windows渗透备忘录
    WPF listbox实现多列显示数据
    Postgresql插入或更新操作upsert
    Windows 10 IoT Core Samples
    物联网平台开源
    实现领域驱动设计
    wpf Visibility 动画
  • 原文地址:https://www.cnblogs.com/chenghaixiang/p/14914728.html
Copyright © 2011-2022 走看看