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();
}
}
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;
}
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)));
}
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();
}
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();
}
}
Aggregations