コード例 #1
0
 @Nullable
 @Override
 public View onCreateView(
     LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
   View v = inflater.inflate(R.layout.fragment_imagegridfragment, container, false);
   recyclerView = (RecyclerView) v.findViewById(R.id.fragment_imagegridfragment_rv_imagegrid);
   v.findViewById(R.id.fragment_imagegridfragment_fab_addimage)
       .setOnClickListener(
           new View.OnClickListener() {
             @Override
             public void onClick(View v) {
               FishBun.with(ImageGridFragment.this)
                   .setRequestCode(INTENT_REQUESTCODE_IMAGEPICK)
                   .setCamera(true)
                   .setPickerCount(PICKER_MAX_IMAGES)
                   .setActionBarColor(
                       getResources().getColor(R.color.colorPrimary),
                       getResources().getColor(R.color.colorPrimaryDark))
                   .startAlbum();
             }
           });
   gridLayoutManager =
       new GridLayoutManager(
           getContext(), PreferenceFacade.getInstance().getColumns(getContext()));
   recyclerView.setLayoutManager(gridLayoutManager);
   recyclerView.setAdapter(adapter);
   return v;
 }
コード例 #2
0
 private void loadItems() {
   loading = true;
   WebRequestBuilder wrb = new WebRequestBuilder(getContext());
   WebRequest wr =
       wrb.getItemsRequest(
           getContext(),
           currentPage,
           PreferenceFacade.getInstance().getItemsPerPage(getContext()));
   assister.runWebRequest(
       new Handler.Callback() {
         @Override
         public boolean handleMessage(Message msg) {
           if (ServiceProcessorMessageUtil.isSuccessful(msg)) {
             Items newItems = ServiceProcessorMessageUtil.getCastedPayLoad(msg);
             adapter.addAll(newItems.getItems());
             currentPage++;
             loading = false;
             return true;
           }
           return false;
         }
       },
       wr,
       new ItemsProcessor());
 }