Git Product home page Git Product logo

forecastio-lib-java's People

Contributors

akapribot avatar askmrsinh avatar bryant1410 avatar duncanj avatar dvdme avatar joosep-wm avatar juanjmarques avatar kschap avatar marcosatanaka avatar martiner avatar myolnir avatar schertzs-amzn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

forecastio-lib-java's Issues

Problem with proxy connections

Hi!
I encountered problems when using forecast.io behind a proxy server.
In the current version there is no way to set anywhere the proxy and the system settings are not used by default...
I already forked the project and implemented a solution to this by adding the possibility to define a proxy if needed. I took care that this is truly optional...
I will soon use a pull request to show you my solution for your consideration...
KR, Franz

Optimise for Android / Android Studio

Awesome Libary,
Please can you optimise this libary to work with android / android studio. it keep crashing the app each time i try to fetch the weather data.

Thanks

System.err Bad Response: </html>

I'm using version 1.6.0 of ForecastIOLib, linked as
Dependencies{
implementation 'com.github.dvdme:ForecastIOLib:1.6.0'
}

I'm seeing error messages in my Android logs but I can't debug them further using what ForecastIO is logging.

I see:
05-07 18:05:47.151 6447 6780 W System.err: Bad Response:

I believe this is printed at ForecastIO.java:781,
System.err.println("Bad Response: " + response + "\n");

It seems that the library is only printing the last line of the error stream, and that error stream seems to be an HTML page.

If you could return a response code or the response stream to the application, it could decide whether or not to retry or let the end user address the issue in some way.

Further Android Optimisation

i have the following code:

  ForecastIO fio = new ForecastIO(apikey);
        fio.setUnits(ForecastIO.UNITS_SI);
        fio.setLang(ForecastIO.LANG_ENGLISH);
        fio.getForecast(9999999,8888888);
        //Currently
        FIOCurrently currently = new FIOCurrently(fio);

it would be really nice if there was a way to make the Currently / Hourly /Minutely e.t.c accessible from any activity. So that developers don't have to make an Api request every time they need to use the returned data on another activity.

Again, Awesome Libary.

Version 1.5.3 won't compile in android studio project.

When i add 1.5.1 or 1.5.2 it works perfectly,but when i use 1.5.3 i get the following error.

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/eclipsesource/json/JsonArray$1;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
    at com.android.dx.command.dexer.Main.run(Main.java:277)
    at com.android.dx.command.dexer.Main.main(Main.java:245)
    at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

Crash on reading big JSON response

response = scanner.useDelimiter("\Z").next();
seems to return only 1024 chars from the JSON response which therefor becomes invalid and the parser crashes.
What I have used (and works at least for me) is:
ForecastIO.java

            if(connection.getResponseCode() == 400){
                System.out.println("Bad Responde. Maybe an invalid location was provided.\n");
                return null;
            }
            else {
//                File file = new File(request.openStream());
//              scanner = new Scanner(new FileInputStream());
//              response = scanner.useDelimiter("\\Z").next();
//              scanner.close();
                BufferedReader reader = null;

                try {
                    reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                    String line = "";
                    while ((line = reader.readLine()) != null) {
                        response = line;
                    }
                }
                catch (IOException e) {
                }
                finally {
                    if (reader != null) {
                        try {
                            reader.close();
                            reader = null;
                        } catch (IOException e) {
                        }
                    }
                }
            }

ClassNotFoundError

Hi,
I try to run this class in my Android project, but I get a ClassNotFoundError.
Tried to clean project, deleting/adding JAR in "Libs" folder, etc. Nothing work.

