fix crash when opening context menu on feed/cats fragments w/ header
This commit is contained in:
parent
4a2673f328
commit
1e0a0387ca
@ -55,8 +55,9 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
|
|||||||
private FeedCategory m_selectedCat;
|
private FeedCategory m_selectedCat;
|
||||||
private FeedsActivity m_activity;
|
private FeedsActivity m_activity;
|
||||||
private SwipeRefreshLayout m_swipeLayout;
|
private SwipeRefreshLayout m_swipeLayout;
|
||||||
|
private ListView m_list;
|
||||||
|
|
||||||
@SuppressLint("DefaultLocale")
|
@SuppressLint("DefaultLocale")
|
||||||
class CatUnreadComparator implements Comparator<FeedCategory> {
|
class CatUnreadComparator implements Comparator<FeedCategory> {
|
||||||
@Override
|
@Override
|
||||||
public int compare(FeedCategory a, FeedCategory b) {
|
public int compare(FeedCategory a, FeedCategory b) {
|
||||||
@ -179,7 +180,7 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
|
|||||||
m_activity.getMenuInflater().inflate(R.menu.category_menu, menu);
|
m_activity.getMenuInflater().inflate(R.menu.category_menu, menu);
|
||||||
|
|
||||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
|
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
|
||||||
FeedCategory cat = m_adapter.getItem(info.position);
|
FeedCategory cat = (FeedCategory) m_list.getItemAtPosition(info.position);
|
||||||
|
|
||||||
if (cat != null)
|
if (cat != null)
|
||||||
menu.setHeaderTitle(cat.title);
|
menu.setHeaderTitle(cat.title);
|
||||||
@ -210,16 +211,16 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ListView list = (ListView)view.findViewById(R.id.feeds);
|
m_list = (ListView)view.findViewById(R.id.feeds);
|
||||||
m_adapter = new FeedCategoryListAdapter(getActivity(), R.layout.feeds_row, (ArrayList<FeedCategory>)m_cats);
|
m_adapter = new FeedCategoryListAdapter(getActivity(), R.layout.feeds_row, (ArrayList<FeedCategory>)m_cats);
|
||||||
list.setAdapter(m_adapter);
|
m_list.setAdapter(m_adapter);
|
||||||
list.setOnItemClickListener(this);
|
m_list.setOnItemClickListener(this);
|
||||||
registerForContextMenu(list);
|
registerForContextMenu(m_list);
|
||||||
|
|
||||||
// TODO: better check
|
// TODO: better check
|
||||||
if (m_activity.findViewById(R.id.headlines_drawer) != null) {
|
if (m_activity.findViewById(R.id.headlines_drawer) != null) {
|
||||||
View layout = inflater.inflate(R.layout.drawer_header, list, false);
|
View layout = inflater.inflate(R.layout.drawer_header, m_list, false);
|
||||||
list.addHeaderView(layout, null, false);
|
m_list.addHeaderView(layout, null, false);
|
||||||
|
|
||||||
TextView login = (TextView) view.findViewById(R.id.drawer_header_login);
|
TextView login = (TextView) view.findViewById(R.id.drawer_header_login);
|
||||||
TextView server = (TextView) view.findViewById(R.id.drawer_header_server);
|
TextView server = (TextView) view.findViewById(R.id.drawer_header_server);
|
||||||
|
@ -61,8 +61,9 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
|
|||||||
private boolean m_feedIconsChecked = false;
|
private boolean m_feedIconsChecked = false;
|
||||||
private SwipeRefreshLayout m_swipeLayout;
|
private SwipeRefreshLayout m_swipeLayout;
|
||||||
private boolean m_enableParentBtn = false;
|
private boolean m_enableParentBtn = false;
|
||||||
|
private ListView m_list;
|
||||||
public void initialize(FeedCategory cat, boolean enableParentBtn) {
|
|
||||||
|
public void initialize(FeedCategory cat, boolean enableParentBtn) {
|
||||||
m_activeCategory = cat;
|
m_activeCategory = cat;
|
||||||
m_enableParentBtn = enableParentBtn;
|
m_enableParentBtn = enableParentBtn;
|
||||||
}
|
}
|
||||||
@ -229,8 +230,8 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
|
|||||||
|
|
||||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
|
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
|
||||||
|
|
||||||
ListView list = (ListView) getView().findViewById(R.id.feeds);
|
//ListView list = (ListView) getView().findViewById(R.id.feeds);
|
||||||
Feed feed = (Feed) getFeedAtPosition(info.position);
|
Feed feed = (Feed) m_list.getItemAtPosition(info.position);
|
||||||
|
|
||||||
menu.setHeaderTitle(feed.display_title != null ? feed.display_title : feed.title);
|
menu.setHeaderTitle(feed.display_title != null ? feed.display_title : feed.title);
|
||||||
|
|
||||||
@ -283,10 +284,10 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
|
|||||||
}
|
}
|
||||||
} */
|
} */
|
||||||
|
|
||||||
ListView list = (ListView)view.findViewById(R.id.feeds);
|
m_list = (ListView)view.findViewById(R.id.feeds);
|
||||||
|
|
||||||
if (m_enableParentBtn) {
|
if (m_enableParentBtn) {
|
||||||
View layout = inflater.inflate(R.layout.feeds_goback, list, false);
|
View layout = inflater.inflate(R.layout.feeds_goback, m_list, false);
|
||||||
|
|
||||||
layout.setOnClickListener(new OnClickListener() {
|
layout.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -295,12 +296,12 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
list.addHeaderView(layout, null, false);
|
m_list.addHeaderView(layout, null, false);
|
||||||
} else {
|
} else {
|
||||||
// TODO: better check
|
// TODO: better check
|
||||||
if (m_activity.findViewById(R.id.headlines_drawer) != null) {
|
if (m_activity.findViewById(R.id.headlines_drawer) != null) {
|
||||||
View layout = inflater.inflate(R.layout.drawer_header, list, false);
|
View layout = inflater.inflate(R.layout.drawer_header, m_list, false);
|
||||||
list.addHeaderView(layout, null, false);
|
m_list.addHeaderView(layout, null, false);
|
||||||
|
|
||||||
TextView login = (TextView) view.findViewById(R.id.drawer_header_login);
|
TextView login = (TextView) view.findViewById(R.id.drawer_header_login);
|
||||||
TextView server = (TextView) view.findViewById(R.id.drawer_header_server);
|
TextView server = (TextView) view.findViewById(R.id.drawer_header_server);
|
||||||
@ -315,11 +316,11 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_adapter = new FeedListAdapter(getActivity(), R.layout.feeds_row, (ArrayList<Feed>)m_feeds);
|
m_adapter = new FeedListAdapter(getActivity(), R.layout.feeds_row, (ArrayList<Feed>)m_feeds);
|
||||||
list.setAdapter(m_adapter);
|
m_list.setAdapter(m_adapter);
|
||||||
//list.setEmptyView(view.findViewById(R.id.no_feeds));
|
//list.setEmptyView(view.findViewById(R.id.no_feeds));
|
||||||
list.setOnItemClickListener(this);
|
m_list.setOnItemClickListener(this);
|
||||||
|
|
||||||
registerForContextMenu(list);
|
registerForContextMenu(m_list);
|
||||||
|
|
||||||
//m_enableFeedIcons = m_prefs.getBoolean("download_feed_icons", false);
|
//m_enableFeedIcons = m_prefs.getBoolean("download_feed_icons", false);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user