List of usage examples for android.widget RelativeLayout setOnLongClickListener
public void setOnLongClickListener(@Nullable OnLongClickListener l)
From source file:com.dish.browser.activity.BrowserActivity.java
@SuppressLint("NewApi") @SuppressWarnings("deprecation") private synchronized void initialize() { setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from ww w .j a v a 2 s .com*/ ActionBar actionBar = getSupportActionBar(); mPreferences = PreferenceManager.getInstance(); mDarkTheme = mPreferences.getUseDarkTheme() || isIncognito(); mActivity = this; mWebViews.clear(); mClickHandler = new ClickHandler(this); mBrowserFrame = (FrameLayout) findViewById(R.id.content_frame); mToolbarLayout = (LinearLayout) findViewById(R.id.toolbar_layout); // initialize background ColorDrawable mBackground.setColor(((ColorDrawable) mToolbarLayout.getBackground()).getColor()); mUiLayout = (LinearLayout) findViewById(R.id.ui_layout); mProgressBar = (AnimatedProgressBar) findViewById(R.id.progress_view); RelativeLayout newTab = (RelativeLayout) findViewById(R.id.new_tab_button); mDrawerLeft = (LinearLayout) findViewById(R.id.left_drawer); // Drawer stutters otherwise mDrawerLeft.setLayerType(View.LAYER_TYPE_HARDWARE, null); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerListLeft = (ListView) findViewById(R.id.left_drawer_list); setNavigationDrawerWidth(); mWebpageBitmap = Utils.getWebpageBitmap(getResources(), mDarkTheme); mHomepage = mPreferences.getHomepage(); mTitleAdapter = new LightningViewAdapter(this, R.layout.tab_list_item, mWebViews); mDrawerListLeft.setAdapter(mTitleAdapter); mDrawerListLeft.setOnItemClickListener(new DrawerItemClickListener()); mDrawerListLeft.setOnItemLongClickListener(new DrawerItemLongClickListener()); mHistoryDatabase = HistoryDatabase.getInstance(getApplicationContext()); // set display options of the ActionBar actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowCustomEnabled(true); actionBar.setCustomView(R.layout.toolbar_content); View v = actionBar.getCustomView(); LayoutParams lp = v.getLayoutParams(); lp.width = LayoutParams.MATCH_PARENT; v.setLayoutParams(lp); mArrowDrawable = new DrawerArrowDrawable(this); mArrowImage = (ImageView) actionBar.getCustomView().findViewById(R.id.arrow); // Use hardware acceleration for the animation mArrowImage.setLayerType(View.LAYER_TYPE_HARDWARE, null); mArrowImage.setImageDrawable(mArrowDrawable); LinearLayout arrowButton = (LinearLayout) actionBar.getCustomView().findViewById(R.id.arrow_button); arrowButton.setOnClickListener(this); mI2PHelper = new I2PAndroidHelper(this); RelativeLayout back = (RelativeLayout) findViewById(R.id.action_back); back.setOnClickListener(this); RelativeLayout forward = (RelativeLayout) findViewById(R.id.action_forward); forward.setOnClickListener(this); // create the search EditText in the ToolBar mSearch = (AutoCompleteTextView) actionBar.getCustomView().findViewById(R.id.search); mUntitledTitle = getString(R.string.untitled); mBackgroundColor = getResources().getColor(R.color.primary_color); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { mDeleteIcon = getResources().getDrawable(R.drawable.ic_action_delete); mRefreshIcon = getResources().getDrawable(R.drawable.ic_action_refresh); mCopyIcon = getResources().getDrawable(R.drawable.ic_action_copy); } else { Theme theme = getTheme(); mDeleteIcon = getResources().getDrawable(R.drawable.ic_action_delete, theme); mRefreshIcon = getResources().getDrawable(R.drawable.ic_action_refresh, theme); mCopyIcon = getResources().getDrawable(R.drawable.ic_action_copy, theme); } int iconBounds = Utils.convertDpToPixels(24); mDeleteIcon.setBounds(0, 0, iconBounds, iconBounds); mRefreshIcon.setBounds(0, 0, iconBounds, iconBounds); mCopyIcon.setBounds(0, 0, iconBounds, iconBounds); mIcon = mRefreshIcon; SearchClass search = new SearchClass(); mSearch.setCompoundDrawables(null, null, mRefreshIcon, null); mSearch.setOnKeyListener(search.new KeyListener()); mSearch.setOnFocusChangeListener(search.new FocusChangeListener()); mSearch.setOnEditorActionListener(search.new EditorActionListener()); mSearch.setOnTouchListener(search.new TouchListener()); mSystemBrowser = getSystemBrowser(); Thread initialize = new Thread(new Runnable() { @Override public void run() { initializeSearchSuggestions(mSearch); } }); initialize.run(); newTab.setOnClickListener(this); newTab.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { String url = mPreferences.getSavedUrl(); if (url != null) { newTab(url, true); Toast.makeText(mActivity, R.string.deleted_tab, Toast.LENGTH_SHORT).show(); } mPreferences.setSavedUrl(null); return true; } }); mDrawerLayout.setDrawerShadow(R.drawable.drawer_right_shadow, GravityCompat.END); mDrawerLayout.setDrawerShadow(R.drawable.drawer_left_shadow, GravityCompat.START); initializeTabs(); if (API <= Build.VERSION_CODES.JELLY_BEAN_MR2) { WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath()); } checkForProxy(); }