• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Function0类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: before

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
@Before
public void before() throws Exception {
    Answer<Cancelable> runAndReturn = new Answer<Cancelable>() {
        @Override
        public Cancelable answer(InvocationOnMock invocation) throws Exception {
            try {
                Function0<Unit> block = invocation.getArgument(0);
                block.invoke();
            } catch (Exception e) {
                e.printStackTrace();
                Assert.fail(e.getMessage());
            }
            return canceler;
        }
    };
    doAnswer(runAndReturn).when(mockRunner).runWithCancel(ArgumentMatchers.<Function0<Unit>>any());
    doAnswer(runAndReturn).when(mockRunner).run(ArgumentMatchers.<Function0<Unit>>any());
}
 
开发者ID:gladed,项目名称:kotlin-late,代码行数:19,代码来源:LateTest.java


示例2: onReceive

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
@Override
public void onReceive(Context context, final Intent intent) {
    if (!isDeviceChangeStateToOnline(App.Companion.getAppContext()) || inWork.get()) return;
    inWork.set(true);
    mainHandler.post(new Function0<Unit>() {
        @Override
        public Unit invoke() {
            internetEnabledPoster.internetEnabled();
            return Unit.INSTANCE;
        }
    });


    threadPoolExecutor.execute(new Runnable() {
        @Override
        public void run() {
            processViewAssignments();
            processViewedNotifications();
            inWork.set(false);
        }
    });
}
 
开发者ID:StepicOrg,项目名称:stepik-android,代码行数:23,代码来源:InternetConnectionEnabledReceiver.java


示例3: makeLessonCached

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
@WorkerThread
private void makeLessonCached(final long lessonId) {
    final Lesson lesson = databaseFacade.getLessonById(lessonId);
    if (lesson == null) {
        analytic.reportError(Analytic.Error.LESSON_IN_STORE_STATE_NULL, new NullPointerException("lesson was null"));
        return;
    }

    lesson.set_loading(false);
    lesson.set_cached(true);

    databaseFacade.updateOnlyCachedLoadingLesson(lesson);
    mainHandler.post(new Function0<kotlin.Unit>() {
        @Override
        public kotlin.Unit invoke() {
            for (LessonCallback callback : lessonCallbackContainer.asIterable()) {
                callback.onLessonCached(lessonId);
            }
            return kotlin.Unit.INSTANCE;
        }
    });
}
 
开发者ID:StepicOrg,项目名称:stepik-android,代码行数:23,代码来源:StoreStateManagerImpl.java


示例4: updateSectionAfterDeleting

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
@Override
public void updateSectionAfterDeleting(long sectionId) {
    final Section section = databaseFacade.getSectionById(sectionId);
    if (section == null) {
        analytic.reportError(Analytic.Error.NULL_SECTION, new Exception("update Section after deleting"));
        return;
    }
    if (section.isCached() || section.isLoading()) {
        section.setCached(false);
        section.setLoading(false);
        databaseFacade.updateOnlyCachedLoadingSection(section);
        mainHandler.post(
                new Function0<kotlin.Unit>() {
                    @Override
                    public kotlin.Unit invoke() {
                        for (SectionCallback callback : sectionCallbackContainer.asIterable()) {
                            callback.onSectionNotCached(section.getId());
                        }
                        return kotlin.Unit.INSTANCE;
                    }
                }
        );
    }
}
 
开发者ID:StepicOrg,项目名称:stepik-android,代码行数:25,代码来源:StoreStateManagerImpl.java


示例5: makeSectionCached

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
@WorkerThread
private void makeSectionCached(long sectionId) {
    //all units, lessons, steps of section are cached
    final Section section = databaseFacade.getSectionById(sectionId);
    if (section == null) {
        analytic.reportError(Analytic.Error.NULL_SECTION, new Exception("update section state"));
        return;
    }

    section.setCached(true);
    section.setLoading(false);
    databaseFacade.updateOnlyCachedLoadingSection(section);

    mainHandler.post(new Function0<kotlin.Unit>() {
        @Override
        public kotlin.Unit invoke() {
            for (SectionCallback callback : sectionCallbackContainer.asIterable()) {
                callback.onSectionCached(section.getId());
            }
            return kotlin.Unit.INSTANCE;
        }
    });
}
 
开发者ID:StepicOrg,项目名称:stepik-android,代码行数:24,代码来源:StoreStateManagerImpl.java


示例6: tryBlock

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
@Test
public void tryBlock() throws Exception {
    tried = Try.invoke(new Function0<Integer>() {
        @Override
        public Integer invoke() {
            return 5;
        }
    });
    assertEquals(Integer.valueOf(5), tried.get());
}
 
开发者ID:gladed,项目名称:kotlin-late,代码行数:11,代码来源:TryTest.java


