Search in sources :

Example 96 with URISyntaxException

use of java.net.URISyntaxException in project FileExplorer by MiCode.

the class FileViewActivity method onPick.

@Override
public void onPick(FileInfo f) {
    try {
        Intent intent = Intent.parseUri(Uri.fromFile(new File(f.filePath)).toString(), 0);
        mActivity.setResult(Activity.RESULT_OK, intent);
        mActivity.finish();
        return;
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
}
Also used : Intent(android.content.Intent) URISyntaxException(java.net.URISyntaxException) File(java.io.File)

Example 97 with URISyntaxException

use of java.net.URISyntaxException in project FileExplorer by MiCode.

the class FileViewActivity method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mActivity = getActivity();
    // getWindow().setFormat(android.graphics.PixelFormat.RGBA_8888);
    mRootView = inflater.inflate(R.layout.file_explorer_list, container, false);
    ActivitiesManager.getInstance().registerActivity(ActivitiesManager.ACTIVITY_FILE_VIEW, mActivity);
    mFileCagetoryHelper = new FileCategoryHelper(mActivity);
    mFileViewInteractionHub = new FileViewInteractionHub(this);
    Intent intent = mActivity.getIntent();
    String action = intent.getAction();
    if (!TextUtils.isEmpty(action) && (action.equals(Intent.ACTION_PICK) || action.equals(Intent.ACTION_GET_CONTENT))) {
        mFileViewInteractionHub.setMode(Mode.Pick);
        boolean pickFolder = intent.getBooleanExtra(PICK_FOLDER, false);
        if (!pickFolder) {
            String[] exts = intent.getStringArrayExtra(EXT_FILTER_KEY);
            if (exts != null) {
                mFileCagetoryHelper.setCustomCategory(exts);
            }
        } else {
            mFileCagetoryHelper.setCustomCategory(new String[] {});
            mRootView.findViewById(R.id.pick_operation_bar).setVisibility(View.VISIBLE);
            mRootView.findViewById(R.id.button_pick_confirm).setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    try {
                        Intent intent = Intent.parseUri(mFileViewInteractionHub.getCurrentPath(), 0);
                        mActivity.setResult(Activity.RESULT_OK, intent);
                        mActivity.finish();
                    } catch (URISyntaxException e) {
                        e.printStackTrace();
                    }
                }
            });
            mRootView.findViewById(R.id.button_pick_cancel).setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    mActivity.finish();
                }
            });
        }
    } else {
        mFileViewInteractionHub.setMode(Mode.View);
    }
    mFileListView = (ListView) mRootView.findViewById(R.id.file_path_list);
    mFileIconHelper = new FileIconHelper(mActivity);
    mAdapter = new FileListAdapter(mActivity, R.layout.file_browser_item, mFileNameList, mFileViewInteractionHub, mFileIconHelper);
    boolean baseSd = intent.getBooleanExtra(GlobalConsts.KEY_BASE_SD, !FileExplorerPreferenceActivity.isReadRoot(mActivity));
    Log.i(LOG_TAG, "baseSd = " + baseSd);
    String rootDir = intent.getStringExtra(ROOT_DIRECTORY);
    if (!TextUtils.isEmpty(rootDir)) {
        if (baseSd && this.sdDir.startsWith(rootDir)) {
            rootDir = this.sdDir;
        }
    } else {
        rootDir = baseSd ? this.sdDir : GlobalConsts.ROOT_PATH;
    }
    mFileViewInteractionHub.setRootPath(rootDir);
    String currentDir = FileExplorerPreferenceActivity.getPrimaryFolder(mActivity);
    Uri uri = intent.getData();
    if (uri != null) {
        if (baseSd && this.sdDir.startsWith(uri.getPath())) {
            currentDir = this.sdDir;
        } else {
            currentDir = uri.getPath();
        }
    }
    mFileViewInteractionHub.setCurrentPath(currentDir);
    Log.i(LOG_TAG, "CurrentDir = " + currentDir);
    mBackspaceExit = (uri != null) && (TextUtils.isEmpty(action) || (!action.equals(Intent.ACTION_PICK) && !action.equals(Intent.ACTION_GET_CONTENT)));
    mFileListView.setAdapter(mAdapter);
    mFileViewInteractionHub.refreshFileList();
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
    intentFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
    intentFilter.addDataScheme("file");
    mActivity.registerReceiver(mReceiver, intentFilter);
    updateUI();
    setHasOptionsMenu(true);
    return mRootView;
}
Also used : IntentFilter(android.content.IntentFilter) Intent(android.content.Intent) URISyntaxException(java.net.URISyntaxException) View(android.view.View) ListView(android.widget.ListView) Uri(android.net.Uri) OnClickListener(android.view.View.OnClickListener)

