Search in sources :

Example 1 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project android_frameworks_base by ParanoidAndroid.

the class ProfileActivity method onCreate.

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mInspectButton = (Button) findViewById(R.id.inspect);
    mCaptureButton = (ToggleButton) findViewById(R.id.capture);
    mVelocitySpinner = (Spinner) findViewById(R.id.velocity);
    mMovementSpinner = (Spinner) findViewById(R.id.movement);
    mUrl = (EditText) findViewById(R.id.url);
    mWeb = (ProfiledWebView) findViewById(R.id.web);
    setCallback(new ProfileCallback() {

        @SuppressWarnings("unchecked")
        @Override
        public void profileCallback(RunData data) {
            new StoreFileTask().execute(new Pair<String, RunData>(TEMP_FILENAME, data));
            Log.d("ProfileActivity", "stored " + data.frames.length + " frames in file");
            setTestingState(TestingState.STOP_TESTING);
        }
    });
    // Inspect button (opens PlaybackActivity)
    mInspectButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(ProfileActivity.this, PlaybackActivity.class));
        }
    });
    // Velocity spinner
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.velocity_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mVelocitySpinner.setAdapter(adapter);
    mVelocitySpinner.setOnItemSelectedListener(new VelocitySelectedListener());
    mVelocitySpinner.setSelection(3);
    // Movement spinner
    String[] content = { getResources().getString(R.string.movement_auto_scroll), getResources().getString(R.string.movement_manual), getResources().getString(R.string.movement_timed) };
    adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, content);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mMovementSpinner.setAdapter(adapter);
    mMovementSpinner.setOnItemSelectedListener(new MovementSelectedListener());
    mMovementSpinner.setSelection(0);
    // Capture toggle button
    mCaptureButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mCaptureButton.isChecked()) {
                startViewProfiling(false);
            } else {
                mWeb.stopScrollTest();
            }
        }
    });
    // Custom profiling WebView
    mWeb.init(this);
    mWeb.setWebViewClient(new LoggingWebViewClient());
    // URL text entry
    mUrl.setOnEditorActionListener(new OnEditorActionListener() {

        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            String url = mUrl.getText().toString();
            mWeb.loadUrl(url);
            mWeb.requestFocus();
            return true;
        }
    });
    setTestingState(TestingState.NOT_TESTING);
}
Also used : Intent(android.content.Intent) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) TextView(android.widget.TextView) KeyEvent(android.view.KeyEvent) OnClickListener(android.view.View.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView) Pair(android.util.Pair)

Example 2 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project GT by Tencent.

the class GTCaptureActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pi_capture);
    initLayout();
    tv_tcpdump_back = (TextView) findViewById(R.id.tcpdump_back_gt);
    tv_tcpdump_back.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    tv_tcpdump_curFile.setText(curFilePath == null ? "" : curFilePath);
    tv_tcpdump_progress.setText(curFileSize == null ? "" : curFileSize + "KB");
    tv_param_switch = (TextView) findViewById(R.id.tcpdump_param_switch);
    tv_param_switch.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!switch_param) {
                switch_param = true;
                tv_param_title.setVisibility(View.VISIBLE);
                fl_param.setVisibility(View.VISIBLE);
            } else {
                switch_param = false;
                et_param.setText(param);
                tv_param_title.setVisibility(View.GONE);
                fl_param.setVisibility(View.GONE);
            }
        }
    });
    btn_param_clear = (Button) findViewById(R.id.tcpdump_param_cancel);
    btn_param_clear.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            param = "";
            et_param.setText(param);
        }
    });
    et_param = (EditText) findViewById(R.id.tcpdump_param);
    et_param.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            return (event.getKeyCode() == KeyEvent.KEYCODE_ENTER);
        }
    });
    tv_switch = (TextView) findViewById(R.id.tcpdump_switch);
    tv_switch.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // 获取权限过程比较耗时,交给菊花去处理
            Thread t = new Thread(new ProgressRunnable());
            t.start();
        }
    });
    cb_param_switch = (GTCheckBox) findViewById(R.id.cb_param_switch);
    cb_param_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                cur_param_switch_status = isChecked;
                tv_param_title.setVisibility(View.VISIBLE);
                fl_param.setVisibility(View.VISIBLE);
                String cur_param = et_param.getText().toString();
                if (cur_param.equals("") || cur_param.trim().equals("")) {
                    et_param.setText(default_param);
                }
            } else {
                cur_param_switch_status = isChecked;
                tv_param_title.setVisibility(View.GONE);
                fl_param.setVisibility(View.GONE);
            }
        }
    });
    tcpdumpSwitchHandler = new Handler() {

        public void handleMessage(Message msg) {
            switch(msg.what) {
                case // 启动抓包开始,控件状态置为红色,显示stop
                0:
                    switch_tcpdump = true;
                    tv_switch.setBackgroundResource(R.drawable.switch_off_border);
                    tv_switch.setText(getString(R.string.stop));
                    break;
                case // 抓包结束,控件状态置为绿色,显示start
                1:
                    switch_tcpdump = false;
                    tv_switch.setBackgroundResource(R.drawable.switch_on_border);
                    tv_switch.setText(getString(R.string.start));
                    break;
                case // 吐槽提示
                2:
                    String message = msg.obj == null ? "" : msg.obj.toString();
                    WidgetUtils.openToast(message);
                    // 有菊花则停止菊花
                    dismissProDialog();
                    break;
                case // 抓包文件发生大小变化时
                3:
                    curFileSize = msg.obj == null ? "" : msg.obj.toString();
                    tv_tcpdump_progress.setText(curFileSize + "KB");
                    break;
                case // 启动抓包完成,显示当前保存的抓包文件  TODO
                4:
                    curFilePath = msg.obj == null ? "" : msg.obj.toString();
                    tv_tcpdump_curFile.setText(curFilePath == null ? "" : curFilePath);
                    // 停止菊花
                    dismissProDialog();
                    break;
                case // 抓包之前的校验,转菊花
                5:
                    showProDialog();
                    break;
            }
        }
    };
    GTCaptureEngine.getInstance().addListener(this);
}
Also used : Message(android.os.Message) Handler(android.os.Handler) TextView(android.widget.TextView) View(android.view.View) KeyEvent(android.view.KeyEvent) OnClickListener(android.view.View.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton)

