예제 #1
0
  /** 获取数据 */
  private void getImagePath() {

    IAssetManager iAssetManager =
        AssetManagerFactory.getInstance(getActivity(), AssetManagerFactory.PHOTO_MGR_ALL);
    final List<AssetItem> items = (List<AssetItem>) iAssetManager.getAssetsSync();

    iAssetManager.setContentManagerListener(
        new IAssettManagerListener() {
          @Override
          public void onDeletePhotosProgress(long deletedSize, double percent) {}

          @Override
          public void onPhoto(List<?> photos) {}

          @Override
          public void onPhotoProgress(
              final AssetItem asset, final long rightItemsToal, final long scannedTotoal) {
            getActivity()
                .runOnUiThread(
                    new Runnable() {
                      @Override
                      public void run() {
                        if (asset != null) {
                          itemsBig.add(asset);
                        }
                        String checkMsg = getString(R.string.main_fragment_sroll_checking);
                        String checkMsgFormat =
                            String.format(checkMsg, scannedTotoal, items.size());
                        check.setText(checkMsgFormat);
                        String textL = (String) deal.getText();
                        boolean b = textL.equals(rightItemsToal + "");
                        if (!b) {
                          deal.setText(rightItemsToal + "");
                        }
                        System.out.println(
                            "--------"
                                + rightItemsToal
                                + "----"
                                + scannedTotoal
                                + "--"
                                + itemsBig.size());
                      }
                    });
          }

          @Override
          public void onDeletePhoto(List<?> photos) {}

          @Override
          public void onPhotosSize(long size) {}

          @Override
          public void onScanFinished() {
            getActivity()
                .runOnUiThread(
                    new Runnable() {
                      @Override
                      public void run() {
                        setSpeed(0);
                        if (allPhotoFragment != null) {
                          //                            allPhotoFragment.swapData(itemsBig);
                          allPhotoFragment.setFunctionData(itemsBig, function);
                        }

                        FragmentManager manager = getFragmentManager();
                        FragmentTransaction transaction = manager.beginTransaction();
                        //                        AllPhotoFragment allPhotoFragment =
                        // AllPhotoFragment.newInstance();
                        //                        ListBuddiesFragment.newInstance();
                        transaction.remove(ListBuddiesFragment.newInstance());
                        transaction.commit();
                      }
                    });
          }

          @Override
          public void onDeleteFinished() {}
        });
    iAssetManager.startScanBigAssetsByDateGroup();

    System.out.println("----------------总个数: " + items.size());
    int _size = items.size();
    AssetItem item = items.get(0);
    if (_size == 1) {
      mImagesLeft.add(item.getPath());
      mImagesRight = mImagesLeft;
      mImagesRight3 = mImagesLeft;
    } else if (_size == 2) {
      mImagesLeft.add(items.get(0).getPath());
      mImagesRight.add(items.get(1).getPath());
      mImagesRight3 = mImagesLeft;
    } else {
      int mCount = 0;
      for (AssetItem f : items) {
        String path = f.getPath();
        int row = mCount % mRow;
        mCount++;
        if (row == 0) {
          mImagesLeft.add(path);
        } else if (row == 1) {
          mImagesRight.add(path);
        } else if (row == 2) {
          mImagesRight3.add(path);
        } else if (row == 3) {
          //				setNullForSmooth(mImagesLeft, mImagesRight3, mImagesRight, mImagesRight3,
          // mImagesRight);
          //				setNullForSmooth(mImagesLeft, mImagesRight3, mImagesRight, mImagesRight3,
          // mImagesRight);
          mImagesRight4.add(path);
        } else if (row == 4) {
          //				setNullForSmooth(mImagesRight4, mImagesLeft, mImagesRight, mImagesRight3,
          // mImagesRight3);
          //				setNullForSmooth(mImagesRight4, mImagesLeft, mImagesRight, mImagesRight3,
          // mImagesRight3);
          mImagesRight5.add(path);
        } else if (row == 5) {
          //				setNullForSmooth(mImagesRight5, mImagesRight, mImagesRight6,
          // mImagesRight5,mImagesRight4);
          //				setNullForSmooth(mImagesRight5, mImagesRight, mImagesRight6,
          // mImagesRight5,mImagesRight4);
          mImagesRight6.add(path);
        } else if (row == 6) {
          //				setNullForSmooth(mImagesRight7, mImagesLeft, mImagesRight3,
          // mImagesRight7,mImagesRight5);
          //				setNullForSmooth(mImagesRight7, mImagesLeft, mImagesRight3,
          // mImagesRight7,mImagesRight5);
          mImagesRight7.add(path);
        } else if (row == 7) {
          //				setNullForSmooth(mImagesLeft, mImagesRight5, mImagesRight,
          // mImagesRight7,mImagesRight6);
          //				setNullForSmooth(mImagesLeft, mImagesRight5, mImagesRight,
          // mImagesRight7,mImagesRight6);
          mImagesRight8.add(path);
        } else if (row == 8) {
          //				setNullForSmooth(mImagesRight9, mImagesLeft, mImagesRight9,
          // mImagesRight7,mImagesRight6);
          //				setNullForSmooth(mImagesRight9, mImagesLeft, mImagesRight9,
          // mImagesRight7,mImagesRight6);
          mImagesRight9.add(path);
        } else {
          System.err.println("哎呀,出错啦,row: " + row);
        }
      }
    }
  }