Review-IQ

Android: 9/19  203分
1- Android里面res下的layout是一个目录,如果存在landscape和portrait,则分别为layout-land和layout-port
drawable是图片的目录,如果是xml格式则就是drawable,而以前的png则需要按照分辨率dpi放在不同的目录如 drawable-xxhdpi
2- Android shape drawable
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape=["rectangle" | "oval" | "line" | "ring"] >
...
ring: 戒指形状,也就是环
3- custom attributes 用户定义View的属性
res/values/attrs.xml
<resources>
<declare-styleable name="PieChart">
<attr name="showText" format="boolean" />
<attr name="labelPosition" format="enum">
<enum name="left" value="0"/>
<enum name="right" value="1"/>
</attr>
</declare-styleable>
</resources>
这个指给PieChart这个自定义的View的添加两个属性
https://developer.android.com/training/custom-views/create-view
4- Mockito
想要mock Context类,两种方法
一个使用属性
@Mock
Context mMockContext;
第二种使用mock()
Context context = mock(Context.class);
5-
说两个EditText输入的内容(有ID),在比如activity旋转之后是否会保存?
我的感觉这个题目有点问题,重新restore的时候可能会清空啊
6- UI Automator
https://developer.android.com/training/testing/ui-automator
这个很少使用,
UiDevice可以做的事情:旋转/设备按键(电源估计不行)Home back 音量/截屏/通知栏
也就是与app本身无关的事情。
The UI Automator testing framework provides a UiDevice class to access and perform operations on the device on which the target app is running. You can call its methods to access device properties such as current orientation or display size. The UiDevice class also let you perform actions such as:
- Change the device rotation.
- Press a hardware key, such as "volume up".
- Press the Back, Home, or Menu buttons.
- Open the notification shade.
- Take a screenshot of the current window.
For example, to simulate a Home button press, call the UiDevice.pressHome() method.
UiCollection: Enumerates a container's UI elements for the purpose of counting, or targeting sub-elements by their visible text or content-description property.
UiObject: Represents a UI element that is visible on the device.
UiScrollable: Provides support for searching for items in a scrollable UI container.
UiSelector: Represents a query for one or more target UI elements on a device.
Configurator: Allows you to set key parameters for running UI Automator tests.
7- 很少或不用ListView了
8- Android back stack
https://developer.android.com/guide/topics/manifest/activity-element#lmode
Activity launchMode:
android:launchMode=["standard" | "singleTop" |
"singleTask" | "singleInstance"]
standard/singleTop:默认是standard,每次都会启动一个新的Activity
singleTop:如果该Activity是在Top则不会create新的,而是发送onNewIntent给那个Activity
singleTask/singleInstance:
这里面涉及到一个task的概念,比较麻烦,没有几个人理解是对的,或者说有点过时但系统仍然在用的概念。
我厂的App启动Activity(Splash)使用的是singleTask8- option menu的生命周期
On Android 3.0 and higher, the options menu is considered to always be open when menu items are presented in the app bar. When an event occurs and you want to perform a menu update, you must call invalidateOptionsMenu() to request that the system call onPrepareOptionsMenu().
这儿说因为app bar上面的item也可option menu,因此认为是一直打开着的。要想刷新item则调用 invalidateOptionsMenu(),然后会callback onPrepareOptionsMenu。
另外一个问题:我记得在back stack的时候,onCreateOptionsMenu貌似一直会调用。9- 定义widget 长度高度
values/dimens.xml
<resources>
<dimen name="leftMargin">80dp</dimen>
...
11- 资源国际化的问题https://developer.android.com/guide/topics/resources/localization
internaltionization
res/values-fr/strings.xml
res/layout-de/main.xml
但是当某些缺失时候的优先级问题: 本地化始终优先12- Implicit Intent vs Explicit Intent
Explicit Intent: 明确指出哪个Activity class
Implicit Intent: 让系统/用户根据intent-filter来选择可用的
13- RecyclerView
Adapter/ViewHolder一般用户需要派生
但LayoutManager使用默认的,如果自己来弄一个则是不小的工作量
LinearLayoutManager
StaggeredGridLayoutManager
GridLayoutManager
14- 15- Android Interface Definition Language- AIDL
IPC/RPC
但我真不知道这个怎么使用?如果可以的,岂不是很好的sever/client利器,但显然并不是。16- Fragment
现在的Fragment是androidx下的 androidx.fragment.app.Fragment
而且其Activity必须是 FragmentActivity
的确,默认的FramentTransaction是不会处理Fragment的回退问题的https://stackoverflow.com/questions/7992216/android-fragment-handle-back-button-press
FragmentTransaction tx = fragmentManager.beginTransation();
tx.replace( R.id.fragment, new MyFragment() ).addToBackStack( "tag" ).commit();
在navigation中默认是自带back button。17- Activity的生命周期
默认时候,旋转会重新create所有,包括fragment
可以使用configChange来改变默认的:
<activity
android:name=".MyActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:label="@string/app_name">
如上配置的这些会发送到这个callback中,而不是re-create activity
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
...
}
https://developer.android.com/reference/android/content/res/Configuration
可以看到有这些configuration
18- RemoteViews
https://developer.android.com/reference/android/widget/RemoteViews
用于在另外一个进程显示的UI,比如Notification,可能
https://developer.android.com/guide/topics/ui/shortcuts
Android shortcuts
iOS则有extension: Today/Action
iOS的shortcuts则是另外一个东西;有点类似与deeplink
19- Google play
单个apk文件最多100M,
bundle file: 150M
expansion 文件,1-2个,每个最多2G
https://developer.android.com/google/play/expansion-files
Android app bundle: .aab
https://developer.android.com/guide/app-bundle
Google会用这个 aab文件来产生对应的apk,以此来优化下载的大小等。
Android Foundations: 15/19 
1- Java8的兼容性,当然是只有很少不兼容
2- 关键词 decreasing,降序,这个只是不小心
3- lint的作用:代码的命名格式方面的问题
4- javac 编译成class文件
5- HashSet 实现了Set,Set是接口
6- Gradle的优势:Gradle exposes its Tooling API for embedding and extension(plugins),整体上是描述的事情
7- java里面的interface可以实现多个interfaces
8- Gradle是跑在JVM平台上:JVM-Groovy-Gradle
9- Gradle: DSL
10-
11- anonymous inner class: 没有名字
12-
13- Generic是在编译的时候处理的,而不是在运行的时候,因此没有额外的运行负担,但是在运行的时候存在类型不知道的问题(不是类型不确定,而是不知道)
14- While Integer is subtype of Number, SimpleContainer<Integer> is not a subtype of SimpleContainer<Number>,这种范型不存在继承关系
15- 一个简单的gradle task
task('hello') {
doLast {
println "hello"
}
}
16- Gradle 有一个daemon进程, maven/ant 没有
17- Interface default methods
Java8以前 interface的所有方法都是abstract,只有方法签名;java8提供default method,也就是可以提供实现,这样会省很多代码
方法签名加上 default
18- gradle 依赖的不同方式
https://stackoverflow.com/questions/44493378/whats-the-difference-between-implementation-and-compile-in-gradle
已经没有compile了,用implementation
api: 依赖让使用者确定
一般使用implementation
api: transitive
我的理解是 如果我们依赖X,而X依赖Y;如果是implementation方式,则我们自己无需添加Y,如果是api方式则我们需要自己添加Y。
19-
Swift: 12/19
1-
if let view1 = view1,
let view2 = view2,
view1 is UIButton,
view2 is UIButton {
print("Both views are buttons")
}
2-
3-
4- function parameter labels
func encrypt(plainText: String, secret key: Int, using algorithm: Algorithm) -> Data?
5- Int is 32bits in 32-CPU
6- trailing closure 最后一个参数是block/closure
7- Set 的insert
8- swap方法,swift是静态类型
9- swift可以推断类型
let primes: Set = [2, 3, 5, 7]
for n in primes {
print(n)
}
10- argument labels
func distance(input numbers: [Int], from startIndex: Int = 0, to: Int) -> Int
我觉得to是argument而不是label
11- let 的struct变量是不能修改的, immutable
12- escape function
13- switch
对于枚举,需要包含全部,否则会有exausted 问题
extension State: CustomStringConvertible {
var description: String {
let state: String // 这种使用let是合法的?合法
switch self {
case .open:
state = "Open"
case .closed:
state = "Closed"
case .unknown:
state = "Unknown"
}
return state
}
}
let str: String
str = "Hello, playground" // 合法
str = "Ynot"// 不合法
14-
15-
16- enum associated values
枚举存额外的值
17-
18- CustomStringConvertible 隐式toString
extension Circle: CustomStringConvertible {
public var description: String {
return "Circle center x:\(center.0) y:\(center.1), radius:\(radius)"
}
}
19-
1- xcode 里如果constraints有问题,则那个地方会显示黄色或者红色
另外一个模拟器里面的不同颜色表示不同的情况
2- tab上最多只能有5个3- CollectionView的cell和supplementary都是派生自
UICollectionResuableView
4-
UIAlertController + UIAlertControllerStyleActionSheet
这个是从底下出来的那个
5-https://developer.apple.com/documentation/foundation/nsblockoperation?language=objcThe NSBlockOperation class is a concrete subclass of NSOperation that manages the concurrent execution of one or more blocks. You can use this object to execute several blocks at once without having to create separate operation objects for each.addExecutionBlock6-
Core Animation: Instrument
用于调试draw
7-
Voice Over: Accessibility
8- iOS app icon color space:
sRGB or P3?
9- Dispatch Groups用于同步
并不会说Dispatch sync/async Groups
10- UIGestureRecognizer11-

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

CS 373 Blog 12 Nov 9 — Nov 15

He don’t even know how to write a function.

Serving CSS In Go’s Native Server

Problems 4,1, 2, 3

Need for Domain Driven Design and its advantages

Flutter BLoC for State Management using dio with retrofit

CS371p Spring 2021: Blog Post 6

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
XollXoll

XollXoll

More from Medium

The development prospect and prospect of NFT

Purple Teaming Like a Pro: Overview of Project Part 1

Details About Sealem Lab

Office Hours with Karpf and Loge — the Footnotes