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


Java FilePickerActivity类代码示例

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


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

示例1: start

import com.nbsp.materialfilepicker.ui.FilePickerActivity; //导入依赖的package包/类
public void start() {
    if (mActivity == null) {
        throw new RuntimeException("You must pass activity by calling withActivity method");
    }

    if (mRequestCode == null) {
        throw new RuntimeException("You must pass request code by calling withRequestCode method");
    }

    CompositeFilter filter = getFilter();

    Intent intent = new Intent(mActivity, FilePickerActivity.class);
    intent.putExtra(FilePickerActivity.ARG_FILTER, filter);

    if (mRootPath != null) {
        intent.putExtra(FilePickerActivity.ARG_START_PATH, mRootPath);
    }

    if (mCurrentPath != null) {
        intent.putExtra(FilePickerActivity.ARG_CURRENT_PATH, mCurrentPath);
    }
    mActivity.startActivityForResult(intent, mRequestCode);
}
 
开发者ID:qq1198,项目名称:mtoolbox,代码行数:24,代码来源:MaterialFilePicker.java

示例2: onActivityResult

import com.nbsp.materialfilepicker.ui.FilePickerActivity; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == 1 && resultCode == RESULT_OK) {

        String filePath = data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH);
        String format = filePath.substring(filePath.lastIndexOf(".") + 1);
        String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
        selectedFile.setText("Selected file: " + fileName);

        if (format.equals("txt"))
            askToExtractParameters(filePath);
        else
            Toast.makeText(this, getString(R.string.please_select), Toast.LENGTH_LONG).show();

    }
}
 
开发者ID:webianks,项目名称:scout,代码行数:19,代码来源:MainActivity.java

示例3: getIntent

import com.nbsp.materialfilepicker.ui.FilePickerActivity; //导入依赖的package包/类
/**
 * @return Intent that can be used to start Material File Picker
 */
public Intent getIntent() {
    CompositeFilter filter = getFilter();

    Activity activity = null;
    if (mActivity != null) {
        activity = mActivity;
    } else if (mFragment != null) {
        activity = mFragment.getActivity();
    } else if (mSupportFragment != null) {
        activity = mSupportFragment.getActivity();
    }

    Intent intent = new Intent(activity, FilePickerActivity.class);
    intent.putExtra(FilePickerActivity.ARG_FILTER, filter);

    if (mRootPath != null) {
        intent.putExtra(FilePickerActivity.ARG_START_PATH, mRootPath);
    }

    if (mCurrentPath != null) {
        intent.putExtra(FilePickerActivity.ARG_CURRENT_PATH, mCurrentPath);
    }

    return intent;
}
 
开发者ID:Martin20150405,项目名称:Pano360,代码行数:29,代码来源:MaterialFilePicker.java

示例4: onActivityResult

import com.nbsp.materialfilepicker.ui.FilePickerActivity; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 1) {
        switch (resultCode) {
            case RESULT_OK: //restart the activity when something major was changed in the settings
                finish();
                startActivity(getIntent());
                break;
            case UPDATE_ALARM:
                if (prefHelper.getNotificationInterval() != 0)
                    WakefulIntentService.scheduleAlarms(new ComicListener(), this, true);
                else
                    WakefulIntentService.cancelAlarms(this);
                break;
        }
    } else if (requestCode == 2 && resultCode == FilePickerActivity.RESULT_OK) {
        ((FavoritesFragment) getSupportFragmentManager().findFragmentByTag(FAV_TAG)).importFavorites(data);
    }
}
 
开发者ID:T-Rex96,项目名称:Easy_xkcd,代码行数:20,代码来源:MainActivity.java

示例5: onActivityResult

