Hi,
I implemented a small feature in the Android client to select either Articles or Feeds with one tap from the list of the Categories, and I’d like to share with the TT RSS community and receive a feedback:
Tap on the category name to display the list of the Articles:
Tap on the category icon to display the list of the Feeds:
I believe this behavior may increase the standard one and simplifies settings.
It is done in the FeedCategoriesFragment class:
- Add a new View.OnClickListener class:
private class IconOnClickListener implements View.OnClickListener {
private int m_position;
private ViewGroup m_parent;public IconOnClickListener (int position, ViewGroup parent) { m_position = position + 1; // Increase by 1 because of Special folder m_parent = parent; } @Override public void onClick(View v) { ((ListView) m_parent).performItemClick(v, m_position, 0); // Let the event be handled in onItemClick() }
}
- Add the listener in the “public View getView(int position, View convertView, ViewGroup parent)” method:
if (icon != null) { TypedValue tv = new TypedValue(); m_activity.getTheme().resolveAttribute(R.attr.ic_folder_outline, tv, true); icon.setImageResource(tv.resourceId); icon.setOnClickListener(new IconOnClickListener(position, parent)); // setup the listener }
- Manage the tap in the “public void onItemClick(AdapterView<?> av, View view, int position, long id)” method:
if (cat != null) { if (cat.id < 0) { m_activity.onCatSelected(cat, false); } else { long viewId = view.getId(); // If tap the icon, open the category if (viewId == R.id.icon) m_activity.onCatSelected(cat, false); else m_activity.onCatSelected(cat); } }
I am not an Android developer, so sorry if coding is not clean or “beautiful”.
Gabriele