当前位置: 首页>>代码示例>>Java>>正文


Java Sort类代码示例

本文整理汇总了Java中io.realm.Sort的典型用法代码示例。如果您正苦于以下问题:Java Sort类的具体用法?Java Sort怎么用?Java Sort使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Sort类属于io.realm包,在下文中一共展示了Sort类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadNewsFeed

import io.realm.Sort; //导入依赖的package包/类
/**
 * Loads the news feed as well as all future updates.
 */
@UiThread
public Flowable<RealmResults<NYTimesStory>> loadNewsFeed(@NonNull String sectionKey, boolean forceReload) {
    // Start loading data from the network if needed
    // It will put all data into Realm
    if (forceReload || timeSinceLastNetworkRequest(sectionKey) > MINIMUM_NETWORK_WAIT_SEC) {
        dataLoader.loadData(sectionKey, apiKey, realm, networkLoading);
        lastNetworkRequest.put(sectionKey, System.currentTimeMillis());
    }

    // Return the data in Realm. The query result will be automatically updated when the network requests
    // save data in Realm
    return realm.where(NYTimesStory.class)
            .equalTo(NYTimesStory.API_SECTION, sectionKey)
            .findAllSortedAsync(NYTimesStory.PUBLISHED_DATE, Sort.DESCENDING)
            .asFlowable();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:Repository.java

示例2: getInstance

import io.realm.Sort; //导入依赖的package包/类
private static SortDescriptor getInstance(
        FieldDescriptor.SchemaProxy proxy,
        Table table,
        String[] fieldDescriptions,
        @Nullable Sort[] sortOrders,
        Set<RealmFieldType> legalInternalTypes,
        Set<RealmFieldType> legalTerminalTypes,
        String message) {

    //noinspection ConstantConditions
    if (fieldDescriptions == null || fieldDescriptions.length == 0) {
        throw new IllegalArgumentException("You must provide at least one field name.");
    }

    long[][] columnIndices = new long[fieldDescriptions.length][];

    // Force aggressive parsing of the FieldDescriptors, so that only valid SortDescriptor objects are created.
    for (int i = 0; i < fieldDescriptions.length; i++) {
        FieldDescriptor descriptor = FieldDescriptor.createFieldDescriptor(proxy, table, fieldDescriptions[i], legalInternalTypes, null);
        checkFieldType(descriptor, legalTerminalTypes, message, fieldDescriptions[i]);
        columnIndices[i] = descriptor.getColumnIndices();
    }

    return new SortDescriptor(table, columnIndices, sortOrders);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:SortDescriptor.java

示例3: getInstanceForSort_multipleFields

import io.realm.Sort; //导入依赖的package包/类
@Test
public void getInstanceForSort_multipleFields() {
    RealmFieldType stringType = RealmFieldType.STRING;
    long stringColumn = table.addColumn(stringType, stringType.name());
    RealmFieldType intType = RealmFieldType.INTEGER;
    long intColumn = table.addColumn(intType, intType.name());

    SortDescriptor sortDescriptor = SortDescriptor.getInstanceForSort(null, table, new String[] {
            stringType.name(), intType.name()}, new Sort[] {Sort.ASCENDING, Sort.DESCENDING});

    assertEquals(2, sortDescriptor.getAscendings().length);
    assertEquals(2, sortDescriptor.getColumnIndices().length);

    assertEquals(1, sortDescriptor.getColumnIndices()[0].length);
    assertEquals(stringColumn, sortDescriptor.getColumnIndices()[0][0]);
    assertTrue(sortDescriptor.getAscendings()[0]);

    assertEquals(1, sortDescriptor.getColumnIndices()[1].length);
    assertEquals(intColumn, sortDescriptor.getColumnIndices()[1][0]);
    assertFalse(sortDescriptor.getAscendings()[1]);

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:SortDescriptorTests.java

示例4: getData

import io.realm.Sort; //导入依赖的package包/类
private void getData() {
    if (showID != -1) {

        result = realm.where(RealmEpisode.class)
                .equalTo("showID", showID)
                .equalTo("watched", false)
                .notEqualTo("seasonNumber", 0)
                .findAllSortedAsync("details", Sort.ASCENDING);
        result.addChangeListener(callback);

    } else {

        singleEpisode = realm.where(RealmEpisode.class)
                .equalTo("episodeID", episodeID)
                .findFirstAsync();
        singleEpisode.addChangeListener(singleEpisodeCallback);

    }
}
 
开发者ID:chashmeetsingh,项目名称:TrackIt-Android,代码行数:20,代码来源:EpisodeDetailFragment.java

示例5: getResults

import io.realm.Sort; //导入依赖的package包/类
private RealmResults<Album> getResults() {
    RealmResults<Album> results = null;
    switch (Media.getSortType()) {
        case ALPHABETICAL: {
            if (Media.isShowHidden()) {
                results = realm.where(Album.class).findAll().sort("name", Media.isSortAscending() ? Sort.ASCENDING : Sort.DESCENDING);
                break;
            } else {
                results = realm.where(Album.class).equalTo("hidden", false).findAll().sort("name", Media.isSortAscending() ? Sort.ASCENDING : Sort.DESCENDING);
                break;
            }
        }
        case SIZE: {
            if (Media.isShowHidden()) {
                results = realm.where(Album.class).findAll().sort("size", Media.isSortAscending() ? Sort.ASCENDING : Sort.DESCENDING);
                break;
            } else {
                results = realm.where(Album.class).equalTo("hidden", false).findAll().sort("size", Media.isSortAscending() ? Sort.ASCENDING : Sort.DESCENDING);
                break;
            }
        }
    }
    return results;
}
 
开发者ID:garretyoder,项目名称:Cluttr,代码行数:25,代码来源:AlbumPickerFragment.java

示例6: updateCoverPhotos

import io.realm.Sort; //导入依赖的package包/类
public static void updateCoverPhotos() {
    long time = System.currentTimeMillis();
    Realm realm = Realm.getDefaultInstance();
    realm.beginTransaction();
    for (Album a : realm.where(Album.class).findAll()) {
        switch (Media.getMediaSortType()) {
            case ALPHABETICAL: {
                a.setCoverPath(a.getMedia().sort("name", Media.isMediaSortAscending() ? Sort.ASCENDING : Sort.DESCENDING).first().getPath());
                break;
            }
            case DATE: {
                a.setCoverPath(a.getMedia().sort("date", Media.isMediaSortAscending() ? Sort.ASCENDING : Sort.DESCENDING).first().getPath());
                break;
            }
        }
    }
    realm.commitTransaction();
    realm.close();
    Log.d(Util.LOG_TAG, "Reloading all cover photos took " + (System.currentTimeMillis() - time));
}
 
开发者ID:garretyoder,项目名称:Cluttr,代码行数:21,代码来源:MediaLoader.java

示例7: updateSingleCover

import io.realm.Sort; //导入依赖的package包/类
public static void updateSingleCover(String key) {
    long time = System.currentTimeMillis();
    Realm realm = Realm.getDefaultInstance();
    realm.beginTransaction();
    Album a = realm.where(Album.class).equalTo("path",key).findFirst();
    switch (Media.getMediaSortType()) {
        case ALPHABETICAL: {
            a.setCoverPath(a.getMedia().sort("name", Media.isMediaSortAscending() ? Sort.ASCENDING : Sort.DESCENDING).first().getPath());
            break;
        }
        case DATE: {
            a.setCoverPath(a.getMedia().sort("date", Media.isMediaSortAscending() ? Sort.ASCENDING : Sort.DESCENDING).first().getPath());
            break;
        }
    }
    realm.commitTransaction();
    realm.close();
    Log.d(Util.LOG_TAG, "Reloading all cover photos took " + (System.currentTimeMillis() - time));
}
 
开发者ID:garretyoder,项目名称:Cluttr,代码行数:20,代码来源:MediaLoader.java

示例8: searchCompanies

import io.realm.Sort; //导入依赖的package包/类
@Override
public Observable<List<Company>> searchCompanies(@NonNull String keyWords) {
    Realm rlm = RealmHelper.newRealmInstance();
    List<Company> results = rlm.copyFromRealm(
            rlm.where(Company.class)
                    .like("name","*" + keyWords + "*", Case.INSENSITIVE)
                    .or()
                    .like("tel", "*" + keyWords + "*", Case.INSENSITIVE)
                    .or()
                    .like("website", "*" + keyWords + "*", Case.INSENSITIVE)
                    .or()
                    .like("alphabet", "*" + keyWords + "*", Case.INSENSITIVE)
                    .findAllSorted("alphabet", Sort.ASCENDING));
    return Observable.fromIterable(results)
            .toList()
            .toObservable();
}
 
开发者ID:TonnyL,项目名称:Espresso,代码行数:18,代码来源:CompaniesLocalDataSource.java

示例9: findAllProfil

import io.realm.Sort; //导入依赖的package包/类
/**
 * method mencari semua Profil
 */
public ArrayList<ProfilModel> findAllProfil(){
    ArrayList<ProfilModel> data = new ArrayList<>();

    realmResultProfil = realm.where(Profil.class).findAll();
    realmResultProfil.sort("id", Sort.DESCENDING);
    if (realmResultProfil.size() > 0){
        showLog("Size : " + realmResultProfil.size());

        for (int i = 0; i < realmResultProfil.size(); i++) {
            String nama, email, instansi;
            int id = realmResultProfil.get(i).getId();
            nama = realmResultProfil.get(i).getNama();
            email = realmResultProfil.get(i).getEmail();
            instansi = realmResultProfil.get(i).getInstansi();
            data.add(new ProfilModel(id, nama, email, instansi));
        }

    } else {
        showLog("Size : 0");
    }

    return data;
}
 
开发者ID:setakarim,项目名称:ingetin,代码行数:27,代码来源:RealmHelper.java

示例10: findAllLainnya

import io.realm.Sort; //导入依赖的package包/类
/**
 * method mencari semua Lainnya
 */
public ArrayList<LainnyaModel> findAllLainnya(){
    ArrayList<LainnyaModel> data = new ArrayList<>();

    realmResultLainnya = realm.where(Lainnya.class).findAll();
    realmResultLainnya.sort("id", Sort.DESCENDING);
    if (realmResultLainnya.size() > 0){
        showLog("Size : " + realmResultLainnya.size());

        for (int i = 0; i < realmResultLainnya.size(); i++) {
            String judul, jenis, deadline, deskripsi, done;
            int id = realmResultLainnya.get(i).getId();
            judul = realmResultLainnya.get(i).getJudul();
            deadline = realmResultLainnya.get(i).getDeadline();
            deskripsi = realmResultLainnya.get(i).getDeskripsi();
            done = realmResultLainnya.get(i).getDone();
            data.add(new LainnyaModel(id, judul, deadline, deskripsi, done));
        }

    } else {
        showLog("Size : 0");
    }

    return data;
}
 
开发者ID:setakarim,项目名称:ingetin,代码行数:28,代码来源:RealmHelper.java

示例11: getAll

import io.realm.Sort; //导入依赖的package包/类
@Override
public Iterable<Preview> getAll(ItemsPerPreview itemsPerPreview) {
    Realm realm = Realm.getInstance(configuration);
    RealmResults<TodoListDAO> allTodoListDAO = realm.where(TodoListDAO.class).findAllSorted("position", Sort.DESCENDING);
    RealmResults<NoteDAO> allNoteDAO = realm.where(NoteDAO.class).findAllSorted("position", Sort.DESCENDING);

    List<Preview> previews = new ArrayList<>(allTodoListDAO.size() + allNoteDAO.size());

    for (TodoListDAO todoListDAO : allTodoListDAO) {
        previews.add(constructPreview(realm, todoListDAO, itemsPerPreview));
    }
    for (NoteDAO noteDAO : allNoteDAO) {
        previews.add(new NotePreview(RealmConverter.convert(noteDAO)));
    }
    realm.close();
    return previews;
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:18,代码来源:PreviewRepositoryImpl.java

示例12: getItemPreviewOfHeader

import io.realm.Sort; //导入依赖的package包/类
private List<TodoListItem> getItemPreviewOfHeader(Realm realm, TodoListHeader header, ItemsPerPreview itemsPerPreview) {
    if (header == null || itemsPerPreview.areZero()) return new ArrayList<>(0);

    RealmResults<TodoListItemDAO> itemDAOs = realm.where(TodoListItemDAO.class)
            .equalTo("parentTodoListUuid", header.getParentTodoListUuid())
            .equalTo("parentHeaderUuid", header.getUuid())
            .findAllSorted("position", Sort.DESCENDING);

    int size = Math.min(itemDAOs.size(), itemsPerPreview.getCount());
    List<TodoListItem> items = new ArrayList<>(size);
    if (size > 0) {
        for (TodoListItemDAO itemDAO : itemDAOs.subList(0, size)) {
            items.add(RealmConverter.convert(itemDAO));
        }
    }
    return items;
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:18,代码来源:PreviewRepositoryImpl.java

示例13: parseRawData

import io.realm.Sort; //导入依赖的package包/类
static void parseRawData() {
    Realm realmRawData = Realm.getInstance(realmConfigRawData);
    Realm realmProcessedData = Realm.getInstance(realmConfigProcessedData);

    // if processed data realm is empty
    if (realmProcessedData.isEmpty() && !realmRawData.isEmpty()) {
        // parse data from raw realm into processed data realm
        Log.i(LOG_ID, "Parsing data raw_data realm to processed_data realm.");
        realmProcessedData.beginTransaction();
        for (RawTagData rawTagData : realmRawData.where(RawTagData.class)
                        .findAllSorted(RawTagData.DATE, Sort.ASCENDING)) {
            realmProcessedData.copyToRealmOrUpdate(new ReadingData(rawTagData));
        }
        realmProcessedData.commitTransaction();
    }

    realmProcessedData.close();
    realmRawData.close();
}
 
开发者ID:DorianScholz,项目名称:OpenLibre,代码行数:20,代码来源:OpenLibre.java

示例14: onCreateView

import io.realm.Sort; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_log_list, container, false);

    // Set the adapter
    if (view instanceof RecyclerView) {
        Context context = view.getContext();
        RecyclerView recyclerView = (RecyclerView) view;
        recyclerView.setLayoutManager(new LinearLayoutManager(context));
        recyclerView.setAdapter(new LogRecyclerViewAdapter(this,
                mRealmProcessedData
                        .where(ReadingData.class)
                        .isNotEmpty(ReadingData.TREND)
                        .findAllSortedAsync(ReadingData.DATE, Sort.DESCENDING)
        ));
        recyclerView.setHasFixedSize(true);
        recyclerView.addItemDecoration(
                new DividerItemDecoration(this.getContext(), DividerItemDecoration.VERTICAL_LIST)
        );
        registerForContextMenu(recyclerView);
    }
    return view;
}
 
开发者ID:DorianScholz,项目名称:OpenLibre,代码行数:25,代码来源:LogFragment.java

示例15: getLatestNewsFromDB

import io.realm.Sort; //导入依赖的package包/类
Observable<LatestNews> getLatestNewsFromDB() {
    return Observable.fromCallable(new Callable<LatestNews>() {
        @Override
        public LatestNews call() throws Exception {
            Realm realm = Realm.getDefaultInstance();
            RealmResults<LatestNewsDB> result;
            LatestNews latestNews;
            try {
                result = realm.where(LatestNewsDB.class).findAll();
                result = result.sort("date", Sort.DESCENDING);
                if (result.size() < 1) {
                    return null;
                }
                latestNews = Mapper.getLatestNews(result);
                return latestNews;
            } finally {
                if (realm != null) {
                    realm.close();
                }
            }
        }
    });
}
 
开发者ID:wl9739,项目名称:DuDian,代码行数:24,代码来源:DiskRepository.java


注:本文中的io.realm.Sort类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。