当前位置: 首页>>代码示例>>Java>>正文


Java AndroidContext类代码示例

本文整理汇总了Java中com.couchbase.lite.android.AndroidContext的典型用法代码示例。如果您正苦于以下问题:Java AndroidContext类的具体用法?Java AndroidContext怎么用?Java AndroidContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AndroidContext类属于com.couchbase.lite.android包,在下文中一共展示了AndroidContext类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initDatabase

import com.couchbase.lite.android.AndroidContext; //导入依赖的package包/类
/**
 * 初始化数据库manager和数据库实例,保证全局唯
 *
 * @param context 上下文
 * @return mDatabase
 */
private synchronized boolean initDatabase(Context context) {

    if (context == null) {
        return false;
    }

    try {
        if (mDatabase == null) {
            Manager manager = new Manager(new AndroidContext(context), Manager.DEFAULT_OPTIONS);
            mDatabase = manager.getDatabase("guanghetv");
        }
    } catch (Exception e) {
        LogUtils.d(e.getMessage());
        mDatabase = null;
    }

    if (mDatabase != null) {
        return true;
    } else {
        return false;
    }
}
 
开发者ID:jessie345,项目名称:RealArchitecture,代码行数:29,代码来源:CouchBaseStorage.java

示例2: initializeCouchbase

import com.couchbase.lite.android.AndroidContext; //导入依赖的package包/类
private void initializeCouchbase(Context context) {
    final Map<String, Object> s = new HashMap<>();
    s.put("key1", "value1");
    s.put("key2", "value2");
    s.put("key3", "value3");
    s.put("key4", "value4");
    s.put("key5", "value5");
    s.put("key6", "value6");
    s.put("key7", "value7");
    s.put("key8", "value8");
    s.put("key9", "value9");
    s.put("key10", "value10");

    try {
        mManager = new Manager(new AndroidContext(context), Manager.DEFAULT_OPTIONS);
        mDatabase = mManager.getDatabase("stetho-couchbase-sample");
        Document doc = mDatabase.getDocument("id:123456");
        doc.putProperties(s);
        doc = mDatabase.getDocument("p::abcdefg");
        doc.putProperties(s);
        doc = mDatabase.getDocument("p::123abc");
        doc.putProperties(s);
    } catch (Exception ignored) {

    }
}
 
开发者ID:RobotPajamas,项目名称:Stetho-Couchbase,代码行数:27,代码来源:MainApplication.java

示例3: onCreate

import com.couchbase.lite.android.AndroidContext; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    docCountLabel = (TextView) findViewById(docCount);

    try {
        manager = new Manager(new AndroidContext(getApplicationContext()), Manager.DEFAULT_OPTIONS);
    } catch (IOException e) {
        e.printStackTrace();
    }

    DatabaseDownloader databaseDownloader = new DatabaseDownloader(getApplicationContext());
    databaseDownloader.execute();
    databaseDownloader.setDownloaderListener(new DownloaderListener() {
        @Override
        public void onCompleted() {
            setupQuery();
        }
    });

}
 
开发者ID:couchbaselabs,项目名称:mini-hacks,代码行数:23,代码来源:MainActivity.java

示例4: CouchbaseLite

