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 static int getApproxXToCenterText(String text, Typeface typeface, int fontSize, int widthToFitStringInto) { | |
| Paint p = new Paint(); | |
| p.setTypeface(typeface); | |
| p.setTextSize(fontSize); | |
| float textWidth = p.measureText(text); | |
| int xOffset = (int)((widthToFitStringInto-textWidth)/2f) - (int)(fontSize/2f); | |
| return xOffset; | |
| } |
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 'dart:io' show Platform; | |
| ... | |
| var horizontalTitleAlignment = Platform.isIOS | |
| ? CrossAxisAlignment.center | |
| : CrossAxisAlignment.start; |
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
| final todos = List<Todo>.generate( | |
| 20, | |
| (i) => Todo( | |
| 'Todo $i', | |
| 'A description of what needs to be done for Todo $i', | |
| ), | |
| ); |
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
| <?xml version="1.0" encoding="utf-8"?> | |
| <shape xmlns:android="http://schemas.android.com/apk/res/android" | |
| android:shape="oval" | |
| android:useLevel="false" > | |
| <solid android:color="@android:color/white" /> | |
| <size | |
| android:height="50dp" | |
| android:width="50dp" /> | |
| </shape> |
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 MyWaitNotify { | |
| String myMonitorObject = ""; | |
| boolean wasSignalled = false; | |
| public void doWait() { | |
| synchronized (myMonitorObject) { | |
| while(!wasSignalled) { | |
| try { | |
| myMonitorObject.wait(); |
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 MyWaitNotify3 { | |
| MonitorObject myMonitorObject = new MonitorObject(); | |
| boolean wasSignalled = false; | |
| public void doWait() { | |
| synchronized (myMonitorObject) { | |
| while (!wasSignalled) { | |
| try { | |
| myMonitorObject.wait(); | |
| } catch (InterruptedException e) { |
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 MyWaitNotify2 { | |
| MonitorObject myMonitorObject = new MonitorObject(); | |
| boolean wasSignalled = false; | |
| public void doWait() { | |
| synchronized (myMonitorObject) { | |
| if (!wasSignalled) { | |
| try { | |
| myMonitorObject.wait(); |
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 MonitorObject { | |
| } | |
| public class MyWaitNotify { | |
| MonitorObject myMonitorObject = new MonitorObject(); | |
| public void doWait() { | |
| synchronized(myMonitorObject) { | |
| try { | |
| myMonitor.wait(); |
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
| protected MySignal sharedSignal = … | |
| while (!sharedSignal.hasDataToProcess()) { | |
| // do nothing… busy waiting | |
| } |
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 MySignal { | |
| protected boolean hasDataToProcess = false; | |
| public synchronized boolean hasDataToProcess() { | |
| return this.hasDataToProcess; | |
| } | |
| public synchronized void setHasDataToProcess(boolean hasData) { | |
| this.hasDataToProcess = hasData; | |
| } |