GithubHelp home page GithubHelp logo

Comments (24)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
FileReader is not implemented so there's no way to read files

Original comment by [email protected] on 21 Sep 2011 at 3:48

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
you are right, fix will be in trunk soon

Original comment by [email protected] on 21 Sep 2011 at 5:18

  • Changed state: Accepted

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
Will you implement FileReader also?

Original comment by [email protected] on 21 Sep 2011 at 5:58

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
yes sure

Original comment by [email protected] on 21 Sep 2011 at 6:08

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
fix is in trunk, but I havent had time to test anything yet. Testing and a Mock 
API for hosted mode will be done soon. Hope that premature fix helps.

I leave the issue open until proper testing is done.

Original comment by [email protected] on 21 Sep 2011 at 6:32

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
Trying to use it but having some problem figuring out how to use the 
FileReader. Here's my code:

phoneGap.getFile().requestFileSystem(File.LocalFileSystem_PERSISTENT, 0, new 
FileCallback<FileSystem, FileError>() {

                    public void onSuccess(FileSystem entry) {
                        if (entry != null) {
                            Flags f = new Flags();
                            f.setCreate(true);
                            entry.getRoot().getFile("file.txt", f, new FileCallback<FileEntry, FileError>() {

                                public void onSuccess(FileEntry entry) {
// the following contructor is protected but I would assume that's how it 
should be used?
                                    FileReader fr = new FileReaderJsImpl();
                                    fr.setOnLoadEndCallback(new ReaderCallback<FileReader>() {

                                        public void onCallback(FileReader result) {
                                            String content = result.getResult();
                                        }
                                    });
                                    fr.readAsText(entry);

                                }

                                public void onFailure(FileError error) {
                                    throw new UnsupportedOperationException("Not supported yet.");
                                }
                            });
                        }
                    }

                    public void onFailure(FileError error) {
                        throw new UnsupportedOperationException("Not supported yet.");
                    }
                });

