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


Java Paper类代码示例

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


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

示例1: saveValue

import io.paperdb.Paper; //导入依赖的package包/类
@Override
public void saveValue(String completePath, Object value) {

    completePath = formatPath(completePath);

    final Book book = Paper.book(VALUES);
    if(value instanceof Integer) {
        book.write(completePath, (Integer) value);
    } else if(value instanceof Float) {
        book.write(completePath, (Float) value);
    } else if(value instanceof Boolean) {
        book.write(completePath, (Boolean) value);
    } else if(value instanceof Long) {
        book.write(completePath, (Long) value);
    } else {
        book.write(completePath, String.valueOf(value));
    }
}
 
开发者ID:florent37,项目名称:Android-NoSql,代码行数:19,代码来源:PaperDataSaver.java

示例2: remove

import io.paperdb.Paper; //导入依赖的package包/类
@Override
public void remove(String startingPath) {
    final Book bookNodes = Paper.book(NODES);
    final Book bookValues = Paper.book(VALUES);
    final Set<String> nodes = getNodes();
    final Set<String> nodesToKeep = new HashSet<>();
    //update values
    for (String node : nodes) {
        if(node.startsWith(startingPath)) {
            bookValues.delete(formatPath(node));
        } else {
            nodesToKeep.add(node);
        }
    }
    bookNodes.write(NODES, nodesToKeep);
}
 
开发者ID:florent37,项目名称:Android-NoSql,代码行数:17,代码来源:PaperDataSaver.java

示例3: sendResult

import io.paperdb.Paper; //导入依赖的package包/类
public void sendResult(ResultData resultData) {
    if (!Utils.isNetworkConnected()) {
        Timber.w("offline, sendResult later");
        pendingResultData.add(resultData);
        Paper.book().write(KEY_PENDING_RESULT_DATA, pendingResultData);
        return;
    }

    if (pendingResultData.size() > 10) {
        Utils.reportNonFatal(new Exception("Emptying Track-o-bot queue"));
        pendingResultData.clear();
    }

    while (!pendingResultData.isEmpty()) {
        ResultData pendingData = pendingResultData.remove(0);
        sendResultInternal(pendingData);
        Paper.book().write(KEY_PENDING_RESULT_DATA, pendingResultData);
    }

    sendResultInternal(resultData);
}
 
开发者ID:HearthSim,项目名称:arcane_tracker,代码行数:22,代码来源:Trackobot.java

示例4: onCreate

import io.paperdb.Paper; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    CustomActivityOnCrash.install(this);
    EventBus.getDefault().register(this);
    EasyImage.configuration(this)
            .saveInRootPicturesDirectory()
            .setImagesFolderName(getString(R.string.app_name));
    Nammu.init(this);
    Paper.init(this);
    Typekit.getInstance()
            .addNormal(Typekit.createFromAsset(this, "fonts/LatoLatin-Regular.ttf"))
            .addBold(Typekit.createFromAsset(this, "fonts/LatoLatin-Bold.ttf"))
            .addItalic(Typekit.createFromAsset(this, "fonts/LatoLatin-Italic.ttf"))
            .addBoldItalic(Typekit.createFromAsset(this, "fonts/LatoLatin-BoldItalic.ttf"))
            .addCustom1(Typekit.createFromAsset(this, "fonts/Geomanist-Regular.otf"))
            .addCustom2(Typekit.createFromAsset(this, "fonts/Handlee-Regular.ttf"));

    initFabric();
    initParse();
}
 
开发者ID:adrielcafe,项目名称:NMSAlphabetAndroidApp,代码行数:22,代码来源:App.java

示例5: onDataOk

