コード例 #1
0
  public void AddtoFav(int position) {

    Image_catName = mAllImageCatName[position];
    Image_Url = mAllImages[position];

    db.AddtoFavorite(new Pojo(Image_catName, Image_Url));
    Toast.makeText(getApplicationContext(), "Added to Favorite", Toast.LENGTH_SHORT).show();
    menu.getItem(3).setIcon(getResources().getDrawable(R.drawable.fav_hover));
  }
コード例 #2
0
  public void FirstFav() {
    int first = viewpager.getCurrentItem();
    String Image_id = mAllImages[first];

    List<Pojo> pojolist = db.getFavRow(Image_id);
    if (pojolist.size() == 0) {
      menu.getItem(3).setIcon(getResources().getDrawable(R.drawable.fav));

    } else {
      if (pojolist.get(0).getImageurl().equals(Image_id)) {
        menu.getItem(3).setIcon(getResources().getDrawable(R.drawable.fav_hover));
      }
    }
  }
コード例 #3
0
 // remove from favorite
 public void RemoveFav(int position) {
   Image_Url = mAllImages[position];
   db.RemoveFav(new Pojo(Image_Url));
   Toast.makeText(getApplicationContext(), "Removed from Favorite", Toast.LENGTH_SHORT).show();
   menu.getItem(3).setIcon(getResources().getDrawable(R.drawable.fav));
 }
コード例 #4
0
  @Override
  public boolean onOptionsItemSelected(MenuItem menuItem) {
    switch (menuItem.getItemId()) {
      case android.R.id.home:
        onBackPressed();
        return true;

      case R.id.menu_back:
        position = viewpager.getCurrentItem();
        position--;
        if (position < 0) {
          position = 0;
        }
        viewpager.setCurrentItem(position);

        return true;

      case R.id.menu_next:
        position = viewpager.getCurrentItem();
        position++;
        if (position == TOTAL_IMAGE) {
          position = TOTAL_IMAGE;
        }
        viewpager.setCurrentItem(position);

        return true;

      case R.id.menu_play:
        if (Play_Flag) {
          handler.removeCallbacks(Update);
          menuItem.setIcon(getResources().getDrawable(R.drawable.play));
          Play_Flag = false;
          ShowMenu();
        } else {
          /*
           * when Play_Flag false then Play but when image is last not
           * start auto play now hide all menu when auto play start
           */
          if (viewpager.getCurrentItem() == TOTAL_IMAGE) {
            Toast.makeText(
                    getApplicationContext(),
                    "Currently Last Image!! Not Start Auto Play",
                    Toast.LENGTH_SHORT)
                .show();
          } else {
            AutoPlay();
            menuItem.setIcon(getResources().getDrawable(R.drawable.stop));
            Play_Flag = true;
            HideMenu();
          }
        }
        return true;

      case R.id.menu_fav:
        position = viewpager.getCurrentItem();

        Image_Url = mAllImages[position];

        List<Pojo> pojolist = db.getFavRow(Image_Url);
        if (pojolist.size() == 0) {
          AddtoFav(position); // if size is zero i.e means that record not
          // in database show add to favorite
        } else {
          if (pojolist.get(0).getImageurl().equals(Image_Url)) {
            RemoveFav(position);
          }
        }

        return true;

      case R.id.menu_overflow:
        // just override click
        return true;
      case R.id.menu_make_meme:
        String ImgURL =
            Constant.SERVER_IMAGE_UPFOLDER_CATEGORY
                + mAllImageCatName[position]
                + "/"
                + mAllImages[viewpager.getCurrentItem()];
        Intent i = new Intent(this, MemeActivity.class);
        i.putExtra("URL", ImgURL);
        startActivity(i);
        return true;
      case R.id.menu_share:
        position = viewpager.getCurrentItem();

        (new ShareTask(SlideImageActivity.this))
            .execute(
                Constant.SERVER_IMAGE_UPFOLDER_CATEGORY
                    + mAllImageCatName[position]
                    + "/"
                    + mAllImages[position]);

        return true;

      case R.id.menu_save:
        position = viewpager.getCurrentItem();

        (new SaveTask(SlideImageActivity.this, false))
            .execute(
                Constant.SERVER_IMAGE_UPFOLDER_CATEGORY
                    + mAllImageCatName[position]
                    + "/"
                    + mAllImages[position]);

        return true;

      case R.id.menu_setaswallaper:
        position = viewpager.getCurrentItem();
        Intent intwall = new Intent(getApplicationContext(), SetAsWallpaperActivity.class);
        intwall.putExtra("WALLPAPER_IMAGE_URL", mAllImages);
        intwall.putExtra("WALLPAPER_IMAGE_CATEGORY", mAllImageCatName);
        intwall.putExtra("POSITION_ID", position);
        startActivity(intwall);

        return true;
      case R.id.menu_editbyapp:
        position = viewpager.getCurrentItem();

        (new SaveTask(SlideImageActivity.this, true))
            .execute(
                Constant.SERVER_IMAGE_UPFOLDER_CATEGORY
                    + mAllImageCatName[position]
                    + "/"
                    + mAllImages[position]);
        return true;
      case R.id.menu_zoom:
        position = viewpager.getCurrentItem();
        Intent intzoom = new Intent(getApplicationContext(), PinchZoom.class);
        intzoom.putExtra("ZOOM_IMAGE_URL", mAllImages);
        intzoom.putExtra("ZOOM_IMAGE_CATEGORY", mAllImageCatName);
        intzoom.putExtra("POSITION_ID", position);
        startActivity(intzoom);

        return true;

      default:
        return super.onOptionsItemSelected(menuItem);
    }
  }