Original comment by [email protected] on 22 Sep 2011 at 7:35

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
you can`t instanciate FileReaderJsImpl its a javascript overlay class

Use the createReader on the File module:

phoneGap.getFile().createReader();

You can also simualte the phonegap file api in dev mode now, but you need to 
start your jvm with -DinsecurePhoneGapFileApi=true -DphonegapFilePath="<the 
directory to use" (note: jvm options not gwt hosted mode options). I will write 
up some documentation on how to use it soon (its not quite finished yet)

in the trunk theres an example how to use it:
http://code.google.com/p/gwt-phonegap/source/browse/gwt-phonegap-showcase/src/ma
in/java/de/kurka/phonegap/showcase/client/file/FilePresenter.java


Original comment by [email protected] on 22 Sep 2011 at 3:17

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
The following code is yielding a "[INFO] Error in success callback: 
com.phonegap.file1 = RangeError: Maximum call stack size exceeded" - it fails 
somewhere in the onSuccess(FileEntry entry)

phoneGap.getFile().requestFileSystem(File.LocalFileSystem_PERSISTENT, 0, new 
FileCallback<FileSystem, FileError>() {

            public void onSuccess(FileSystem entry) {
                console("got fs: "+entry);
                if (entry != null) {
                    Flags f = new Flags();
                    f.setCreate(true);

                    entry.getRoot().getFile(filename, f, new FileCallback<FileEntry, FileError>() {

                        public void onSuccess(FileEntry entry) {
                            console("got fs2: "+entry);
                            FileReader fr = phoneGap.getFile().createReader();
                            fr.setOnLoadEndCallback(new ReaderCallback<FileReader>() {

                                public void onCallback(FileReader result) {
                                    console("got fs3: "+result);
                                    String content = result.getResult();
                                    console("login file found: " + content);

                                    callback.onSuccess(content);
                                }
                            });
                            fr.readAsText(entry);

                        }

                        public void onFailure(FileError error) {
                            console("failed1");
                            throw new UnsupportedOperationException("Not supported yet.");
                        }
                    });
                }
            }

            public void onFailure(FileError error) {
                console("failed2");
                throw new UnsupportedOperationException("Not supported yet.");
            }
        });


console:
2011-09-23 10:26:38.133 CM[1904:f503] [INFO] got fs2: 
de.kurka.phonegap.client.file.js.FileEntryJsImpl@1f
2011-09-23 10:26:38.135 CM[1904:f503] [INFO] Error in success callback: 
com.phonegap.file1 = RangeError: Maximum call stack size exceeded.

Original comment by [email protected] on 23 Sep 2011 at 8:33

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
I have a feeling that readAsText is recursively calling itself in your code. 

Original comment by [email protected] on 23 Sep 2011 at 8:45

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
make sure that you have got the latest version. I had the same issue yesterday 
and fixed it in trunk

Original comment by [email protected] on 23 Sep 2011 at 8:49

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
Ok confirmed, funtion readAsText was calling itself. Here's the fix:

  @Override
    public void readAsText(FileEntry entry) {
        FileEntryJsImpl entryJs = (FileEntryJsImpl) entry;
        readAsText(entryJs.getEntry());
    }

Original comment by [email protected] on 23 Sep 2011 at 9:00

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
take a look at trunk should be fine now:
http://code.google.com/p/gwt-phonegap/source/browse/gwt-phonegap/src/main/java/d
e/kurka/phonegap/client/file/js/FileReaderJsImpl.java

Original comment by [email protected] on 23 Sep 2011 at 9:10

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
Yes it works

Original comment by [email protected] on 23 Sep 2011 at 1:28

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
Not sure why but it seems that getFile() in the following, returns null (on 
Android emulator). Permissions are set, SD is available but it still returns 
null:

phoneGap.getFile().requestFileSystem(File.LocalFileSystem_PERSISTENT, 0, new 
FileCallback....

Original comment by [email protected] on 23 Sep 2011 at 2:01

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
it seems fine to me on android emulator. can you provide a bigger code sample 
for me to run?

Original comment by [email protected] on 24 Sep 2011 at 9:22

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
[deleted comment]

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
This code fails in FileJsImpl's requestFileSystem (right after 
$wnd.requestFileSystem is called). callback functions are never called:


        phoneGap.getFile().requestFileSystem(File.LocalFileSystem_PERSISTENT, 0, new FileCallback<FileSystem, FileError>() {

            public void onSuccess(FileSystem entry) {
                console("got fs: " + entry);
                if (entry != null) {
                    Flags f = new Flags();
                    f.setCreate(false);

                    entry.getRoot().getFile(filename, f, new FileCallback<FileEntry, FileError>() {

                        public void onSuccess(FileEntry entry) {
                            console("got fs2: " + entry);
                            FileReader fr = phoneGap.getFile().createReader();
                            fr.setOnLoadEndCallback(new ReaderCallback<FileReader>() {

                                public void onCallback(FileReader result) {
                                    console("got fs3: " + result);
                                    String content = result.getResult();

                                    callback.onSuccess(content);
                                }
                            });
                            console("reader created");
                            fr.readAsText(entry);

                        }

                        public void onFailure(FileError error) {
                            console("login file does not exist");
                            callback.onSuccess(null);
                        }
                    });
                }
            }

            public void onFailure(FileError error) {
                console("failed2");
                throw new UnsupportedOperationException("Not supported yet.");
            }
        });


Original comment by [email protected] on 27 Sep 2011 at 12:33

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
Upgraded to latest gwt-phonegap, using phonegap 1.0.0 - the above will throw 
the following error in Android only, works fine with iOS:
 (TypeError): Result of expression '$wnd.requestFileSystem' [undefined] is not a function

Original comment by [email protected] on 30 Sep 2011 at 9:38

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
seems like you missing the phonegap.js file for some reason. 
can you post your html host file for your device?

can you post your bootup code in gwt for starting gwt-phonegap?

Original comment by [email protected] on 30 Sep 2011 at 9:59

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
Well phonegap is loading properly because  void 
onPhoneGapAvailable(PhoneGapAvailableEvent event) is called just fine after 
phoneGap.initializePhoneGap();

Remember this works fine in iOS just not Android.

I have         <script src="./phonegap-1.0.0.js" type="text/javascript" 
charset="utf-8"></script> 
and
 <meta name='gwt:module' content='com.mobile=com.mobile'/>
in <Head>

Also
        <iframe src="javascript:''" id='__gwt_historyFrame' style='width:0;height:0;border:0'></iframe>
        <script type="text/javascript"  src="./com.mobile/com.mobile.nocache.js"></script>
first thing in <body>

Original comment by [email protected] on 2 Oct 2011 at 7:24

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
What kind of phone are you using?

I can`t seem to be able to reproduce this with any android phone I have got

Original comment by [email protected] on 2 Oct 2011 at 6:59

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
Using emulators (2.2 & 3.x)

Original comment by [email protected] on 3 Oct 2011 at 5:58

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
I have tried to replicate the problem with the trunk and an android 2.2 
emulated device.

My onFailure function is called just fine with PERMISSION_DENIED.

can you put some javascript into your page to alert the value of 
window.requestFileSystem ?

It this is null or not a function something is fishy with your setup for android

Original comment by [email protected] on 4 Oct 2011 at 8:45

from gwt-phonegap.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 7, 2024
I will close this off since there hasn`t been any feebback for more than 6 
months

Original comment by [email protected] on 30 Apr 2012 at 5:46

  • Changed state: Done

from gwt-phonegap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.