本文整理匯總了Java中io.realm.RealmResults.get方法的典型用法代碼示例。如果您正苦於以下問題:Java RealmResults.get方法的具體用法?Java RealmResults.get怎麽用?Java RealmResults.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.realm.RealmResults
的用法示例。
在下文中一共展示了RealmResults.get方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import io.realm.RealmResults; //導入方法依賴的package包/類
@Override
public void init() {
RealmResults<TodoList> listResults = todoRepository.queryList(listId);
list = listResults.get(0);
view.initViews(list.getTitle());
bindData();
list.addChangeListener(new RealmChangeListener<RealmModel>() {
@Override
public void onChange(RealmModel element) {
if (view != null) {
bindData();
view.notifyDataChanged(list.getTitle());
}
}
});
}
示例2: init
import io.realm.RealmResults; //導入方法依賴的package包/類
@Override
public void init(long taskId) {
RealmResults<Task> taskResults = repository.queryTask(taskId);
if (taskResults.size() > 0) {
task = taskResults.get(0);
}
task.addChangeListener(new RealmChangeListener<RealmModel>() {
@Override
public void onChange(RealmModel element) {
task.getId();
view.updateViews(task);
}
});
view.initViews();
view.updateViews(task);
}
示例3: fetchRandomMovieOrTvSeries
import io.realm.RealmResults; //導入方法依賴的package包/類
private Movie fetchRandomMovieOrTvSeries() {
Realm realm = Realm.getDefaultInstance();
//TODO: Add Random TV Series to fetch
RealmResults<Movie> movieRealmResults = realm.where(Movie.class).equalTo("isNotified", false).findAll();
Util.debugLog(TAG, "fetchRandomMovieOrTvSeries: Size of movies with isNotified false " + movieRealmResults.size());
if (movieRealmResults.size() != 0) {
Random r = new Random();
int randomNumber = r.nextInt(movieRealmResults.size());
Movie movie = movieRealmResults.get(randomNumber);
realm.beginTransaction();
movieRealmResults.get(randomNumber).setNotified(true);
realm.commitTransaction();
return movie;
} else {
return null;
}
}
示例4: saveData
import io.realm.RealmResults; //導入方法依賴的package包/類
private void saveData(List<Android> data) {//刷新時才調用到
RealmResults<Android> all = mRealm.where(Android.class).findAll();
if (all.size() > 0) {
Android android = all.get(0);
if (android != null) {
if (!(android.content).equals(data.get(0).content)) {
mRealm.executeTransaction(realm -> {
items.clear();
time2 = "";
realm.delete(Android.class);
realm.copyToRealmOrUpdate(data);
});
} else {//數據一樣不保存,同時不做 Adapter 刷新
mPage = mPageIndex;
AppUtils.toast(R.string.tip_no_new_data);
mView.hideLoading();
}
}
} else {
mRealm.executeTransaction(realm -> realm.copyToRealmOrUpdate(data));
}
}
示例5: saveData
import io.realm.RealmResults; //導入方法依賴的package包/類
private void saveData(List<Content> data) {
RealmResults<Content> all = mRealm.where(Content.class).findAll();
if (all.size() > 0) {
Content content = all.get(0);
if (content != null) {
if (!(content.content).equals(data.get(0).content)) {
mRealm.executeTransaction(realm -> {
realm.delete(Android.class);
mList.clear();
mList.addAll(data);
realm.copyToRealmOrUpdate(data);
});
} else {//數據一樣不保存,同時不做 Adapter 刷新
mPage = mPageIndex;
AppUtils.toast(R.string.tip_no_new_data);
mView.hideLoading();
}
}
} else {
mList.addAll(data);
mRealm.executeTransaction(realm -> realm.copyToRealmOrUpdate(data));//第一次進入應用時
}
}
示例6: saveData
import io.realm.RealmResults; //導入方法依賴的package包/類
private void saveData(List<IOS> data) {//刷新時才調用到
RealmResults<IOS> all = mRealm.where(IOS.class).findAll();
if (all.size() > 0) {
IOS ios = all.get(0);
if (ios != null) {
if (!(ios.content).equals(data.get(0).content)) {
mRealm.executeTransaction(realm -> {
items.clear();
time2 = "";
realm.delete(IOS.class);
realm.copyToRealmOrUpdate(data);
});
} else {//數據一樣不保存,同時不做 Adapter 刷新
mPage = mPageIndex;
AppUtils.toast(R.string.tip_no_new_data);
mView.hideLoading();
}
}
} else {
mRealm.executeTransaction(realm -> realm.copyToRealmOrUpdate(data));
}
}
示例7: generateSeasons
import io.realm.RealmResults; //導入方法依賴的package包/類
private void generateSeasons() {
try {
dataLoaded = true;
seasonList.clear();
Realm realm = RealmSingleton.getInstance().getRealm();
RealmResults<RealmEpisode> episodes = realm.where(RealmEpisode.class)
.equalTo("showID", showID)
.equalTo("episodeNumber", 1)
.distinct("seasonNumber")
.sort("seasonNumber", Sort.DESCENDING);
for (int i = 0; i < episodes.size(); i++) {
RealmEpisode temp = episodes.get(i);
int seasonNumber = temp.getSeasonNumber();
if (seasonNumber == 0) {
seasonList.add(new SeasonItem("Specials", temp.getEpisodeID(), seasonNumber));
} else {
seasonList.add(new SeasonItem("Season " + seasonNumber, temp.getEpisodeID(), seasonNumber));
}
}
if (episodes.size() != 0) {
mSeasonFragmentAdapter.notifyDataSetChanged();
} else {
tvError.setVisibility(View.VISIBLE);
}
} catch (Exception e) {
Log.e("SeasonFragment", String.valueOf(e));
}
}
示例8: getCurrentActivity
import io.realm.RealmResults; //導入方法依賴的package包/類
@NonNull
private String getCurrentActivity(Context context) {
String packageName = null;
String activityName = null;
String applicationName;
switch (Settings.getString(Settings.Mode.SELECTION, Settings.Mode.NONE)) {
case Settings.Mode.ROOT:
String request = SU.getSU().runCommand("dumpsys activity | grep \"mFocusedActivity\"");
if (!TextUtils.isEmpty(request)) {
String requests[] = request.split(" ")[3].split("/");
packageName = requests[0];
activityName = requests[1].substring(0, 1).equals(".") ? requests[0] + requests[1] : requests[1];
}
break;
case Settings.Mode.ACCESSIBILITY_SERVICE:
if (AccessibilityServiceUtils.isAccessibilityServiceEnabled(context, CurrentActivityAccessibilityService.class)) {
packageName = CurrentActivityAccessibilityService.foregroundPackageName();
activityName = CurrentActivityAccessibilityService.foregroundClassName();
if (packageName.equals("null") || activityName.equals("null")) return "";
} else {
return context.getString(R.string.should_re_enable_accessibility_service);
}
break;
}
if (packageName != null && activityName != null) {
applicationName = ApplicationUtil.getApplicationNameByPackageName(context, packageName);
if (applicationName != null) {
RealmResults<CurrentActivityData> results = realm.where(CurrentActivityData.class).findAll();
if (!Objects.equals(packageName, getPackageName())) {
if (results.isEmpty()) {
saveCurrentActivityData(applicationName, packageName, activityName);
} else {
CurrentActivityData lastData = results.get(results.size() - 1);
if (!Objects.equals(lastData.getPackageName(), packageName) || !Objects.equals(lastData.getActivityName(), activityName))
saveCurrentActivityData(applicationName, packageName, activityName);
}
}
return (applicationName + " ( " + packageName + " )" + "\n" + activityName);
} else {
return (packageName + "\n" + activityName);
}
} else {
return context.getString(R.string.failed_to_get);
}
}
示例9: deleteBlog
import io.realm.RealmResults; //導入方法依賴的package包/類
public static void deleteBlog(@NonNull String blogUrl) {
RealmResults<BlogMetadata> matchingBlogs = findAllBlogsMatchingUrl(blogUrl);
if (matchingBlogs.isEmpty()) {
throw new IllegalStateException("No blog found matching the URL: " + blogUrl);
}
// we don't allow adding more than 1 blog with the same URL, so this should never happen
if (matchingBlogs.size() > 1) {
throw new IllegalStateException("More than 1 blog found matching the URL: " + blogUrl);
}
// delete blog metadata before data because data without metadata is harmless, but vice-versa is not
// keep a copy of the metadata around so we can delete the data Realm after this
final Realm realm = Realm.getDefaultInstance();
BlogMetadata blogToDelete = matchingBlogs.get(0);
RealmConfiguration dataRealmToDelete = realm.copyFromRealm(blogToDelete).getDataRealmConfig();
RealmUtils.executeTransaction(realm, r -> {
RealmObject.deleteFromRealm(blogToDelete);
});
// delete blog data
Realm.deleteRealm(dataRealmToDelete);
// if the active blog was deleted, set the active blog to a different one
if (blogUrl.equals(getActiveBlogUrl())) {
List<BlogMetadata> allBlogs = getAllBlogs();
if (!allBlogs.isEmpty()) {
setActiveBlog(allBlogs.get(0).getBlogUrl());
} else {
setActiveBlog("");
}
}
}
示例10: getLastGlucoseReading
import io.realm.RealmResults; //導入方法依賴的package包/類
public GlucoseReading getLastGlucoseReading() {
RealmResults<GlucoseReading> results =
realm.where(GlucoseReading.class)
.findAllSorted("created", Sort.DESCENDING);
return results.get(0);
}