// Determine device posture. mInfo = info; isTablet = info.isTablet(windowBounds); isPhone = !isTablet; isTwoPanels = isTablet && useTwoPanels; isTaskbarPresent = isTablet && ApiWrapper.TASKBAR_DRAWN_IN_PROCESS; // Some more constants. context = getContext(context, info, isVerticalBarLayout() || (isTablet && isLandscape) ? Configuration.ORIENTATION_LANDSCAPE : Configuration.ORIENTATION_PORTRAIT, windowBounds); final Resources res = context.getResources(); mMetrics = res.getDisplayMetrics();
时间: 2024-02-14 08:26:52 浏览: 159
这段代码是用于确定设备的姿势(posture)的。它首先获取一个DeviceInfo对象,然后使用该对象的方法来判断设备是平板还是手机。如果设备是平板,则设置isTablet为true,否则设置为false。接下来,根据isTablet的值和useTwoPanels的值,判断是否需要使用两个面板。然后,根据设备的方向(横向或纵向)和窗口边界,获取一个Context对象。最后,通过获取Context对象的Resources对象,获取设备的显示度量信息(DisplayMetrics)。
相关问题
//@version=5 indicator("Multi-Divergence Buy/Sell Indicator", overlay=true) // Input parameters rsiLength = input(14, "RSI Length") macdShortLength = input(12, "MACD Short Length") macdLongLength = input(26, "MACD Long Length") macdSignalSmoothing = input(9, "MACD Signal Smoothing") stochLength = input(14, "Stochastic Length") stochOverbought = input(80, "Stochastic Overbought Level") stochOversold = input(20, "Stochastic Oversold Level") // Calculate RSI rsi = ta.rsi(close, rsiLength) // Calculate MACD [macdLine, signalLine, _] = ta.macd(close, macdShortLength, macdLongLength, macdSignalSmoothing) // Calculate Stochastic stoch = ta.stoch(close, high, low, stochLength) // Determine divergences rsiDivergence = ta.crossover(rsi, ta.sma(rsi, 14)) macdDivergence = ta.crossover(macdLine, signalLine) stochDivergence = ta.crossover(stoch, ta.sma(stoch, 14)) // Determine buy/sell conditions buyCondition = rsiDivergence and macdDivergence and stochDivergence sellCondition = rsiDivergence and macdDivergence and not stochDivergence // Plotting buy/sell signals plotshape(buyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="Buy") plotshape(sellCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell")
对于这段代码,它是一个使用多种技术指标来判断买入或卖出的交易所使用的指标。其中,使用了RSI、MACD和Stochastic三种指标,并且通过判断它们的背离情况来确定买入/卖出的条件。其中,RSI背离、MACD背离和Stochastic背离同时出现时,判断为买入条件;RSI背离、MACD背离但Stochastic没有背离时,判断为卖出条件。最后,使用plotshape函数来绘制买入/卖出信号。
if (windows.InvokeRequired)//determine the thread now whether is the thread that creat the ui { if (windows.Text == "")//it is not { windows.BeginInvoke(new Action<string>(s =>//avoid accorss thread is invalid { this.windows.Text = string.Format("{0}", txt); }), txt); } else { windows.BeginInvoke(new Action<string>(s => { this.windows.Text = string.Format("{0}\r\n{1}", windows.Text, txt); }), txt); } }这段代码中我的if (windows.Text == "")报错怎么修改
在跨线程访问 UI 控件时,必须使用 UI 线程来更新控件。在这种情况下,最好使用 Invoke 或 BeginInvoke 方法来执行 UI 操作。您的代码中使用了 BeginInvoke 方法。
关于您的问题,如果您想检查文本框中是否有文本,可以使用以下代码:
if (string.IsNullOrEmpty(windows.Text))
或者
if (windows.Text.Length == 0)
所以您的代码应该修改为:
if (windows.InvokeRequired)
{
if (string.IsNullOrEmpty(windows.Text))
{
windows.BeginInvoke(new Action<string>(s =>
{
this.windows.Text = string.Format("{0}", txt);
}), txt);
}
else
{
windows.BeginInvoke(new Action<string>(s =>
{
this.windows.Text = string.Format("{0}\r\n{1}", windows.Text, txt);
}), txt);
}
}
阅读全文