本文整理汇总了Java中com.taobao.weex.common.WXModuleAnno类的典型用法代码示例。如果您正苦于以下问题:Java WXModuleAnno类的具体用法?Java WXModuleAnno怎么用?Java WXModuleAnno使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WXModuleAnno类属于com.taobao.weex.common包,在下文中一共展示了WXModuleAnno类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setItem
import com.taobao.weex.common.WXModuleAnno; //导入依赖的package包/类
@Override
@WXModuleAnno
public void setItem(String key, String value, @Nullable final JSCallback callback) {
if (TextUtils.isEmpty(key) || TextUtils.isEmpty(value)) {
StorageResultHandler.handleInvalidParam(callback);
return;
}
IWXStorageAdapter adapter = ability();
if (adapter == null) {
StorageResultHandler.handleNoHandlerError(callback);
return;
}
adapter.setItem(key, value, new IWXStorageAdapter.OnResultReceivedListener() {
@Override
public void onReceived(Map<String, Object> data) {
if(callback != null){
callback.invoke(data);
}
}
});
}
示例2: getItem
import com.taobao.weex.common.WXModuleAnno; //导入依赖的package包/类
@Override
@WXModuleAnno
public void getItem(String key, @Nullable final JSCallback callback) {
if (TextUtils.isEmpty(key)) {
StorageResultHandler.handleInvalidParam(callback);
return;
}
IWXStorageAdapter adapter = ability();
if (adapter == null) {
StorageResultHandler.handleNoHandlerError(callback);
return;
}
adapter.getItem(key, new IWXStorageAdapter.OnResultReceivedListener() {
@Override
public void onReceived(Map<String, Object> data) {
if(callback != null){
callback.invoke(data);
}
}
});
}
示例3: removeItem
import com.taobao.weex.common.WXModuleAnno; //导入依赖的package包/类
@Override
@WXModuleAnno
public void removeItem(String key, @Nullable final JSCallback callback) {
if (TextUtils.isEmpty(key)) {
StorageResultHandler.handleInvalidParam(callback);
return;
}
IWXStorageAdapter adapter = ability();
if (adapter == null) {
StorageResultHandler.handleNoHandlerError(callback);
return;
}
adapter.removeItem(key, new IWXStorageAdapter.OnResultReceivedListener() {
@Override
public void onReceived(Map<String, Object> data) {
if(callback != null){
callback.invoke(data);
}
}
});
}
示例4: length
import com.taobao.weex.common.WXModuleAnno; //导入依赖的package包/类
@Override
@WXModuleAnno
public void length(@Nullable final JSCallback callback) {
IWXStorageAdapter adapter = ability();
if (adapter == null) {
StorageResultHandler.handleNoHandlerError(callback);
return;
}
adapter.length(new IWXStorageAdapter.OnResultReceivedListener() {
@Override
public void onReceived(Map<String, Object> data) {
if(callback != null){
callback.invoke(data);
}
}
});
}
示例5: getAllKeys
import com.taobao.weex.common.WXModuleAnno; //导入依赖的package包/类
@Override
@WXModuleAnno
public void getAllKeys(@Nullable final JSCallback callback) {
IWXStorageAdapter adapter = ability();
if (adapter == null) {
StorageResultHandler.handleNoHandlerError(callback);
return;
}
adapter.getAllKeys(new IWXStorageAdapter.OnResultReceivedListener() {
@Override
public void onReceived(Map<String, Object> data) {
if(callback != null){
callback.invoke(data);
}
}
});
}
示例6: pop
import com.taobao.weex.common.WXModuleAnno; //导入依赖的package包/类
@WXModuleAnno
public void pop(String param, final String callbackId) {
if (WXSDKEngine.getActivityNavBarSetter() != null) {
if (WXSDKEngine.getActivityNavBarSetter().pop(param)) {
WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId,
MSG_SUCCESS);
return;
}
}
if (mWXSDKInstance.getContext() instanceof Activity) {
WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId,
MSG_SUCCESS);
((Activity) mWXSDKInstance.getContext()).finish();
}
}
示例7: setNavBarLeftItem
import com.taobao.weex.common.WXModuleAnno; //导入依赖的package包/类
@WXModuleAnno
public void setNavBarLeftItem(String param, final String callbackId) {
if (!TextUtils.isEmpty(param)) {
if (WXSDKEngine.getActivityNavBarSetter() != null) {
if (WXSDKEngine.getActivityNavBarSetter().setNavBarLeftItem(param)) {
WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId,
MSG_SUCCESS);
return;
}
}
}
WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId,
MSG_FAILED);
}
示例8: getString
import com.taobao.weex.common.WXModuleAnno; //导入依赖的package包/类
@Override
@WXModuleAnno
public void getString(@Nullable JSCallback callback) {
Context context = mWXSDKInstance.getContext();
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
Map<String, Object> map = new HashMap<>(2);
ClipData clip = clipboard.getPrimaryClip();
if (clip != null && clip.getItemCount() > 0) {
ClipData.Item item = clip.getItemAt(0);
CharSequence text = coerceToText(context, item);
map.put(RESULT, text != null ? RESULT_OK : RESULT_FAILED);
map.put(DATA, text != null ? text : "");
} else {
map.put(RESULT, RESULT_FAILED);
map.put(DATA, "");
}
if (null != callback) {
callback.invoke(map);
}
}
示例9: openURL
import com.taobao.weex.common.WXModuleAnno; //导入依赖的package包/类
@WXModuleAnno(moduleMethod = true,runOnUIThread = true)
public void openURL(String url) {
if (TextUtils.isEmpty(url)) {
return;
}
String scheme = Uri.parse(url).getScheme();
StringBuilder builder = new StringBuilder();
if (TextUtils.equals("http",scheme) || TextUtils.equals("https",scheme) || TextUtils.equals("file",scheme)) {
builder.append(url);
} else {
builder.append("http:");
builder.append(url);
}
Uri uri = Uri.parse(builder.toString());
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.addCategory(WEEX_CATEGORY);
mWXSDKInstance.getContext().startActivity(intent);
}
示例10: scrollToElement
import com.taobao.weex.common.WXModuleAnno; //导入依赖的package包/类
/**
* Scroll the specified {@link WXDomObject} to given offset in given duration
* @param ref {@link WXDomObject#ref} of specified dom object
* @param options scroll option, like {offset:0, duration:300}
*/
@WXModuleAnno(moduleMethod = true, runOnUIThread = false)
public void scrollToElement(String ref, JSONObject options) {
if (TextUtils.isEmpty(ref) || options == null) {
return;
}
Message msg = Message.obtain();
WXDomTask task = new WXDomTask();
task.instanceId = mWXSDKInstance.getInstanceId();
task.args = new ArrayList<>();
task.args.add(ref);
task.args.add(options);
msg.what = WXDomHandler.MsgType.WX_DOM_SCROLLTO;
msg.obj = task;
WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
}
示例11: setNavBarLeftItem
import com.taobao.weex.common.WXModuleAnno; //导入依赖的package包/类
@WXModuleAnno
public void setNavBarLeftItem(String param, final String callbackId) {
if (!TextUtils.isEmpty(param)) {
if (WXSDKEngine.getActivityNavBarSetter() != null) {
if (WXSDKEngine.getActivityNavBarSetter().setNavBarLeftItem(param)) {
WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId,
WXConst.MSG_SUCCESS);
return;
}
}
}
WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId,
WXConst.MSG_FAILED);
}
示例12: updateAttrs
import com.taobao.weex.common.WXModuleAnno; //导入依赖的package包/类
/**
* Update {@link WXDomObject#attr}
* @param ref {@link WXDomObject#ref}
* @param attr the expected attr
*/
@WXModuleAnno(moduleMethod = true, runOnUIThread = false)
public void updateAttrs(String ref, JSONObject attr) {
if (TextUtils.isEmpty(ref) || attr == null || attr.size() < 1) {
return;
}
Message msg = Message.obtain();
WXDomTask task = new WXDomTask();
task.instanceId = mWXSDKInstance.getInstanceId();
task.args = new ArrayList<>();
task.args.add(ref);
task.args.add(attr);
msg.what = WXDomHandler.MsgType.WX_DOM_UPDATE_ATTRS;
msg.obj = task;
WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
}
示例13: updateStyle
import com.taobao.weex.common.WXModuleAnno; //导入依赖的package包/类
/**
* Update {@link WXDomObject#style}
* @param ref {@link WXDomObject#ref}
* @param style the expected style
*/
@WXModuleAnno(moduleMethod = true, runOnUIThread = false)
public void updateStyle(String ref, JSONObject style) {
if (TextUtils.isEmpty(ref) || style == null || style.size() < 1) {
return;
}
Message msg = Message.obtain();
WXDomTask task = new WXDomTask();
task.instanceId = mWXSDKInstance.getInstanceId();
task.args = new ArrayList<>();
task.args.add(ref);
task.args.add(style);
msg.what = WXDomHandler.MsgType.WX_DOM_UPDATE_STYLE;
msg.obj = task;
WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
}
示例14: addElement
import com.taobao.weex.common.WXModuleAnno; //导入依赖的package包/类
/**
* Add a {@link WXDomObject} to the specified parent as its given n-th child.
* @param parentRef {@link WXDomObject#ref} of the parent.
* @param element the node to be added
* @param index the expected index that the new dom in its new parent
*/
@WXModuleAnno(moduleMethod = true, runOnUIThread = false)
public void addElement(String parentRef, JSONObject element, Integer index) {
if (element == null
|| TextUtils.isEmpty(parentRef)) {
return;
}
Message msg = Message.obtain();
WXDomTask task = new WXDomTask();
task.instanceId = mWXSDKInstance.getInstanceId();
task.args = new ArrayList<>();
task.args.add(parentRef);
task.args.add(element);
task.args.add(index);
msg.what = WXDomHandler.MsgType.WX_DOM_ADD_DOM;
msg.obj = task;
WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
}
示例15: moveElement
import com.taobao.weex.common.WXModuleAnno; //导入依赖的package包/类
/**
* Move the DomElement to the specified parent as its given n-th child.
* @param ref {@link WXDomObject#ref} of the node to be moved.
* @param parentRef {@link WXDomObject#ref} of the parent.
* @param index the expected index that the dom in its new parent
*/
@WXModuleAnno(moduleMethod = true, runOnUIThread = false)
public void moveElement(String ref, String parentRef, Integer index) {
if (TextUtils.isEmpty(ref)
|| TextUtils.isEmpty(parentRef)) {
return;
}
Message msg = Message.obtain();
WXDomTask task = new WXDomTask();
task.instanceId = mWXSDKInstance.getInstanceId();
task.args = new ArrayList<>();
task.args.add(ref);
task.args.add(parentRef);
task.args.add(index);
msg.what = WXDomHandler.MsgType.WX_DOM_MOVE_DOM;
msg.obj = task;
WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
}