コード例 #1
0
  // ツイート内容を書く関数
  private void tweetDialog() throws TwitterException {
    // 認証済みだったら
    if (TwitterUtils.hasAccessToken(this)) {
      final EditText editText = new EditText(this);
      final AlertDialog alertDialog =
          new AlertDialog.Builder(this)
              .setTitle(getString(R.string.tweet_body))
              .setView(editText)
              .setPositiveButton(
                  getString(R.string.tweet_send),
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      tweet(editText.getText().toString());
                    }
                  })
              .setNegativeButton(getString(R.string.cancel), null)
              .create();

      editText.setOnFocusChangeListener(
          new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
              if (hasFocus) {
                alertDialog
                    .getWindow()
                    .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
              }
            }
          });
      alertDialog.show();
    } else {
      new AlertDialog.Builder(this)
          .setTitle(getString(R.string.no_set_account))
          .setPositiveButton(
              getString(R.string.twitter_auth),
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  startActivity(new Intent(MainActivity.this, TwitterOAuthActivity.class));
                  finish();
                }
              })
          .setNegativeButton(getString(R.string.cancel), null)
          .create()
          .show();
    }
  }
コード例 #2
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();
  }