This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Override | |
| public void onViewPositionChanged(View child, int x, int y, int dx, int dy) { | |
| float startAlphaDistance = mOriginalCapturedViewLeft | |
| + child.getWidth() * mAlphaStartSwipeDistance; | |
| float endAlphaDistance = mOriginalCapturedViewLeft | |
| + child.getWidth() * mAlphaEndSwipeDistance; | |
| float diff = Math.abs(x - startAlphaDistance); | |
| float totalLength = endAlphaDistance - startAlphaDistance; | |
| ViewCompat.setAlpha(child, clamp(0f, 1f - diff / totalLength, 1f)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private final ViewDragHelper.Callback dragCallback = | |
| new ViewDragHelper.Callback() { | |
| ... | |
| @Override | |
| public void onViewPositionChanged(View child, int left, int top, int dx, int dy) { | |
| final float startAlphaDistance = | |
| originalCapturedViewLeft + child.getWidth() * alphaStartSwipeDistance; | |
| final float endAlphaDistance = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // The following is pseudo code. If you want actual code: | |
| // https://android.googlesource.com/platform/frameworks/base/+/master/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java | |
| private RankingMap mRankingMap; | |
| Ranking mTemporaryRanking = new Ranking(); | |
| @Override | |
| public void onNotificationRankingUpdate(RankingMap rankingMap) { | |
| mRankingMap = rankingMap; | |
| for (StatusBarNotification sbn : mYourNotifications) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <service android:name=".ExampleNotificationListener" | |
| android:label="@string/notification_service_label" | |
| android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" | |
| android:directBootAware="true"> | |
| <intent-filter> | |
| <action android:name="android.service.notification.NotificationListenerService"/> | |
| </intent-filter> | |
| </service> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for (int i = 0; i < nUserIds; ++i) { | |
| final Set<ComponentName> add = toAdd.get(userIds[i]); | |
| for (ComponentName component : add) { | |
| try { | |
| ServiceInfo info = mPm.getServiceInfo(component, | |
| PackageManager.MATCH_DIRECT_BOOT_AWARE | |
| | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, userIds[i]); | |
| if (info == null || !mConfig.bindPermission.equals(info.permission)) { | |
| Slog.w(TAG, "Not binding " + getCaption() + " service " + component | |
| + ": it does not require the permission " + mConfig.bindPermission); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.lang.Math; | |
| public class HelloWorld { | |
| public static void main(String[] args) { | |
| Board b = new Board(8, 8); | |
| b.findSolution(1); | |
| b.Print(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Solution { | |
| public bool WordBreak(string s, ISet<string> wordDict) { | |
| int len = s.Length; | |
| bool[] canBreak = new bool[len + 1]; | |
| canBreak[0] = true; | |
| for(int i = 1; i <= len; i++) { // i stands for the length of the substring | |
| foreach (string word in wordDict) { | |
| if (i - word.Length < 0) continue; | |
| if (canBreak[i - word.Length] && word == s.Substring(i - word.Length, word.Length)) { | |
| canBreak[i] = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Definition for a binary tree node. | |
| * public class TreeNode { | |
| * public int val; | |
| * public TreeNode left; | |
| * public TreeNode right; | |
| * public TreeNode(int x) { val = x; } | |
| * } | |
| */ | |
| public class Solution { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| namespace GameOfLife | |
| { | |
| class Program | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| namespace GameOfLife3D | |
| { | |
| class Program | |
| { |
NewerOlder