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);
  • 相关阅读:
    iOS 10 的杂碎资料
    MAC SVN Merge 操作
    iOS中AFNetworking2.0和AFNetworking3.0 的HTTPS的配置
    从字符串中获取指定字符内的内容
    判断是否是是全汉字、全字母、全数字、数字和字母等
    解析URL 获取某一个参数值
    长按TextField或TextView显示中文的粘贴复制
    TextField和TextView的限制输入长度
    抢购、距活动结束,剩余时间倒计时。
    Cell右滑 多个编辑选项栏
  • 原文地址:https://www.cnblogs.com/chenghaixiang/p/14914728.html
Copyright © 2011-2022 走看看