Vou postar a sequência do código para que vocês possam entender o demônio que ta acontecendo.
No meu ChatFragment há um método para setar o adapter que será chamado pela activity. Mas ao chamar, o recycler é null, mesmo depois de ter passado o onCreateView() onde tudo é instanciado.
-- No meu ChatFragment há um método para setar o adapter que será chamado pela activity. Mas ao chamar, o recycler é null, mesmo depois de ter passado o onCreateView() onde tudo é instanciado.
//ACTIVITY
@Override
public void onIRCConnected() {
runOnUiThread(
new Runnable() {
@Override
public void run() {
mViewPager.getAdapter().notifyDataSetChanged();
// nesse momento, o ChatFragment já está sendo exibido e é chamado o onCreateView();
setChatFragmentConversation(mService.getChannelConversation());
}
}
);
public void setChatFragmentConversation(Conversation conversation){
try {
FragmentChat frag = (FragmentChat) ((MyPagerAdapter) mViewPager.getAdapter()).getItem(1);
frag.setConversationAdapter(mService.getChannelConversation());
}catch (ClassCastException e){
}
}
// FRAGMENT
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.layout_fragment_chat, container, false);
mEditText = (EditText) v.findViewById(R.id.edittext_input);
mRecyclerView = (RecyclerView) v.findViewById(R.id.recyclerview);
mImageView = (ImageView) v.findViewById(R.id.imageview_sendbutton);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
mImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onSendButtonClicked(mEditText.getText().toString());
}
});
return v;
}
public void setConversationAdapter(Conversation conversation) {
mConversation = conversation;
// NESSE MOMENTO, NESSE MALDITO DESGRAÇADO MORFÉTICO MOMENTO, MRECYCLERVIEW É NULL... PQ? COMO?
mRecyclerView.setAdapter(new ChatRecyclerAdapter(conversation));
}Qualquer ajuda é bem vinda e pode me ajudar a não desistir do projeto por estar cansado da ingrata e muitas vezes paradoxalmente ilógica vida de programador.
Obrigado.
Obrigado.
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.






0 comentários:
Postar um comentário