import io.paperdb.Paper; //导入依赖的package包/类
@Override
public void onDataOk(String url, String data) {
    switch (url) {
        case Api.URL_HOME:
            Home home = JsonUtil.getEntity(data, Home.class);
            refreshUI(home);
            if (home != null) {
                Paper.book().write(Constants.TAG_HOME + curDate, home);
            }
            HomeFragment.getInstance().pager.onRefreshComplete();
            break;
        case Api.URL_LIKE_OR_CANCLELIKE:
            try {
                JSONObject jsonObject = new JSONObject(data);
                int likeCount = jsonObject.optInt("strPraisednumber");
                //若实际的喜欢数量与LikeView自增的结果值不同,显示实际的数量
                if (likeCount != lvSaying.getLikeCount()) {
                    lvSaying.setText(likeCount + "");
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
            break;
    }
}
 
开发者ID:Uphie,项目名称:ONE-Unofficial,代码行数:26,代码来源:HomeContentFragment.java

示例6: onDataOk

import io.paperdb.Paper; //导入依赖的package包/类
@Override
public void onDataOk(String url, String data) {
    switch (url) {
        case Api.URL_QUESTION:
            Question question = JsonUtil.getEntity(data, Question.class);
            refreshUI(question);
            if (question != null) {
                Paper.book().write(Constants.TAG_QUESTION + curDate, question);
            }
            QuestionFragment.getInstance().pager.onRefreshComplete();
            break;
        case Api.URL_LIKE_OR_CANCLELIKE:
            try {
                JSONObject jsonObject = new JSONObject(data);
                int likeCount = jsonObject.optInt("strPraisednumber");
                //若实际的喜欢数量与LikeView自增的结果值不同,更新显示最新的数量
                if (likeCount != lvQuestion.getLikeCount()) {
                    lvQuestion.setText(likeCount + "");
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
            break;
    }
}
 
开发者ID:Uphie,项目名称:ONE-Unofficial,代码行数:26,代码来源:QuestionContentFragment.java

示例7: onCreate

import io.paperdb.Paper; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    Paper.init(this);

    CrashHandler.getInstance().init(this);
    ImageUtil.init(this);
    NetworkUtil.init(this);
    ConfigUtil.init(this);
    TextToast.init(this);

    //Facebook分享初始化
    FacebookSdk.sdkInitialize(getApplicationContext());
    //友盟意见反馈初始化
    FeedbackPush.getInstance(this).init(false);
}
 
开发者ID:Uphie,项目名称:ONE-Unofficial,代码行数:17,代码来源:App.java

示例8: testReadWrite500Contacts

import io.paperdb.Paper; //导入依赖的package包/类
@Test
public void testReadWrite500Contacts() throws Exception {
    final List<Person> contacts = TestDataGenerator.genPersonList(500);
    Paper.init(getTargetContext());
    Paper.book().destroy();
    long paperTime = runTest(new PaperReadWriteContactsTest(), contacts, REPEAT_COUNT);

    Hawk.init(getTargetContext());
    Hawk.clear();
    long hawkTime = runTest(new HawkReadWriteContactsTest(), contacts, REPEAT_COUNT);

    final List<PersonArg> contactsArg = TestDataGenerator.genPersonArgList(500);
    Paper.init(getTargetContext());
    Paper.book().destroy();
    long paperArg = runTest(new PaperReadWriteContactsArgTest(), contactsArg, REPEAT_COUNT);

    printResults("Read/write 500 contacts", paperTime, hawkTime, paperArg);
}
 
开发者ID:pilgr,项目名称:Paper,代码行数:19,代码来源:Benchmark.java

示例9: testClear

import io.paperdb.Paper; //导入依赖的package包/类
@Test
public void testClear() throws Exception {
    Paper.put("persons", TestDataGenerator.genPersonList(10));
    Paper.put("persons2", TestDataGenerator.genPersonList(20));
    assertTrue(Paper.exist("persons"));
    assertTrue(Paper.exist("persons2"));

    Paper.clear(getTargetContext());
    // init() call is not required after clear()
    assertFalse(Paper.exist("persons"));
    assertFalse(Paper.exist("persons2"));

    // Should be possible to continue to use Paper after clear()
    Paper.put("persons3", TestDataGenerator.genPersonList(30));
    assertTrue(Paper.exist("persons3"));
    assertThat(Paper.<List>get("persons3")).hasSize(30);
}
 
开发者ID:pilgr,项目名称:Paper,代码行数:18,代码来源:PaperDeprecatedAPITest.java

示例10: read_write_different_keys

import io.paperdb.Paper; //导入依赖的package包/类
@Test
public void read_write_different_keys() throws InterruptedException {
    // Primary write something else
    Paper.book().write("city", "Victoria");

    // Start writing large dataset
    CountDownLatch writeEndLatch = startWritingLargeDataSetInSeparateThread("dataset");

    Log.d(TAG, "read other key: start");
    // Read for different key 'city' should be locked by writing other key 'dataset'
    assertEquals("Victoria", Paper.book().read("city"));
    assertEquals(1, writeEndLatch.getCount());
    writeEndLatch.await(5, TimeUnit.SECONDS);
    assertEquals(10000, Paper.book().<List<Person>>read("dataset").size());
    Log.d(TAG, "read other key: finish");
}
 
开发者ID:pilgr,项目名称:Paper,代码行数:17,代码来源:MultiThreadTest.java

示例11: startWritingLargeDataSetInSeparateThread

import io.paperdb.Paper; //导入依赖的package包/类
@NonNull
private CountDownLatch startWritingLargeDataSetInSeparateThread(
        @SuppressWarnings("SameParameterValue") final String key) throws InterruptedException {
    final CountDownLatch writeStartLatch = new CountDownLatch(1);
    final CountDownLatch writeFinishLatch = new CountDownLatch(1);
    new Thread() {
        final List<Person> dataset = TestDataGenerator.genPersonList(10000);

        @Override
        public void run() {
            Log.d(TAG, "write '" + key + "': start");
            writeStartLatch.countDown();
            Paper.book().write(key, dataset);
            Log.d(TAG, "write '" + key + "': finish");
            writeFinishLatch.countDown();
        }
    }.start();
    writeStartLatch.await(5, TimeUnit.SECONDS);
    // A small delay is required to let writer thread start writing data and acquire a lock
    Thread.sleep(100);
    return writeFinishLatch;
}
 
开发者ID:pilgr,项目名称:Paper,代码行数:23,代码来源:MultiThreadTest.java

示例12: convertMangaListItemsToManga

import io.paperdb.Paper; //导入依赖的package包/类
public static List<Manga> convertMangaListItemsToManga(List<MangaEdenMangaListItem> mangaListItems) {
    Log.d("MangaEden", "Converting manga models...");
    Manga manga;
    List<Manga> result = new ArrayList<>();
    for (MangaEdenMangaListItem mangaListItem : mangaListItems) {
        manga = Paper.book(UserLibraryHelper.USER_LIBRARY_DB).read(mangaListItem.id);
        if (manga == null) {
            manga = new Manga();
            manga.id = mangaListItem.id;
            manga.title = mangaListItem.title;
            manga.imageSrc = mangaListItem.imageUrl;
            manga.lastChapterDate = mangaListItem.lastChapterDate;
            manga.genres = mangaListItem.genres;
            manga.status = Integer.parseInt(mangaListItem.status);
            manga.hits = mangaListItem.hits;
        }
        result.add(manga);
    }
    Log.d("MangaEden", "Finished converting manga models...");
    return result;
}
 
开发者ID:ckmah,项目名称:DangoReader,代码行数:22,代码来源:MangaEden.java

示例13: onCreate

import io.paperdb.Paper; //导入依赖的package包/类
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_manga_item);

        Paper.init(this);
        findViewById(R.id.manga_item_pager).setVisibility(View.GONE);
        initToolBar();

        String mangaId = getIntent().getStringExtra("mangaId");
        manga = Paper.book(UserLibraryHelper.USER_LIBRARY_DB).read(mangaId);
//        if (manga != null && manga.chaptersList != null) {
//            initViewPager();
//            initMarqueeTitle();
//        }
        fetchMangaDetailFromMangaEden(mangaId);
    }
 
开发者ID:ckmah,项目名称:DangoReader,代码行数:18,代码来源:MangaItemActivity.java

示例14: saveNodes

import io.paperdb.Paper; //导入依赖的package包/类
@Override
public void saveNodes(String completePath, Set<String> values) {
    final Set<String> nodes = new HashSet<>();
    nodes.add(completePath);
    nodes.addAll(getNodes());
    for (String value : values) {
        nodes.add(completePath + value);
    }

    Paper.book(NODES).write(NODES, nodes);
}
 
开发者ID:florent37,项目名称:Android-NoSql,代码行数:12,代码来源:PaperDataSaver.java

示例15: DatabaseController

import io.paperdb.Paper; //导入依赖的package包/类
public DatabaseController(Context context, EventBus eventBus) {
    this.mEventBus = eventBus;
    //mEventBus.register(this);

    Paper.init(context);
    Paper.addSerializer(Bundle.class, new BundleSerializer());
    Paper.addSerializer(Media.class, new MediaSerializer());

    mBundleDao = new BundleDaoImpl();
    mMediaDao = new MediaDaoImpl();
}
 
开发者ID:resourcepool,项目名称:dashboard,代码行数:12,代码来源:DatabaseController.java


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