Java Code Examples for com.gianlu.commonutils.preferences.Prefs#putString()
The following examples show how to use
com.gianlu.commonutils.preferences.Prefs#putString() .
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: MultiProfile.java From Aria2App with GNU General Public License v3.0 | 6 votes |
@NonNull public static MultiProfile forInAppDownloader() { int port = ThreadLocalRandom.current().nextInt(2000, 8000); Prefs.putInt(Aria2PK.RPC_PORT, port); String token = CommonUtils.randomString(8, ThreadLocalRandom.current()); Prefs.putString(Aria2PK.RPC_TOKEN, token); MultiProfile profile = new MultiProfile(IN_APP_DOWNLOADER_NAME, true); profile.add(ConnectivityCondition.newUniqueCondition(), new ConnectionFragment.Fields(ConnectionMethod.WEBSOCKET, "localhost", port, "/jsonrpc", false, null, false), new AuthenticationFragment.Fields(AbstractClient.AuthMethod.TOKEN, token, null, null), new DirectDownloadFragment.Fields(null)); return profile; }
Example 2
Source File: PrefsJsonStoring.java From CommonUtils with Apache License 2.0 | 5 votes |
@Override public void putJsonArray(@NonNull String key, JSONArray array) { if (array == null) { Prefs.remove(key); return; } String str = array.toString(); str = Base64.encodeToString(str.getBytes(), Base64.NO_WRAP); Prefs.putString(key, str); }
Example 3
Source File: PrefsJsonStoring.java From CommonUtils with Apache License 2.0 | 5 votes |
@Override public void putJsonObject(@NonNull String key, JSONObject obj) { if (obj == null) { Prefs.remove(key); return; } String str = obj.toString(); str = Base64.encodeToString(str.getBytes(), Base64.NO_WRAP); Prefs.putString(key, str); }
Example 4
Source File: AnalyticsApplication.java From CommonUtils with Apache License 2.0 | 5 votes |
@Override @CallSuper public void onCreate() { super.onCreate(); String uuid = Prefs.getString(CommonPK.ANALYTICS_USER_ID, null); if (uuid == null) { uuid = UUID.randomUUID().toString(); Prefs.putString(CommonPK.ANALYTICS_USER_ID, uuid); } if (FossUtils.hasFirebaseCrashlytics()) { if (Prefs.getBoolean(CommonPK.CRASH_REPORT_ENABLED)) { FirebaseCrashlytics.getInstance().setUserId(uuid); CRASHLYTICS_ENABLED = true; } else { CRASHLYTICS_ENABLED = false; } } else { Prefs.putBoolean(CommonPK.CRASH_REPORT_ENABLED, false); } if (FossUtils.hasFirebaseAnalytics()) { ANALYTICS = FirebaseAnalytics.getInstance(this); if (Prefs.getBoolean(CommonPK.TRACKING_ENABLED)) { ANALYTICS.setUserId(uuid); ANALYTICS.setAnalyticsCollectionEnabled(true); } else { ANALYTICS.setAnalyticsCollectionEnabled(false); ANALYTICS = null; } } else { Prefs.putBoolean(CommonPK.TRACKING_ENABLED, false); } }
Example 5
Source File: PreferenceActivity.java From Aria2App with GNU General Public License v3.0 | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == DOWNLOAD_PATH_CODE) { if (resultCode == RESULT_OK && isAdded() && data.getData() != null) { DocumentFile file = DocumentFile.fromTreeUri(requireContext(), data.getData()); if (file != null) Prefs.putString(PK.DD_DOWNLOAD_PATH, file.getUri().toString()); } return; } super.onActivityResult(requestCode, resultCode, data); }
Example 6
Source File: RegisteredPyx.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 5 votes |
RegisteredPyx(Server server, LifecycleAwareHandler handler, OkHttpClient client, FirstLoadAndConfig firstLoad, User user) { super(server, handler, client, firstLoad); this.user = user; this.pollingThread = new PollingThread(); this.pollingThread.start(); Prefs.putString(PK.LAST_JSESSIONID, user.sessionId); AnalyticsApplication.setCrashlyticsString("server", server.url.toString()); }
Example 7
Source File: MainActivity.java From Aria2App with GNU General Public License v3.0 | 4 votes |
private void handleSortingReal(DownloadCardsAdapter.SortBy sorting) { if (adapter != null) adapter.sort(sorting); Prefs.putString(PK.A2_MAIN_SORTING, sorting.name()); }
Example 8
Source File: ProfilesManager.java From Aria2App with GNU General Public License v3.0 | 4 votes |
public void setLastProfile(@NonNull MultiProfile profile) { Prefs.putString(PK.LAST_USED_PROFILE, profile.id); }
Example 9
Source File: LoadingActivity.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 4 votes |
private void setServer(@NonNull Pyx.Server server) { Pyx.invalidate(); Prefs.putString(PK.LAST_SERVER, server.name); currentServer.setText(server.name); }