-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainActivity.java
More file actions
61 lines (45 loc) · 1.59 KB
/
MainActivity.java
File metadata and controls
61 lines (45 loc) · 1.59 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.example.post;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle;
import com.example.post.contract.PostContract;
import com.example.post.model.Post;
import com.example.post.presenter.PostPresenter;
import com.example.post.view.PostAdapter;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity implements PostContract.View {
PostPresenter postPresenter;
RecyclerView recyclerViewPost;
List<Post> postList;
PostAdapter postAdapter;
LinearLayoutManager linearLayoutManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerViewPost = findViewById(R.id.rvPost);
postList = new ArrayList<>();
linearLayoutManager = new LinearLayoutManager(this);
recyclerViewPost.setLayoutManager(linearLayoutManager);
recyclerViewPost.setHasFixedSize(true);
postPresenter = new PostPresenter(this);
postPresenter.requestDataFromServer();
}
@Override
public void showProgress() {
}
@Override
public void hideProgress() {
}
@Override
public void setDataToRecyclerview(List<Post> postList) {
postList.addAll(postList);
postAdapter = new PostAdapter(this, postList);
recyclerViewPost.setAdapter(postAdapter);
}
@Override
public void onResponseFailure(Throwable t) {
}
}