コード例 #1
0
ファイル: AddActivity.java プロジェクト: Ertyguy/ContTent
  private void addThumbnail(String thumbnail) {
    if (!Var.isEmpty(thumbnail)) {
      userPictureThumbnails.add(thumbnail);

      if (Var.isEmpty(editUser.getThumbnail())) {
        editUser.setThumbnail(userPictureThumbnails.get(0));
        userPicture_sp.setSelection(0);
      }

      iconAdapter.notifyDataSetChanged();
    }
  }
コード例 #2
0
ファイル: AddActivity.java プロジェクト: Ertyguy/ContTent
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    if (searchMode == Var.SEARCH_YOUTUBE) {
      searchChannel = youtubeChannelSearch.get(position - 1);
      Log.d(TAG, searchChannel.toString());

      addThumbnail(searchChannel.getThumbnail());
      if (Var.isEmpty(userName_edt.getText().toString()))
        userName_edt.setText(searchChannel.getName());
      name_tv.setText(searchChannel.getName());
      imageLoader.DisplayImage(searchChannel.getThumbnail(), thumbnail_iv);

      toggleSearch(Var.SEARCH_YT_CHANNEL);
      searchChannel();
    }

    if (searchMode == Var.SEARCH_TWITTER) {
      editUser.getMediaFeed().add(twitterFeedSearch.get(position - 1));
      addThumbnail(twitterFeedSearch.get(position - 1).getThumbnail());

      if (Var.isEmpty(userName_edt.getText().toString()))
        userName_edt.setText(twitterFeedSearch.get(position - 1).getDisplayName());

      toggleSearch(Var.SEARCH_NONE);
    }
  }
コード例 #3
0
ファイル: AddActivity.java プロジェクト: Ertyguy/ContTent
  @Override
  public void onClick(View v) {
    Log.d(TAG, "onclick " + (v == action_fab) + ", " + searchMode);
    if (v == search_fab) {
      if (searchMode == Var.SEARCH_NONE) toggleSearch(Var.SEARCH_OPTIONS);
      else if (searchMode == Var.SEARCH_OPTIONS) toggleSearch(Var.SEARCH_NONE);
    }

    if (v == action_fab) {
      if (searchMode == Var.SEARCH_YT_CHANNEL) {
        SparseBooleanArray checked = search_lv.getCheckedItemPositions();
        for (int i = 0; i < checked.size(); i++) {
          if (checked.valueAt(i) == true) {
            YoutubeFeed youtubeFeed = (YoutubeFeed) search_lv.getItemAtPosition(checked.keyAt(i));
            youtubeFeed.setChannelHandle(searchChannel.getFeedId());
            editUser.getMediaFeed().add(youtubeFeed);
          }
        }

        feedAdapter.notifyDataSetChanged();
        clearSearchOptions();

        toggleSearch(Var.SEARCH_NONE);
      } else if (searchMode == Var.SEARCH_NONE) {

        editUser.setName(userName_edt.getText().toString().trim());
        editUser.setNotification(notification_sw.isChecked());
        editUser.setThumbnail((String) userPicture_sp.getSelectedItem());

        UserORM.saveUser(this, editUser);

        finish();
      }
    }
    if (v == youtube_ll) toggleSearch(Var.SEARCH_YOUTUBE);
    if (v == twitter_ll) toggleSearch(Var.SEARCH_TWITTER);
    if (v == search_v) toggleSearch(Var.SEARCH_NONE);
    if (v == searchTwitterLogin_tv) {
      twitter.resetAccessToken();
      if (!twitter.hasAccessToken()) twitter.authorize();
      // Hide the signin
      searchTwitter_v.setVisibility(View.GONE);
      searchDiv_v.setVisibility(View.GONE);
    }
    if (v == clearSearch_iv) search_edt.getText().clear();
  }
コード例 #4
0
ファイル: AddActivity.java プロジェクト: Ertyguy/ContTent
  private void toggleSearch(int searchMode) {
    this.searchMode = searchMode;

    search_v.setVisibility(searchModePreSearch() ? View.GONE : View.VISIBLE);
    searchTwitter_v.setVisibility(
        (searchMode == Var.SEARCH_TWITTER && !twitter.hasAccessToken()) ? View.VISIBLE : View.GONE);
    searchDiv_v.setVisibility(
        (searchMode == Var.SEARCH_TWITTER && twitter.hasAccessToken()) ? View.GONE : View.VISIBLE);
    youtube_ll.setVisibility((searchMode == Var.SEARCH_OPTIONS) ? View.VISIBLE : View.GONE);
    twitter_ll.setVisibility((searchMode == Var.SEARCH_OPTIONS) ? View.VISIBLE : View.GONE);
    channel_v.setVisibility((searchMode == Var.SEARCH_YT_CHANNEL) ? View.VISIBLE : View.GONE);
    search_fab.setVisibility(
        (searchModePreSearch() || searchMode == Var.SEARCH_YT_CHANNEL) ? View.VISIBLE : View.GONE);
    search_fab.setDrawable(
        getResources()
            .getDrawable(
                searchMode == Var.SEARCH_YT_CHANNEL
                    ? R.drawable.ic_add_white_18dp
                    : R.drawable.ic_search_white_24dp));

    search_lv.setChoiceMode(
        (searchMode == Var.SEARCH_YT_CHANNEL)
            ? ListView.CHOICE_MODE_MULTIPLE
            : ListView.CHOICE_MODE_SINGLE);

    if (searchMode == Var.SEARCH_NONE) {
      dismissSearch();
      // searchView.setQuery("", false);
      // searchView.setVisibility(View.GONE);
      search_rl.setVisibility(View.GONE);
      search_edt.getText().clear();

      action_fab.setVisibility((editUser.getMediaFeed().size() > 0) ? View.VISIBLE : View.GONE);
      search_lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
      youtubeChannelSearch.clear();
      twitterFeedSearch.clear();
      searchAdapter.notifyDataSetChanged();
    }
    if (searchMode == Var.SEARCH_YT_CHANNEL) {
      dismissSearch();
      action_fab.setVisibility(View.VISIBLE);
      search_lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
      clearSearchOptions();
    } else if (searchMode == Var.SEARCH_YOUTUBE || searchMode == Var.SEARCH_TWITTER) {
      // if(searchItem != null) {
      // searchView.setQueryHint(getResources().getString((searchMode == Var.SEARCH_YOUTUBE) ?
      // R.string.search_youtube : R.string.search_twitter));
      // searchView.setIconified(false);
      // searchView.setVisibility(View.VISIBLE);
      // searchView.requestFocusFromTouch();
      search_edt.setHint(
          (searchMode == Var.SEARCH_YOUTUBE) ? R.string.search_youtube : R.string.search_twitter);
      search_rl.setVisibility(View.VISIBLE);
      search_rl.requestFocus();
      // }
    }
    if (searchModePreSearch()) {
      search_fab.setDrawable(
          getResources()
              .getDrawable(
                  searchMode == Var.SEARCH_NONE
                      ? R.drawable.ic_search_white_24dp
                      : R.drawable.ic_close_white_36dp));
    }
  }