private void createMenuButton() {
    mMenuButton = new FloatingActionButton(getContext());

    mMenuButton.mShowShadow = mMenuShowShadow;
    if (mMenuShowShadow) {
      mMenuButton.mShadowRadius = Util.dpToPx(getContext(), mMenuShadowRadius);
      mMenuButton.mShadowXOffset = Util.dpToPx(getContext(), mMenuShadowXOffset);
      mMenuButton.mShadowYOffset = Util.dpToPx(getContext(), mMenuShadowYOffset);
    }
    mMenuButton.setColors(mMenuColorNormal, mMenuColorPressed, mMenuColorRipple);
    mMenuButton.mShadowColor = mMenuShadowColor;
    mMenuButton.mFabSize = mMenuFabSize;
    mMenuButton.updateBackground();

    mMenuButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            toggle(mIsAnimated);
          }
        });

    mImageToggle = new ImageView(getContext());
    mImageToggle.setImageDrawable(mIcon);

    addView(mMenuButton, super.generateDefaultLayoutParams());
    addView(mImageToggle);

    createDefaultIconAnimation();
  }
Exemplo n.º 2
0
 @Override
 public boolean onDependentViewChanged(
     CoordinatorLayout parent, FloatingActionButton fab, View dependency) {
   if (dependency instanceof AppBarLayout) {
     CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
     int fabBottomMargin = lp.bottomMargin;
     int distanceToScroll = fab.getHeight() + fabBottomMargin;
     float ratio = dependency.getY() / (float) toolbarHeight;
     fab.setTranslationY(-distanceToScroll * ratio);
   }
   return true;
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_complete_info);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    Intent intent = getIntent();
    Bundle bundle = intent.getExtras();
    if (bundle == null) {
      finish();
      return;
    } else {
      ORG_ID = bundle.getInt("id");
    }
    Log.i(TAG, String.valueOf(ORG_ID));
    setVars();
    nextUrl = nextUrl + ORG_ID;
    if (nextUrl.contains(" ")) {
      nextUrl = nextUrl.replaceAll(" ", "%20");
    }
    //        ***************** LOG.i *****************
    Log.i(TAG, nextUrl);
    new CompleteData().execute();

    floatingActionButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            startActivity(new Intent(getApplicationContext(), NeedsList.class));
          }
        });
  }
Exemplo n.º 4
0
  @Override
  public void setFloatActionButton() {
    // 今天按钮的操作
    today.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            //                Toast.makeText(MainActivity.this , "今天" , Toast.LENGTH_SHORT).show();
            mPresenter.startNewActivity(0);
            closeFloatActionButton();
          }
        });
    // 明天按钮的操作
    tomorrow.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mPresenter.startNewActivity(1);
            closeFloatActionButton();
            //                Toast.makeText(MainActivity.this , "tomorrow" ,
            // Toast.LENGTH_SHORT).show();
          }
        });

    // 收集
    collection.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mPresenter.startNewActivity(2);
            closeFloatActionButton();
            //                Toast.makeText(MainActivity.this, "collection",
            // Toast.LENGTH_SHORT).show();
          }
        });

    // 定制
    book.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mPresenter.startNewActivity(3);
            closeFloatActionButton();
            //                Toast.makeText(MainActivity.this, "book", Toast.LENGTH_SHORT).show();
          }
        });
  }
  private void createLabels() {
    Context context = new ContextThemeWrapper(getContext(), mLabelsStyle);

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

      if (getChildAt(i) == mImageToggle) continue;

      final FloatingActionButton fab = (FloatingActionButton) getChildAt(i);
      String text = fab.getLabelText();

      if (fab == mMenuButton || TextUtils.isEmpty(text) || fab.getTag(R.id.fab_label) != null) {
        continue;
      }

      final Label label = new Label(context);
      label.setFab(fab);
      label.setShowAnimation(AnimationUtils.loadAnimation(getContext(), mLabelsShowAnimation));
      label.setHideAnimation(AnimationUtils.loadAnimation(getContext(), mLabelsHideAnimation));

      if (mLabelsStyle > 0) {
        label.setTextAppearance(getContext(), mLabelsStyle);
        label.setShowShadow(false);
        label.setUsingStyle(true);
      } else {
        label.setColors(mLabelsColorNormal, mLabelsColorPressed, mLabelsColorRipple);
        label.setShowShadow(mLabelsShowShadow);
        label.setCornerRadius(mLabelsCornerRadius);
        if (mLabelsEllipsize > 0) {
          setLabelEllipsize(label);
        }
        label.setMaxLines(mLabelsMaxLines);
        label.updateBackground();

        label.setTextSize(TypedValue.COMPLEX_UNIT_PX, mLabelsTextSize);
        label.setTextColor(mLabelsTextColor);

        int left = mLabelsPaddingLeft;
        int top = mLabelsPaddingTop;
        if (mLabelsShowShadow) {
          left += fab.getShadowRadius() + Math.abs(fab.getShadowXOffset());
          top += fab.getShadowRadius() + Math.abs(fab.getShadowYOffset());
        }

        label.setPadding(left, top, mLabelsPaddingLeft, mLabelsPaddingTop);

        if (mLabelsMaxLines < 0 || mLabelsSingleLine) {
          label.setSingleLine(mLabelsSingleLine);
        }
      }

      label.setText(text);

      addView(label);
      fab.setTag(R.id.fab_label, label);
    }
  }
 private void showMenuButtonWithImage(boolean animate) {
   if (isMenuButtonHidden()) {
     mMenuButton.show(animate);
     if (animate) {
       mImageToggle.startAnimation(mMenuButtonShowAnimation);
     }
     mImageToggle.setVisibility(VISIBLE);
   }
 }
 private void hideMenuButtonWithImage(boolean animate) {
   if (!isMenuButtonHidden()) {
     mMenuButton.hide(animate);
     if (animate) {
       mImageToggle.startAnimation(mMenuButtonHideAnimation);
     }
     mImageToggle.setVisibility(INVISIBLE);
     mIsMenuButtonAnimationRunning = false;
   }
 }
Exemplo n.º 8
0
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   View rootView = inflater.inflate(R.layout.blog_fragment_main, container, false);
   ButterKnife.inject(this, rootView);
   vpDate.setAdapter(new BlogFragmentListAdapter(getChildFragmentManager()));
   tabs.setViewPager(vpDate);
   tabs.setTextColor(Color.WHITE);
   tabs.setBackgroundColor(getResources().getColor(R.color.blue));
   write.setOnClickListener(v -> startActivity(new Intent(getActivity(), WriteActivity.class)));
   return rootView;
 }
Exemplo n.º 9
0
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    Activity a = getActivity();

    questionList = (RecyclerView) a.findViewById(R.id.fragment_my_questions_list);
    text = (FloatingActionButton) a.findViewById(R.id.menu_item_text);
    image = (FloatingActionButton) a.findViewById(R.id.menu_item_image);
    video = (FloatingActionButton) a.findViewById(R.id.menu_item_video);

    final LinearLayoutManager layoutManager =
        new LinearLayoutManager(getActivity().getApplicationContext());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    questionList.setLayoutManager(layoutManager);

    questionList.setAdapter(new MyQuestionsListAdapter(getContext()));

    text.setOnClickListener(this);
    image.setOnClickListener(this);
    video.setOnClickListener(this);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
    super.onCreate(savedInstanceState);
    Intent data = getIntent();
    earthWallpaper = (EarthWallpaper) data.getExtras().getSerializable(WALLPAPER_OBJECT);
    // setTheme(R.style.AppTheme_NoActionBar);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
      setTheme(R.style.AppTheme_NoActionBar);
    }
    setContentView(R.layout.activity_wallpaper);

    downloadDialog = new BaseDialog(this).getDownloadDialog();

    if (!downloadDir.exists()) {
      boolean created = downloadDir.mkdir();
      Log.d("WallpaperActivity", "Download directory didn't exist : creation -> " + created);
    }

    if (!Preferences.exists()) Preferences.init(this);

    downloadDir = new File(Preferences.getInstance().getWallpaperDownloadDirectory());

    rootLayout = (CoordinatorLayout) findViewById(R.id.wallpaper_coordinator_root);
    collapsingToolbarLayout =
        (CollapsingToolbarLayout) findViewById(R.id.wallpaper_collapsing_toolbar);
    // collapsingToolbarLayout.setExpandedTitleTextAppearance(android.R.style.TextAppearance_DeviceDefault_Medium);
    collapsingToolbarLayout.setExpandedTitleTextAppearance(R.style.FullscreenTextPreview);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_details_view);
    toolbar.setTitle(earthWallpaper.getFormattedWallpaperTitle());
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // set and load the appbar image
    appBarImage = (ImageView) findViewById(R.id.wall_preview);
    Picasso.with(this).load(earthWallpaper.getWallThumbUrl()).into(appBarImage);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      appBarImage.setTransitionName(data.getExtras().getString(IMAGE_TRANSITION_NAME));
      // toolbar.setTransitionName(data.getExtras().getString(TEXT_TRANSITION_NAME));
    }

    // assigning the information to the views
    cityTextView = (TextView) findViewById(R.id.details_location_text);
    if (earthWallpaper.getWallpaperRegion() == null) {
      cityTextView.setText(R.string.details_unknown);
    } else {
      cityTextView.setText(earthWallpaper.getWallpaperRegion());
    }
    countryTextView = (TextView) findViewById(R.id.details_country_text);
    if (earthWallpaper.getWallpaperCountry() == null) {
      countryTextView.setText(R.string.details_unknown);
    } else {
      countryTextView.setText(earthWallpaper.getWallpaperCountry());
    }
    coordinatesTextView = (TextView) findViewById(R.id.details_coords_text);
    coordinatesTextView.setText(getFormattedCoordinates());

    // setting the google maps layout stuff
    googleMapsLayout = (RelativeLayout) findViewById(R.id.gmaps_nav_layout);
    googleMapsLayout.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent googleMaps =
                new Intent(Intent.ACTION_VIEW, Uri.parse(earthWallpaper.getGoogleMapsUrl()));
            startActivity(googleMaps);
          }
        });
    googleMapsHintTextView = (TextView) findViewById(R.id.details_gmaps_link_icon_text);
    googleMapsHintTextView.setText(earthWallpaper.getGoogleMapsTitle());

    final int[] c = {0};
    attributionLayout = (RelativeLayout) findViewById(R.id.details_attribution_layout);
    attributionLayout.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            c[0]++;
            if (c[0] >= 20) unlock = true;
          }
        });

    attributionTextView = (TextView) findViewById(R.id.details_attribution_text);
    if (earthWallpaper.getWallpaperAttribution() == null) {
      attributionTextView.setText(R.string.details_unknown);
    } else {
      attributionTextView.setText(earthWallpaper.getWallpaperAttribution());
    }

    shareLinkLayout = (RelativeLayout) findViewById(R.id.share_link_layout);
    shareLinkLayout.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onEarthViewShow();
          }
        });

    shareLinkTextView = (TextView) findViewById(R.id.details_share_link_text);
    shareLinkTextView.setText(earthWallpaper.getShareUrl());

    // inflating the fab menu and it's entries
    floatingActionMenu = (FloatingActionMenu) findViewById(R.id.details_fab_menu);
    floatingActionMenu.setClosedOnTouchOutside(true);

    floatingActionShare = (FloatingActionButton) findViewById(R.id.fab_item_share);
    floatingActionShare.setImageDrawable(
        new IconicsDrawable(this)
            .icon(CommunityMaterial.Icon.cmd_share_variant)
            .color(Color.WHITE)
            .sizeDp(16));
    floatingActionShare.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onEarthViewShare();
            if (floatingActionMenu.isOpened()) floatingActionMenu.close(true);
          }
        });

    floatingActionApply = (FloatingActionButton) findViewById(R.id.fab_item_apply);
    floatingActionApply.setImageDrawable(
        new IconicsDrawable(this)
            .icon(CommunityMaterial.Icon.cmd_check)
            .color(Color.WHITE)
            .sizeDp(16));
    floatingActionApply.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // Snackbar.make(rootLayout, "Applying is coming soon!", Snackbar.LENGTH_SHORT).show();
            onSetAsWallpaper();
            if (floatingActionMenu.isOpened()) floatingActionMenu.close(true);
          }
        });

    floatingActionArchive = (FloatingActionButton) findViewById(R.id.fab_item_archive);
    if (Preferences.getInstance().isFavorite(earthWallpaper)) {
      floatingActionArchive.setImageDrawable(
          new IconicsDrawable(this)
              .icon(CommunityMaterial.Icon.cmd_heart_outline)
              .color(Color.WHITE)
              .sizeDp(16));
      floatingActionArchive.setLabelText(
          getResources().getString(R.string.fab_menu_item_remove_archive));
    } else {
      floatingActionArchive.setImageDrawable(
          new IconicsDrawable(this)
              .icon(CommunityMaterial.Icon.cmd_heart)
              .color(Color.WHITE)
              .sizeDp(16));
      floatingActionArchive.setLabelText(getResources().getString(R.string.fab_menu_item_archive));
    }
    floatingActionArchive.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (floatingActionMenu.isOpened()) floatingActionMenu.close(false);

            if (Preferences.getInstance().isFavorite(earthWallpaper)) {
              Preferences.getInstance().removeFavorite(earthWallpaper);
              floatingActionArchive.setImageDrawable(
                  new IconicsDrawable(WallpaperActivityPre.this)
                      .icon(CommunityMaterial.Icon.cmd_heart)
                      .color(Color.WHITE)
                      .sizeDp(16));
              floatingActionArchive.setLabelText(
                  getResources().getString(R.string.fab_menu_item_archive));
              Snackbar.make(rootLayout, R.string.fab_snack_bar_fav_removed, Snackbar.LENGTH_SHORT)
                  .setAction(
                      R.string.fab_snack_bar_fav_action,
                      new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {}
                      })
                  .show();
            } else {
              Preferences.getInstance().addFavorite(earthWallpaper);
              floatingActionArchive.setImageDrawable(
                  new IconicsDrawable(WallpaperActivityPre.this)
                      .icon(CommunityMaterial.Icon.cmd_heart_outline)
                      .color(Color.WHITE)
                      .sizeDp(16));
              floatingActionArchive.setLabelText(
                  getResources().getString(R.string.fab_menu_item_remove_archive));
              Snackbar.make(rootLayout, R.string.fab_snack_bar_fav_added, Snackbar.LENGTH_SHORT)
                  .setAction(
                      R.string.fab_snack_bar_fav_action,
                      new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {}
                      })
                  .show();
            }
          }
        });

    floatingActionDownload = (FloatingActionButton) findViewById(R.id.fab_item_download);
    floatingActionDownload.setImageDrawable(
        new IconicsDrawable(this)
            .icon(CommunityMaterial.Icon.cmd_download)
            .color(Color.WHITE)
            .sizeDp(16));
    floatingActionDownload.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (floatingActionMenu.isOpened()) floatingActionMenu.close(true);
            if (Preferences.getInstance().canWriteExternalStorage()) {
              new DownloadWallpaperTask(
                      WallpaperActivityPre.this,
                      Preferences.getInstance().getWallpaperDownloadDir(),
                      earthWallpaper)
                  .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, unlock);
            } else {
              Preferences.getInstance()
                  .requestExternalStoragePermission(
                      WallpaperActivityPre.this, WallpaperActivityPre.this, false);
            }
          }
        });

    // EarthView.withGoogle().getEarthWallpaper(earthWallpaper.getWallpaperId(), this);
    new DownloadHighResImage(this, earthWallpaper, this)
        .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

    setTypefaces();
  }
Exemplo n.º 11
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    UserGuideDialog userGuideDialog = new UserGuideDialog(MainActivity.this, "homePage");

    initViews();

    // set OnClickListener for Floating Action Button
    mFabCamera.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            addFromCamera();
          }
        });

    mFabGallery.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            addFromGallery();
          }
        });

    // set OnItemClickListener for grid items
    mGridView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            BeaconMap beaconMap = (BeaconMap) parent.getItemAtPosition(position);
            onMapSelected(beaconMap);
          }
        });

    mGridView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {

          @Override
          public boolean onItemLongClick(
              AdapterView<?> parent, View view, final int arg2, long arg3) {

            AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this);

            alertDialog.setTitle("Confirm Delete...");

            // Setting Dialog Message
            alertDialog.setMessage("Are you sure you want delete this?");

            // Setting Icon to Dialog
            alertDialog.setIcon(R.drawable.delete);

            // Setting Positive "Yes" Button
            alertDialog.setPositiveButton(
                "YES",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {

                    deleteMap(arg2);
                    updateGridContent();
                  }
                });

            // Setting Negative "NO" Button
            alertDialog.setNegativeButton(
                "NO",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    // Write your code here to invoke NO event
                    dialog.cancel();
                  }
                });

            // Showing Alert Message
            alertDialog.show();

            return false;
          }
        });
  }
