RecyclerViewCursorAdapter & Loader機(jī)制

關(guān)于RecyclerViewCursorAdapter

RecyclerView是谷歌推薦使用的也是現(xiàn)在比較常用的控件薄湿,用來代替ListView您炉。CursorAdapter經(jīng)常會(huì)配合數(shù)據(jù)庫(kù)使用朦佩,然而在RecyclerView中使用CursorAdapter時(shí)會(huì)出錯(cuò)剑梳!查了一下,CursorAdapter只和ListView適配起趾,RecyclerView并不兼容唉锌,看來需要一個(gè)改造過的CursorAdapter隅肥。還好,Github上有大神實(shí)現(xiàn)了RecyclerViewCursorAdapter:傳送門袄简。在里面找到主要用到了兩個(gè)類腥放,代碼這里就直接貼出來了:

RecyclerViewCursorAdapter.java
public abstract class RecyclerViewCursorAdapter<VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> implements Filterable,
        CursorFilter.CursorFilterClient {

    /**
     * Call when bind view with the cursor
     *
     * @param holder
     * @param cursor
     */
    public abstract void onBindViewHolder(VH holder, Cursor cursor);

    /**
     * This field should be made private, so it is hidden from the SDK.
     * {@hide}
     */
    protected boolean mDataValid;

    /**
     * The current cursor
     */
    protected Cursor mCursor;

    /**
     * This field should be made private, so it is hidden from the SDK.
     * {@hide}
     */
    protected Context mContext;

    /**
     * The row id column
     */
    protected int mRowIDColumn;

    /**
     * This field should be made private, so it is hidden from the SDK.
     * {@hide}
     */
    protected ChangeObserver mChangeObserver;
    /**
     * This field should be made private, so it is hidden from the SDK.
     * {@hide}
     */
    protected DataSetObserver mDataSetObserver;

    /**
     * This field should be made private, so it is hidden from the SDK.
     * {@hide}
     */
    protected CursorFilter mCursorFilter;

    /**
     * This field should be made private, so it is hidden from the SDK.
     * {@hide}
     */
    protected FilterQueryProvider mFilterQueryProvider;

    /**
     * If set the adapter will register a content observer on the cursor and will call
     * {@link #onContentChanged()} when a notification comes in.  Be careful when
     * using this flag: you will need to unset the current Cursor from the adapter
     * to avoid leaks due to its registered observers.  This flag is not needed
     * when using a CursorAdapter with a
     * {@link android.content.CursorLoader}.
     */
    public static final int FLAG_REGISTER_CONTENT_OBSERVER = 0x02;

    /**
     * Recommended constructor.
     *
     * @param c       The cursor from which to get the data.
     * @param context The context
     * @param flags   Flags used to determine the behavior of the adapter;
     *                Currently it accept {@link #FLAG_REGISTER_CONTENT_OBSERVER}.
     */
    public RecyclerViewCursorAdapter(Context context, Cursor c, int flags) {
        init(context, c, flags);
    }

    void init(Context context, Cursor c, int flags) {

        boolean cursorPresent = c != null;
        mCursor = c;
        mDataValid = cursorPresent;
        mContext = context;
        mRowIDColumn = cursorPresent ? c.getColumnIndexOrThrow("_id") : -1;
        if ((flags & FLAG_REGISTER_CONTENT_OBSERVER) == FLAG_REGISTER_CONTENT_OBSERVER) {
            mChangeObserver = new ChangeObserver();
            mDataSetObserver = new MyDataSetObserver();
        } else {
            mChangeObserver = null;
            mDataSetObserver = null;
        }

        if (cursorPresent) {
            if (mChangeObserver != null) c.registerContentObserver(mChangeObserver);
            if (mDataSetObserver != null) c.registerDataSetObserver(mDataSetObserver);
        }
        setHasStableIds(true);
    }

    /**
     * Returns the cursor.
     *
     * @return the cursor.
     */
    @Override
    public Cursor getCursor() {
        return mCursor;
    }

    /**
     * @see RecyclerView.Adapter#getItemCount()
     */
    @Override
    public int getItemCount() {
        if (mDataValid && mCursor != null) {
            return mCursor.getCount();
        } else {
            return 0;
        }
    }

    /**
     * @param position Adapter position to query
     * @return
     * @see RecyclerView.Adapter#getItemId(int)
     */
    @Override
    public long getItemId(int position) {
        if (mDataValid && mCursor != null) {
            if (mCursor.moveToPosition(position)) {
                return mCursor.getLong(mRowIDColumn);
            } else {
                return 0;
            }
        } else {
            return 0;
        }
    }

    @Override
    public void onBindViewHolder(VH holder, int position) {
        if (!mDataValid) {
            throw new IllegalStateException("this should only be called when the cursor is valid");
        }
        if (!mCursor.moveToPosition(position)) {
            throw new IllegalStateException("couldn't move cursor to position " + position);
        }
        onBindViewHolder(holder, mCursor);
    }

    /**
     * Change the underlying cursor to a new cursor. If there is an existing cursor it will be
     * closed.
     *
     * @param cursor The new cursor to be used
     */
    public void changeCursor(Cursor cursor) {
        Cursor old = swapCursor(cursor);
        if (old != null) {
            old.close();
        }
    }

    /**
     * Swap in a new Cursor, returning the old Cursor.  Unlike
     * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em>
     * closed.
     *
     * @param newCursor The new cursor to be used.
     * @return Returns the previously set Cursor, or null if there wasa not one.
     * If the given new Cursor is the same instance is the previously set
     * Cursor, null is also returned.
     */
    public Cursor swapCursor(Cursor newCursor) {
        if (newCursor == mCursor) {
            return null;
        }
        Cursor oldCursor = mCursor;
        if (oldCursor != null) {
            if (mChangeObserver != null) oldCursor.unregisterContentObserver(mChangeObserver);
            if (mDataSetObserver != null) oldCursor.unregisterDataSetObserver(mDataSetObserver);
        }
        mCursor = newCursor;
        if (newCursor != null) {
            if (mChangeObserver != null) newCursor.registerContentObserver(mChangeObserver);
            if (mDataSetObserver != null) newCursor.registerDataSetObserver(mDataSetObserver);
            mRowIDColumn = newCursor.getColumnIndexOrThrow("_id");
            mDataValid = true;
            // notify the observers about the new cursor
            notifyDataSetChanged();
        } else {
            mRowIDColumn = -1;
            mDataValid = false;
            // notify the observers about the lack of a data set
            notifyDataSetChanged();
//            notifyDataSetInvalidated();
        }
        return oldCursor;
    }

    /**
     * <p>Converts the cursor into a CharSequence. Subclasses should override this
     * method to convert their results. The default implementation returns an
     * empty String for null values or the default String representation of
     * the value.</p>
     *
     * @param cursor the cursor to convert to a CharSequence
     * @return a CharSequence representing the value
     */
    public CharSequence convertToString(Cursor cursor) {
        return cursor == null ? "" : cursor.toString();
    }

    /**
     * Runs a query with the specified constraint. This query is requested
     * by the filter attached to this adapter.
     * <p/>
     * The query is provided by a
     * {@link FilterQueryProvider}.
     * If no provider is specified, the current cursor is not filtered and returned.
     * <p/>
     * After this method returns the resulting cursor is passed to {@link #changeCursor(Cursor)}
     * and the previous cursor is closed.
     * <p/>
     * This method is always executed on a background thread, not on the
     * application's main thread (or UI thread.)
     * <p/>
     * Contract: when constraint is null or empty, the original results,
     * prior to any filtering, must be returned.
     *
     * @param constraint the constraint with which the query must be filtered
     * @return a Cursor representing the results of the new query
     * @see #getFilter()
     * @see #getFilterQueryProvider()
     * @see #setFilterQueryProvider(FilterQueryProvider)
     */
    public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
        if (mFilterQueryProvider != null) {
            return mFilterQueryProvider.runQuery(constraint);
        }

        return mCursor;
    }

    public Filter getFilter() {
        if (mCursorFilter == null) {
            mCursorFilter = new CursorFilter(this);
        }
        return mCursorFilter;
    }

    /**
     * Returns the query filter provider used for filtering. When the
     * provider is null, no filtering occurs.
     *
     * @return the current filter query provider or null if it does not exist
     * @see #setFilterQueryProvider(FilterQueryProvider)
     * @see #runQueryOnBackgroundThread(CharSequence)
     */
    public FilterQueryProvider getFilterQueryProvider() {
        return mFilterQueryProvider;
    }

    /**
     * Sets the query filter provider used to filter the current Cursor.
     * The provider's
     * {@link FilterQueryProvider#runQuery(CharSequence)}
     * method is invoked when filtering is requested by a client of
     * this adapter.
     *
     * @param filterQueryProvider the filter query provider or null to remove it
     * @see #getFilterQueryProvider()
     * @see #runQueryOnBackgroundThread(CharSequence)
     */
    public void setFilterQueryProvider(FilterQueryProvider filterQueryProvider) {
        mFilterQueryProvider = filterQueryProvider;
    }

    /**
     * Called when the {@link ContentObserver} on the cursor receives a change notification.
     * The default implementation provides the auto-requery logic, but may be overridden by
     * sub classes.
     *
     * @see ContentObserver#onChange(boolean)
     */
    protected abstract void onContentChanged();

    private class ChangeObserver extends ContentObserver {
        public ChangeObserver() {
            super(new Handler());
        }

        @Override
        public boolean deliverSelfNotifications() {
            return true;
        }

        @Override
        public void onChange(boolean selfChange) {
            onContentChanged();
        }
    }

    private class MyDataSetObserver extends DataSetObserver {
        @Override
        public void onChanged() {
            mDataValid = true;
            notifyDataSetChanged();
        }

        @Override
        public void onInvalidated() {
            mDataValid = false;
            notifyDataSetChanged();
//            notifyDataSetInvalidated();
        }
    }
}
CursorFilter.java
class CursorFilter extends Filter {

    CursorFilterClient mClient;

    interface CursorFilterClient {
        CharSequence convertToString(Cursor cursor);

        Cursor runQueryOnBackgroundThread(CharSequence constraint);

        Cursor getCursor();

        void changeCursor(Cursor cursor);
    }

    CursorFilter(CursorFilterClient client) {
        mClient = client;
    }

    @Override
    public CharSequence convertResultToString(Object resultValue) {
        return mClient.convertToString((Cursor) resultValue);
    }

    @Override
    protected FilterResults performFiltering(CharSequence constraint) {
        Cursor cursor = mClient.runQueryOnBackgroundThread(constraint);

        FilterResults results = new FilterResults();
        if (cursor != null) {
            results.count = cursor.getCount();
            results.values = cursor;
        } else {
            results.count = 0;
            results.values = null;
        }
        return results;
    }

    @Override
    protected void publishResults(CharSequence constraint, FilterResults results) {
        Cursor oldCursor = mClient.getCursor();

        if (results.values != null && results.values != oldCursor) {
            mClient.changeCursor((Cursor) results.values);
        }
    }
}

把上面這兩個(gè)類直接放到工程中,讓RecyclerView的Adapter繼承RecyclerViewCursorAdapter绿语,然后就可以像ListView的CursorAdapter那樣使用它了秃症。

