Search in sources :

Example 11 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project GT by Tencent.

the class GTOpMulPerfActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gt_perf_op_mul_detail);
    Intent intent = this.getIntent();
    if (intent == null) {
        finish();
    }
    Bundle extras = intent.getExtras();
    if (extras == null) {
        finish();
    }
    final String name = extras.getString("name");
    final String alias = extras.getString("alias");
    final String client = extras.getString("client");
    // 出参的性能数据源取法
    dataSet = OpPerfBridge.getProfilerData(name);
    // 在onCreat之前数据源可能被清理了,这样就不打开页面
    if (null == dataSet) {
        finish();
        return;
    }
    // 保存对应的出参变量,以便刷值
    op = ClientManager.getInstance().getClient(client).getOutPara(name);
    attentEntry = dataSet.getSubTagEntrys()[0];
    about = dataSet.getDesc();
    tvTitle = (TextView) findViewById(R.id.perf_detail_title);
    tvTitle.setText(alias);
    tvKey = (TextView) findViewById(R.id.op_perf_detail_key);
    tvKey.setText(name);
    tvAbout = (TextView) findViewById(R.id.op_perf_detail_about);
    tvAbout.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            GTOutParaPerfDialog dialog = new GTOutParaPerfDialog(v.getContext(), alias, name, about);
            dialog.show();
        }
    });
    lv_attentAttr = (ListView) findViewById(R.id.op_perf_detail_attent_list);
    attrAdapter = new ArrayAdapter<String>(this, R.layout.gt_simple_dropdown_item);
    for (TagTimeEntry itemName : dataSet.getChildren()) {
        attrAdapter.add(itemName.getName());
    }
    lv_attentAttr.setAdapter(attrAdapter);
    lv_attentAttr.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View v, int position, long arg3) {
            img_empty.setVisibility(View.GONE);
            lv_attentAttr.setVisibility(View.GONE);
            String lastSelectedItem = btn_attent.getText().toString();
            btn_attent.setText(attrAdapter.getItem(position));
            attentEntry = dataSet.getSubTagEntrys()[position];
            if (!lastSelectedItem.equals(attentEntry.getName())) {
                refreshAttent();
                refreshThreshold();
            }
        }
    });
    /*
		 * 用于覆盖整个屏幕的透明ImageView,
		 * 主要帮助点击非lv_attentAttr区域使lv_attentAttr消失
		 */
    img_empty = (ImageView) findViewById(R.id.view_empty);
    img_empty.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            img_empty.setVisibility(View.GONE);
            lv_attentAttr.setVisibility(View.GONE);
            return true;
        }
    });
    btn_attent = (Button) findViewById(R.id.op_perf_detail_attent);
    btn_attent.setText(attrAdapter.getItem(0));
    btn_attent.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            btn_attent.setBackgroundResource(R.drawable.a_gt_perf_op_btn_selected_border);
            handler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    btn_attent.setBackgroundResource(R.drawable.a_gt_perf_op_btn_default_border);
                }
            }, 200);
            if (lv_attentAttr.getVisibility() == View.VISIBLE) {
                img_empty.setVisibility(View.GONE);
                lv_attentAttr.setVisibility(View.GONE);
            } else {
                lv_attentAttr.setVisibility(View.VISIBLE);
                img_empty.setVisibility(View.VISIBLE);
            }
        }
    });
    btn_back = (ImageButton) findViewById(R.id.perf_detail_back);
    btn_back.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            finish();
        }
    });
    //		btn_save = (ImageButton)findViewById(R.id.perf_detail_save);
    //		btn_save.setOnClickListener(new OnClickListener() {
    //
    //			public void onClick(View v) {
    //				String lastSaveLog = GTGWInternal.getLastSaveFolder();
    //				if (lastSaveLog != null && lastSaveLog.contains(".")
    //						&& lastSaveLog.endsWith(LogUtils.TLOG_POSFIX))
    //				{
    //					lastSaveLog = lastSaveLog.substring(0, lastSaveLog.lastIndexOf("."));
    //				}
    //				et_savePath3.setText(lastSaveLog.trim());
    //				dlg_save.show();
    //			}
    //		});
    RelativeLayout rl_save = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.gt_dailog_save_gw, null, false);
    ImageButton btn_cleanSavePath = (ImageButton) rl_save.findViewById(R.id.save_clean);
    btn_cleanSavePath.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            et_savePath3.setText("");
        }
    });
    et_savePath1 = (EditText) rl_save.findViewById(R.id.save_editor_folder_parent1);
    et_savePath2 = (EditText) rl_save.findViewById(R.id.save_editor_folder_parent2);
    et_savePath3 = (EditText) rl_save.findViewById(R.id.save_editor);
    et_saveTestDesc = (EditText) rl_save.findViewById(R.id.save_editor_desc);
    String lastSaveLog = GTGWInternal.getLastSaveFolder();
    if (lastSaveLog != null && lastSaveLog.contains(".") && lastSaveLog.endsWith(LogUtils.TLOG_POSFIX)) {
        lastSaveLog = lastSaveLog.substring(0, lastSaveLog.lastIndexOf("."));
    }
    et_savePath3.setText(lastSaveLog);
    et_savePath1.setText(Env.CUR_APP_NAME);
    et_savePath2.setText(Env.CUR_APP_VER);
    dlg_save = new Builder(this).setTitle(getString(R.string.save)).setView(rl_save).setPositiveButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    }).setNegativeButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            String path1 = et_savePath1.getText().toString().trim();
            if (!StringUtil.isLetter(path1)) {
                ToastUtil.ShowShortToast(GTOpMulPerfActivity.this, getString(R.string.save_folder_valid));
                return;
            }
            String path2 = et_savePath2.getText().toString().trim();
            if (!StringUtil.isLetter(path2)) {
                ToastUtil.ShowShortToast(GTOpMulPerfActivity.this, getString(R.string.save_folder_valid));
                return;
            }
            String path3 = et_savePath3.getText().toString().trim();
            if (!StringUtil.isLetter(path3)) {
                ToastUtil.ShowShortToast(GTOpMulPerfActivity.this, getString(R.string.save_folder_valid));
                return;
            }
            String testDesc = et_saveTestDesc.getText().toString().trim();
            GWSaveEntry saveEntry = new GWSaveEntry(path1, path2, path3, testDesc);
            GTGWInternal.saveGWData(saveEntry, dataSet);
            dialog.dismiss();
        }
    }).create();
    btn_delete = (ImageButton) findViewById(R.id.perf_detail_delete);
    btn_delete.setOnClickListener(showDeleteDlg);
    // 告警区操作的UI
    tvWarningCntToast = (TextView) findViewById(R.id.op_perf_detail_warning_cnt_toast);
    tvWarningCnt = (TextView) findViewById(R.id.bh_perf_detail_warning_cnt);
    // 告警区
    final LinearLayout ll_warnArea = (LinearLayout) findViewById(R.id.op_perf_detail_warnarea);
    img_bottom_arrow = (ImageView) findViewById(R.id.bottom_arrow);
    if (dataSet.getThresholdEntry().isEnable()) {
        img_bottom_arrow.setBackgroundResource(R.drawable.unfold_arrow);
        ll_warnArea.setVisibility(View.VISIBLE);
    } else {
        img_bottom_arrow.setBackgroundResource(R.drawable.fold_arrow);
        ll_warnArea.setVisibility(View.GONE);
    }
    // 告警抬头文本
    tvWaringArea = (TextView) findViewById(R.id.op_perf_detail_interval_toast);
    // 折叠线
    ll_fold = (LinearLayout) findViewById(R.id.warning_fold);
    // 因为多曲线情况的各子项的告警的enable值是一起变化的,所以从一个判断决定UI初始状态即可
    if (!attentEntry.getThresholdEntry().isEnable()) {
        img_bottom_arrow.setBackgroundResource(R.drawable.fold_arrow);
        ll_warnArea.setVisibility(View.GONE);
        tvWarningCntToast.setVisibility(View.GONE);
        tvWarningCnt.setVisibility(View.GONE);
        tvWaringArea.setText(getString(R.string.warning_title_mul_disable));
    }
    ll_fold.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO 需要对所有的子项告警全开和全屏蔽,UI与业务逻辑混一起了,需要重构
            if (attentEntry.getThresholdEntry().isEnable()) {
                for (TagTimeEntry temp : dataSet.getSubTagEntrys()) {
                    temp.getThresholdEntry().setEnable(false);
                }
                img_bottom_arrow.setBackgroundResource(R.drawable.fold_arrow);
                ll_warnArea.setVisibility(View.GONE);
                tvWarningCntToast.setVisibility(View.GONE);
                tvWarningCnt.setVisibility(View.GONE);
                tvWaringArea.setText(getString(R.string.warning_title_mul_disable));
            } else {
                for (TagTimeEntry temp : dataSet.getSubTagEntrys()) {
                    temp.getThresholdEntry().setEnable(true);
                }
                img_bottom_arrow.setBackgroundResource(R.drawable.unfold_arrow);
                ll_warnArea.setVisibility(View.VISIBLE);
                tvWarningCntToast.setVisibility(View.VISIBLE);
                tvWarningCnt.setVisibility(View.VISIBLE);
                tvWaringArea.setText(getString(R.string.warning_title_mul));
            }
        }
    });
    // 从未开始统计过的出参,不允许设置告警
    if (!op.hasMonitorOnce) {
        etUpperInterval.setEnabled(false);
        etUpperValue.setEnabled(false);
        etLowerValue.setEnabled(false);
    } else {
        etUpperInterval = (EditText) findViewById(R.id.op_perf_detail_upper_interval);
        etUpperValue = (EditText) findViewById(R.id.op_perf_detail_upper_value);
        etLowerValue = (EditText) findViewById(R.id.op_perf_detail_lower_value);
        etUpperInterval.setInputType(EditorInfo.TYPE_CLASS_PHONE);
        etUpperValue.setInputType(EditorInfo.TYPE_CLASS_PHONE);
        etLowerValue.setInputType(EditorInfo.TYPE_CLASS_PHONE);
        etUpperInterval.setOnKeyListener(thresholdKeyListener);
        etUpperValue.setOnKeyListener(thresholdKeyListener);
        etLowerValue.setOnKeyListener(thresholdKeyListener);
        refreshThreshold();
    }
    tvValue = (TextView) findViewById(R.id.op_perf_detail_value);
    tvTimes = (TextView) findViewById(R.id.bh_perf_detail_times);
    tvMin = (TextView) findViewById(R.id.bh_perf_detail_min);
    tvMax = (TextView) findViewById(R.id.bh_perf_detail_max);
    tvAve = (TextView) findViewById(R.id.bh_perf_detail_ave);
    //		tvValue.setText(dataSet.getLastValue());
    tvValue.setText(op.getValue());
    refreshAttent();
    LinearLayout ll_chart = (LinearLayout) findViewById(R.id.bh_perf_detail_chart);
    chartView = new GTMulOpPerfDetailView(this, dataSet);
    chartView.setInput(0);
    ll_chart.addView(chartView);
}
Also used : OnTouchListener(android.view.View.OnTouchListener) TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) DialogInterface(android.content.DialogInterface) Bundle(android.os.Bundle) Builder(android.app.AlertDialog.Builder) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) GTMulOpPerfDetailView(com.tencent.wstt.gt.views.GTMulOpPerfDetailView) TextView(android.widget.TextView) ListView(android.widget.ListView) MotionEvent(android.view.MotionEvent) GTMulOpPerfDetailView(com.tencent.wstt.gt.views.GTMulOpPerfDetailView) ImageButton(android.widget.ImageButton) RelativeLayout(android.widget.RelativeLayout) GWSaveEntry(com.tencent.wstt.gt.log.GWSaveEntry) OnClickListener(android.view.View.OnClickListener) GTOutParaPerfDialog(com.tencent.wstt.gt.views.GTOutParaPerfDialog) LinearLayout(android.widget.LinearLayout)

Example 12 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project LitePal by LitePalFramework.

the class ModelListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.model_list_layout);
    mModelListview = (ListView) findViewById(R.id.model_listview);
    populateMappingClasses();
    mAdapter = new StringArrayAdapter(this, 0, mList);
    mModelListview.setAdapter(mAdapter);
    mModelListview.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View view, int index, long id) {
            ModelStructureActivity.actionStart(ModelListActivity.this, mList.get(index));
        }
    });
}
Also used : StringArrayAdapter(org.litepal.litepalsample.adapter.StringArrayAdapter) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 13 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project LitePal by LitePalFramework.

the class TableListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.table_list_layout);
    mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
    mTableListview = (ListView) findViewById(R.id.table_listview);
    mAdapter = new StringArrayAdapter(this, 0, mList);
    mTableListview.setAdapter(mAdapter);
    populateTables();
    mTableListview.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View view, int index, long id) {
            TableStructureActivity.actionStart(TableListActivity.this, mList.get(index));
        }
    });
}
Also used : StringArrayAdapter(org.litepal.litepalsample.adapter.StringArrayAdapter) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 14 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project MWM-for-Android-Gen1 by MetaWatchOpenProjects.

the class DeviceSelection method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    pdWait = ProgressDialog.show(this, "Please wait", "Searching Bluetooth devices...");
    pdWait.setCancelable(true);
    pdWait.setOnCancelListener(new OnCancelListener() {

        public void onCancel(DialogInterface dialog) {
            Log.d(MetaWatch.TAG, "canceled");
            if (MetaWatchService.bluetoothAdapter.isDiscovering())
                MetaWatchService.bluetoothAdapter.cancelDiscovery();
            finish();
        }
    });
    pdWait.show();
    setContentView(R.layout.device_selection);
    //constructMenuList();
    listView = (ListView) findViewById(android.R.id.list);
    //listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menuList));
    listView.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            Log.d(MetaWatch.TAG, "device selected: " + arg2);
            Map<String, String> map = list.get(arg2);
            String mac = map.get("mac");
            Log.d(MetaWatch.TAG, "mac selected: " + mac);
            MetaWatchService.Preferences.watchMacAddress = mac;
            MetaWatchService.saveMac(context, mac);
            sendToast("Selected watch set");
            finish();
        }
    });
    if (MetaWatchService.bluetoothAdapter == null)
        MetaWatchService.bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    Set<BluetoothDevice> pairedDevices = MetaWatchService.bluetoothAdapter.getBondedDevices();
    if (pairedDevices.size() > 0) {
        for (BluetoothDevice device : pairedDevices) {
            addToList(device.getAddress(), device.getName());
        }
    }
    Receiver receiver = new Receiver();
    IntentFilter intentFilter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
    intentFilter.addAction(BluetoothDevice.ACTION_FOUND);
    registerReceiver(receiver, intentFilter);
    MetaWatchService.bluetoothAdapter.startDiscovery();
}
Also used : IntentFilter(android.content.IntentFilter) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) BluetoothDevice(android.bluetooth.BluetoothDevice) DialogInterface(android.content.DialogInterface) BroadcastReceiver(android.content.BroadcastReceiver) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) HashMap(java.util.HashMap) Map(java.util.Map) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 15 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project MFCalendarView by MustafaFerhan.

the class MFCalendarView method init.

void init(Context context) {
    LayoutInflater li = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view = li.inflate(R.layout.mf_calendarview, null, false);
    month = (GregorianCalendar) GregorianCalendar.getInstance();
    month.setTimeInMillis(Util.dateToLong(getInitialDate()));
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd", Util.getLocale());
    currentSelectedDate = df.format(month.getTime());
    calendaradapter = new CalendarAdapter(context, month);
    gridview = (ExpandableHeightGridView) view.findViewById(R.id.gridview);
    gridview.setAdapter(calendaradapter);
    handler = new Handler();
    handler.post(calendarUpdater);
    TextView title = (TextView) view.findViewById(R.id.title);
    title.setText(android.text.format.DateFormat.format("MMMM yyyy", month));
    RelativeLayout previous = (RelativeLayout) view.findViewById(R.id.previous);
    previous.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            setPreviousMonth();
            refreshCalendar();
        }
    });
    RelativeLayout next = (RelativeLayout) view.findViewById(R.id.next);
    next.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            setNextMonth();
            refreshCalendar();
        }
    });
    gridview.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            ((CalendarAdapter) parent.getAdapter()).setSelected(v);
            currentSelectedDate = CalendarAdapter.dayString.get(position);
            String[] separatedTime = currentSelectedDate.split("-");
            String gridvalueString = separatedTime[2].replaceFirst("^0*", // taking last part of date. ie; 2 from 2012-12-02.
            "");
            int gridvalue = Integer.parseInt(gridvalueString);
            // navigate to next or previous month on clicking offdays.
            if ((gridvalue > 10) && (position < 8)) {
                setPreviousMonth();
                refreshCalendar();
            } else if ((gridvalue < 15) && (position > 28)) {
                setNextMonth();
                refreshCalendar();
            }
            ((CalendarAdapter) parent.getAdapter()).setSelected(v);
            month.setTimeInMillis(Util.dateToLong(currentSelectedDate));
            calendaradapter.initCalendarAdapter(month, calendarListener);
            if (calendarListener != null)
                calendarListener.onDateChanged(currentSelectedDate);
        }
    });
    addView(view);
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Handler(android.os.Handler) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) LayoutInflater(android.view.LayoutInflater) RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

OnItemClickListener (android.widget.AdapterView.OnItemClickListener)135 AdapterView (android.widget.AdapterView)134 View (android.view.View)133 ListView (android.widget.ListView)102 TextView (android.widget.TextView)71 Intent (android.content.Intent)43 ImageView (android.widget.ImageView)41 OnClickListener (android.view.View.OnClickListener)24 Bundle (android.os.Bundle)18 ArrayAdapter (android.widget.ArrayAdapter)17 SuppressLint (android.annotation.SuppressLint)15 Paint (android.graphics.Paint)12 ColorDrawable (android.graphics.drawable.ColorDrawable)11 GridView (android.widget.GridView)11 LayoutInflater (android.view.LayoutInflater)10 DialogInterface (android.content.DialogInterface)9 CheckBox (android.widget.CheckBox)9 LinearLayout (android.widget.LinearLayout)9 ArrayList (java.util.ArrayList)7 OnItemLongClickListener (android.widget.AdapterView.OnItemLongClickListener)6