damonkohler / sl4a

SL4A brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device.
Apache License 2.0
2.43k stars 800 forks source link

can't refresh css stylesheet in webviewshow #156

Open damonkohler opened 9 years ago

damonkohler commented 9 years ago

From @GoogleCodeExporter on May 31, 2015 11:29

What device(s) are you experiencing the problem on?
Motorola Droid and Motorola Xoom

What firmware version are you running on the device?
Droid=Cyanogenmod7 (Gingerbread), Xoom=Stock Honeycomb

What steps will reproduce the problem?

1.load a page, i.e., droid.webViewShow('sample_page.html') with a separate 
stylesheet.

2.close the script and edit the css in the stylesheet.

3.open the webpage again.

What is the expected output? The page should open with updated styling.  

What do you see instead? The old stylesheet is still cached with no way to 
update it.

What version of the product are you using? On what operating system?
sl4r3 on Gingerbread and Honeycomb

Original issue reported on code.google.com by business...@gmail.com on 21 Mar 2011 at 3:56

Copied from original issue: damonkohler/android-scripting#535

damonkohler commented 9 years ago

From @GoogleCodeExporter on May 31, 2015 11:29

The only workaround I've found so far is to delete sl4a's data in 
settings>applications>sl4a.  Not ideal for obvious reasons.

Original comment by business...@gmail.com on 22 Mar 2011 at 2:56

damonkohler commented 9 years ago

From @GoogleCodeExporter on May 31, 2015 11:29

I have the same problems.. 
I'd like to clear the cache of webview programmatically but can't find a clear 
way to do that with SL4A. There exists code to wash the cache in java but not 
python apparently.. does someone as a solution in python we didn't see? 
Thanks 
Lio

Original comment by lio.chi...@gmail.com on 28 Dec 2011 at 3:53

damonkohler commented 9 years ago

From @GoogleCodeExporter on May 31, 2015 11:29

I solved this in a programmatic way.  With python sl4a, if the 'same' webview 
is opened (ie: samefile.html), it will display the previous cached page, which 
is not good if you change the page code, such as viewing an image jpg, then 
viewing a new image jpg.  With apps built on sl4a, webviews are the only real 
useable user interface.  I tried having the script name a new page (ie: 
newfile1.html; newfile2.html; ...) but still the old cached jpg image was used. 
 in my app, i display a number of images to the user ina webview, updating the 
jpg image in the html code each view.  I solved this by ALSO changing the jpg 
names (ie: jpg1.jpg; jpg2.jpg; ...)

To do this:
import random
randomPageName=random.randrange(0,100)
randomJpgName=random.randrange(0,100)
htmlPage=open('//file'+str(randomPageName)+'.html','wb')
htmlPage.write('<html><body><img 
src="jpg'+str(randomJpgName)+'.jpg"/></body></html>')
htmlPage.close()
droid.webViewShow('//file'+str(randomPageName)+'.html')

..get the idea?
further to this, i delete the folder i use for the app upon exiting the script:
import shutil
shutil.rmtree('/sdcard/MyAppFolder')
mypath=('/sdcard/MyAppFolder')

...then to make your folder again:
import os.path
if not os.path.isdir(mypath):
   os.makedirs(mypath)

Cheers:)
and please have a look at my apps:
https://play.google.com/store/apps/developer?id=FineLineLabs

Original comment by MichaelD...@gmail.com on 24 Oct 2012 at 2:51