Skip to content

Instantly share code, notes, and snippets.

@imrankst1221
Last active June 24, 2017 07:33
Show Gist options
  • Save imrankst1221/113b3328564dc0b14072e6b792dab6a2 to your computer and use it in GitHub Desktop.
Save imrankst1221/113b3328564dc0b14072e6b792dab6a2 to your computer and use it in GitHub Desktop.
Programing Test for Cookpad Inc.
This Git made for Programing Test for Cookpad Inc. I use GitHub for manage version control system, but I use Gist for the first time. At first, I complete my project in GitHub after that I upload Gist.
Forgave me if I make any mistakes, I try my best. I Choose Android project and I share my code and detail bellow,
build.gradle:
I use some trusted library to make easier development and manage the project. Inside this file, you can see the list of library use in this project.
I try to develop simple and user-friendly UI. It's a single Activity project. I try to touch your all requirement in one page. dimens.xml is the value of text and other content sizes.
HomeActivity.java (activity_home.xml):
HomeActivity is the main solution page. I try to develop userfriendly and simple UI.
getWeatherAPI() is API call for reading data, initially, show a demo location's ("Dhaka") weather. The user can change location by using search option which can suggest city locations.
Use RxJava and RxAndroid books for Observable multitasking, OkHttpClient library for reading API and get value. Gson library to generate plain Old Java Objects from JSON format.
setCurrentWeather() is set all weather data for Activity and load image using Picasso. get the image from API.
setSearch() is getting offline .json file to suggest user locations. Read.java is getting the .json file from assets folder and return list of cities. citys.json is some demo citys name.
WeatherAdapter.java (layout_weather.xml) showing 7 dayes weather update bellow of activity with weekly name and image.
I also share all schemas that's use into my project.
If you have any query let me know,
Thnak you.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fitsSystemWindows="true"
tools:context="imrankst1221.weatherapp.ui.HomeActivity">
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_gradient"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin.3">
<AutoCompleteTextView
android:id="@+id/txt_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:paddingLeft="@dimen/margin.2"
android:paddingRight="@dimen/margin.2"
android:layout_margin="@dimen/margin.1"
android:drawablePadding="@dimen/margin.3"
android:drawableLeft="@drawable/ic_search"
android:drawableRight="@drawable/ic_close"
android:textColor="@color/text.white"
android:textColorHint="@color/text.white"
android:inputType="text"
android:background="@color/white.transparent"
android:completionThreshold="2"
android:textSize="@dimen/text.size.medium"
android:imeOptions="actionDone"
android:hint="Search"/>
<TextView
android:id="@+id/txt_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:layout_below="@+id/txt_search"
android:textSize="@dimen/text.size.7xl"
android:layout_centerHorizontal="true"
android:textColor="@color/text.white"
android:drawablePadding="@dimen/margin.2"
android:drawableLeft="@drawable/ic_location"
android:layout_marginTop="@dimen/margin.2"
android:gravity="center"
android:text="Dhaka"/>
<ImageView
android:id="@+id/img_weather"
android:layout_width="140dp"
android:layout_height="110dp"
android:layout_marginLeft="@dimen/margin.4"
android:layout_below="@id/txt_location"
android:src="@drawable/demo_weather"/>
<TextView
android:id="@+id/txt_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/img_weather"
android:minEms="8"
android:layout_marginLeft="@dimen/margin.3"
android:textSize="@dimen/text.size.xl"
android:textColor="@color/text.white"
android:text="heavy intensity rain"/>
<RelativeLayout
android:id="@+id/layout_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/txt_location"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/margin.5">
<TextView
android:id="@+id/txt_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/text.size.7xl"
android:textColor="@color/text.white"
android:minEms="3"
android:gravity="center"
android:layout_alignParentRight="true"
android:textStyle="bold"
android:text="Drizzle"/>
<LinearLayout
android:id="@+id/layout_level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/txt_main"
android:orientation="horizontal">
<TextView
android:id="@+id/txt_temp_min"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="@dimen/text.size.4xl"
android:textColor="@color/text.white"
android:text="-09"/>
<TextView
android:id="@+id/txt_divider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="@dimen/text.size.4xl"
android:textColor="@color/text.white"
android:text=" / "/>
<TextView
android:id="@+id/txt_temp_max"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="@dimen/text.size.4xl"
android:textColor="@color/text.white"
tools:text="09"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="@dimen/text.size.4xl"
android:textColor="@color/text.white"
android:text=" \u00B0 C"/>
</LinearLayout>
<TextView
android:id="@+id/txt_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/layout_level"
android:minEms="5"
android:gravity="center"
android:layout_alignParentRight="true"
android:textSize="@dimen/text.size.xl"
android:textColor="@color/text.white"
android:text="12:02:34"/>
<TextView
android:id="@+id/txt_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_time"
android:minEms="5"
android:gravity="center"
android:layout_alignParentRight="true"
android:textSize="@dimen/text.size.xl"
android:textColor="@color/text.white"
android:text="09/02/2017"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/margin.1"
android:layout_below="@id/layout_location">
<TextView
android:id="@+id/txt_temp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="@dimen/text.size.superxXl"
android:textColor="@color/text.white"
android:text="-09"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:gravity="right"
android:layout_toRightOf="@+id/txt_temp"
android:textSize="@dimen/text.size.superXl"
android:textColor="@color/text.white"
android:text=" \u00B0 C"/>
</RelativeLayout>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/list_weather"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/margin.3"
android:overScrollMode="always" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="imrankst1221.weatherapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.HomeActivity"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
</application>
</manifest>
package imrankst1221.weatherapp.api.response_layer;
/**
* Created by imrankst1221@gmail.com
*/
public class APIResponse {
private int responseCode;
public String getResponseMessage() {
return responseMessage;
}
public void setResponseMessage(String responseMessage) {
this.responseMessage = responseMessage;
}
private String responseMessage;
public String getResponse() {
return response;
}
public void setResponse(String response) {
this.response = response;
}
public int getResponseCode() {
return responseCode;
}
public void setResponseCode(int responseCode) {
this.responseCode = responseCode;
//setMessage(responseCode);
}
public boolean isError() {
return isError;
}
public void setError(boolean error) {
isError = error;
}
public boolean isError;
private String response;
}
package imrankst1221.weatherapp.api;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import imrankst1221.weatherapp.Constants;
import imrankst1221.weatherapp.api.response_layer.APIResponse;
import imrankst1221.weatherapp.api.response_layer.WeatherResponse;
import imrankst1221.weatherapp.api.response_layer.WeeklyWeatherResponse;
import imrankst1221.weatherapp.api.response_layer.current_weather.Weather;
import imrankst1221.weatherapp.api.response_layer.weekly_weather.Weathers;
import imrankst1221.weatherapp.setting.NetworkTimeoutException;
import imrankst1221.weatherapp.utility.Utils;
import rx.Observable;
import rx.Subscriber;
/**
* Created by imrankst1221@gmail.com
*/
public class ApiService {
static final String TAG = "---API";
//get current weather
public static Observable<WeatherResponse> getWeatherAPI(final String location) {
return Observable.create(new Observable.OnSubscribe<WeatherResponse>() {
String response = "";
@Override
public void call(Subscriber<? super WeatherResponse> subscriber) {
try {
//String url = Utils.urlBuilder(Constants.API_GET_HOME_STATUS,params);
APIResponse apiResponse = ApiWorker.executeGETPublic("weather?q="+location+"&units=metric");
if(apiResponse.getResponseCode() != Constants.NOT_FOUND) {
response = apiResponse.getResponse(); // Optional Check
WeatherResponse mResponse = new WeatherResponse();
mResponse.setError(apiResponse.isError());
if(!apiResponse.isError()) {
GsonBuilder builder = new GsonBuilder();
builder.excludeFieldsWithoutExposeAnnotation();
Gson gson = builder.create();
Weather result = gson.fromJson(apiResponse.getResponse(), Weather.class);
mResponse.setWeather(result);
} else {
mResponse.setResponseMessage(apiResponse.getResponseMessage());
}
if (!subscriber.isUnsubscribed()) {
subscriber.onNext(mResponse);
subscriber.onCompleted();
}
} else {
if (!subscriber.isUnsubscribed()) {
NetworkTimeoutException networkTimeoutException =
new NetworkTimeoutException("Please check your internet connection");
subscriber.onError(networkTimeoutException);
}
}
} catch (Exception e) {
Log.d(TAG, "-e "+e);
if (!subscriber.isUnsubscribed()) {
Utils.printLog(TAG+" API_RESPONSE", response);
e.printStackTrace();
Utils.printLog(TAG+" ERROR", e.getMessage());
subscriber.onError(e);
}
}
}
});
}
//get weekly weather
public static Observable<WeeklyWeatherResponse> getWeeklyWeatherAPI(final String location) {
return Observable.create(new Observable.OnSubscribe<WeeklyWeatherResponse>() {
String response = "";
@Override
public void call(Subscriber<? super WeeklyWeatherResponse> subscriber) {
try {
//String url = Utils.urlBuilder(Constants.API_GET_HOME_STATUS,params);
APIResponse apiResponse = ApiWorker.executeGETPublic("forecast/daily?q="+location+"&units=metric"+"&cnt=7");
if(apiResponse.getResponseCode() != Constants.NOT_FOUND) {
response = apiResponse.getResponse(); // Optional Check
WeeklyWeatherResponse mResponse = new WeeklyWeatherResponse();
mResponse.setError(apiResponse.isError());
if(!apiResponse.isError()) {
GsonBuilder builder = new GsonBuilder();
builder.excludeFieldsWithoutExposeAnnotation();
Gson gson = builder.create();
Weathers result = gson.fromJson(apiResponse.getResponse(), Weathers.class);
mResponse.setWeathers(result);
} else {
mResponse.setResponseMessage(apiResponse.getResponseMessage());
}
if (!subscriber.isUnsubscribed()) {
subscriber.onNext(mResponse);
subscriber.onCompleted();
}
} else {
if (!subscriber.isUnsubscribed()) {
NetworkTimeoutException networkTimeoutException =
new NetworkTimeoutException("Please check your internet connection");
subscriber.onError(networkTimeoutException);
}
}
} catch (Exception e) {
if (!subscriber.isUnsubscribed()) {
Utils.printLog(TAG+" API_RESPONSE", response);
e.printStackTrace();
Utils.printLog(TAG+" ERROR", e.getMessage());
subscriber.onError(e);
}
}
}
});
}
}
package imrankst1221.weatherapp.api;
import android.text.TextUtils;
import java.io.IOException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.TimeUnit;
import imrankst1221.weatherapp.Constants;
import imrankst1221.weatherapp.api.response_layer.APIResponse;
import imrankst1221.weatherapp.utility.Utils;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
/**
* Created by imrankst1221@gmail.com
*/
public class ApiWorker {
//OkHttpClient
private static OkHttpClient mClient = null;
private static String TAG = "--REQUEST URL = ";
//MediaType
private static final MediaType MEDIA_TYPE = MediaType.parse(Constants.API_CONTENT_TYPE);
public static OkHttpClient getClient() throws NoSuchAlgorithmException, KeyManagementException {
if (mClient == null) {
OkHttpClient.Builder httpBuilder = new OkHttpClient.Builder();
httpBuilder
.connectTimeout(15, TimeUnit.SECONDS) // Connection Timeout
.readTimeout(20, TimeUnit.SECONDS); // Read Timeout
/*//Stetho
if (BuildConfig.DEBUG) {
httpBuilder.addNetworkInterceptor(new StethoInterceptor());
}*/
mClient = httpBuilder.build();
}
return mClient;
}
public static APIResponse executeGETPublic(String url) {
Utils.printLog(TAG, Constants.API_BASE_PATH + url +"&appid="+Constants.AUTHENTICATION_KEY);
APIResponse apiResponse = new APIResponse();
try {
OkHttpClient client = ApiWorker.getClient();
Request request;
if(TextUtils.isEmpty(url)) {
request = new Request.Builder()
.url(Constants.API_BASE_PATH)
.get()
.build();
} else {
request = new Request.Builder()
.url(Constants.API_BASE_PATH + url +"&appid="+Constants.AUTHENTICATION_KEY)
.get()
.build();
}
Response response = client.newCall(request).execute();
apiResponse.setResponseCode(response.code());
if(response.body().toString().isEmpty()) {
apiResponse.setResponse(null);
} else {
apiResponse.setResponse(response.body().string());
}
apiResponse.setResponseCode(response.code());
return apiResponse;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
apiResponse.setError(true);
String errorMessage = e.getMessage();
if(TextUtils.isEmpty(errorMessage)) {
errorMessage = "NoSuchAlgorithmException";
}
apiResponse.setResponseMessage(errorMessage);
apiResponse.setResponseCode(404);// Default = Not Found
return apiResponse;
} catch (KeyManagementException e) {
e.printStackTrace();
apiResponse.setError(true);
String errorMessage = e.getMessage();
if(TextUtils.isEmpty(errorMessage)) {
errorMessage = "KeyManagementException";
}
apiResponse.setResponseMessage(errorMessage);
apiResponse.setResponseCode(404);// Default = Not Found
return apiResponse;
} catch (IOException e) {
e.printStackTrace();
apiResponse.setError(true);
String errorMessage = e.getMessage();
if(TextUtils.isEmpty(errorMessage)) {
errorMessage = "IOException";
}
apiResponse.setResponseMessage(errorMessage);
apiResponse.setResponseCode(404);// Default = Not Found
return apiResponse;
} catch (Exception e) {
e.printStackTrace();
apiResponse.setError(true);
String errorMessage = e.getMessage();
if(TextUtils.isEmpty(errorMessage)) {
errorMessage = "Unknown Exception";
}
apiResponse.setResponseMessage(errorMessage);
apiResponse.setResponseCode(404);// Default = Not Found
return apiResponse;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="225"
android:endColor="@color/colorPrimary"
android:startColor="@color/colorAccent" />
</shape>
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "imrankst1221.weatherapp"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
///libraries that's used in the project.
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.okhttp3:okhttp:3.3.0'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'io.reactivex:rxjava:1.0.15'
}
{
"citys": [{
"name": "Hurzuf"
}, {
"name": "Novinki"
}, {
"name": "Dhaka"
}, {
"name": "Gorkhā"
}, {
"name": "State of Haryāna"
}, {
"name": "Holubynka"
}, {
"name": "Bāgmatī Zone"
}, {
"name": "Mar’ina Roshcha"
}, {
"name": "Republic of India"
}, {
"name": "Kathmandu"
}, {
"name": "Laspi"
}, {
"name": "Merida"
}, {
"name": "Vinogradovo"
}, {
"name": "Qarah Gawl al ‘Ulyā"
}, {
"name": "Cherkizovo"
}, {
"name": "Alupka"
}, {
"name": "Lichtenrade"
}, {
"name": "Zavety Il’icha"
}, {
"name": "‘Azriqam"
}, {
"name": "Ghūra"
}, {
"name": "Tyuzler"
}, {
"name": "Zaponor’ye"
}, {
"name": "Il’ichëvka"
}, {
"name": "Partyzans’ke"
}, {
"name": "Yurevichi"
}, {
"name": "Gumist’a"
}, {
"name": "Ptitsefabrika"
}, {
"name": "Orekhovo"
}, {
"name": "Birim"
}, {
"name": "Priiskovyy"
}, {
"name": "Dzhaga"
}, {
"name": "Tret’ya Rota"
}, {
"name": "Ruislip"
}, {
"name": "Karow"
}, {
"name": "Gatow"
}, {
"name": "Mkuze"
}, {
"name": "Lhasa"
}, {
"name": "İstanbul"
}, {
"name": "Mao"
}, {
"name": "Russian Federation"
}, {
"name": "De-Friz"
}, {
"name": "Rumbak"
}, {
"name": "Vavibet"
}, {
"name": "Surtagān Chib"
}, {
"name": "Rīgas Rajons"
}, {
"name": "Verkhneye Shchekotikhino"
}, {
"name": "Bucha"
}, {
"name": "Republic of Poland"
}, {
"name": "Kuchary"
}, {
"name": "North America"
}, {
"name": "Brumaire"
}, {
"name": "Ishikawa-ken"
}, {
"name": "Matoba"
}, {
"name": "Pya"
}, {
"name": "Kalanac"
}, {
"name": "Federal Republic of Germany"
}, {
"name": "Land Nordrhein-Westfalen"
}, {
"name": "Mutaykutan"
}, {
"name": "Nalchik"
}, {
"name": "Kolganov"
}, {
"name": "Rybatskiy"
}, {
"name": "Bellara"
}, {
"name": "Bartlett"
}, {
"name": "Rietfontein"
}, {
"name": "Hardap"
}, {
"name": "Botswana"
}, {
"name": "El Destierro"
}, {
"name": "Jones Crossroads"
}, {
"name": "Vernon Parish"
}, {
"name": "Pennick"
}, {
"name": "Black Bear Spring"
}, {
"name": "Bee House"
}, {
"name": "Morden"
}, {
"name": "Nasirotu"
}, {
"name": "Sisali"
}, {
"name": "Puntan"
}, {
"name": "Tsiémé-Mandiélé"
}, {
"name": "Masama"
}, {
"name": "Purukcahu"
}, {
"name": "Néméyong II"
}, {
"name": "Pondok Genteng"
}, {
"name": "Mbongoté"
}, {
"name": "Amiling"
}, {
"name": "Kélkoto"
}, {
"name": "Angetu"
}, {
"name": "Massa"
}, {
"name": "Tumko"
}, {
"name": "Moskva"
}, {
"name": "Japan"
}, {
"name": "Hokkaidō"
}, {
"name": "Sanggrahan"
}, {
"name": "Karangmangle"
}, {
"name": "Sheremetyevskiy"
}, {
"name": "Yershovo"
}, {
"name": "Znamenka"
}, {
"name": "Lisbon"
}, {
"name": "Walbrzych"
}, {
"name": "Naklo nad Notecia"
}, {
"name": "Zhengzhou"
}, {
"name": "Tonyrefail"
}, {
"name": "Bankra"
}, {
"name": "Europe"
}, {
"name": "Moskovskaya Oblast’"
}, {
"name": "Provo"
}, {
"name": "Tejon"
}, {
"name": "Guliston"
}, {
"name": "Ciciler"
}, {
"name": "Bilmece"
}, {
"name": "Provincia de Pontevedra"
}, {
"name": "Carmarthenshire"
}, {
"name": "Helsinki"
}, {
"name": "Gemeente Wervershoof"
}, {
"name": "Forville"
}, {
"name": "Tall ‘Alāwī"
}, {
"name": "La Portanière"
}, {
"name": "East Portlemouth"
}, {
"name": "Whyalla"
}, {
"name": "Terrace End"
}, {
"name": "Hashimoto"
}, {
"name": "Tsukuba-kenkyūgakuen-toshi"
}, {
"name": "Higashi-asahimachi"
}, {
"name": "Hanabatachō"
}, {
"name": "Senzaki"
}, {
"name": "Sakaki"
}, {
"name": "Daisen"
}, {
"name": "Ikaruga"
}, {
"name": "Matsuzaki"
}, {
"name": "Noboribetsu"
}, {
"name": "Grandate"
}, {
"name": "Biella"
}, {
"name": "Soverato"
}, {
"name": "Pinerolo"
}, {
"name": "Dundee City"
}, {
"name": "Nuneaton and Bedworth District"
}, {
"name": "Rhyl"
}, {
"name": "Foulridge"
}, {
"name": "Hermitage"
}, {
"name": "Golcar"
}, {
"name": "Thornbury"
}, {
"name": "Peterhof"
}, {
"name": "Grebnevo"
}, {
"name": "Centro Habana"
}, {
"name": "Carolina"
}, {
"name": "Gustavia"
}, {
"name": "Xianju"
}, {
"name": "Tōkyō-to"
}, {
"name": "Washington"
}, {
"name": "San Dimas"
}, {
"name": "Culfa"
}, {
"name": "Bandar Emām Khomeynī"
}, {
"name": "Shāhrūd"
}, {
"name": "Bo"
}, {
"name": "Daché"
}, {
"name": "Département de l'Ouest"
}, {
"name": "Montescudo"
}, {
"name": "San Pedro"
}, {
"name": "Wels(Stadt)"
}, {
"name": "Palmerston"
}, {
"name": "Telmankend"
}, {
"name": "Neftcala"
}, {
"name": "Pushkino"
}, {
"name": "Visé"
}]
}
package imrankst1221.weatherapp.api.response_layer.current_weather;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Clouds {
@SerializedName("all")
@Expose
private Long all;
public Long getAll() {
return all;
}
public void setAll(Long all) {
this.all = all;
}
}
package imrankst1221.weatherapp.api.response_layer.current_weather;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Coord {
@SerializedName("lon")
@Expose
private Double lon;
@SerializedName("lat")
@Expose
private Double lat;
public Double getLon() {
return lon;
}
public void setLon(Double lon) {
this.lon = lon;
}
public Double getLat() {
return lat;
}
public void setLat(Double lat) {
this.lat = lat;
}
}
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="tabsHeight">48dp</dimen>
<dimen name="fab_margin">8dp</dimen>
<!--Default value for margin Created imrankst1221 -->
<dimen name="margin.1">4dp</dimen>
<dimen name="margin.2">8dp</dimen>
<dimen name="margin.3">12dp</dimen>
<dimen name="margin.4">16dp</dimen>
<dimen name="margin.5">20dp</dimen>
<dimen name="margin.6">24dp</dimen>
<dimen name="margin.7">28dp</dimen>
<dimen name="margin.8">32dp</dimen>
<!--Default size for content-->
<dimen name="content.size.micro">60dp</dimen>
<dimen name="content.size.mini">80dp</dimen>
<dimen name="content.size.small">110dp</dimen>
<dimen name="content.size.regular">120dp</dimen>
<dimen name="content.size.medium">140dp</dimen>
<dimen name="content.size.large">160dp</dimen>
<!--Default width size for content-->
<dimen name="content.size.width.micro">140dp</dimen>
<dimen name="content.size.width.small">160dp</dimen>
<dimen name="content.size.width.regular">180dp</dimen>
<dimen name="content.size.width.medium">220dp</dimen>
<dimen name="content.size.width.large">250dp</dimen>
<dimen name="content.size.width.extra">320dp</dimen>
<!-- Text sizes -->
<dimen name="text.size.nano">7sp</dimen>
<dimen name="text.size.micro">9sp</dimen>
<dimen name="text.size.small">10sp</dimen>
<dimen name="text.size.regular">12sp</dimen>
<dimen name="text.size.medium">14sp</dimen>
<dimen name="text.size.large">16sp</dimen>
<dimen name="text.size.xl">18sp</dimen>
<dimen name="text.size.2xl">20sp</dimen>
<dimen name="text.size.3xl">22sp</dimen>
<dimen name="text.size.4xl">24sp</dimen>
<dimen name="text.size.5xl">26sp</dimen>
<dimen name="text.size.6xl">28sp</dimen>
<dimen name="text.size.7xl">30sp</dimen>
<dimen name="text.size.superXl">40sp</dimen>
<dimen name="text.size.superxXl">100sp</dimen>
<dimen name="text.size.tab">@dimen/text.size.medium</dimen>
<dimen name="text.size.title">@dimen/text.size.3xl</dimen>
<dimen name="text.size.subTitle">@dimen/text.size.xl</dimen>
<dimen name="height.dashboard.item">140dp</dimen>
<dimen name="width.dashboard.item">100dp</dimen>
<dimen name="height.image.item">50dp</dimen>
</resources>
package imrankst1221.weatherapp.ui;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import imrankst1221.weatherapp.Constants;
import imrankst1221.weatherapp.R;
import imrankst1221.weatherapp.api.ApiService;
import imrankst1221.weatherapp.api.response_layer.WeatherResponse;
import imrankst1221.weatherapp.api.response_layer.WeeklyWeatherResponse;
import imrankst1221.weatherapp.api.response_layer.current_weather.Weather;
import imrankst1221.weatherapp.api.response_layer.weekly_weather.Weathers;
import imrankst1221.weatherapp.common.CustomProgressDialog;
import imrankst1221.weatherapp.common.MyCustomDialog;
import imrankst1221.weatherapp.common.Read;
import imrankst1221.weatherapp.common.citys.City;
import imrankst1221.weatherapp.setting.NetworkTimeoutException;
import imrankst1221.weatherapp.utility.UtilMethods;
import imrankst1221.weatherapp.utility.Utils;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
public class HomeActivity extends AppCompatActivity {
private Context mContext;
private String TAG = "---HomeActivity";
private String demoLocation = "Dhaka";
private ProgressDialog progress;
private MyCustomDialog myCustomDialog;
private WeatherAdapter weatherAdapter;
private ArrayAdapter searchAdapter;
private ArrayList<City> cities;
@BindView(R.id.txt_location)
TextView txtLocation;
@BindView(R.id.txt_main)
TextView txtMain;
@BindView(R.id.txt_temp_min)
TextView txtTempMin;
@BindView(R.id.txt_temp_max)
TextView txtTempMax;
@BindView(R.id.txt_temp)
TextView txtTemp;
@BindView(R.id.txt_date)
TextView txtDate;
@BindView(R.id.txt_time)
TextView txtTime;
@BindView(R.id.txt_detail)
TextView txtDetail;
@BindView(R.id.txt_search)
AutoCompleteTextView txtSearch;
@BindView(R.id.img_weather)
ImageView imgWeather;
@BindView(R.id.list_weather)
RecyclerView listWeather;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
mContext = this;
ButterKnife.bind(this);
progress = new CustomProgressDialog(mContext);
myCustomDialog = new MyCustomDialog();
//initially get demo location data
getWeatherAPI(demoLocation);
//initial search values
setSearch();
}
private void setSearch() {
//get offline .json city name
Read mRead = new Read(mContext);
cities = mRead.loadCitys().getCityses();
Log.d(TAG, ""+cities.size());
final List<String> items = new ArrayList();
for(City item : cities){
items.add(item.getName());
}
searchAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, items);
txtSearch.setAdapter(searchAdapter);
//search suggestion adapter item on click action
txtSearch.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
int index;
txtSearch.setText("");
UtilMethods.hideSoftKeyboard(HomeActivity.this);
index = cities.indexOf(parent.getItemAtPosition(position));
Log.d(TAG, parent.getItemAtPosition(position)+" "+index);
getWeatherAPI(parent.getItemAtPosition(position).toString());
}
});
//if not found in suggestion then keyboard's done button action
txtSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if( actionId== EditorInfo.IME_ACTION_DONE) {
getWeatherAPI(txtSearch.getText().toString());
txtSearch.setText("");
UtilMethods.hideSoftKeyboard(HomeActivity.this);
}
return true;
}
});
}
public void setCurrentWeather(Weather mWeather) {
try{
txtLocation.setText(mWeather.getName());
txtTemp.setText(mWeather.getMain().getTemp().toString());
txtTempMax.setText(mWeather.getMain().getTempMax().toString());
txtTempMin.setText(mWeather.getMain().getTempMin().toString());
txtTime.setText(new SimpleDateFormat("HH:mm:ss").format(new Date(mWeather.getDt() * 1000L)));
txtDate.setText(new SimpleDateFormat("MM/dd/yyyy").format(new Date(mWeather.getDt() * 1000L)));
txtMain.setText(mWeather.getWeather().get(0).getMain());
txtDetail.setText(mWeather.getWeather().get(0).getDescription());
Picasso.with(mContext).load(Constants.API_IMAGE_PATH + mWeather.getWeather().get(0).getIcon()+".png").
placeholder(R.drawable.ic_placeholder).error(R.drawable.ic_placeholder).into(imgWeather);
}catch (Exception ex){
Log.e(TAG, "--"+ex);
}
}
private void setWeekltWeather(Weathers mWeathers) {
weatherAdapter = new WeatherAdapter(mContext, mWeathers.getList());
listWeather.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
listWeather.setAdapter(weatherAdapter);
}
private void getWeatherAPI(String location) {
if(Utils.internetCheck(mContext)) {
showProgressDialog();
ApiService.getWeatherAPI(location)
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<WeatherResponse>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
dismisProgressDialog();
if(e instanceof NetworkTimeoutException) {
NetworkTimeoutException networkTimeoutException = (NetworkTimeoutException) e;
myCustomDialog.myDialog(mContext, "Network Error", networkTimeoutException.getMessage());
} else {
myCustomDialog.myDialog(mContext, "Error", "Sorry! Please enter current City name.");
}
}
@Override
public void onNext(WeatherResponse mResponse) {
if(mResponse.isError()) {
dismisProgressDialog();
myCustomDialog.myDialog(mContext, "Error", mResponse.getResponseMessage());
} else {
Weather mWeather = mResponse.getWeather();
if(mWeather.getName()!=null){
dismisProgressDialog();
setCurrentWeather(mWeather);
getWeeklyWeatherAPI(demoLocation);
}else {
dismisProgressDialog();
myCustomDialog.myDialog(mContext, "Error-II", "Sorry! Please try later.");
}
}
}
});
}else {
myCustomDialog.myDialog(mContext, "Error", getString(R.string.massage_nointernet));
}
}
private void getWeeklyWeatherAPI(String location) {
if(Utils.internetCheck(mContext)) {
ApiService.getWeeklyWeatherAPI(location)
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<WeeklyWeatherResponse>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
dismisProgressDialog();
if(e instanceof NetworkTimeoutException) {
NetworkTimeoutException networkTimeoutException = (NetworkTimeoutException) e;
myCustomDialog.myDialog(mContext, "Network Error", networkTimeoutException.getMessage());
} else {
myCustomDialog.myDialog(mContext, "Error-", "Sorry! Please try later.");
}
}
@Override
public void onNext(WeeklyWeatherResponse mResponse) {
dismisProgressDialog();
if(mResponse.isError()) {
myCustomDialog.myDialog(mContext, "Error--", mResponse.getResponseMessage());
} else {
Weathers mWeathers = mResponse.getWeathers();
if(mWeathers.getCity()!=null){
setWeekltWeather(mWeathers);
}else {
myCustomDialog.myDialog(mContext, "Error-II", "Sorry! Please try later.");
}
}
}
});
}else {
myCustomDialog.myDialog(mContext, "Error", getString(R.string.massage_nointernet));
}
}
//method for dialog show and dismis
private void showProgressDialog() {
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = new Runnable() {
@Override
public void run() {
progress.show();
}
};
mainHandler.post(myRunnable);
}
private void dismisProgressDialog() {
progress.dismiss();
}
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/card_view_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardBackgroundColor="@color/colorPrimary"
card_view:cardCornerRadius="@dimen/margin.3"
card_view:contentPaddingLeft="@dimen/margin.3"
card_view:contentPaddingRight="@dimen/margin.3"
card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="true"
tools:context=".ui.HomeActivity">
<RelativeLayout
android:layout_width="@dimen/width.dashboard.item"
android:layout_height="@dimen/height.dashboard.item"
android:clickable="false"
android:layout_gravity="center">
<TextView
android:id="@+id/txt_day"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/margin.1"
android:textSize="@dimen/text.size.xl"
android:textColor="@color/text.white"
android:text="Sunday"/>
<ImageView
android:id="@+id/img_weather"
android:layout_width="@dimen/height.image.item"
android:layout_height="@dimen/height.image.item"
android:adjustViewBounds="true"
android:layout_below="@+id/txt_day"
android:layout_centerHorizontal="true"
android:src="@drawable/demo_weather" />
<TextView
android:id="@+id/txt_weather"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@+id/img_weather"
android:textSize="@dimen/text.size.xl"
android:textColor="@color/text.white"
android:text="Drizzle"/>
<LinearLayout
android:id="@+id/layout_level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_below="@id/txt_weather"
android:layout_marginBottom="@dimen/margin.3"
android:orientation="horizontal">
<TextView
android:id="@+id/txt_temp_min"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="@dimen/text.size.xl"
android:textColor="@color/text.white"
android:text="-09"/>
<TextView
android:id="@+id/txt_divider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="@dimen/text.size.xl"
android:textColor="@color/text.white"
android:text=" / "/>
<TextView
android:id="@+id/txt_temp_max"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="@dimen/text.size.xl"
android:textColor="@color/text.white"
tools:text="09"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="@dimen/text.size.xl"
android:textColor="@color/text.white"
android:text=" \u00B0 C"/>
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
package imrankst1221.weatherapp.api.response_layer.current_weather;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Main {
@SerializedName("temp")
@Expose
private Long temp;
@SerializedName("pressure")
@Expose
private Long pressure;
@SerializedName("humidity")
@Expose
private Long humidity;
@SerializedName("temp_min")
@Expose
private Long tempMin;
@SerializedName("temp_max")
@Expose
private Long tempMax;
public Long getTemp() {
return temp;
}
public void setTemp(Long temp) {
this.temp = temp;
}
public Long getPressure() {
return pressure;
}
public void setPressure(Long pressure) {
this.pressure = pressure;
}
public Long getHumidity() {
return humidity;
}
public void setHumidity(Long humidity) {
this.humidity = humidity;
}
public Long getTempMin() {
return tempMin;
}
public void setTempMin(Long tempMin) {
this.tempMin = tempMin;
}
public Long getTempMax() {
return tempMax;
}
public void setTempMax(Long tempMax) {
this.tempMax = tempMax;
}
}
package imrankst1221.weatherapp.setting;
/**
* Created by imrankst1221@gmail.com
*/
public class NetworkTimeoutException extends Exception {
@Override
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
String message;
public NetworkTimeoutException(String message) {
this.message = message;
}
}
package imrankst1221.weatherapp.common;
import android.content.Context;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.IOException;
import java.io.InputStream;
import imrankst1221.weatherapp.common.citys.Citys;
public class Read {
Context mContext;
public Read(Context mContext){
this.mContext = mContext;
}
public Citys loadCitys() {
Citys items = new Citys();
String json = null;
try {
InputStream is = mContext.getAssets().open("citys.json");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
json = new String(buffer, "UTF-8");
} catch (IOException ex) {
ex.printStackTrace();
return null;
}
try {
GsonBuilder builder = new GsonBuilder();
builder.excludeFieldsWithoutExposeAnnotation();
Gson gson = builder.create();
items = gson.fromJson(json, Citys.class);
} catch (Exception e) {
e.printStackTrace();
}
return items;
}
}
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/accent</item>
</style>
<!--theme for progress bar-->
<style name="CircularProgress" parent="Theme.AppCompat.Light">
<item name="colorAccent">@color/white</item>
</style>
</resources>
package imrankst1221.weatherapp.api.response_layer.current_weather;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Sys {
@SerializedName("type")
@Expose
private Long type;
@SerializedName("id")
@Expose
private Long id;
@SerializedName("message")
@Expose
private Double message;
@SerializedName("country")
@Expose
private String country;
@SerializedName("sunrise")
@Expose
private Long sunrise;
@SerializedName("sunset")
@Expose
private Long sunset;
public Long getType() {
return type;
}
public void setType(Long type) {
this.type = type;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Double getMessage() {
return message;
}
public void setMessage(Double message) {
this.message = message;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public Long getSunrise() {
return sunrise;
}
public void setSunrise(Long sunrise) {
this.sunrise = sunrise;
}
public Long getSunset() {
return sunset;
}
public void setSunset(Long sunset) {
this.sunset = sunset;
}
}
package imrankst1221.weatherapp.api.response_layer.current_weather;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Weather {
@SerializedName("coord")
@Expose
private Coord coord;
@SerializedName("weather")
@Expose
private List<WeatherItem> weather = null;
@SerializedName("base")
@Expose
private String base;
@SerializedName("main")
@Expose
private Main main;
@SerializedName("visibility")
@Expose
private Long visibility;
@SerializedName("wind")
@Expose
private Wind wind;
@SerializedName("clouds")
@Expose
private Clouds clouds;
@SerializedName("dt")
@Expose
private Long dt;
@SerializedName("sys")
@Expose
private Sys sys;
@SerializedName("id")
@Expose
private Long id;
@SerializedName("name")
@Expose
private String name;
@SerializedName("cod")
@Expose
private Long cod;
public Coord getCoord() {
return coord;
}
public void setCoord(Coord coord) {
this.coord = coord;
}
public List<WeatherItem> getWeather() {
return weather;
}
public void setWeather(List<WeatherItem> weather) {
this.weather = weather;
}
public String getBase() {
return base;
}
public void setBase(String base) {
this.base = base;
}
public Main getMain() {
return main;
}
public void setMain(Main main) {
this.main = main;
}
public Long getVisibility() {
return visibility;
}
public void setVisibility(Long visibility) {
this.visibility = visibility;
}
public Wind getWind() {
return wind;
}
public void setWind(Wind wind) {
this.wind = wind;
}
public Clouds getClouds() {
return clouds;
}
public void setClouds(Clouds clouds) {
this.clouds = clouds;
}
public Long getDt() {
return dt;
}
public void setDt(Long dt) {
this.dt = dt;
}
public Sys getSys() {
return sys;
}
public void setSys(Sys sys) {
this.sys = sys;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getCod() {
return cod;
}
public void setCod(Long cod) {
this.cod = cod;
}
}
package imrankst1221.weatherapp.ui;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import imrankst1221.weatherapp.Constants;
import imrankst1221.weatherapp.R;
import imrankst1221.weatherapp.api.response_layer.weekly_weather.WeatherList;
/**
* Created by Imran-PC
*/
public class WeatherAdapter extends RecyclerView.Adapter<WeatherAdapter.TeamViewHolder> {
private String TAG = "---WeatherAdapter";
private Context mContext;
private ArrayList<WeatherList> itemList;
public WeatherAdapter(Context context, ArrayList<WeatherList> itemList) {
mContext = context;
this.itemList = itemList;
}
@Override
public TeamViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_weather, null);
TeamViewHolder vh = new TeamViewHolder(v);
return vh;
}
@Override
public void onBindViewHolder(TeamViewHolder holder, int position) {
try{
holder.txtTempMax.setText(itemList.get(position).getTemp().getMax().toString());
holder.txtTempMin.setText(itemList.get(position).getTemp().getMin().toString());
holder.txtDay.setText(new SimpleDateFormat("EEEE").format(
new Date(itemList.get(position).getDt() * 1000L)));
holder.txtWeather.setText(itemList.get(position).getWeather().get(0).getMain().toString());
Picasso.with(mContext).load(Constants.API_IMAGE_PATH + itemList.get(position).getWeather().get(0).getIcon()+".png").
placeholder(R.drawable.ic_placeholder).error(R.drawable.ic_placeholder).into(holder.itemImgView);
}catch (Exception ex){
Log.e(TAG, ex.getMessage());
}
}
@Override
public int getItemCount() {
return itemList.size();
}
class TeamViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.img_weather)
ImageView itemImgView;
@BindView(R.id.txt_temp_min)
TextView txtTempMin;
@BindView(R.id.txt_temp_max)
TextView txtTempMax;
@BindView(R.id.txt_day)
TextView txtDay;
@BindView(R.id.txt_weather)
TextView txtWeather;
public TeamViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this,itemView);
}
}
}
package imrankst1221.weatherapp.api.response_layer.current_weather;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class WeatherItem {
@SerializedName("id")
@Expose
private Long id;
@SerializedName("main")
@Expose
private String main;
@SerializedName("description")
@Expose
private String description;
@SerializedName("icon")
@Expose
private String icon;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getMain() {
return main;
}
public void setMain(String main) {
this.main = main;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
}
package imrankst1221.weatherapp.api.response_layer;
import imrankst1221.weatherapp.api.response_layer.current_weather.Weather;
/**
* Created by imrankst1221@gmail.com
*/
public class WeatherResponse extends APIResponse{
Weather weather;
public Weather getWeather() {
return weather;
}
public void setWeather(Weather weather) {
this.weather = weather;
}
}
package imrankst1221.weatherapp.api.response_layer;
import imrankst1221.weatherapp.api.response_layer.weekly_weather.Weathers;
/**
* Created by imrankst1221@gmail.com
*/
public class WeeklyWeatherResponse extends APIResponse{
Weathers weathers;
public Weathers getWeathers() {
return weathers;
}
public void setWeathers(Weathers weathers) {
this.weathers = weathers;
}
}
package imrankst1221.weatherapp.api.response_layer.current_weather;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Wind {
@SerializedName("speed")
@Expose
private Double speed;
@SerializedName("deg")
@Expose
private Long deg;
public Double getSpeed() {
return speed;
}
public void setSpeed(Double speed) {
this.speed = speed;
}
public Long getDeg() {
return deg;
}
public void setDeg(Long deg) {
this.deg = deg;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment