60 lines
1.8 KiB
Java
60 lines
1.8 KiB
Java
package at.fhj.swd.dailyhelper.ui.fragemnt;
|
|
|
|
import android.app.ProgressDialog;
|
|
import android.content.Intent;
|
|
import android.content.SharedPreferences;
|
|
import android.location.Location;
|
|
import android.os.Bundle;
|
|
import android.preference.PreferenceManager;
|
|
import android.support.annotation.NonNull;
|
|
import android.support.annotation.Nullable;
|
|
import android.support.v4.app.Fragment;
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
import android.support.v7.widget.RecyclerView;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
|
|
import org.json.JSONException;
|
|
|
|
import java.util.List;
|
|
|
|
import at.fhj.swd.dailyhelper.R;
|
|
import at.fhj.swd.dailyhelper.adapter.WeatherListAdapter;
|
|
import at.fhj.swd.dailyhelper.db.room.WeatherDB;
|
|
import at.fhj.swd.dailyhelper.model.Weather;
|
|
import at.fhj.swd.dailyhelper.network.HttpsGetTask;
|
|
import at.fhj.swd.dailyhelper.network.RequestCallback;
|
|
|
|
public class WeatherFragment extends Fragment implements WeatherListAdapter.ItemClickListener {
|
|
|
|
private RecyclerView weatherList;
|
|
|
|
@Nullable
|
|
@Override
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
View view = inflater.inflate(R.layout.fragment_weather, container, false);
|
|
|
|
weatherList = view.findViewById(R.id.rvWeatherList);
|
|
|
|
weatherList.setLayoutManager(new LinearLayoutManager(getContext()));
|
|
|
|
return view;
|
|
}
|
|
|
|
private void fetchLoctions() {
|
|
WeatherListAdapter adapter = new WeatherListAdapter(WeatherDB.getDatabase(getContext()).weatherDAO().getAll(), this);
|
|
weatherList.setAdapter(adapter);
|
|
}
|
|
|
|
|
|
public void refresh(){
|
|
fetchLoctions();
|
|
}
|
|
|
|
@Override
|
|
public void onItemClicked(Weather weather, int position) {
|
|
|
|
}
|
|
}
|