Business Sample App Discussion

I haven’t tested the ATOM feed in a while.  It was working against Wordpress ATOM feeds a while back.  Are you getting errors?  What’s in your console log?  What is the URL of the feed you’re trying to use?

There are two things you need to do to make the atom feed work with the business app sample.  These will be included when I push the new version. 

But in the mean time, near the bottom of atom.lua change the line:

feed.entries = stories

to

feed.items = stories

Then in feed.lua and feed2.lua (its the same code in both)  around line 278, replace the pubDate code with:

    local timeStamp
    if atom then
        timeStamp = story.pubDate
    else
        timeStamp = string.match(story.pubDate,"%w+, %d+ %w+ %w+ %w+:%w+")
    end

This assumes that you have done a:

local atom = require( “atom” )

at the top.  The pubDate is in a format like:   yyyy-mm-ddTmm:dd:ssZ

but the RSS feed is more of a human readable format.  You may want to parse this and convert it to a prettier date format.

Rob

Hi Rob,

thank you for reply.

I made the changes you suggested. Of course I had already changed the call to the file atom.lua (instead of rss.lua). 

But the error in my console is:

ERROR: Non-directory file already exists at (null)

The link that I’m testing is as follows:

http://www.krimissa.com/data/_addondata/d5nufsh/feed.atom

In file main.lua I’ve inserted:

feedName = "feed.atom", feedURL = "http://www.krimissa.com/data/\_addondata/d5nufsh/",

Thanks in advance.

Regards.

-j

A new developer question: how can I load the thumbnails automatically for each feed?

I need to load the automatically generated thumbnails from YouTube link, Example:

http://img.youtube.com/vi/VIDEOIDHERE/1.jpg

I want my thumbnails to appear. How can I change the local filename = string.format to read the url and display the thumbnails?

I can’t figure out the right way to get the thumbnail for each feed. Any help appreciated, thanks!

