Skip to content

Commit

Permalink
build UI in sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
kalyandechiraju committed Jan 17, 2016
1 parent 9b67d88 commit 60cbc76
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 22 deletions.
2 changes: 1 addition & 1 deletion sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package="studios.codelight.weatherdownloader">

<application
android:allowBackup="true"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle("Current Weather");
}
}
184 changes: 179 additions & 5 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,190 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context="studios.codelight.weatherdownloader.MainActivity">

<TextView
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello World!" />
</RelativeLayout>
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Search by name" />
<EditText
android:id="@+id/city_name"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:hint="city name"
android:inputType="textAutoCorrect" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/city_result"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />

<ProgressBar
android:id="@+id/city_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:indeterminate="true"/>

<Button
android:id="@+id/city_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get Current Weather" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Search by zip code" />
<EditText
android:id="@+id/zip_code"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:hint="zip code"
android:inputType="number" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/zip_code_result"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />

<ProgressBar
android:id="@+id/zip_code_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:indeterminate="true"/>

<Button
android:id="@+id/zip_code_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get Current Weather"
android:layout_gravity="end"/>

</LinearLayout>


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Search by coordinates" />
<EditText
android:id="@+id/coordinates"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:hint="lat:lon"
android:inputType="text" />
</LinearLayout>


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/coordinates_result"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />

<ProgressBar
android:id="@+id/coordinates_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:indeterminate="true"/>

<Button
android:id="@+id/coordinates_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get Current Weather"
android:layout_gravity="end"/>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Search by City ID" />
<EditText
android:id="@+id/city_id"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:hint="city id"
android:inputType="text" />
</LinearLayout>


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/city_id_result"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />

<ProgressBar
android:id="@+id/city_id_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:indeterminate="true"/>

<Button
android:id="@+id/city_id_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get Current Weather"
android:layout_gravity="end"/>

</LinearLayout>

</LinearLayout>
4 changes: 4 additions & 0 deletions sample/src/main/res/values/keys.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="weather_api_key">REPLACE_WITH_YOUR_KEY</string>
</resources>
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
package studios.codelight.weatherdownloaderlibrary;

import android.util.Log;

import org.json.JSONException;
import org.json.JSONObject;

import studios.codelight.weatherdownloaderlibrary.model.Clouds;
import studios.codelight.weatherdownloaderlibrary.model.Coord;
import studios.codelight.weatherdownloaderlibrary.model.Main;
import studios.codelight.weatherdownloaderlibrary.model.Sys;
import studios.codelight.weatherdownloaderlibrary.model.Weather;
import studios.codelight.weatherdownloaderlibrary.model.WeatherData;
import studios.codelight.weatherdownloaderlibrary.model.Wind;
import studios.codelight.weatherdownloaderlibrary.util.JsonUtil;

/**
* The MIT License (MIT)
* <p/>
Expand All @@ -38,6 +22,23 @@
* SOFTWARE.
* Created by kalyan on 9/1/16.
*/

package studios.codelight.weatherdownloaderlibrary;

import android.util.Log;

import org.json.JSONException;
import org.json.JSONObject;

import studios.codelight.weatherdownloaderlibrary.model.Clouds;
import studios.codelight.weatherdownloaderlibrary.model.Coord;
import studios.codelight.weatherdownloaderlibrary.model.Main;
import studios.codelight.weatherdownloaderlibrary.model.Sys;
import studios.codelight.weatherdownloaderlibrary.model.Weather;
import studios.codelight.weatherdownloaderlibrary.model.WeatherData;
import studios.codelight.weatherdownloaderlibrary.model.Wind;
import studios.codelight.weatherdownloaderlibrary.util.JsonUtil;

public class WeatherDataBuilder {
private static final String LOG_TAG = "WeatherDownloader";
public static WeatherData buildWeatherData(String response) {
Expand Down

0 comments on commit 60cbc76

Please sign in to comment.