Skip to content

Commit

Permalink
Fix list not loading correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
joydeepsaha05 committed May 9, 2017
1 parent 17776a4 commit e1921d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ protected void onCreate(Bundle savedInstanceState) {
ButterKnife.bind(this);

setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mAdapter = new LoanDetailAdapter(mArrayList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ public void execute(Realm realm) {

mRecyclerView.addOnItemTouchListener(new RecyclerItemClickListener(this, this));
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mAdapter = new MainActivityAdapter(mRealmLoanList);
mRecyclerView.setAdapter(mAdapter);

loadData();
}
Expand Down Expand Up @@ -107,9 +105,6 @@ private void loadData() {
.findFirst();

if (realmUser != null) {
if (realmUser.loanRealmList == null) {
realmUser.loanRealmList = new RealmList<>();
}
mRealmLoanList = realmUser.loanRealmList;
} else {
mRealmLoanList = new RealmList<>();
Expand All @@ -118,10 +113,14 @@ private void loadData() {
if (mRealmLoanList.size() == 0) {
mDefaultTV.setVisibility(View.VISIBLE);
} else {
if (mAdapter == null) {
mAdapter = new MainActivityAdapter(mRealmLoanList);
mRecyclerView.setAdapter(mAdapter);
} else {
mAdapter.notifyDataSetChanged();
}
mDefaultTV.setVisibility(View.GONE);
}

mAdapter.notifyDataSetChanged();
}

private void addLoan() {
Expand Down Expand Up @@ -173,7 +172,6 @@ public void execute(Realm realm) {
}
});
bottomSheetDialog.dismiss();
loadData();
Intent i = new Intent(MainActivity.this, LoanDetailActivity.class);
i.putExtra("principle", Double.parseDouble(principle));
i.putExtra("tenure", Double.parseDouble(tenure));
Expand Down

0 comments on commit e1921d5

Please sign in to comment.