Loader機(jī)制

Loader候址,顧名思義,就是一個(gè)加載器种柑。是Android 3.0后推出的一個(gè)用于異步加載數(shù)據(jù)的機(jī)制岗仑。可用與Activity和Fragment中聚请。它能檢測(cè)數(shù)據(jù)源荠雕,當(dāng)數(shù)據(jù)源內(nèi)容改變時(shí)它們能夠傳遞新的結(jié)果,當(dāng)配置改變后需要重新創(chuàng)建時(shí)驶赏,它們會(huì)重新連接到最后一個(gè)Loader的游標(biāo)炸卑。這樣,它們不需要重新查詢它們的數(shù)據(jù)煤傍。常用于ContentProvider盖文、CursorAdapter和數(shù)據(jù)庫(kù)配合使用。Google提供了一個(gè)標(biāo)準(zhǔn)的Loader患久,另外還有一個(gè)抽象類AsyncTaskLoader。本文只是簡(jiǎn)單的談?wù)勥@個(gè)Loader的使用浑槽,即CursorLoader蒋失,它是Loader的標(biāo)準(zhǔn)實(shí)現(xiàn),如果你的數(shù)據(jù)能夠用Cursor表示桐玻,比如來自SQLiteDatabase的數(shù)據(jù)就是標(biāo)準(zhǔn)的Cursor篙挽,那么這個(gè)類對(duì)你而言就夠用了。

