public static void showPicasaGallery(Long id, String name) {
    notFoundIfNull(id);
    PicasaGallery gallery = PicasaGallery.findById(id);
    notFoundIfNull(gallery);

    PicasawebService service = new PicasawebService("portfolio");
    List<PhotoEntry> photoEntries = Collections.emptyList();
    try {
      java.net.URL feedUrl = new java.net.URL(gallery.getFeedUrl());

      AlbumFeed feed = service.getFeed(feedUrl, AlbumFeed.class);
      photoEntries = feed.getPhotoEntries();
    } catch (MalformedURLException e) {
      Logger.error("Service URL for Picasa is not well formed");
      e.printStackTrace();
    } catch (IOException e) {
      Logger.error("Error I/O while communicating with Picasa Service");
      e.printStackTrace();
    } catch (ServiceException e) {
      Logger.error("Picasa service error");
      e.printStackTrace();
    }

    List<ImageView> images = new ArrayList<ImageView>();
    for (PhotoEntry entry : photoEntries) {
      ImageView image = new ImageView();
      // We take the largest
      image.thumbnail =
          entry.getMediaThumbnails().get(entry.getMediaThumbnails().size() - 1).getUrl();
      image.url = entry.getMediaContents().get(0).getUrl();
      images.add(image);
    }

    render("Application/gallery.html", images, gallery);
  }
示例#2
0
  private void processImageResponse(
      ImageResponse response, String graphObjectId, ImageView imageView) {
    pendingRequests.remove(graphObjectId);
    if (response.getError() != null) {
      callOnErrorListener(response.getError());
    }

    if (imageView == null) {
      // This was a pre-fetch request.
      if (response.getBitmap() != null) {
        // Is the cache too big?
        if (prefetchedPictureCache.size() >= MAX_PREFETCHED_PICTURES) {
          // Find the oldest one and remove it.
          String oldestId = prefetchedProfilePictureIds.remove(0);
          prefetchedPictureCache.remove(oldestId);
        }
        prefetchedPictureCache.put(graphObjectId, response);
      }
    } else if (graphObjectId.equals(imageView.getTag())) {
      Exception error = response.getError();
      Bitmap bitmap = response.getBitmap();
      if (error == null && bitmap != null) {
        imageView.setImageBitmap(bitmap);
        imageView.setTag(response.getRequest().getImageUri());
      }
    }
  }
示例#3
0
    public View getView(int position, View convertView, ViewGroup parent) {
      final View view =
          (convertView != null)
              ? convertView
              : LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.bookmark_item, parent, false);
      final ImageView imageView = (ImageView) view.findViewById(R.id.bookmark_item_icon);
      final TextView textView = (TextView) view.findViewById(R.id.bookmark_item_text);
      final TextView bookTitleView = (TextView) view.findViewById(R.id.bookmark_item_booktitle);

      final Bookmark bookmark = getItem(position);
      if (bookmark == null) {
        imageView.setVisibility(View.VISIBLE);
        imageView.setImageResource(R.drawable.ic_list_plus);
        textView.setText(ZLResource.resource("bookmarksView").getResource("new").getValue());
        bookTitleView.setVisibility(View.GONE);
      } else {
        imageView.setVisibility(View.GONE);
        textView.setText(bookmark.getText());
        if (myCurrentBook) {
          bookTitleView.setVisibility(View.GONE);
        } else {
          bookTitleView.setVisibility(View.VISIBLE);
          bookTitleView.setText(bookmark.getBookTitle());
        }
      }
      return view;
    }
    @Override
    public View getView(int position, View convertView, final ViewGroup parent) {
      final Item item = getItem(position);

      final View view;
      if (convertView != null && item.getClass().equals(convertView.getTag())) {
        view = convertView;
      } else {
        view =
            getLayoutInflater()
                .inflate(
                    item instanceof SectionItem
                        ? R.layout.catalog_manager_section_head
                        : R.layout.catalog_manager_item,
                    null);
        view.setTag(item.getClass());
      }

      if (item instanceof SectionItem) {
        ((TextView) view.findViewById(R.id.catalog_manager_section_head_title))
            .setText(((SectionItem) item).Title);
      } else /* if (item instanceof CatalogItem) */ {
        final CatalogItem catalogItem = (CatalogItem) item;

        if (myCoverManager == null) {
          view.measure(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
          final int coverHeight = view.getMeasuredHeight();
          myCoverManager =
              new CoverManager(CatalogManagerActivity.this, coverHeight * 15 / 22, coverHeight);
          view.requestLayout();
        }

        final INetworkLink link = catalogItem.Tree.getLink();
        ((TextView) view.findViewById(R.id.catalog_manager_item_title)).setText(link.getTitle());
        ((TextView) view.findViewById(R.id.catalog_manager_item_subtitle))
            .setText(link.getSummary());

        final ImageView coverView = (ImageView) view.findViewById(R.id.catalog_manager_item_icon);
        if (!myCoverManager.trySetCoverImage(coverView, catalogItem.Tree)) {
          coverView.setImageResource(R.drawable.ic_list_library_books);
        }

        final CheckBox checkBox = (CheckBox) view.findViewById(R.id.catalog_manager_item_checkbox);
        checkBox.setChecked(catalogItem.IsChecked);
        checkBox.setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View v) {
                catalogItem.IsChecked = checkBox.isChecked();
                setResultIds(catalogItem, 0);
              }
            });
      }
      return view;
    }
示例#5
0
  String getPictureFieldSpecifier() {
    // How big is our image?
    View view = createGraphObjectView(null);
    ImageView picture = (ImageView) view.findViewById(R.id.com_facebook_picker_image);
    if (picture == null) {
      return null;
    }

    // Note: these dimensions are in pixels, not dips
    ViewGroup.LayoutParams layoutParams = picture.getLayoutParams();
    return String.format("picture.height(%d).width(%d)", layoutParams.height, layoutParams.width);
  }
    public FileGridCell() {
      Label titleLabel = new Label();
      titleLabel.setPrefWidth(80);
      titleLabel.setWrapText(true);
      titleLabel.setTextAlignment(TextAlignment.CENTER);
      title = titleLabel.textProperty();

      ImageView iconView = new ImageView();
      icon = iconView.imageProperty();

      VBox vbox = new VBox(iconView, titleLabel);
      vbox.setAlignment(Pos.TOP_CENTER);

      setGraphic(vbox);
    }
示例#7
0
        private void processResult(LoadResult result) {
          // Cache the new drawable
          final String filePath = (result.fso);
          mAppIcons.put(filePath, result.result);

          // find the request for it
          for (Map.Entry<ImageView, String> entry : mRequests.entrySet()) {
            final ImageView imageView = entry.getKey();
            final String fso = entry.getValue();
            if (fso == result.fso) {
              imageView.setImageBitmap(result.result);
              mRequests.remove(imageView);
              break;
            }
          }
        }
示例#8
0
  /**
   * Method that returns a drawable reference of a FileSystemObject.
   *
   * @param iconView View to load the drawable into
   * @param fso The FileSystemObject reference
   * @param defaultIcon Drawable to be used in case no specific one could be found
   * @return Drawable The drawable reference
   */
  public void loadDrawable(ImageView iconView, final String fso, Drawable defaultIcon) {
    if (!mUseThumbs) {
      return;
    }

    // Is cached?
    final String filePath = fso;
    if (this.mAppIcons.containsKey(filePath)) {
      iconView.setImageBitmap(this.mAppIcons.get(filePath));
      return;
    }
    mRequests.put(iconView, fso);
    new Thread(
            new Runnable() {
              @Override
              public void run() {

                mHandler.removeMessages(MSG_DESTROY);
                if (mWorkerThread == null || mWorkerHandler == null) {
                  mWorkerThread = new HandlerThread("IconHolderLoader");
                  mWorkerThread.start();
                  mWorkerHandler = new WorkerHandler(mWorkerThread.getLooper());
                }
                Message msg = mWorkerHandler.obtainMessage(MSG_LOAD, fso);
                msg.sendToTarget();
              }
            })
        .start();
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Get local Bluetooth adapter
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    // If the adapter is null, then Bluetooth is not supported
    if (mBluetoothAdapter == null) {
      Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
      finish();
      return;
    }

    ImageView controlsView = (ImageView) findViewById(R.id.controlsView);
    controlsView.setOnTouchListener(new ControlsTouchListener());
  }
示例#10
0
  protected void populateGraphObjectView(View view, T graphObject) {
    String id = getIdOfGraphObject(graphObject);
    view.setTag(id);

    CharSequence title = getTitleOfGraphObject(graphObject);
    TextView titleView = (TextView) view.findViewById(R.id.com_facebook_picker_title);
    if (titleView != null) {
      titleView.setText(title, TextView.BufferType.SPANNABLE);
    }

    CharSequence subtitle = getSubTitleOfGraphObject(graphObject);
    TextView subtitleView = (TextView) view.findViewById(R.id.picker_subtitle);
    if (subtitleView != null) {
      if (subtitle != null) {
        subtitleView.setText(subtitle, TextView.BufferType.SPANNABLE);
        subtitleView.setVisibility(View.VISIBLE);
      } else {
        subtitleView.setVisibility(View.GONE);
      }
    }

    if (getShowCheckbox()) {
      CheckBox checkBox = (CheckBox) view.findViewById(R.id.com_facebook_picker_checkbox);
      updateCheckboxState(checkBox, isGraphObjectSelected(id));
    }

    if (getShowPicture()) {
      URI pictureURI = getPictureUriOfGraphObject(graphObject);

      if (pictureURI != null) {
        ImageView profilePic = (ImageView) view.findViewById(R.id.com_facebook_picker_image);

        // See if we have already pre-fetched this; if not, download it.
        if (prefetchedPictureCache.containsKey(id)) {
          ImageResponse response = prefetchedPictureCache.get(id);
          profilePic.setImageBitmap(response.getBitmap());
          profilePic.setTag(response.getRequest().getImageUri());
        } else {
          downloadProfilePicture(id, pictureURI, profilePic);
        }
      }
    }
  }
 @Override
 public void ßløødy_Image() {
   if (Active_Image == -1) {
     Active_Image = 1;
     animate((View) Arpan_ßløødy_CoverImages[Active_Image]);
     return;
   }
   int n = Active_Image;
   Active_Image = (1 + Active_Image) % Arpan_ßløødy_CoverImages.length;
   ImageView imageView = Arpan_ßløødy_CoverImages[Active_Image];
   imageView.setAlpha(0.0f);
   ImageView imageView2 = Arpan_ßløødy_CoverImages[n];
   animate((View) imageView);
   AnimatorSet animatorSet = new AnimatorSet();
   animatorSet.setDuration((long) Fade_In_Out_Animation_Duration);
   Animator[] animator =
       new Animator[] {
         ObjectAnimator.ofFloat((Object) imageView2, "alpha", new float[] {1.0f, 0.0f}),
         ObjectAnimator.ofFloat((Object) imageView, "alpha", new float[] {0.0f, 1.0f})
       };
   animatorSet.playTogether(animator);
   animatorSet.start();
 }
示例#12
0
  private void downloadProfilePicture(
      final String profileId, URI pictureURI, final ImageView imageView) {
    if (pictureURI == null) {
      return;
    }

    // If we don't have an imageView, we are pre-fetching this image to store in-memory because we
    // think the user might scroll to its corresponding list row. If we do have an imageView, we
    // only want to queue a download if the view's tag isn't already set to the URL (which would
    // mean
    // it's already got the correct picture).
    boolean prefetching = imageView == null;
    if (prefetching || !pictureURI.equals(imageView.getTag())) {
      if (!prefetching) {
        // Setting the tag to the profile ID indicates that we're currently downloading the
        // picture for this profile; we'll set it to the actual picture URL when complete.
        imageView.setTag(profileId);
        imageView.setImageResource(getDefaultPicture());
      }

      ImageRequest.Builder builder =
          new ImageRequest.Builder(context.getApplicationContext(), pictureURI)
              .setCallerTag(this)
              .setCallback(
                  new ImageRequest.Callback() {
                    @Override
                    public void onCompleted(ImageResponse response) {
                      processImageResponse(response, profileId, imageView);
                    }
                  });

      ImageRequest newRequest = builder.build();
      pendingRequests.put(profileId, newRequest);

      ImageDownloader.downloadAsync(newRequest);
    }
  }
示例#13
0
  protected View createGraphObjectView(T graphObject) {
    View result = inflater.inflate(getGraphObjectRowLayoutId(graphObject), null);

    ViewStub checkboxStub = (ViewStub) result.findViewById(R.id.com_facebook_picker_checkbox_stub);
    if (checkboxStub != null) {
      if (!getShowCheckbox()) {
        checkboxStub.setVisibility(View.GONE);
      } else {
        CheckBox checkBox = (CheckBox) checkboxStub.inflate();
        updateCheckboxState(checkBox, false);
      }
    }

    ViewStub profilePicStub =
        (ViewStub) result.findViewById(R.id.com_facebook_picker_profile_pic_stub);
    if (!getShowPicture()) {
      profilePicStub.setVisibility(View.GONE);
    } else {
      ImageView imageView = (ImageView) profilePicStub.inflate();
      imageView.setVisibility(View.VISIBLE);
    }

    return result;
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.matchview);

    progressDialog = UIFactory.getDefaultProgressDialog(this);

    TextView nameField = (TextView) findViewById(R.id.nameField);
    TextView genderField = (TextView) findViewById(R.id.genderField);
    TextView ageField = (TextView) findViewById(R.id.ageField);
    ImageView avatarImage = (ImageView) findViewById(R.id.avatarImage);
    ImageView genderImage = (ImageView) findViewById(R.id.genderImage);
    matchPercentField = (TextView) findViewById(R.id.matchPercents);
    foodMatchValue = (TextView) findViewById(R.id.foodMatchValue);
    foodProgressBar = (ProgressBar) findViewById(R.id.foodProgressBar);
    musicMatchValue = (TextView) findViewById(R.id.musicMatchValue);
    musicProgressBar = (ProgressBar) findViewById(R.id.musicProgressBar);
    hobbiesMatchValue = (TextView) findViewById(R.id.hobbiesMatchValue);
    hobbiesProgressBar = (ProgressBar) findViewById(R.id.hobbiesProgressBar);
    travelMatchValue = (TextView) findViewById(R.id.travelMatchValue);
    travelProgressBar = (ProgressBar) findViewById(R.id.travelProgressBar);

    currentUserGeoPoint =
        (GeoPoint) getIntent().getSerializableExtra(Defaults.CURRENT_USER_GEO_POINT_BUNDLE_TAG);
    targetUserGeoPoint =
        (GeoPoint) getIntent().getSerializableExtra(Defaults.TARGET_USER_GEO_POINT_BUNDLE_TAG);
    triger = getIntent().getStringExtra(Defaults.TRIGER);

    String targetUserEmail = targetUserGeoPoint.getMetadata(BackendlessUser.EMAIL_KEY);
    targetUserName = targetUserGeoPoint.getMetadata(Defaults.NAME_PROPERTY);
    Gender targetUserGender =
        Gender.valueOf(targetUserGeoPoint.getMetadata(Defaults.GENDER_PROPERTY));
    targetUserDeviceRegistrationId =
        targetUserGeoPoint.getMetadata(Defaults.DEVICE_REGISTRATION_ID_PROPERTY);

    Date userBirthDate;
    try {
      userBirthDate =
          Defaults.DEFAULT_DATE_FORMATTER.parse(
              targetUserGeoPoint.getMetadata(Defaults.BIRTH_DATE_PROPERTY));
    } catch (ParseException e) {
      progressDialog.cancel();
      Log.logLine(e);

      return;
    }

    Button actionButton = (Button) findViewById(R.id.actionButton);

    if (!targetUserGeoPoint
            .getMetadata()
            .containsKey(Backendless.UserService.CurrentUser().getEmail())
        || !currentUserGeoPoint.getMetadata().containsKey(targetUserEmail)) {
      actionButton.setText(getResources().getText(R.string.button_match_ping));
      actionButton.setOnClickListener(pingUserListener);
    } else {
      actionButton.setText(getResources().getText(R.string.button_sendmessage));
      actionButton.setOnClickListener(sendMessageListener);
    }

    nameField.setText(targetUserName);
    genderField.setText(targetUserGender.name());

    if (targetUserGender == Gender.male) {
      avatarImage.setImageDrawable(getResources().getDrawable(R.drawable.avatar_default_male));
      genderImage.setImageDrawable(getResources().getDrawable(R.drawable.icon_male));
    } else {
      avatarImage.setImageDrawable(getResources().getDrawable(R.drawable.avatar_default_female));
      genderImage.setImageDrawable(getResources().getDrawable(R.drawable.icon_female));
    }

    ageField.setText(String.valueOf(SimpleMath.getAgeFromDate(userBirthDate)));

    // Food
    Map<String, String> metaDataFood = new HashMap<String, String>();
    metaDataFood.put("Asian", foodName);
    metaDataFood.put("Caribean", foodName);
    metaDataFood.put("Bar food", foodName);
    metaDataFood.put("French", foodName);
    metaDataFood.put("Mediterranean", foodName);
    metaDataFood.put("Greek", foodName);
    metaDataFood.put("Spanish", foodName);
    metaDataFood.put("Mexican", foodName);
    metaDataFood.put("Thai", foodName);
    int maxPoints = 10;
    BackendlessGeoQuery backendlessGeoQuery = new BackendlessGeoQuery(metaDataFood, maxPoints);
    backendlessGeoQuery.setPageSize(50);
    backendlessGeoQuery.setIncludeMeta(true);
    food = false;
    Backendless.Geo.relativeFind(backendlessGeoQuery, gotFoodCallback);
    // Music
    Map<String, String> metaDataMusic = new HashMap<String, String>();
    metaDataMusic.put("Classical", musicName);
    metaDataMusic.put("Jazz", musicName);
    metaDataMusic.put("Hip-hop", musicName);
    metaDataMusic.put("Reggae", musicName);
    metaDataMusic.put("Blues", musicName);
    metaDataMusic.put("Trance", musicName);
    metaDataMusic.put("House", musicName);
    metaDataMusic.put("Rock", musicName);
    metaDataMusic.put("Folk", musicName);
    backendlessGeoQuery = new BackendlessGeoQuery(metaDataMusic, maxPoints);
    backendlessGeoQuery.setPageSize(50);
    backendlessGeoQuery.setIncludeMeta(true);
    music = false;
    Backendless.Geo.relativeFind(backendlessGeoQuery, gotMusicCallback);
    // Hobbies
    Map<String, String> metaDataHobbies = new HashMap<String, String>();
    metaDataHobbies.put("Fishing", hobbiesName);
    metaDataHobbies.put("Diving", hobbiesName);
    metaDataHobbies.put("Rock climbing", hobbiesName);
    metaDataHobbies.put("Hiking", hobbiesName);
    metaDataHobbies.put("Reading", hobbiesName);
    metaDataHobbies.put("Dancing", hobbiesName);
    metaDataHobbies.put("Cooking", hobbiesName);
    metaDataHobbies.put("Surfing", hobbiesName);
    metaDataHobbies.put("Photography", hobbiesName);
    backendlessGeoQuery = new BackendlessGeoQuery(metaDataHobbies, maxPoints);
    backendlessGeoQuery.setPageSize(50);
    backendlessGeoQuery.setIncludeMeta(true);
    hobbies = false;
    Backendless.Geo.relativeFind(backendlessGeoQuery, gotHobbiesCallback);
    // Travel
    Map<String, String> metaDataTravel = new HashMap<String, String>();
    metaDataTravel.put("Cruise", travelName);
    metaDataTravel.put("B&B", travelName);
    metaDataTravel.put("Europe", travelName);
    metaDataTravel.put("Asia", travelName);
    metaDataTravel.put("Caribean", travelName);
    metaDataTravel.put("Mountains", travelName);
    metaDataTravel.put("Whale watching", travelName);
    metaDataTravel.put("Active travel", travelName);
    metaDataTravel.put("Passive travel", travelName);
    backendlessGeoQuery = new BackendlessGeoQuery(metaDataTravel, maxPoints);
    backendlessGeoQuery.setPageSize(50);
    backendlessGeoQuery.setIncludeMeta(true);
    travel = false;
    Backendless.Geo.relativeFind(backendlessGeoQuery, gotTravelCallback);
  }