示例7: tryThrowingBlock

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
@Test
public void tryThrowingBlock() throws Exception {
    tried = Try.invoke(new Function0<Integer>() {
        @Override
        public Integer invoke() {
            throw boom;
        }
    });
    assertEquals(boom, tried.getError());
}
 
开发者ID:gladed,项目名称:kotlin-late,代码行数:11,代码来源:TryTest.java


示例8: runTest

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
@Test
public void runTest() throws Exception {
    final CountDownLatch latch = new CountDownLatch(1);
    runner.run(new Function0<Unit>() {
        @Override
        public Unit invoke() {
            latch.countDown();
            return Unit.INSTANCE;
        }
    });
    latch.await(MEDIUM, TimeUnit.MILLISECONDS);
}
 
开发者ID:gladed,项目名称:kotlin-late,代码行数:13,代码来源:ExecutorServiceRunnerTest.java


示例9: noRunAfterStop

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
@Test
public void noRunAfterStop() throws Exception {
    runner.stop();
    thrown.expect(StoppedException.class);
    runner.run(new Function0<Unit>() {
        @Override
        public Unit invoke() {
            return Unit.INSTANCE;
        }
    });
}
 
开发者ID:gladed,项目名称:kotlin-late,代码行数:12,代码来源:ExecutorServiceRunnerTest.java


示例10: onViewClicked

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
@OnClick({R.id.btn_query, R.id.onlineReservedCountView, R.id.announcementLinkView, R.id.orcplats, R.id.licenseInputChangeBtn})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_query:
                queryPlates(getLicense());
                break;
            case R.id.onlineReservedCountView:
                activity.replaceFragment(R.id.panel_content, 0, 0, new ReserveOrderFragment());
                break;
            case R.id.announcementLinkView:
                activity.pushFragment(R.id.panel_content, new StoreNoticeDetailsFragment(announcementId, 0, new Function0<Unit>() {
                    @Override
                    public Unit invoke() {
                        return null;
                    }
                }));
                break;
            case R.id.orcplats:
                showLicenseSpec = true;
                changeLicenseInput();
                startActivityForResult(new Intent(getContext(), OrcPlatsActivity.class), PLATS_RESOURCE);
//                startActivityForResult(new Intent(getContext(), OrcVinActivity.class),activity.VIN_RESOURCE);
                break;
            case R.id.licenseInputChangeBtn:
                changeLicenseInput();
                break;
        }
    }
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:29,代码来源:HomeFragment.java


示例11: IcsSettingsPanel

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
public IcsSettingsPanel(@Nullable Project project) {
  super(project, true);

  urlTextField.setText(IcsManagerKt.getIcsManager().getRepositoryManager().getUpstream());
  urlTextField.addBrowseFolderListener(new TextBrowseFolderListener(FileChooserDescriptorFactory.createSingleFolderDescriptor()));

  syncActions = UpstreamEditorKt.createMergeActions(project, urlTextField, getRootPane(), new Function0<Unit>() {
    @Override
    public Unit invoke() {
      doOKAction();
      return null;
    }
  });

  urlTextField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      UpstreamEditorKt.updateSyncButtonState(StringUtil.nullize(urlTextField.getText()), syncActions);
    }
  });

  UpstreamEditorKt.updateSyncButtonState(StringUtil.nullize(urlTextField.getText()), syncActions);

  setTitle(IcsBundleKt.icsMessage("settings.panel.title"));
  setResizable(false);
  init();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:IcsSettingsPanel.java


示例12: postUpdateToNextFrame

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
private void postUpdateToNextFrame() {
    mainHandler.post(new Function0<Unit>() {
        @Override
        public Unit invoke() {
            notifyItemChanged(getItemCount() - 1);
            return Unit.INSTANCE;
        }
    });
}
 
开发者ID:StepicOrg,项目名称:stepik-android,代码行数:10,代码来源:CoursesAdapter.java


示例13: processViewAssignments

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
@WorkerThread
private void processViewAssignments() {
    List<ViewAssignment> list = databaseFacade.getAllInQueue();
    for (ViewAssignment item : list) {
        try {
            retrofit2.Response<Void> response = api.postViewed(item).execute();
            if (response.isSuccessful()) {
                databaseFacade.removeFromQueue(item);
                Step step = databaseFacade.getStepById(item.getStep());
                if (step != null) {
                    final long stepId = step.getId();
                    if (StepHelper.isViewedStatePost(step)) {
                        if (item.getAssignment() != null) {
                            databaseFacade.markProgressAsPassed(item.getAssignment());
                        } else {
                            if (step.getProgressId() != null) {
                                databaseFacade.markProgressAsPassedIfInDb(step.getProgressId());
                            }
                        }
                        unitProgressManager.checkUnitAsPassed(step.getId());
                    }
                    // Get a handler that can be used to post to the main thread

                    mainHandler.post(new Function0<Unit>() {
                                         @Override
                                         public Unit invoke() {
                                             updatingStepPoster.updateStep(stepId, false);
                                             return Unit.INSTANCE;
                                         }
                                     }
                    );
                }
            }
        } catch (IOException e) {
            //no internet, just ignore and send next time
        }
    }
}
 
开发者ID:StepicOrg,项目名称:stepik-android,代码行数:39,代码来源:InternetConnectionEnabledReceiver.java


示例14: updateUnitLessonAfterDeleting

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
@Override
public void updateUnitLessonAfterDeleting(long lessonId) {
    //now unit lesson and all steps are deleting
    //cached = false, loading false
    //just make for parents
    //// FIXME: 14.12.15 it is not true, see related commit. Now we can delete one step.

    final Lesson lesson = databaseFacade.getLessonById(lessonId);
    final Unit unit = databaseFacade.getUnitByLessonId(lessonId);

    if (lesson != null && (lesson.is_cached() || lesson.is_loading())) {
        lesson.set_loading(false);
        lesson.set_cached(false);
        databaseFacade.updateOnlyCachedLoadingLesson(lesson);
        mainHandler.post(new Function0<kotlin.Unit>() {
            @Override
            public kotlin.Unit invoke() {
                for (LessonCallback callback : lessonCallbackContainer.asIterable()) {
                    callback.onLessonNotCached(lesson.getId());
                }
                return kotlin.Unit.INSTANCE;
            }
        });
    }
    if (unit != null) {
        updateSectionAfterDeleting(unit.getSection());
    }
}
 
开发者ID:StepicOrg,项目名称:stepik-android,代码行数:29,代码来源:StoreStateManagerImpl.java


示例15: checkUnitAsPassed

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
@Override
    public void checkUnitAsPassed(final long stepId) {
        Step step = databaseFacade.getStepById(stepId);
        if (step == null) return;
        List<Step> stepList = databaseFacade.getStepsOfLesson(step.getLesson());
        for (Step stepItem : stepList) {
            if (!stepItem.is_custom_passed()) return;
        }

        Unit unit = databaseFacade.getUnitByLessonId(step.getLesson());
        if (unit == null) return;

//        unit.set_viewed_custom(true);
//        mDatabaseFacade.addUnit(unit); //// TODO: 26.01.16 progress is not saved
        if (unit.getProgressId() != null) {
            databaseFacade.markProgressAsPassedIfInDb(unit.getProgressId());
        }

        final long unitId = unit.getId();
        //Say to ui that ui is cached now
        mainHandler.post(new Function0<kotlin.Unit>() {
            @Override
            public kotlin.Unit invoke() {
                for (UnitProgressListener unitProgressListener : listenerContainer.asIterable()) {
                    unitProgressListener.onUnitPassed(unitId);
                }
                return kotlin.Unit.INSTANCE;
            }
        });
    }
 
开发者ID:StepicOrg,项目名称:stepik-android,代码行数:31,代码来源:LocalProgressImpl.java


示例16: transformToBlockingMock

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
public static void transformToBlockingMock(MainHandler mainHandler) {
    doAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            Object firstArg = invocation.getArguments()[0];
            ((Function0) firstArg).invoke();
            return null;
        }
    }).when(mainHandler).post(any(Function0.class));
}
 
开发者ID:StepicOrg,项目名称:stepik-android,代码行数:11,代码来源:ConcurrencyUtilForTest.java


示例17: onHandleIntent

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
    final long stepId = intent.getLongExtra(AppConstants.KEY_STEP_BUNDLE, -1);
    Long assignmentId = intent.getLongExtra(AppConstants.KEY_ASSIGNMENT_BUNDLE, -1);
    if (stepId == -1) return;

    if (assignmentId < 0) {
        assignmentId = null;
    }

    try {
        Response<Void> response = api.postViewed(new ViewAssignment(assignmentId, stepId)).execute();
        if (!response.isSuccessful()) {
            throw new IOException("response is not success");
        }
    } catch (IOException e) {
        //if we not push:
        database.addToQueueViewedState(new ViewAssignment(assignmentId, stepId));
    }

    Step step = database.getStepById(stepId);

    //check in db as passed if it can be passed by view
    if (StepHelper.isViewedStatePost(step)) {
        if (assignmentId != null) {
            database.markProgressAsPassed(assignmentId);
        } else {
            if (step != null && step.getProgressId() != null) {
                database.markProgressAsPassedIfInDb(step.getProgressId());
            }
        }
        unitProgressManager.checkUnitAsPassed(stepId);
    }
    // Get a handler that can be used to post to the main thread

    mainHandler.post(new Function0<Unit>() {
        @Override
        public Unit invoke() {
            updatingStepPoster.updateStep(stepId, false);
            return Unit.INSTANCE;
        }
    });
}
 
