Search in sources :

Example 66 with OnTouchListener

use of android.view.View.OnTouchListener in project GT by Tencent.

the class GTFloatView method initOutParamLayout.

private void initOutParamLayout() {
    // 初始化出参布局
    tv_floatview_op1 = (TextView) view_floatview.findViewById(R.id.floatview_op1);
    tv_floatview_op1_value = (TextView) view_floatview.findViewById(R.id.floatview_op1_value);
    tv_floatview_op2 = (TextView) view_floatview.findViewById(R.id.floatview_op2);
    tv_floatview_op2_value = (TextView) view_floatview.findViewById(R.id.floatview_op2_value);
    tv_floatview_op3 = (TextView) view_floatview.findViewById(R.id.floatview_op3);
    tv_floatview_op3_value = (TextView) view_floatview.findViewById(R.id.floatview_op3_value);
    // 设置点击事件
    tv_floatview_op1_value.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch(event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    tv_floatview_op_clickHandler.sendEmptyMessage(0);
                    break;
            }
            return false;
        }
    });
    tv_floatview_op2_value.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch(event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    tv_floatview_op_clickHandler.sendEmptyMessage(1);
                    break;
            }
            return false;
        }
    });
    tv_floatview_op3_value.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch(event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    tv_floatview_op_clickHandler.sendEmptyMessage(2);
                    break;
            }
            return false;
        }
    });
}
Also used : OnTouchListener(android.view.View.OnTouchListener) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) MotionEvent(android.view.MotionEvent)

Example 67 with OnTouchListener

use of android.view.View.OnTouchListener in project umeng-android-sdk-theme by umeng.

the class ConversationActivity method setListViewHeader.

private void setListViewHeader() {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    header = (RelativeLayout) inflater.inflate(R.layout.umeng_fb_list_header, replyListView, false);
    replyListView.addHeaderView(header);
    measureView(header);
    headerHeight = header.getMeasuredHeight();
    headerPaddingOriginal = header.getPaddingTop();
    header.setPadding(header.getPaddingLeft(), -headerHeight, header.getPaddingRight(), header.getPaddingBottom());
    header.setVisibility(View.GONE);
    replyListView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // nothing. Do not show the header.
            if (replyListView.getAdapter().getCount() < 2)
                return false;
            switch(event.getAction()) {
                case MotionEvent.ACTION_UP:
                    if (replyListView.getFirstVisiblePosition() == 0) {
                        if ((header.getBottom() >= headerHeight + 20 || header.getTop() > 0)) {
                            header.setVisibility(View.VISIBLE);
                            header.setPadding(header.getPaddingLeft(), headerPaddingOriginal, header.getPaddingRight(), header.getPaddingBottom());
                        } else // if (header.getBottom() < headerHeight + 20 ||
                        // header.getTop() <= 0)
                        {
                            replyListView.setSelection(1);
                            header.setVisibility(View.GONE);
                            header.setPadding(header.getPaddingLeft(), -headerHeight, header.getPaddingRight(), header.getPaddingBottom());
                        }
                    }
                    break;
                case MotionEvent.ACTION_DOWN:
                    mLastMotionY = (int) event.getY();
                    // header.setVisibility(View.VISIBLE);
                    break;
                case MotionEvent.ACTION_MOVE:
                    applyHeaderPadding(event);
                    break;
            }
            return false;
        }

        private void applyHeaderPadding(MotionEvent ev) {
            // getHistorySize has been available since API 1
            int pointerCount = ev.getHistorySize();
            for (int p = 0; p < pointerCount; p++) {
                if (replyListView.getFirstVisiblePosition() == 0) {
                    int historicalY = (int) ev.getHistoricalY(p);
                    // Calculate the padding to apply, we divide by 1.7 to
                    // simulate a more resistant effect during pull.
                    int topPadding = (int) (((historicalY - mLastMotionY) - headerHeight) / 1.7);
                    header.setVisibility(View.VISIBLE);
                    header.setPadding(header.getPaddingLeft(), topPadding, header.getPaddingRight(), header.getPaddingBottom());
                }
            }
        }
    });
    replyListView.setOnScrollListener(new OnScrollListener() {

        private int mScrollState;

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if (mScrollState == OnScrollListener.SCROLL_STATE_FLING && firstVisibleItem == 0) {
            // replyListView.setSelection(1);
            }
        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            mScrollState = scrollState;
        }
    });
}
Also used : OnTouchListener(android.view.View.OnTouchListener) OnScrollListener(android.widget.AbsListView.OnScrollListener) LayoutInflater(android.view.LayoutInflater) AbsListView(android.widget.AbsListView) View(android.view.View) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent)

Example 68 with OnTouchListener

use of android.view.View.OnTouchListener in project EngineDriver by JMRI.

the class ConsistLightsEdit method onCreate.

/**
 * Called when the activity is first created.
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mainapp = (threaded_application) getApplication();
    if (mainapp.isForcingFinish()) {
        // expedite
        return;
    }
    prefs = getSharedPreferences("jmri.enginedriver_preferences", 0);
    mainapp.applyTheme(this);
    setContentView(R.layout.consist_lights);
    // put pointer to this activity's handler in main app's shared variable
    mainapp.consist_lights_edit_msg_handler = new ConsistLightsEditHandler();
    myGesture = new GestureDetector(this);
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        whichThrottle = mainapp.throttleCharToInt(extras.getChar("whichThrottle"));
    }
    LIGHT_TEXT_OFF = getApplicationContext().getResources().getString(R.string.lightsTextOff);
    LIGHT_TEXT_FOLLOW = getApplicationContext().getResources().getString(R.string.lightsTextFollow);
    LIGHT_TEXT_UNKNOWN = getApplicationContext().getResources().getString(R.string.lightsTextUnknown);
    if (mainapp.consists == null || mainapp.consists[whichThrottle] == null) {
        if (mainapp.consists == null)
            Log.d("Engine_Driver", "consistLightsEdit onCreate consists is null");
        else
            Log.d("Engine_Driver", "consistLightsEdit onCreate consists[" + whichThrottle + "] is null");
        this.finish();
        return;
    }
    consist = mainapp.consists[whichThrottle];
    // Set up a list adapter to allow adding the list of recent connections to the UI.
    consistList = new ArrayList<>();
    consistListAdapter = new SimpleAdapter(this, consistList, R.layout.consist_lights_item, new String[] { "loco_name", "loco_addr", "loco_light" }, new int[] { R.id.con_loco_name, R.id.con_loco_addr_hidden, R.id.con_loco_light });
    ListView consistLV = findViewById(R.id.consist_lights_list);
    consistLV.setAdapter(consistListAdapter);
    consistLV.setOnItemClickListener(new OnItemClickListener() {

        // When an entry is clicked, toggle the lights state for that loco
        @Override
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            // convert to viewgroup for clicked row
            ViewGroup vg = (ViewGroup) v;
            // get address text from 2nd box
            TextView addrv = (TextView) vg.getChildAt(1);
            String address = addrv.getText().toString();
            int light;
            if (consist.getLeadAddr().equals(address)) {
                // lead loco is always 'follow'
                light = LIGHT_FOLLOW;
            } else {
                if ((consist.isLight(address) == LIGHT_UNKNOWN) || (consist.isLight(address) == LIGHT_FOLLOW)) {
                    light = LIGHT_OFF;
                } else {
                    light = LIGHT_FOLLOW;
                }
            }
            try {
                consist.setLight(address, light);
            } catch (Exception e) {
                // setLight returns null if address is not in consist - should not happen since address was selected from consist list
                Log.d("Engine_Driver", "ConsistLightsEdit selected engine " + address + " that is not in consist");
            }
            mainapp.buttonVibration();
            refreshConsistLists();
        }
    });
    consistLV.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        // When an entry is long-clicked, toggle the lights state for that loco but don't send the command to the loco
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View v, int pos, long id) {
            ViewGroup vg = (ViewGroup) v;
            // get address text from 2nd box
            TextView addrv = (TextView) vg.getChildAt(1);
            String address = addrv.getText().toString();
            int light;
            if ((consist.isLight(address) == LIGHT_UNKNOWN) | (consist.isLight(address) == LIGHT_FOLLOW)) {
                light = LIGHT_OFF;
            } else {
                light = LIGHT_FOLLOW;
            }
            try {
                consist.setLight(address, light);
            } catch (Exception e) {
                // setLight returns null if address is not in consist - should not happen since address was selected from consist list
                Log.d("Engine_Driver", "ConsistLightsEdit selected engine " + address + " that is not in consist");
            }
            refreshConsistLists();
            return true;
        }
    });
    OnTouchListener gestureListener = new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            mainapp.buttonVibration();
            return myGesture.onTouchEvent(event);
        }
    };
    consistLV.setOnTouchListener(gestureListener);
    // consistObjList = new ArrayList<>();
    // update consist list
    refreshConsistLists();
    result = RESULT_OK;
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        mainapp.setToolbarTitle(toolbar, getApplicationContext().getResources().getString(R.string.app_name), getApplicationContext().getResources().getString(R.string.app_name_ConsistLightsEdit), "");
    }
}
Also used : OnTouchListener(android.view.View.OnTouchListener) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Bundle(android.os.Bundle) ViewGroup(android.view.ViewGroup) SimpleAdapter(android.widget.SimpleAdapter) GestureDetector(android.view.GestureDetector) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) ListView(android.widget.ListView) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView)

Example 69 with OnTouchListener

use of android.view.View.OnTouchListener in project EngineDriver by JMRI.

the class turnouts method onCreate.

// @Override
// public boolean onTouchEvent(MotionEvent event) {
// return myGesture.onTouchEvent(event);
// }
/**
 * Called when the activity is first created.
 */
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
    mainapp = (threaded_application) getApplication();
    prefs = getSharedPreferences("jmri.enginedriver_preferences", 0);
    mainapp.applyTheme(this);
    super.onCreate(savedInstanceState);
    if (mainapp.isForcingFinish()) {
        // expedite
        return;
    }
    setContentView(R.layout.turnouts);
    // put pointer to this activity's handler in main app's shared variable (If needed)
    mainapp.turnouts_msg_handler = new turnouts_handler();
    // myGesture = new GestureDetector(this);
    // -------------------------------------------------------------------
    turnoutsFullList = new ArrayList<>();
    // Set up a list adapter to allow adding the list of defined turnouts to the UI.
    turnouts_list = new ArrayList<>();
    turnouts_list_adapter = new SimpleAdapter(this, turnouts_list, R.layout.turnouts_item, new String[] { "to_user_name", "to_system_name", "to_current_state_desc" }, new int[] { R.id.to_user_name, R.id.to_system_name, R.id.to_current_state_desc }) {

        // set up listener for each state button
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View row = super.getView(position, convertView, parent);
            if (row != null) {
                Button bt = row.findViewById(R.id.turnout_throw);
                bt.setOnClickListener(new turnout_state_button_listener(TURNOUT_THROW));
                Button bc = row.findViewById(R.id.turnout_close);
                bc.setOnClickListener(new turnout_state_button_listener(TURNOUT_CLOSE));
                Button b = row.findViewById(R.id.to_current_state_desc);
                b.setOnClickListener(new turnout_state_button_listener(TURNOUT_TOGGLE));
                setTurnoutRowButtonState(row, b, bt, bc);
            }
            return row;
        }
    };
    turnouts_lv = findViewById(R.id.turnouts_list);
    turnouts_lv.setAdapter(turnouts_list_adapter);
    OnTouchListener gestureListener = new ListView.OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            return myGesture != null && myGesture.onTouchEvent(event);
        }
    };
    turnouts_lv.setOnTouchListener(gestureListener);
    turnouts_lv.setOnScrollListener(new AbsListView.OnScrollListener() {

        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        }

        public void onScrollStateChanged(AbsListView view, int scrollState) {
            if (scrollState == 0) {
                // scrolling has stopped
                refreshTurnoutViewStates();
            }
        }
    });
    // -------------------------------------------------------------------
    trn = findViewById(R.id.turnout_entry);
    // trn.addTextChangedListener(new TextWatcher() {
    // public void afterTextChanged(Editable s) {
    // updateTurnoutEntry();
    // }
    // 
    // public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    // }
    // 
    // public void onTextChanged(CharSequence s, int start, int before, int count) {
    // }
    // });
    // trn.setOnEditorActionListener(new OnEditorActionListener() {
    // @Override
    // public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    // if ((actionId & EditorInfo.IME_MASK_ACTION) != 0) {
    // InputMethodManager imm =
    // (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    // if (imm != null) {
    // imm.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    // }
    // return true;
    // } else
    // return false;
    // }
    // });
    // Set the button callbacks, storing the command to pass for each
    Button b = findViewById(R.id.turnout_toggle);
    button_listener click_listener = new button_listener('2');
    b.setOnClickListener(click_listener);
    b = findViewById(R.id.turnout_close);
    click_listener = new button_listener('C');
    b.setOnClickListener(click_listener);
    b = findViewById(R.id.turnout_throw);
    click_listener = new button_listener('T');
    b.setOnClickListener(click_listener);
    locationList = new ArrayList<>();
    locationSpinner = findViewById(R.id.turnouts_location);
    locationListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, locationList);
    locationListAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    locationSpinner.setAdapter(locationListAdapter);
    locationSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            location = parent.getSelectedItem().toString();
            filterTurnoutView();
            refreshTurnoutViewStates();
        }

        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    llSelectionGroup = findViewById(R.id.select_turnout_method_radio_group);
    tvSelectionHeading = findViewById(R.id.turnouts_selection_type_heading);
    llAddress = findViewById(R.id.enter_turnout_address_group);
    llRoster = findViewById(R.id.turnouts_from_roster_group);
    llRecent = findViewById(R.id.turnouts_recent_group);
    mainapp.shownRosterTurnouts = false;
    // -------------------------------------------------------------------
    // Set up a list adapter to allow adding the list of recent turnouts to the UI.
    recentTurnoutsList = new ArrayList<>();
    recentTurnoutsListAdapter = new RecentTurnoutsSimpleAdapter(this, recentTurnoutsList, R.layout.turnouts_recent_item, new String[] { "to_recent_user_name", "to_recent_system_name" }, new int[] { R.id.to_recent_user_name, R.id.to_recent_system_name }) {

        // set up listener for each Throw state button
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View row = super.getView(position, convertView, parent);
            if (row != null) {
                Button b = row.findViewById(R.id.turnout_recent_throw);
                b.setOnClickListener(new recentTurnoutStateButtonListener(TURNOUT_THROW));
                b = row.findViewById(R.id.turnout_recent_close);
                b.setOnClickListener(new recentTurnoutStateButtonListener(TURNOUT_CLOSE));
                b = row.findViewById(R.id.turnout_recent_toggle);
                b.setOnClickListener(new recentTurnoutStateButtonListener(TURNOUT_TOGGLE));
            }
            return row;
        }
    };
    recentTurnoutsListView = findViewById(R.id.turnouts_recent_list);
    recentTurnoutsListView.setAdapter(recentTurnoutsListAdapter);
    OnTouchListener recentTurnoutsGestureListener = new ListView.OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            return myGesture != null && myGesture.onTouchEvent(event);
        }
    };
    recentTurnoutsListView.setOnTouchListener(recentTurnoutsGestureListener);
    loadRecentTurnoutsList();
    b = findViewById(R.id.clear_turnouts_list_button);
    b.setOnClickListener(new clearRecentTurnoutsListButton());
    // -------------------------------------------------------------------
    // setup the method radio buttons
    rbAddress = findViewById(R.id.select_turnout_method_address_button);
    rbRoster = findViewById(R.id.select_turnout_method_roster_button);
    String serverType = mainapp.getServerType();
    if (serverType.isEmpty())
        serverType = getApplicationContext().getResources().getString(R.string.server);
    rbRoster.setText(getApplicationContext().getResources().getString(R.string.turnoutsSelectionTypeRoster, serverType));
    prefSelectTurnoutsMethod = prefs.getString("prefSelectTurnoutsMethod", WHICH_METHOD_FIRST);
    // if the recent lists are empty make sure the radio button will be pointing to something valid
    if (((importExportPreferences.recent_turnout_address_list.size() == 0) && (prefSelectTurnoutsMethod.equals(WHICH_METHOD_ADDRESS)))) {
        prefSelectTurnoutsMethod = WHICH_METHOD_ADDRESS;
    }
    showMethod(prefSelectTurnoutsMethod);
    RadioGroup rgTurnoutsSelect = findViewById(R.id.select_turnout_method_radio_group);
    rgTurnoutsSelect.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            switch(checkedId) {
                case R.id.select_turnout_method_address_button:
                    showMethod(WHICH_METHOD_ADDRESS);
                    break;
                case R.id.select_turnout_method_roster_button:
                    showMethod(WHICH_METHOD_ROSTER);
                    break;
            }
        }
    });
    // update turnout list
    refresh_turnout_view();
    refreshTurnoutViewStates();
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
    }
    turnoutsView = findViewById(R.id.select_turnout_screen);
    // enable swipe/fling detection if enabled in Prefs
    turnoutsOverlayView = findViewById(R.id.turnouts_overlay);
    turnoutsOverlayView.addOnGestureListener(this);
    turnoutsOverlayView.setEventsInterceptionEnabled(true);
    if (mVelocityTracker == null) {
        mVelocityTracker = VelocityTracker.obtain();
    }
    mainapp.prefFullScreenSwipeArea = prefs.getBoolean("prefFullScreenSwipeArea", getResources().getBoolean(R.bool.prefFullScreenSwipeAreaDefaultValue));
}
Also used : OnTouchListener(android.view.View.OnTouchListener) RadioGroup(android.widget.RadioGroup) RadioButton(android.widget.RadioButton) Button(android.widget.Button) ViewGroup(android.view.ViewGroup) SimpleAdapter(android.widget.SimpleAdapter) AbsListView(android.widget.AbsListView) GestureOverlayView(android.gesture.GestureOverlayView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) AdapterView(android.widget.AdapterView)

