Esempio n. 1
0
 @Override
 protected void onRestart() {
   ImageDrawing.registerCache(super.mContext);
   super.onRestart();
 }
Esempio n. 2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    GlobalSettings.init(this);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    super.mContext = (Context) this;
    ImageDrawing.registerCache(super.mContext);

    Log.i(TAG, "Boarder storage directory is " + mSbDir.getAbsolutePath());

    super.onCreate(savedInstanceState);

    mIntent = getIntent();
    mAction = mIntent.getAction();

    if (Intent.ACTION_CREATE_SHORTCUT.equals(mAction)) {
      setTitle("Select shortcut target:");
    } else {
      setTitle("Soundboard Menu");
    }

    String launchExtra = mIntent.getStringExtra(EXTRA_LAUNCH_BAORD_KEY);
    if (launchExtra != null) {
      try {
        Intent i = null;

        for (File boardDirContent : new File(mSbDir, launchExtra).listFiles()) {
          if (boardDirContent.getName().equals("graphicalBoard")) {
            i = new Intent(this, BoardEditor.class);
            break;
          }
        }
        i.putExtra(MenuDbAdapter.KEY_TITLE, launchExtra);
        startActivity(i);
      } catch (NullPointerException e) {
        mIntent = new Intent();
        Log.e(SoundboardMenu.TAG, "Board not found", e);
        Toast.makeText(this, "Board not found", Toast.LENGTH_LONG).show();
      }
    }

    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

    mFunctionSounds.add(mPauseSoundFilePath);
    mFunctionSounds.add(mTopBlackBarSoundFilePath);
    mFunctionSounds.add(mBottomBlackBarSoundFilePath);
    mFunctionSounds.add(mLeftBlackBarSoundFilePath);
    mFunctionSounds.add(mRightBlackBarSoundFilePath);

    mDbHelper = new MenuDbAdapter(this);
    mDbHelper.open();

    mGlobalVariableDbHelper = new GlobalVariablesDbAdapter(this);
    mGlobalVariableDbHelper.open();

    loadGlobalSettings();

    if (!mSbDir.exists()) {
      mSbDir.mkdirs();
    }

    refreshMenu();
    LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
    View layout =
        inflater.inflate(
            R.layout.soundboard_menu_list, (ViewGroup) findViewById(R.id.soundboard_menu_root));
    Button enableNotificationButton = (Button) layout.findViewById(R.id.enableNotificationButton);
    Button disableNotificationButton = (Button) layout.findViewById(R.id.disableNotificationButton);

    enableNotificationButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            updateNotification(SoundboardMenu.this, "Soundboard Menu", null);
          }
        });

    disableNotificationButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            final NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            notificationManager.cancel(SoundboardMenu.TAG, mNotificationId);
          }
        });

    setContentView(layout);
    registerForContextMenu(getListView());

    firstStartIntroduction();
  }