Integrated longclick-handling on NewsReaderList-Items
This commit is contained in:
parent
7adf8ba631
commit
792e3cc3d2
4 changed files with 84 additions and 13 deletions
|
@ -249,25 +249,40 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter
|
|||
viewHolder = (GroupHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
|
||||
viewHolder.txt_Summary.setText(group.header);
|
||||
viewHolder.listItemLayout.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
long idFeed = group.id_database;
|
||||
boolean skipFireEvent = false;
|
||||
long idFeed = group.id_database;
|
||||
boolean skipFireEvent = false;
|
||||
|
||||
if(group instanceof ConcreteFeedItem) {
|
||||
if (group instanceof ConcreteFeedItem) {
|
||||
fireListTextClicked(idFeed, false, (long) ITEMS_WITHOUT_FOLDER.getValue());
|
||||
skipFireEvent = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!skipFireEvent)
|
||||
fireListTextClicked(idFeed, true, ((FolderSubscribtionItem) group).idFolder);
|
||||
}
|
||||
});
|
||||
if (!skipFireEvent)
|
||||
fireListTextClicked(idFeed, true, ((FolderSubscribtionItem) group).idFolder);
|
||||
}
|
||||
});
|
||||
|
||||
viewHolder.listItemLayout.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
|
||||
long idFeed = group.id_database;
|
||||
|
||||
if (group instanceof ConcreteFeedItem) {
|
||||
fireListTextLongClicked(idFeed, false, (long) ITEMS_WITHOUT_FOLDER.getValue());
|
||||
} else {
|
||||
fireListTextLongClicked(idFeed, true, ((FolderSubscribtionItem) group).idFolder);
|
||||
}
|
||||
return true; //consume event
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
viewHolder.txt_UnreadCount.setText("");
|
||||
|
@ -609,4 +624,9 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter
|
|||
if(eListTextClickHandler != null)
|
||||
eListTextClickHandler.onTextClicked(idFeed, isFolder, optional_folder_id);
|
||||
}
|
||||
protected void fireListTextLongClicked(long idFeed, boolean isFolder, Long optional_folder_id)
|
||||
{
|
||||
if(eListTextClickHandler != null)
|
||||
eListTextClickHandler.onTextLongClicked(idFeed, isFolder, optional_folder_id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -583,6 +583,21 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
StartDetailFragment(idFeed, false, optional_folder_id, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTopItemLongClicked(long idFeed, boolean isFolder, Long optional_folder_id) {
|
||||
if(isFolder) {
|
||||
//top-folder long-clicked
|
||||
} else {
|
||||
//top-item long-clicked
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChildItemLongClicked(long idFeed, Long optional_folder_id) {
|
||||
//child-item long-clicked
|
||||
|
||||
}
|
||||
|
||||
private NewsReaderDetailFragment StartDetailFragment(long id, Boolean folder, Long optional_folder_id, boolean updateListView)
|
||||
{
|
||||
if(menuItemDownloadMoreItems != null) {
|
||||
|
|
|
@ -31,6 +31,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.View.OnCreateContextMenuListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ExpandableListView;
|
||||
import android.widget.ExpandableListView.OnChildClickListener;
|
||||
import android.widget.ImageView;
|
||||
|
@ -95,6 +96,8 @@ public class NewsReaderListFragment extends Fragment implements OnCreateContextM
|
|||
*/
|
||||
void onChildItemClicked(long idFeed, Long optional_folder_id);
|
||||
void onTopItemClicked(long idFeed, boolean isFolder, Long optional_folder_id);
|
||||
void onChildItemLongClicked(long idFeed, Long optional_folder_id);
|
||||
void onTopItemLongClicked(long idFeed, boolean isFolder, Long optional_folder_id);
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,8 +134,10 @@ public class NewsReaderListFragment extends Fragment implements OnCreateContextM
|
|||
eListView.setGroupIndicator(null);
|
||||
|
||||
eListView.setOnChildClickListener(onChildClickListener);
|
||||
eListView.setOnItemLongClickListener(onItemLongClickListener);
|
||||
|
||||
eListView.setClickable(true);
|
||||
eListView.setLongClickable(true);
|
||||
eListView.setAdapter(lvAdapter);
|
||||
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
|
@ -178,9 +183,15 @@ public class NewsReaderListFragment extends Fragment implements OnCreateContextM
|
|||
|
||||
@Override
|
||||
public void onTextClicked(long idFeed, boolean isFolder, Long optional_folder_id) {
|
||||
mCallbacks.onTopItemClicked(idFeed, isFolder, optional_folder_id);
|
||||
mCallbacks.onTopItemClicked(idFeed, isFolder, optional_folder_id);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onTextLongClicked(long idFeed, boolean isFolder, Long optional_folder_id) {
|
||||
mCallbacks.onTopItemLongClicked(idFeed, isFolder, optional_folder_id);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
OnChildClickListener onChildClickListener = new OnChildClickListener() {
|
||||
|
||||
|
@ -200,4 +211,28 @@ public class NewsReaderListFragment extends Fragment implements OnCreateContextM
|
|||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
AdapterView.OnItemLongClickListener onItemLongClickListener = new AdapterView.OnItemLongClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
|
||||
|
||||
int groupPosition = ExpandableListView.getPackedPositionGroup(id);
|
||||
int childPosition = ExpandableListView.getPackedPositionChild(id);
|
||||
|
||||
long idItem = lvAdapter.getChildId(groupPosition, childPosition);
|
||||
|
||||
Long optional_id_folder = null;
|
||||
FolderSubscribtionItem groupItem = (FolderSubscribtionItem) lvAdapter.getGroup(groupPosition);
|
||||
if(groupItem != null)
|
||||
optional_id_folder = groupItem.id_database;
|
||||
|
||||
mCallbacks.onChildItemLongClicked(idItem, optional_id_folder);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
|
@ -23,4 +23,5 @@ package de.luhmer.owncloudnewsreader.interfaces;
|
|||
|
||||
public interface ExpListTextClicked {
|
||||
void onTextClicked(long idFeed, boolean isFolder, Long optional_folder_id);
|
||||
void onTextLongClicked(long idFeed, boolean isFolder, Long optional_folder_id);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue