This is not a duplicate question. So please don't make this question as a duplicate.
I have scenario. I am implementing chat module in which all functionalities i have already done.
MainActivity - MainFragment - Chat List Fragment.
MainActivity
holds the MainFragment
which have a viewpager with tablayout. MainFragment's
view pager adapter holds ChatList
Fragment in which API call for chat list.
Now if i already in chat list fragment and push notification come for message then notification should not be appeared that i did. But i want to update data in chat list means want to call chat list API.
I am not getting MainActivity
context so i can access MainFragment
and retrieve that ChatList
fragment.
Code
case "chat_message":
// if (HirerTabsActivity.isOpenChat()) {
// Log.v("ATATATA", "asd");
//
// } else {
if (GetUserProfileData.getInstance().getUserDetail().getUser_type().equalsIgnoreCase("artist")) {
intent = new Intent(this, ArtistTabsActivity.class);
intent.putExtra("fromNotification", "Y");
} else {
intent = new Intent(this, HirerTabsActivity.class);
intent.putExtra("fromNotification", "Y");
}
break;
Updated Code
case "chat_message":
if (mediaPrefs.getString(Constant.SharedPreferences_IN_CHAT_SCREEN, "").equalsIgnoreCase("Y")) {
sendBroadcast(new Intent().setAction("chat_refresh"));
} else {
if (GetUserProfileData.getInstance().getUserDetail().getUser_type().equalsIgnoreCase("artist")) {
intent = new Intent(this, ArtistTabsActivity.class);
intent.putExtra("fromNotification", "Y");
} else {
intent = new Intent(this, HirerTabsActivity.class);
intent.putExtra("fromNotification", "Y");
}
}
Advanced help would be appreciated!