local filename = string.format(“http://img.youtube.com/vi/” … videoID … “/1.jpg”,id, string.sub(e.type, string.find(e.type,"/") + 1))

 &nbsp;local found = false &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; local j = 0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while j \< #story.enclosures and not found do &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; j = j + 1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; local e = story.enclosures[j] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if e.type == "image/jpeg" or e.type == "image/jpg" or e.type == "image/png" then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- Ah Ha! we have a potentially displayable image &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- create a local filename.&nbsp; I suppose I could parse it out of the URL, but it really doesn't matter &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- so make up one, but I do need to parse the extension off of the type. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; local filename = string.format("image\_%3d.%s",id, string.sub(e.type, string.find(e.type,"/") + 1)) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- Now make Corona SDK do all the heavy lifting for me.&nbsp; This little gem will fetch the URL, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- store it in the Caches directory (to make Apple happy) and when complete it will call a function that &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- will shove it into our row for us.&nbsp; If the image is bad, or doesn't exist, then it won't display anything &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- though it should drop a message into the console log. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; display.loadRemoteImage( e.url, "GET", thumbListener, filename, system.CachesDirectory, 0, 0 ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end

Hi there, I was wondering how I might go about having the tab bar vertically on the left side of the screen as apposed to horizontally on the bottom? Nothing I’ve tried seems to work :confused: Any help would be much appreciated!

Corona SDK widgets are built to emulate the design patterns of their native OS equivalents.  In the case of the tabBar, Android really doesn’t use one and in iOS, it’s a navigation bar at the bottom of the screen.  We do not support a vertical tabBar with this widget.

Many people request features that are limited to their specific use or that a few people would find useful, such as this.  With the limited engineering time, we simply cannot honor every feature request that comes along.  Because of this, for widgets, we made them open source.  They are written in Lua (no native code) so any Corona SDK developer can download the widget library from our github repository and build in whatever features they like.  You can have a local copy of the widget library for your app to use.  You can find the library here:

https://github.com/coronalabs/framework-widget

Feel free to download and modify them as you see fit.

Rob

Ok, thanks for getting back to me Rob. I have another question. Is it possible to modify the videoViewer to use native.newVideo()?

No, those are not open source.

Rob

Hey Rob, 

I’m trying to use your sample business app as an added functionality on top of my app. I’m trying to place the contents of your main.lua file into its own composer scene, but I’m having trouble keeping myApp.tabBar around and getting rid of it when transitioning to scene to scene and back to my main game screen. 

Here’s my code: 

In main.lua:

\_G.HQTab=display.newGroup() \_G.HQTab.x, \_G.HQTab.y = \_W,\_H local display\_stage = display.getCurrentStage() display\_stage:insert( composer.stage ) display\_stage:insert( \_G.HQTab )&nbsp;

In devMenu.lua (adapted from your main.lua):

local composer = require ( "composer" ) local widget = require( "widget" ) local json = require( "json" ) local myApp = require( "HQ.myapp" ) local sheetLoader = require("sheetLoader") local scene = composer.newScene() math.randomseed(os.time()) -- -- Load our fonts and define our styles -- function scene:create( event ) local sceneGroup = self.view if (display.pixelHeight/display.pixelWidth) \> 1.5 then myApp.isTall = true end if display.contentWidth \> 320 then myApp.is\_iPad = true end local tabBarBackgroundFile = "images/tabBarBg7.png" local tabBarLeft = "images/tabBar\_tabSelectedLeft7.png" local tabBarMiddle = "images/tabBar\_tabSelectedMiddle7.png" local tabBarRight = "images/tabBar\_tabSelectedRight7.png" myApp.topBarBg = "images/topBarBg7.png" local iconInfo = { width = 40, height = 40, numFrames = 20, sheetContentWidth = 200, sheetContentHeight = 160 } myApp.icons = graphics.newImageSheet("images/ios7icons.png", iconInfo) if system.getInfo("platformName") == "Android" then myApp.theme = "widget\_theme\_android" myApp.font = "Droid Sans" myApp.fontBold = "Droid Sans Bold" myApp.fontItalic = "Droid Sans" myApp.fontBoldItalic = "Droid Sans Bold" myApp.topBarBg = "images/topBarBg7.png" else myApp.theme = "widget\_theme\_ios7" local coronaBuild = system.getInfo("build") if tonumber(coronaBuild:sub(6,12)) \< 1206 then myApp.theme = "widget\_theme\_ios" end myApp.font = "HelveticaNeue-Light" myApp.fontBold = "HelveticaNeue" myApp.fontItalic = "HelveticaNeue-LightItalic" myApp.fontBoldItalic = "Helvetica-BoldItalic" end widget.setTheme(myApp.theme) myApp.tabBar = {} function myApp.showScreen1() myApp.tabBar:setSelected(1) --composer.removeHidden() composer.gotoScene("HQ.menu", {time=250, effect="crossFade"}) return true end function myApp.showScreen2(event) myApp.tabBar:setSelected(2) local options = { feedName = "outcast.rss", feedURL = "http://www.simplemachine.co/?cat=60&feed=rss2", icons = "fixed", displayMode = "webpage", pageTitle = "The Outcast" } --composer.removeHidden() composer.gotoScene("HQ.feed", {time=250, effect="crossFade", params = options}) return true end function myApp.showScreen3() myApp.tabBar:setSelected(3) --composer.removeHidden() composer.gotoScene("HQ.photogallery", {time=250, effect="crossFade"}) return true end function myApp.showScreen4() myApp.tabBar:setSelected(4) local options = { feedName = "video.rss", feedURL = "http://gdata.youtube.com/feeds/mobile/playlists/PLUqsW7siiOQScFgxcIi-upYV7wAmsgWCL?max-results=20&alt=rss&orderby=published&format=1", icons = "fixed", displayMode = "videoviewer", pageTitle = "The Outcast Videos" } --composer.removeHidden() composer.gotoScene("HQ.feed2", {time=250, effect="crossFade", params = options}) return true end function myApp.showScreen5() print("Making the call to update...") local sheetArray = sheetLoader.new() return true end local function closeMenu() print("YEEEEAHHAHAHAH") local function killNav() composer.gotoScene("scene1", "crossFade", 400) -- end --myApp.tabBar:removeSelf() transition.to(myApp.tabBar, {time=300, transition=easing.inOutQuad, onComplete=killNav}) return true end local tabButtons = { { label = "", defaultFile = "images/tabbaricon\_main.png", overFile = "images/tabbaricon\_main\_down.png", labelColor = { default = { 0.25, 0.25, 0.25 }, over = { 0.768, 0.516, 0.25 } }, width = 32, height = 32, onPress = myApp.showScreen1, selected = true, }, { label = "", defaultFile = "images/tabbaricon\_blog.png", overFile = "images/tabbaricon\_blog\_down.png", labelColor = { default = { 0.25, 0.25, 0.25 }, over = { 0.768, 0.516, 0.25 } }, width = 32, height = 32, onPress = myApp.showScreen2, }, { label = "", defaultFile = "images/tabbaricon\_pic.png", overFile = "images/tabbaricon\_pic\_down.png", labelColor = { default = { 0.25, 0.25, 0.25 }, over = { 0.768, 0.516, 0.25 } }, width = 32, height = 32, onPress = myApp.showScreen3, }, { label = "", defaultFile = "images/tabbaricon\_vid.png", overFile = "images/tabbaricon\_vid\_down.png", labelColor = { default = { 0.25, 0.25, 0.25 }, over = { 0.768, 0.516, 0.25 } }, width = 32, height = 32, onPress = myApp.showScreen4, }, { label = "", defaultFile = "images/tabbaricon\_exit.png", overFile = "images/tabbaricon\_exit\_down.png", labelColor = { default = { 0.25, 0.25, 0.25 }, over = { 0.768, 0.516, 0.25 } }, width = 32, height = 32, onPress = closeMenu, }, } myApp.tabBar = widget.newTabBar{ top = -50 + display.contentHeight/2, left = 0, width = display.contentWidth\*2, backgroundFile = tabBarBackgroundFile, tabSelectedLeftFile = tabBarLeft, -- New tabSelectedRightFile = tabBarRight, -- New tabSelectedMiddleFile = tabBarMiddle, -- New tabSelectedFrameWidth = 20, -- New tabSelectedFrameHeight = 50, -- New buttons = tabButtons, height = 50, background="images/tabBarBg7.png" } -- -- now make the first tab active.align -- --sceneGroup:insert(background) --sceneGroup:insert(myApp.tabBar) --sceneGroup:insert(background) \_G.HQTab:insert(myApp.tabBar) end function scene:show( event ) local sceneGroup = self.view myApp.showScreen1() end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) return scene

Any pointers on how to make this entirely composer-based? Thanks!

Hi, I get this warning in the terminal. I think this has to do with spinner.

 WARNING: timer.resume( timerId ) ignored b/c timerId was not paused.

Is this causing an issue?

Rob

No, it’s not causing issue and not sure if anything will do on iOS.

Dear All,

I am new to use Corona, when I download the Business -app sample and running in the simulator, a Warning message will be show:

“your project uses premium graphics feature(object.fill) available…”

thus how can I fix it for using in starter simulator , please advise.

And I would like to ask is it possible to use corona to open a PDF file or word file in local mobile memory or by URL? please reply and let me know.

thanks & Regards,

Look in the widget-extras.lua file.  These four lines need changed:
 

widget-extras.lua:        background.fill = { type = “image”, filename=opt.background}
widget-extras.lua:        background.fill = opt.backgroundColor
widget-extras.lua:            background.fill = {1,1,1}
widget-extras.lua:            background.fill = { type = “gradient”, color1={0.5, 0.5, 0.5}, color2={0, 0, 0}}

You would have to change them to not use background.fill.

Rob

Hi,

I’ve tried Atom feed but there are some problems with parser. Cannot retrieve the effective entries…

Atom feed passed check well from remote validator:

http://validator.w3.org/feed

The rss version works well…

Of course I’ve replaced the correct “require” in the feed.lua file…

Is there any problem?

Thanks in advance

-j

I haven’t tested the ATOM feed in a while.  It was working against Wordpress ATOM feeds a while back.  Are you getting errors?  What’s in your console log?  What is the URL of the feed you’re trying to use?

There are two things you need to do to make the atom feed work with the business app sample.  These will be included when I push the new version. 

