org.appcelerator.kroll.common.Log Java Examples
The following examples show how to use
org.appcelerator.kroll.common.Log.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CollectionViewProxy.java From TiCollectionView with MIT License | 6 votes |
@Kroll.setProperty @Kroll.method public void setSections(Object sections) { if (!(sections instanceof Object[])) { Log.e(TAG, "Invalid argument type to setSection(), needs to be an array", Log.DEBUG_MODE); return; } //Update java and javascript property setProperty(TiC.PROPERTY_SECTIONS, sections); Object[] sectionsArray = (Object[]) sections; TiUIView listView = peekView(); //Preload sections if listView is not opened. if (listView == null) { preload = true; clearPreloadSections(); addPreloadSections(sectionsArray, -1, true); } else { if (TiApplication.isUIThread()) { ((CollectionView)listView).processSectionsAndNotify(sectionsArray); } else { TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SET_SECTIONS), sectionsArray); } } }
Example #2
Source File: ActionbarextrasModule.java From actionbarextras with MIT License | 6 votes |
/** * Sets the homeAsUp icon * @param icon */ private void handleSetHomeAsUpIcon(Object obj) { ActionBar actionBar = getActionBar(); if (actionBar == null) { return; } if (obj instanceof HashMap) { HashMap args = (HashMap) obj; actionBar.setHomeAsUpIndicator(getDrawableFromFont(args)); } else if (obj instanceof String) { int resId = TiUIHelper.getResourceId(resolveUrl(null, (String)obj)); if (resId != 0) { actionBar.setHomeAsUpIndicator(resId); } else { Log.e(TAG, "Couldn't resolve " + (String)obj); } } else { Log.e(TAG, "Please pass an Object or String to handleSetHomeAsUpIcon"); } }
Example #3
Source File: CollectionView.java From TiCollectionView with MIT License | 6 votes |
private int findItemPosition(int sectionIndex, int sectionItemIndex) { int position = 0; for (int i = 0; i < sections.size(); i++) { CollectionSectionProxy section = sections.get(i); if (i == sectionIndex) { if (sectionItemIndex >= section.getContentCount()) { Log.e(TAG, "Invalid item index"); return -1; } position += sectionItemIndex; break; } else { position += section.getItemCount(); } } return position; }
Example #4
Source File: CollectionView.java From TiCollectionView with MIT License | 6 votes |
public void insertSectionAt(int index, Object section) { if (index > sections.size()) { Log.e(TAG, "Invalid index to insert/replace section"); return; } if (section instanceof Object[]) { Object[] secs = (Object[]) section; for (int i = 0; i < secs.length; i++) { processSection(secs[i], index); index++; } } else { processSection(section, index); } adapter.notifyDataSetChanged(); }
Example #5
Source File: NovarumbluetoothModule.java From NovarumBluetooth with MIT License | 6 votes |
@Kroll.method public KrollDict getPairedDevices() { Log.d(TAG, "getPairedDevices called"); Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices(); KrollDict result = new KrollDict(); // If there are paired devices if (pairedDevices.size() > 0) { // Loop through paired devices for (BluetoothDevice device : pairedDevices) { //Halilk: for some devices, device name is the same so put some of mac digits String strDigitstoAdd = device.getAddress(); strDigitstoAdd = strDigitstoAdd.replace(":",""); result.put(device.getName()+"_"+strDigitstoAdd, device.getAddress()); } } return result; }
Example #6
Source File: ActionbarextrasModule.java From actionbarextras with MIT License | 6 votes |
/** * Sets Up icon color * @param obj */ private void handleSetUpColor(String color){ ActionBar actionBar = getActionBar(); try { TiApplication appContext = TiApplication.getInstance(); AppCompatActivity _activity = (AppCompatActivity) appContext.getCurrentActivity(); final int res_id = TiRHelper.getResource("drawable.abc_ic_ab_back_material", true); final Drawable upArrow = ContextCompat.getDrawable(_activity, res_id); upArrow.setColorFilter(TiConvert.toColor(color), PorterDuff.Mode.SRC_ATOP); actionBar.setHomeAsUpIndicator(upArrow); }catch(Exception e){ Log.e(TAG, e.toString()); } }
Example #7
Source File: NovarumbluetoothModule.java From NovarumBluetooth with MIT License | 6 votes |
@Kroll.method public boolean searchDevices() { Log.d(TAG, "searchDevices called"); //Halilk: if not enabled, enable bluetooth enableBluetooth(); //Get Current activity// TiApplication appContext = TiApplication.getInstance(); Activity activity = appContext.getCurrentActivity(); IntentFilter intentFilter = new IntentFilter(BluetoothDevice.ACTION_FOUND); activity.registerReceiver(myReceiver, intentFilter); bluetoothAdapter.cancelDiscovery(); //cancel if it's already searching bluetoothAdapter.startDiscovery(); return true; }
Example #8
Source File: GCMIntentService.java From gcmpush with Apache License 2.0 | 6 votes |
private int getResource(String type, String name) { int icon = 0; if (name != null) { /* Remove extension from icon */ int index = name.lastIndexOf("."); if (index > 0) { name = name.substring(0, index); } try { icon = TiRHelper.getApplicationResource(type + "." + name); } catch (TiRHelper.ResourceNotFoundException ex) { Log.e(LCAT, type + "." + name + " not found; make sure it's in platform/android/res/" + type); } } return icon; }
Example #9
Source File: CollectionViewTemplate.java From TiCollectionView with MIT License | 6 votes |
private void processChildProperties(Object childProperties, DataItem parent) { if (childProperties instanceof Object[]) { Object[] propertiesArray = (Object[])childProperties; for (int i = 0; i < propertiesArray.length; i++) { HashMap<String, Object> properties = (HashMap<String, Object>) propertiesArray[i]; //bind proxies and default properties DataItem item = bindProxiesAndProperties(new KrollDict(properties), false, parent); //Recursively calls for all childTemplates if (properties.containsKey(TiC.PROPERTY_CHILD_TEMPLATES)) { if(item == null) { Log.e(TAG, "Unable to generate valid data from child view", Log.DEBUG_MODE); } processChildProperties(properties.get(TiC.PROPERTY_CHILD_TEMPLATES), item); } } } }
Example #10
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 6 votes |
private void handleSetItems(Object data) { if (data instanceof Object[]) { Object[] items = (Object[]) data; itemProperties = new ArrayList<Object>(Arrays.asList(items)); listItemData.clear(); //only process items when listview's properties is processed. if (getListView() == null) { preload = true; return; } itemCount = items.length; processData(items, 0); } else { Log.e(TAG, "Invalid argument type to setData", Log.DEBUG_MODE); } }
Example #11
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 6 votes |
private void handleAppendItems(Object data) { if (data instanceof Object[]) { Object[] views = (Object[]) data; if (itemProperties == null) { itemProperties = new ArrayList<Object>(Arrays.asList(views)); } else { for (Object view: views) { itemProperties.add(view); } } //only process items when listview's properties is processed. if (getListView() == null) { preload = true; return; } //we must update the itemCount before notify data change. If we don't, it will crash int count = itemCount; itemCount += views.length; processData(views, count); } else { Log.e(TAG, "Invalid argument type to setData", Log.DEBUG_MODE); } }
Example #12
Source File: NativeBubbleView.java From TiBubbleViewForAndroid with MIT License | 5 votes |
public NativeBubbleView(Context context) { super(context); this.radius = 20.0F; this.bubbleBeak = 1; this.bubbleBeakVertical = 0; setWillNotDraw(false); DisplayMetrics metrics = context.getResources().getDisplayMetrics(); padding = metrics.widthPixels / 100; Log.d(LCAT, "padding = " + padding); }
Example #13
Source File: GCMModule.java From gcmpush with Apache License 2.0 | 5 votes |
/** * Cancel a notification by the id given in the payload. * @param notificationId */ @Kroll.method public void cancelNotificationById(int notificationId) { try { NotificationManager notificationManager = (NotificationManager) TiApplication.getInstance().getApplicationContext().getSystemService(TiApplication.NOTIFICATION_SERVICE); notificationManager.cancel(notificationId); Log.i(LCAT, "Notification " + notificationId + " cleared successfully"); } catch (Exception ex) { Log.e(LCAT, "Cannot cancel notification:" + notificationId + " Error: " + ex.getMessage()); } }
Example #14
Source File: ViewProxy.java From TiTouchImageView with MIT License | 5 votes |
private Bitmap loadImageFromApplication(String imageName) { Bitmap result = null; try { // Load the image from the application assets String url = getPathToApplicationAsset(imageName); TiBaseFile file = TiFileFactory.createTitaniumFile(new String[] { url }, false); result = TiUIHelper.createBitmap(file.getInputStream()); } catch (IOException e) { Log.e(LCAT, " TiTouchImageView only supports local image files"); } return result; }
Example #15
Source File: NovarumbluetoothModule.java From NovarumBluetooth with MIT License | 5 votes |
@Kroll.onAppCreate public static void onAppCreate(TiApplication app) { Log.d(TAG, "inside onAppCreate"); // put module init code that needs to run when the application is created bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); }
Example #16
Source File: GCMModule.java From gcmpush with Apache License 2.0 | 5 votes |
@Kroll.method public void unsubscribe(final HashMap options) { // unsubscripe from a topic final String senderId = (String) options.get("senderId"); final String topic = (String) options.get("topic"); final KrollFunction callback = (KrollFunction) options.get("callback"); if (topic == null || !topic.startsWith("/topics/")) { Log.e(LCAT, "No or invalid topic specified, should start with /topics/"); } if (senderId != null) { new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { try { String token = getToken(senderId); if (token != null) { GcmPubSub.getInstance(TiApplication.getInstance()).unsubscribe(token, topic); if (callback != null) { // send success callback HashMap<String, Object> data = new HashMap<String, Object>(); data.put("success", true); data.put("topic", topic); data.put("token", token); callback.callAsync(getKrollObject(), data); } } else { sendError(callback, "Cannot unsubscribe from topic " + topic); } } catch (Exception ex) { sendError(callback, "Cannot unsubscribe from topic " + topic + ": " + ex.getMessage()); } return null; } }.execute(); } }
Example #17
Source File: GCMModule.java From gcmpush with Apache License 2.0 | 5 votes |
@Kroll.method @SuppressWarnings("unchecked") public void registerPush(HashMap options) { Log.d(LCAT, "registerPush called"); String senderId = (String) options.get("senderId"); Map<String, Object> notificationSettings = (Map<String, Object>) options.get("notificationSettings"); successCallback = (KrollFunction) options.get("success"); errorCallback = (KrollFunction) options.get("error"); messageCallback = (KrollFunction) options.get("callback"); /* Store notification settings in global Ti.App properties */ JSONObject json = new JSONObject(notificationSettings); TiApplication.getInstance().getAppProperties().setString(GCMModule.NOTIFICATION_SETTINGS, json.toString()); if (senderId != null) { GCMRegistrar.register(TiApplication.getInstance(), senderId); String registrationId = getRegistrationId(); if (registrationId != null && registrationId.length() > 0) { sendSuccess(registrationId); } } else { sendError(errorCallback, "No GCM senderId specified; get it from the Google Play Developer Console"); } }
Example #18
Source File: GCMModule.java From gcmpush with Apache License 2.0 | 5 votes |
@Kroll.method public void unregister() { Log.d(LCAT, "unregister called (" + (instance != null) + ")"); try { GCMRegistrar.unregister(TiApplication.getInstance()); } catch (Exception ex) { Log.e(LCAT, "Cannot unregister from push: " + ex.getMessage()); } }
Example #19
Source File: NovarumbluetoothModule.java From NovarumBluetooth with MIT License | 5 votes |
@Override public void onReceive(Context context, Intent intent) { Message msg = Message.obtain(); String action = intent.getAction(); if(BluetoothDevice.ACTION_FOUND.equals(action)) { bluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); BluetoothClass blclass = intent.getParcelableExtra(BluetoothDevice.EXTRA_CLASS); int Majorclass = blclass.getMajorDeviceClass(); int minorclass = blclass.getDeviceClass(); devicelist = new KrollDict(); try { devicelist.put("name",bluetoothDevice.getName()); devicelist.put("macaddress",bluetoothDevice.getAddress()); devicelist.put("pairedstatus",bluetoothDevice.getBondState()); } catch (Exception e) { Log.w(TAG, "devicesFound exception: "+e.getMessage()); postError(e.getMessage()); } devicesFound(); } }
Example #20
Source File: DefaultCollectionViewTemplate.java From TiCollectionView with MIT License | 5 votes |
private void parseDefaultData(KrollDict data) { //for built-in template, we only process 'properties' key Iterator<String> bindings = data.keySet().iterator(); while (bindings.hasNext()) { String binding = bindings.next(); if (!binding.equals(TiC.PROPERTY_PROPERTIES)) { Log.e(TAG, "Please only use 'properties' key for built-in template", Log.DEBUG_MODE); bindings.remove(); } } KrollDict properties = data.getKrollDict(TiC.PROPERTY_PROPERTIES); KrollDict clone_properties = new KrollDict((HashMap)properties); if (clone_properties.containsKey(TiC.PROPERTY_TITLE)) { KrollDict text = new KrollDict(); text.put(TiC.PROPERTY_TEXT, TiConvert.toString(clone_properties, TiC.PROPERTY_TITLE)); data.put(TiC.PROPERTY_TITLE, text); if (clone_properties.containsKey(TiC.PROPERTY_FONT)) { text.put(TiC.PROPERTY_FONT, clone_properties.getKrollDict(TiC.PROPERTY_FONT).clone()); clone_properties.remove(TiC.PROPERTY_FONT); } if (clone_properties.containsKey(TiC.PROPERTY_COLOR)) { text.put(TiC.PROPERTY_COLOR, clone_properties.get(TiC.PROPERTY_COLOR)); clone_properties.remove(TiC.PROPERTY_COLOR); } clone_properties.remove(TiC.PROPERTY_TITLE); } if (clone_properties.containsKey(TiC.PROPERTY_IMAGE)) { KrollDict image = new KrollDict(); image.put(TiC.PROPERTY_IMAGE, TiConvert.toString(clone_properties, TiC.PROPERTY_IMAGE)); data.put(TiC.PROPERTY_IMAGE, image); clone_properties.remove(TiC.PROPERTY_IMAGE); } data.put(TiC.PROPERTY_PROPERTIES, clone_properties); }
Example #21
Source File: TicroutonModule.java From TiCrouton with MIT License | 5 votes |
@Kroll.method public Crouton makeText(String text, int style) { Log.d(TAG, "makeText called"); return Crouton.makeText(TiApplication.getInstance().getCurrentActivity(), text, getStyle(style)); }
Example #22
Source File: TicroutonModule.java From TiCrouton with MIT License | 5 votes |
@Kroll.method public void showText(final String text, final int style) { Log.d(TAG, "showText called"); TiUIHelper.runUiDelayedIfBlock(new Runnable() { @Override public void run() { Crouton.showText(TiApplication.getInstance().getCurrentActivity(), text, getStyle(style)); } }); }
Example #23
Source File: TicroutonModule.java From TiCrouton with MIT License | 5 votes |
@Kroll.onAppCreate public static void onAppCreate(TiApplication app) { Log.d(TAG, "inside onAppCreate"); // put module init code that needs to run when the application is created }
Example #24
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 5 votes |
private CollectionViewTemplate processTemplate(KrollDict itemData, int index) { CollectionView listView = getListView(); String defaultTemplateBinding = null; if (listView != null) { defaultTemplateBinding = listView.getDefaultTemplateBinding(); } //if template is specified in data, we look it up and if one exists, we use it. //Otherwise we check if a default template is specified in ListView. If not, we use builtInTemplate. String binding = TiConvert.toString(itemData.get(TiC.PROPERTY_TEMPLATE)); if (binding != null) { //check if template is default if (binding.equals(UIModule.LIST_ITEM_TEMPLATE_DEFAULT)) { return processDefaultTemplate(itemData, index); } CollectionViewTemplate template = listView.getTemplateByBinding(binding); //if template is successfully retrieved, bind it to the index. This is b/c //each row can have a different template. if (template == null) { Log.e(TAG, "Template undefined"); } return template; } else { //if a valid default template is specify, use that one if (defaultTemplateBinding != null && !defaultTemplateBinding.equals(UIModule.LIST_ITEM_TEMPLATE_DEFAULT)) { CollectionViewTemplate defTemplate = listView.getTemplateByBinding(defaultTemplateBinding); if (defTemplate != null) { return defTemplate; } } return processDefaultTemplate(itemData, index); } }
Example #25
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 5 votes |
private void handleInsertItemsAt(int index, Object data) { if (data instanceof Object[]) { Object[] views = (Object[]) data; if (itemProperties == null) { itemProperties = new ArrayList<Object>(Arrays.asList(views)); } else { if (index < 0 || index > itemProperties.size()) { Log.e(TAG, "Invalid index to handleInsertItem", Log.DEBUG_MODE); return; } int counter = index; for (Object view: views) { itemProperties.add(counter, view); counter++; } } //only process items when listview's properties is processed. if (getListView() == null) { preload = true; return; } itemCount += views.length; processData(views, index); } else { Log.e(TAG, "Invalid argument type to insertItemsAt", Log.DEBUG_MODE); } }
Example #26
Source File: DefaultCollectionViewTemplate.java From TiCollectionView with MIT License | 5 votes |
public void updateOrMergeWithDefaultProperties(KrollDict data, boolean update) { if (!data.containsKey(TiC.PROPERTY_PROPERTIES)) { Log.e(TAG, "Please use 'properties' binding for builtInTemplate"); if (!update) { //apply default behavior data.clear(); } return; } parseDefaultData(data); super.updateOrMergeWithDefaultProperties(data, update); }
Example #27
Source File: CollectionView.java From TiCollectionView with MIT License | 5 votes |
public void deleteSectionAt(int index) { if (index >= 0 && index < sections.size()) { sections.remove(index); adapter.notifyDataSetChanged(); } else { Log.e(TAG, "Invalid index to delete section"); } }
Example #28
Source File: CollectionViewProxy.java From TiCollectionView with MIT License | 5 votes |
private void handleDeleteSectionAt(int index) { TiUIView listView = peekView(); if (listView != null) { ((CollectionView) listView).deleteSectionAt(index); } else { if (index < 0 || index >= preloadSections.size()) { Log.e(TAG, "Invalid index to delete section"); return; } preload = true; preloadSections.remove(index); } }
Example #29
Source File: CollectionViewProxy.java From TiCollectionView with MIT License | 5 votes |
private void handleInsertSectionAt(int index, Object section) { TiUIView listView = peekView(); if (listView != null) { ((CollectionView) listView).insertSectionAt(index, section); } else { if (index < 0 || index > preloadSections.size()) { Log.e(TAG, "Invalid index to insertSection"); return; } preload = true; addPreloadSections(section, index, false); } }
Example #30
Source File: ExampleProxy.java From TiCollectionView with MIT License | 5 votes |
@Override public void handleCreationDict(KrollDict options) { super.handleCreationDict(options); if (options.containsKey("message")) { Log.d(LCAT, "example created with message: " + options.get("message")); } }