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

Java Result类代码示例

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

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



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

示例1: setUpRepository

import com.google.android.agera.Result; //导入依赖的package包/类
private void setUpRepository() {
    mExecutor = Executors.newSingleThreadExecutor();
    mReservoir = Reservoirs.reservoir();
    Supplier<Result<Integer>> supplier = new Supplier<Result<Integer>>() {
        @NonNull
        @Override
        public Result<Integer> get() {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            mReservoir.get();// consume receiver
            return Result.success(++mCount);
        }
    };
    mRepository = Repositories.repositoryWithInitialValue(Result.<Integer>absent())
            .observe(mReservoir)
            .onUpdatesPerLoop()
            .goTo(mExecutor)
            .thenGetFrom(supplier)
            .compile();
}
 
开发者ID:captain-miao,项目名称:AndroidAgeraTutorial,代码行数:24,代码来源:SimpleActivityH.java


示例2: setUpRepository

import com.google.android.agera.Result; //导入依赖的package包/类
private void setUpRepository() {
    mObservable = new OnClickObservable() {
        @Override
        public void onClick( ) {
            dispatchUpdate();
        }
    };
    Supplier<Result<Integer>> supplier = new Supplier<Result<Integer>>() {
        @NonNull
        @Override
        public Result<Integer> get() {
            return Result.success(MockRandomData.getRandomColor());
        }
    };

    mRepository = Repositories.repositoryWithInitialValue(Result.<Integer>absent())
            .observe(mObservable)
            .onUpdatesPerLoop()
            .thenGetFrom(supplier)
            .compile();
}
 
开发者ID:captain-miao,项目名称:AndroidAgeraTutorial,代码行数:22,代码来源:SimpleActivityA.java


示例3: setUpRepository

import com.google.android.agera.Result; //导入依赖的package包/类
private void setUpRepository() {
    networkExecutor = Executors.newSingleThreadExecutor();

    mMutableRepository = Repositories.mutableRepository(mPagination);

    mLoadDataRepository = Repositories.repositoryWithInitialValue(Result.<ApiResult<GirlInfo>>absent())
            .observe(mMutableRepository)
            .onUpdatesPerLoop()
            .goTo(networkExecutor)
            .attemptGetFrom(new GirlsSupplier(mMutableRepository)).orSkip()
            .thenTransform(new Function<ApiResult<GirlInfo>, Result<ApiResult<GirlInfo>>>() {
                @NonNull
                @Override
                public Result<ApiResult<GirlInfo>> apply(@NonNull ApiResult<GirlInfo> input) {
                    return absentIfNull(input);
                }
            })
            .onDeactivation(RepositoryConfig.SEND_INTERRUPT)
            .compile();

}
 
开发者ID:captain-miao,项目名称:AndroidAgeraTutorial,代码行数:22,代码来源:ComplexRecycleViewActivity.java


示例4: update

import com.google.android.agera.Result; //导入依赖的package包/类
@Override
public void update() {
    Result<ApiResult<GirlInfo>> result = mLoadDataRepository.get();

    result.ifSucceededSendTo(this)
            .ifFailedSendTo(new Receiver<Throwable>() {
                @Override
                public void accept(@NonNull Throwable value) {
                    Toast.makeText(ComplexRecycleViewActivity.this, "load data fail", Toast.LENGTH_LONG).show();
                    if (mPagination == 1) {
                        mRefreshRecyclerView.refreshComplete();
                    } else {
                        mRefreshRecyclerView.hideFooterView();
                    }
                    mRefreshRecyclerView.loadMoreComplete();
                }
            });

}
 
开发者ID:captain-miao,项目名称:AndroidAgeraTutorial,代码行数:20,代码来源:ComplexRecycleViewActivity.java


示例5: responseTypes