import com.couchbase.lite.android.AndroidContext; //导入依赖的package包/类
public CouchbaseLite(Context context){
    try {
        manager = new Manager(new AndroidContext(context), Manager.DEFAULT_OPTIONS);
        couchDbAuthor = manager.getDatabase("dbauthor");
        couchDbPost = manager.getDatabase("dbpost");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:AmeliaPessoa,项目名称:DBPA,代码行数:10,代码来源:CouchbaseLite.java

示例5: getAllDocumentIds

import com.couchbase.lite.android.AndroidContext; //导入依赖的package包/类
List<String> getAllDocumentIds(String databaseId) {
    Timber.d("getAllDocumentIds: %s", databaseId);
    ManagerOptions managerOptions = new ManagerOptions();
    managerOptions.setReadOnly(true);

    DatabaseOptions databaseOptions = new DatabaseOptions();
    databaseOptions.setReadOnly(true);

    com.couchbase.lite.Database database = null;
    try {
        // TODO: Create LiveQuery on this?
        // TODO: Open manager/database and cache result - could be expensive operation
        Manager manager = new Manager(new AndroidContext(mContext), managerOptions);
        database = manager.openDatabase(databaseId, databaseOptions);

        List<String> docIds = new ArrayList<>();
        QueryEnumerator result = database.createAllDocumentsQuery().run();
        while (result.hasNext()) {
            QueryRow row = result.next();
            docIds.add(row.getDocumentId());
        }

        return docIds;
    } catch (Exception e) {
        return Collections.emptyList();
    } finally {
        if (database != null) {
            database.close();
        }
    }
}
 
开发者ID:RobotPajamas,项目名称:Stetho-Couchbase,代码行数:32,代码来源:CouchbasePeerManager.java

示例6: initWithCredentials

import com.couchbase.lite.android.AndroidContext; //导入依赖的package包/类
private void initWithCredentials(Credentials credentials, Callback callback) {
    this.allowedCredentials = credentials;

    try {
        View.setCompiler(new JavaScriptViewCompiler());
        Database.setFilterCompiler(new JavaScriptReplicationFilterCompiler());

        AndroidContext context = new AndroidContext(this.context);

        manager = new Manager(context, Manager.DEFAULT_OPTIONS);

        this.startListener();

        String url;
        if (credentials != null) {
            url = String.format(
                    "http://%s:%[email protected]:%d/",
                    credentials.getLogin(),
                    credentials.getPassword(),
                    listener.getListenPort()
            );
        } else {
            url = String.format(
                    "http://localhost:%d/",
                    listener.getListenPort()
            );
        }

        callback.invoke(url, null);

    } catch (final Exception e) {
        Log.e(TAG, "Couchbase init failed", e);
        callback.invoke(null, e.getMessage());
    }
}
 
开发者ID:couchbaselabs,项目名称:react-native-couchbase-lite,代码行数:36,代码来源:ReactCBLite.java

示例7: Storage

import com.couchbase.lite.android.AndroidContext; //导入依赖的package包/类
public Storage(Context context) throws IOException, CouchbaseLiteException {
    mContext = context;

    manager = new Manager(new AndroidContext(mContext), Manager.DEFAULT_OPTIONS);
    database = manager.getDatabase(BUCKET_NAME);

    startSync();
}
 
开发者ID:Ryanair,项目名称:fr-heat-map-android,代码行数:9,代码来源:Storage.java

示例8: CouchbaseInstance

import com.couchbase.lite.android.AndroidContext; //导入依赖的package包/类
private CouchbaseInstance(Context context) throws CouchbaseLiteException, IOException {
    mContext = context.getApplicationContext();

    DatabaseOptions options = new DatabaseOptions();
    options.setCreate(true);
    options.setStorageType(Manager.FORESTDB_STORAGE);
    Manager manager = new Manager(new AndroidContext(mContext), Manager.DEFAULT_OPTIONS);
    mDatabase = manager.openDatabase(DB_SOLVES, options);

    initApiClient();
}
 
开发者ID:plusCubed,项目名称:plusTimer,代码行数:12,代码来源:CouchbaseInstance.java

示例9: DataLoader

import com.couchbase.lite.android.AndroidContext; //导入依赖的package包/类
public DataLoader(Query query) {
	super(((AndroidContext) query.getDatabase().getManager().getContext()).getWrappedContext());
	this.query = query;
}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:5,代码来源:DataLoader.java

示例10: setupCouchbase

import com.couchbase.lite.android.AndroidContext; //导入依赖的package包/类
private void setupCouchbase() throws CouchbaseLiteException, IOException {
    Manager manager = new Manager(new AndroidContext(getTargetContext()),
            Manager.DEFAULT_OPTIONS);
    database = manager.getDatabase(DB_NAME);
}
 
开发者ID:greenrobot,项目名称:android-database-performance,代码行数:6,代码来源:PerfTestCouchbase.java

示例11: startCBLite

import com.couchbase.lite.android.AndroidContext; //导入依赖的package包/类
protected void startCBLite() throws CouchbaseLiteException, IOException {
    File serverPathFile = getServerPath();
    FileDirUtils.deleteRecursive(serverPathFile);
    serverPathFile.mkdir();
    manager = new Manager(new AndroidContext(getInstrumentation().getContext()), Manager.DEFAULT_OPTIONS);
}
 
开发者ID:couchbaselabs,项目名称:couchbase-lite-android-ektorp,代码行数:7,代码来源:CBLiteEktorpTestCase.java


注:本文中的com.couchbase.lite.android.AndroidContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。