I am building a Java android app and I am using realm.io for my database. My problem is I have a RealmList and my Custom ListView adapter only accepts RealmResults. Below is the code and more details.
I have an Chat class that has a RealmList, RealmList, userId and a chatId.
public class Chat extends RealmObject{
private RealmList<Friend> participants;
private RealmList<Message> messages;
@PrimaryKey
private String chatId;
private String userId;
...
}
In my activity where I am trying to display all the messages that the chat has, I can call chat.getMessages() to get all the messages for this chat as a RealmList but my ListView adapter below takes a RealmResult because it extends RealmBaseAdapter
public class MessageAdapter extends RealmBaseAdapter<Message> implements ListAdapter {
private String TAG = getClass().getSimpleName();
public MessageAdapter(Context context,
RealmResults<Message> realmResults,
boolean automaticUpdate) {
super(context, realmResults, automaticUpdate);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null)
{
convertView = inflater.inflate(R.layout.listitem_message, parent, false);
}
Message message = getRealmResults().get(position);
if (message != null)
{
((TextView) convertView.findViewById(R.id.message_content)).setText(message.getContent());
DateFormat dateFormat = new SimpleDateFormat("HH:mm", Locale.CANADA);
((TextView) convertView.findViewById(R.id.message_time)).setText(dateFormat.format(message.getTimestamp()));
}
return convertView;
}
public RealmResults<Message> getRealmResults() {
return realmResults;
}
}
Here is where I call it all
RealmList<Message> messages = chat.getMessages();
ListView messageList = (ListView) findViewById(R.id.message_list);
adapter = new MessageAdapter(this, messages, true);
messageList.setAdapter(adapter);
I am open to changing my RealmList to a RealmResult if possible (I have looked and it doesn't seem to be) or If I can use a RealmList in the custom realm adapter that would another solution. Anything to help me move forward would be great help.
thanks
Steps 1 Close your current WoW gaming session. The realmlist can only be changed successfully if you’re logged completely out of WoW. 2 Navigate to the WoW folder using File Explorer in Windows or Finder on Mac OS X. ... 3 Open the “Data” folder, then open the “enUS” folder. Mais itens...
If you experience difficulty with locating the realmlist file using File Explorer or Finder, type "realmlist.wtf" into the search bar to navigate directly to this file. Double-click on the "realmlist.wtf" file, and select the option to open the file using Notepad, TextEdit, or any other text-editing program of your choice.
2 Realm has some new features check-in documentation Realm Documentation Realm has copyfromRealm function which we can use to convert the result to list RealmList<Student> student=realm.copyfromRealm(Realmresult); Share Improve this answer Follow
The Realmlist is a special text file in World of Warcraft (WoW) that informs the WoW client which server you need to connect to. Setting, or changing the realmlist is crucial for players who want to play WoW on a private server. The...
Just do
chat.getMessages().where().findAll()
(Answer from here)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With