But in the mean time, near the bottom of atom.lua change the line:

feed.entries = stories

to

feed.items = stories

Then in feed.lua and feed2.lua (its the same code in both)  around line 278, replace the pubDate code with:

    local timeStamp
    if atom then
        timeStamp = story.pubDate
    else
        timeStamp = string.match(story.pubDate,"%w+, %d+ %w+ %w+ %w+:%w+")
    end

This assumes that you have done a:

local atom = require( “atom” )

at the top.  The pubDate is in a format like:   yyyy-mm-ddTmm:dd:ssZ

but the RSS feed is more of a human readable format.  You may want to parse this and convert it to a prettier date format.

Rob

Hi Rob,

thank you for reply.

I made the changes you suggested. Of course I had already changed the call to the file atom.lua (instead of rss.lua). 

But the error in my console is:

ERROR: Non-directory file already exists at (null)

The link that I’m testing is as follows:

http://www.krimissa.com/data/_addondata/d5nufsh/feed.atom

In file main.lua I’ve inserted:

feedName = "feed.atom", feedURL = "http://www.krimissa.com/data/\_addondata/d5nufsh/",

Thanks in advance.

Regards.

-j

Hey Rob, 

I’m trying to use your sample business app as an added functionality on top of my app. I’m trying to place the contents of your main.lua file into its own composer scene, but I’m having trouble keeping myApp.tabBar around and getting rid of it when transitioning to scene to scene and back to my main game screen. 

Here’s my code: 

In main.lua:

\_G.HQTab=display.newGroup() \_G.HQTab.x, \_G.HQTab.y = \_W,\_H local display\_stage = display.getCurrentStage() display\_stage:insert( composer.stage ) display\_stage:insert( \_G.HQTab )&nbsp;

In devMenu.lua (adapted from your main.lua):