我們就來配合前面提到的RecyclerViewCursorAdapter镊靴,讓Loader機(jī)制結(jié)合RecyclerViewCursorAdapter寫一個(gè)demo铣卡,上圖看看效果:


LoaderDemo.gif
簡(jiǎn)單使用的過程

建一個(gè)bean類,Book.java:

package com.sonnyzoom.loaderdemo.bean;

/**
 * Created by zoom on 2016/3/30.
 */
public class Book {

    private String id;
    private String name;
    private int price;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
    
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }
}

數(shù)據(jù)庫(kù):BookDBHelper.java:

package com.sonnyzoom.loaderdemo.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by zoom on 2016/3/30.
 */
public class BookDBHelper extends SQLiteOpenHelper {

    private static final String DATABASE_NAME = "Book.db";
    private static final int DATABASE_VERSION = 1;

    public static final String TABLE_NAME = "BookInfo";
    public static final String ID = "_id";
    public static final String NAME = "name";
    public static final String PRICE = "price";

    private static final String CREATE_DATABASE="CREATE TABLE "+TABLE_NAME+" ( "
            +ID+" INTEGER PRIMARY KEY AUTOINCREMENT ,"
            +NAME+" TEXT,"
            +PRICE+" INTEGER)";

    private volatile static BookDBHelper helper;

    private BookDBHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    public static BookDBHelper getInstance(Context context) {

        if (helper == null) {
            synchronized (BookDBHelper.class) {
                if (helper == null) {
                    helper = new BookDBHelper(context);
                }
            }
        }

        return helper;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_DATABASE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}

一個(gè)基本的ContentProvider類偏竟,關(guān)于ContentProvider就不多說了煮落,不要忘記在AndroidManifest里面注冊(cè)。

package com.sonnyzoom.loaderdemo.provider;

import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.support.annotation.Nullable;

import com.sonnyzoom.loaderdemo.db.BookDBHelper;

/**
 * Created by zoom on 2016/3/30.
 */
public class BookProvider extends ContentProvider {

    private static final String AUTHORITY="com.sonnyzoom.loaderdemo.provider.bookprovider";
    public static final Uri URI_BOOK_ALL=Uri.parse("content://"+AUTHORITY+"/book");

    private static UriMatcher matcher;
    private BookDBHelper helper;
    private SQLiteDatabase db;

    private static final int BOOK_ALL=0;
    private static final int BOOK_ONE=1;

    static {
        matcher=new UriMatcher(UriMatcher.NO_MATCH);
        matcher.addURI(AUTHORITY,"book/",BOOK_ALL);
        matcher.addURI(AUTHORITY,"book/#",BOOK_ONE);
    }

    @Override
    public boolean onCreate() {
        helper=BookDBHelper.getInstance(getContext());
        return true;
    }

    @Nullable
    @Override
    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {

        switch (matcher.match(uri)){

            case BOOK_ALL:

                break;
            case BOOK_ONE:
                long id= ContentUris.parseId(uri);
                selection="_id=?";
                selectionArgs=new String[]{String.valueOf(id)};
                break;
            default:
                throw new IllegalArgumentException("Wrong Uri:"+uri);
        }

        db=helper.getReadableDatabase();
        Cursor cursor=db.query(BookDBHelper.TABLE_NAME,projection,selection,selectionArgs,null,null,sortOrder);
        cursor.setNotificationUri(getContext().getContentResolver(),URI_BOOK_ALL);
        return cursor;
    }

    @Nullable
    @Override
    public String getType(Uri uri) {
        return null;
    }

    @Nullable
    @Override
    public Uri insert(Uri uri, ContentValues values) {

        if (matcher.match(uri)!=BOOK_ALL){
            throw new IllegalArgumentException("Wrong Uri:"+uri);
        }
        db=helper.getReadableDatabase();
        long rowId = db.insert(BookDBHelper.TABLE_NAME, null, values);
        if (rowId>0){
            notifyDataSetChanged();
            return ContentUris.withAppendedId(uri,rowId);
        }

        return null;
    }

    @Override
    public int delete(Uri uri, String selection, String[] selectionArgs) {
        return 0;
    }

    @Override
    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
        return 0;
    }