Example 70 with OnTouchListener

use of android.view.View.OnTouchListener in project EngineDriver by JMRI.

the class routes method onCreate.

// @Override
// public boolean onTouchEvent(MotionEvent event) {
// return myGesture.onTouchEvent(event);
// }
// public void setTitleToIncludeThrotName() {
// String defaultName = getApplicationContext().getResources().getString(R.string.prefThrottleNameDefaultValue);
// setTitle(getApplicationContext().getResources().getString(R.string.app_name_routes) + "    |    Throttle Name: " +
// prefs.getString("throttle_name_preference", defaultName));
// }
/**
 * Called when the activity is first created.
 */
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
    // Log.d("Engine_Driver", "routes: onCreate");
    mainapp = (threaded_application) getApplication();
    prefs = getSharedPreferences("jmri.enginedriver_preferences", 0);
    mainapp.applyTheme(this);
    super.onCreate(savedInstanceState);
    if (mainapp.isForcingFinish()) {
        // expedite
        return;
    }
    setContentView(R.layout.routes);
    // put pointer to this activity's handler in main app's shared variable
    mainapp.routes_msg_handler = new routes_handler();
    routesFullList = new ArrayList<>();
    // Set up a list adapter to allow adding the list of recent connections to the UI.
    routes_list = new ArrayList<>();
    routes_list_adapter = new SimpleAdapter(this, routes_list, R.layout.routes_item, new String[] { "rt_user_name", "rt_system_name_hidden", "rt_system_name", "rt_current_state_desc" }, new int[] { R.id.rt_user_name, R.id.rt_system_name_hidden, R.id.rt_system_name, R.id.rt_current_state_desc }) {

        // set up listener for each state button
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View row = super.getView(position, convertView, parent);
            if (row != null) {
                Button b = row.findViewById(R.id.rt_current_state_desc);
                b.setOnClickListener(new route_state_button_listener());
            }
            return row;
        }
    };
    ListView routes_lv = findViewById(R.id.routes_list);
    routes_lv.setAdapter(routes_list_adapter);
    OnTouchListener gestureListener = new ListView.OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                mainapp.buttonVibration();
            }
            return myGesture != null && myGesture.onTouchEvent(event);
        }
    };
    routes_lv.setOnTouchListener(gestureListener);
    EditText rte = findViewById(R.id.route_entry);
    rte.addTextChangedListener(new TextWatcher() {

        public void afterTextChanged(Editable s) {
            updateRouteEntry();
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });
    rte.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((actionId & EditorInfo.IME_MASK_ACTION) != 0) {
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                if (imm != null) {
                    imm.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
                }
                return true;
            } else
                return false;
        }
    });
    // Set the button callbacks, storing the command to pass for each
    Button b = findViewById(R.id.route_toggle);
    button_listener click_listener = new button_listener('2');
    b.setOnClickListener(click_listener);
    locationList = new ArrayList<>();
    locationSpinner = findViewById(R.id.routes_location);
    locationListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, locationList);
    locationListAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    locationSpinner.setAdapter(locationListAdapter);
    locationSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            location = parent.getSelectedItem().toString();
            filterRouteView();
        }

        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    // update route list
    refresh_route_view();
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
    }
    routesView = findViewById(R.id.routes);
    // enable swipe/fling detection if enabled in Prefs
    routesOverlayView = findViewById(R.id.routes_overlay);
    routesOverlayView.addOnGestureListener(this);
    routesOverlayView.setEventsInterceptionEnabled(true);
    if (mVelocityTracker == null) {
        mVelocityTracker = VelocityTracker.obtain();
    }
    mainapp.prefFullScreenSwipeArea = prefs.getBoolean("prefFullScreenSwipeArea", getResources().getBoolean(R.bool.prefFullScreenSwipeAreaDefaultValue));
}
Also used : OnTouchListener(android.view.View.OnTouchListener) InputMethodManager(android.view.inputmethod.InputMethodManager) KeyEvent(android.view.KeyEvent) ListView(android.widget.ListView) Button(android.widget.Button) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) EditText(android.widget.EditText) ViewGroup(android.view.ViewGroup) SimpleAdapter(android.widget.SimpleAdapter) GestureOverlayView(android.gesture.GestureOverlayView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) AdapterView(android.widget.AdapterView)

Aggregations

OnTouchListener (android.view.View.OnTouchListener)70 MotionEvent (android.view.MotionEvent)68 View (android.view.View)68 TextView (android.widget.TextView)40 OnClickListener (android.view.View.OnClickListener)21 ImageView (android.widget.ImageView)19 ListView (android.widget.ListView)16 AdapterView (android.widget.AdapterView)15 SuppressLint (android.annotation.SuppressLint)12 KeyEvent (android.view.KeyEvent)8 Intent (android.content.Intent)7 AbsListView (android.widget.AbsListView)7 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)6 Rect (android.graphics.Rect)5 Handler (android.os.Handler)5 GestureDetector (android.view.GestureDetector)5 OnGenericMotionListener (android.view.View.OnGenericMotionListener)5 WindowManager (android.view.WindowManager)5 DialogInterface (android.content.DialogInterface)4 Editable (android.text.Editable)4