package com.wasu.cs.provider;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.net.Uri;

import com.wasu.authsdk.AuthSDK;
import com.wasu.authsdk.IAuthInterface;

/**
 * @Description: 为乐视APK提供信息
 * @Author: Danxingxi
 * @CreateDate: 2016/10/28 17:39
 */
public class Provider4Leshi extends ContentProvider {
    private static final String CONTENT = "content://";
    private static final String AUTHORITY = "com.wasutv.providerforleshi";
    private static final String path = "parameters";
    private static final Uri CONTENT_URI = Uri.parse(CONTENT + AUTHORITY + "/" + path);

    private static final String[] COLUMN_NAMES = new String[] { "type",
            "from_external",
            "channel",
            "device_id",
            "site_id",
            "tv_id"};

    private static final UriMatcher sUriMatcher;
    private static final int PARAMETERS = 1;

    static {
        sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
        sUriMatcher.addURI(AUTHORITY, path, PARAMETERS);
    }

    @Override
    public boolean onCreate() {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public Cursor query(Uri uri, String[] projection, String selection,
                        String[] selectionArgs, String sortOrder) {
        switch (sUriMatcher.match(uri)) {
            case PARAMETERS:
                MatrixCursor cursor = new MatrixCursor(COLUMN_NAMES);
                cursor.addRow(new Object[] { "2",
                        1,
                        "wasu",
                        AuthSDK.getInstance().getValue(IAuthInterface.KEY_DEVICEID),
                        AuthSDK.getInstance().getValue(IAuthInterface.KEY_SITEID),
                        AuthSDK.getInstance().getValue(IAuthInterface.KEY_TVID)});
                return cursor;

            default:
                throw new IllegalArgumentException("Unknow URI: " + uri);
        }
    }

    @Override
    public String getType(Uri uri) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Uri insert(Uri uri, ContentValues values) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public int delete(Uri uri, String selection, String[] selectionArgs) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public int update(Uri uri, ContentValues values, String selection,
                      String[] selectionArgs) {
        // TODO Auto-generated method stub
        return 0;
    }

}