开发者ID:StepicOrg,项目名称:stepik-android,代码行数:44,代码来源:ViewPusher.java


示例18: blockForInBackground

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
@WorkerThread
private void blockForInBackground(final long referenceId) {
    try {
        RWLocks.DownloadLock.writeLock().lock();

        final DownloadEntity downloadEntity = databaseFacade.getDownloadEntityIfExist(referenceId);
        if (downloadEntity != null) {
            final long stepId = downloadEntity.getStepId();
            databaseFacade.deleteDownloadEntityByDownloadId(referenceId);


            if (cancelSniffer.isStepIdCanceled(stepId)) {
                downloadManager.remove(referenceId);//remove notification (is it really work and need?)
                cancelSniffer.removeStepIdCancel(stepId);
            } else {
                //is not canceled
                final Step step = databaseFacade.getStepById(stepId);
                if (step == null) return;
                final long status = getDownloadStatus(systemDownloadManager, referenceId);

                final CachedVideo cachedVideo;
                if (status == DownloadManager.STATUS_SUCCESSFUL) {
                    cachedVideo = prepareCachedVideo(downloadEntity);
                    databaseFacade.addVideo(cachedVideo);
                    step.set_cached(true);
                } else {
                    cachedVideo = null;
                    step.set_cached(false);
                }

                step.set_loading(false);
                databaseFacade.updateOnlyCachedLoadingStep(step);
                storeStateManager.updateUnitLessonState(step.getLesson());

                final Lesson lesson = databaseFacade.getLessonById(step.getLesson());
                if (lesson == null) {
                    return;
                }

                //Say to ui that step is cached now
                mainHandler.post(new Function0<Unit>() {
                    @Override
                    public Unit invoke() {
                        if (cachedVideo != null) {
                            downloadsPoster.downloadComplete(stepId, lesson, cachedVideo);
                        } else {
                            final Context context = App.Companion.getAppContext();
                            Toast.makeText(context, context.getString(R.string.video_download_fail, lesson.getTitle()), Toast.LENGTH_SHORT).show();
                            analytic.reportEvent(Analytic.Error.DOWNLOAD_FAILED);
                            downloadsPoster.downloadFailed(referenceId);
                        }
                        return Unit.INSTANCE;
                    }
                });
            }
        } else {
            downloadManager.remove(referenceId);//remove notification (is it really work and need?)
        }
    } finally {
        RWLocks.DownloadLock.writeLock().unlock();
    }
}
 
开发者ID:StepicOrg,项目名称:stepik-android,代码行数:63,代码来源:DownloadCompleteReceiver.java


示例19: updateUnitProgress

import kotlin.jvm.functions.Function0; //导入依赖的package包/类
@Override
public void updateUnitProgress(final long unitId) {

    Unit unit = databaseFacade.getUnitById(unitId);
    if (unit == null) return;
    Progress updatedUnitProgress;
    try {
        updatedUnitProgress = api.getProgresses(new String[]{unit.getProgressId()}).execute().body().getProgresses().get(0);
    } catch (Exception e) {
        //if we have no progress of unit or progress is null -> do nothing
        return;
    }
    if (updatedUnitProgress == null)
        return;
    databaseFacade.addProgress(updatedUnitProgress);

    final Double finalScoreInUnit = getScoreOfProgress(updatedUnitProgress);
    if (finalScoreInUnit == null) {
        return;
    }
    mainHandler.post(new Function0<kotlin.Unit>() {
        @Override
        public kotlin.Unit invoke() {
            for (UnitProgressListener unitProgressListener : listenerContainer.asIterable()) {
                unitProgressListener.onScoreUpdated(unitId, finalScoreInUnit);
            }
            return kotlin.Unit.INSTANCE;
        }
    });

    //after that update section progress
    final long sectionId = unit.getSection();
    try {
        final Section persistentSection = databaseFacade.getSectionById(sectionId);
        if (persistentSection == null) {
            return;
        }

        String progressId = persistentSection.getProgress();
        if (progressId == null) {
            return;
        }

        final Progress progress = api.getProgresses(new String[]{progressId}).execute().body().getProgresses().get(0);
        databaseFacade.addProgress(progress);
        mainHandler.post(new Function0<kotlin.Unit>() {
            @Override
            public kotlin.Unit invoke() {
                for (SectionProgressListener sectionProgressListener : sectionProgressListenerListenerContainer.asIterable()) {
                    sectionProgressListener.onProgressUpdated(progress, persistentSection.getCourse());
                }
                return kotlin.Unit.INSTANCE;
            }
        });
    } catch (Exception exception) {
        Timber.e(exception);
    }
}
 
开发者ID:StepicOrg,项目名称:stepik-android,代码行数:59,代码来源:LocalProgressImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PixelFormat类代码示例发布时间:2022-05-22
下一篇:
Java SqlJetDb类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap