示例#1
0
    public void bind(@NonNull final Movie movie) {
      mFavoriteButton.setSelected(movie.isFavorited());
      mMovieItemTitle.setText(movie.getTitle());
      mMovieItemContainer.setOnClickListener(
          v -> BusProvider.getInstance().post(new OnMovieClickedEvent(movie, itemView)));
      mFavoriteButton.setOnClickListener(
          v -> {
            BusProvider.getInstance()
                .post(new FavoriteClickedEvent(movie, MovieViewHolder.this.getAdapterPosition()));
            mFavoriteButton.setSelected(movie.isFavorited());
          });
      // stop that blinking ish
      if (mMovieId != movie.getId()) {
        resetColors();
        mMovieId = movie.getId();
      }

      Glide.with(itemView.getContext())
          .load("http://image.tmdb.org/t/p/w185/" + movie.getPosterPath())
          .crossFade()
          .placeholder(R.color.movie_poster_placeholder)
          .listener(
              GlidePalette.with(movie.getPosterPath())
                  .intoCallBack(palette -> applyColors(palette.getVibrantSwatch())))
          .into(mMovieItemImage);
    }
示例#2
0
 private void setFeatureMode(FeatureMode featureMode) {
   if (featureMode != mFeatureMode) {
     mFeatureMode = featureMode;
     mWeatherModeBtn.setSelected(mFeatureMode == FeatureMode.WEATHER);
     mTemperatureModeBtn.setSelected(mFeatureMode == FeatureMode.TEMPERATURE);
     mMarkersAdapter.setFeatureMode(mFeatureMode);
     reloadMap();
   }
 }
  private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {

      View v = tabsContainer.getChildAt(i);

      v.setBackgroundResource(!tabSwitch ? tabBackgroundResId : transparentColorId);

      if (v instanceof TextView) {

        TextView tab = (TextView) v;
        tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
        tab.setTypeface(tabTypeface, tabTypefaceStyle);
        tab.setTextColor(tabSwitch && i != 0 ? tabDeactivateTextColor : tabTextColor);

        // setAllCaps() is only available from API 14, so the upper case is made manually if we are
        // on a
        // pre-ICS-build
        if (textAllCaps) {
          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            tab.setAllCaps(true);
          } else {
            tab.setText(tab.getText().toString().toUpperCase(locale));
          }
        }
      } else if (v instanceof ImageButton) {
        ImageButton tab = (ImageButton) v;
        tab.setSelected(tabSwitch && i == 0);
      }
    }
  }
 private void setInitial(final View view) {
   btn_header = (ImageButton) view.findViewById(R.id.btn_header);
   btn_qrcode = (ImageButton) view.findViewById(R.id.btn_qrcode);
   btn_valid = (Button) view.findViewById(R.id.btn_valid);
   txt_code = (EditText) view.findViewById(R.id.txt_code);
   setEventListener();
   btn_header.setSelected(Home.instance.isPopHeader());
 }
示例#5
0
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mMapView = (MapView) view.findViewById(R.id.map);
    mMapView.onCreate(savedInstanceState != null ? savedInstanceState.getBundle(STATE_MAP) : null);
    mMapView.getMapAsync(this);

    mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
    ((AppCompatActivity) getActivity()).setSupportActionBar(mToolbar);
    mWeatherModeBtn = (ImageButton) view.findViewById(R.id.feature_mode_weather_btn);
    mWeatherModeBtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            setFeatureMode(FeatureMode.WEATHER);
          }
        });
    mTemperatureModeBtn = (ImageButton) view.findViewById(R.id.feature_mode_temperature_btn);
    mTemperatureModeBtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            setFeatureMode(FeatureMode.TEMPERATURE);
          }
        });
    mLogoView = view.findViewById(R.id.logo);

    mPostButton = view.findViewById(R.id.post_button);
    mPostButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            showPostFragment(null);
          }
        });
    if (getHomeFragment() != null) {
      showHomeFragment();
    } else if (getPostFragment() != null) {
      showPostFragment(null);
    }

    if (savedInstanceState == null) {
      Bundle args = getArguments();
      if (args != null) {
        if (args.getBoolean(ARG_SHOW_HOME)) showHomeFragment();
        else if (args.getBoolean(ARG_SHOW_POST)) showPostFragment(args);
        else if (args.containsKey(ARG_LOCATION)) {
          mMapLocation = args.getParcelable(ARG_LOCATION);
        }
      }
      mWeatherModeBtn.setSelected(true);
    }
  }
 @Override
 public void dismiss() {
   tab_menu.setSelected(false);
   tab_menu.setBackgroundResource(R.drawable.tab_menu_default);
   super.dismiss();
 }
示例#7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_single_drink);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

    // Navigation Drawer
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(
            this,
            drawer,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    drinkImage = (ImageView) findViewById(R.id.drinkImage);
    ingredientsList = (ListView) findViewById(R.id.SingleDrinkIngredients);
    drinkName = (TextView) findViewById(R.id.name);
    favorite = (ImageButton) findViewById(R.id.favorite_button);
    instructions = (TextView) findViewById(R.id.instructions);

    Bundle extras = getIntent().getExtras();
    final String dotd = extras.getString("RECIPE_ID");

    Cursor CR2 = favs.getInfo(favs);
    if (CR2 != null && CR2.getCount() > 0) {
      CR2.moveToFirst();
      String data = "";
      do {
        data += CR2.getString(0) + '\n';
      } while (CR2.moveToNext());
      Scanner scan = new Scanner(data);
      do {
        if (Objects.equals(scan.nextLine(), dotd)) favorite.setSelected(true);
      } while (scan.hasNextLine());
    }
    APIClient.getDrinkProvider()
        .getDOTDRecipeById(dotd)
        .subscribeOn(Schedulers.newThread())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(
            new Subscriber<DrinkSearchResultModel>() {

              @Override
              public void onCompleted() {}

              @Override
              public void onError(Throwable e) {
                int i = 0;
              }

              @Override
              public void onNext(DrinkSearchResultModel searchResultModel) {
                drinkName.setText(searchResultModel.drinks.get(0).drinkName);
                ingredientsList.setAdapter(
                    new IngredientListAdapter(
                        getBaseContext(), searchResultModel.drinks.get(0).getIngredients()));
                Picasso.with(getBaseContext())
                    .load(searchResultModel.drinks.get(0).thumbnail)
                    .placeholder(R.drawable.icon)
                    .resize(400, 400)
                    .into(drinkImage);
                instructions.setText(searchResultModel.drinks.get(0).instructions);
              }
            });

    favorite.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (favorite.isSelected()) {
              favorite.setSelected(false);
              favs.deleteFavorite(favs, dotd);
            } else {
              favorite.setSelected(true);
              favs.insertFavorite(favs, dotd);
            }
          }
        });
  }
 public void unselectPanelButtons(Vector<ImageButton> buttons) {
   for (ImageButton button : buttons) {
     button.setSelected(false);
   }
 }
 public void unselectBottomPanelButtons() {
   for (ImageButton button : mBottomPanelButtons) {
     button.setSelected(false);
   }
 }