我试图将Python代码实现为等效的Scla代码,但混淆了特定的代码段。代码是
public class FileOpener extends AsyncTask<String, Void, Uri> {
private ThreadLocal<Context> context;
private String type;
public FileOpener(Context context, ProgressBar loading) {
this.context = new ThreadLocal<>();
this.context.set(context);
}
@Override
protected Uri doInBackground(String[] data) {
//At index 0 are stored the bytes, index 1 is stored the name
//and index 2 is stored the type
type = data[2];
java.io.File file = new File(context.get().getFilesDir(), data[1]);
byte[] bytes = FileManager.convertBytesToFile(data[0]);
FileManager.writeToFile(context.get(), bytes, data[1]);
}
@Override
protected void onPostExecute(Uri uri) {
}
}
关于代码的更多详细信息是here