Created
October 16, 2017 16:56
-
-
Save nutchy/63289212b60c740c7466288bef134e92 to your computer and use it in GitHub Desktop.
[MyLazyInstagram] - MainActivity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
public OkHttpClient client; | |
public Retrofit retrofit; | |
public LazyInstagramApi lazyInstagramApi; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.lazyinstagram_main); | |
getConnection(); | |
getContentByName("cartoon"); | |
} | |
// Create Conenction | |
public void getConnection(){ | |
// .. | |
} | |
private void getContentByName(String userName){ | |
// .. | |
@Override | |
public void onResponse(Call<UserProfile> call, Response<UserProfile> response) { | |
if (response.isSuccessful()){ | |
UserProfile userProfile = response.body(); | |
display(userProfile); | |
} | |
} | |
//.. | |
} | |
private void display(UserProfile userProfile){ | |
// Each Layout has number of type recycler | |
List<Layout> layouts = new ArrayList<>(); | |
layouts.add(new Layout(Layout.TYPE_USER_DETAIL)); | |
layouts.add(new Layout(Layout.TYPE_POST_ITEM)); | |
LazyInstagramAdapter lazyInstagramAdapter = new LazyInstagramAdapter(this, layouts); | |
lazyInstagramAdapter.setUserProfile(userProfile); | |
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.main_recycler); | |
recyclerView.setLayoutManager(new LinearLayoutManager(this)); | |
recyclerView.setAdapter(lazyInstagramAdapter); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment