/** 开关灯 */
 private void operateLight() {
   if (!mIsLightOpen) {
     cameraManager.openLight();
     mIsLightOpen = true;
     mLightBtn.setImageResource(R.drawable.light_pressed);
   } else {
     cameraManager.offLight();
     mIsLightOpen = false;
     mLightBtn.setImageResource(R.drawable.light_normal);
   }
 }
 /** 关灯 */
 private void offLight() {
   if (mIsLightOpen) {
     cameraManager.offLight();
     mIsLightOpen = false;
     mLightBtn.setImageResource(R.drawable.light_normal);
   }
 }
示例#3
0
 /**
  * 重载父类实现的 EventBus 订阅方法,实现更具体的逻辑处理
  *
  * @param event 订阅的消息类型
  */
 @Override
 public void onEventBus(MLConnectionEvent event) {
   /** 因为3.x的sdk断开服务器连接后会一直重试并发出回调,所以为了防止一直Toast提示用户, 这里取消弹出 Toast 方式,只是显示图标 */
   if (event.getType() == MLConstants.ML_CONNECTION_CONNECTED) {
     mConnectionFabBtn.setImageResource(R.mipmap.ic_signal_wifi_on_white_24dp);
     mConnectionFabBtn.setVisibility(View.GONE);
   } else {
     mConnectionFabBtn.setImageResource(R.mipmap.ic_signal_wifi_off_white_24dp);
     mConnectionFabBtn.setVisibility(View.VISIBLE);
   }
   super.onEventBus(event);
 }
示例#4
0
  /** 界面初始化操作 */
  private void init() {
    mActivity = this;

    if (EMClient.getInstance().isConnected()) {
      mConnectionFabBtn.setImageResource(R.mipmap.ic_signal_wifi_on_white_24dp);
      mConnectionFabBtn.setVisibility(View.GONE);
    } else {
      mConnectionFabBtn.setImageResource(R.mipmap.ic_signal_wifi_off_white_24dp);
      mConnectionFabBtn.setVisibility(View.VISIBLE);
    }

    setSupportActionBar(getToolbar());
    getSupportActionBar().setTitle(R.string.ml_chat);
  }
示例#5
0
  private void connect() {
    fab.setBackgroundTintList(TINT_CONNECTING);
    fab.setImageResource(R.drawable.ic_connected);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
    String connectionType =
        prefs.getString(
            getString(R.string.prefs_conn_type), getString(R.string.prefs_bt_connection));
    if (getString(R.string.prefs_bt_connection).equals(connectionType)) {
      BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
      if (adapter == null || !adapter.isEnabled()) {
        Toast.makeText(MainActivity.this, R.string.bluetooth_is_not_available, Toast.LENGTH_LONG)
            .show();
        return;
      }
      showDevices();
    } else {
      String host = prefs.getString("tcp_host", null);
      int port = 0;
      try {
        port = Integer.parseInt(prefs.getString("tcp_port", "0"));
      } catch (NumberFormatException nfe) {
      }

      if (host == null || port <= 0 || port > 0xFFFF) {
        Toast.makeText(
                MainActivity.this,
                String.format(Locale.US, "%s/%d: Illegal host/port combination.", host, port),
                Toast.LENGTH_LONG)
            .show();
        return;
      }
      connect(host, port);
    }
  }
示例#6
0
  private void initFloatingActionButton() {
    FloatingActionButton fab = (FloatingActionButton) getActivity().findViewById(R.id.fab);
    if (fab != null) {
      if (isMyAccount()) {
        // Own log, button opens window to add training
        fab.setVisibility(View.VISIBLE);
        fab.setImageResource(R.drawable.ic_playlist_add);
        fab.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                Activity activity = getActivity();
                Fragment fragment = TrainingFragment.newInstance();
                FragmentTransaction transaction = activity.getFragmentManager().beginTransaction();

                transaction.replace(R.id.fragment_container, fragment);
                transaction.addToBackStack(null);
                transaction.commit();
              }
            });
      } else {
        // Someone else's log, button opens window to add comment
        // TODO
        fab.setVisibility(View.GONE);
      }
    }
  }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    // получаем плавающую кнопку из активити
    FloatingActionButton fab = ButterKnife.findById(getActivity(), R.id.fab);
    // получаем параметры Layout fab приведенные к родителю
    CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
    // выставляем привязку якоря к appBarLayout
    params.setAnchorId(R.id.appbar_layout);
    // выставляем anchorGravity
    params.anchorGravity = Gravity.BOTTOM | Gravity.RIGHT;
    fab.setLayoutParams(params);
    // меняем иконку плавающей кнопки
    fab.setImageResource(R.drawable.ic_mode_edit_24dp);
    /*        fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) { //создаем и вешаем новый обработчик на fab
            //выбираем действие для fab в зависимости от текущего режима
            if (sCurrentFunctionality.equals(FUNCTIONALITY_PROFILE_VIEW)) {
                setupFuncionality(FUNCTIONALITY_PROFILE_EDIT);
            } else {
                setupFuncionality(FUNCTIONALITY_PROFILE_VIEW);
            }
        }
    });*/
  }
示例#8
0
 @Override
 public void onCropping() {
   // - Update snap icon,  display progress circle and stop preview.
   mSnapButton.setImageResource(R.drawable.ic_visibility_white_24dp);
   mFabProgressCircle.show();
   mEasyCamera.stopPreview();
 }
示例#9
0
 public void setCategoryFragment() {
   setTitle("漫画分类");
   isHome = false;
   fab.setImageResource(R.drawable.ic_action_search);
   isCategory = true;
   handFab(false);
   if (mCategoryFragment == null) {
     mCategoryFragment = CategoryFragment.newInstance();
   }
   switchFragment(TAG_CATEGORY, mCategoryFragment);
 }
  public void addFabListener() {
    try {
      if (toggleStar) {
        fab.setImageResource(R.drawable.ic_star_white_24dp);
      } else {
        fab.setImageResource(R.drawable.ic_star_border_white_24dp);
      }

      fab.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (!BrewSharedPrefs.getIsUserLoggedIn()) {
                AlertLoginPrompt(
                    _mContext,
                    "",
                    getText(R.string.text_login_to_favorite).toString(),
                    getText(R.string.text_sign_in).toString(),
                    getText(R.string.text_close).toString());
              } else {
                if (toggleStar) {
                  fab.setImageResource(R.drawable.ic_star_border_white_24dp);
                  toggleStar = false;
                } else {
                  fab.setImageResource(R.drawable.ic_star_white_24dp);
                  toggleStar = true;
                }

                Ion.with(getApplicationContext())
                    .load(Constants.wcfAddUpdateFavorite + responseContentItemPk + "/" + userToken)
                    .asString();
              }
            }
          });
    } catch (Exception e) {
      if (BuildConfig.DEBUG) {
        Log.e(Constants.LOG, e.getMessage());
      }
    }
  }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mActionListener =
        new AddNotePresenter(
            Injection.provideNotesRepository(), this, Injection.provideImageFile());

    FloatingActionButton fab =
        (FloatingActionButton) getActivity().findViewById(R.id.fab_add_notes);
    fab.setImageResource(R.drawable.ic_done);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mActionListener.saveNote(
                mTitle.getText().toString(), mDescription.getText().toString());
          }
        });
  }
示例#12
0
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_notes, container, false);
    RecyclerView recyclerView = (RecyclerView) root.findViewById(R.id.notes_list);
    recyclerView.setAdapter(mListAdapter);

    int numColumns = getContext().getResources().getInteger(R.integer.num_notes_columns);

    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new GridLayoutManager(getContext(), numColumns));

    // Set up floating action button
    FloatingActionButton fab =
        (FloatingActionButton) getActivity().findViewById(R.id.fab_add_notes);

    fab.setImageResource(R.drawable.ic_add);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mActionsListener.addNewNote();
          }
        });

    // Pull-to-refresh
    SwipeRefreshLayout swipeRefreshLayout =
        (SwipeRefreshLayout) root.findViewById(R.id.refresh_layout);
    swipeRefreshLayout.setColorSchemeColors(
        ContextCompat.getColor(getActivity(), R.color.colorPrimary),
        ContextCompat.getColor(getActivity(), R.color.colorAccent),
        ContextCompat.getColor(getActivity(), R.color.colorPrimaryDark));
    swipeRefreshLayout.setOnRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {
          @Override
          public void onRefresh() {
            mActionsListener.loadNotes(true);
          }
        });
    return root;
  }
 @Nullable
 @Override
 public View onCreateView(
     LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
   View res = inflater.inflate(R.layout.fragment_fab, container, false);
   FloatingActionButton fabRoot = (FloatingActionButton) res.findViewById(R.id.fab);
   fabRoot.setImageResource(R.drawable.ic_edit_white_24dp);
   fabRoot.setBackgroundTintList(
       new ColorStateList(
           new int[][] {
             new int[] {android.R.attr.state_pressed}, StateSet.WILD_CARD,
           },
           new int[] {
             ActorSDK.sharedActor().style.getFabPressedColor(),
             ActorSDK.sharedActor().style.getFabColor(),
           }));
   fabRoot.setRippleColor(ActorSDK.sharedActor().style.getFabPressedColor());
   fabRoot.setOnClickListener(
       v -> startActivity(new Intent(getActivity(), ComposeActivity.class)));
   return res;
 }
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {
      long movieId = ContentUris.parseId(mUri);
      title = data.getString(COL_MOVIE_TITLE);
      // fetch meta data from async task
      new TmdbApiTask(getActivity(), textView_runtime).execute(String.valueOf(movieId));

      // fetch trailer list
      new TmdbApiTask(
              getActivity(),
              listView_trailers,
              Constants.FETCH_VIDEOS,
              new TmdbApiTask.AsyncResponse() {
                @Override
                public void processFinish(String result) {
                  listView_trailers.setEmptyView(textView_empty_trailer_list);
                  if (mShareActionProvider != null) {
                    Intent shareIntent = createShareVideoIntent(result);
                    mShareActionProvider.setShareIntent(shareIntent);
                  }
                }
              })
          .execute(String.valueOf(movieId));

      // fetch reviews list
      new TmdbApiTask(
              getActivity(),
              linearListView,
              Constants.FETCH_REVIEWS,
              new TmdbApiTask.AsyncResponse() {
                @Override
                public void processFinish(String str) {
                  progressBar.setVisibility(View.GONE);
                  linearListView.setEmptyView(textView_empty_list_item);
                }
              })
          .execute(String.valueOf(movieId));

      if (getActivity().findViewById(R.id.gridView_tiles) == null) {
        // single pane
        getActivity().setTitle(title);
      }

      String year = data.getString(COL_MOVIE_DATE);

      textView_release_year.setText(title + " \n\n" + Utility.getYear(year));

      String overview = data.getString(COL_MOVIE_SYNOPSIS);
      textView_overview.setText(overview);

      String rating = data.getString(COL_MOVIE_RATING);
      textView_vote_average.setText(rating + "/10");

      String poster = data.getString(COL_MOVIE_POSTER);

      imageView_poster_detail.setContentDescription(title);
      Picasso.with(getContext())
          .load(Utility.getPoster_path(Constants.DEFAULT_POSTER_WIDTH, poster))
          .into(imageView_poster_detail);

      Boolean fav = data.getInt(COL_MOVIE_FAV) > 0;
      if (fav) {
        myFab.setSelected(true);
        myFab.setImageResource(R.drawable.ic_favorite_black_24dp);
      } else {
        myFab.setSelected(false);
        myFab.setImageResource(R.drawable.ic_favorite_border_black_24dp);
      }
    }
  }
示例#15
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final Context contextThemeWrapper =
        new ContextThemeWrapper(
            getActivity(), new ColorPreferences(inflater.getContext()).getThemeSubreddit(id));
    View v =
        ((LayoutInflater) contextThemeWrapper.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
            .inflate(R.layout.fragment_verticalcontent, container, false);

    rv = ((RecyclerView) v.findViewById(R.id.vertical_content));
    final RecyclerView.LayoutManager mLayoutManager;
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
        && SettingValues.tabletUI) {
      mLayoutManager =
          new CatchStaggeredGridLayoutManager(
              Reddit.dpWidth, CatchStaggeredGridLayoutManager.VERTICAL);
    } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT
        && SettingValues.dualPortrait) {
      mLayoutManager =
          new CatchStaggeredGridLayoutManager(2, CatchStaggeredGridLayoutManager.VERTICAL);

    } else {
      mLayoutManager = new PreCachingLayoutManager(getActivity());
    }

    if (!(getActivity() instanceof SubredditView)) {
      v.findViewById(R.id.back).setBackground(null);
    }
    rv.setLayoutManager(mLayoutManager);
    rv.setItemAnimator(new SlideInUpAnimator(new AccelerateDecelerateInterpolator()));

    mSwipeRefreshLayout =
        (SwipeRefreshLayout) v.findViewById(R.id.activity_main_swipe_refresh_layout);
    mSwipeRefreshLayout.setColorSchemeColors(Palette.getColors(id, getContext()));

    // If we use 'findViewById(R.id.header).getMeasuredHeight()', 0 is always returned.
    // So, we just do 13% of the device screen height as a general estimate for the Tabs view type
    int screenHeight = getContext().getResources().getDisplayMetrics().heightPixels;
    int headerOffset = Math.round((float) (screenHeight * 0.13));

    // if the view type is "single" (and therefore "commentPager"), we need a different offset
    if (SettingValues.single) {
      headerOffset = Math.round((float) (screenHeight * 0.07));
    }

    mSwipeRefreshLayout.setProgressViewOffset(
        false,
        headerOffset - Reddit.pxToDp(42, getContext()),
        headerOffset + Reddit.pxToDp(42, getContext()));

    if (SettingValues.fab) {
      fab = (FloatingActionButton) v.findViewById(R.id.post_floating_action_button);

      if (SettingValues.fabType == R.integer.FAB_POST) {
        fab.setImageResource(R.drawable.add);
        fab.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                Intent inte = new Intent(getActivity(), Submit.class);
                inte.putExtra(Submit.EXTRA_SUBREDDIT, id);
                getActivity().startActivity(inte);
              }
            });
      } else {
        fab.setImageResource(R.drawable.hide);
        fab.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                if (!Reddit.fabClear) {
                  new AlertDialogWrapper.Builder(getActivity())
                      .setTitle(R.string.settings_fabclear)
                      .setMessage(R.string.settings_fabclear_msg)
                      .setPositiveButton(
                          R.string.btn_ok,
                          new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                              Reddit.seen
                                  .edit()
                                  .putBoolean(SettingValues.PREF_FAB_CLEAR, true)
                                  .apply();
                              Reddit.fabClear = true;
                              clearSeenPosts(false);
                            }
                          })
                      .show();
                } else {
                  clearSeenPosts(false);
                }
              }
            });
        fab.setOnLongClickListener(
            new View.OnLongClickListener() {
              @Override
              public boolean onLongClick(View v) {
                if (!Reddit.fabClear) {
                  new AlertDialogWrapper.Builder(getActivity())
                      .setTitle(R.string.settings_fabclear)
                      .setMessage(R.string.settings_fabclear_msg)
                      .setPositiveButton(
                          R.string.btn_ok,
                          new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                              Reddit.seen
                                  .edit()
                                  .putBoolean(SettingValues.PREF_FAB_CLEAR, true)
                                  .apply();
                              Reddit.fabClear = true;
                              clearSeenPosts(true);
                            }
                          })
                      .show();
                } else {
                  clearSeenPosts(true);
                }
                /*
                ToDo Make a sncakbar with an undo option of the clear all
                View.OnClickListener undoAction = new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        adapter.dataSet.posts = original;
                        for(Submission post : adapter.dataSet.posts){
                            if(HasSeen.getSeen(post.getFullName()))
                                Hidden.undoHidden(post);
                        }
                    }
                };*/
                Snackbar s =
                    Snackbar.make(
                        rv,
                        getResources().getString(R.string.posts_hidden_forever),
                        Snackbar.LENGTH_LONG);
                View view = s.getView();
                TextView tv =
                    (TextView) view.findViewById(android.support.design.R.id.snackbar_text);
                tv.setTextColor(Color.WHITE);
                s.show();

                return false;
              }
            });
      }
    } else {
      v.findViewById(R.id.post_floating_action_button).setVisibility(View.GONE);
    }

    rv.addOnScrollListener(
        new ToolbarScrollHideHandler(
            ((BaseActivity) getActivity()).mToolbar, getActivity().findViewById(R.id.header)) {
          @Override
          public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (!posts.loading && !posts.nomore && !posts.offline) {

              visibleItemCount = rv.getLayoutManager().getChildCount();
              totalItemCount = rv.getLayoutManager().getItemCount();
              if (rv.getLayoutManager() instanceof PreCachingLayoutManager) {
                pastVisiblesItems =
                    ((PreCachingLayoutManager) rv.getLayoutManager())
                        .findFirstVisibleItemPosition();
                if (SettingValues.scrollSeen) {
                  if (pastVisiblesItems > 0) {
                    HasSeen.addSeen(posts.posts.get(pastVisiblesItems - 1).getFullName());
                  }
                }
              } else {
                int[] firstVisibleItems = null;
                firstVisibleItems =
                    ((CatchStaggeredGridLayoutManager) rv.getLayoutManager())
                        .findFirstVisibleItemPositions(firstVisibleItems);
                if (firstVisibleItems != null && firstVisibleItems.length > 0) {
                  for (int i = 0; i < firstVisibleItems.length; i++) {
                    pastVisiblesItems = firstVisibleItems[i];
                    if (SettingValues.scrollSeen) {
                      if (pastVisiblesItems > 0) {
                        HasSeen.addSeen(posts.posts.get(pastVisiblesItems - 1).getFullName());
                      }
                    }
                  }
                }
              }

              if ((visibleItemCount + pastVisiblesItems) + 5 >= totalItemCount) {
                posts.loading = true;
                posts.loadMore(
                    mSwipeRefreshLayout.getContext(), SubmissionsView.this, false, posts.subreddit);
              }
            }

            /*
            if(dy <= 0 && !down){
                (getActivity()).findViewById(R.id.header).animate().translationY(((BaseActivity)getActivity()).mToolbar.getTop()).setInterpolator(new AccelerateInterpolator()).start();
                down = true;
            } else if(down){
                (getActivity()).findViewById(R.id.header).animate().translationY(((BaseActivity)getActivity()).mToolbar.getTop()).setInterpolator(new AccelerateInterpolator()).start();
                down = false;
            }*/
            // todo For future implementation instead of scrollFlags

            if (fab != null) {
              if (dy <= 0 && fab.getId() != 0 && SettingValues.fab) {

                fab.show();

              } else {
                fab.hide();
              }
            }
          }
        });

    Reddit.isLoading = false;
    if (MainActivity.shouldLoad == null
        || id == null
        || (MainActivity.shouldLoad != null && id != null && MainActivity.shouldLoad.equals(id))
        || !(getActivity() instanceof MainActivity)) {
      doAdapter();
    }
    return v;
  }
示例#16
0
 @Override
 public void onSearching() {
   // - Update snap icon.
   mSnapButton.setImageResource(R.drawable.ic_track_changes_white_24dp);
 }
示例#17
0
 @Override
 public void onArticleRemoved(String message) {
   mSaved = false;
   fabArchive.setImageResource(R.drawable.ic_archive_24dp);
 }
示例#18
0
 @Override
 public void onChecking() {
   // - Update snap icon.
   mSnapButton.setImageResource(R.drawable.ic_spellcheck_white_24dp);
 }
示例#19
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // set theme
    setSystemTheme(getFeedThemeBgId());

    setContentView(R.layout.activity_article);

    ButterKnife.bind(this);

    // get Feed item from intent bundle
    FeedItem feedItem = getFeedItem();

    // set toolbar
    setToolbar(feedItem);

    // set default font sizes
    setFontSize();

    // set feed title
    txtFeedTitle.setText(feedItem.getItemTitle());

    // set feed category
    txtFeedCategory.setText(feedItem.getItemCategory());

    // set feed publish date
    txtFeedPubDate.setText(feedItem.getItemPubDate());

    // set feed image
    Glide.with(ArticleActivity.this)
        .load(feedItem.getItemImgUrl())
        .centerCrop()
        .crossFade()
        .into(imgArticle);

    // load article presenter
    if (mArticlePresenter == null) {
      mArticlePresenter = new ArticlePresenter(ArticleActivity.this, this);
    }

    // load feeds presenter
    if (mFeedsPresenter == null) {
      mFeedsPresenter = new FeedsPresenter(ArticleActivity.this, this);
    }

    // only load the data online if this activity was opened from FeedsFragment
    // , else if it was redirected from ArchiveFragment then load the saved article
    if (feedItem.getItemWebDesc().isEmpty()) {
      mSaved = false;
      if (NetworkConnectionUtil.isNetworkAvailable(ArticleActivity.this)) {
        mArticlePresenter.attemptArticleLoading(feedItem.getItemLink());
      } else {
        NetworkConnectionUtil.showNoNetworkDialog(ArticleActivity.this);
      }
    } else {
      mSaved = true;
      fabArchive.setImageResource(R.drawable.ic_archive_done_24dp);
      txtContent.setText(feedItem.getItemWebDesc());
    } /* else if(!feedItem.getItemWebDescSync().isEmpty()){
          txtContent.setText(feedItem.getItemWebDescSync());
      }*/
  }
示例#20
0
  private void initFab() {
    final BookListDAO bookListDAO = new BookListDAO(BookInfoActivity.this);

    fab = (FloatingActionButton) findViewById(R.id.fab);

    if (bookListDAO.findBookById(BOOKID)) {
      fab.setImageResource(R.drawable.ic_check_white_24dp);
      IS_SAVED_FLAG = true;
    } else {
      fab.setImageResource(R.drawable.ic_book_white_24dp);
      IS_SAVED_FLAG = false;
    }

    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            //  保存如数据库
            if (!IS_SAVED_FLAG) {
              //  未保存
              Snackbar.make(collapsingToolbarLayout, "成功加入我的书单", Snackbar.LENGTH_SHORT)
                  .setCallback(
                      new Snackbar.Callback() {
                        @Override
                        public void onShown(Snackbar snackbar) {
                          bookListDAO.insertBook(
                              BOOKID, BOOK_NAME, BOOK_AUTHOR, BOOK_PUBLISHER, BOOK_CALL_NUMBER);
                          fab.setImageResource(R.drawable.ic_check_white_24dp);
                          IS_SAVED_FLAG = true;
                        }
                      })
                  .setAction(
                      "撤销",
                      new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                          bookListDAO.deleteBook(BOOKID);
                          fab.setImageResource(R.drawable.ic_book_white_24dp);
                        }
                      })
                  .show();
            } else {
              Snackbar.make(collapsingToolbarLayout, "从书单中删除", Snackbar.LENGTH_SHORT)
                  .setCallback(
                      new Snackbar.Callback() {
                        @Override
                        public void onShown(Snackbar snackbar) {
                          bookListDAO.deleteBook(BOOKID);
                          fab.setImageResource(R.drawable.ic_book_white_24dp);
                        }
                      })
                  .setAction(
                      "撤销",
                      new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                          bookListDAO.insertBook(
                              BOOKID, BOOK_NAME, BOOK_AUTHOR, BOOK_PUBLISHER, BOOK_CALL_NUMBER);
                          fab.setImageResource(R.drawable.ic_check_white_24dp);
                        }
                      })
                  .show();
            }
          }
        });
  }
示例#21
0
 private void updateConnectButton() {
   fab.setBackgroundTintList(ecm.isConnected() ? TINT_CONNECTED : TINT_DISCONNECTED);
   fab.setImageResource(ecm.isConnected() ? R.drawable.ic_connected : R.drawable.ic_disconnected);
 }
示例#22
0
 @Override
 public void onArticleSaved(String message) {
   mSaved = true;
   fabArchive.setImageResource(R.drawable.ic_archive_done_24dp);
   Toast.makeText(ArticleActivity.this, "saved: " + message, Toast.LENGTH_SHORT).show();
 }