use of org.adw.launcher2.ItemInfo.EditAction in project ADWLauncher2 by boombuler.
the class Launcher method showActions.
public void showActions(ItemInfo info, View view, PopupWindow.OnDismissListener onDismissListener) {
if (info == null || view == null)
return;
List<EditAction> actions = info.getAvailableActions(view, this);
if (actions.size() <= 0)
return;
final View finalview = view;
final ItemInfo finalInfo = info;
int[] xy = new int[2];
//fills the array with the computed coordinates
view.getLocationInWindow(xy);
new Rect(xy[0], xy[1], xy[0] + view.getWidth(), xy[1] + view.getHeight());
//a new QuickActionWindow object
final QuickAction qa = new QuickAction(view);
view.setTag(org.adw.launcher2.R.id.TAG_PREVIEW, qa);
if (onDismissListener != null) {
qa.setOnDismissListener(onDismissListener);
}
//when the item is clicked on
for (EditAction action : actions) {
final EditAction finalaction = action;
Drawable icon;
CharSequence title;
if (action.getIconResourceId() == 0) {
icon = action.getIconDrawable();
} else {
icon = getResources().getDrawable(action.getIconResourceId());
}
if (action.getTitleResourceId() == 0) {
title = action.getTitleString();
} else {
title = getResources().getString(action.getTitleResourceId());
}
ActionItem ai = new ActionItem(icon);
if (title != null)
ai.setTitle(title.toString());
ai.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
qa.dismiss();
finalInfo.executeAction(finalaction, finalview, Launcher.this);
}
});
qa.addActionItem(ai);
}
//shows the quick action window on the screen
qa.show();
}
Aggregations