Exemplo n.º 12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_feed);

    gps = new GPSTracker(this);

    toolbar = (Toolbar) findViewById(R.id.toolBarFeed);
    setSupportActionBar(toolbar);

    Display mdisp = getWindowManager().getDefaultDisplay();
    Point mdispSize = new Point();
    mdisp.getSize(mdispSize);
    int maxX = mdispSize.x;
    int maxY = mdispSize.y;

    float dpPadding = convertDpToPixel(20, MainFeedActivity.this);

    pivotX = maxX - (int) dpPadding;
    pivotY = maxY - (int) dpPadding;

    mPager = (ViewPager) findViewById(R.id.loginPagerMain);
    mPager.setAdapter(new MainPagerAdapter(getFragmentManager()));
    mPager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            // TODO: scale Floating Action Button size
            Log.d("POSITION_OFFSET", positionOffset + "");
            Log.d("POS_OFFSET_VIEW", whichView + "");
            Log.d("JUST_POS", position + "");

            if (positionOffset < 0.5) {
              if (whichView) {
                //
                // fabMainFeed.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.primaryColorDark)));

              } else {
                //
                // fabMainFeed.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.accentColor)));
              }
              //                    fabMainFeed.setScaleX((1 - 2 * positionOffset));
              //                    fabMainFeed.setScaleY((1 - 2 * positionOffset));

            } else {

              //
              // fabMainFeed.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.primaryColorDark)));
              //                    fabMainFeed.setScaleX((2 * positionOffset - 1));
              //                    fabMainFeed.setScaleY((2 * positionOffset - 1));
            }
          }

          @Override
          public void onPageSelected(int position) {
            whichView = !whichView;
          }

          @Override
          public void onPageScrollStateChanged(int state) {
            if (state == ViewPager.SCROLL_STATE_IDLE) {
              // Hide the keyboard.
              ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
                  .hideSoftInputFromWindow(mPager.getWindowToken(), 0);
            }
          }
        });

    mTabs = (SlidingTabLayout) findViewById(R.id.loginTabsMain);
    mTabs.setCustomTabView(R.layout.custom_tab_view_main, R.id.mainTabsText);
    mTabs.setDistributeEvenly(true);
    mTabs.setCustomTabColorizer(
        new SlidingTabLayout.TabColorizer() {
          @Override
          public int getIndicatorColor(int position) {
            return getResources().getColor(R.color.primaryColorLight);
          }
        });
    mTabs.setViewPager(mPager);

    navigationView = (NavigationView) findViewById(R.id.navigationView);
    navigationView.setNavigationItemSelectedListener(
        new NavigationView.OnNavigationItemSelectedListener() {
          @Override
          public boolean onNavigationItemSelected(MenuItem menuItem) {

            menuItem.setChecked(false);

            mNavItemId = menuItem.getItemId();
            drawerLayout.closeDrawers();

            switch (mNavItemId) {
              case R.id.navProfile:
                Intent profIntent = new Intent(MainFeedActivity.this, ProfileActivity.class);
                startActivity(profIntent);
                return true;
              case R.id.navSettings:
                Intent settingsIntent = new Intent(MainFeedActivity.this, SettingsActivity.class);
                startActivity(settingsIntent);
                return true;
            }
            return false;
          }
        });

    fabMenu = (FloatingActionMenu) findViewById(R.id.fabMenu);
    fabCurrentLocation =
        (com.github.clans.fab.FloatingActionButton) findViewById(R.id.fabCurrentLocation);
    fabPickLocation =
        (com.github.clans.fab.FloatingActionButton) findViewById(R.id.fabPickLocation);
    fabAirport = (com.github.clans.fab.FloatingActionButton) findViewById(R.id.fabAirport);

    fabCurrentLocation.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {}
        });

    fabPickLocation.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(MainFeedActivity.this, FSPickLocActivity.class);
            startActivity(intent);
          }
        });

    fabAirport.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {}
        });

    //        fabMainFeed = (FloatingActionButton) findViewById(R.id.fabMainFeed);
    //        fabMainFeed.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //
    //                // TODO: expand the FAB to give three options, each launching a different
    // intent
    //                // Can use whichView boolean value to launch the right intent by assigning
    //                // OnClickListener to the 3 options and check the whichView boolean in each
    //
    //                if (whichView) {
    //                    Toast.makeText(MainFeedActivity.this, "SECOND INTENT",
    // Toast.LENGTH_LONG).show();
    //                    Intent intent = new Intent(MainFeedActivity.this,
    // AddForSalePostActivity.class);
    //                    startActivity(intent);
    //
    //                } else {
    //                    Toast.makeText(MainFeedActivity.this, "FIRST INTENT",
    // Toast.LENGTH_LONG).show();
    //                    Intent intent = new Intent(MainFeedActivity.this,
    // AddForSalePostActivity.class);
    //                    startActivity(intent);
    //                }
    //            }
    //        });

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer);
    mDrawerToggle =
        new ActionBarDrawerToggle(
            this, drawerLayout, toolbar, R.string.openDrawer, R.string.closeDrawer);
    drawerLayout.setDrawerListener(mDrawerToggle);

    toolbar.setTitle("Browse");
    toolbar.setTitleTextColor(getResources().getColor(R.color.whiteColor));
    mPager.setCurrentItem(0);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    activity = this;
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics());
    ins = this;
    PreferenceManager.setDefaultValues(
        this, R.xml.pref_openaps, false); // Sets default OpenAPS Preferences if the user has not

    // xdrip start
    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    checkEula();

    startService(new Intent(getApplicationContext(), DataCollectionService.class));
    PreferenceManager.setDefaultValues(this, R.xml.pref_general, false);
    PreferenceManager.setDefaultValues(this, R.xml.pref_bg_notification, false);
    // xdrip end

    setContentView(R.layout.activity_main);

    // Setup menu
    menu1 = (FloatingActionMenu) findViewById(R.id.menu);
    FloatingActionButton menu_add_treatment =
        (FloatingActionButton) findViewById(R.id.menu_add_treatment);
    menu_add_treatment.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), EnterTreatment.class);
            startActivity(intent);
            menu1.close(true);
          }
        });
    FloatingActionButton menu_settings = (FloatingActionButton) findViewById(R.id.menu_settings);
    menu_settings.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            startActivity(new Intent(getApplicationContext(), SettingsActivity.class));
            menu1.close(true);
          }
        });
    FloatingActionButton menu_cancel_temp =
        (FloatingActionButton) findViewById(R.id.menu_cancel_temp);
    menu_cancel_temp.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            pumpAction.cancelTempBasal(MainActivity.activity);
            menu1.close(true);
          }
        });

    // Create the adapter that will return a fragment for each of the 4 primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) this.findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    // mViewPager.setOffscreenPageLimit(4);
    // //Do not destroy any Fragments, // TODO: 14/09/2015 casues an issue with bvb chart rendering,
    // not sure why
    // Build Fragments
    openAPSFragmentObject = new openAPSFragment();
    iobcobActiveFragmentObject = new iobcobActiveFragment();
    iobcobFragmentObject = new iobcobFragment();
    basalvsTempBasalObject = new basalvsTempBasalFragment();

    // starts OpenAPS and Treatments loops
    startLoops();

    // RunsOpenAPS
    runOpenAPS(findViewById(android.R.id.content));

    // Get Recent Stats
    updateStats();
  }
Exemplo n.º 14
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Logger.v("onCreateView");
    View view = inflater.inflate(R.layout.fragment_thread_detail, container, false);

    mDetailListView = (XListView) view.findViewById(R.id.lv_thread_details);
    mDetailListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    mTipBar = (TextView) view.findViewById(R.id.thread_detail_tipbar);
    mTipBar.bringToFront();

    mFam = (FloatingActionMenu) view.findViewById(R.id.multiple_actions);
    mFam.setVisibility(View.INVISIBLE);

    FloatingActionButton fabRefresh =
        (FloatingActionButton) view.findViewById(R.id.action_fab_refresh);
    fabRefresh.setImageDrawable(
        new IconicsDrawable(getActivity(), GoogleMaterial.Icon.gmd_refresh).color(Color.WHITE));
    fabRefresh.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            mFam.close(true);
            mFloorOfPage = LAST_FLOOR;
            refresh();
          }
        });

    FloatingActionButton fabQuickReply =
        (FloatingActionButton) view.findViewById(R.id.action_fab_quick_reply);
    fabQuickReply.setImageDrawable(
        new IconicsDrawable(getActivity(), GoogleMaterial.Icon.gmd_reply).color(Color.WHITE));
    fabQuickReply.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            mFam.close(false);
            mFam.setVisibility(View.INVISIBLE);
            quickReply.setVisibility(View.VISIBLE);
            quickReply.bringToFront();
            (new Handler())
                .postDelayed(
                    new Runnable() {
                      public void run() {
                        mReplyTextTv.requestFocus();
                        mReplyTextTv.dispatchTouchEvent(
                            MotionEvent.obtain(
                                SystemClock.uptimeMillis(),
                                SystemClock.uptimeMillis(),
                                MotionEvent.ACTION_DOWN,
                                0,
                                0,
                                0));
                        mReplyTextTv.dispatchTouchEvent(
                            MotionEvent.obtain(
                                SystemClock.uptimeMillis(),
                                SystemClock.uptimeMillis(),
                                MotionEvent.ACTION_UP,
                                0,
                                0,
                                0));
                      }
                    },
                    200);
          }
        });

    FloatingActionButton fabGotoPage =
        (FloatingActionButton) view.findViewById(R.id.action_fab_goto_page);
    fabGotoPage.setImageDrawable(
        new IconicsDrawable(getActivity(), GoogleMaterial.Icon.gmd_swap_horiz).color(Color.WHITE));
    fabGotoPage.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            mFam.close(true);
            showGotoPageDialog();
          }
        });

    if (!HiSettingsHelper.getInstance().getIsLandscape()) {
      mDetailListView.addHeaderView(inflater.inflate(R.layout.head_thread_detail, null));
      mTitleView = (TextView) view.findViewById(R.id.thread_detail_title);
      mTitleView.setTextSize(HiSettingsHelper.getTitleTextSize());
      mTitleView.setText(mTitle);
    }
    mDetailListView.setPullLoadEnable(false);
    mDetailListView.setPullRefreshEnable(false);
    mDetailListView.setXListViewListener(
        new XListView.IXListViewListener() {
          @Override
          public void onRefresh() {
            // Previous Page
            if (mCurrentPage > 1) {
              mCurrentPage--;
            }
            mDetailListView.stopRefresh();
            mFloorOfPage = LAST_FLOOR;
            showOrLoadPage();
            quickReply.setVisibility(View.INVISIBLE);
          }

          @Override
          public void onLoadMore() {
            // Next Page
            if (mCurrentPage < mMaxPage) {
              mCurrentPage++;
            }
            mDetailListView.stopLoadMore();
            showOrLoadPage();
          }
        });

    final GestureDetector.SimpleOnGestureListener listener =
        new GestureDetector.SimpleOnGestureListener() {
          @Override
          public boolean onDoubleTap(MotionEvent e) {
            if (mDetailListView.isFastScrollEnabled()) {
              mDetailListView.setFastScrollEnabled(false);
              mDetailListView.setFastScrollAlwaysVisible(false);
            } else {
              mDetailListView.setFastScrollEnabled(true);
              mDetailListView.setFastScrollAlwaysVisible(true);
            }
            return true;
          }
        };

    final GestureDetector detector = new GestureDetector(mCtx, listener);
    detector.setOnDoubleTapListener(listener);

    mDetailListView.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View view, MotionEvent event) {
            if (mFam.isOpened()) {
              mFam.close(false);
            }
            return detector.onTouchEvent(event);
          }
        });

    quickReply = view.findViewById(R.id.quick_reply);
    mReplyTextTv = (TextView) quickReply.findViewById(R.id.tv_reply_text);
    mReplyTextTv.setTextSize(HiSettingsHelper.getPostTextSize());
    mPostReplyIb = (ImageButton) quickReply.findViewById(R.id.ib_reply_post);
    mPostReplyIb.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            String replyText = mReplyTextTv.getText().toString();
            if (replyText.length() < 5) {
              Toast.makeText(getActivity(), "字数必须大于5", Toast.LENGTH_LONG).show();
            } else {
              mReplyTextTv.setText("");
              quickReply.setVisibility(View.INVISIBLE);
              PostBean postBean = new PostBean();
              postBean.setContent(replyText);
              postBean.setTid(mTid);
              new PostAsyncTask(
                      getActivity(),
                      PostAsyncTask.MODE_QUICK_REPLY,
                      null,
                      ThreadDetailFragment.this)
                  .execute(postBean);
              // Close SoftKeyboard
              InputMethodManager imm =
                  (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
              imm.hideSoftInputFromWindow(mReplyTextTv.getWindowToken(), 0);
              mFam.setVisibility(View.VISIBLE);
            }
          }
        });

    return view;
  }
 public void removeMenuButton(FloatingActionButton fab) {
   removeView(fab.getLabelView());
   removeView(fab);
   mButtonsCount--;
 }
 public void setMenuButtonShowAnimation(Animation showAnimation) {
   mMenuButtonShowAnimation = showAnimation;
   mMenuButton.setShowAnimation(showAnimation);
 }
 public void setMenuButtonColorRipple(int color) {
   mMenuColorRipple = color;
   mMenuButton.setColorRipple(color);
 }
