// Path: MyZhiHuDaily/app/src/main/java/com/example/chentian/myzhihudaily/activity/DownloadDetaiContentActivity.java
// public class DownloadDetaiContentActivity extends BaseActivity {
//     String body,title;
//     WebView contentView;
//     ImageView topImage;
//     TextView topTitle,topSource;
// 
//     @Override
//     protected void onCreate(@Nullable Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
//         initTheme();
//         setContentView(R.layout.detail_layout);
//         //将状态栏透明
//         if(Build.VERSION.SDK_INT>=21){
//             View decorView = getWindow().getDecorView();
//             int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|
//                     View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
//             decorView.setSystemUiVisibility(option);
//             getWindow().setStatusBarColor(Color.TRANSPARENT);
//         }
// 
//         init();
//         fillContent();
//     }
// 
//     private void initTheme() {
//         setTheme(R.style.NightTheme);
//     }
// 
//     private void init(){
//         LinearLayout layout = (LinearLayout) findViewById(R.id.Download_layout);
//         layout.setVisibility(View.GONE);
// 
//         Intent intent = getIntent();
//         body = intent.getStringExtra("body");
//         title = intent.getStringExtra("title");
//         contentView = (WebView) findViewById(R.id.content_webview);
//         contentView.setHorizontalScrollBarEnabled(false);//水平不显示
//         contentView.setVerticalScrollBarEnabled(false); //垂直不显示
// 
//         contentView.setOnTouchListener(new View.OnTouchListener() {
//             @Override
//             public boolean onTouch(View v, MotionEvent event) {
//                 return (event.getAction() == MotionEvent.ACTION_MOVE);
//             }
//         });
//         contentView.setWebViewClient(new WebViewClient());
// 
//         topImage = (ImageView) findViewById(R.id.top_image);
//         topTitle = (TextView) findViewById(R.id.top_titlt);
//         topSource = (TextView) findViewById(R.id.top_source);
//     }
// 
//     //进行网络请求，请求首页的详细内容
//     private void fillContent() {
//         topTitle.setText(title);
//         topSource.setText("图片:"+"懒得获取~");
//         topImage.setImageResource(R.mipmap.default_img);
// 
//         String css;
//         if(!isDay){
//             css = "<link type=\"text/css\" href=\"" +
//                     "file:///android_asset/zhihu_dark.css" +
//                     "\" " +
//                     "rel=\"stylesheet\" />\n";
//         }else {
//             css = "<link type=\"text/css\" href=\"" +
//                     "file:///android_asset/zhihu.css" +
//                     "\" " +
//                     "rel=\"stylesheet\" />\n";
//         }
//         String html = "<!DOCTYPE html>\n" +
//                 "<html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\">\n" +
//                 "<head>\n" +
//                 "\t<meta charset=\"utf-8\" />\n</head>\n" +
//                 "<body>\n" + css +
//                 body.replace("<div class=\"img-place-holder\">", "") + "\n<body>";
//         contentView.loadDataWithBaseURL("x-data://base", html, "text/html", "utf-8", null);
//     }
// }
// 
// Path: MyZhiHuDaily/app/src/main/java/com/example/chentian/myzhihudaily/database/Artical.java
// public class Artical extends DataSupport {
// 
//     private String articalBody;
// 
//     @Column(unique = true)
//     private String articalTitle;
// 
//     public String getArticalBody() {
//         return articalBody;
//     }
// 
//     public void setArticalBody(String articalBody) {
//         this.articalBody = articalBody;
//     }
// 
//     public String getArticalTitle() {
//         return articalTitle;
//     }
// 
//     public void setArticalTitle(String articalTitle) {
//         this.articalTitle = articalTitle;
//     }
// }


