@Override
  public void onClick(View v) {
    SharedPreferences gameSettings = getSharedPreferences(GAME_SETTING_PREFS, 0);
    SharedPreferences.Editor editor = gameSettings.edit();

    if (v.getId() == R.id.playBtn) {
      Intent nextIntent;

      SharedPreferences gameState = getSharedPreferences(GameActivity.GAME_STATE_PREFS, 0);
      final int currLevel = gameState.getInt(GameActivity.STATE_LEVEL, 0);

      nextIntent = new Intent(this, GameActivity.class);
      MediaController.stopLoopingSound();

      // startNext intent
      startActivity(nextIntent);
    } else if (v.getId() == R.id.settings_btn) {
      RelativeLayout settingsWrap = (RelativeLayout) findViewById(R.id.other_settings_buttons_wrap);
      if (View.GONE == settingsWrap.getVisibility()) {
        settingsWrap.setVisibility(View.VISIBLE);
      } else {
        settingsWrap.setVisibility(View.GONE);
      }
    } else if (v.getId() == R.id.toggle_sound) {
      boolean soundEdit = gameSettings.getBoolean(SOUND_PREF, true);
      editor.putBoolean(SOUND_PREF, !soundEdit);
      editor.commit();

      if (soundEdit) {
        Toast.makeText(getApplicationContext(), "Sound is turned off", Toast.LENGTH_SHORT).show();
        MediaController.stopLoopingSound();
      } else {
        Toast.makeText(getApplicationContext(), "Sound is turned on", Toast.LENGTH_SHORT).show();
        MediaController.playSoundClip(this, R.raw.background_intro, true);
      }
    } else if (v.getId() == R.id.toggle_vibration) {
      boolean vibrateEdit = gameSettings.getBoolean(VIBRATE_PREF, true);
      editor.putBoolean(VIBRATE_PREF, !vibrateEdit);

      String vibrateState = (!vibrateEdit) ? "on" : "off";
      Toast.makeText(
              getApplicationContext(), "Vibration is turned " + vibrateState, Toast.LENGTH_SHORT)
          .show();
    } else if (v.getId() == R.id.show_credits) {
      new GameAlertDialogBuilder(this)
          .setTitle("Credits")
          .setMessage(this.getResources().getString(R.string.credits))
          .setPositiveButton(
              android.R.string.no,
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  dialog.cancel();
                }
              })
          .show();
    }
    editor.commit();

    updateColorOfSettingsButtons();
  }
Example #2
0
 public void showGameBottom() {
   if (bottomMenuContainer.getVisibility() == View.GONE
       || bottomMenuContainer.getVisibility() == View.INVISIBLE) {
     bottomMenuContainer.setVisibility(View.VISIBLE);
   }
   commonBottom.setVisibility(View.INVISIBLE);
   playBottom.setVisibility(View.VISIBLE);
 }
 public boolean isBack() {
   if (menuBgLayout.getVisibility() == View.VISIBLE) {
     hiddenMenuBg();
     return true;
   }
   return false;
 }
 @Override
 public void onSaveInstanceState(Bundle outState) {
   outState.putString(KEY_STATUSMESSAGE, statusMessage);
   outState.putString(KEY_FILENAME, filename);
   outState.putInt(KEY_ADVANCEDSETTINGS, advancedRl.getVisibility());
   super.onSaveInstanceState(outState);
 }
Example #5
0
  private void next(boolean bplay) {
    Logger.LOGD("fun ...... next...");
    mPlayingIdx = 0;
    if (mRunMode == Configer.RunMode.MODE_NETWORK) {
      if (mAdapter.getCount() - mHListView.getClickPos() < 12) { // 这儿与onscroll事件是有些不一样的哦
        Logger.LOGD("", "!!!!!! begin to load pg: " + (mCurPg + 1));
        queryPlayList(mCurPg + 1);
      }
    }

    if (bplay) {
      int pos = mHListView.getClickPos() + 1;
      if (mAdapter == null || mData.size() == 0) {
        onExitProc();
        return;
      }
      if (pos >= mData.size()) {
        pos = 0;
      }
      mHListView.setClickPos(pos);

      int setgrppos = (int) (Math.ceil((pos * 1f) / PAGE_SIZE) - 1);
      if (setgrppos >= 0) {
        mCurSetsGrpIdx = setgrppos;
        mSetsHList.setSelection(mCurSetsGrpIdx);
      }

      // 仅当隐藏时,其才将当前播放的滚动到开头,避免用户在选择影片时,其突然跳到正在播放的条目
      if (/*mFill1*/ mLayerTop.getVisibility() == View.INVISIBLE) mHListView.setSelection(pos);

      myPlay(pos);
    }
  }
Example #6
0
 // ****************************************************************
 // * Functions
 // ****************************************************************
 public boolean checkBackButton() throws Exception {
   Logger.d("checkBackButton");
   if (layoutWebViewAddScoin.getVisibility() == VISIBLE) {
     showWebView(false);
     return true;
   } else {
     return false;
   }
 }
  @Override
  public void onBackPressed() {

    if (layoutDevices.getVisibility() == View.VISIBLE) {
      layoutDevices.setVisibility(View.INVISIBLE);
    } else {
      super.onBackPressed();
    }
  }
  @Override
  protected void onResume() {
    super.onResume();

    if (mLoaclVideoView != null && mLoaclVideoView.getVisibility() == View.VISIBLE) {
      SurfaceView localView = ViERenderer.CreateLocalRenderer(this);
      mLoaclVideoView.addView(localView);
    }

    lockScreen();
  }
  @Override
  public void onClick(View v) {
    Log.d(TAG, "onSearchClick()");
    RelativeLayout searchPanel = (RelativeLayout) findViewById(R.id.extended_search);

    if (searchPanel.getVisibility() == View.GONE) {
      searchPanel.setVisibility(View.VISIBLE);
    } else {
      searchPanel.setVisibility(View.GONE);
    }
  }
  public void closeSideBar() {

    if (mRlSideBarHolder.getVisibility() == View.VISIBLE) {
      mRlBody.bringToFront();
      mRlSideBarHolder.startAnimation(SpikaApp.getSlideOutLeft());
      mRlBody.startAnimation(SpikaApp.getSlideInRight());
      mRlSideBarHolder.setVisibility(View.INVISIBLE);
      mSideBarOpened = false;
    }

    enableViews();
  }
Example #11
0
  /** 回到正常选择模式 */
  public void toNormal() {
    editmodel = false;
    listAdapter.setEdit(false);
    listAdapter.initMap();
    noteListView.setAdapter(listAdapter);

    if (editTopLayout.getVisibility() == View.VISIBLE) {
      editTopLayout.setVisibility(View.GONE);
      bottomLayout.setVisibility(View.GONE);
      bottomLayout.startAnimation(AnimationUtils.loadAnimation(this, R.anim.push_bottom_out));
      editTopLayout.startAnimation(AnimationUtils.loadAnimation(this, R.anim.push_top_out));
    }

    if (searchTitle.getVisibility() == View.VISIBLE) {
      searchTitle.setVisibility(View.GONE);
      searchTitle.startAnimation(AnimationUtils.loadAnimation(this, R.anim.push_top_out));
    }

    // 恢复侧栏可用
    slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    seeAllButton.setEnabled(true); // 恢复侧栏按钮可用
    addNoteButton.setEnabled(true); // 恢复添加按钮可用
  }
  @SuppressWarnings("deprecation")
  private void setKeyStowDrawableAndVisibility() {
    Drawable replacer = null;
    if (layoutKeys.getVisibility() == View.GONE)
      replacer = getResources().getDrawable(R.drawable.showkeys);
    else replacer = getResources().getDrawable(R.drawable.hidekeys);

    int sdk = android.os.Build.VERSION.SDK_INT;
    if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
      keyStow.setBackgroundDrawable(replacer);
    } else {
      keyStow.setBackground(replacer);
    }

    if (connection.getExtraKeysToggleType() == Constants.EXTRA_KEYS_OFF)
      keyStow.setVisibility(View.GONE);
    else keyStow.setVisibility(View.VISIBLE);
  }
 public void testNoResultForVendorsFavorites() {
   loadingSplashPage();
   assertLoginByUserInfo("*****@*****.**", "123456");
   getSolo().goBack();
   getSolo().clickOnView(getSolo().getView(android.R.id.home));
   getSolo().sleep(WAIT_LONG_TIME);
   View menuItemView = getSolo().getView(R.id.menu_item_title_favorites);
   getSolo().clickOnView(menuItemView);
   getSolo().sleep(WAIT_LONG_TIME);
   assertWaitForSpinner("fragment_favorites", R.id.loading_bar);
   ListView mVendorFavoritesListView = (ListView) getSolo().getView(R.id.lv_all_favorits);
   assertEquals(true, mVendorFavoritesListView != null);
   boolean flag =
       getSolo()
           .waitForCondition(
               new FavoritesListViewNotEmptyCondition(mVendorFavoritesListView),
               WAIT_FOR_FAVORITES_RESPONSE_TIME);
   assertEquals(false, flag);
   getSolo().sleep(WAIT_LONG_TIME);
   RelativeLayout mNoResRelativeLayout =
       (RelativeLayout) getSolo().getView(R.id.rl_vendor_no_result);
   assertEquals(true, mNoResRelativeLayout.getVisibility() == View.VISIBLE);
 }
  @Override
  public void onBackPressed() {
    if (backScreen.getVisibility() == View.INVISIBLE) {
      backScreen.setVisibility(View.VISIBLE);

      AlphaAnimation screenAnim = new AlphaAnimation(0.5f, 0.5f);
      screenAnim.setDuration(0);
      screenAnim.setFillAfter(true);
      backScreen.setAnimation(screenAnim);

      resumeButton.setEnabled(true);
      exitButton.setEnabled(true);
    } else {
      backScreen.setVisibility(View.INVISIBLE);

      AlphaAnimation screenAnim = new AlphaAnimation(0f, 0f);
      screenAnim.setDuration(0);
      screenAnim.setFillAfter(true);
      backScreen.setAnimation(screenAnim);

      resumeButton.setEnabled(false);
      exitButton.setEnabled(false);
    }
  }
Example #15
0
 public void mostrarPreguntaDias(View button) {
   if (layoutPreguntaDias.getVisibility() == View.VISIBLE) {
     layoutPreguntaDias.setVisibility(View.GONE);
   } else layoutPreguntaDias.setVisibility(View.VISIBLE);
 }
 private void toggleAdvancedSettings() {
   advancedRl.setVisibility(advancedRl.getVisibility() == View.GONE ? View.VISIBLE : View.GONE);
 }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

      RelativeLayout v;
      View child;

      // Log.d("mobeta",
      // "getView: position="+position+" convertView="+convertView);
      if (convertView != null) {

        v = (RelativeLayout) convertView;
        View oldChild = v.getChildAt(0);

        // child = super.getView(position, oldChild, v);
        child = mAdapter.getView(position, oldChild, v);
        if (child != oldChild) {
          // shouldn't get here if user is reusing convertViews
          // properly
          v.removeViewAt(0);
          v.addView(child);
          // check that tags are equal too?
          v.setTag(child.findViewById(R.id.drag));
        }

      } else {
        AbsListView.LayoutParams params =
            new AbsListView.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        v = new RelativeLayout(getContext());
        v.setLayoutParams(params);
        child = mAdapter.getView(position, null, v);
        v.addView(child);

        v.setTag(child.findViewById(R.id.drag));
      }

      ViewGroup.LayoutParams lp = v.getLayoutParams();
      final int numHeaders = getHeaderViewsCount();

      final int srcAdapter = mSrcDragPos - numHeaders;
      final int expAdapter = mExpDragPos - numHeaders;

      boolean itemIsNormal = position != srcAdapter && position != expAdapter;
      boolean listHasExpPos = mDragState == SRC_ABOVE || mDragState == SRC_BELOW;
      boolean itemNeedsWC = itemIsNormal || !listHasExpPos;

      int oldHeight = lp.height;
      if (itemNeedsWC && lp.height != ViewGroup.LayoutParams.WRAP_CONTENT) {
        // items that have a user-provided height
        lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
      } else if (listHasExpPos) {
        if (position == srcAdapter && lp.height != mItemHeightCollapsed) {
          // collapsed items
          lp.height = mItemHeightCollapsed;
        } else if (position == expAdapter) {
          // what if a previously-expanded wrapper view is used
          // as a convertView for a different expanded item?
          // Always measure child
          int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
          child.measure(spec, spec);

          mExpandedChildHeight = child.getMeasuredHeight();
          // Log.d("mobeta",
          // "childh="+mExpandedChildHeight+" pos="+position);
          int height = mExpandedChildHeight + mFloatViewHeight;
          if (lp.height != height) {
            lp.height = height;
          }

          // set gravity
          if (mDragState == SRC_ABOVE) {
            v.setGravity(Gravity.TOP);
          } else {
            v.setGravity(Gravity.BOTTOM);
          }
        }
      }

      if (lp.height != oldHeight) {
        v.setLayoutParams(lp);
      }

      int oldVis = v.getVisibility();
      int vis = oldVis;

      if (position == srcAdapter && mDragState != NO_DRAG) {
        if (vis == View.VISIBLE) {
          vis = View.INVISIBLE;
        }
      } else if (vis == View.INVISIBLE) {
        vis = View.VISIBLE;
      }

      if (vis != oldVis) {
        v.setVisibility(vis);
      }

      return v;
    }
Example #18
0
  /**
   * 点击事件逻辑
   *
   * @param v
   */
  public void widgetClick(View v) {
    switch (v.getId()) {

        // 清空聊天记录按钮
      case R.id.container_menu:
        {
          String st5 = getResources().getString(R.string.Whether_to_empty_all_chats);
          startActivityForResult(
              new Intent(this, AlertDialog.class)
                  .putExtra("titleIsCancel", true)
                  .putExtra("msg", st5)
                  .putExtra("cancel", true),
              REQUEST_CODE_EMPTY_HISTORY);
          break;
        }

      case R.id.btn_set_mode_voice:
        {
          // 点击录音部分视图显示状态变化
          hideKeyboard();
          edittext_layout.setVisibility(View.GONE);
          more.setVisibility(View.GONE);
          v.setVisibility(View.GONE);
          buttonSetModeKeyboard.setVisibility(View.VISIBLE);
          buttonSend.setVisibility(View.GONE);
          btnMore.setVisibility(View.VISIBLE);
          buttonPressToSpeak.setVisibility(View.VISIBLE);
          iv_emoticons_normal.setVisibility(View.VISIBLE);
          iv_emoticons_checked.setVisibility(View.INVISIBLE);
          btnContainer.setVisibility(View.VISIBLE);
          emojiIconContainer.setVisibility(View.GONE);
          break;
        }

      case R.id.btn_set_mode_keyboard:
        {
          // 点击键盘按钮图标显示状态变化
          edittext_layout.setVisibility(View.VISIBLE);
          more.setVisibility(View.GONE);
          v.setVisibility(View.GONE);
          buttonSetModeVoice.setVisibility(View.VISIBLE);
          mEditTextContent.requestFocus();
          buttonPressToSpeak.setVisibility(View.GONE);
          if (TextUtils.isEmpty(mEditTextContent.getText())) {
            btnMore.setVisibility(View.VISIBLE);
            buttonSend.setVisibility(View.GONE);
          } else {
            btnMore.setVisibility(View.GONE);
            buttonSend.setVisibility(View.VISIBLE);
          }
          break;
        }

      case R.id.btn_more:
        {
          // 点击更多按钮
          if (more.getVisibility() == View.GONE) {
            hideKeyboard();
            more.setVisibility(View.VISIBLE);
            btnContainer.setVisibility(View.VISIBLE);
            alarmPreview_layout.setVisibility(View.GONE);
            emojiIconContainer.setVisibility(View.GONE);
          } else if (emojiIconContainer.getVisibility() == View.VISIBLE) {
            emojiIconContainer.setVisibility(View.GONE);
            btnContainer.setVisibility(View.VISIBLE);
            iv_emoticons_normal.setVisibility(View.VISIBLE);
            iv_emoticons_checked.setVisibility(View.INVISIBLE);
          } else if (alarmPreview_layout.getVisibility() == View.VISIBLE) {
            alarmPreview_layout.setVisibility(View.GONE);
            btnContainer.setVisibility(View.VISIBLE);
          } else {
            more.setVisibility(View.GONE);
          }
          break;
        }

      case R.id.et_sendmessage:
        {
          listView.setSelection(listView.getCount() - 1);
          if (more.getVisibility() == View.VISIBLE) {
            more.setVisibility(View.GONE);
            iv_emoticons_normal.setVisibility(View.VISIBLE);
            iv_emoticons_checked.setVisibility(View.INVISIBLE);
          }
          break;
        }

      default:
        break;
    }
  }
Example #19
0
  private void render() {

    if (mHeaderView != null) {
      if (mExpandableListView.getHeaderViewsCount() <= 0) {
        mHeaderView.findViewById(R.id.filter_select_class).setOnClickListener(this);
        mHasGoodView.setOnClickListener(this);
        mExpandableListView.addHeaderView(mHeaderView);
        selectedViewContainer.setVisibility(
            null == mSearchCategoryModels ? View.GONE : View.VISIBLE);
        mHeaderView
            .findViewById(R.id.filter_select_topline)
            .setVisibility(selectedViewContainer.getVisibility());
      }
    }
    if (null != selectedCategoryView) {
      if (!TextUtils.isEmpty(mSearchModel.getCategoryName())) {
        selectedCategoryView.setText(mSearchModel.getCategoryName());
      }
    }

    refreshHasGoodView();

    if (mSearchFilterAttributeModels.size() == 0
        && null == mSearchCategoryModels
        && total_num <= 0) {
      findViewById(R.id.filter_relative_empty).setVisibility(View.VISIBLE);
      findViewById(R.id.global_container).setVisibility(View.GONE);
      return;
    }

    for (SearchFilterAttributeModel mSearchFilterAttributeModel : mSearchFilterAttributeModels) {
      String[] options = mSearchModel.getOptions(mSearchFilterAttributeModel.getId());

      for (SearchFilterOptionModel mSearchFilterOptionModel :
          mSearchFilterAttributeModel.getSearchFilterOptionModels()) {
        if (options == null || options.length == 0) {
          mSearchFilterOptionModel.setSelect(false);
        } else {
          boolean found = false;
          for (String option : options) {
            if (mSearchFilterOptionModel.getId() == Integer.valueOf(option)) {
              found = true;
              mSearchFilterOptionModel.setSelect(true);
            }
          }

          if (!found) {
            mSearchFilterOptionModel.setSelect(false);
          }
        }
      }
    }

    if (null == mFilterAdapter) {
      mFilterAdapter = new FilterAdapter(this, mSearchFilterAttributeModels);
      mExpandableListView.setAdapter(mFilterAdapter);
    } else {
      mFilterAdapter.notifyDataSetChanged();

      // 默认刷新数据时将ListView默认收缩
      int groupCount = mExpandableListView.getCount();
      for (int i = 0; i < groupCount; i++) {
        mExpandableListView.collapseGroup(i);
      }
      ;
    }
  }
  private void showRealTimeLocationBar(RealTimeLocationConstant.RealTimeLocationStatus status) {

    if (status == null)
      status =
          RongIMClient.getInstance().getRealTimeLocationCurrentState(mConversationType, targetId);

    final List<String> userIds =
        RongIMClient.getInstance().getRealTimeLocationParticipants(mConversationType, targetId);

    if (status != null
        && status
            == RealTimeLocationConstant.RealTimeLocationStatus
                .RC_REAL_TIME_LOCATION_STATUS_INCOMING) {

      if (userIds != null && userIds.get(0) != null && userIds.size() == 1) {

        DemoContext.getInstance()
            .getDemoApi()
            .getUserInfo(
                userIds.get(0),
                new DemoApi.GetUserInfoListener() {

                  @Override
                  public void onSuccess(final UserInfo userInfo) {
                    runOnUiThread(
                        new Runnable() {
                          @Override
                          public void run() {
                            TextView textView =
                                (TextView) mRealTimeBar.findViewById(android.R.id.text1);
                            textView.setText(userInfo.getName() + " 正在共享位置");
                          }
                        });
                  }

                  @Override
                  public void onError(String userId, BaseException e) {}
                });
      } else {
        if (userIds != null && userIds.size() > 0) {
          if (mRealTimeBar != null) {
            TextView textView = (TextView) mRealTimeBar.findViewById(android.R.id.text1);
            textView.setText(userIds.size() + " 人正在共享位置");
          }
        } else {
          if (mRealTimeBar != null && mRealTimeBar.getVisibility() == View.VISIBLE) {
            mRealTimeBar.setVisibility(View.GONE);
          }
        }
      }

    } else if (status != null
        && status
            == RealTimeLocationConstant.RealTimeLocationStatus
                .RC_REAL_TIME_LOCATION_STATUS_OUTGOING) {
      TextView textView = (TextView) mRealTimeBar.findViewById(android.R.id.text1);
      textView.setText("你正在共享位置");
    } else {

      if (mRealTimeBar != null && userIds != null) {
        TextView textView = (TextView) mRealTimeBar.findViewById(android.R.id.text1);
        textView.setText(userIds.size() + " 人正在共享位置");
      }
    }

    if (userIds != null && userIds.size() > 0) {

      if (mRealTimeBar != null && mRealTimeBar.getVisibility() == View.GONE) {
        mRealTimeBar.setVisibility(View.VISIBLE);
      }
    } else {

      if (mRealTimeBar != null && mRealTimeBar.getVisibility() == View.VISIBLE) {
        mRealTimeBar.setVisibility(View.GONE);
      }
    }
  }
Example #21
0
 public void changeBottomVisiblity(int type) {
   if (bottomMenuContainer.getVisibility() != type) bottomMenuContainer.setVisibility(type);
 }
Example #22
0
 private void dismissButtonRefresh() {
   if (buttonRefresh.getVisibility() == View.VISIBLE) buttonRefresh.setVisibility(View.GONE);
 }
Example #23
0
 private boolean isSearchFilerShowing() {
   if (filterLayout != null && filterLayout.getVisibility() == View.VISIBLE) return true;
   else return false;
 }
Example #24
0
  private void findViews() {

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(
            this,
            drawer,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    nestedScrollView = (NestedScrollView) findViewById(R.id.nsv);
    prefs = getSharedPreferences("user_prefs", MODE_PRIVATE);
    // Button
    addVoltButton = (Button) findViewById(R.id.addVoltButton);
    addMinuteButton = (Button) findViewById(R.id.addMinuteButton);
    decreaseVoltButton = (Button) findViewById(R.id.decreaseVoltButton);
    decreaseMinuteButton = (Button) findViewById(R.id.decreaseMinuteButton);
    buttonStartTime = (Button) findViewById(R.id.btnStartTime);
    buttonStopTime = (Button) findViewById(R.id.btnStopTime);
    minuteHelpText = (TextView) findViewById(R.id.minuteHelpText);
    // TextViews
    textViewShowTime = (TextView) findViewById(R.id.tvTimeCount);
    volts = (TextView) findViewById(R.id.volts);
    volts.setText(prefs.getInt("volts", 20) + "");

    minutes = (TextView) findViewById(R.id.minutes);
    minutes.setText(prefs.getInt("minutes", 2) + "");

    // checkbox
    delayCheckBox = (CheckBox) findViewById(R.id.delayCheckBox);
    delayCheckBox.setChecked(prefs.getBoolean("delay", false));
    delaytimer = delayCheckBox.isChecked();

    voltageTextView = (TextView) findViewById(R.id.voltage_textview);
    polarityTextView = (TextView) findViewById(R.id.polarity_textview);

    // Progress Bar
    mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
    //  Floating Action Button
    // fab = (FloatingActionButton) findViewById(R.id.fab);

    // Views
    rootview = (RelativeLayout) findViewById(R.id.rootview);
    connect_button_view = (RelativeLayout) findViewById(R.id.connect_button_view);
    connectDeviceButton = (Button) findViewById(R.id.connect_device_button);

    // set connect view
    setVisibility(CONNECT_VIEW);

    // this should make the screen stay on when rootview is visible
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    if (rootview != null && rootview.getVisibility() == View.VISIBLE) {
      rootview.setKeepScreenOn(true);
    }

    mProgressBar
        .getBackground()
        .setColorFilter(Color.argb(255, 0, 230, 118), PorterDuff.Mode.SRC_IN);
    mProgressBar
        .getProgressDrawable()
        .setColorFilter(Color.argb(255, 0, 230, 118), PorterDuff.Mode.SRC_IN);

    // Listeners
    addMinuteButton.setOnClickListener(this);
    addVoltButton.setOnClickListener(this);
    decreaseVoltButton.setOnClickListener(this);
    decreaseMinuteButton.setOnClickListener(this);
    buttonStartTime.setOnClickListener(this);
    buttonStopTime.setOnClickListener(this);
    // fab.setOnClickListener(this);
    connectDeviceButton.setOnClickListener(this);
    textViewShowTime.setOnClickListener(this);
    delayCheckBox.setOnCheckedChangeListener(this);

    final Snackbar snackbar =
        Snackbar.make(
                nestedScrollView, "Bluetooth has not been enabled", Snackbar.LENGTH_INDEFINITE)
            .setAction(
                "ENABLE",
                new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                    // ENABLE DEVICE'S BLUETOOTH
                    setDeviceBluetooth(true);
                  }
                });

    bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    boolean isEnabled = bluetoothAdapter.isEnabled();
    if (!isEnabled) {

      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder
          .setTitle(getBaseContext().getResources().getString(R.string.use_bluetooth))
          .setMessage(getBaseContext().getResources().getString(R.string.need_bluetooth_pliz))
          .setCancelable(false)
          .setPositiveButton(
              getBaseContext().getResources().getString(R.string.yes),
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  // ENABLE DEVICE'S BLUETOOTH
                  setDeviceBluetooth(true);
                  dialog.dismiss();
                }
              })
          .setNegativeButton(
              getBaseContext().getResources().getString(R.string.no),
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  snackbar.show();
                  dialog.dismiss();
                }
              });
      AlertDialog alertDialog = builder.create();

      alertDialog.show();
    }
  }
Example #25
0
 private void switchManagePage() {
   int vis = manageBody.getVisibility();
   manageBody.setVisibility(manageNewProtest.getVisibility());
   manageNewProtest.setVisibility(vis);
 }