org.appcelerator.titanium.util.TiConvert Java Examples
The following examples show how to use
org.appcelerator.titanium.util.TiConvert.
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: 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 #2
Source File: ViewProxy.java From TiTouchImageView with MIT License | 6 votes |
@Override public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy) { if (key.equals("zoom")) { tiv.setZoom(TiConvert.toFloat(newValue)); } if (key.equals("image")) { handleImage(newValue); } if (key.equals("maxZoom")) { tiv.setMaxZoom(TiConvert.toFloat(newValue)); } if (key.equals("minZoom")) { tiv.setMinZoom(TiConvert.toFloat(newValue)); } }
Example #3
Source File: RealSwitch.java From RealSwitch with MIT License | 6 votes |
@Override public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy) { CompoundButton cb = (CompoundButton) getNativeView(); if (key.equals(TiC.PROPERTY_TITLE_OFF)) { ((Switch) cb).setTextOff((String) newValue); } else if (key.equals(TiC.PROPERTY_TITLE_ON)) { ((Switch) cb).setTextOff((String) newValue); } else if (key.equals(TiC.PROPERTY_VALUE)) { cb.setChecked(TiConvert.toBoolean(newValue)); } else if (key.equals(TiC.PROPERTY_COLOR)) { cb.setTextColor(TiConvert.toColor(TiConvert.toString(newValue))); } else if (key.equals(TiC.PROPERTY_FONT)) { TiUIHelper.styleText(cb, (KrollDict) newValue); } else if (key.equals(TiC.PROPERTY_TEXT_ALIGN)) { TiUIHelper.setAlignment(cb, TiConvert.toString(newValue), null); cb.requestLayout(); } else if (key.equals(TiC.PROPERTY_VERTICAL_ALIGN)) { TiUIHelper.setAlignment(cb, null, TiConvert.toString(newValue)); cb.requestLayout(); } else { super.propertyChanged(key, oldValue, newValue, proxy); } }
Example #4
Source File: ViewProxy.java From TiTouchImageView with MIT License | 6 votes |
@Override public void processProperties(KrollDict props) { super.processProperties(props); if (props.containsKey("zoom")) { tiv.setZoom(TiConvert.toFloat(proxy.getProperty("zoom"))); } if (props.containsKey("image")) { handleImage(proxy.getProperty("image")); } if (props.containsKey("maxZoom")) { tiv.setMaxZoom(TiConvert.toFloat(proxy.getProperty("maxZoom"))); } if (props.containsKey("minZoom")) { tiv.setMinZoom(TiConvert.toFloat(proxy.getProperty("minZoom"))); } }
Example #5
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 6 votes |
public CollectionItemData (KrollDict properties, CollectionViewTemplate template) { this.properties = properties; this.template = template; //set searchableText if (properties.containsKey(TiC.PROPERTY_PROPERTIES)) { Object props = properties.get(TiC.PROPERTY_PROPERTIES); if (props instanceof HashMap) { HashMap<String, Object> propsHash = (HashMap<String, Object>) props; Object searchText = propsHash.get(TiC.PROPERTY_SEARCHABLE_TEXT); if (propsHash.containsKey(TiC.PROPERTY_SEARCHABLE_TEXT) && searchText != null) { searchableText = TiConvert.toString(searchText); } } } }
Example #6
Source File: CollectionViewProxy.java From TiCollectionView with MIT License | 6 votes |
@Kroll.method public void scrollToItem(int sectionIndex, int itemIndex, @SuppressWarnings("rawtypes") @Kroll.argument(optional=true)HashMap options) { boolean animated = true; if ( (options != null) && (options instanceof HashMap<?, ?>) ) { @SuppressWarnings("unchecked") KrollDict animationargs = new KrollDict(options); if (animationargs.containsKeyAndNotNull(TiC.PROPERTY_ANIMATED)) { animated = TiConvert.toBoolean(animationargs.get(TiC.PROPERTY_ANIMATED), true); } } if (TiApplication.isUIThread()) { handleScrollToItem(sectionIndex, itemIndex, animated); } else { KrollDict d = new KrollDict(); d.put("itemIndex", itemIndex); d.put("sectionIndex", sectionIndex); d.put(TiC.PROPERTY_ANIMATED, Boolean.valueOf(animated)); TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SCROLL_TO_ITEM), d); } }
Example #7
Source File: ImageViewerActivity.java From titanium-imagepicker with Apache License 2.0 | 5 votes |
private void setTitle(String title, String titleColor, String titleBg) { if (title.trim().isEmpty()) { this.layout.removeView(this.title); } else { this.title.setTextColor(TiConvert.toColor(titleColor)); this.title.setBackgroundColor(TiConvert.toColor(titleBg)); this.title.setText(title); } }
Example #8
Source File: ExampleProxy.java From NovarumBluetooth with MIT License | 5 votes |
public ExampleView(TiViewProxy proxy) { super(proxy); LayoutArrangement arrangement = LayoutArrangement.DEFAULT; if (proxy.hasProperty(TiC.PROPERTY_LAYOUT)) { String layoutProperty = TiConvert.toString(proxy.getProperty(TiC.PROPERTY_LAYOUT)); if (layoutProperty.equals(TiC.LAYOUT_HORIZONTAL)) { arrangement = LayoutArrangement.HORIZONTAL; } else if (layoutProperty.equals(TiC.LAYOUT_VERTICAL)) { arrangement = LayoutArrangement.VERTICAL; } } setNativeView(new TiCompositeLayout(proxy.getActivity(), arrangement)); }
Example #9
Source File: ActionbarextrasModule.java From actionbarextras with MIT License | 5 votes |
/** * disables or enables the icon * @param arg */ @Kroll.method @Kroll.setProperty public void setDisableIcon(@Kroll.argument(optional = true) Boolean arg) { Boolean disabled = true; if (arg != null) { disabled = TiConvert.toBoolean(arg); } Message message = getMainHandler().obtainMessage(MSG_DISABLE_ICON, disabled); message.sendToTarget(); }
Example #10
Source File: ActionbarextrasModule.java From actionbarextras with MIT License | 5 votes |
/** * Set the current hide offset of the action bar * See http://developer.android.com/reference/android/support/v7/app/ActionBar.html#setHideOffset(int) * * @param Integer - value */ private void handleSetHideOffset(Object value){ ActionBar actionBar = getActionBar(); if (actionBar == null){ return; } actionBar.setHideOffset(TiConvert.toInt(value)); }
Example #11
Source File: ActionbarextrasModule.java From actionbarextras with MIT License | 5 votes |
/** * Sets the Actionbar elevation * See http://developer.android.com/reference/android/support/v7/app/ActionBar.html#setElevation(float) * * @param Integer - value */ private void handleSetElevation(Object value){ ActionBar actionBar = getActionBar(); if (actionBar == null){ return; } actionBar.setElevation(TiConvert.toFloat(value)); }
Example #12
Source File: ActionbarextrasModule.java From actionbarextras with MIT License | 5 votes |
/** * Sets Actionbar background color * @param obj */ private void handleSetBackgroundColor(String color){ ActionBar actionBar = getActionBar(); if (actionBar == null){ return; } actionBar.setBackgroundDrawable(new ColorDrawable(TiConvert.toColor(color))); }
Example #13
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 #14
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 #15
Source File: CollectionItem.java From TiCollectionView with MIT License | 5 votes |
public void processProperties(KrollDict d) { if (d.containsKey(TiC.PROPERTY_ACCESSORY_TYPE)) { int accessory = TiConvert.toInt(d.get(TiC.PROPERTY_ACCESSORY_TYPE), -1); handleAccessory(accessory); } if (d.containsKey(TiC.PROPERTY_SELECTED_BACKGROUND_COLOR)) { d.put(TiC.PROPERTY_BACKGROUND_SELECTED_COLOR, d.get(TiC.PROPERTY_SELECTED_BACKGROUND_COLOR)); } if (d.containsKey(TiC.PROPERTY_SELECTED_BACKGROUND_IMAGE)) { d.put(TiC.PROPERTY_BACKGROUND_SELECTED_IMAGE, d.get(TiC.PROPERTY_SELECTED_BACKGROUND_IMAGE)); } super.processProperties(d); }
Example #16
Source File: ExampleProxy.java From TiCollectionView with MIT License | 5 votes |
public ExampleView(TiViewProxy proxy) { super(proxy); LayoutArrangement arrangement = LayoutArrangement.DEFAULT; if (proxy.hasProperty(TiC.PROPERTY_LAYOUT)) { String layoutProperty = TiConvert.toString(proxy.getProperty(TiC.PROPERTY_LAYOUT)); if (layoutProperty.equals(TiC.LAYOUT_HORIZONTAL)) { arrangement = LayoutArrangement.HORIZONTAL; } else if (layoutProperty.equals(TiC.LAYOUT_VERTICAL)) { arrangement = LayoutArrangement.VERTICAL; } } setNativeView(new TiCompositeLayout(proxy.getActivity(), arrangement)); }
Example #17
Source File: CollectionView.java From TiCollectionView with MIT License | 5 votes |
private void addSearchLayout(RelativeLayout layout, TiViewProxy searchView, TiUIView search) { RelativeLayout.LayoutParams p = createBasicSearchLayout(); p.addRule(RelativeLayout.ALIGN_PARENT_TOP); TiDimension rawHeight; if (searchView.hasProperty(TiC.PROPERTY_HEIGHT)) { rawHeight = TiConvert.toTiDimension(searchView.getProperty(TiC.PROPERTY_HEIGHT), 0); } else { rawHeight = TiConvert.toTiDimension(MIN_SEARCH_HEIGHT, 0); } p.height = rawHeight.getAsPixels(layout); View nativeView = search.getNativeView(); layout.addView(nativeView, p); p = createBasicSearchLayout(); p.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); p.addRule(RelativeLayout.BELOW, nativeView.getId()); ViewParent parentWrapper = wrapper.getParent(); if (parentWrapper != null && parentWrapper instanceof ViewGroup) { //get the previous layout params so we can reset with new layout ViewGroup.LayoutParams lp = wrapper.getLayoutParams(); ViewGroup parentView = (ViewGroup) parentWrapper; //remove view from parent parentView.removeView(wrapper); //add new layout layout.addView(wrapper, p); parentView.addView(layout, lp); } else { layout.addView(wrapper, p); } this.searchLayout = layout; }
Example #18
Source File: CollectionViewTemplate.java From TiCollectionView with MIT License | 5 votes |
private DataItem bindProxiesAndProperties(KrollDict properties, boolean isRootTemplate, DataItem parent) { Object proxy = null; String id = null; Object props = null; DataItem item = null; if (properties.containsKey(TiC.PROPERTY_TI_PROXY)) { proxy = properties.get(TiC.PROPERTY_TI_PROXY); } //Get/generate random bind id if (isRootTemplate) { id = itemID; } else if (properties.containsKey(TiC.PROPERTY_BIND_ID)) { id = TiConvert.toString(properties, TiC.PROPERTY_BIND_ID); } else { id = GENERATED_BINDING + Math.random(); } if (proxy instanceof TiViewProxy) { TiViewProxy viewProxy = (TiViewProxy) proxy; if (isRootTemplate) { rootItem = item = new DataItem(viewProxy, TiC.PROPERTY_PROPERTIES, null); } else { item = new DataItem(viewProxy, id, parent); parent.addChild(item); } dataItems.put(id, item); } if (properties.containsKey(TiC.PROPERTY_PROPERTIES)) { props = properties.get(TiC.PROPERTY_PROPERTIES); } if (props instanceof HashMap) { item.setDefaultProperties(new KrollDict((HashMap)props)); } return item; }
Example #19
Source File: RealSwitch.java From RealSwitch with MIT License | 5 votes |
protected void updateButton(CompoundButton cb, KrollDict d) { if (d.containsKey(TiC.PROPERTY_TITLE_OFF)) { ((Switch) cb).setTextOff(TiConvert.toString(d, TiC.PROPERTY_TITLE_OFF)); } if (d.containsKey(TiC.PROPERTY_TITLE_ON)) { ((Switch) cb).setTextOn(TiConvert.toString(d, TiC.PROPERTY_TITLE_ON)); } if (d.containsKey(TiC.PROPERTY_VALUE)) { cb.setChecked(TiConvert.toBoolean(d, TiC.PROPERTY_VALUE)); } if (d.containsKey(TiC.PROPERTY_COLOR)) { cb.setTextColor(TiConvert.toColor(d, TiC.PROPERTY_COLOR)); } if (d.containsKey(TiC.PROPERTY_FONT)) { TiUIHelper.styleText(cb, d.getKrollDict(TiC.PROPERTY_FONT)); } if (d.containsKey(TiC.PROPERTY_TEXT_ALIGN)) { String textAlign = d.getString(TiC.PROPERTY_TEXT_ALIGN); TiUIHelper.setAlignment(cb, textAlign, null); } if (d.containsKey(TiC.PROPERTY_VERTICAL_ALIGN)) { String verticalAlign = d.getString(TiC.PROPERTY_VERTICAL_ALIGN); TiUIHelper.setAlignment(cb, null, verticalAlign); } cb.invalidate(); }
Example #20
Source File: RealSwitch.java From RealSwitch with MIT License | 5 votes |
@Override public void processProperties(KrollDict d) { super.processProperties(d); // Create Real Switch CompoundButton button = new Switch(proxy.getActivity()) { @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); TiUIHelper.firePostLayoutEvent(proxy); } }; setNativeView(button); updateButton(button, proxy.getProperties()); button.setOnCheckedChangeListener(this); if (d.containsKey(TiC.PROPERTY_VALUE)) { oldValue = TiConvert.toBoolean(d, TiC.PROPERTY_VALUE); } View nativeView = getNativeView(); if (nativeView != null) { updateButton((CompoundButton) nativeView, d); } }
Example #21
Source File: ImageViewerActivity.java From titanium-imagepicker with Apache License 2.0 | 5 votes |
private void setTitle(String title, String titleColor, String titleBg) { if (title.trim().isEmpty()) { this.layout.removeView(this.title); } else { this.title.setTextColor(TiConvert.toColor(titleColor)); this.title.setBackgroundColor(TiConvert.toColor(titleBg)); this.title.setText(title); } }
Example #22
Source File: CollectionView.java From TiCollectionView with MIT License | 4 votes |
public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy) { if (key.equals(TiC.PROPERTY_HEADER_TITLE)) { setHeaderTitle(TiConvert.toString(newValue)); } else if (key.equals(TiC.PROPERTY_FOOTER_TITLE)) { setFooterTitle(TiConvert.toString(newValue)); } else if (key.equals(TiC.PROPERTY_SECTIONS) && newValue instanceof Object[] ) { processSectionsAndNotify((Object[])newValue); } else if (key.equals(TiC.PROPERTY_SEARCH_TEXT)) { this.searchText = TiConvert.toString(newValue); if (this.searchText != null) { reFilter(this.searchText); } } else if (key.equals(TiC.PROPERTY_CASE_INSENSITIVE_SEARCH)) { this.caseInsensitive = TiConvert.toBoolean(newValue, true); if (this.searchText != null) { reFilter(this.searchText); } } else if (key.equals(TiC.PROPERTY_SEARCH_VIEW)) { TiViewProxy searchView = (TiViewProxy) newValue; if (isSearchViewValid(searchView)) { TiUIView search = searchView.getOrCreateView(); setSearchListener(searchView, search); if (searchLayout != null) { searchLayout.removeAllViews(); addSearchLayout(searchLayout, searchView, search); } else { layoutSearchView(searchView); } } else { Log.e(TAG, "Searchview type is invalid"); } } else if (key.equals(TiC.PROPERTY_SHOW_VERTICAL_SCROLL_INDICATOR) && newValue != null) { listView.setVerticalScrollBarEnabled(TiConvert.toBoolean(newValue)); } else if (key.equals(TiC.PROPERTY_DEFAULT_ITEM_TEMPLATE) && newValue != null) { defaultTemplateBinding = TiConvert.toString(newValue); refreshItems(); } else if (key.equals(TiC.PROPERTY_SEPARATOR_COLOR)) { String color = TiConvert.toString(newValue); setSeparatorColor(color); } else { super.propertyChanged(key, oldValue, newValue, proxy); } }
Example #23
Source File: TicroutonModule.java From TiCrouton with MIT License | 4 votes |
@Kroll.method public void show(KrollDict args) { Log.d(TAG, "show called"); final Crouton crouton; Activity activity; String text = ""; Style style = null; Builder config = new Configuration.Builder(); if (args.containsKey(TiC.PROPERTY_ACTIVITY)){ ActivityProxy activityProxy = (ActivityProxy) args.get(TiC.PROPERTY_ACTIVITY); activity = activityProxy.getActivity(); }else{ activity = TiApplication.getInstance().getCurrentActivity(); } if (args.containsKey(TiC.PROPERTY_TEXT)){ text = TiConvert.toString(args.get(TiC.PROPERTY_TEXT)); } if (args.containsKey(TiC.PROPERTY_STYLE)){ style = getStyle(TiConvert.toInt(args.get(TiC.PROPERTY_STYLE))); } if (args.containsKey(TiC.PROPERTY_COLOR)){ String color = (String) args.get(TiC.PROPERTY_COLOR); style = new Style.Builder() .setBackgroundColorValue(TiConvert.toColor(color)) .build(); } if (style == null){ style = Style.INFO; } crouton = Crouton.makeText(activity, text, style); if (args.containsKey(TiC.PROPERTY_DURATION)){ config.setDuration(TiConvert.toInt(args.get(TiC.PROPERTY_DURATION))); crouton.setConfiguration(config.build()); } TiUIHelper.runUiDelayedIfBlock(new Runnable() { @Override public void run() { crouton.show(); } }); }
Example #24
Source File: TicroutonModule.java From TiCrouton with MIT License | 4 votes |
@Kroll.method public Crouton make(KrollDict args) { Log.d(TAG, "make called"); Crouton crouton; Activity activity; String text = ""; Style style = null; Builder config = new Configuration.Builder(); if (args.containsKey(TiC.PROPERTY_ACTIVITY)){ ActivityProxy activityProxy = (ActivityProxy) args.get(TiC.PROPERTY_ACTIVITY); activity = activityProxy.getActivity(); }else{ activity = TiApplication.getInstance().getCurrentActivity(); } if (args.containsKey(TiC.PROPERTY_TEXT)){ text = TiConvert.toString(args.get(TiC.PROPERTY_TEXT)); } if (args.containsKey(TiC.PROPERTY_STYLE)){ style = getStyle(TiConvert.toInt(args.get(TiC.PROPERTY_STYLE))); } if (args.containsKey(TiC.PROPERTY_COLOR)){ String color = (String) args.get(TiC.PROPERTY_COLOR); style = new Style.Builder() .setBackgroundColorValue(TiConvert.toColor(color)) .build(); } if (style == null){ style = Style.INFO; } crouton = Crouton.makeText(activity, text, style); if (args.containsKey(TiC.PROPERTY_DURATION)){ config.setDuration(TiConvert.toInt(args.get(TiC.PROPERTY_DURATION))); crouton.setConfiguration(config.build()); } return crouton; }
Example #25
Source File: ActionbarextrasModule.java From actionbarextras with MIT License | 4 votes |
private IconDrawable getDrawableFromFont(HashMap args) { Typeface iconFontTypeface = TiUIHelper.toTypeface(TiApplication.getInstance(), (String) args.get(TiC.PROPERTY_FONTFAMILY)); return new IconDrawable(TiApplication.getInstance(), (String) args.get(TiC.PROPERTY_ICON), iconFontTypeface).actionBarSize().color(TiConvert.toColor((String) args.get(TiC.PROPERTY_COLOR))); }
Example #26
Source File: ImagePickerActivity.java From titanium-imagepicker with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); Defaults.setupInitialValues(getApplicationContext(), getIntent()); if (!Defaults.ACTIVITY_THEME.isEmpty()) { setTheme(Utils.getR("style." + Defaults.ACTIVITY_THEME)); } setupIds(); setContentView(main_layout_id); isMultipleSelection = (1 != Defaults.MAX_IMAGE_SELECTION); isShapeCircle = Defaults.SHAPE_CIRCLE == Defaults.SHAPE; if (Build.VERSION.SDK_INT >= 21) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (!Defaults.STATUS_BAR_COLOR.isEmpty()) { window.setStatusBarColor(TiConvert.toColor(Defaults.STATUS_BAR_COLOR)); } window.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BACKGROUND_COLOR)); } ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { if (!Defaults.BAR_COLOR.isEmpty()) { actionBar.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BAR_COLOR)); } actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(Defaults.TITLE); } else { Log.e(TAG, Defaults.ACTION_BAR_ERROR_MSG); } mRecyclerView = new RecyclerView(TiApplication.getInstance()); mRecyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mRecyclerView.setLayoutManager(new GridLayoutManager(ImagePickerActivity.this, Defaults.GRID_SIZE)); FrameLayout frame_container = (FrameLayout) findViewById(container); frame_container.addView(mRecyclerView); frame_container.setBackgroundColor(TiConvert.toColor(Defaults.BACKGROUND_COLOR)); adapterSet = new PhotoAdapter(adapter); mRecyclerView.setAdapter(adapterSet); if ( (1 == Defaults.SHOW_DIVIDER) && (!isShapeCircle) ) { mRecyclerView.addItemDecoration(new DividerDecoration()); } setupGlideOptions(); // set glide-options to apply on image // Get gallery photos in a new UI thread like AsyncTask to update UI changes properly new FetchImages().execute(); }
Example #27
Source File: ImageViewerActivity.java From titanium-imagepicker with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); imagesAdapter = intent.getExtras().getParcelableArrayList(Defaults.Params.IMAGES); Defaults.setupInitialValues(getApplicationContext(), intent); if (!Defaults.ACTIVITY_THEME.isEmpty()) { setTheme(Utils.getR("style." + Defaults.ACTIVITY_THEME)); } setupIds(); setContentView(frame_layout); isShapeCircle = Defaults.SHAPE_CIRCLE == Defaults.SHAPE; if (Build.VERSION.SDK_INT >= 21) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (!Defaults.STATUS_BAR_COLOR.isEmpty()) { window.setStatusBarColor(TiConvert.toColor(Defaults.STATUS_BAR_COLOR)); } window.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BACKGROUND_COLOR)); } ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { if (!Defaults.BAR_COLOR.isEmpty()) { actionBar.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BAR_COLOR)); } actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(Defaults.TITLE); } else { Log.e(TAG, Defaults.ACTION_BAR_ERROR_MSG); } mRecyclerView = new RecyclerView(TiApplication.getInstance()); mRecyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mRecyclerView.setLayoutManager(new GridLayoutManager(ImageViewerActivity.this, Defaults.GRID_SIZE)); FrameLayout frame_container = (FrameLayout) findViewById(frame_layout_id); frame_container.addView(mRecyclerView); frame_container.setBackgroundColor(TiConvert.toColor(Defaults.BACKGROUND_COLOR)); adapterSet = new PhotoAdapter(imagesAdapter); mRecyclerView.setAdapter(adapterSet); if ( (1 == Defaults.SHOW_DIVIDER) && (!isShapeCircle) ) { mRecyclerView.addItemDecoration(new DividerDecoration()); } setupGlideOptions(); // set glide-options to apply on image }
Example #28
Source File: ImagePickerActivity.java From titanium-imagepicker with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); Defaults.setupInitialValues(getApplicationContext(), getIntent()); if (!Defaults.ACTIVITY_THEME.isEmpty()) { setTheme(Utils.getR("style." + Defaults.ACTIVITY_THEME)); } setupIds(); setContentView(main_layout_id); isMultipleSelection = (1 != Defaults.MAX_IMAGE_SELECTION); isShapeCircle = Defaults.SHAPE_CIRCLE == Defaults.SHAPE; if (Build.VERSION.SDK_INT >= 21) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (!Defaults.STATUS_BAR_COLOR.isEmpty()) { window.setStatusBarColor(TiConvert.toColor(Defaults.STATUS_BAR_COLOR)); } window.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BACKGROUND_COLOR)); } ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { if (!Defaults.BAR_COLOR.isEmpty()) { actionBar.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BAR_COLOR)); } actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(Defaults.TITLE); } else { Log.e(TAG, Defaults.ACTION_BAR_ERROR_MSG); } mRecyclerView = new RecyclerView(TiApplication.getInstance()); mRecyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mRecyclerView.setLayoutManager(new GridLayoutManager(ImagePickerActivity.this, Defaults.GRID_SIZE)); FrameLayout frame_container = (FrameLayout) findViewById(container); frame_container.addView(mRecyclerView); frame_container.setBackgroundColor(TiConvert.toColor(Defaults.BACKGROUND_COLOR)); adapterSet = new PhotoAdapter(adapter); mRecyclerView.setAdapter(adapterSet); if ( (1 == Defaults.SHOW_DIVIDER) && (!isShapeCircle) ) { mRecyclerView.addItemDecoration(new DividerDecoration()); } setupGlideOptions(); // set glide-options to apply on image // Get gallery photos in a new UI thread like AsyncTask to update UI changes properly new FetchImages().execute(); }
Example #29
Source File: ImageViewerActivity.java From titanium-imagepicker with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); imagesAdapter = intent.getExtras().getParcelableArrayList(Defaults.Params.IMAGES); Defaults.setupInitialValues(getApplicationContext(), intent); if (!Defaults.ACTIVITY_THEME.isEmpty()) { setTheme(Utils.getR("style." + Defaults.ACTIVITY_THEME)); } setupIds(); setContentView(frame_layout); isShapeCircle = Defaults.SHAPE_CIRCLE == Defaults.SHAPE; if (Build.VERSION.SDK_INT >= 21) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (!Defaults.STATUS_BAR_COLOR.isEmpty()) { window.setStatusBarColor(TiConvert.toColor(Defaults.STATUS_BAR_COLOR)); } window.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BACKGROUND_COLOR)); } ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { if (!Defaults.BAR_COLOR.isEmpty()) { actionBar.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BAR_COLOR)); } actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(Defaults.TITLE); } else { Log.e(TAG, Defaults.ACTION_BAR_ERROR_MSG); } mRecyclerView = new RecyclerView(TiApplication.getInstance()); mRecyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mRecyclerView.setLayoutManager(new GridLayoutManager(ImageViewerActivity.this, Defaults.GRID_SIZE)); FrameLayout frame_container = (FrameLayout) findViewById(frame_layout_id); frame_container.addView(mRecyclerView); frame_container.setBackgroundColor(TiConvert.toColor(Defaults.BACKGROUND_COLOR)); adapterSet = new PhotoAdapter(imagesAdapter); mRecyclerView.setAdapter(adapterSet); if ( (1 == Defaults.SHOW_DIVIDER) && (!isShapeCircle) ) { mRecyclerView.addItemDecoration(new DividerDecoration()); } setupGlideOptions(); // set glide-options to apply on image }
Example #30
Source File: Drawer.java From Ti.DrawerLayout with MIT License | 4 votes |
/** * Helpers */ public int getDevicePixels(Object value) { return TiConvert.toTiDimension(TiConvert.toString(value), TiDimension.TYPE_WIDTH).getAsPixels(layout); }