Skip to content

Commit

Permalink
fix(null obj)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximeleroylaval committed May 2, 2019
1 parent fc24af6 commit 8fe14ad
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public void onVoiceChannelClicked(Channel channel) {
public void onSearch(String search) {
if (FileManager.requirePermissions(this)) {
Intent intent = new Intent(this, FileManager.class);
intent.putExtra(FilePickerActivity.ARG_FILTER, Pattern.compile(search + ".*\\.(opus)"));
intent.putExtra(FilePickerActivity.ARG_FILTER, Pattern.compile(search + "*.*\\.(opus)"));
intent.putExtra(FilePickerActivity.ARG_CLOSEABLE, true);
intent.putExtra(FilePickerActivity.ARG_TITLE, getString(R.string.choose_file));
intent.putExtra(FilePickerActivity.ARG_START_PATH, FileManager.importedDir.getAbsolutePath());
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/java/ca/ulaval/ima/mp/adapter/MessageAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
holder.mItem = mValues.get(position);
holder.mUserView.setText(mValues.get(position).author.username);
holder.mContentView.setText(mValues.get(position).content);
Picasso.get().load(mValues.get(position).author.getAvatarURI()).into(holder.mAvatarView);
if (position < mValues.size()) {
holder.mItem = mValues.get(position);
holder.mUserView.setText(mValues.get(position).author.username);
holder.mContentView.setText(mValues.get(position).content);
Picasso.get().load(mValues.get(position).author.getAvatarURI()).into(holder.mAvatarView);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void run() {

public void setActiveChannel(Channel channel) {
this.loadMessages(channel);
if (getActivity() != null && channel.name != null) {
if (getActivity() != null && channel != null && channel.name != null) {
getActivity().setTitle("#" + channel.name);
}
activeChannel = channel;
Expand All @@ -149,7 +149,8 @@ public void onClick(View v) {
recyclerView.setAdapter(mAdapter);
}
this.setActiveChannel(this.activeChannel);
Gateway.server.setMessageHandler(this);
if (Gateway.server != null)
Gateway.server.setMessageHandler(this);
return rootView;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void onFailure(String message) {

public void setActiveChannel(Channel channel) {
voiceChannel = channel;
if (getActivity() != null && channel.name != null) {
if (getActivity() != null && channel != null && channel.name != null) {
getActivity().setTitle("@" + channel.name);
}
if (voiceChannel != null) {
Expand Down

0 comments on commit 8fe14ad

Please # to comment.