import com.google.android.agera.Result; //导入依赖的package包/类
@Test public void responseTypes() {
    Type oBodyClass = new TypeToken<Supplier<Result<String>>>() {}.getType();
    assertThat(factory.get(oBodyClass, NO_ANNOTATIONS, retrofit).responseType(),
        equalTo(new TypeToken<String>() {}.getType()));

    Type oBodyWildcard = new TypeToken<Supplier<Result<? extends String>>>() {}.getType();
    assertThat(factory.get(oBodyWildcard, NO_ANNOTATIONS, retrofit).responseType(),
        equalTo(new TypeToken<String>() {}.getType()));

    Type oBodyGeneric = new TypeToken<Supplier<Result<List<String>>>>() {}.getType();
    assertThat(factory.get(oBodyGeneric, NO_ANNOTATIONS, retrofit).responseType(),
        equalTo(new TypeToken<List<String>>() {}.getType()));

    Type oResponseClass = new TypeToken<Supplier<Result<Response<String>>>>() {}.getType();
    assertThat(factory.get(oResponseClass, NO_ANNOTATIONS, retrofit).responseType(),
        equalTo(new TypeToken<String>() {}.getType()));

    Type oResponseWildcard
        = new TypeToken<Supplier<Result<Response<? extends String>>>>() {}.getType();
    assertThat(factory.get(oResponseWildcard, NO_ANNOTATIONS, retrofit).responseType(),
        equalTo(new TypeToken<String>() {}.getType()));
}
 
开发者ID:drakeet,项目名称:retrofit-agera-call-adapter,代码行数:23,代码来源:AgeraCallAdapterFactoryTest.java


示例6: yinResponseToResult

import com.google.android.agera.Result; //导入依赖的package包/类
@NonNull private static Function<HttpResponse, Result<String>> yinResponseToResult() {
    return Functions.functionFrom(HttpResponse.class)
        .apply(input -> new String(input.getBody()))
        .apply(body -> {
            String re = "title\">\\s+.+?href=\"([^\"]*)\">(.+?)</a>.+</li>";
            Pattern pattern = Pattern.compile(re, Pattern.DOTALL);
            return pattern.matcher(body);
        })
        .thenApply(matcher -> {
            if (matcher.find()) {
                return Result.success("为你找到最新的一篇文章是: \n" +
                    matcher.group(2) + "\n" + matcher.group(1));
            } else {
                return Result.absent();
            }
        });
}
 
开发者ID:drakeet,项目名称:TimeMachine,代码行数:18,代码来源:YinRequests.java


示例7: mapResponse

import com.google.android.agera.Result; //导入依赖的package包/类
@NonNull private static Function<HttpResponse, Result<String>> mapResponse() {
    return Functions.functionFrom(HttpResponse.class)
        .apply(input -> new String(input.getBody()))
        .apply(body -> {
            int sourceTag = body.indexOf("<sdk:source>");
            if (sourceTag != -1) {
                String apiLevelStart = "<sdk:api-level>";
                String apiLevelEnd = "</sdk:api-level>";
                int targetStart = body.indexOf(apiLevelStart, sourceTag) +
                    apiLevelStart.length();
                int targetEnd = body.indexOf(apiLevelEnd, targetStart);
                return body.substring(targetStart, targetEnd);
            }
            return "24";
        })
        .thenApply(version -> {
            return Result.success("为你找到最新的 Android SDK Source 是第 " + version + " 版");
        });
}
 
开发者ID:drakeet,项目名称:TimeMachine,代码行数:20,代码来源:AndroidSDKRequests.java


示例8: prepare

import com.google.android.agera.Result; //导入依赖的package包/类
@SuppressWarnings("unchecked") private void prepare() {
    translateReaction = Reservoirs.<Translation>reactionReservoir();
    Repository<Result<String>> translationRepo = repositoryWithInitialValue(
        Result.<String>absent())
        .observe(translateReaction)
        .onUpdatesPerLoop()
        .attemptGetFrom(translateReaction).orSkip()
        .goTo(networkExecutor)
        .check(input -> input.getStep() == OnConfirm)
        .orEnd((Function<Translation, Result<String>>) input -> {
            Log.e("check-confirm", input.toString());
            return Result.failure();
        })
        .mergeIn(YOU_DAO, current2UrlMerger())
        .attemptTransform(urlToResponse())
        .orEnd(Result::failure)
        .goTo(calculationExecutor)
        .transform(youdaoResponseToResult())
        .goLazy()
        .thenTransform(input -> input)
        .onDeactivation(SEND_INTERRUPT)
        .compile();
    translationRepo.addUpdatable(() -> translationRepo.get()
        .ifSucceededSendTo(this::handleConfirm)
        .ifFailedSendTo(errorHandler()));
}
 
开发者ID:drakeet,项目名称:TimeMachine,代码行数:27,代码来源:TransformService.java


示例9: shouldBindRepositoryPresenterOfResult

import com.google.android.agera.Result; //导入依赖的package包/类
@Test
public void shouldBindRepositoryPresenterOfResult() {
  final RepositoryPresenter<Result<String>> resultRepositoryPresenter =
      dataBindingRepositoryPresenterOf(String.class)
          .layout(LAYOUT_ID)
          .itemId(ITEM_ID)
          .handler(HANDLER_ID, HANDLER)
          .handler(SECOND_HANDLER_ID, SECOND_HANDLER)
          .forResult();

  resultRepositoryPresenter.bind(STRING_RESULT, 0, viewHolder);

  verify(view).setTag(R.id.agera__rvdatabinding__item_id, ITEM_ID);
  verify(viewDataBinding).setVariable(ITEM_ID, STRING);
  verify(viewDataBinding).setVariable(HANDLER_ID, HANDLER);
  verify(viewDataBinding).setVariable(SECOND_HANDLER_ID, SECOND_HANDLER);
  verify(viewDataBinding).executePendingBindings();
  verifyNoMoreInteractions(viewDataBinding);
}
 
开发者ID:google,项目名称:agera,代码行数:20,代码来源:DataBindingRepositoryPresentersTest.java


示例10: shouldRecycleRepositoryPresenterOfResultWithItemRecycling

import com.google.android.agera.Result; //导入依赖的package包/类
@Test
public void shouldRecycleRepositoryPresenterOfResultWithItemRecycling() {
  when(view.getTag(R.id.agera__rvdatabinding__item_id)).thenReturn(ITEM_ID);

  final RepositoryPresenter<Result<String>> resultRepositoryPresenter =
      dataBindingRepositoryPresenterOf(String.class)
          .layout(LAYOUT_ID)
          .itemId(ITEM_ID)
          .handler(HANDLER_ID, HANDLER)
          .handler(SECOND_HANDLER_ID, SECOND_HANDLER)
          .onRecycle(CLEAR_ITEM)
          .forResult();

  resultRepositoryPresenter.recycle(viewHolder);

  verify(viewDataBinding).setVariable(ITEM_ID, null);
  verify(viewDataBinding).executePendingBindings();
  verifyNoMoreInteractions(viewDataBinding);
}
 
开发者ID:google,项目名称:agera,代码行数:20,代码来源:DataBindingRepositoryPresentersTest.java


示例11: shouldRecycleRepositoryPresenterOfResultWithAllRecycling

import com.google.android.agera.Result; //导入依赖的package包/类
@Test
public void shouldRecycleRepositoryPresenterOfResultWithAllRecycling() {
  when(view.getTag(R.id.agera__rvdatabinding__item_id)).thenReturn(ITEM_ID);
  final RepositoryPresenter<Result<String>> resultRepositoryPresenter =
      dataBindingRepositoryPresenterOf(String.class)
          .layout(LAYOUT_ID)
          .itemId(ITEM_ID)
          .handler(HANDLER_ID, HANDLER)
          .handler(SECOND_HANDLER_ID, SECOND_HANDLER)
          .onRecycle(CLEAR_ALL)
          .forResult();

  resultRepositoryPresenter.recycle(viewHolder);

  verify(viewDataBinding).setVariable(ITEM_ID, null);
  verify(viewDataBinding).setVariable(HANDLER_ID, null);
  verify(viewDataBinding).setVariable(SECOND_HANDLER_ID, null);
  verify(viewDataBinding).executePendingBindings();
  verifyNoMoreInteractions(viewDataBinding);
}
 
开发者ID:google,项目名称:agera,代码行数:21,代码来源:DataBindingRepositoryPresentersTest.java


示例12: shouldRecycleRepositoryPresenterOfResultWithHandlerRecycling

import com.google.android.agera.Result; //导入依赖的package包/类
@Test
public void shouldRecycleRepositoryPresenterOfResultWithHandlerRecycling() {
  when(view.getTag(R.id.agera__rvdatabinding__item_id)).thenReturn(ITEM_ID);
  final RepositoryPresenter<Result<String>> resultRepositoryPresenter =
      dataBindingRepositoryPresenterOf(String.class)
          .layout(LAYOUT_ID)
          .itemId(ITEM_ID)
          .handler(HANDLER_ID, HANDLER)
          .handler(SECOND_HANDLER_ID, SECOND_HANDLER)
          .onRecycle(CLEAR_HANDLERS)
          .forResult();

  resultRepositoryPresenter.recycle(viewHolder);

  verify(viewDataBinding).setVariable(HANDLER_ID, null);
  verify(viewDataBinding).setVariable(SECOND_HANDLER_ID, null);
  verify(viewDataBinding).executePendingBindings();
  verifyNoMoreInteractions(viewDataBinding);
}
 
开发者ID:google,项目名称:agera,代码行数:20,代码来源:DataBindingRepositoryPresentersTest.java


示例13: shouldBindRepositoryPresenterOfResultList

import com.google.android.agera.Result; //导入依赖的package包/类
@Test
public void shouldBindRepositoryPresenterOfResultList() {
  final RepositoryPresenter<Result<List<String>>> resultListRepositoryPresenter =
      dataBindingRepositoryPresenterOf(String.class)
          .layout(LAYOUT_ID)
          .itemId(ITEM_ID)
          .handler(HANDLER_ID, HANDLER)
          .forResultList();

  resultListRepositoryPresenter.bind(STRING_LIST_RESULT, 1, viewHolder);

  verify(view).setTag(R.id.agera__rvdatabinding__item_id, ITEM_ID);
  verify(viewDataBinding).setVariable(ITEM_ID, SECOND_STRING);
  verify(viewDataBinding).setVariable(HANDLER_ID, HANDLER);
  verify(viewDataBinding).executePendingBindings();
  verifyNoMoreInteractions(viewDataBinding);
}
 
开发者ID:google,项目名称:agera,代码行数:18,代码来源:DataBindingRepositoryPresentersTest.java


示例14: shouldRecycleRepositoryPresenterOfResultListWithItemRecycling

import com.google.android.agera.Result; //导入依赖的package包/类
@Test
public void shouldRecycleRepositoryPresenterOfResultListWithItemRecycling() {
  when(view.getTag(R.id.agera__rvdatabinding__item_id)).thenReturn(ITEM_ID);

  final RepositoryPresenter<Result<List<String>>> resultRepositoryPresenter =
      dataBindingRepositoryPresenterOf(String.class)
          .layout(LAYOUT_ID)
          .itemId(ITEM_ID)
          .handler(HANDLER_ID, HANDLER)
          .handler(SECOND_HANDLER_ID, SECOND_HANDLER)
          .onRecycle(CLEAR_ITEM)
          .forResultList();

  resultRepositoryPresenter.recycle(viewHolder);

  verify(viewDataBinding).setVariable(ITEM_ID, null);
  verify(viewDataBinding).executePendingBindings();
  verifyNoMoreInteractions(viewDataBinding);
}
 
开发者ID:google,项目名称:agera,代码行数:20,代码来源:DataBindingRepositoryPresentersTest.java


示例15: shouldRecycleRepositoryPresenterOfResultListWithAllRecycling

import com.google.android.agera.Result; //导入依赖的package包/类
@Test
public void shouldRecycleRepositoryPresenterOfResultListWithAllRecycling() {
  when(view.getTag(R.id.agera__rvdatabinding__item_id)).thenReturn(ITEM_ID);
  final RepositoryPresenter<Result<List<String>>> resultRepositoryPresenter =
      dataBindingRepositoryPresenterOf(String.class)
          .layout(LAYOUT_ID)
          .itemId(ITEM_ID)
          .handler(HANDLER_ID, HANDLER)
          .handler(SECOND_HANDLER_ID, SECOND_HANDLER)
          .onRecycle(CLEAR_ALL)
          .forResultList();

  resultRepositoryPresenter.recycle(viewHolder);

  verify(viewDataBinding).setVariable(ITEM_ID, null);
  verify(viewDataBinding).setVariable(HANDLER_ID, null);
  verify(viewDataBinding).setVariable(SECOND_HANDLER_ID, null);
  verify(viewDataBinding).executePendingBindings();
  verifyNoMoreInteractions(viewDataBinding);
}
 
开发者ID:google,项目名称:agera,代码行数:21,代码来源:DataBindingRepositoryPresentersTest.java


示例16: shouldRecycleRepositoryPresenterOfResultListWithHandlerRecycling

import com.google.android.agera.Result; //导入依赖的package包/类
@Test
public void shouldRecycleRepositoryPresenterOfResultListWithHandlerRecycling() {
  when(view.getTag(R.id.agera__rvdatabinding__item_id)).thenReturn(ITEM_ID);
  final RepositoryPresenter<Result<List<String>>> resultRepositoryPresenter =
      dataBindingRepositoryPresenterOf(String.class)
          .layout(LAYOUT_ID)
          .itemId(ITEM_ID)
          .handler(HANDLER_ID, HANDLER)
          .handler(SECOND_HANDLER_ID, SECOND_HANDLER)
          .onRecycle(CLEAR_HANDLERS)
          .forResultList();

  resultRepositoryPresenter.recycle(viewHolder);

  verify(viewDataBinding).setVariable(HANDLER_ID, null);
  verify(viewDataBinding).setVariable(SECOND_HANDLER_ID, null);
  verify(viewDataBinding).executePendingBindings();
  verifyNoMoreInteractions(viewDataBinding);
}
 
开发者ID:google,项目名称:agera,代码行数:20,代码来源:DataBindingRepositoryPresentersTest.java


示例17: merge

import com.google.android.agera.Result; //导入依赖的package包/类
@NonNull
@Override
public Result<List<T>> merge(@NonNull final SQLiteDatabase database,
    @NonNull final SqlRequest input) {
  try {
    final Cursor cursor = database.rawQuery(input.sql, input.arguments);
    try {
      final int count = cursor.getCount();
      if (count == 0) {
        return success(Collections.<T>emptyList());
      }
      final List<T> items = new ArrayList<>(count);
      while (cursor.moveToNext()) {
        items.add(cursorToItem.apply(cursor));
      }
      return success(items);
    } finally {
      cursor.close();
    }
  } catch (final SQLException e) {
    return failure(e);
  }
}
 
开发者ID:google,项目名称:agera,代码行数:24,代码来源:SqlDatabaseFunctions.java


示例18: onCreate

import com.google.android.agera.Result; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TwitterAuthConfig authConfig = new TwitterAuthConfig(getString(R.string.twitter_consumer_key), getString(R.string.twitter_consumer_secret));
    Fabric.with(this, new Twitter(authConfig));
    final ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);

    // OnRefresh observable
    final OnRefreshObservable refreshObservable = new OnRefreshObservable();
    swipeRefreshLayout = binding.refreshLayout;
    swipeRefreshLayout.setColorSchemeColors(
            ContextCompat.getColor(this, R.color.colorPrimary),
            ContextCompat.getColor(this, R.color.colorAccent),
            ContextCompat.getColor(this, R.color.colorPrimaryDark));
    swipeRefreshLayout.setOnRefreshListener(refreshObservable);

    networkExecutor = Executors.newSingleThreadExecutor();

    // Tweets supplier and repository
    final TweetsSupplier tweetsSupplier = new TweetsSupplier();
    tweetsRepository = Repositories
            .repositoryWithInitialValue(Result.<List<Tweet>>absent())
            .observe(refreshObservable)
            .onUpdatesPerLoop()
            .goTo(networkExecutor)
            .thenGetFrom(tweetsSupplier)
            .compile();

    listAdapter = RepositoryAdapter.repositoryAdapter()
            .add(tweetsRepository, new TweetPresenter())
            .build();
    final RecyclerView list = binding.list;
    list.setAdapter(listAdapter);
    list.setLayoutManager(new LinearLayoutManager(this));
}
 
开发者ID:hkurokawa,项目名称:AgeraSample,代码行数:36,代码来源:MainActivity.java


示例19: getItemCount

import com.google.android.agera.Result; //导入依赖的package包/类
@Override
public int getItemCount(@NonNull Result<List<Tweet>> data) {
    if (data.succeeded()) {
        return data.get().size();
    }
    return 0;
}
 
开发者ID:hkurokawa,项目名称:AgeraSample,代码行数:8,代码来源:TweetPresenter.java


示例20: bind

import com.google.android.agera.Result; //导入依赖的package包/类
@Override
public void bind(@NonNull Result<List<Tweet>> data, int index, @NonNull RecyclerView.ViewHolder holder) {
    if (data.isAbsent() || data.failed()) {
        return;
    }
    final Tweet tweet = data.get().get(index);
    final ListItemTweetBinding binding = DataBindingUtil.bind(holder.itemView);
    binding.userName.setText(tweet.username);
    binding.tweet.setText(tweet.text);
}
 
开发者ID:hkurokawa,项目名称:AgeraSample,代码行数:11,代码来源:TweetPresenter.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Ref类代码示例发布时间:2022-05-22
下一篇:
Java AppenderAttachableImpl类代码示例发布时间: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