import com.nbsp.materialfilepicker.ui.FilePickerActivity; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {


    if (requestCode==1987 && data!=null)
    {
        String filePath = data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH);
        Log.i(TAG, "onActivityResult: file path "+filePath);
        File file=new File(filePath);
        byte fileContent[] = new byte[(int)file.length()];

        try {
            FileInputStream fin = new FileInputStream(file);
            fin.read(fileContent);
            HashMap<String, Object> content = new HashMap<>();
            content.put("file",file.getName());

            com.bridgefy.sdk.client.Message.Builder builder=new com.bridgefy.sdk.client.Message.Builder();
            com.bridgefy.sdk.client.Message message = builder.setReceiverId(conversationId).setContent(content).setData(fileContent).build();
            Bridgefy.sendMessage(message);
            BridgefyFile bridgefyFile = new BridgefyFile(filePath);
            bridgefyFile.setDirection(BridgefyFile.OUTGOING_FILE);
            bridgefyFile.setData(fileContent);
            messagesAdapter.addMessage(bridgefyFile);




        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
 
开发者ID:bridgefy,项目名称:bridgefy-android-samples,代码行数:36,代码来源:FileActivity.java

示例6: onActivityResult

import com.nbsp.materialfilepicker.ui.FilePickerActivity; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == 1 && resultCode == RESULT_OK) {
        File root = android.os.Environment.getExternalStorageDirectory();
        File dire = new File(root.getAbsolutePath() + "/Exames-App/Guias");
        String guiaPDFDir = dire.toString();

        String filePath = data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH);

        String guiaPath = "/Guia-" + filePath.substring(filePath.lastIndexOf("/") + 1);

        String finalGuiaPath = guiaPDFDir + guiaPath;

        Log.v("TAG", "guiaPath: " + guiaPath);
        Log.v("TAG", "guiaPDFDir: " + guiaPDFDir);

        Log.v("TAG", "finalGuiaPath: " + finalGuiaPath);
        // Do anything with filePath, that is, file.

        Intent executeExamesGo = new Intent(ExamesActivity.this, ExamesGoActivity.class);
        executeExamesGo.putExtra("FILE_PDF", filePath);
        executeExamesGo.putExtra("GUIA_PDF", finalGuiaPath);
        startActivity(executeExamesGo);
    } else if (requestCode == 0 && resultCode == RESULT_CANCELED) {
        Toast.makeText(this, "Whoops! Ocorreu um erro.", Toast.LENGTH_SHORT).show();
    }

}
 
开发者ID:kishannareshpal,项目名称:ExamesGithub,代码行数:31,代码来源:ExamesActivity.java

示例7: onActivityResult

import com.nbsp.materialfilepicker.ui.FilePickerActivity; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == 1 && resultCode == RESULT_OK) {
        File root = android.os.Environment.getExternalStorageDirectory();
        File dire = new File(root.getAbsolutePath() + "/Exames-App/Guias");
        String guiaPDFDir = dire.toString();

        String filePath = data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH);

        String guiaPath = "/Guia-" + filePath.substring(filePath.lastIndexOf("/") + 1);

        String finalGuiaPath = guiaPDFDir + guiaPath;

        Log.v("TAG", "guiaPath: " + guiaPath);
        Log.v("TAG", "guiaPDFDir: " + guiaPDFDir);

        Log.v("TAG", "finalGuiaPath: " + finalGuiaPath);
        // Do anything with filePath, that is, file.

        Intent executeExamesGo = new Intent(MainActivity.this, ExamesGoActivity.class);
        executeExamesGo.putExtra("FILE_PDF", filePath);
        executeExamesGo.putExtra("GUIA_PDF", finalGuiaPath);
        startActivity(executeExamesGo);
    } else if (requestCode == 0 && resultCode == RESULT_CANCELED) {
        Toast.makeText(this, "Whoops! Ocorreu um erro.", Toast.LENGTH_SHORT).show();
    }

}
 
开发者ID:kishannareshpal,项目名称:ExamesGithub,代码行数:31,代码来源:MainActivity.java

示例8: onActivityResult

import com.nbsp.materialfilepicker.ui.FilePickerActivity; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 1 && resultCode == RESULT_OK) {
        String filePath = data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH);
        new FileOpenTask(new File(filePath), LModActivity.this, editor.getEditor()).execute();
    }
}
 
开发者ID:Light-Team,项目名称:ModPE-IDE-Source,代码行数:9,代码来源:LModActivity.java

示例9: onActivityResult

import com.nbsp.materialfilepicker.ui.FilePickerActivity; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == Constants.REQUEST_CODE_FILE && resultCode == RESULT_OK && data != null)
        if (getSupportFragmentManager().findFragmentByTag(CollectionFragment.class.toString()) != null)
            ((CollectionFragment) getSupportFragmentManager().findFragmentByTag(
                    CollectionFragment.class.toString()))
                    .addComic(new File(data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH)));
}
 
开发者ID:owniz,项目名称:OzComicReader,代码行数:11,代码来源:MainActivity.java

示例10: onActivityResult

import com.nbsp.materialfilepicker.ui.FilePickerActivity; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 1 && resultCode == RESULT_OK) {
        filePath = data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH);
        mimeType= MimeType.LOCAL_FILE | MimeType.VIDEO;
        planeModeEnabled=planeMode.isChecked();
        start();
    }
}
 
开发者ID:Martin20150405,项目名称:Pano360,代码行数:11,代码来源:HomeActivity.java

示例11: onFileSelectedByFileChooser

