问题
lets say I have master/detail pattern using fragments, so as usual, the detail fragment would be inside new activity on a phone and on a tablet it would be inside the previous activity that list fragment is in also. Old stuff.
I have some actions to perform on the detail, like share, it would be actionbar item. Old stuff.
But now, I want to implement Contextual ActionBar, or a dialog, it doesnt really matter in my opinion, that would allow sharing right from the list.
My question is, where should I have that sharing code? I want to avoid duplicates. In my head, it cant really be a callback because the detail can be inside the dual activity or inside its single activity. Its just really confusing to me how should I do this.
Hope you get it. Thanks!
回答1:
where should I have that sharing code? I want to avoid duplicates
Taking a guess that "that sharing code" is your ACTION_SEND
invocation, since that is only a half-dozen lines of code or so, tuck that in a static method somewhere that can be accessed by your detail fragment and by the activity that is hosting the list on smaller screens.
来源:https://stackoverflow.com/questions/14990269/where-to-handle-cab-actions-of-a-list-item-that-are-common-with-detail