Skip to content

Commit

Permalink
new-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunadhikary committed Sep 30, 2020
1 parent 39a1e49 commit 43550ff
Show file tree
Hide file tree
Showing 26 changed files with 890 additions and 138 deletions.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
134 changes: 134 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
testImplementation 'junit:junit:4.13'
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.arjun.weather">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application
android:allowBackup="true"
Expand Down
50 changes: 31 additions & 19 deletions app/src/main/java/com/arjun/weather/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.arjun.weather.Model.FiveDaysWeather;
import com.arjun.weather.Model.ItemHourly;
import com.arjun.weather.RecyclerView.Adapter;
import com.arjun.weather.RecyclerView.MainAdapter;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -28,23 +29,27 @@

public class MainActivity extends AppCompatActivity {
private EditText userSearch;
private List<ItemHourly> weatherHourly = new ArrayList<>();
private FiveDaysWeather fiveDaysWeather;
private Weather weather;
private String baseUrl = "https://api.openweathermap.org/data/2.5/";


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
userSearch = findViewById(R.id.search);
Button send = findViewById(R.id.send);
send.setOnClickListener(sendListener);
setContentView(R.layout.main);
// userSearch = findViewById(R.id.search);
// Button send = findViewById(R.id.send);
// send.setOnClickListener(sendListener);
getSupportActionBar().setElevation(0);
setRecyclerView();


}

private void setRecyclerView() {
RecyclerView recyclerView = findViewById(R.id.allWeather);
Adapter adapter = new Adapter(weatherHourly, this);
RecyclerView recyclerView = findViewById(R.id.rv);
MainAdapter adapter = new MainAdapter(fiveDaysWeather, this);
LinearLayoutManager llm = new LinearLayoutManager(this);
llm.setOrientation(LinearLayoutManager.HORIZONTAL);
recyclerView.setLayoutManager(llm);
Expand All @@ -60,20 +65,27 @@ public void onClick(View view) {
Toast.makeText(MainActivity.this, "Enter valid Location to Search", Toast.LENGTH_SHORT).show();
return;
}
String baseUrl = "https://api.openweathermap.org/data/2.5/";
Log.d("Base_Url", "onClick: " + baseUrl);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(GsonConverterFactory.create())
.build();
weather = retrofit.create(Weather.class);
String appid = "Your_API_Key";
getAllData(userData, appid);
buildRetroift(baseUrl,userData);

}
};

private void getAllData(String search,String apiKey) {


private void buildRetroift(String baseUrl,String userData) {
Log.d("Base_Url", "onClick: " + baseUrl);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(GsonConverterFactory.create())
.build();
weather = retrofit.create(Weather.class);
String appid = "API_KEY";
getAllData(userData, appid);

}
};


private void getAllData(String search,String apiKey) {
Call<FiveDaysWeather> weatherCall = weather.getAllWeatherData(search, apiKey,"metric");
weatherCall.enqueue(new Callback<FiveDaysWeather>() {
@Override
Expand All @@ -84,7 +96,7 @@ public void onResponse(Call<FiveDaysWeather> call, Response<FiveDaysWeather> res
}
Log.e("TAG", "onResponse:Data received " );
assert response.body() != null;
weatherHourly = response.body().getList();
fiveDaysWeather = response.body();
Log.e("TAG", "onResponse:Total Data "+response.body().getList().size());
setRecyclerView();
}
Expand Down
Loading

0 comments on commit 43550ff

Please sign in to comment.