use of com.googlecode.flickrjandroid.photos.Photo in project glimmr by brk3.
the class AddToPhotosetDialogFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mLayout = (LinearLayout) inflater.inflate(R.layout.add_to_photoset_fragment, container, false);
TextView titleTextView = (TextView) mLayout.findViewById(R.id.titleText);
titleTextView.setText(R.string.add_photos);
mTextUtils.setFont(titleTextView, TextUtils.FONT_ROBOTOBOLD);
//ProgressBar progressBar = (ProgressBar)
// mLayout.findViewById(R.id.progressIndicator);
/* Nested fragments have to be added this way, not from xml */
FragmentTransaction ft = getChildFragmentManager().beginTransaction();
final boolean retainInstance = false;
final PhotoStreamGridFragment frag = PhotoStreamGridFragment.newInstance(mOAuth.getUser(), retainInstance, ListView.CHOICE_MODE_MULTIPLE);
ft.replace(R.id.photoStreamFragment, frag);
ft.commit();
/* When add button is clicked, get selected ids and add to queue */
mLayout.findViewById(R.id.buttonAddToPhotoset).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
List<Photo> selectedPhotos = frag.getSelectedPhotos();
for (Photo photo : selectedPhotos) {
mQueue.add(new AddItemToPhotosetTask(mPhotoset.getId(), photo.getId(), mOAuth));
}
mActivity.startService(new Intent(mActivity, AddToPhotosetTaskQueueService.class));
dismiss();
Crouton.makeText(mActivity, R.string.photos_will_be_added, Style.CONFIRM).show();
}
});
return mLayout;
}
use of com.googlecode.flickrjandroid.photos.Photo in project glimmr by brk3.
the class PhotoGridFragment method getSelectedPhotos.
public List<Photo> getSelectedPhotos() {
List<Photo> ret = new ArrayList<Photo>();
if (mGridView.getChoiceMode() != ListView.CHOICE_MODE_MULTIPLE) {
Log.e(TAG, "PhotoGridFragment not in CHOICE_MODE_MULTIPLE");
return ret;
}
SparseBooleanArray checkArray = mGridView.getCheckedItemPositions();
for (int i = 0; i < checkArray.size(); i++) {
if (checkArray.valueAt(i)) {
ret.add(mPhotos.get(checkArray.keyAt(i)));
}
}
if (BuildConfig.DEBUG)
Log.d(TAG, "getSelectedPhotos: " + ret.size());
return ret;
}
use of com.googlecode.flickrjandroid.photos.Photo in project glimmr by brk3.
the class MainActivity method startViewerForActivityItem.
private void startViewerForActivityItem(int itemPos) {
setProgressBarIndeterminateVisibility(Boolean.TRUE);
List<Item> items = ActivityNotificationHandler.loadItemList(MainActivity.this);
Item item = items.get(itemPos);
new LoadPhotoInfoTask(new IPhotoInfoReadyListener() {
@Override
public void onPhotoInfoReady(final Photo photo, Exception e) {
setProgressBarIndeterminateVisibility(Boolean.FALSE);
if (FlickrHelper.getInstance().handleFlickrUnavailable(MainActivity.this, e)) {
return;
}
if (photo == null) {
Log.e(TAG, "onPhotoInfoReady: photo is null, " + "can't start viewer");
return;
}
List<Photo> photos = new ArrayList<Photo>();
photos.add(photo);
setProgressBarIndeterminateVisibility(Boolean.FALSE);
PhotoViewerActivity.startPhotoViewer(MainActivity.this, photos, 0);
}
}, item.getId(), item.getSecret()).execute(mOAuth);
}
use of com.googlecode.flickrjandroid.photos.Photo in project glimmr by brk3.
the class ActivityNotificationHandler method showNotification.
private void showNotification(final Item item, final int eventOffset) {
if (BuildConfig.DEBUG) {
Log.d(TAG, "showNotification for " + item.getTitle() + ", starting ajax task to fetch the item image");
}
/* fetch the photo the item refers to */
new LoadPhotoInfoTask(new IPhotoInfoReadyListener() {
@Override
public void onPhotoInfoReady(final Photo photo, Exception e) {
/* fetch the photo bitmap to be shown in the notification */
String url = photo.getMediumUrl();
new DownloadPhotoTask(mContext, new Events.IPhotoDownloadedListener() {
@Override
public void onPhotoDownloaded(Bitmap bitmap, Exception e) {
onItemPhotoReady(item, photo, bitmap, eventOffset);
}
}, url).execute();
}
}, item.getId(), item.getSecret()).execute(mOAuth);
}
use of com.googlecode.flickrjandroid.photos.Photo in project glimmr by brk3.
the class ContactsPhotosNotificationHandler method onPhotosReady.
/**
* Once photos are ready check for new ones and notify the user.
*
* There are two conditions that must be satisfied for a notification to be
* shown:
* 1) The id must be newer than ones previously shown in the main app.
* 2) The id must not equal the one previously notified about, to avoid
* duplicate notifications.
*/
@Override
public void onPhotosReady(List<Photo> photos, Exception e) {
if (BuildConfig.DEBUG)
Log.d(TAG, "onPhotosReady");
if (photos != null) {
List<Photo> newPhotos = checkForNewPhotos(photos);
if (newPhotos != null && !newPhotos.isEmpty()) {
String latestIdNotifiedAbout = getLatestIdNotifiedAbout();
Photo latestPhoto = newPhotos.get(0);
if (!latestIdNotifiedAbout.equals(latestPhoto.getId())) {
showNewPhotosNotification(newPhotos);
storeLatestIdNotifiedAbout(latestPhoto);
}
}
} else {
Log.e(TAG, "onPhotosReady: null photolist received");
}
}
Aggregations