当前位置: 编程技术>移动开发
本页文章导读:
▪穿梭NTLM HTTPProxy 穿越NTLM HTTPProxy
1、Http连接有两种方法穿越NTLM的HTTP Proxy。1.1、第一种使用HttpURLConnection,详细参见:http://www.ibm.com/developerworks/cn/java/j-lo-jse62/index.html1.2、第二种是使用org.apache.commons.httpclien.........
▪ 在Titanium中兑现图片的Rotate和Pinch Gesture 在Titanium中实现图片的Rotate和Pinch Gesture
在iPhone中,图片的缩放,移动,旋转以及Pinch Gesture功能在Titanium Mobile中并不支持这样Gesture。这里有人做了一个Module来实现这个功能。(只限于iOS)G.........
▪ 在Titanium中处置手机的方向 在Titanium中处理手机的方向
【原文】Handling Device OrientationRun-time Device Orientation DetectionYou can detect the current device orientation by checking value of the Ti.UI.orientation property. This value will match one of the ori.........
[1]穿梭NTLM HTTPProxy
来源: 互联网 发布时间: 2014-02-18
穿越NTLM HTTPProxy
1、Http连接有两种方法穿越NTLM的HTTP Proxy。
1.1、第一种使用HttpURLConnection,详细参见:
http://www.ibm.com/developerworks/cn/java/j-lo-jse62/index.html
1.2、第二种是使用org.apache.commons.httpclient.HttpClient,该类介绍详见:
http://blog.csdn.net/joy_jiang/archive/2005/03/17/321858.aspx
2、axis 1.4的包中使用的HTTP通信的类是org.apache.axis.transport.http.HTTPSender,该类使用了Socket直接通信
3、为了实现穿越NTLM的HTTP代理,修改org.apache.axis.client包下的client-config.wsdd文件,axis提供了1.2的方式解决ntlm认证的问题。
<transport name="http" pivot="java:org.apache.axis.transport.http.CommonsHTTPSender"> < transport name="http" pivot="java:org.apache.axis.transport.http.CommonsHTTPSender"/ >
4、axis 1.4的CommonsHTTPSender有问题(也许只是某些下载版本),直接运行会报host is null类似的错,细观之,发现getHostConfiguration函数中在走proxy的时候未调用config.setHost(....)所致,修改后重新打包
5、需要穿越proxy的时候,添加下面代码即可。
</transport>
Properties systemSettings = System.getProperties();<o:p></o:p>
systemSettings.put("http.proxyHost","xxx.com") ;<o:p></o:p>
systemSettings.put("http.proxyPort", "8080") ;<o:p></o:p>
systemSettings.put("http.proxyUser", "domain\\name") ;<o:p></o:p>
systemSettings.put("http.proxyPassword", "123456") ;<o:p></o:p>
http://docs.oracle.com/javase/6/docs/technotes/guides/net/http-auth.html
1、Http连接有两种方法穿越NTLM的HTTP Proxy。
1.1、第一种使用HttpURLConnection,详细参见:
http://www.ibm.com/developerworks/cn/java/j-lo-jse62/index.html
1.2、第二种是使用org.apache.commons.httpclient.HttpClient,该类介绍详见:
http://blog.csdn.net/joy_jiang/archive/2005/03/17/321858.aspx
2、axis 1.4的包中使用的HTTP通信的类是org.apache.axis.transport.http.HTTPSender,该类使用了Socket直接通信
3、为了实现穿越NTLM的HTTP代理,修改org.apache.axis.client包下的client-config.wsdd文件,axis提供了1.2的方式解决ntlm认证的问题。
<transport name="http" pivot="java:org.apache.axis.transport.http.CommonsHTTPSender"> < transport name="http" pivot="java:org.apache.axis.transport.http.CommonsHTTPSender"/ >
4、axis 1.4的CommonsHTTPSender有问题(也许只是某些下载版本),直接运行会报host is null类似的错,细观之,发现getHostConfiguration函数中在走proxy的时候未调用config.setHost(....)所致,修改后重新打包
5、需要穿越proxy的时候,添加下面代码即可。
</transport>
Properties systemSettings = System.getProperties();<o:p></o:p>
systemSettings.put("http.proxyHost","xxx.com") ;<o:p></o:p>
systemSettings.put("http.proxyPort", "8080") ;<o:p></o:p>
systemSettings.put("http.proxyUser", "domain\\name") ;<o:p></o:p>
systemSettings.put("http.proxyPassword", "123456") ;<o:p></o:p>
http://docs.oracle.com/javase/6/docs/technotes/guides/net/http-auth.html
[2] 在Titanium中兑现图片的Rotate和Pinch Gesture
来源: 互联网 发布时间: 2014-02-18
在Titanium中实现图片的Rotate和Pinch Gesture
在iPhone中,图片的缩放,移动,旋转以及Pinch Gesture功能在Titanium Mobile中并不支持这样Gesture。这里有人做了一个Module来实现这个功能。(只限于iOS)
Gesture-Recognizer
在view中将rotateGesture、pinchGesture设置为true后,就能处理rotate,pinch的事件了。
Gesture完成后,将触发rotateend、pinchend事件。
代码大概是下边这样:
效果图如下:
在iPhone中,图片的缩放,移动,旋转以及Pinch Gesture功能在Titanium Mobile中并不支持这样Gesture。这里有人做了一个Module来实现这个功能。(只限于iOS)
Gesture-Recognizer
在view中将rotateGesture、pinchGesture设置为true后,就能处理rotate,pinch的事件了。
Gesture完成后,将触发rotateend、pinchend事件。
代码大概是下边这样:
var window = Ti.UI.createWindow({ orientationModes:[ Ti.UI.LANDSCAPE_LEFT, Ti.UI.LANDSCAPE_RIGHT, Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT ] }); var image = Ti.UI.createImageView({ image:"lena_std.jpg", rotateGesture:true, pinchGesture:true }); var lastAngle = 0.0; var currentAngle = 0.0; var lastScale = 1.0; var currentScale = 1.0; image.addEventListener('rotate', function(e){ currentAngle = e.rotation / Math.PI * 180.0; image.transform = Ti.UI.create2DMatrix() .scale(lastScale*currentScale) .rotate(lastAngle+currentAngle); }); image.addEventListener('rotateend', function(e){ lastAngle = (lastAngle + currentAngle) % 360.0; currentAngle = 0.0; }); image.addEventListener('pinch', function(e){ currentScale = e.scale; image.transform = Ti.UI.create2DMatrix() .scale(lastScale*currentScale) .rotate(lastAngle+currentAngle); }); image.addEventListener('pinchend', function(e){ lastScale = (lastScale * currentScale); currentScale = 1.0; }); window.add(image); window.open();
效果图如下:
[3] 在Titanium中处置手机的方向
来源: 互联网 发布时间: 2014-02-18
在Titanium中处理手机的方向
【原文】Handling Device Orientation
Run-time Device Orientation Detection
You can detect the current device orientation by checking value of the Ti.UI.orientation property. This value will match one of the orientation constants defined under the Ti.UI namespace:
An example use of this property might be to define helper functions to determine if the device is in a landscape or portrait orientation:
Handling Orientation Changes
Orientation changes can be detected by attaching an event listener for orientationchange event in the Ti.Gesture module:
The updated device orientation can be read from orientation property of the event object passed to the callback, which will be defined as one of:
Using our helper function above, you might use the following code to redraw your application UI based on device orientation:
Changing Device Orientation Programmatically
There are two ways of changing the device orientation in JavaScript. One can modify Ti.UI global value or limit the number of supported orientations for a given window object.
Changing the global orientation
First, you can change it directly by updating the value of Ti.UI.orientation property with the appropriate orientation constant:
This approach is recommended if you need to permanently change device orientation and stick to it. You can accomplish the same thing using the orientation section of the tiapp.xml file (for iOS).
Limiting supported orientation modes for a given window
You can limit allowed orientations for a Window object. Then device will go into the desired orientation whenever the window is opened:
This specific window will support only landscape mode, so whenever you call win.open() or Ti.UI.currentTab.open(win) the device will go landscape. Whenever you close close the window (or user navigate back using navigation controller) the screen will return back to the actual physical orientation of the device.
You can also update orientationModes of existing windows (including the opened one):
【原文】Handling Device Orientation
Run-time Device Orientation Detection
You can detect the current device orientation by checking value of the Ti.UI.orientation property. This value will match one of the orientation constants defined under the Ti.UI namespace:
- Ti.UI.PORTRAIT
- Ti.UI.UPSIDE_PORTRAIT
- Ti.UI.LANDSCAPE_LEFT
- Ti.UI.LANDSCAPE_RIGHT
An example use of this property might be to define helper functions to determine if the device is in a landscape or portrait orientation:
Ti.Gesture.isLandscape = function (orient) { orient = orient || Ti.UI.orientation; return orient == Ti.UI.LANDSCAPE_LEFT || orient == Ti.UI.LANDSCAPE_RIGHT; }; Ti.Gesture.isPortrait = function (orient) { orient = orient || Ti.UI.orientation; return orient == Ti.UI.PORTRAIT || orient == Ti.UI.UPSIDE_PORTRAIT; };
Handling Orientation Changes
Orientation changes can be detected by attaching an event listener for orientationchange event in the Ti.Gesture module:
Ti.Gesture.addEventListener('orientationchange', function (e) { // Put your handling code here });
The updated device orientation can be read from orientation property of the event object passed to the callback, which will be defined as one of:
- Ti.UI.PORTRAIT
- Ti.UI.UPSIDE_PORTRAIT
- Ti.UI.LANDSCAPE_LEFT
- Ti.UI.LANDSCAPE_RIGHT
Using our helper function above, you might use the following code to redraw your application UI based on device orientation:
Ti.Gesture.addEventListener('orientationchange', function (ev) { if (Ti.Gesture.isLandscape(ev.orientation)) { // Update your UI for landscape orientation } else { // Update your UI for portrait orientation } });
Changing Device Orientation Programmatically
There are two ways of changing the device orientation in JavaScript. One can modify Ti.UI global value or limit the number of supported orientations for a given window object.
Changing the global orientation
First, you can change it directly by updating the value of Ti.UI.orientation property with the appropriate orientation constant:
Ti.UI.orientation = Ti.UI.PORTRAIT;
This approach is recommended if you need to permanently change device orientation and stick to it. You can accomplish the same thing using the orientation section of the tiapp.xml file (for iOS).
Limiting supported orientation modes for a given window
You can limit allowed orientations for a Window object. Then device will go into the desired orientation whenever the window is opened:
var win = Ti.UI.createWindow({ width: '100%', height: '100%', orientationModes: [ Titanium.UI.LANDSCAPE_LEFT, Titanium.UI.LANDSCAPE_RIGHT ] });
This specific window will support only landscape mode, so whenever you call win.open() or Ti.UI.currentTab.open(win) the device will go landscape. Whenever you close close the window (or user navigate back using navigation controller) the screen will return back to the actual physical orientation of the device.
You can also update orientationModes of existing windows (including the opened one):
Ti.UI.currentWindow.orientationModes = [ Titanium.UI.LANDSCAPE_LEFT, Titanium.UI.LANDSCAPE_RIGHT ];
最新技术文章: