/**
   * Overridden method to display the share action button in the options menu
   *
   * @param menu the options menu
   * @return boolean - if options were created for the menu
   */
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_detail, menu);

    Movie selectedMovie = getIntent().getParcelableExtra(DetailActivity.EXTRASCURRENTMOVIE);
    if (selectedMovie.getFavorite() != null && !selectedMovie.getFavorite().isEmpty()) {
      // Locate MenuItem for Favorite/Bookmark button
      MenuItem favItem = menu.findItem(R.id.menu_item_bookmark);
      favItem.setIcon(R.drawable.bookmark_plus);
      favItem.setChecked(true);
    }

    // Locate MenuItem with ShareActionProvider
    MenuItem shareItem = menu.findItem(R.id.menu_item_share);
    // Fetch and store ShareActionProvider
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);

    if (mShareActionProvider != null) {
      mShareActionProvider.setShareIntent(getDefaultShareIntent());
    } else {
      Log.d(LOG_TAG, "ShareActionProvider is null");
      return false;
    }
    return true;
  }
Пример #2
0
  public static void setStatusShareMenu(MenuItem shareItem, StatusContent status) {
    String url = null;

    if (status.getPic_urls() != null && status.getPic_urls().length > 0) {
      url = status.getPic_urls()[0].getThumbnail_pic();
    } else if (!TextUtils.isEmpty(status.getThumbnail_pic())) {
      url = status.getThumbnail_pic();
    }
    if (!TextUtils.isEmpty(url)) {
      File file = BitmapLoader.getInstance().getCacheFile(url.replace("thumbnail", "large"));
      if (file.exists()) {
        url = url.replace("thumbnail", "large");
      } else {
        file = BitmapLoader.getInstance().getCacheFile(url.replace("thumbnail", "bmiddle"));
        if (file.exists()) {
          url = url.replace("thumbnail", "bmiddle");
        }
      }
    }

    Intent shareIntent = Utils.getShareIntent(status.getText(), status.getText(), url);

    ShareActionProvider shareProvider =
        (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
    shareProvider.setShareHistoryFileName("channe_share.xml");
    shareProvider.setShareIntent(shareIntent);
  }
Пример #3
0
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data.moveToFirst()) {
      detailString = convertCursorRowToUXFormat(data);
      if (shareProvider != null) {
        shareProvider.setShareIntent(createForecastShareIntent());
      }
      mWeatherId = data.getInt(COL_WEATHER_ID);

      long date = data.getLong(ForecastFragment.COL_WEATHER_DATE);
      // POPULATE THE text views
      mDay.setText(Utility.getDayName(getActivity(), date));
      mDate.setText(Utility.getFormattedMonthDay(getActivity(), date));

      mHigh.setText(
          getString(R.string.format_degrees, data.getFloat(ForecastFragment.COL_WEATHER_MAX_TEMP)));
      mLow.setText(
          getString(R.string.format_degrees, data.getFloat(ForecastFragment.COL_WEATHER_MIN_TEMP)));
      mHumidity.setText(getString(R.string.format_humidity, data.getFloat(COL_HUMIDITY)));
      mPressure.setText(getString(R.string.format_pressure, data.getFloat(COL_PRESSURE)));
      mIcon.setImageResource(Utility.weatherCodeToArtPath(mWeatherId));

      float windSpeed = data.getFloat(COL_WIND_SPEED);
      String windDirection = getWindDirection(data.getFloat(COL_DEGREES));
      mWind.setText(getString(R.string.format_wind_kmh, windSpeed, windDirection));
      if (mCompass != null) {
        mCompass.setAngle(degreesToRadians(data.getFloat(COL_DEGREES)));
      }

      mDescription.setText(data.getString(ForecastFragment.COL_WEATHER_DESC));
    }
  }
Пример #4
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);

    // And implement a share action
    // Fetch/store provider
    // But only if there is data to share
    MenuItem item = menu.findItem(R.id.menu_item_share);

    if (mbShowShare == true) {

      ShareActionProvider shareAction =
          (ShareActionProvider) MenuItemCompat.getActionProvider(item);

      if (shareAction != null) {
        shareAction.setShareIntent(createShareIntent());
      }
    } else {
      // hide the share
      item.setVisible(false);
    }

    return true;
  }
Пример #5
0
 @Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   inflater.inflate(R.menu.detail, menu);
   MenuItem menuItem = menu.findItem(R.id.action_share);
   mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
   if (mVideos != null) mShareActionProvider.setShareIntent(createShareIntent());
 }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (mMovie != null) {
      inflater.inflate(R.menu.menu_fragment_detail, menu);

      final MenuItem action_favorite = menu.findItem(R.id.action_favorite);
      MenuItem action_share = menu.findItem(R.id.action_share);
      /*
      action_favorite.setIcon(Utility.isFavorited(getActivity(), mMovie.getId()) == 1 ?
              R.drawable.abc_btn_rating_star_on_mtrl_alpha :
              R.drawable.abc_btn_rating_star_off_mtrl_alpha);
      */
      new AsyncTask<Void, Void, Integer>() {
        @Override
        protected Integer doInBackground(Void... params) {
          return Utility.isFavorited(getActivity(), mMovie.getId());
        }

        @Override
        protected void onPostExecute(Integer isFavorited) {
          action_favorite.setIcon(
              isFavorited == 1
                  ? R.drawable.ic_favorite_white_18dp
                  : R.drawable.ic_favorite_border_white_18dp);
        }
      }.execute();

      mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(action_share);

      if (mTrailer != null) {
        mShareActionProvider.setShareIntent(createShareMovieIntent());
      }
    }
  }
Пример #7
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   Fragment fragment = fm.findFragmentById(R.id.fragment_container);
   MenuInflater menuInflater = getMenuInflater();
   // ListView Menu - edit list, get new list, about
   if (fragment instanceof TkkListViewFragment) {
     menuInflater.inflate(R.menu.menu_tkk, menu);
     listEditEnabled = false;
     ((TkkListViewFragment) fragment).getListView().setRearrangeEnabled(false);
   } else if (fragment instanceof TkkWebViewFragment) {
     // WebView Menu - share button
     menuInflater.inflate(R.menu.menu_webview, menu);
     MenuItem item = menu.findItem(R.id.menu_item_share);
     ShareActionProvider mShareActionProvider =
         (ShareActionProvider) MenuItemCompat.getActionProvider(item);
     Intent shareIntent = new Intent(Intent.ACTION_SEND);
     shareIntent.setType("text/plain");
     shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(getString(R.string.app_icon_url)));
     shareIntent.putExtra(Intent.EXTRA_TITLE, getString(R.string.app_name));
     shareIntent.putExtra(
         Intent.EXTRA_TEXT,
         getString(R.string.share_message)
             + " "
             + getString(R.string.subtitle)
             + '\n'
             + fragment.getArguments().getString("name")
             + '\n'
             + getString(R.string.get_message)
             + '\n'
             + getString(R.string.download_url));
     mShareActionProvider.setShareIntent(shareIntent);
   }
   return true;
 }
Пример #8
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_activity_player, menu);

    MenuItem shareItem = menu.findItem(R.id.ss_action_share);
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
    mShareActionProvider.setShareIntent(getDefaultIntent());
    return super.onCreateOptionsMenu(menu);
  }
 public void onLoadFinished(Loader<Drawable> loader, Drawable data) {
   swipeRefreshLayout.setRefreshing(false);
   mImage.setImageDrawable(data);
   try {
     shareAction.setShareIntent(createShareIntent());
   } catch (NullPointerException e) {
     Log.e(TAG, "createShareIntent() returned NULL: " + e.getStackTrace());
   }
 }
Пример #10
0
 private void updateShareIntent() {
   // If the ShareActionProvider has been created in onCreateOptionsMenu() and the movieDetails
   // have
   // been initialized in onLoadFinished(), we can set the shareIntent.
   if (shareActionProvider != null && movieDetails != null && !movieDetails.trailers.isEmpty()) {
     String firstTrailerKey = movieDetails.trailers.get(0).key;
     shareActionProvider.setShareIntent(createShareFirstTrailerIntent(firstTrailerKey));
   }
 }
Пример #11
0
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {
      // Read weather condition ID from cursor
      int weatherId = data.getInt(data.getColumnIndex(WeatherEntry.COLUMN_WEATHER_ID));
      // Use placeholder Image
      mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId));

      // Read date from cursor and update views for day of week and date
      String date = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_DATETEXT));
      String friendlyDateText = Utility.getDayName(getActivity(), date);
      String dateText = Utility.getFormattedMonthDay(getActivity(), date);
      mFriendlyDateView.setText(friendlyDateText);
      mDateView.setText(dateText);

      // Read description from cursor and update view
      String description = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_SHORT_DESC));
      mDescriptionView.setText(description);

      // For accessibility, add a content description to the icon field.
      mIconView.setContentDescription(description);

      // Read high temperature from cursor and update view
      boolean isMetric = Utility.isMetric(getActivity());

      double high = data.getDouble(data.getColumnIndex(WeatherEntry.COLUMN_MAX_TEMP));
      String highString = Utility.formatTemperature(getActivity(), high, isMetric);
      mHighTempView.setText(highString);

      // Read low temperature from cursor and update view
      double low = data.getDouble(data.getColumnIndex(WeatherEntry.COLUMN_MIN_TEMP));
      String lowString = Utility.formatTemperature(getActivity(), low, isMetric);
      mLowTempView.setText(lowString);

      // Read humidity from cursor and update view
      float humidity = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_HUMIDITY));
      mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity));

      // Read wind speed and direction from cursor and update view
      float windSpeedStr = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_WIND_SPEED));
      float windDirStr = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_DEGREES));
      mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr));

      // Read pressure from cursor and update view
      float pressure = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_PRESSURE));
      mPressureView.setText(getActivity().getString(R.string.format_pressure, pressure));

      // We still need this for the share intent
      mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low);

      // If onCreateOptionsMenu has already happened, we need to update the share intent now.
      if (mShareActionProvider != null) {
        mShareActionProvider.setShareIntent(createShareForecastIntent());
      }
    }
  }
Пример #12
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   getMenuInflater().inflate(R.menu.menu_web, menu);
   ShareActionProvider shareActionProvider =
       (ShareActionProvider) MenuItemCompat.getActionProvider(menu.findItem(R.id.menu_share));
   shareActionProvider.setShareIntent(
       AppUtils.makeShareIntent(
           getString(R.string.share_format, mItem.getDisplayedTitle(), mItem.getUrl())));
   return super.onCreateOptionsMenu(menu);
 }
Пример #13
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {

    getMenuInflater().inflate(R.menu.menu_article, menu);

    MenuItem item = menu.findItem(R.id.action_share);
    actionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
    actionProvider.setShareIntent(shareIntent);
    return true;
  }
Пример #14
0
 public boolean onCreateOptionsMenu(Menu menu) {
   // Inflate the menu items for use in the action bar
   MenuInflater inflater = getMenuInflater();
   inflater.inflate(R.menu.product_detail, menu);
   // Get the menu item.
   MenuItem menuItem = menu.findItem(R.id.action_share);
   // Get the provider and hold onto it to set/change the share intent.
   mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
   mShareActionProvider.setShareIntent(getDefaultIntent());
   return super.onCreateOptionsMenu(menu);
 }
Пример #15
0
  private void setShareIntent(int position) {

    if (mShareActionProvider != null) {
      // Get the currently selected item, and retrieve it's share intent
      ContentItem item = mItems.get(position);
      Intent shareIntent = item.getShareIntent(MainActivity.this);

      // Now update the ShareActionProvider with the new share intent
      mShareActionProvider.setShareIntent(shareIntent);
    }
  }
Пример #16
0
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (!data.moveToFirst()) return;
    transformCursorData(data);
    fillUI();
    if (mShareActionProvider != null) {
      mShareActionProvider.setShareIntent(createShareIntent());
    }
    // Adjust Image View on Phone

  }
Пример #17
0
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.detailfragment, menu);

    MenuItem shareItem = menu.findItem(R.id.action_share);
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);

    if (mForecast != null) {
      mShareActionProvider.setShareIntent(createShareForecastIntent());
    }
  }
Пример #18
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   // Inflate the menu; this adds items to the action bar if it is present.
   getMenuInflater().inflate(R.menu.menu_main, menu);
   MenuItem miShare = menu.findItem(R.id.action_share);
   shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(miShare);
   Intent intent = new Intent(Intent.ACTION_SEND);
   intent.setType("text/plain");
   intent.putExtra(Intent.EXTRA_TEXT, "this is an test text");
   shareActionProvider.setShareIntent(intent);
   return super.onCreateOptionsMenu(menu);
 }
Пример #19
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.about_menu, menu);

    // 定位使用ShareActionProvider的菜单项
    MenuItem item = menu.findItem(R.id.shareMenuItem);
    shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
    shareActionProvider.setShareIntent(shareIntent);

    return super.onCreateOptionsMenu(menu);
  }
Пример #20
0
  private void setShareIntent() {

    // create an Intent with the contents of the TextView
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Book Recommendation!");
    shareIntent.putExtra(Intent.EXTRA_TEXT, mImageURL);

    // Make sure the provider knows
    // it should work with that Intent
    mShareActionProvider.setShareIntent(shareIntent);
  }
 @Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   inflater.inflate(R.menu.detail_fragment, menu);
   MenuItem menuItem = menu.findItem(R.id.action_share);
   ShareActionProvider mShareActionProvider =
       (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
   if (mShareActionProvider != null) {
     mShareActionProvider.setShareIntent(createShareIntent());
   } else {
     Log.d(TAG, "Share action provider is null?");
   }
 }
Пример #22
0
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.book_detail, menu);

    MenuItem menuItem = menu.findItem(R.id.action_share);
    shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
    if (shareActionProvider != null) {
      shareActionProvider.setShareIntent(createShareIntent(null));
    } else {
      Log.e(LOG_TAG, "Share Action Provider is null?");
    }
  }
  @Override
  public void onLoadFinished(android.support.v4.content.Loader<Cursor> loader, Cursor data) {
    if (!data.moveToFirst()) {
      return;
    }

    bookTitle = data.getString(data.getColumnIndex(AlexandriaContract.BookEntry.TITLE));
    ((TextView) rootView.findViewById(R.id.fullBookTitle)).setText(bookTitle);

    // Catering for any possibility of null values below
    if (shareActionProvider != null) {
      Intent shareIntent = new Intent(Intent.ACTION_SEND);
      shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
      shareIntent.setType("text/plain");
      shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_text) + bookTitle);
      shareActionProvider.setShareIntent(shareIntent);
    }

    String bookSubTitle =
        data.getString(data.getColumnIndex(AlexandriaContract.BookEntry.SUBTITLE));
    if (bookSubTitle != null) {
      ((TextView) rootView.findViewById(R.id.fullBookSubTitle)).setText(bookSubTitle);
    }

    String desc = data.getString(data.getColumnIndex(AlexandriaContract.BookEntry.DESC));
    if (desc != null) {
      ((TextView) rootView.findViewById(R.id.fullBookDesc)).setText(desc);
    }

    String authors = data.getString(data.getColumnIndex(AlexandriaContract.AuthorEntry.AUTHOR));
    if (authors != null) {
      String[] authorsArr = authors.split(",");
      ((TextView) rootView.findViewById(R.id.authors)).setLines(authorsArr.length);
      ((TextView) rootView.findViewById(R.id.authors)).setText(authors.replace(",", "\n"));
    }

    String imgUrl = data.getString(data.getColumnIndex(AlexandriaContract.BookEntry.IMAGE_URL));
    if (imgUrl != null && Patterns.WEB_URL.matcher(imgUrl).matches()) {
      new DownloadImage((ImageView) rootView.findViewById(R.id.fullBookCover)).execute(imgUrl);
      rootView.findViewById(R.id.fullBookCover).setVisibility(View.VISIBLE);
    }

    String categories =
        data.getString(data.getColumnIndex(AlexandriaContract.CategoryEntry.CATEGORY));
    ((TextView) rootView.findViewById(R.id.categories)).setText(categories);

    // REmoving uneccessary button
    /*if(rootView.findViewById(R.id.right_container)!=null){
        rootView.findViewById(R.id.backButton).setVisibility(View.INVISIBLE);
    }*/

  }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   getMenuInflater().inflate(R.menu.image, menu);
   MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
   if (ActionBarUtil.hasSB()) {
     MenuItemCompat.setShowAsAction(actionItem, MenuItemCompat.SHOW_AS_ACTION_NEVER);
   }
   ShareActionProvider actionProvider =
       (ShareActionProvider) MenuItemCompat.getActionProvider(actionItem);
   actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
   actionProvider.setShareIntent(createShareIntent());
   return super.onCreateOptionsMenu(menu);
 }
 public void setShareIntent(ClimbingArea area) {
   if (menu != null) {
     MenuItem shareItem = menu.findItem(R.id.menu_item_details_share);
     ShareActionProvider mShareActionProvider =
         (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
     Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
     sharingIntent.setType(AppConstants.MIME_TEXT_PLAIN);
     String shareBody = "";
     sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Klettergebiet Empfehlung");
     sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
     mShareActionProvider.setShareIntent(sharingIntent);
   }
 }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.share_action_provider, menu);

    // Set file with share history to the provider and set the share intent.
    MenuItem menuItem_Share = menu.findItem(R.id.action_share);
    ShareActionProvider shareAction =
        (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem_Share);
    shareAction.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
    // Note that you can set/change the intent any time,
    // say when the user has selected an image.
    shareAction.setShareIntent(createShareIntent());
  }
Пример #27
0
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.detailfragment, menu);
    MenuItem item = menu.findItem(R.id.action_share);
    shareProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);

    // The provider needs to store an intent when it is loaded!  It is not handled via
    // onOptionsItemSelected
    if (detailString != null) {
      shareProvider.setShareIntent(createForecastShareIntent());
    }
  }
Пример #28
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_music_player, menu);

    MenuItem item = menu.findItem(R.id.share);
    shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);

    if (trackInfo.getPreviewURL() != null) {
      shareActionProvider.setShareIntent(createShareIntent());
    }
    return true;
  }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.main, menu);

    MenuItem menuItem = menu.findItem(R.id.action_share);

    shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);

    if (textView.getText().toString() != null) {

      shareActionProvider.setShareIntent(createShareConstitutionIntent());
    }
  }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.menu_fragement_detail, menu);

    MenuItem menuItem = menu.findItem(R.id.action_share);

    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
    //        mShareActionProvider.setShareHistoryFileName(null);

    if (mShare != null) {
      mShareActionProvider.setShareIntent(createShareTrailerIntent());
    }
  }