Skip to content

Commit

Permalink
Hotfix crash on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
vladholubiev committed Jan 24, 2015
1 parent 379d057 commit 26f7283
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,17 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
public void onEvent(RefreshEvent event) {
StudentKeeper.refreshStudent();
ModulesFragment.initSubjects();
rerenderModuleSubjectsList();
reRenderModuleSubjectsList();
}

public void onEvent(SemesterChangedEvent event) {
Log.d("[ModuleFragment#onEvent(SemesterChangedEvent)]",
"Current semesterIndex:" + StudentKeeper.getCurrentSemesterIndex());
Log.d("SEMESTER_CHANGED_EVENT", "SemesterIndex:" + StudentKeeper.getCurrentSemesterIndex());

ModulesFragment.initSubjects();
rerenderModuleSubjectsList();
reRenderModuleSubjectsList();
}

private void rerenderModuleSubjectsList() {
private void reRenderModuleSubjectsList() {
moduleSubjectItemAdapter.notifyItemRangeChanged(0, moduleSubjectItemAdapter.getItemCount());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class SubjectsFragment extends Fragment {
private List<Subject> mSubjects = new ArrayList<>();

private RecyclerView mRecyclerView;
private SubjectItemAdapter mSectionAdapter;
private SubjectItemAdapter mSubjectItemAdapter;

public SubjectsFragment() {
// Required empty public constructor
Expand All @@ -57,12 +57,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
}

private void initSectionAdapter() {
mSectionAdapter = new SubjectItemAdapter(getActivity(), mSubjects);
mSubjectItemAdapter = new SubjectItemAdapter(getActivity(), mSubjects);
}

private void initRecyclerView(View rootView) {
mRecyclerView = (RecyclerView) rootView.findViewById(R.id.subjects_recycler_view);
mRecyclerView.setAdapter(mSectionAdapter);
mRecyclerView.setAdapter(mSubjectItemAdapter);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
mRecyclerView.addOnItemTouchListener(new RecyclerItemClickListener(getActivity(), new RecyclerItemClickListener.OnItemClickListener() {
@Override
Expand Down Expand Up @@ -91,11 +91,10 @@ private void initSubjects() {
} catch (IllegalArgumentException e) {
openLoginFragment();
}
reRenderSubjectsList();
}

private void reRenderSubjectsList() {
mSectionAdapter.notifyItemRangeChanged(0, mSectionAdapter.getItemCount());
mSubjectItemAdapter.notifyItemRangeChanged(0, mSubjectItemAdapter.getItemCount());
}

private void openLoginFragment() {
Expand All @@ -107,12 +106,14 @@ private void openLoginFragment() {
public void onEvent(RefreshEvent event) {
StudentKeeper.refreshStudent();
initSubjects();
reRenderSubjectsList();
}

public void onEvent(SemesterChangedEvent event) {
Log.d("SEMESTER_CHANGED_EVENT", "SemesterIndex:" + StudentKeeper.getCurrentSemesterIndex());

initSubjects();
reRenderSubjectsList();
}

@Override
Expand Down

0 comments on commit 26f7283

Please sign in to comment.