コード例 #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);

    // 入れ物に中身入れる
    if (gpuImage == null) gpuImage = new GPUImage(this);
    imageView = (ImageView) findViewById(R.id.gpuimage);

    filterType = (TextView) findViewById(R.id.filter_type);
    final SeekBar seekBar = (SeekBar) findViewById(R.id.seek);
    final TextView textView = (TextView) findViewById(R.id.value);

    // シークバーが操作されたときの処理
    seekBar.setOnSeekBarChangeListener(
        new SeekBar.OnSeekBarChangeListener() {
          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // シークバーの最大値は 100
            // 取得したい値は 0 ~ 1 の値なので /100 する
            // 関数に後の処理はお任せ
            float val = (float) progress / 100;
            textView.setText("VALUE: " + String.valueOf(val));
            changeFilter(val);
          }

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {}

          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {}
        });

    // アニメーションをセット
    inAnim = AnimationUtils.loadAnimation(this, R.anim.in_anim);
    outAnim = AnimationUtils.loadAnimation(this, R.anim.out_anim);

    // 画像を押したときに消すレイアウトグループを呼ぶ
    final RelativeLayout relativeLayout1 = (RelativeLayout) findViewById(R.id.menu_top);
    final RelativeLayout relativeLayout2 = (RelativeLayout) findViewById(R.id.menu_bottom);
    // 画像を押したときの処理
    imageView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            animationView(relativeLayout1);
            animationView(relativeLayout2);
          }
        });

    twitter = TwitterUtils.getTwitterInstance(this);

    try {
      gpuImage.getBitmapWithFilterApplied();
    } catch (NullPointerException e) {
      getPicture();
    }

    setButtonOnClickEvent();
  }