    private void notifyDataSetChanged() {
        getContext().getContentResolver().notifyChange(URI_BOOK_ALL,null);
    }
}

然后是RecyclerView的適配器踊谋,BookAdapter.java蝉仇,繼承上面我們開頭提過的RecyclerViewCursorAdapter:

package com.sonnyzoom.loaderdemo.adapter;

import android.content.Context;
import android.database.Cursor;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.sonnyzoom.loaderdemo.R;
import com.sonnyzoom.loaderdemo.bean.Book;
import com.sonnyzoom.loaderdemo.db.BookDBHelper;

/**
 * Created by zoom on 2016/3/30.
 */
public class BookAdapter extends RecyclerViewCursorAdapter<BookAdapter.BookViewHolder> {

    private LayoutInflater inflater;

    public BookAdapter(Context context, Cursor c, int flags) {
        super(context, c, flags);
        inflater=LayoutInflater.from(context);
    }

    @Override
    public void onBindViewHolder(BookViewHolder holder, Cursor cursor) {

        Book book=new Book();
        book.setId(cursor.getString(cursor.getColumnIndex(BookDBHelper.ID)));
        book.setName(cursor.getString(cursor.getColumnIndex(BookDBHelper.NAME)));
        book.setPrice(cursor.getInt(cursor.getColumnIndex(BookDBHelper.PRICE)));

        holder.name.setText(book.getName());
        holder.price.setText(Integer.toString(book.getPrice()));

    }

    @Override
    protected void onContentChanged() {}

    @Override
    public BookViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View v=inflater.inflate(R.layout.book_item,parent,false);

        return new BookViewHolder(v);
    }

    class BookViewHolder extends RecyclerView.ViewHolder{

        public TextView name;
        public TextView price;

        public BookViewHolder(View itemView) {
            super(itemView);
            name= (TextView) itemView.findViewById(R.id.book_name);
            price= (TextView) itemView.findViewById(R.id.book_price);

        }
    }
}

MainActivity里面主要的是CursorLoader :

    private void initLoader() {

        getLoaderManager().initLoader(1, null, new LoaderManager.LoaderCallbacks<Cursor>() {
            @Override
            public Loader<Cursor> onCreateLoader(int id, Bundle args) {

                CursorLoader loader = new CursorLoader(MainActivity.this, BookProvider.URI_BOOK_ALL, null, null, null, null);

                return loader;
            }

            @Override
            public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
                adapter.swapCursor(data);
            }

            @Override
            public void onLoaderReset(Loader<Cursor> loader) {
                adapter.swapCursor(null);
            }
        });
    }

MainActivity.java全部代碼:

package com.sonnyzoom.loaderdemo;

import android.app.LoaderManager;
import android.content.ContentValues;
import android.content.CursorLoader;
import android.content.Loader;
import android.database.Cursor;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.sonnyzoom.loaderdemo.adapter.BookAdapter;
import com.sonnyzoom.loaderdemo.db.BookDBHelper;
import com.sonnyzoom.loaderdemo.provider.BookProvider;

public class MainActivity extends AppCompatActivity {

    private RecyclerView recyclerView;
    private FloatingActionButton fab;

    private BookAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        initViews();
        initLoader();

        if (fab != null) {
            fab.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    showDialog();
                }
            });
        }

    }

    private void showDialog() {

        final AlertDialog dialog = new AlertDialog.Builder(this).create();
        View v = getLayoutInflater().inflate(R.layout.dialog, null);
        dialog.setView(v);
        dialog.setCancelable(false);
        dialog.show();

        final EditText name = (EditText) v.findViewById(R.id.edit_name);
        final EditText price = (EditText) v.findViewById(R.id.edit_price);

        Button cancel = (Button) v.findViewById(R.id.btn_cancel);
        Button save = (Button) v.findViewById(R.id.btn_save);

        save.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                String mName = name.getText().toString();
                String mPrice = price.getText().toString();

                ContentValues values = new ContentValues();
                values.put(BookDBHelper.NAME, mName);
                values.put(BookDBHelper.PRICE, Integer.valueOf(mPrice));

                getContentResolver().insert(BookProvider.URI_BOOK_ALL, values);
                dialog.dismiss();
            }
        });

        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

    }

    private void initLoader() {

        getLoaderManager().initLoader(1, null, new LoaderManager.LoaderCallbacks<Cursor>() {
            @Override
            public Loader<Cursor> onCreateLoader(int id, Bundle args) {

                CursorLoader loader = new CursorLoader(MainActivity.this, BookProvider.URI_BOOK_ALL, null, null, null, null);

                return loader;
            }

            @Override
            public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
                adapter.swapCursor(data);
            }

            @Override
            public void onLoaderReset(Loader<Cursor> loader) {
                adapter.swapCursor(null);
            }
        });

    }

    private void initViews() {

        fab = (FloatingActionButton) findViewById(R.id.fab);
        recyclerView = (RecyclerView) findViewById(R.id.recyclerView);

        if (adapter == null) {

            Cursor c = getContentResolver().query(BookProvider.URI_BOOK_ALL, null, null, null, null);
            adapter = new BookAdapter(this, c, 1);
        }

        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        recyclerView.setHasFixedSize(true);
        recyclerView.setAdapter(adapter);

    }

}

