update fileName

This commit is contained in:
吴尚昆 2022-03-02 20:43:11 +08:00 committed by osborn
parent 08cc6cd293
commit fcc016d81c

View File

@ -28,6 +28,7 @@ import android.text.Html;
import android.text.Layout; import android.text.Layout;
import android.text.Spanned; import android.text.Spanned;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
@ -258,6 +259,7 @@ public class TextNode extends ViewNode<TextView> {
} }
} else if (prop.isObject()) { } else if (prop.isObject()) {
final JSObject resource = prop.asObject(); final JSObject resource = prop.asObject();
final String identifier = resource.getProperty("identifier").asString().value();
final DoricResource doricResource = getDoricContext().getDriver().getRegistry().getResourceManager() final DoricResource doricResource = getDoricContext().getDriver().getRegistry().getResourceManager()
.load(getDoricContext(), resource); .load(getDoricContext(), resource);
if (doricResource != null) { if (doricResource != null) {
@ -271,7 +273,7 @@ public class TextNode extends ViewNode<TextView> {
} else { } else {
filePath = getContext().getFilesDir().getPath() + "/customFonts"; filePath = getContext().getFilesDir().getPath() + "/customFonts";
} }
File file = createFile(fontData, filePath, "tempFont.ttf"); File file = createFile(fontData, filePath, (identifier == null) ? "tempFont.ttf" : identifier);
Typeface customFont = Typeface.createFromFile(file); Typeface customFont = Typeface.createFromFile(file);
view.setTypeface(customFont); view.setTypeface(customFont);
} catch (Exception e) { } catch (Exception e) {
@ -461,6 +463,7 @@ public class TextNode extends ViewNode<TextView> {
if(!dir.exists()&&dir.isDirectory()){ // 判断文件目录是否存在 if(!dir.exists()&&dir.isDirectory()){ // 判断文件目录是否存在
dir.mkdirs(); dir.mkdirs();
} }
Log.d("font", fileName);
file = new File(filePath+"\\"+fileName); file = new File(filePath+"\\"+fileName);
fos = new FileOutputStream(file); fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos); bos = new BufferedOutputStream(fos);