Search in sources :

Example 1 with FilePickerListener

use of com.odysee.app.listener.FilePickerListener in project odysee-android by OdyseeTeam.

the class MainActivity method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_FILE_PICKER) {
        startingFilePickerActivity = false;
        if (resultCode == RESULT_OK && data != null) {
            Uri fileUri = data.getData();
            String filePath = Helper.getRealPathFromURI_API19(this, fileUri);
            for (FilePickerListener listener : filePickerListeners) {
                listener.onFilePicked(filePath);
            }
        } else {
            for (FilePickerListener listener : filePickerListeners) {
                listener.onFilePickerCancelled();
            }
        }
    } else if (requestCode == REQUEST_SIMPLE_SIGN_IN || requestCode == REQUEST_WALLET_SYNC_SIGN_IN) {
        if (resultCode == RESULT_OK) {
            // user signed in
            if (requestCode == REQUEST_WALLET_SYNC_SIGN_IN) {
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
                sp.edit().putBoolean(MainActivity.PREFERENCE_KEY_INTERNAL_WALLET_SYNC_ENABLED, true).apply();
                WalletFragment f = (WalletFragment) getSupportFragmentManager().findFragmentByTag("WALLET");
                if (f != null) {
                    f.onWalletSyncEnabled();
                }
                scheduleWalletSyncTask();
            }
        }
    } else if (requestCode == REQUEST_VIDEO_CAPTURE || requestCode == REQUEST_TAKE_PHOTO) {
        if (resultCode == RESULT_OK) {
            PublishFragment publishFragment = null;
            PublishFragment f = (PublishFragment) getSupportFragmentManager().findFragmentByTag("PUBLISH");
            if (f != null) {
                publishFragment = (PublishFragment) f;
            }
            Map<String, Object> params = new HashMap<>();
            params.put("directFilePath", cameraOutputFilename);
            if (publishFragment != null) {
                params.put("suggestedUrl", publishFragment.getSuggestedPublishUrl());
            }
        // openFragment(PublishFormFragment.class, true, NavMenuItem.ID_ITEM_NEW_PUBLISH, params);
        }
        cameraOutputFilename = null;
    }
}
Also used : PublishFragment(com.odysee.app.ui.publish.PublishFragment) WalletFragment(com.odysee.app.ui.wallet.WalletFragment) FilePickerListener(com.odysee.app.listener.FilePickerListener) SharedPreferences(android.content.SharedPreferences) HashMap(java.util.HashMap) JSONObject(org.json.JSONObject) SpannableString(android.text.SpannableString) LbryUri(com.odysee.app.utils.LbryUri) Uri(android.net.Uri)

Aggregations

SharedPreferences (android.content.SharedPreferences)1 Uri (android.net.Uri)1 SpannableString (android.text.SpannableString)1 FilePickerListener (com.odysee.app.listener.FilePickerListener)1 PublishFragment (com.odysee.app.ui.publish.PublishFragment)1 WalletFragment (com.odysee.app.ui.wallet.WalletFragment)1 LbryUri (com.odysee.app.utils.LbryUri)1 HashMap (java.util.HashMap)1 JSONObject (org.json.JSONObject)1