0

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!

AstroCB
  • 12,337
  • 20
  • 57
  • 73
urSus
  • 12,492
  • 12
  • 69
  • 89

1 Answers1

0

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • That was just an example to simplify things. So, the problem is that the detail fragment might not exist when executing a CAB action, when in phone layout, so the only solution use static stuff or duplicate? – urSus Feb 21 '13 at 17:20
  • @VlastoBennyLava: "so the only solution use static stuff or duplicate?" -- or do not implement "that sharing code" at all. Or isolate "that sharing code" in some common utility class that you use from both spots. – CommonsWare Feb 21 '13 at 17:36