Пример #1
0
  /*
   * Create scrolling card deck with two cards
   */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(WindowUtils.FEATURE_VOICE_COMMANDS);
    getActionBar().hide();

    PACKAGE_NAME = getPackageName();
    rootView = getWindow().getDecorView().getRootView();
    isCasting = false;

    mCards = new ArrayList<CardBuilder>();
    mCards.add(
        new CardBuilder(this, CardBuilder.Layout.TEXT).setText("Quotes from Friedrich Nietzsche"));
    mCards.add(new CardBuilder(this, CardBuilder.Layout.TEXT).setText("Quotes from Lao Zi"));

    mCardScrollAdapter = new CustomCardScrollAdapter(mCards);

    mCardScrollView = new CardScrollView(this);
    mCardScrollView.setAdapter(mCardScrollAdapter);
    mCardScrollView.activate();
    mCardScrollView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            openOptionsMenu();
          }
        });
    setContentView(mCardScrollView);
  }
Пример #2
0
  @Override
  protected void onCreate(Bundle bundle) {

    super.onCreate(bundle);

    ((GlassTuneApplication) getApplication()).inject(this);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    mView = buildView();

    mCardScroller = new CardScrollView(this);
    mCardScroller.setAdapter(
        new CardScrollAdapter() {
          @Override
          public int getCount() {
            return 1;
          }

          @Override
          public Object getItem(int position) {
            return mView;
          }

          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
            return mView;
          }

          @Override
          public int getPosition(Object item) {
            if (mView.equals(item)) {
              return 0;
            }
            return AdapterView.INVALID_POSITION;
          }
        });

    // Handle the TAP event.
    mCardScroller.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            openOptionsMenu();
          }
        });

    setContentView(mCardScroller);
    createAndShowDialog(
        R.drawable.ic_action_guitar_150,
        R.string.initial_overlay_text,
        R.string.initial_overlay_footnote);
    startPitchDetection();
    Log.d("TAG", "Created View");
  }
Пример #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    createCards();

    pCardScrollView = new CardScrollView(this);
    PropertyCardScrollAdapter adapter = new PropertyCardScrollAdapter();
    pCardScrollView.setAdapter(adapter);
    pCardScrollView.activate();
    setContentView(pCardScrollView);
  }
Пример #4
0
 @Override
 protected void onCreate(Bundle bundle) {
   super.onCreate(bundle);
   WintLess2 = new CardScrollView(this);
   WintLess2.setAdapter(new CardAdapter(createCards(this)));
   setContentView(WintLess2);
 } // onCreate
Пример #5
0
  /*
   * Handle starting and ending connection
   */
  @Override
  public boolean onMenuItemSelected(int featureId, MenuItem item) {
    if (featureId == WindowUtils.FEATURE_VOICE_COMMANDS
        || featureId == Window.FEATURE_OPTIONS_PANEL) {
      switch (item.getItemId()) {
        case R.id.start_casting_menu_item:
          BaseCastingNetworkActivity.startCasting(PACKAGE_NAME, rootView);
          isCasting = true;
          break;

        case R.id.stop_casting_menu_item:
          BaseCastingNetworkActivity.stopCasting();
          isCasting = false;
          break;

        case R.id.see_quotes_menu_item:
          switch (mCardScrollView.getSelectedItemPosition()) {
            case 0: // Friedrich Nietzsche
              Log.d(PACKAGE_NAME, "Immersion to Friedrich Nietzsche quotes");

              mHandler.post(
                  new Runnable() {
                    @Override
                    public void run() {
                      Intent intent =
                          new Intent(MainActivity.this, QuotesFriedrichNietzscheActivity.class);
                      intent.putExtra(CASTING, isCasting);
                      startActivityForResult(intent, SHOW_QUOTES);
                    }
                  });

              break;

            case 1: // Lao Zi
              Log.d(PACKAGE_NAME, "Immersion to Lao Zi quotes");

              mHandler.post(
                  new Runnable() {
                    @Override
                    public void run() {
                      Intent intent = new Intent(MainActivity.this, QuotesLaoZiActivity.class);
                      intent.putExtra(CASTING, isCasting);
                      startActivityForResult(intent, SHOW_QUOTES);
                    }
                  });

              break;
          }
          break;

        default:
          return true;
      }
      return true;
    }
    // Good practice to pass through to super if not handled
    return super.onMenuItemSelected(featureId, item);
  }
Пример #6
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    android.os.Debug.waitForDebugger();
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // Cards start
    cardManager = new CardManager(this, mCards);
    mCardScrollView = new CardScrollView(this);
    adapter = new ExampleCardScrollAdapter();
    mCardScrollView.setAdapter(adapter);
    mCardScrollView.setOnItemClickListener(adapter);
    mCardScrollView.activate();
    setContentView(mCardScrollView);

    _cameraPreview = new CameraPreview(this);
    setContentView(_cameraPreview);
  }
  @Override
  protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    mView = buildView();

    mCardScroller = new CardScrollView(this);
    mCardScroller.setAdapter(
        new CardScrollAdapter() {
          @Override
          public int getCount() {
            return 1;
          }

          @Override
          public Object getItem(int position) {
            return mView;
          }

          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
            return mView;
          }

          @Override
          public int getPosition(Object item) {
            if (mView.equals(item)) {
              return 0;
            }
            return AdapterView.INVALID_POSITION;
          }
        });
    // Handle the TAP event.
    mCardScroller.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // Plays disallowed sound to indicate that TAP actions are not supported.
            AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
            am.playSoundEffect(Sounds.DISALLOWED);
          }
        });
    setContentView(mCardScroller);
  }
Пример #8
0
  @Override
  protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mAdapter = new CardAdapter(createCards(this));
    mCardScroller = new CardScrollView(this);
    mCardScroller.setAdapter(mAdapter);
    setContentView(mCardScroller);
    setCardScrollerListener();
  }
Пример #9
0
  /** Method the define the actions when tapping on a card */
  private void setCardScrollerListener() {
    mCardScroller.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            SharedPreferences.Editor editor = mSharedPreferences.edit();
            int soundEffect = Sounds.TAP;
            switch (position) {
                // A new activity for the demo is called
              case DEMO:
                mHandler.post(
                    new Runnable() {
                      @Override
                      public void run() {
                        startDemo();
                      }
                    });
                break;

                // Definition of the sensitivity for the motion handler (maximum rotational span)
              case SENSITIVITY_SETTINGS:
                int nb_sensitivities = Sensitivity.values().length;
                int s = mSharedPreferences.getInt("sensitivity", 2);
                if (s == (nb_sensitivities - 1)) {
                  s = 0;
                } else {
                  s = s + 1;
                }
                Sensitivity sensitivity = Sensitivity.values()[s];
                CardBuilder cardSensitivity = (CardBuilder) mAdapter.getItem(SENSITIVITY_SETTINGS);
                cardSensitivity.setText(
                    getString(R.string.text_card_sensitivity_settings)
                        + " "
                        + getString(sensitivity.textId));
                mCardScroller.getAdapter().notifyDataSetChanged();
                editor.putInt("sensitivity", s);
                editor.commit();
                break;

              default:
                soundEffect = Sounds.ERROR;
                Log.d(TAG, "Don't do anything");
            }
            AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
            am.playSoundEffect(soundEffect);
          }
        });
  }
Пример #10
0
  private void takePicture(
      String id, String title, String bid, String bin, String location, String condition) {
    // This is due saving picture that user can approve photo only after 2-3
    // seconds, otherwise scanning would fail
    // Toast.makeText(getApplicationContext(), "Wait...",
    // Toast.LENGTH_LONG).show();
    // Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    // startActivityForResult(intent, TAKE_PICTURE_REQUEST);

    // Cards start
    cardManager = new CardManager(this, mCards);
    cardManager.createTitleCard(title, bid, bin, id);
    cardManager.createContentCard(id, location, condition);
    cardManager.createSaveCard(id);
    cardManager.createScanCard();
    mCardScrollView = new CardScrollView(this);
    adapter = new ExampleCardScrollAdapter();
    mCardScrollView.setAdapter(adapter);
    mCardScrollView.setOnItemClickListener(adapter);
    mCardScrollView.activate();
    setContentView(mCardScrollView);

    adapter.notifyDataSetChanged();
  }
Пример #11
0
 @Override
 protected void onPause() {
   WintLess2.deactivate();
   super.onPause();
 } // onPause
Пример #12
0
 @Override
 protected void onResume() {
   super.onResume();
   WintLess2.activate();
 } // onResume
 @Override
 protected void onPause() {
   mCardScroller.deactivate();
   super.onPause();
 }
 @Override
 protected void onResume() {
   super.onResume();
   mCardScroller.activate();
 }
Пример #15
0
 private void hideCard() {
   stopPitchDetection();
   getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
   mCardScroller.deactivate();
 }
Пример #16
0
 @Override
 protected void onResume() {
   super.onResume();
   Log.d(TAG, "resume");
   mCardScroller.activate();
 }