Skip to content

Commit 665b637

Browse files
committed
weather_app_ui_issue_#22
1 parent 73015a4 commit 665b637

File tree

85 files changed

+2388
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+2388
-0
lines changed

weather_app/.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

weather_app/.idea/.gitignore

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

weather_app/.idea/.name

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

weather_app/.idea/compiler.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

weather_app/.idea/gradle.xml

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

weather_app/.idea/misc.xml

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

weather_app/.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

weather_app/app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

weather_app/app/build.gradle

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
plugins {
2+
id 'com.android.application'
3+
}
4+
5+
android {
6+
compileSdk 31
7+
8+
defaultConfig {
9+
applicationId "com.example.weather_app_ui"
10+
minSdk 21
11+
targetSdk 31
12+
versionCode 1
13+
versionName "1.0"
14+
15+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16+
}
17+
18+
buildTypes {
19+
release {
20+
minifyEnabled false
21+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22+
}
23+
}
24+
compileOptions {
25+
sourceCompatibility JavaVersion.VERSION_1_8
26+
targetCompatibility JavaVersion.VERSION_1_8
27+
}
28+
}
29+
30+
dependencies {
31+
32+
implementation 'androidx.appcompat:appcompat:1.4.0'
33+
implementation 'com.google.android.material:material:1.4.0'
34+
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
35+
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
36+
testImplementation 'junit:junit:4.+'
37+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
38+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
39+
}

weather_app/app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.example.weather_app_ui;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24+
assertEquals("com.example.weather_app_ui", appContext.getPackageName());
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.example.weather_app_ui">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/Theme.Weather_app_ui">
12+
<activity
13+
android:name=".MainActivity"
14+
android:exported="true">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN" />
17+
18+
<category android:name="android.intent.category.LAUNCHER" />
19+
</intent-filter>
20+
</activity>
21+
<meta-data
22+
android:name="preloaded_fonts"
23+
android:resource="@array/preloaded_fonts" />
24+
</application>
25+
26+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.example.weather_app_ui;
2+
3+
import android.content.Context;
4+
import android.view.LayoutInflater;
5+
import android.view.View;
6+
import android.view.ViewGroup;
7+
import android.widget.ImageView;
8+
import android.widget.TextView;
9+
10+
import androidx.annotation.NonNull;
11+
import androidx.recyclerview.widget.RecyclerView;
12+
13+
import java.util.List;
14+
15+
public class CityAdapter extends RecyclerView.Adapter<CityAdapter.ViewHolder>{
16+
17+
private final List<CityModel> mlist;
18+
private final LayoutInflater inflater;
19+
20+
public CityAdapter(Context context, List<CityModel> data){
21+
this.mlist = data;
22+
this.inflater = LayoutInflater.from(context);
23+
}
24+
25+
@NonNull
26+
@Override
27+
public CityAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
28+
View view = inflater.inflate(R.layout.cities,parent,false);
29+
return new CityAdapter.ViewHolder(view);
30+
}
31+
32+
@Override
33+
public void onBindViewHolder(@NonNull CityAdapter.ViewHolder holder, int position) {
34+
CityModel cm = mlist.get(position);
35+
36+
holder.temp.setText(cm.getTemp());
37+
holder.contry.setText(cm.getContry());
38+
holder.city.setText(cm.getCity());
39+
holder.rain.setText(cm.getRain());
40+
holder.wind.setText(cm.getWind());
41+
holder.icon.setImageResource(cm.getIcon());
42+
43+
}
44+
45+
@Override
46+
public int getItemCount() {
47+
return mlist.size();
48+
}
49+
50+
public static class ViewHolder extends RecyclerView.ViewHolder {
51+
52+
TextView temp,city,contry,wind,rain;
53+
ImageView icon;
54+
55+
public ViewHolder(@NonNull View itemView) {
56+
super(itemView);
57+
58+
temp = itemView.findViewById(R.id.temp_cities);
59+
city = itemView.findViewById(R.id.cityname);
60+
contry = itemView.findViewById(R.id.contry);
61+
wind = itemView.findViewById(R.id.speed);
62+
rain = itemView.findViewById(R.id.rain);
63+
icon = itemView.findViewById(R.id.outlinedIcon);
64+
}
65+
}
66+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package com.example.weather_app_ui;
2+
3+
public class CityModel {
4+
String temp,city,contry,wind,rain;
5+
int icon;
6+
7+
public String getTemp() {
8+
return temp;
9+
}
10+
11+
public int getIcon() {
12+
return icon;
13+
}
14+
15+
public String getCity() {
16+
return city;
17+
}
18+
19+
public String getContry() {
20+
return contry;
21+
}
22+
23+
public String getRain() {
24+
return rain;
25+
}
26+
27+
public String getWind() {
28+
return wind;
29+
}
30+
31+
public CityModel(CityBuilder cm){
32+
temp = cm.temp;
33+
city = cm.city;
34+
contry = cm.contry;
35+
wind = cm.wind;
36+
rain = cm.rain;
37+
icon = cm.icon;
38+
}
39+
40+
public static class CityBuilder {
41+
String temp,city,contry,wind,rain;
42+
int icon;
43+
44+
public CityBuilder setTemp(String temp) {
45+
this.temp = temp;
46+
return this;
47+
}
48+
49+
public CityBuilder setCity(String city) {
50+
this.city = city;
51+
return this;
52+
}
53+
54+
public CityBuilder setContry(String contry) {
55+
this.contry = contry;
56+
return this;
57+
}
58+
59+
public CityBuilder setWind(String wind) {
60+
this.wind = wind;
61+
return this;
62+
}
63+
64+
public CityBuilder setIcon(int icon) {
65+
this.icon = icon;
66+
return this;
67+
}
68+
69+
public CityBuilder setRain(String rain) {
70+
this.rain = rain;
71+
return this;
72+
}
73+
74+
public CityModel build(){
75+
return new CityModel(this);
76+
}
77+
78+
}
79+
}

0 commit comments

Comments
 (0)