Example 3 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project mobile-android by photo.

the class TagsFragment method init.

public void init(View v) {
    final EditText search = (EditText) v.findViewById(R.id.edit_search);
    search.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (event != null) {
                switch(event.getKeyCode()) {
                    case KeyEvent.KEYCODE_ENTER:
                        CommonUtils.debug(TAG, "Key code enter");
                        if (KeyEvent.ACTION_DOWN == event.getAction()) {
                            CommonUtils.debug(TAG, "Opening gallery");
                            search.post(new Runnable() {

                                @Override
                                public void run() {
                                    galleryOpenControl.openGallery(search.getText().toString().trim(), null);
                                }
                            });
                            return true;
                        }
                        break;
                }
            }
            return false;
        }
    });
    Button filterBtn = (Button) v.findViewById(R.id.filterBtn);
    filterBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            TrackerUtils.trackButtonClickEvent("filterBtn", TagsFragment.this);
            galleryOpenControl.openGallery(mAdapter.getSelectedTags(), null);
        }
    });
    refresh(v);
}
Also used : EditText(android.widget.EditText) KeyEvent(android.view.KeyEvent) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) ListView(android.widget.ListView)

Example 4 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project httpclient by pixmob.

the class AstroboyMasterConsole method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    // @Inject, @InjectResource, and @InjectExtra injection happens during super.onCreate()
    super.onCreate(savedInstanceState);
    sayText.setOnEditorActionListener(new OnEditorActionListener() {

        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            // Have the remoteControl tell Astroboy to say something
            remoteControl.say(textView.getText().toString());
            textView.setText(null);
            return true;
        }
    });
    brushTeethButton.setOnClickListener(new OnClickListener() {

        public void onClick(View view) {
            remoteControl.brushTeeth();
        }
    });
    selfDestructButton.setOnClickListener(new OnClickListener() {

        public void onClick(View view) {
            // Self destruct the remoteControl
            vibrator.vibrate(2000);
            remoteControl.selfDestruct();
        }
    });
    // Fighting the forces of evil deserves its own activity
    fightEvilButton.setOnClickListener(new OnClickListener() {

        public void onClick(View view) {
            startActivity(new Intent(AstroboyMasterConsole.this, FightForcesOfEvilActivity.class));
        }
    });
}
Also used : KeyEvent(android.view.KeyEvent) OnClickListener(android.view.View.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView) Intent(android.content.Intent) ContentView(roboguice.inject.ContentView) InjectView(roboguice.inject.InjectView) TextView(android.widget.TextView) View(android.view.View)

Example 5 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project roboguice by roboguice.

the class AstroboyMasterConsole method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    // @Inject, @InjectResource, and @InjectExtra injection happens during super.onCreate()
    super.onCreate(savedInstanceState);
    sayText.setOnEditorActionListener(new OnEditorActionListener() {

        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            // Have the remoteControl tell Astroboy to say something
            remoteControl.say(textView.getText().toString());
            textView.setText(null);
            return true;
        }
    });
    brushTeethButton.setOnClickListener(new OnClickListener() {

        public void onClick(View view) {
            remoteControl.brushTeeth();
        }
    });
    selfDestructButton.setOnClickListener(new OnClickListener() {

        public void onClick(View view) {
            // Self destruct the remoteControl
            vibrator.vibrate(2000);
            remoteControl.selfDestruct();
        }
    });
    // Fighting the forces of evil deserves its own activity
    fightEvilButton.setOnClickListener(new OnClickListener() {

        public void onClick(View view) {
            startActivity(new Intent(AstroboyMasterConsole.this, FightForcesOfEvilActivity.class));
        }
    });
}
Also used : KeyEvent(android.view.KeyEvent) OnClickListener(android.view.View.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView) Intent(android.content.Intent) ContentView(roboguice.inject.ContentView) InjectView(roboguice.inject.InjectView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

OnEditorActionListener (android.widget.TextView.OnEditorActionListener)37 KeyEvent (android.view.KeyEvent)32 TextView (android.widget.TextView)32 View (android.view.View)28 DialogInterface (android.content.DialogInterface)13 LayoutInflater (android.view.LayoutInflater)13 EditText (android.widget.EditText)13 OnClickListener (android.view.View.OnClickListener)12 AlertDialog (android.app.AlertDialog)11 Context (android.content.Context)11 OnClickListener (android.content.DialogInterface.OnClickListener)11 Intent (android.content.Intent)9 Test (org.junit.Test)6 ContentResolver (android.content.ContentResolver)5 Button (android.widget.Button)4 InjectView (roboguice.inject.InjectView)4 Handler (android.os.Handler)3 AlertDialog (android.support.v7.app.AlertDialog)3 InputMethodManager (android.view.inputmethod.InputMethodManager)3 AutoCompleteTextView (android.widget.AutoCompleteTextView)3