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


Java Function0类代码示例

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


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


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