import com.nbsp.materialfilepicker.ui.FilePickerActivity; //导入依赖的package包/类
/**
 * This will be executed if a file has been selected by file chooser. This method must be
 * implemented in the Parent-Activity in the method: onActivityResult
 * @param requestCode the request code
 * @param resultCode the result code
 * @param data the intent containing the path of selected data
 */
public void onFileSelectedByFileChooser(int requestCode, int resultCode, Intent data) {
    if (requestCode == FileChooserDialogs.PERMISSION_REQUEST_CODE && resultCode == RESULT_OK) {
        String filePath = data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH);

        UtilsRG.info("Selected file by file chooser. filepath = "+filePath);
        TastyToast.makeText(activity, "filepath="+filePath, TastyToast.LENGTH_LONG, TastyToast.INFO);

        JSONArray json = getJSONbyFilePath(filePath);
        new ImportViaJSON().importDataToDBbyJSON(json, activity);
    }
}
 
开发者ID:lidox,项目名称:reaction-test,代码行数:19,代码来源:FileChooserDialogs.java

示例12: chooseTestAsset

import com.nbsp.materialfilepicker.ui.FilePickerActivity; //导入依赖的package包/类
private void chooseTestAsset(File testAsset, final AssetType assetType)
        throws InterruptedException {
    final Intent data = new Intent();
    data.putExtra(FilePickerActivity.RESULT_FILE_PATH, testAsset.getAbsolutePath());
    final TaskCreateFragment fragment = getFragment();
    activityRule.getActivity().runOnUiThread(new Runnable() {
        public void run() {
            fragment.onActivityResult(assetType.ordinal(),
                    FilePickerActivity.RESULT_OK, data);
        }
    });
    Thread.sleep(CHOOSE_FILE_TIMEOUT);
}
 
开发者ID:autyzm-pg,项目名称:friendly-plans,代码行数:14,代码来源:AssetTestRule.java

示例13: whenActivityResultIsCalledWithNonExistingPictureDataExpectToastWithErrorMessageIsShown

import com.nbsp.materialfilepicker.ui.FilePickerActivity; //导入依赖的package包/类
@Test
public void whenActivityResultIsCalledWithNonExistingPictureDataExpectToastWithErrorMessageIsShown() {
    fragment.onActivityResult(
            AssetType.PICTURE.ordinal(),
            FilePickerActivity.RESULT_OK,
            new Intent()
    );
    String expectedMessage = activity.getResources().getString(R.string.picking_file_error);
    assertThat(ShadowToast.getTextOfLatestToast(), equalTo(expectedMessage));
}
 
开发者ID:autyzm-pg,项目名称:friendly-plans,代码行数:11,代码来源:TaskCreateActivityTest.java

示例14: whenActivityResultIsCalledWithNonExistingSoundDataExpectToastWithErrorMessageIsShown

import com.nbsp.materialfilepicker.ui.FilePickerActivity; //导入依赖的package包/类
@Test
public void whenActivityResultIsCalledWithNonExistingSoundDataExpectToastWithErrorMessageIsShown() {
    fragment.onActivityResult(
            AssetType.SOUND.ordinal(),
            FilePickerActivity.RESULT_OK,
            new Intent()
    );
    String expectedMessage = activity.getResources().getString(R.string.picking_file_error);
    assertThat(ShadowToast.getTextOfLatestToast(), equalTo(expectedMessage));
}
 
开发者ID:autyzm-pg,项目名称:friendly-plans,代码行数:11,代码来源:TaskCreateActivityTest.java

示例15: importFavorites

import com.nbsp.materialfilepicker.ui.FilePickerActivity; //导入依赖的package包/类
public void importFavorites(Intent intent) {
    String filePath = intent.getStringExtra(FilePickerActivity.RESULT_FILE_PATH);
    try {
        File file = new File(filePath);
        InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(file));
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
        String line;

        Stack<Integer> newFavorites = new Stack<>();
        while ((line = bufferedReader.readLine()) != null) {
            String[] numberTitle = line.split(" - ");
            int number = Integer.parseInt(numberTitle[0]);
            if (Arrays.binarySearch(favorites, number) < 0) {
                newFavorites.push(number);
                databaseManager.setFavorite(number, true);
                if (number <= ((MainActivity) getActivity()).getDatabaseManager().getHighestInDatabase())
                    ((MainActivity) getActivity()).getDatabaseManager().setFavorite(number, true);
            }
            if (!prefHelper.fullOfflineEnabled()) {
                new DownloadImageTask(newFavorites).execute();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(getActivity(), "Import failed", Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:T-Rex96,项目名称:Easy_xkcd,代码行数:28,代码来源:FavoritesFragment.java


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