realm

Writing realm from service class causing UI block

限于喜欢 提交于 2019-12-12 07:01:49
问题 I am writing realm db from my LocationService class on every location change listener and listing this change in Activity to update the UI. Initially it works fine, however when number of entries in realm db exceeds 2K, it is started blocking the UI. Anyone please suggest. 回答1: Yes, the problem is that Service run in MainThread (UI thread by default). you need to write data asynchronously on background thread. Notice, that Realm instance is thread dependent and it has to be obrained and

Realm + Object Mapper + SwityJSON

删除回忆录丶 提交于 2019-12-12 06:36:26
问题 I need help in mapping my object Realm Model: https://gist.github.com/n1tesh/7d6c6e155285dd6b39c8edba76f6eba5 This is how I'm doing // write request result to realm database let entries = json["data"] realm.beginWrite() let entry: ChatGroups = Mapper<ChatGroups>().map(JSONObject: entries)! realm.add(entry, update: true) do { try realm.commitWrite() } catch { } JSON Response: https://gist.github.com/n1tesh/bf84cbd930f8c76b340f21723a217ebe But i'm getting error fatal error: unexpectedly found

Realm - Copy Realm Object to Another Realm Object Type

老子叫甜甜 提交于 2019-12-12 05:30:03
问题 I am trying to copy one realm object data to another realm object data. Is this possible without having to set each property individually? I am doing the following but the app just stops responding and ends up crashing. Realm realmThread = Realm.getDefaultInstance(); PropertyObject currProperty = realmThread.where(PropertyObject.class).equalTo("propertyId", propertyId).findFirst(); if (currProperty != null) { int propertyFollow = Integer.parseInt(params[1]); realmThread.beginTransaction();

MapStruct - mapping RealmList relationship

帅比萌擦擦* 提交于 2019-12-12 05:28:43
问题 Okay, I'm not very sure how to ask this but I'm going to try. I am using MapStruct to map my incoming network objects to database objects. I use Realm.io as my local datastore. Some of my objects have RealmList<Obj> which store their relationships, for example: public class Client extends RealmObject { @PrimaryKey private String id = UUID.randomUUID().toString(); private Date createdAt = new Date(); private Date updatedAt = new Date(); private RealmList<Contact> contacts; // <-- this guy //

Realm not query string field with whitespace

北城以北 提交于 2019-12-12 04:55:26
问题 I have such function in my data source: func getAllFood(by type: String) -> [UserFoodInformation] { var findedFood = [UserFoodInformation]() findedFood.append(contentsOf: baseUserFoodDataSource.getAllFood(by: type)) let predicate = NSPredicate(format: "foodType == %@", type) let resultOfSearching = dataBase.objects(AddedUserFood.self).filter(predicate).sorted(byKeyPath: "name") for searchedFood in resultOfSearching { findedFood.append(searchedFood) } return findedFood } When I try to query

Realm Swift: retrieve user, object not returned when launching app

送分小仙女□ 提交于 2019-12-12 04:47:09
问题 I use Realm to store user information. When I launch the app, I look into the Realm database to see if there is a user object (to determine if the user is logged in or logged out). Here's my code: func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let config=Realm.Configuration( schemaVersion: 2, migrationBlock: { migration, oldSchemaVersion in if (oldSchemaVersion<1) || (oldSchemaVersion<2){ migration

RLMArray properties in unmanaged RLMObjects in Objective-C

落花浮王杯 提交于 2019-12-12 04:45:16
问题 I cannot find a good example code of this anywhere....but the information I find is contradictory and confusing... @interface DAORealmMetadata : RLMObject @property (nonatomic, copy) NSString* id; @end RLM_ARRAY_TYPE(DAORealmMetadata) @interface DAORealmBase : RLMObject @property (nonatomic, copy) NSString* id; @property (nonatomic, copy) RLMArray<DAORealmMetadata*><DAORealmMetadata>* metadata; @end RLM_ARRAY_TYPE(DAORealmBase) Question: Am I supposed to add @dynamic metadata in the

Realm Object-Level Notifications inside UICollectionViewCell's

不想你离开。 提交于 2019-12-12 04:35:22
问题 I have a collection view with Album objects. An Album could be favorited or unfavorited by tapping a button inside of the cell. The buttons image changes depending on if the Album is favorited or not. This part is easy and works. The problem I have is: If you select a cell, a new view controller appears with the Album object in the cell. Within this view controller, you can favorite or unfavorite the Album object. Now when I dismiss this view controller, the button in the cell is "not"

Realm Support for UWP

自作多情 提交于 2019-12-12 04:35:14
问题 I am working on a windows 10 app, and I have to store data locally, but I am new to Entity Framework, So kindly suggest me which database technique should i use for storing data locally? Also please someone let me know if Relam supports windows 10 apps for UWP? Thanks in advance. 回答1: Update: Realm released UWP support. Check the announcement here: https://news.realm.io/news/realm-mobile-database-for-universal-windows-platform/ Old answer: There an Issue, realm/realm-core#2059, discussing

Recyclerview is so slow with a lot of item [duplicate]

让人想犯罪 __ 提交于 2019-12-12 04:30:54
问题 This question already has answers here : how to implement filterable in RealmRecyclerViewAdapter (2 answers) Closed 3 years ago . I have made this code that could retrieve from realm 50k items and show it in recyclerview: public class ListAirportFragment extends Fragment { Realm realm; List<AirportR> airports = new ArrayList<>(); RealmResults<AirportR> airps; RecyclerView recyclerView; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)