Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringIndexOutOfBoundsException at com.codekidlabs.storagechooser.fragments.SecondaryChooserFragment.populateList(SecondaryChooserFragment.java:623) #104

Open
yhs0602 opened this issue Feb 24, 2019 · 5 comments
Assignees
Labels

Comments

@yhs0602
Copy link

yhs0602 commented Feb 24, 2019

yhs0602/Android-Disassembler#47

Well, it is said that StringIndexOutOfBoundsException is occuring from your code.

My code is here like this.

private void showFileChooser()
{
	requestAppPermissions(this);
	//SharedPreferences sharedPreferences = null;
	settingPath=getSharedPreferences("path",MODE_PRIVATE);
	String prepath=settingPath.getString(DiskUtil.SC_PREFERENCE_KEY,"/storage/emulated/0/");
	File tmp=new File(prepath);
	if(tmp.isFile())
	{
		tmp=tmp.getParentFile();
		prepath=tmp.getAbsolutePath();
	}
	SharedPreferences spPicker=getSharedPreferences(SETTINGKEY,MODE_PRIVATE);
	int picker=spPicker.getInt("Picker",0);
	switch(picker)
	{
		case 0:
			StorageChooser chooser = new StorageChooser.Builder()
				.withActivity(MainActivity.this)
				.withFragmentManager(getFragmentManager())
				.withMemoryBar(true)
				.allowCustomPath(true)
				.setType(StorageChooser.FILE_PICKER)
				.actionSave(true)		
				//.withPreference(settingPath)
			//	.withPredefinedPath(prepath)
				.shouldResumeSession(true)
				.showHidden(true)
				.build();
				// Show dialog whenever you want by
			//chooser.getsConfig().setPrimaryPath(prepath);
			chooser.show();
			// get path that the user has chosen
			chooser.setOnSelectListener(new StorageChooser.OnSelectListener() {
					@Override
					public void onSelect(String path) {
						SharedPreferences.Editor edi=settingPath.edit();
						edi.putString(DiskUtil.SC_PREFERENCE_KEY,path);
						edi.apply();
						disableEnableControls(false,llmainLinearLayoutSetupRaw);
						OnChoosePath(path);
						//Log.e("SELECTED_PATH", path);
					}
				});
			break;
		case 1:
			Intent i=new Intent(this, com.kyhsgeekcode.rootpicker.FileSelectorActivity.class);
			startActivityForResult(i, REQUEST_SELECT_FILE);		
			break;
	}	//	
}
@codekidX codekidX added the bug label Feb 25, 2019
@codekidX codekidX self-assigned this Feb 25, 2019
@codekidX codekidX added this to the 3.0 milestone Feb 25, 2019
@codekidX
Copy link
Owner

Hi, thanks for letting me know. I have got this weird bug sometimes but I couldn't spot the error as the next time it would work. The dev-3.0 branch is now rewritten in Kotlin and has a fresh codebase so I hope this won't come in the next release as well.

I'm not closing this issue until 3.0.

@codekidX codekidX removed this from the 3.0 milestone Mar 20, 2019
@rahulpopuri
Copy link
Contributor

+1 My users are reporting this issue too

Until this is fixed, should I just be catching the StringIndexOutOfBoundsException and retrying?

@muzzikapp
Copy link

Fixed in my fork branch, basicly what i do is if i got an exception i set the selected folder to default music folder (at least app doesnt crash because of this)

https://github.com/muzzikapp/storage-chooser

@codekidX
Copy link
Owner

@muzzikapp thanks for this. Was there any reason why you weren't able to create PR?

@muzzikapp
Copy link

@muzzikapp thanks for this. Was there any reason why you weren't able to create PR?

@codekidX you are welcome. I didn't create a PR just because my fix is just intended to be used in my app. But if you think it is a good way of handling this error, i can create a PR as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants