use of com.meisolsson.githubsdk.model.ReleaseAsset in project gh4a by slapperwan.
the class EventListFragment method onContextItemSelected.
@Override
public boolean onContextItemSelected(MenuItem item) {
ContextMenuAwareRecyclerView.RecyclerContextMenuInfo info = (ContextMenuAwareRecyclerView.RecyclerContextMenuInfo) item.getMenuInfo();
if (info.position >= mAdapter.getItemCount()) {
return false;
}
int id = item.getItemId();
GitHubEvent event = mAdapter.getItemFromAdapterPosition(info.position);
if (id >= MENU_DOWNLOAD_START && id <= MENU_DOWNLOAD_END) {
if (event.type() == GitHubEventType.ReleaseEvent) {
ReleasePayload payload = (ReleasePayload) event.payload();
ReleaseAsset asset = payload.release().assets().get(id - MENU_DOWNLOAD_START);
UiUtils.enqueueDownloadWithPermissionCheck((BaseActivity) getActivity(), asset.url(), asset.contentType(), asset.name(), asset.label(), null);
} else if (event.type() == GitHubEventType.DownloadEvent) {
DownloadPayload payload = (DownloadPayload) event.payload();
Download download = payload.download();
UiUtils.enqueueDownloadWithPermissionCheck((BaseActivity) getActivity(), download.htmlUrl(), download.contentType(), download.name(), download.description(), null);
}
return true;
}
return false;
}
Aggregations