-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMainActivity.java
38 lines (27 loc) · 1.08 KB
/
MainActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.example.abhishek.starwars;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.swapi.models.Starship;
import com.swapi.sw.StarWarsApi;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private List<Starship> starsList = new ArrayList<>();
RecyclerView recycler;
RecyclerAdapter adapter;
Starship[] mStars;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
StarWarsApi.init();
mStars = new Starship[starsList.size()];
adapter = new RecyclerAdapter(mStars);
recycler =(RecyclerView) findViewById(R.id.recyclerView);
recycler.setAdapter(adapter);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(this);
recycler.setLayoutManager(mLayoutManager);
}
}