Exemplo n.º 18
0
 public static void setFabBtnColor(Activity activity, FloatingActionButton fab) {
   // 更新FAB的颜色
   fab.setColorNormal(getThemeColor(activity));
   fab.setColorPressed(getThemeColor(activity));
   fab.setColorRipple(getThemeColor(activity));
 }
  public void sharePhoto() {

    final FloatingActionButton share = (FloatingActionButton) findViewById(R.id.share);
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    share.setEnabled(false);
    share.setIndeterminate(true);

    Thread t =
        new Thread(
            new Runnable() {
              @Override
              public void run() {
                pushObjectToSP();

                File directory_gags =
                    new File(
                        getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)
                            + File.separator
                            + "gags");
                if (!directory_gags.exists()) {
                  directory_gags.mkdirs();
                }
                final File dir_app = new File(directory_gags + File.separator + photo_id);

                FileOutputStream out = null;
                try {
                  out = new FileOutputStream(dir_app);
                  bp.getBitmap(true).compress(Bitmap.CompressFormat.PNG, 100, out);
                } catch (Exception e) {
                  e.printStackTrace();
                } finally {
                  try {
                    if (out != null) {
                      out.close();
                    }
                  } catch (IOException e) {
                    e.printStackTrace();
                  }
                }

                runOnUiThread(
                    new Runnable() {
                      @Override
                      public void run() {
                        share.setEnabled(true);
                        share.setIndeterminate(false);
                      }
                    });

                Uri uri = Uri.fromFile(dir_app);
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_SEND);
                intent.setType("image/*");

                Boolean boo = prefs.getBoolean("useTitleAsMessage", false);

                intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "");
                if (boo) {
                  intent.putExtra(android.content.Intent.EXTRA_TEXT, gagTitle);
                } else {
                  intent.putExtra(android.content.Intent.EXTRA_TEXT, "");
                }
                intent.putExtra(Intent.EXTRA_STREAM, uri);
                startActivity(Intent.createChooser(intent, "Share Gag to..."));
              }
            });
    t.start();
  }
 public void setMenuButtonColorNormal(int color) {
   mMenuColorNormal = color;
   mMenuButton.setColorNormal(color);
 }
 public boolean isMenuButtonHidden() {
   return mMenuButton.isHidden();
 }
 public void setMenuButtonHideAnimation(Animation hideAnimation) {
   mMenuButtonHideAnimation = hideAnimation;
   mMenuButton.setHideAnimation(hideAnimation);
 }