import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.example.chentian.myzhihudaily.R;
import com.example.chentian.myzhihudaily.activity.DownloadDetaiContentActivity;
import com.example.chentian.myzhihudaily.database.Artical;
import org.litepal.crud.DataSupport;
import java.util.ArrayList;
        ContentRecyclerViewHolder viewHolder = (ContentRecyclerViewHolder) holder;
        viewHolder.textView.setText(titleData.get(position));
        Glide.with(context).load(R.mipmap.default_img).into(viewHolder.imageView);
        viewHolder.bodyText.setText(bodyData.get(position));
    }

    @Override
    public int getItemCount() {
        return titleData.size();
    }

    class ContentRecyclerViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

        TextView textView,bodyText;
        ImageView imageView;
        LinearLayout itemLayout;

        public ContentRecyclerViewHolder(View itemView) {
            super(itemView);
            textView = (TextView) itemView.findViewById(R.id.recycler_title);
            bodyText = (TextView) itemView.findViewById(R.id.tv_content_id);
            imageView = (ImageView) itemView.findViewById(R.id.recycler_img);
            itemLayout = (LinearLayout) itemView.findViewById(R.id.recycler_item);

            itemLayout.setOnClickListener(this);
            itemLayout.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    titleData.remove(textView.getText().toString());
                    notifyDataSetChanged();
// Path: MyZhiHuDaily/app/src/main/java/com/example/chentian/myzhihudaily/activity/DownloadDetaiContentActivity.java
// public class DownloadDetaiContentActivity extends BaseActivity {
//     String body,title;
//     WebView contentView;
//     ImageView topImage;
//     TextView topTitle,topSource;
// 
//     @Override
//     protected void onCreate(@Nullable Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
//         initTheme();
//         setContentView(R.layout.detail_layout);
//         //将状态栏透明
//         if(Build.VERSION.SDK_INT>=21){
//             View decorView = getWindow().getDecorView();
//             int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|
//                     View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
//             decorView.setSystemUiVisibility(option);
//             getWindow().setStatusBarColor(Color.TRANSPARENT);
//         }
// 
//         init();
//         fillContent();
//     }
// 
//     private void initTheme() {
//         setTheme(R.style.NightTheme);
//     }
// 
//     private void init(){
//         LinearLayout layout = (LinearLayout) findViewById(R.id.Download_layout);
//         layout.setVisibility(View.GONE);
// 
//         Intent intent = getIntent();
//         body = intent.getStringExtra("body");
//         title = intent.getStringExtra("title");
//         contentView = (WebView) findViewById(R.id.content_webview);
//         contentView.setHorizontalScrollBarEnabled(false);//水平不显示
//         contentView.setVerticalScrollBarEnabled(false); //垂直不显示
// 
//         contentView.setOnTouchListener(new View.OnTouchListener() {
//             @Override
//             public boolean onTouch(View v, MotionEvent event) {
//                 return (event.getAction() == MotionEvent.ACTION_MOVE);
//             }
//         });
//         contentView.setWebViewClient(new WebViewClient());
// 
//         topImage = (ImageView) findViewById(R.id.top_image);
//         topTitle = (TextView) findViewById(R.id.top_titlt);
//         topSource = (TextView) findViewById(R.id.top_source);
//     }
// 
//     //进行网络请求，请求首页的详细内容
//     private void fillContent() {
//         topTitle.setText(title);
//         topSource.setText("图片:"+"懒得获取~");
//         topImage.setImageResource(R.mipmap.default_img);
// 
//         String css;
//         if(!isDay){
//             css = "<link type=\"text/css\" href=\"" +
//                     "file:///android_asset/zhihu_dark.css" +
//                     "\" " +
//                     "rel=\"stylesheet\" />\n";
//         }else {
//             css = "<link type=\"text/css\" href=\"" +
//                     "file:///android_asset/zhihu.css" +
//                     "\" " +
//                     "rel=\"stylesheet\" />\n";
//         }
//         String html = "<!DOCTYPE html>\n" +
//                 "<html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\">\n" +
//                 "<head>\n" +
//                 "\t<meta charset=\"utf-8\" />\n</head>\n" +
//                 "<body>\n" + css +
//                 body.replace("<div class=\"img-place-holder\">", "") + "\n<body>";
//         contentView.loadDataWithBaseURL("x-data://base", html, "text/html", "utf-8", null);
//     }
// }
// 
// Path: MyZhiHuDaily/app/src/main/java/com/example/chentian/myzhihudaily/database/Artical.java
// public class Artical extends DataSupport {
// 
//     private String articalBody;
// 
//     @Column(unique = true)
//     private String articalTitle;
// 
//     public String getArticalBody() {
//         return articalBody;
//     }
// 
//     public void setArticalBody(String articalBody) {
//         this.articalBody = articalBody;
//     }
// 
//     public String getArticalTitle() {
//         return articalTitle;
//     }
// 
//     public void setArticalTitle(String articalTitle) {
//         this.articalTitle = articalTitle;
//     }
// }


// Path: MyZhiHuDaily/app/src/main/java/com/example/chentian/myzhihudaily/adapter/DownloadAdapter.java
import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.example.chentian.myzhihudaily.R;
import com.example.chentian.myzhihudaily.activity.DownloadDetaiContentActivity;
import com.example.chentian.myzhihudaily.database.Artical;
import org.litepal.crud.DataSupport;
import java.util.ArrayList;

        ContentRecyclerViewHolder viewHolder = (ContentRecyclerViewHolder) holder;
        viewHolder.textView.setText(titleData.get(position));
        Glide.with(context).load(R.mipmap.default_img).into(viewHolder.imageView);
        viewHolder.bodyText.setText(bodyData.get(position));
    }

    @Override
    public int getItemCount() {
        return titleData.size();
    }

    class ContentRecyclerViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

        TextView textView,bodyText;
        ImageView imageView;
        LinearLayout itemLayout;

        public ContentRecyclerViewHolder(View itemView) {
            super(itemView);
            textView = (TextView) itemView.findViewById(R.id.recycler_title);
            bodyText = (TextView) itemView.findViewById(R.id.tv_content_id);
            imageView = (ImageView) itemView.findViewById(R.id.recycler_img);
            itemLayout = (LinearLayout) itemView.findViewById(R.id.recycler_item);

            itemLayout.setOnClickListener(this);
            itemLayout.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    titleData.remove(textView.getText().toString());
                    notifyDataSetChanged();
                    DataSupport.deleteAll(Artical.class, "articalTitle = ?" , textView.getText().toString());