feat: util.format() supports java array
This commit is contained in:
@@ -41,7 +41,6 @@ import com.stardust.scriptdroid.ui.widget.EWebView;
|
|||||||
import com.stardust.scriptdroid.ui.widget.SimpleTextWatcher;
|
import com.stardust.scriptdroid.ui.widget.SimpleTextWatcher;
|
||||||
import com.stardust.scriptdroid.ui.widget.ToolbarMenuItem;
|
import com.stardust.scriptdroid.ui.widget.ToolbarMenuItem;
|
||||||
import com.stardust.util.BackPressedHandler;
|
import com.stardust.util.BackPressedHandler;
|
||||||
import com.stardust.util.ViewUtil;
|
|
||||||
import com.stardust.util.ViewUtils;
|
import com.stardust.util.ViewUtils;
|
||||||
import com.stardust.widget.ViewSwitcher;
|
import com.stardust.widget.ViewSwitcher;
|
||||||
|
|
||||||
@@ -393,7 +392,7 @@ public class EditorView extends FrameLayout implements CodeCompletionBar.OnHintC
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void selectTextSize() {
|
public void selectTextSize() {
|
||||||
new TextSizeChangeDialogBuilder(getContext())
|
new TextSizeSettingDialogBuilder(getContext())
|
||||||
.initialValue((int) ViewUtils.pxToSp(getContext(), mEditor.getCodeEditText().getTextSize()))
|
.initialValue((int) ViewUtils.pxToSp(getContext(), mEditor.getCodeEditText().getTextSize()))
|
||||||
.callback(this::setTextSize)
|
.callback(this::setTextSize)
|
||||||
.show();
|
.show();
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import butterknife.ButterKnife;
|
|||||||
* Created by Stardust on 2018/2/24.
|
* Created by Stardust on 2018/2/24.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class TextSizeChangeDialogBuilder extends ThemeColorMaterialDialogBuilder implements SeekBar.OnSeekBarChangeListener {
|
public class TextSizeSettingDialogBuilder extends ThemeColorMaterialDialogBuilder implements SeekBar.OnSeekBarChangeListener {
|
||||||
|
|
||||||
|
|
||||||
public interface PositiveCallback {
|
public interface PositiveCallback {
|
||||||
@@ -36,9 +36,9 @@ public class TextSizeChangeDialogBuilder extends ThemeColorMaterialDialogBuilder
|
|||||||
private int mTextSize;
|
private int mTextSize;
|
||||||
private MaterialDialog mMaterialDialog;
|
private MaterialDialog mMaterialDialog;
|
||||||
|
|
||||||
public TextSizeChangeDialogBuilder(@NonNull Context context) {
|
public TextSizeSettingDialogBuilder(@NonNull Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
View view = View.inflate(context, R.layout.dialog_text_size_change, null);
|
View view = View.inflate(context, R.layout.dialog_text_size_setting, null);
|
||||||
customView(view, false);
|
customView(view, false);
|
||||||
title(R.string.text_text_size);
|
title(R.string.text_text_size);
|
||||||
positiveText(R.string.ok);
|
positiveText(R.string.ok);
|
||||||
@@ -58,12 +58,12 @@ public class TextSizeChangeDialogBuilder extends ThemeColorMaterialDialogBuilder
|
|||||||
mPreviewText.setTextSize(textSize);
|
mPreviewText.setTextSize(textSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextSizeChangeDialogBuilder initialValue(int value) {
|
public TextSizeSettingDialogBuilder initialValue(int value) {
|
||||||
mSeekBar.setProgress(value - MIN);
|
mSeekBar.setProgress(value - MIN);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextSizeChangeDialogBuilder callback(PositiveCallback callback) {
|
public TextSizeSettingDialogBuilder callback(PositiveCallback callback) {
|
||||||
onPositive((dialog, which) -> callback.onPositive(mTextSize));
|
onPositive((dialog, which) -> callback.onPositive(mTextSize));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -33,6 +33,7 @@ import com.stardust.scriptdroid.BuildConfig;
|
|||||||
import com.stardust.scriptdroid.ui.edit.theme.Theme;
|
import com.stardust.scriptdroid.ui.edit.theme.Theme;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Administrator on 2018/2/11.
|
* Created by Administrator on 2018/2/11.
|
||||||
|
|||||||
@@ -213,9 +213,8 @@ function arrayToHash(array) {
|
|||||||
function formatValue(ctx, value, recurseTimes) {
|
function formatValue(ctx, value, recurseTimes) {
|
||||||
// Provide a hook for user-specified inspect functions.
|
// Provide a hook for user-specified inspect functions.
|
||||||
// Check that value is an object with an inspect function on it
|
// Check that value is an object with an inspect function on it
|
||||||
if (ctx.customInspect &&
|
if (ctx.customInspect && value && value instanceof Object &&
|
||||||
value &&
|
("inspect" in value) && isFunction(value.inspect) &&
|
||||||
isFunction(value.inspect) &&
|
|
||||||
// Filter out the util module, it's inspect function is special
|
// Filter out the util module, it's inspect function is special
|
||||||
value.inspect !== exports.inspect &&
|
value.inspect !== exports.inspect &&
|
||||||
// Also filter out any prototype objects using the circular check.
|
// Also filter out any prototype objects using the circular check.
|
||||||
@@ -227,6 +226,10 @@ function formatValue(ctx, value, recurseTimes) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(value && isFunction(value.getClass) && value.getClass().isArray()){
|
||||||
|
return formatJavaArray(value);
|
||||||
|
}
|
||||||
|
|
||||||
// Primitive types cannot have properties
|
// Primitive types cannot have properties
|
||||||
var primitive = formatPrimitive(ctx, value);
|
var primitive = formatPrimitive(ctx, value);
|
||||||
if (primitive) {
|
if (primitive) {
|
||||||
@@ -345,6 +348,9 @@ function formatPrimitive(ctx, value) {
|
|||||||
return ctx.stylize('null', 'null');
|
return ctx.stylize('null', 'null');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatJavaArray(javaArray){
|
||||||
|
return java.util.Arrays.toString(javaArray);
|
||||||
|
}
|
||||||
|
|
||||||
function formatError(value) {
|
function formatError(value) {
|
||||||
return '[' + Error.prototype.toString.call(value) + ']';
|
return '[' + Error.prototype.toString.call(value) + ']';
|
||||||
|
|||||||
Reference in New Issue
Block a user