List of usage examples for java.lang Float compare
public static int compare(float f1, float f2)
From source file:WeakIdentityMap.java
static int compare(float[] a, float[] b) { if (a == b) { return 0; }/*w ww. j av a2 s . c om*/ if (a == null) { return 1; } if (b == null) { return -1; } int length = Math.min(a.length, b.length); for (int i = 0; i < length; i++) { int v = Float.compare(a[i], b[i]); if (v != 0) { return v; } } return a.length < b.length ? -1 : (a.length > b.length ? 1 : 0); }
From source file:org.cesecore.certificates.ca.CaSessionBean.java
/** Performs upgrades on the entity if needed within a transaction. */ private CAData upgradeAndMergeToDatabase(CAData cadata) { if (cadata == null) { return null; }// ww w. jav a 2s . c o m CAData caDataReturn = cadata; final LinkedHashMap<Object, Object> caDataMap = cadata.getDataMap(); // If CA-data is upgraded we want to save the new data, so we must get the old version before loading the data // and perhaps upgrading final float oldversion = ((Float) caDataMap.get(UpgradeableDataHashMap.VERSION)).floatValue(); // Perform "live" upgrade from 5.0.x and earlier boolean adhocUpgrade = adhocUpgradeFrom50(cadata.getCaId().intValue(), caDataMap, cadata.getName()); if (adhocUpgrade) { // Convert map into storage friendly format now since we changed it cadata.setDataMap(caDataMap); } // Fetching the CA object will trigger UpgradableHashMap upgrades CA ca = cadata.getCA(); final boolean expired = hasCAExpiredNow(ca); if (expired) { ca.setStatus(CAConstants.CA_EXPIRED); } final boolean upgradedExtendedService = ca.upgradeExtendedCAServices(); // Compare old version with current version and save the data if there has been a change final boolean upgradeCA = (Float.compare(oldversion, ca.getVersion()) != 0); if (adhocUpgrade || upgradedExtendedService || upgradeCA || expired) { if (log.isDebugEnabled()) { log.debug("Merging CA to database. Name: " + cadata.getName() + ", id: " + cadata.getCaId() + ", adhocUpgrade: " + adhocUpgrade + ", upgradedExtendedService: " + upgradedExtendedService + ", upgradeCA: " + upgradeCA + ", expired: " + expired); } ca.getCAToken(); final int caId = caSession.mergeCa(ca); caDataReturn = entityManager.find(CAData.class, caId); } return caDataReturn; }
From source file:com.moviejukebox.plugin.SratimPlugin.java
public void downloadSubtitle(Movie movie, MovieFile mf) throws IOException { if (!subtitleDownload) { mf.setSubtitlesExchange(true);/*w w w . j a v a2 s . co m*/ return; } // Get the file base name String path = mf.getFile().getName().toUpperCase(); int lindex = path.lastIndexOf('.'); if (lindex == -1) { return; } String basename = path.substring(0, lindex); // Check if this is a bluray file boolean bluRay = false; if (path.endsWith(".M2TS") && path.startsWith("0")) { bluRay = true; } if (movie.isExtra()) { mf.setSubtitlesExchange(true); return; } // Check if this movie already have subtitles for it (.srt and .sub) if (hasExistingSubtitles(mf, bluRay)) { mf.setSubtitlesExchange(true); return; } basename = basename.replace('.', ' ').replace('-', ' ').replace('_', ' '); LOG.debug("Download Subtitle: {}", mf.getFile().getAbsolutePath()); LOG.debug("Basename : {}", basename); LOG.debug("BluRay : {}", bluRay); int bestFPSCount = 0; int bestBlurayCount = 0; int bestBlurayFPSCount = 0; String bestFPSID = ""; String bestBlurayID = ""; String bestBlurayFPSID = ""; String bestFileID = ""; String bestSimilar = ""; // retrieve subtitles page String subID = movie.getId(SRATIM_PLUGIN_SUBTITLE_ID); String mainXML = httpClient.request("http://www.sratim.co.il/subtitles.php?mid=" + subID); int index = 0; int endIndex; // find the end of hebrew subtitles section, to prevent downloading non-hebrew ones int endHebrewSubsIndex = findEndOfHebrewSubtitlesSection(mainXML); // Check that hebrew subtitle exist String hebrewSub = HTMLTools.getTextAfterElem(mainXML, "<img src=\"images/Flags/1.png"); LOG.debug("hebrewSub: {}", hebrewSub); // Check that there is no 0 hebrew sub if (Movie.UNKNOWN.equals(hebrewSub)) { LOG.debug("No Hebrew subtitles"); return; } double maxMatch = 0.0; double matchThreshold = PropertiesUtil.getFloatProperty("sratim.textMatchSimilarity", 0.8f); while (index < endHebrewSubsIndex) { // // scanID // index = mainXML.indexOf("href=\"downloadsubtitle.php?id=", index); if (index == -1) { break; } index += 30; endIndex = mainXML.indexOf('\"', index); if (endIndex == -1) { break; } String scanID = mainXML.substring(index, endIndex); // // scanDiscs // index = mainXML.indexOf("src=\"images/cds/cd", index); if (index == -1) { break; } index += 18; endIndex = mainXML.indexOf('.', index); if (endIndex == -1) { break; } String scanDiscs = mainXML.substring(index, endIndex); // // scanFileName // index = mainXML.indexOf("subtitle_title\" style=\"direction:ltr;\" title=\"", index); if (index == -1) { break; } index += 46; endIndex = mainXML.indexOf('\"', index); if (endIndex == -1) { break; } String scanFileName = mainXML.substring(index, endIndex).toUpperCase().replace('.', ' '); // removing all characters causing metric to hang. scanFileName = scanFileName.replaceAll("-|\u00A0", " ").replaceAll(" ++", " "); // // scanFormat // index = mainXML.indexOf("\u05e4\u05d5\u05e8\u05de\u05d8", index); // the hebrew letters for the word "format" if (index == -1) { break; } index += 6; endIndex = mainXML.indexOf(',', index); if (endIndex == -1) { break; } String scanFormat = mainXML.substring(index, endIndex); // // scanFPS // index = mainXML.indexOf("\u05dc\u05e9\u05e0\u0027\u003a", index); // the hebrew letters for the word "for sec':" lamed shin nun ' : if (index == -1) { break; } index += 5; endIndex = mainXML.indexOf('<', index); if (endIndex == -1) { break; } String scanFPS = mainXML.substring(index, endIndex); // // scanCount // index = mainXML.indexOf("subt_date\"><span class=\"smGray\">", index); if (index == -1) { break; } index += 32; endIndex = mainXML.indexOf(' ', index); if (endIndex == -1) { break; } String scanCount = mainXML.substring(index, endIndex); // Check for best text similarity double result = StringUtils.getJaroWinklerDistance(basename, scanFileName); if (result > maxMatch) { maxMatch = result; bestSimilar = scanID; } LOG.debug( "scanFileName: {} scanFPS: {} scanID: {} scanCount: {} scanDiscs: {} scanFormat: {} similarity: {}", scanFileName, scanFPS, scanID, scanCount, scanDiscs, scanFormat, result); // Check if movie parts matches int nDiscs = movie.getMovieFiles().size(); if (!String.valueOf(nDiscs).equals(scanDiscs)) { continue; } // Check for exact file name if (scanFileName.equals(basename)) { bestFileID = scanID; break; } int scanCountInt = NumberUtils.toInt(scanCount, 0); float scanFPSFloat = NumberUtils.toFloat(scanFPS, 0F); LOG.debug("FPS: {} scanFPS: {}", movie.getFps(), scanFPSFloat); if (bluRay && ((scanFileName.contains("BRRIP")) || (scanFileName.contains("BDRIP")) || (scanFileName.contains("BLURAY")) || (scanFileName.contains("BLU-RAY")) || (scanFileName.contains("HDDVD")))) { if ((Float.compare(scanFPSFloat, 0F) == 0) && (scanCountInt > bestBlurayCount)) { bestBlurayCount = scanCountInt; bestBlurayID = scanID; } if ((Float.compare(movie.getFps(), scanFPSFloat) == 0) && (scanCountInt > bestBlurayFPSCount)) { bestBlurayFPSCount = scanCountInt; bestBlurayFPSID = scanID; } } if ((Float.compare(movie.getFps(), scanFPSFloat) == 0) && (scanCountInt > bestFPSCount)) { bestFPSCount = scanCountInt; bestFPSID = scanID; } } // Select the best subtitles ID String bestID; // Check for exact file name match if (StringUtils.isNotBlank(bestFileID)) { LOG.debug("Best Filename"); bestID = bestFileID; } else if (maxMatch >= matchThreshold) { // Check for text similarity match, similarity threshold takes precedence over FPS check LOG.debug("Best Text Similarity threshold"); bestID = bestSimilar; } else if (StringUtils.isNotBlank(bestBlurayFPSID)) { // Check for bluray match LOG.debug("Best Bluray FPS"); bestID = bestBlurayFPSID; } else if (StringUtils.isNotBlank(bestBlurayID)) { // Check for bluray match LOG.debug("Best Bluray"); bestID = bestBlurayID; } else if (StringUtils.isNotBlank(bestFPSID)) { // Check for fps match LOG.debug("Best FPS"); bestID = bestFPSID; } else if (maxMatch > 0) { // Check for text match, now just choose the best similar name LOG.debug("Best Similar"); bestID = bestSimilar; } else { LOG.debug("No subtitle found"); return; } LOG.debug("bestID: {}", bestID); // reconstruct movie filename with full path String orgName = mf.getFile().getAbsolutePath(); File subtitleFile = new File(orgName.substring(0, orgName.lastIndexOf('.'))); if (!downloadSubtitleZip(movie, "http://www.sratim.co.il/downloadsubtitle.php?id=" + bestID, subtitleFile, bluRay)) { LOG.error("Error - Subtitle download failed"); return; } mf.setSubtitlesExchange(true); SubtitleTools.addMovieSubtitle(movie, "YES"); }
From source file:cc.flydev.launcher.Workspace.java
@Override protected void determineScrollingStart(MotionEvent ev) { if (!isFinishedSwitchingState()) return;/*w ww . ja va2s. c om*/ float deltaX = ev.getX() - mXDown; float absDeltaX = Math.abs(deltaX); float absDeltaY = Math.abs(ev.getY() - mYDown); if (Float.compare(absDeltaX, 0f) == 0) return; float slope = absDeltaY / absDeltaX; float theta = (float) Math.atan(slope); if (absDeltaX > mTouchSlop || absDeltaY > mTouchSlop) { cancelCurrentPageLongPress(); } boolean passRightSwipesToCustomContent = (mTouchDownTime - mCustomContentShowTime) > CUSTOM_CONTENT_GESTURE_DELAY; boolean swipeInIgnoreDirection = isLayoutRtl() ? deltaX < 0 : deltaX > 0; if (swipeInIgnoreDirection && getScreenIdForPageIndex(getCurrentPage()) == CUSTOM_CONTENT_SCREEN_ID && passRightSwipesToCustomContent) { // Pass swipes to the right to the custom content page. return; } if (theta > MAX_SWIPE_ANGLE) { // Above MAX_SWIPE_ANGLE, we don't want to ever start scrolling the workspace return; } else if (theta > START_DAMPING_TOUCH_SLOP_ANGLE) { // Above START_DAMPING_TOUCH_SLOP_ANGLE and below MAX_SWIPE_ANGLE, we want to // increase the touch slop to make it harder to begin scrolling the workspace. This // results in vertically scrolling widgets to more easily. The higher the angle, the // more we increase touch slop. theta -= START_DAMPING_TOUCH_SLOP_ANGLE; float extraRatio = (float) Math.sqrt((theta / (MAX_SWIPE_ANGLE - START_DAMPING_TOUCH_SLOP_ANGLE))); super.determineScrollingStart(ev, 1 + TOUCH_SLOP_DAMPING_FACTOR * extraRatio); } else { // Below START_DAMPING_TOUCH_SLOP_ANGLE, we don't do anything special super.determineScrollingStart(ev); } }
From source file:com.wb.launcher3.Workspace.java
@Override protected void determineScrollingStart(MotionEvent ev) { if (!isFinishedSwitchingState()) return;//from w w w . j ava2 s. com float deltaX = ev.getX() - mXDown; float absDeltaX = Math.abs(deltaX); float absDeltaY = Math.abs(ev.getY() - mYDown); if (Float.compare(absDeltaX, 0f) == 0) return; float slope = absDeltaY / absDeltaX; float theta = (float) Math.atan(slope); if (absDeltaX > mTouchSlop || absDeltaY > mTouchSlop) { cancelCurrentPageLongPress(); } boolean passRightSwipesToCustomContent = (mTouchDownTime - mCustomContentShowTime) > CUSTOM_CONTENT_GESTURE_DELAY; boolean swipeInIgnoreDirection = isLayoutRtl() ? deltaX < 0 : deltaX > 0; if (swipeInIgnoreDirection && getScreenIdForPageIndex(getCurrentPage()) == CUSTOM_CONTENT_SCREEN_ID && passRightSwipesToCustomContent) { // Pass swipes to the right to the custom content page. return; } if (theta > MAX_SWIPE_ANGLE) { //*/Added by tyd Greg 2014-03-21,for support the touch swipe gesture if (TydtechConfig.SWIPE_GESTURE_ENABLED && (isInOverviewMode() == mStartIsOverViewMode) && (mPointCount == 1) && (mTouchUPCountTemp == mPointCount)) { CellLayout cell = (CellLayout) getChildAt(mCurrentPage); if (true) { float y = ev.getY(); if ((y - mYDown) > 0) { if (Math.abs(y - mYDown) > (mTouchSlop * 5) && LauncherAppState.getInstance().getSwipeDownEnable()) mTouchState = TOUCH_SWIPE_DOWN_GESTURE; } else { if (Math.abs(y - mYDown) > (mTouchSlop * 5) && LauncherAppState.getInstance().getSwipeUpEnable()) mTouchState = TOUCH_SWIPE_UP_GESTURE; } } } mTouchUPCountTemp = mPointCount; //*/ // Above MAX_SWIPE_ANGLE, we don't want to ever start scrolling the workspace return; } else if (theta > START_DAMPING_TOUCH_SLOP_ANGLE) { // Above START_DAMPING_TOUCH_SLOP_ANGLE and below MAX_SWIPE_ANGLE, we want to // increase the touch slop to make it harder to begin scrolling the workspace. This // results in vertically scrolling widgets to more easily. The higher the angle, the // more we increase touch slop. theta -= START_DAMPING_TOUCH_SLOP_ANGLE; float extraRatio = (float) Math.sqrt((theta / (MAX_SWIPE_ANGLE - START_DAMPING_TOUCH_SLOP_ANGLE))); super.determineScrollingStart(ev, 1 + TOUCH_SLOP_DAMPING_FACTOR * extraRatio); } else { // Below START_DAMPING_TOUCH_SLOP_ANGLE, we don't do anything special super.determineScrollingStart(ev); } }
From source file:com.aidy.launcher3.ui.workspace.Workspace.java
@Override protected void determineScrollingStart(MotionEvent ev) { if (!isFinishedSwitchingState()) return;/*from w ww.j ava2 s . c o m*/ float deltaX = ev.getX() - mXDown; float absDeltaX = Math.abs(deltaX); float absDeltaY = Math.abs(ev.getY() - mYDown); if (Float.compare(absDeltaX, 0f) == 0) return; float slope = absDeltaY / absDeltaX; float theta = (float) Math.atan(slope); if (absDeltaX > mTouchSlop || absDeltaY > mTouchSlop) { cancelCurrentPageLongPress(); } boolean passRightSwipesToCustomContent = (mTouchDownTime - mCustomContentShowTime) > CUSTOM_CONTENT_GESTURE_DELAY; boolean swipeInIgnoreDirection = isLayoutRtl() ? deltaX < 0 : deltaX > 0; if (swipeInIgnoreDirection && getScreenIdForPageIndex(getCurrentPage()) == CUSTOM_CONTENT_SCREEN_ID && passRightSwipesToCustomContent) { // Pass swipes to the right to the custom content page. return; } if (theta > MAX_SWIPE_ANGLE) { // Above MAX_SWIPE_ANGLE, we don't want to ever start scrolling the // workspace return; } else if (theta > START_DAMPING_TOUCH_SLOP_ANGLE) { // Above START_DAMPING_TOUCH_SLOP_ANGLE and below MAX_SWIPE_ANGLE, // we want to // increase the touch slop to make it harder to begin scrolling the // workspace. This // results in vertically scrolling widgets to more easily. The // higher the angle, the // more we increase touch slop. theta -= START_DAMPING_TOUCH_SLOP_ANGLE; float extraRatio = (float) Math.sqrt((theta / (MAX_SWIPE_ANGLE - START_DAMPING_TOUCH_SLOP_ANGLE))); super.determineScrollingStart(ev, 1 + TOUCH_SLOP_DAMPING_FACTOR * extraRatio); } else { // Below START_DAMPING_TOUCH_SLOP_ANGLE, we don't do anything // special super.determineScrollingStart(ev); } }
From source file:com.klinker.android.launcher.launcher3.Workspace.java
@Override protected void determineScrollingStart(MotionEvent ev) { if (!isFinishedSwitchingState()) return;/*from www. ja v a2 s .c om*/ float deltaX = ev.getX() - mXDown; float absDeltaX = Math.abs(deltaX); float absDeltaY = Math.abs(ev.getY() - mYDown); if (Float.compare(absDeltaX, 0f) == 0) return; float slope = absDeltaY / absDeltaX; float theta = (float) Math.atan(slope); if (absDeltaX > mTouchSlop || absDeltaY > mTouchSlop) { cancelCurrentPageLongPress(); } boolean passRightSwipesToCustomContent = (mTouchDownTime - mCustomContentShowTime) > CUSTOM_CONTENT_GESTURE_DELAY; boolean swipeInIgnoreDirection = mIsRtl ? deltaX < 0 : deltaX > 0; boolean onCustomContentScreen = getScreenIdForPageIndex(getCurrentPage()) == CUSTOM_CONTENT_SCREEN_ID; if (swipeInIgnoreDirection && onCustomContentScreen && passRightSwipesToCustomContent) { // Pass swipes to the right to the custom content page. return; } if (onCustomContentScreen && (mCustomContentCallbacks != null) && !mCustomContentCallbacks.isScrollingAllowed()) { // Don't allow workspace scrolling if the current custom content screen doesn't allow // scrolling. return; } if (theta > MAX_SWIPE_ANGLE) { // Above MAX_SWIPE_ANGLE, we don't want to ever start scrolling the workspace return; } else if (theta > START_DAMPING_TOUCH_SLOP_ANGLE) { // Above START_DAMPING_TOUCH_SLOP_ANGLE and below MAX_SWIPE_ANGLE, we want to // increase the touch slop to make it harder to begin scrolling the workspace. This // results in vertically scrolling widgets to more easily. The higher the angle, the // more we increase touch slop. theta -= START_DAMPING_TOUCH_SLOP_ANGLE; float extraRatio = (float) Math.sqrt((theta / (MAX_SWIPE_ANGLE - START_DAMPING_TOUCH_SLOP_ANGLE))); super.determineScrollingStart(ev, 1 + TOUCH_SLOP_DAMPING_FACTOR * extraRatio); } else { // Below START_DAMPING_TOUCH_SLOP_ANGLE, we don't do anything special super.determineScrollingStart(ev); } }
From source file:com.fairphone.fplauncher3.Workspace.java
@Override protected void determineScrollingStart(MotionEvent ev) { if (!isFinishedSwitchingState()) { return;// w w w.j a v a2 s .c o m } float deltaX = ev.getX() - mXDown; float absDeltaX = Math.abs(deltaX); float absDeltaY = Math.abs(ev.getY() - mYDown); if (Float.compare(absDeltaX, 0f) == 0) { return; } float slope = absDeltaY / absDeltaX; float theta = (float) Math.atan(slope); if (absDeltaX > mTouchSlop || absDeltaY > mTouchSlop) { cancelCurrentPageLongPress(); } boolean passRightSwipesToCustomContent = (mTouchDownTime - mCustomContentShowTime) > CUSTOM_CONTENT_GESTURE_DELAY; boolean swipeInIgnoreDirection = isLayoutRtl() ? deltaX < 0 : deltaX > 0; boolean onCustomContentScreen = getScreenIdForPageIndex(getCurrentPage()) == CUSTOM_CONTENT_SCREEN_ID; if (swipeInIgnoreDirection && onCustomContentScreen && passRightSwipesToCustomContent) { // Pass swipes to the right to the custom content page. return; } if (onCustomContentScreen && (mCustomContentCallbacks != null) && !mCustomContentCallbacks.isScrollingAllowed()) { // Don't allow workspace scrolling if the current custom content screen doesn't allow // scrolling. return; } if (theta > MAX_SWIPE_ANGLE) { // Above MAX_SWIPE_ANGLE, we don't want to ever start scrolling the workspace return; } else if (theta > START_DAMPING_TOUCH_SLOP_ANGLE) { // Above START_DAMPING_TOUCH_SLOP_ANGLE and below MAX_SWIPE_ANGLE, we want to // increase the touch slop to make it harder to begin scrolling the workspace. This // results in vertically scrolling widgets to more easily. The higher the angle, the // more we increase touch slop. theta -= START_DAMPING_TOUCH_SLOP_ANGLE; float extraRatio = (float) Math.sqrt((theta / (MAX_SWIPE_ANGLE - START_DAMPING_TOUCH_SLOP_ANGLE))); super.determineScrollingStart(ev, 1 + TOUCH_SLOP_DAMPING_FACTOR * extraRatio); } else { // Below START_DAMPING_TOUCH_SLOP_ANGLE, we don't do anything special super.determineScrollingStart(ev); } }
From source file:org.ejbca.core.model.ca.catoken.CATokenContainerImpl.java
public void upgrade() { if (Float.compare(LATEST_VERSION, getVersion()) != 0) { // New version of the class, upgrade String msg = intres.getLocalizedMessage("catoken.upgrade", new Float(getVersion())); log.info(msg);/*w w w .ja v a2s . co m*/ if (data.get(SIGNKEYALGORITHM) == null) { String oldKeyAlg = (String) data.get(KEYALGORITHM); if (oldKeyAlg != null) { data.put(SIGNKEYALGORITHM, oldKeyAlg); data.put(ENCKEYALGORITHM, oldKeyAlg); } } if (data.get(SIGNKEYSPEC) == null) { Integer oldKeySize = ((Integer) data.get(KEYSIZE)); if (oldKeySize != null) { data.put(SIGNKEYSPEC, oldKeySize.toString()); data.put(ENCKEYSPEC, oldKeySize.toString()); } } if (data.get(ENCRYPTIONALGORITHM) == null) { String signAlg = (String) data.get(SIGNATUREALGORITHM); data.put(ENCRYPTIONALGORITHM, signAlg); } if (data.get(CLASSPATH) == null) { String classpath = SoftCAToken.class.getName(); if (data.get(KEYSTORE) == null) { classpath = NullCAToken.class.getName(); } log.info("Adding new classpath to CA Token data: " + classpath); data.put(CLASSPATH, classpath); } if (data.get(SEQUENCE) == null) { String sequence = CATokenConstants.DEFAULT_KEYSEQUENCE; log.info("Adding new sequence to CA Token data: " + sequence); data.put(SEQUENCE, sequence); } if (data.get(SEQUENCE_FORMAT) == null) { // v7 log.info("Adding new sequence format to CA Token data: " + StringTools.KEY_SEQUENCE_FORMAT_NUMERIC); data.put(SEQUENCE_FORMAT, StringTools.KEY_SEQUENCE_FORMAT_NUMERIC); } data.put(VERSION, new Float(LATEST_VERSION)); } }
From source file:com.android.launcher3.Workspace.java
@Override protected void determineScrollingStart(MotionEvent ev) { if (!isFinishedSwitchingState()) return;// ww w .java2s .c o m float deltaX = ev.getX() - mXDown; float absDeltaX = Math.abs(deltaX); float absDeltaY = Math.abs(ev.getY() - mYDown); if (Float.compare(absDeltaX, 0f) == 0) return; float slope = absDeltaY / absDeltaX; float theta = (float) Math.atan(slope); if (absDeltaX > mTouchSlop || absDeltaY > mTouchSlop) { cancelCurrentPageLongPress(); } boolean passRightSwipesToCustomContent = (mTouchDownTime - mCustomContentShowTime) > CUSTOM_CONTENT_GESTURE_DELAY; boolean swipeInIgnoreDirection = isLayoutRtl() ? deltaX < 0 : deltaX > 0; boolean onCustomContentScreen = getScreenIdForPageIndex(getCurrentPage()) == CUSTOM_CONTENT_SCREEN_ID; if (swipeInIgnoreDirection && onCustomContentScreen && passRightSwipesToCustomContent) { // Pass swipes to the right to the custom content page. return; } if (onCustomContentScreen && (mCustomContentCallbacks != null) && !mCustomContentCallbacks.isScrollingAllowed()) { // Don't allow workspace scrolling if the current custom content screen doesn't allow // scrolling. return; } if (theta > MAX_SWIPE_ANGLE) { // Above MAX_SWIPE_ANGLE, we don't want to ever start scrolling the workspace return; } else if (theta > START_DAMPING_TOUCH_SLOP_ANGLE) { // Above START_DAMPING_TOUCH_SLOP_ANGLE and below MAX_SWIPE_ANGLE, we want to // increase the touch slop to make it harder to begin scrolling the workspace. This // results in vertically scrolling widgets to more easily. The higher the angle, the // more we increase touch slop. theta -= START_DAMPING_TOUCH_SLOP_ANGLE; float extraRatio = (float) Math.sqrt((theta / (MAX_SWIPE_ANGLE - START_DAMPING_TOUCH_SLOP_ANGLE))); super.determineScrollingStart(ev, 1 + TOUCH_SLOP_DAMPING_FACTOR * extraRatio); } else { // Below START_DAMPING_TOUCH_SLOP_ANGLE, we don't do anything special super.determineScrollingStart(ev); } }