Here is my logcat report :
06-28 00:59:38.860: E/AndroidRuntime(30369): FATAL EXCEPTION: main
06-28 00:59:38.860: E/AndroidRuntime(30369): java.lang.NoClassDefFoundError: dme.forecastiolib.ForecastIO
06-28 00:59:38.860: E/AndroidRuntime(30369): at com.yyy.xxx.Weather.getCurr(Weather.java:18)
06-28 00:59:38.860: E/AndroidRuntime(30369): at com.yyy.xxx.Weather.getTemperature(Weather.java:27)
06-28 00:59:38.860: E/AndroidRuntime(30369): at com.yyy.xxx.screens.Infos$1$1.run(Infos.java:35)
06-28 00:59:38.860: E/AndroidRuntime(30369): at android.os.Handler.handleCallback(Handler.java:615)
06-28 00:59:38.860: E/AndroidRuntime(30369): at android.os.Handler.dispatchMessage(Handler.java:92)
06-28 00:59:38.860: E/AndroidRuntime(30369): at android.os.Looper.loop(Looper.java:137)
06-28 00:59:38.860: E/AndroidRuntime(30369): at android.app.ActivityThread.main(ActivityThread.java:4898)
06-28 00:59:38.860: E/AndroidRuntime(30369): at java.lang.reflect.Method.invokeNative(Native Method)
06-28 00:59:38.860: E/AndroidRuntime(30369): at java.lang.reflect.Method.invoke(Method.java:511)
06-28 00:59:38.860: E/AndroidRuntime(30369): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
06-28 00:59:38.860: E/AndroidRuntime(30369): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
06-28 00:59:38.860: E/AndroidRuntime(30369): at dalvik.system.NativeStart.main(Native Method)

and my code :

import com.yyy.xxx.location.GPSTracker;

import dme.forecastiolib.FIOCurrently;
import dme.forecastiolib.ForecastIO;

import android.content.Context;
import android.util.Log;

public class Weather {

public static String WEATHER_API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxx";
//public static String WEATHER_UNITS;

private FIOCurrently getCurr(Context c) {
    GPSTracker gp = new GPSTracker(c);
    ForecastIO fio = new ForecastIO(WEATHER_API_KEY);
        fio.setUnits(ForecastIO.UNITS_AUTO);
    fio.setExcludeURL("hourly,minutely");
    Log.i("Weather", fio.getUnits());
    fio.getForecast(String.valueOf(gp.getLatitude()), String.valueOf(gp.getLongitude()));
    return new FIOCurrently(fio);
}

public Double getTemperature(Context c) {
    FIOCurrently curr = getCurr(c);
    return curr.get().temperature();
}

}

Regards,
J. L.

New feature: property moonPhase

The property moonPhase it's not available in FIODataPoint. I implemented and tested the new feature locally on my computer. May I fork the project and perform a pull request to yours?

Returning -1d for non existant keys is hard to detect with Doubles

There are several getters that are expected to return a Double, but return -1d for a non-existent key. Example Java doc:

/**

  • The temperature at the given time in degrees in using the units defined
  • in the class ForecastIO.
  • For more information refer to the API Docs:
  • https://developer.forecast.io
  • @return A Double number with the temperature. Returns -1 if the field is not defined.
    */

How can one differentiate between a temperature of -1 and -1 temperature not found? Temperature is an obvious one, but also visibility might be negative distance. There might be others.

Returning null might work or returning a more obviously wrong value.

Thank you,
Matt

Cannot access latest snapshot in maven repo

Basically I'm trying to use LATEST and it fails. I suspect that it's due to maven 3.x removing compatibility with those.

Could you push another release?
(or explain how to solve the issue)

Also jitpack.io fails to compile latest commits: jitpack log which is because of missing imports. Solved here

offset NumberFormatException

java.lang.NumberFormatException: Invalid int: "10.5" ...

Both ForecastIO.offset and ForecastIO.offsetValue have this issue.
Obviously, this only occurs in timezones with offsets that are not integers.

Uses 2 api calls

Each time i run FIOLibTest it uses 2 API calls and i cant figure out why.

In FIODataPoint, fields that are Strings are enclosed by double quotes.

For instance, dataPoint.icon() will not return partly-cloudy-day but "partly-cloudy-day".

This is because of the way the void update(JsonObject dp) method is coded.
This takes all the fields in the Json object and puts it in a map, like this: datapoint.put(dp.names().get(i), dp.get(dp.names().get(i))).

The problem is dp.get() returns JsonNumber, JsonString, etc. depending on the type of the field, and JsonString.toString() returns the value as Json code. And the Json representation of a String is its value enclosed by double quotes :)

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.