local composer = require ( "composer" ) local widget = require( "widget" ) local json = require( "json" ) local myApp = require( "HQ.myapp" ) local sheetLoader = require("sheetLoader") local scene = composer.newScene() math.randomseed(os.time()) -- -- Load our fonts and define our styles -- function scene:create( event ) local sceneGroup = self.view if (display.pixelHeight/display.pixelWidth) \> 1.5 then myApp.isTall = true end if display.contentWidth \> 320 then myApp.is\_iPad = true end local tabBarBackgroundFile = "images/tabBarBg7.png" local tabBarLeft = "images/tabBar\_tabSelectedLeft7.png" local tabBarMiddle = "images/tabBar\_tabSelectedMiddle7.png" local tabBarRight = "images/tabBar\_tabSelectedRight7.png" myApp.topBarBg = "images/topBarBg7.png" local iconInfo = { width = 40, height = 40, numFrames = 20, sheetContentWidth = 200, sheetContentHeight = 160 } myApp.icons = graphics.newImageSheet("images/ios7icons.png", iconInfo) if system.getInfo("platformName") == "Android" then myApp.theme = "widget\_theme\_android" myApp.font = "Droid Sans" myApp.fontBold = "Droid Sans Bold" myApp.fontItalic = "Droid Sans" myApp.fontBoldItalic = "Droid Sans Bold" myApp.topBarBg = "images/topBarBg7.png" else myApp.theme = "widget\_theme\_ios7" local coronaBuild = system.getInfo("build") if tonumber(coronaBuild:sub(6,12)) \< 1206 then myApp.theme = "widget\_theme\_ios" end myApp.font = "HelveticaNeue-Light" myApp.fontBold = "HelveticaNeue" myApp.fontItalic = "HelveticaNeue-LightItalic" myApp.fontBoldItalic = "Helvetica-BoldItalic" end widget.setTheme(myApp.theme) myApp.tabBar = {} function myApp.showScreen1() myApp.tabBar:setSelected(1) --composer.removeHidden() composer.gotoScene("HQ.menu", {time=250, effect="crossFade"}) return true end function myApp.showScreen2(event) myApp.tabBar:setSelected(2) local options = { feedName = "outcast.rss", feedURL = "http://www.simplemachine.co/?cat=60&feed=rss2", icons = "fixed", displayMode = "webpage", pageTitle = "The Outcast" } --composer.removeHidden() composer.gotoScene("HQ.feed", {time=250, effect="crossFade", params = options}) return true end function myApp.showScreen3() myApp.tabBar:setSelected(3) --composer.removeHidden() composer.gotoScene("HQ.photogallery", {time=250, effect="crossFade"}) return true end function myApp.showScreen4() myApp.tabBar:setSelected(4) local options = { feedName = "video.rss", feedURL = "http://gdata.youtube.com/feeds/mobile/playlists/PLUqsW7siiOQScFgxcIi-upYV7wAmsgWCL?max-results=20&alt=rss&orderby=published&format=1", icons = "fixed", displayMode = "videoviewer", pageTitle = "The Outcast Videos" } --composer.removeHidden() composer.gotoScene("HQ.feed2", {time=250, effect="crossFade", params = options}) return true end function myApp.showScreen5() print("Making the call to update...") local sheetArray = sheetLoader.new() return true end local function closeMenu() print("YEEEEAHHAHAHAH") local function killNav() composer.gotoScene("scene1", "crossFade", 400) -- end --myApp.tabBar:removeSelf() transition.to(myApp.tabBar, {time=300, transition=easing.inOutQuad, onComplete=killNav}) return true end local tabButtons = { { label = "", defaultFile = "images/tabbaricon\_main.png", overFile = "images/tabbaricon\_main\_down.png", labelColor = { default = { 0.25, 0.25, 0.25 }, over = { 0.768, 0.516, 0.25 } }, width = 32, height = 32, onPress = myApp.showScreen1, selected = true, }, { label = "", defaultFile = "images/tabbaricon\_blog.png", overFile = "images/tabbaricon\_blog\_down.png", labelColor = { default = { 0.25, 0.25, 0.25 }, over = { 0.768, 0.516, 0.25 } }, width = 32, height = 32, onPress = myApp.showScreen2, }, { label = "", defaultFile = "images/tabbaricon\_pic.png", overFile = "images/tabbaricon\_pic\_down.png", labelColor = { default = { 0.25, 0.25, 0.25 }, over = { 0.768, 0.516, 0.25 } }, width = 32, height = 32, onPress = myApp.showScreen3, }, { label = "", defaultFile = "images/tabbaricon\_vid.png", overFile = "images/tabbaricon\_vid\_down.png", labelColor = { default = { 0.25, 0.25, 0.25 }, over = { 0.768, 0.516, 0.25 } }, width = 32, height = 32, onPress = myApp.showScreen4, }, { label = "", defaultFile = "images/tabbaricon\_exit.png", overFile = "images/tabbaricon\_exit\_down.png", labelColor = { default = { 0.25, 0.25, 0.25 }, over = { 0.768, 0.516, 0.25 } }, width = 32, height = 32, onPress = closeMenu, }, } myApp.tabBar = widget.newTabBar{ top = -50 + display.contentHeight/2, left = 0, width = display.contentWidth\*2, backgroundFile = tabBarBackgroundFile, tabSelectedLeftFile = tabBarLeft, -- New tabSelectedRightFile = tabBarRight, -- New tabSelectedMiddleFile = tabBarMiddle, -- New tabSelectedFrameWidth = 20, -- New tabSelectedFrameHeight = 50, -- New buttons = tabButtons, height = 50, background="images/tabBarBg7.png" } -- -- now make the first tab active.align -- --sceneGroup:insert(background) --sceneGroup:insert(myApp.tabBar) --sceneGroup:insert(background) \_G.HQTab:insert(myApp.tabBar) end function scene:show( event ) local sceneGroup = self.view myApp.showScreen1() end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) return scene

Any pointers on how to make this entirely composer-based? Thanks!

Dear All,

I am new to use Corona, when I download the Business -app sample and running in the simulator, a Warning message will be show:

“your project uses premium graphics feature(object.fill) available…”

thus how can I fix it for using in starter simulator , please advise.

And I would like to ask is it possible to use corona to open a PDF file or word file in local mobile memory or by URL? please reply and let me know.

thanks & Regards,