Example 98 with URISyntaxException

use of java.net.URISyntaxException in project ribbon by Netflix.

the class LoadBalancingHttpClient method submitToServerInURI.

/**
     * Submits the request to the server indicated in the URI
     * @param request
     * @param requestConfig
     * @param config
     * @param errorHandler
     * @param context
     * @return
     */
private Observable<HttpClientResponse<O>> submitToServerInURI(HttpClientRequest<I> request, IClientConfig requestConfig, ClientConfig config, RetryHandler errorHandler, ExecutionContext<HttpClientRequest<I>> context) {
    // First, determine server from the URI
    URI uri;
    try {
        uri = new URI(request.getUri());
    } catch (URISyntaxException e) {
        return Observable.error(e);
    }
    String host = uri.getHost();
    if (host == null) {
        return null;
    }
    int port = uri.getPort();
    if (port < 0) {
        if (clientConfig.getPropertyAsBoolean(IClientConfigKey.Keys.IsSecure, false)) {
            port = 443;
        } else {
            port = 80;
        }
    }
    return LoadBalancerCommand.<HttpClientResponse<O>>builder().withRetryHandler(errorHandler).withLoadBalancerContext(lbContext).withListeners(listeners).withExecutionContext(context).withServer(new Server(host, port)).build().submit(this.requestToOperation(request, getRxClientConfig(requestConfig, config)));
}
Also used : Server(com.netflix.loadbalancer.Server) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 99 with URISyntaxException

use of java.net.URISyntaxException in project feign by OpenFeign.

the class ApacheHttpClient method execute.

@Override
public Response execute(Request request, Request.Options options) throws IOException {
    HttpUriRequest httpUriRequest;
    try {
        httpUriRequest = toHttpUriRequest(request, options);
    } catch (URISyntaxException e) {
        throw new IOException("URL '" + request.url() + "' couldn't be parsed into a URI", e);
    }
    HttpResponse httpResponse = client.execute(httpUriRequest);
    return toFeignResponse(httpResponse).toBuilder().request(request).build();
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) HttpResponse(org.apache.http.HttpResponse) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Example 100 with URISyntaxException

use of java.net.URISyntaxException in project OpenGrok by OpenGrok.

the class ResultsControl method openInBrowser.

private void openInBrowser(String location, int lineNo) {
    try {
        String baseUrl = Activator.getDefault().getPreferenceStore().getString(EGrokPreferencePage.BASE_URL);
        baseUrl += "/xref" + location;
        if (lineNo > -1) {
            baseUrl += "#" + lineNo;
        }
        Desktop.getDesktop().browse(new URI(baseUrl));
    } catch (IOException | URISyntaxException e) {
        e.printStackTrace();
    }
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Aggregations

URISyntaxException (java.net.URISyntaxException)1378 URI (java.net.URI)906 IOException (java.io.IOException)375 URL (java.net.URL)242 File (java.io.File)237 ArrayList (java.util.ArrayList)127 Test (org.testng.annotations.Test)88 Response (javax.ws.rs.core.Response)87 InputStream (java.io.InputStream)84 Builder (javax.ws.rs.client.Invocation.Builder)84 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)84 Parameters (org.testng.annotations.Parameters)84 BaseTest (org.xdi.oxauth.BaseTest)84 ResponseType (org.xdi.oxauth.model.common.ResponseType)84 MalformedURLException (java.net.MalformedURLException)83 AuthorizationRequest (org.xdi.oxauth.client.AuthorizationRequest)78 REGISTRATION_CLIENT_URI (org.xdi.oxauth.model.register.RegisterResponseParam.REGISTRATION_CLIENT_URI)72 HashMap (java.util.HashMap)70 Intent (android.content.Intent)61 Test (org.junit.Test)61