Exemplo n.º 23
0
  private void setupListeners() {

    // on Enter press on keyboard
    searchField.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            imm.hideSoftInputFromInputMethod(v.getWindowToken(), 0);
            genreSpinner.requestFocus();
            searchButton.callOnClick();
            return true;
          }
        });

    searchField.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.length() > 0) clear.setVisibility(View.VISIBLE);
            else clear.setVisibility(View.GONE);
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });

    clear.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            searchField.setText("");
          }
        });

    searchButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent result = new Intent(SearchActivity.this, ResultActivity.class);
            result.putExtra("query", searchField.getText().toString());
            result.putExtra(
                "quality",
                qualityRG.getCheckedRadioButtonId() == R.id.q_720p
                    ? "720p"
                    : qualityRG.getCheckedRadioButtonId() == R.id.q_1080p ? "1080p" : "3D");
            result.putExtra(
                "genre",
                getResources()
                    .getStringArray(R.array.genre_value)[genreSpinner.getSelectedItemPosition()]);
            result.putExtra(
                "sort",
                getResources()
                    .getStringArray(R.array.sort_value)[sortSpinner.getSelectedItemPosition()]);
            result.putExtra(
                "order", orderRG.getCheckedRadioButtonId() == R.id.asc ? "asc" : "desc");
            result.putExtra(
                "rating",
                getResources()
                    .getStringArray(R.array.rating_value)[ratingSpinner.getSelectedItemPosition()]);
            startActivity(result);
          }
        });
  }
 public void setMenuButtonColorRippleResId(int colorResId) {
   mMenuColorRipple = getResources().getColor(colorResId);
   mMenuButton.setColorRippleResId(colorResId);
 }
 public void setMenuButtonColorNormalResId(int colorResId) {
   mMenuColorNormal = getResources().getColor(colorResId);
   mMenuButton.setColorNormalResId(colorResId);
 }
  @Override
  protected void onLayout(boolean changed, int l, int t, int r, int b) {
    int buttonsHorizontalCenter =
        mLabelsPosition == LABELS_POSITION_LEFT
            ? r - l - mMaxButtonWidth / 2 - getPaddingRight()
            : mMaxButtonWidth / 2 + getPaddingLeft();
    boolean openUp = mOpenDirection == OPEN_UP;

    int menuButtonTop =
        openUp ? b - t - mMenuButton.getMeasuredHeight() - getPaddingBottom() : getPaddingTop();
    int menuButtonLeft = buttonsHorizontalCenter - mMenuButton.getMeasuredWidth() / 2;

    mMenuButton.layout(
        menuButtonLeft,
        menuButtonTop,
        menuButtonLeft + mMenuButton.getMeasuredWidth(),
        menuButtonTop + mMenuButton.getMeasuredHeight());

    int imageLeft = buttonsHorizontalCenter - mImageToggle.getMeasuredWidth() / 2;
    int imageTop =
        menuButtonTop + mMenuButton.getMeasuredHeight() / 2 - mImageToggle.getMeasuredHeight() / 2;

    mImageToggle.layout(
        imageLeft,
        imageTop,
        imageLeft + mImageToggle.getMeasuredWidth(),
        imageTop + mImageToggle.getMeasuredHeight());

    int nextY =
        openUp
            ? menuButtonTop - mButtonSpacing
            : menuButtonTop + mMenuButton.getMeasuredHeight() + mButtonSpacing;

    for (int i = mButtonsCount - 1; i >= 0; i--) {
      View child = getChildAt(i);

      if (child == mImageToggle) continue;

      FloatingActionButton fab = (FloatingActionButton) child;

      if (fab == mMenuButton || fab.getVisibility() == GONE) continue;

      int childX = buttonsHorizontalCenter - fab.getMeasuredWidth() / 2;
      int childY = openUp ? nextY - fab.getMeasuredHeight() : nextY;
      fab.layout(childX, childY, childX + fab.getMeasuredWidth(), childY + fab.getMeasuredHeight());

      if (!mMenuOpened) {
        fab.hide(false);
      }

      View label = (View) fab.getTag(R.id.fab_label);
      if (label != null) {
        int labelsOffset = fab.getMeasuredWidth() / 2 + mLabelsMargin;
        int labelXNearButton =
            mLabelsPosition == LABELS_POSITION_LEFT
                ? buttonsHorizontalCenter - labelsOffset
                : buttonsHorizontalCenter + labelsOffset;

        int labelXAwayFromButton =
            mLabelsPosition == LABELS_POSITION_LEFT
                ? labelXNearButton - label.getMeasuredWidth()
                : labelXNearButton + label.getMeasuredWidth();

        int labelLeft =
            mLabelsPosition == LABELS_POSITION_LEFT ? labelXAwayFromButton : labelXNearButton;

        int labelRight =
            mLabelsPosition == LABELS_POSITION_LEFT ? labelXNearButton : labelXAwayFromButton;

        int labelTop =
            childY
                - mLabelsVerticalOffset
                + (fab.getMeasuredHeight() - label.getMeasuredHeight()) / 2;

        label.layout(labelLeft, labelTop, labelRight, labelTop + label.getMeasuredHeight());

        if (!mMenuOpened) {
          label.setVisibility(INVISIBLE);
        }
      }

      nextY =
          openUp ? childY - mButtonSpacing : childY + child.getMeasuredHeight() + mButtonSpacing;
    }
  }
  public void savePhoto() {

    final FloatingActionButton save = (FloatingActionButton) findViewById(R.id.save);
    save.setEnabled(false);
    save.setIndeterminate(true);

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String file_path = prefs.getString("path", null);

    String format = prefs.getString("image_format", "0");

    class FORMAT {
      public String ext;
      public Bitmap.CompressFormat bitmap_format;
      public Integer q;

      public void setString(String x) {
        this.ext = x;
      }

      public void setBitmapFormat(Bitmap.CompressFormat x) {
        this.bitmap_format = x;
      }

      public void setQuality(Integer x) {
        this.q = x;
      }
    }

    final FORMAT f = new FORMAT();

    if (format.equals("0")) {
      f.setString(".png");
      f.setBitmapFormat(Bitmap.CompressFormat.PNG);
      f.setQuality(100);
    } else {
      f.setString(".jpeg");
      f.setBitmapFormat(Bitmap.CompressFormat.JPEG);
      f.setQuality(80);
    }

    assert file_path != null;
    final File dir = new File(file_path);
    if (!dir.exists()) {
      dir.mkdirs();
    }

    Thread normal_save =
        new Thread(
            new Runnable() {
              @Override
              public void run() {
                pushObjectToSP();

                String modifiedTitle = gagTitle.replaceAll(" ", "-");
                File file = new File(dir, modifiedTitle + f.ext);

                FileOutputStream outo = null;
                try {
                  outo = new FileOutputStream(file);
                  bp.getBitmap(true).compress(f.bitmap_format, f.q, outo);
                } catch (Exception e) {
                  e.printStackTrace();
                } finally {
                  try {
                    if (outo != null) {
                      outo.close();
                    }
                  } catch (IOException e) {
                    e.printStackTrace();
                  }
                }

                File directory_gags =
                    new File(
                        getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)
                            + File.separator
                            + "gags");
                if (!directory_gags.exists()) {
                  directory_gags.mkdirs();
                }
                File dir_app = new File(directory_gags + File.separator + photo_id);
                FileOutputStream outi = null;

                try {
                  outi = new FileOutputStream(dir_app);
                  bp.getBitmap(true).compress(f.bitmap_format, f.q, outi);
                } catch (Exception e) {
                  e.printStackTrace();
                } finally {
                  try {
                    if (outi != null) {
                      outi.close();
                    }
                  } catch (IOException e) {
                    e.printStackTrace();
                  }
                }

                Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
                intent.setData(Uri.fromFile(file));
                sendBroadcast(intent);

                runOnUiThread(
                    new Runnable() {
                      @Override
                      public void run() {
                        save.setIndeterminate(false);
                        Toast.makeText(
                                getApplicationContext(),
                                "Gag saved successfully",
                                Toast.LENGTH_LONG)
                            .show();
                      }
                    });
              }
            });

    normal_save.start();
  }
 public void setMenuButtonColorPressed(int color) {
   mMenuColorPressed = color;
   mMenuButton.setColorPressed(color);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    try {
      android.support.v7.app.ActionBar actionBar = getSupportActionBar();
      if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(false);
      }
    } catch (NullPointerException e) {
      e.printStackTrace();
    }

    Intent intent = getIntent();
    gagTitle = intent.getStringExtra(GAG_TITLE);
    gagURL = intent.getStringExtra(GAG_URL);
    file_ext = getIntent().getStringExtra(FILE_EXT);

    setContentView(R.layout.activity_display_recieved_image);
    bp = new BitmapProcessor(this, DisplayReceivedImage.this);

    final FloatingActionMenu fam = (FloatingActionMenu) findViewById(R.id.fam);
    FloatingActionButton save = (FloatingActionButton) findViewById(R.id.save);
    FloatingActionButton share = (FloatingActionButton) findViewById(R.id.share);
    FloatingActionButton changeTitle = (FloatingActionButton) findViewById(R.id.changeTitle);
    final FloatingActionButton changeSize = (FloatingActionButton) findViewById(R.id.changeSize);
    final TouchImageView mImageView = (TouchImageView) findViewById(R.id.imageViewPhoto);

    DiscreteSeekBar seekbar = (DiscreteSeekBar) findViewById(R.id.seekBar);
    final RelativeLayout sbc = (RelativeLayout) findViewById(R.id.seekBarContainer);
    sbc.setVisibility(View.INVISIBLE);

    changeSize.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            sbc.setVisibility(View.VISIBLE);
            changeSize.setEnabled(false);
          }
        });

    seekbar.setOnProgressChangeListener(
        new DiscreteSeekBar.OnProgressChangeListener() {
          @Override
          public void onProgressChanged(DiscreteSeekBar seekBar, int value, boolean fromUser) {
            customPercent = value;
          }

          @Override
          public void onStartTrackingTouch(DiscreteSeekBar seekBar) {
            Toast.makeText(
                    context,
                    "Changes will take effect after releasing seek bar.",
                    Toast.LENGTH_SHORT)
                .show();
          }

          @Override
          public void onStopTrackingTouch(DiscreteSeekBar seekBar) {
            fam.close(true);
            bp.cache(file_ext, mImageView, true, true);
          }
        });

    changeTitle.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            new MaterialDialog.Builder(context)
                .title("Change Title Text")
                .theme(Theme.DARK)
                .cancelable(false)
                .inputType(InputType.TYPE_CLASS_TEXT)
                .alwaysCallInputCallback()
                .negativeText("Cancel")
                .input(
                    "Title",
                    gagTitle,
                    new MaterialDialog.InputCallback() {
                      @Override
                      public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
                        if (input.length() == 0) {
                          dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
                          newGagTitle = "";
                        } else {
                          dialog.getActionButton(DialogAction.POSITIVE).setEnabled(true);
                          newGagTitle = input.toString();
                        }
                      }
                    })
                .onPositive(
                    new MaterialDialog.SingleButtonCallback() {
                      @Override
                      public void onClick(
                          @NonNull MaterialDialog materialDialog,
                          @NonNull DialogAction dialogAction) {
                        if (!newGagTitle.equals("")) gagTitle = newGagTitle;
                        bp.cache(
                            file_ext, mImageView, !(customPercent == 5), !newGagTitle.equals(""));
                      }
                    })
                .show();
          }
        });

    save.setOnClickListener(this);
    share.setOnClickListener(this);

    photoURI =
        Uri.parse(
            getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS) + "/downloads/GAG" + file_ext);

    bp.cache(file_ext, mImageView, false, true);
  }
 public void setMenuButtonColorPressedResId(int colorResId) {
   mMenuColorPressed = getResources().getColor(colorResId);
   mMenuButton.setColorPressedResId(colorResId);
 }