Loader機(jī)制的用法當(dāng)然不只有這一種,還有更多的功能等你去發(fā)掘殖蚕。這里只是淺談轿衔,文章如有什么錯(cuò)誤,歡迎在下方評(píng)論睦疫、交流害驹!
文章源碼地址:Github

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市蛤育,隨后出現(xiàn)的幾起案子宛官,更是在濱河造成了極大的恐慌葫松,老刑警劉巖,帶你破解...
    沈念sama閱讀 219,188評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件摘刑,死亡現(xiàn)場(chǎng)離奇詭異进宝,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)枷恕,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,464評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門党晋,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人徐块,你說我怎么就攤上這事未玻。” “怎么了胡控?”我有些...
    開封第一講書人閱讀 165,562評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵扳剿,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我昼激,道長(zhǎng)庇绽,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,893評(píng)論 1 295
  • 正文 為了忘掉前任橙困,我火速辦了婚禮瞧掺,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘凡傅。我一直安慰自己辟狈,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,917評(píng)論 6 392
  • 文/花漫 我一把揭開白布夏跷。 她就那樣靜靜地躺著哼转,像睡著了一般。 火紅的嫁衣襯著肌膚如雪槽华。 梳的紋絲不亂的頭發(fā)上壹蔓,一...
    開封第一講書人閱讀 51,708評(píng)論 1 305
  • 那天,我揣著相機(jī)與錄音猫态,去河邊找鬼庶溶。 笑死,一個(gè)胖子當(dāng)著我的面吹牛懂鸵,可吹牛的內(nèi)容都是我干的偏螺。 我是一名探鬼主播,決...
    沈念sama閱讀 40,430評(píng)論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼匆光,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼套像!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起终息,我...
    開封第一講書人閱讀 39,342評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤夺巩,失蹤者是張志新(化名)和其女友劉穎贞让,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體柳譬,經(jīng)...
    沈念sama閱讀 45,801評(píng)論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡喳张,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,976評(píng)論 3 337
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了美澳。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片销部。...
    茶點(diǎn)故事閱讀 40,115評(píng)論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖制跟,靈堂內(nèi)的尸體忽然破棺而出舅桩,到底是詐尸還是另有隱情,我是刑警寧澤雨膨,帶...
    沈念sama閱讀 35,804評(píng)論 5 346
  • 正文 年R本政府宣布擂涛,位于F島的核電站,受9級(jí)特大地震影響聊记,放射性物質(zhì)發(fā)生泄漏撒妈。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,458評(píng)論 3 331
  • 文/蒙蒙 一排监、第九天 我趴在偏房一處隱蔽的房頂上張望狰右。 院中可真熱鬧,春花似錦社露、人聲如沸挟阻。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,008評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至脱拼,卻和暖如春瞒瘸,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背熄浓。 一陣腳步聲響...
    開封第一講書人閱讀 33,135評(píng)論 1 272
  • 我被黑心中介騙來泰國(guó)打工情臭, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人赌蔑。 一個(gè)月前我還...
    沈念sama閱讀 48,365評(píng)論 3 373
  • 正文 我出身青樓俯在,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親娃惯。 傳聞我的和親對(duì)象是個(gè)殘疾皇子跷乐,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,055評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容