Java Code Examples for io.paperdb.Paper#init()
The following examples show how to use
io.paperdb.Paper#init() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: App.java From NMSAlphabetAndroidApp with MIT License | 6 votes |
@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(); }
Example 2
Source File: battery_service.java From telegram-sms with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onCreate() { super.onCreate(); context = getApplicationContext(); Paper.init(context); SharedPreferences sharedPreferences = context.getSharedPreferences("data", MODE_PRIVATE); chat_id = sharedPreferences.getString("chat_id", ""); bot_token = sharedPreferences.getString("bot_token", ""); doh_switch = sharedPreferences.getBoolean("doh_switch", true); final boolean charger_status = sharedPreferences.getBoolean("charger_status", false); battery_receiver = new battery_receiver(); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_BATTERY_OKAY); filter.addAction(Intent.ACTION_BATTERY_LOW); filter.addAction(public_func.BROADCAST_STOP_SERVICE); if (charger_status) { filter.addAction(Intent.ACTION_POWER_CONNECTED); filter.addAction(Intent.ACTION_POWER_DISCONNECTED); } registerReceiver(battery_receiver, filter); }
Example 3
Source File: PaperDeprecatedAPITest.java From Paper with Apache License 2.0 | 5 votes |
@Test public void testPutGetNormalAfterReinit() { Paper.put("city", "Lund"); String val = Paper.get("city", "default"); Paper.init(getTargetContext());// Reinit Paper instance assertThat(val).isEqualTo("Lund"); }
Example 4
Source File: Benchmark.java From Paper with Apache License 2.0 | 5 votes |
@Test public void testWrite500Contacts() throws Exception { final List<Person> contacts = TestDataGenerator.genPersonList(500); Paper.init(getTargetContext()); Paper.book().destroy(); long paperTime = runTest(new PaperWriteContactsTest(), contacts, REPEAT_COUNT); Hawk.init(getTargetContext()); Hawk.clear(); long hawkTime = runTest(new HawkWriteContactsTest(), contacts, REPEAT_COUNT); printResults("Write 500 contacts", paperTime, hawkTime); }
Example 5
Source File: boot_receiver.java From telegram-sms with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onReceive(final Context context, Intent intent) { final String TAG = "boot_receiver"; Log.d(TAG, "Receive action: " + intent.getAction()); final SharedPreferences sharedPreferences = context.getSharedPreferences("data", Context.MODE_PRIVATE); if (sharedPreferences.getBoolean("initialized", false)) { Paper.init(context); public_func.write_log(context, "Received [" + intent.getAction() + "] broadcast, starting background service."); public_func.start_service(context, sharedPreferences.getBoolean("battery_monitoring_switch", false), sharedPreferences.getBoolean("chat_command", false)); if (Paper.book().read("resend_list", new ArrayList<>()).size() != 0) { Log.d(TAG, "An unsent message was detected, and the automatic resend process was initiated."); public_func.start_resend(context); } } }
Example 6
Source File: Benchmark.java From Paper with Apache License 2.0 | 5 votes |
@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); }
Example 7
Source File: App.java From ONE-Unofficial with Apache License 2.0 | 5 votes |
@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); }
Example 8
Source File: VkApplication.java From vk_music_android with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); if (!BuildConfig.DEBUG) { Fabric.with(this, new Crashlytics()); } appComponent = DaggerAppComponent.builder() .appModule(new AppModule(this)) .build(); vkAccessTokenTracker.startTracking(); VKSdk.initialize(this); Paper.init(this); Dexter.initialize(this); DrawerImageLoader.init(new AbstractDrawerImageLoader() { @Override public void set(ImageView imageView, Uri uri, Drawable placeholder, String tag) { Glide.with(imageView.getContext()) .load(uri) .into(imageView); } }); }
Example 9
Source File: PaperDeprecatedAPITest.java From Paper with Apache License 2.0 | 4 votes |
@Before public void setUp() throws Exception { Paper.clear(getTargetContext()); Paper.init(getTargetContext()); }
Example 10
Source File: ussd_request_callback.java From telegram-sms with BSD 3-Clause "New" or "Revised" License | 4 votes |
ussd_request_callback(Context context, SharedPreferences sharedPreferences, long message_id) { this.context = context; Paper.init(context); String chat_id = sharedPreferences.getString("chat_id", ""); this.doh_switch = sharedPreferences.getBoolean("doh_switch", true); this.request_body = new message_json(); this.request_body.chat_id = chat_id; String bot_token = sharedPreferences.getString("bot_token", ""); this.request_uri = public_func.get_url(bot_token, "SendMessage"); if (message_id != -1) { this.request_uri = public_func.get_url(bot_token, "editMessageText"); this.request_body.message_id = message_id; } this.message_header = context.getString(R.string.send_ussd_head); }
Example 11
Source File: DataTest.java From Paper with Apache License 2.0 | 4 votes |
@Before public void setUp() throws Exception { Paper.clear(getTargetContext()); Paper.init(getTargetContext()); }
Example 12
Source File: ReadBenchmark.java From Paper with Apache License 2.0 | 4 votes |
@Before public void setUp() { Paper.init(getTargetContext()); Paper.book().destroy(); }
Example 13
Source File: RxPaper.java From RxPaper with MIT License | 4 votes |
public static void init(Context context) { Paper.init(context); }
Example 14
Source File: MultiThreadTest.java From Paper with Apache License 2.0 | 4 votes |
@Before public void setUp() { Paper.init(getTargetContext()); Paper.book().destroy(); }
Example 15
Source File: PaperDataSaver.java From Android-NoSql with Apache License 2.0 | 4 votes |
public PaperDataSaver(Context context){ Paper.init(context); }
Example 16
Source File: public_func.java From telegram-sms with BSD 3-Clause "New" or "Revised" License | 4 votes |
static void add_resend_loop(Context context, String message) { ArrayList<String> resend_list; Paper.init(context); resend_list = Paper.book().read("resend_list", new ArrayList<>()); resend_list.add(message); Paper.book().write("resend_list", resend_list); start_resend(context); }
Example 17
Source File: chat_command_service.java From telegram-sms with BSD 3-Clause "New" or "Revised" License | 3 votes |
@SuppressLint({"InvalidWakeLockTag", "WakelockTimeout"}) @Override public void onCreate() { super.onCreate(); context = getApplicationContext(); Paper.init(context); sharedPreferences = context.getSharedPreferences("data", MODE_PRIVATE); chat_id = sharedPreferences.getString("chat_id", ""); bot_token = sharedPreferences.getString("bot_token", ""); okhttp_client = public_func.get_okhttp_obj(sharedPreferences.getBoolean("doh_switch", true), Paper.book().read("proxy_config", new proxy_config())); privacy_mode = sharedPreferences.getBoolean("privacy_mode", false); wifiLock = ((WifiManager) Objects.requireNonNull(context.getApplicationContext().getSystemService(Context.WIFI_SERVICE))).createWifiLock(WifiManager.WIFI_MODE_FULL, "bot_command_polling_wifi"); wakelock = ((PowerManager) Objects.requireNonNull(context.getSystemService(Context.POWER_SERVICE))).newWakeLock(android.os.PowerManager.PARTIAL_WAKE_LOCK, "bot_command_polling"); wifiLock.setReferenceCounted(false); wakelock.setReferenceCounted(false); if (!wifiLock.isHeld()) { wifiLock.acquire(); } if (!wakelock.isHeld()) { wakelock.acquire(); } thread_main = new Thread(new thread_main_runnable()); thread_main.start(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(public_func.BROADCAST_STOP_SERVICE); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); broadcast_receiver = new broadcast_receiver(); registerReceiver(broadcast_receiver, intentFilter); }
Example 18
Source File: notification_listener_service.java From telegram-sms with BSD 3-Clause "New" or "Revised" License | 3 votes |
@Override public void onCreate() { super.onCreate(); context = getApplicationContext(); Paper.init(context); sharedPreferences = context.getSharedPreferences("data", Context.MODE_PRIVATE); Notification notification = public_func.get_notification_obj(getApplicationContext(), getString(R.string.Notification_Listener_title)); startForeground(public_func.notification_listener_service_notify_id, notification); }
Example 19
Source File: resend_service.java From telegram-sms with BSD 3-Clause "New" or "Revised" License | 3 votes |
@Override public void onCreate() { super.onCreate(); context = getApplicationContext(); Paper.init(context); IntentFilter filter = new IntentFilter(); filter.addAction(public_func.BROADCAST_STOP_SERVICE); receiver = new stop_notify_receiver(); registerReceiver(receiver, filter); SharedPreferences sharedPreferences = context.getSharedPreferences("data", MODE_PRIVATE); request_uri = public_func.get_url(sharedPreferences.getString("bot_token", ""), "SendMessage"); new Thread(() -> { resend_list = Paper.book().read(table_name, new ArrayList<>()); while (true) { if (public_func.check_network_status(context)) { ArrayList<String> send_list = resend_list; OkHttpClient okhttp_client = public_func.get_okhttp_obj(sharedPreferences.getBoolean("doh_switch", true), Paper.book().read("proxy_config", new proxy_config())); for (String item : send_list) { network_progress_handle(item, sharedPreferences.getString("chat_id", ""), okhttp_client); } if (resend_list == send_list) { break; } } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } public_func.write_log(context, "The resend failure message is complete."); stopSelf(); }).start(); }
Example 20
Source File: RxPaperBook.java From RxPaper with MIT License | 2 votes |
/** * Initializes the underlying {@link Paper} database. * <p/> * This operation is required only once, but can be called multiple times safely. * * @param context application context */ public static void init(Context context) { if (INITIALIZED.compareAndSet(false, true)) { Paper.init(context.getApplicationContext()); } }