daily pastebin goal
94%
SHARE
TWEET

Untitled

a guest Nov 17th, 2017 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.example.artistle.testjob.Activity;
  2.  
  3. import android.os.Bundle;
  4. import android.support.annotation.Nullable;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.support.v7.widget.LinearLayoutManager;
  7. import android.support.v7.widget.RecyclerView;
  8. import android.widget.Toast;
  9.  
  10. import com.example.artistle.testjob.Adapter.InfoAdapter;
  11. import com.example.artistle.testjob.App;
  12. import com.example.artistle.testjob.Model.InfoModel;
  13. import com.example.artistle.testjob.R;
  14.  
  15. import java.io.IOException;
  16. import java.util.ArrayList;
  17. import java.util.List;
  18.  
  19. import retrofit2.Call;
  20. import retrofit2.Callback;
  21. import retrofit2.Response;
  22.  
  23. /**
  24.  * Created by artistle on 15.11.17.
  25.  */
  26.  
  27. public class UsersInfoActivity extends AppCompatActivity {
  28.     private List<InfoModel> info;
  29.     private RecyclerView rv;
  30.  
  31.     @Override
  32.     protected void onCreate(@Nullable Bundle savedInstanceState) {
  33.         super.onCreate(savedInstanceState);
  34.         setContentView(R.layout.users_info_activity);
  35.  
  36.         info = new ArrayList<InfoModel>();
  37.  
  38.         rv = (RecyclerView) findViewById(R.id.info_recycler);
  39.         LinearLayoutManager layoutManager = new LinearLayoutManager(this);
  40.         rv.setLayoutManager(layoutManager);
  41.  
  42.         InfoAdapter adapter = new InfoAdapter(info);
  43.         rv.setAdapter(adapter);
  44.  
  45.         App.getInfoUsers().getInfo().enqueue(new Callback<List<InfoModel>>() {
  46.         @Override
  47.         public void onResponse(Call<List<InfoModel>> call, Response<List<InfoModel>> response) {
  48.             info.addAll(response.body());
  49.         }
  50.  
  51.         @Override
  52.         public void onFailure(Call<List<InfoModel>> call, Throwable t) {
  53.             Toast.makeText(UsersInfoActivity.this, "данные не загружены", Toast.LENGTH_SHORT).show();
  54.         }
  55.     });
  56.  
  57.     }
  58. }
RAW Paste Data
Top