Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tgs.app.absensi.Sekretaris;
- import android.support.v4.widget.SwipeRefreshLayout;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.support.v7.widget.LinearLayoutManager;
- import android.support.v7.widget.RecyclerView;
- import java.util.List;
- import retrofit2.Call;
- import retrofit2.Callback;
- import retrofit2.Response;
- import tgs.app.absensi.R;
- import tgs.app.absensi.SekretarisAdapter;
- import tgs.app.absensi.model.Sekretaris;
- import tgs.app.absensi.retrofit.Api;
- import tgs.app.absensi.retrofit.ApiInterface;
- public class DataSekretarisActivity extends AppCompatActivity {
- SwipeRefreshLayout swipe_refresh;
- RecyclerView recyclerView;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_data_sekretaris);
- swipe_refresh = findViewById(R.id.swipe_refresh);
- recyclerView = findViewById(R.id.rc_data);
- recyclerView.setLayoutManager(new LinearLayoutManager(this));
- recyclerView.setHasFixedSize(true);
- DataSekretaris();
- swipe_refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
- @Override
- public void onRefresh() {
- swipe_refresh.setRefreshing(true);
- DataSekretaris();
- }
- });
- getSupportActionBar().setTitle("Data Absen Siswa");
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- }
- private void DataSekretaris(){
- ApiInterface apiInterface = Api.getUrl().create(ApiInterface.class);
- Call<Sekretaris> call = apiInterface.getSekretarisCall();
- call.enqueue(new Callback<Sekretaris>() {
- @Override
- public void onResponse(Call<Sekretaris> call, Response<Sekretaris> response) {
- swipe_refresh.setRefreshing(false);
- List<Sekretaris.Siswa> detailSiswa = response.body().getReadSiswa();
- List<Sekretaris.Kelas> detailKelas = response.body().getReadKelas();
- recyclerView.setAdapter(new SekretarisAdapter(detailSiswa, detailKelas));
- }
- @Override
- public void onFailure(Call<Sekretaris> call, Throwable t) {
- }
- });
- }
- @Override
- public boolean onSupportNavigateUp() {
- finish();
- return super.onSupportNavigateUp();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement