private void setUpActionButtons() {
    actionButtonLayout = (RelativeLayout) findViewById(R.id.action_button_layout);
    final FloatingActionsMenu actionMenu = (FloatingActionsMenu) findViewById(R.id.add_action_menu);
    final FloatingActionButton manuallyAddButton =
        (FloatingActionButton) findViewById(R.id.add_action_button_manually);
    final FloatingActionButton scanButton =
        (FloatingActionButton) findViewById(R.id.add_action_button_scan);

    actionMenu.setOnFloatingActionsMenuUpdateListener(
        new FloatingActionsMenu.OnFloatingActionsMenuUpdateListener() {
          @Override
          public void onMenuExpanded() {
            dimBackgroundAsAnimation(actionButtonLayout);

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

          @Override
          public void onMenuCollapsed() {
            actionButtonLayout.setBackgroundColor(
                getResources().getColor(android.R.color.transparent));
            actionButtonLayout.setOnClickListener(null);
            actionButtonLayout.setClickable(false);
          }
        });

    manuallyAddButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View view) {

            EvercamPlayApplication.sendEventAnalytics(
                CamerasActivity.this,
                R.string.category_menu,
                R.string.action_add_camera,
                R.string.label_add_camera_manually);

            startActivityForResult(
                new Intent(CamerasActivity.this, AddEditCameraActivity.class),
                Constants.REQUEST_CODE_ADD_CAMERA);

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

            EvercamPlayApplication.sendEventAnalytics(
                CamerasActivity.this,
                R.string.category_menu,
                R.string.action_add_camera,
                R.string.label_add_camera_scan);

            startActivityForResult(
                new Intent(CamerasActivity.this, ScanActivity.class),
                Constants.REQUEST_CODE_ADD_CAMERA);

            actionMenu.collapse();
          }
        });
  }
Esempio n. 2
0
 public void send(View view) {
   TextView textView = (TextView) findViewById(R.id.some_text);
   int id = view.getId();
   FloatingActionsMenu parentMenu = (FloatingActionsMenu) view.getParent();
   switch (id) {
     case R.id.from_curr1:
       currentFromCurrency = countries[0];
       break;
     case R.id.from_curr2:
       currentFromCurrency = countries[1];
       break;
     case R.id.from_curr3:
       currentFromCurrency = countries[2];
       break;
     case R.id.to_curr1:
       currentToCurrency = countries[0];
       break;
     case R.id.to_curr2:
       currentToCurrency = countries[1];
       break;
     case R.id.to_curr3:
       currentToCurrency = countries[2];
       break;
     default:
       break;
   }
   currentRate = rates.get(currentToCurrency) / rates.get(currentFromCurrency);
   update();
   parentMenu.collapse();
   onWindowFocusChanged(true);
 }
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.fbNewExit:
       multiple_actions.collapse();
       getActivity().startActivityForResult(new Intent(getActivity(), ExitActivity.class), 1);
       break;
     case R.id.fbNewEntry:
       multiple_actions.collapse();
       getActivity().startActivityForResult(new Intent(getActivity(), EntryActivity.class), 1);
       break;
   }
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, final ViewGroup container, Bundle savedInstance) {

    View v = inflater.inflate(R.layout.fragment_movement, container, false);
    croutonParent = container;

    fabButton = (FloatingActionButton) getActivity().findViewById(R.id.fabButton);
    fabButton.hide();
    /*if(Utils.getDefaultWalletIdPref(getActivity())==-1)
        fabButton.hide(true);
    else
        fabButton.show(true);*/

    cursorCardAdapter =
        new MovementCursorCardAdapter(
            getActivity(),
            dbHelper.getMovementsOfWallet(
                Utils.getDefaultWalletIdPref(getActivity()), Const.KEY_MOVEMENT_DATE, true),
            false); // dbHelper.getMovementsOfWallet(Utils.getDefaultWalletIdPref(getActivity()),
    // Const.KEY_MOVEMENT_NAME),false, true);

    listViewMovement = (CardListView) v.findViewById(R.id.listViewMovement);
    if (listViewMovement != null) {
      listViewMovement.setAdapter(cursorCardAdapter);
    }
    LayoutAnimationController lac =
        new LayoutAnimationController(
            AnimationUtils.loadAnimation(getActivity(), R.anim.table_row_appear),
            0.5f); // 0.5f == time between appearance of listview items.
    listViewMovement.setLayoutAnimation(lac);
    listViewMovement.setFastScrollEnabled(true);
    listViewMovement.setEmptyView(v.findViewById(R.id.emtyView));

    /*fabButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialogAddMovement();
        }
    });
    fabButton.attachToListView(listViewMovement);*/

    multiple_actions = (FloatingActionsMenu) v.findViewById(R.id.multiple_actions);
    fbNewExit =
        (com.getbase.floatingactionbutton.FloatingActionButton) v.findViewById(R.id.fbNewExit);
    fbNewEntry =
        (com.getbase.floatingactionbutton.FloatingActionButton) v.findViewById(R.id.fbNewEntry);
    fbNewEntry.setOnClickListener(this);
    fbNewExit.setOnClickListener(this);
    if (Utils.getDefaultWalletIdPref(getActivity()) == -1)
      multiple_actions.setVisibility(View.GONE);
    else fabButton.setVisibility(View.VISIBLE);

    return v;
  }
Esempio n. 5
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View rootView = inflater.inflate(R.layout.lay_fragpayable, container, false);

    recyclerView = (RecyclerView) rootView.findViewById(R.id.recycleviewPay);
    layoutNoContent = (LinearLayout) rootView.findViewById(R.id.layoutNoContent);

    FloatingActionsMenu actionsMenu =
        (FloatingActionsMenu) getActivity().findViewById(R.id.multiple_actions);

    actionsMenu.setVisibility(View.GONE);
    FloatingActionButton fab = (FloatingActionButton) getActivity().findViewById(R.id.fab);
    fab.setVisibility(View.VISIBLE);

    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Intent intent = new Intent(getActivity(), manage_bill.class);
            intent.putExtra(AppConfig.BILL_ID, billId);
            startActivity(intent);
          }
        });

    // Recycleview onitem touch
    recyclerView.addOnItemTouchListener(
        new RecyclerView.OnItemTouchListener() {
          @Override
          public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
            View child = recyclerView.findChildViewUnder(e.getX(), e.getY());
            if (child != null && mGestureDetector.onTouchEvent(e)) {
              onItemClick(child);
              return true;
            }
            return false;
          }

          @Override
          public void onTouchEvent(RecyclerView rv, MotionEvent e) {}

          @Override
          public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {}
        });

    // recicleview onswipe
    final SimpleCallback simpleItemTouchCallback =
        new SimpleCallback(0, LEFT | RIGHT) {
          @Override
          public boolean onMove(
              RecyclerView recyclerView,
              RecyclerView.ViewHolder viewHolder,
              RecyclerView.ViewHolder target) {
            return false;
          }

          @Override
          public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
            onSwipeDelete(viewHolder, rootView);
          }
        };

    mOnClickListener =
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            restoreBill();
            Snackbar snackbar1 =
                Snackbar.make(rootView, AppConfig.BILL_RESTORED, Snackbar.LENGTH_SHORT);

            snackbar1.show();
          }
        };

    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
    itemTouchHelper.attachToRecyclerView(recyclerView);

    loadBills();
    return rootView;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // view
    toolbar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(toolbar);

    // view
    grid = (GridView) findViewById(R.id.all_room_container);

    // Menu----------------------------

    TextView addThing = (TextView) findViewById(R.id.add_room);
    addThing.setText("Add device  ");

    items.add(new GridItem("Light", R.mipmap.r_light, R.mipmap.light, GridItem.ItemType.Light));
    // Instance of ImageAdapter Class
    grid.setAdapter(new GridItemAdapter(this, items, this));

    FloatingActionButton b0 = new FloatingActionButton(this);

    final List<FloatingActionButton> button = Arrays.asList(b0);

    ScrollView menu_container = (ScrollView) findViewById(R.id.fab_menu_container);

    // FAB_menu-----
    FloatingActionsMenu fab = new FloatingActionsMenu(this);
    menu_container.addView(fab);
    // -----FAB_menu [end]

    for (final FloatingActionButton b : button) {
      final GridItem current = items.get(button.indexOf(b));
      //            b.setTitle(String.valueOf(current.name));
      b.setIcon(current.resIconId);
      b.setColorNormal(Color.parseColor("#FFFFFF"));
      b.setTag(current.type);
      fab.addButton(button.get(button.indexOf(b)));

      b.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(final View v) {
              AlertDialog dialogInputText =
                  new AlertDialog.Builder(DeviceCategoriesActivity.this).create();
              // dialogInputText.setTitle("Add " + String.valueOf(current.name));
              dialogInputText.setTitle(String.valueOf(current.type));

              View dialogView =
                  getLayoutInflater().inflate(R.layout.dialog_input_text_device, null);
              final EditText dialogTextName =
                  (EditText) dialogView.findViewById(R.id.dialog_text_name);

              dialogInputText.setView(dialogView);
              dialogInputText.setButton(
                  "OK",
                  new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {

                      // grid type
                      GridItem.ItemType type = current.type;
                      String name = dialogTextName.getText().toString();

                      // add gridItem with correct icon
                      GridItem toBeAdded = addRoom(name, type);

                      // badge Type ++
                      ((GridItemAdapter) grid.getAdapter()).items.get(button.indexOf(b)).badge++;

                      ((GridItemAdapter) grid.getAdapter()).notifyDataSetChanged();

                      // item Type add
                      ((WirelessHomeApplication) getApplication())
                          .roomRepository.addRoom(toBeAdded);

                      Toast.makeText(
                              DeviceCategoriesActivity.this,
                              grid.getChildAt(button.indexOf(b)).getTag() + " successfully created",
                              Toast.LENGTH_LONG)
                          .show();
                    }
                  });

              dialogInputText.show();
            }
          });
    }

    // ----------------------------Menu [end]

  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_question);
    MobclickAgent.onEvent(this, Mob.Event_Open_Question);
    loadingView = (LoadingView) findViewById(R.id.question_progress_loading);
    loadingView.setReloadListener(this);
    progressBar = (ProgressBar) findViewById(R.id.question_loading);
    Toolbar toolbar = (Toolbar) findViewById(R.id.action_bar);
    setSupportActionBar(toolbar);
    toolbar.setOnClickListener(
        new View.OnClickListener() {

          boolean preparingToScrollToHead = false;

          @Override
          public void onClick(View v) {
            if (preparingToScrollToHead) {
              listView.setSelection(0);
            } else {
              preparingToScrollToHead = true;
              new Handler()
                  .postDelayed(
                      new Runnable() {
                        @Override
                        public void run() {
                          preparingToScrollToHead = false;
                        }
                      },
                      200);
            }
          }
        });
    View headView = findViewById(R.id.head_view);
    question = (Question) getIntent().getSerializableExtra(Consts.Extra_Question);
    notice_id = getIntent().getStringExtra(Consts.Extra_Notice_Id);
    listView = (LListView) findViewById(R.id.list_detail);
    adapter = new QuestionDetailAdapter(this);
    listView.setAdapter(adapter);

    listView.setCanPullToLoadMore(false);
    listView.setOnRefreshListener(this);
    listView.setOnItemClickListener(onItemClickListener);

    floatingActionsMenu = (FloatingActionsMenu) findViewById(R.id.layout_operation);
    FloatingActionButton replyButton = (FloatingActionButton) findViewById(R.id.button_reply);
    FloatingActionButton recomButton = (FloatingActionButton) findViewById(R.id.button_recommend);
    FloatingActionButton favorButton = (FloatingActionButton) findViewById(R.id.button_favor);

    replyButton.setOnClickListener(this);
    recomButton.setOnClickListener(this);
    favorButton.setOnClickListener(this);

    AutoHideUtil.applyListViewAutoHide(
        this,
        listView,
        headView,
        floatingActionsMenu,
        (int) getResources().getDimension(R.dimen.abc_action_bar_default_height_material));
    floatingActionsMenu.setVisibility(View.GONE);
    loadData(-1);
  }