ACTIVITY控制所有FRAGMENT,FRAGMENT交互必须通过ACTIVITY。尽量减少IO数据库读写,减少NEW生成函数的使用,可以使性能更优化。信息都在ACTIVITY层做管理。
更新页面操作:ACTIVITY把数据传给FRAGMENT,FRAGMENT接收新数据,叫ADAPTER更新数据,ADAPTER不同于GOOGLE推荐方法,但性能要高于GOOGLE推荐方法。
ACTIVITY控制所有FRAGMENT,FRAGMENT交互必须通过ACTIVITY。尽量减少IO数据库读写,减少NEW生成函数的使用,可以使性能更优化。信息都在ACTIVITY层做管理。
更新页面操作:ACTIVITY把数据传给FRAGMENT,FRAGMENT接收新数据,叫ADAPTER更新数据,ADAPTER不同于GOOGLE推荐方法,但性能要高于GOOGLE推荐方法。
Switch between tabs:
alt + left or right arrow
Last edit location:
This is a variation on the “Navigate Back” shortcut that cycles between the locations where you typed something.
Picture yourself fixing a nasty bug. You think you have the solution so you start fixing it but then realize that you have to look at the android source code and a couple other classes in your project. You enter a function, which leads you to another class, which leads you to another thing and 20 steps later, you finally have the insight needed to complete your fix… but in which file and at what line where you again? Just use this shortcut and you are right back at the exact line where you stopped writing.
It deletes the current line or selection.
Navigate to highlighted syntax errors => F2/Shift+F2
This is doing more than simulating the delete key at the end of the line! It will preserve formatting rules and it will also:
Selet the method name, right click, find usage.
Firstly import your sound files into your project.
then write following code into AppDelegate.swift. note to repeat your your music, add audioPlayer.numberOfLoops=-1;
import UIKit
import AVFoundation
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var audioPlayer = AVAudioPlayer()
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
var alertSound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource(“bgmusic”, ofType: “mp3”)!)
println(alertSound)
var error:NSError?
audioPlayer = AVAudioPlayer(contentsOfURL: alertSound, error: &error)
audioPlayer.prepareToPlay()
audioPlayer.play()
return true
}
By now, you have probably heard about the digital exposure, so to speak, of nude photos of as many as 100 celebrities, taken from their Apple iCloud backups and posted to the “b” forum on 4Chan. Over the last day, an alleged perpetrator has been exposed by redditors, although the man has declared his innocence. The mainstream media have leapt on the story and have gotten reactions from affected celebrities including Oscar winner Jennifer Lawrence and model Kate Upton.
Someone claiming to be the individual responsible for the breach has used 4Chan to offer explicit videos from Lawrence’s phone, as well as more than 60 nude “selfies” of the actress. In fact, it seems multiple “b-tards” claimed they had access to the images, with one providing a Hotmail address associated with a PayPal account, and another seeking contributions to a Bitcoin wallet. Word of the images launched a cascade of Google searches and set Twitter trending. As a result, 4Chan/b/ — the birthplace of Anonymous — has opened its characteristically hostile arms to a wave of curious onlookers hoping to catch a glimpse of their favourite starlets’ naked bodies. Happy Labour Day!
This breach is different from other recent celebrity “hacks” in that it used a near-zero-day vulnerability in an Apple cloud interface. Instead of using social engineering or some low-tech research to gain control of the victims’ cloud accounts, the attacker basically bashed in the front door — and Apple didn’t find out until the attack was over. While an unusual, long, convoluted password may have prevented the attack from being successful, the only real defence against this assault was never to put photos in Apple’s cloud in the first place. Even Apple’s two-factor authentication would not have helped.
iBrute iForce iHack
The breach of the celebrities’ iCloud accounts was reportedly made possible by a vulnerability in Apple’s Find My iPhone application programming interface — at least, that’s what has been suggested. Proof-of-concept code for the exploit, called iBrute, allowed for brute-force password cracking of accounts. It was uploaded to GitHub on August 30, just a day before the breach occurred, as ZDNet’s Adrian Kingsley-Hughes noted. Apple patched the vulnerability early on September 1.
All the brute force attack did was test combinations of e-mail addresses and passwords from two separate “dictionary” files. It required knowledge (or good guesses) of the targets’ iCloud account e-mail addresses and a huge list of potential passwords. Because of this weakness, the Find My iPhone service did not lock out access to the account after a number of failed attempts — so the attacker was able to keep hammering away at targeted accounts until access was granted. Once successful, the attacker could then connect to iCloud and retrieve iPhone backups, images from the iOS Camera Roll, and other data.
iCloud’s history of abuse
Apple’s iCloud security has been bruised and broken before, though most of the past attacks have been based on social engineering and use of publicly available information about the victims. Christina Aguilera, Scarlett Johansson, and other celebrities were hacked in 2011 by a Florida man who essentially guessed passwords or recovered them using personal details. He then set up forwarding addresses in their e-mail accounts to an account he controlled — allowing him to answer security confirmation e-mails and take control of their devices.
And then there’s the story of what happened to Wired’s Mat Honan in 2012: a “hacker” was able to get access to the last four digits of his credit card number from Amazon and, using that information, gained access to his Gmail account. The attacker then called Apple’s tech support and convinced Apple that he was Honan, getting the password on his account reset.
Caveat selfor
Given how much of what is on smartphones is now automatically backed up to the cloud, anyone should take pause before disrobing before their smartphone camera — regardless of the phone operating system or how that image will be delivered to its intended audience. The security of all of these services is only as secure as the obscurity of the mother’s maiden name of the person you sent that picture to — or of the next zero-day flaw.
Apple’s iOS backs up your photos to iCloud by default if you configure an account. Android’s backup does the same, and Google Plus, Yahoo Flickr, and many other services offer to automatically sync your images to the cloud. Even if you don’t set one of these up for syncing, you never know what the person you send the picture to will do with them. Even “ephemeral” messaging applications like SnapChat, Glimpse, Wickr and the like don’t block people taking screen captures of the image — and if image recipients are using an iPhone, those might automatically get synced to their cloud.
If it’s in the cloud — a public, free cloud service, especially — then chances are good that eventually it will find its way to the Internet. Cloud services are leaky by their nature; things that are supposed to be private get stored alongside things that are shared, and anything from user error to a previously undiscovered vulnerability can make even strong passwords pointless, while exposing all of those things to the world.
And what happens when a cloud store gets breached? If the one doing the breaching is never caught, the answer is “not much” — because the cloud providers are generally covered from the victims’ wrath by terms of service.
In a conversation I had on Twitter this morning with Tal Klein, the vice president of strategy for the cloud security firm Adallom, Klein said there were two things to take away from this latest breach: “1. Don’t take pictures of your junk; it will end up on the Internet somehow at some point. 2. Not all security is equal. And all vendors are mostly indemnified. So use the cloud because it’s great, but be cognisant of accountability.”
Or, as Ricky Gervais tweeted (and then deleted): “Celebrities, make it harder for hackers to get nude pics of you from your computer by not putting nude pics of yourself on your computer.” It’s not that it’s celebrities’ fault for being hacked; it’s just that they should arm themselves with the knowledge that the cloud is fundamentally insecure in the future.
Callback function for login, delegate to different view based on different roles.
When customer register, no need for password. Device id will be auto becoming the password. When passing into http, data will be encrypted. This encryption can be reversed into reader data at server. For password, it will encryped by SHA4 and stored in database, the password encryption is inversable, which means even the company’s server breaks, there is no way to read the real password.
I just filed a bug report with Apple on this same issue. The default Launch Screen template includes your app’s name as a label and if that name has an ampersand it invalidates the XML. You can fix this by opening your Launch Screen in a text editor (right click on it in Xcode and select “Open with External Editor” and then doing a Find & Replace for & with &.
lomeal is the main interface package. other packages are the library to support lomeal.

package api encapsulates apis allows app talking to the server.
factory package use factory design pattern to generate new classes
gson package contains database apis using gson
model package contains the data base models. data are exchanged by gson. use annotation @DatabaseField @SerializedName and keyword transient to talk to database. gson it’s like hibernate. object-to database. no need write direct sql as it’s hard to maintain.
service package contain two main servcies. direct service and ServiceTask.java. service runs in one process and multiple threads
ulti package contains utility suppport classes
| Action | Mac OSX | Win/Linux |
|---|---|---|
| 注释代码(//) | Cmd + / | Ctrl + / |
| 注释代码(/**/) | Cmd + Option + / | Ctrl + Shift + / |
| 格式化代码 | Cmd + Option + L | Ctrl + Alt + L |
| 清除无效包引用 | Option + Control + O | Alt + Ctrl + O |
| 查找 | Cmd + F | Ctrl + F |
| 查找+替换 | Cmd + R | Ctrl + R |
| 上下移动代码 | Option + Shift + Up/Down | Alt + Shift + Up/Down |
| 删除行 | Cmd + Delete | Ctrl + Y |
| 扩大缩小选中范围 | Option + Up/Down | Ctrl + W/Ctrl + Shift + W |
| 快捷生成结构体 | Cmd + Option + T | Ctrl + Alt + T |
| 快捷覆写方法 | Cmd + O | Ctrl + O |
| 快捷定位到行首/尾 | Cmd + Left/Right | Ctrl + Left/Right |
| 折叠展开代码块 | Cmd + Plus,Minus | Ctrl + Plus/Minus |
| 折叠展开全部代码块 | Cmd + Shift + Plus,Minus | Ctrl + Shift + Plus,Minus |
| 文件方法结构 | Cmd + F12 | Ctrl + F12 |
| 查找调用的位置 | Ctrl + Option + H | Ctrl + Alt + H |
| 大小写转换 | Cmd + Shift + U | Ctrl + Shift + U |
(PS: 以上快捷键没有在win平台尝试确认,欢迎反馈错误与补充)
最后再介绍一个最有用的设置,我们只有每次引用一些类的时候必须要导包,而Studio可以通过设置自动导包,简直太实用了.
到 Preferences -> Editor -> Auto Import -> Java 把以下选项勾上就OK了
1.应该先学知识点吗?
个人经验表明,学编程,最开始拿一个月先学知识点或者只学知识点,基本就等于没学。于是你发现你很 努力的看了一个月的书,还是什么都不会写,或者写出来了一坨bug都不知道怎么改,终于你放弃治疗了。当然,骨骼清奇的可能21天精通C++,然后妈妈再 也不用担心他的编程了。人跟人的情况不一样,所以这里不是绝对的,但是我觉得对楼主的情况还是比较符合的。
2.不看书那应该先写代码?
你发现,你不看书,完了直接写代码又什么都不会,于是你表示要先学代码,完了你又懵了,先学代码怎么学?很多人又跑去看书了。。额,接下来发生了什么,这里参见第一条。
3.书是干什么用的?
我觉得书更多的时候就是参考文档,就Android来说,谁最懂Android?当然是谷歌,那么问题来了,参考文档哪家强?不找官方文档你还要去找蓝翔么?https://developer.android.com/guide/index.html
至于其他的中文书,我觉得很多都夹杂了个人的见解,初学者慎入,不然很容易接触不到原汁原味的理念和思想。如果觉得英文的官方文档很蛋疼,看看翻译过来的中文版也可以。
4.不看书也不先写代码难道要去山东找蓝翔吗?
如果你发现你学了一个月,看了一个月的书,还是什么都不会,那接下来你要么放弃治疗,要么吃口药开始从别人的代码读起来啊。那么问题来了?别人的代码哪家强?不找官方的demo你还要去山东找蓝翔么?android.com 的页面
当然以上我提到的所有界面你如果不翻墙,可能都打不开,看着一坨无法连接可能你还会有一种要去山东找蓝翔的赶脚,不过不用怕, GitHub · Build software better, together.你值得拥有。
其实这里说的就是题主说的,在应用中学习,但是在应用中学习的方式也是有区别的。
5.读别人的代码应该怎么读?
如何读别人的代码我写过一篇自我体会的博客,如何阅读别人的代码,自知水平一般,大神就不用点了。
6.读别人的Android代码应该怎么读?
注意千万别上来就一个一个文件地通读,相信我,其实不用相信我你也会发现根本读不明白的。什么?读当然要读明白才有用啊?废话,你丫直接通读就能读明白了还读他干啥。
其实读什么代码都先得搞明白数据的走向,具体到Android身上,他是有MVC层的。
View层在Android里其实就是传说中让无数开发人员蛋疼菊紧,闻风色变的UI适配,具体讲就是res/layout/.xml那堆东西。
Model跟Controller层就是.java了。这个分的不是很清楚,你可以自己作区分。
说通俗点你要懂得:
前端的一个数据用户输入进去,你要在后台如何获取到。
你后台的一个数据,如果反馈给前端。
做到这你会了点毛?你发现你毛都不会,但是这个时候其实你已经知道部分Android的文件夹之间是干什么的,之间是如何协作的。
什么?你说你还是没看懂啊,在心里问自己bin文件夹里是啥?res/layout以外的文件夹是啥?
大声的对自己吼一句:劳资怎么知道,我又没用到那呢。
不要再问搞不明白怎么往下学了?你刚开始的时候知道res/layout是干什么的吗?那现在呢?
7.为毛要读别人的代码?
写代码的最终目的是执行,所以你从一个能执行的程序开始,能很快的验证自己的学习到底对不对。
什么?你问我怎么验证?你改了以后他成功跑出了结果就说明你学的是对的啊。跑错了显然就是错的。
别人的代码好处就在于他都写好了,虽然你毛都看不懂。但是他能顺畅地跑起来。当然,除了用了你的电脑编译器编译了下,再用了你的手机安装呈现了以下,现在这事跟你半毛钱关系都没有。
但是你可以输出啊亲,这时候你必须给自己壮壮士气:“尼玛劳资虽然还不会Android,但是改个String值还是会的。” 所以你成功的将前台textView里的“A”改成了“B”。虽然你完全不知道发生了什么。但其实你已经知道数据输出到前台的最后一步是什么了。
搞到这,你可以装逼点说自己已经入门了。虽然你还是不懂别人的那坨代码。但是你已经潜意识地把代码细化到了某个点上开始逐个突破了。
8.读到什么时候能学会?
读啊,接着读,再接下来呢?接下来就是按需学习了啊。
比如你想加个按钮,你就可以搜一下Android button的东西看一看,然后发现了xml里的<button />和java里的findViewById,setOnclickListener().
比如你想向用户显示一些帮助/提示.于是你发现了Toast这个玩意。
什么?别人问你什么是Service,告诉他:“劳资不是不会Android,劳资压根没用到过那东西,要学的东西这么多,我现在还用不着先学他干啥。”
比如你….
若干个比如以后你发现,我凑,劳资当年改String值的时候怎么会觉得findViewById这个鬼函数这么难。
再若干个比如以后你发现,尼玛,劳资什么时候学会的Android?
——————————————————————-
以上。
——————————————————————-
补充:
9.java设计模式应该学好么?
有人问,java设计模式应该学好么。稍微聊聊我的感受吧。
首先,我也是个入坑不久的新手,纯属个人感受,欢迎参考交流指教,大神勿喷。
我最开始写代码的时候,听说过一个词叫做代码风格。
后来又听到了一个词叫设计模式。
我当时的感受你造吗?!设计模式,虽然不知道是啥,但是好高大上的赶脚!
就好像一个不懂但想学代码的家伙突然听到身边的人淡定地说了句,
“你printf出来看看结果”一样,恨不得跪下来求他收我为徒吧思密达!
于是跑去看了看书,于是还有模有样的学了几个设计模式,但是后来我突然有了一种感觉:
这什么时候用?
尼玛这又什么时候用?
诶我凑这到底该什么时候用?
看到最后产生了一种程序猿不适合我,要去山东蓝翔学挖掘机谋生的冲动。
最终放弃了。
后来?
后来我开始写一些代码。
后来我越来越觉得不顺手,越来越觉得自己的代码写的像一坨翔。
于是我头疼如何能更好的组织代码结构的时候,我发现,尼玛MVC模式还有点意思啊。
于是我头疼如何在不同的地方调用同一个类却执行不同的方法内容时,我发现,尼玛回调原来这么好用。
于是我突然发现,原来设计模式还有点意思啊,劳资看来不用去山东找蓝翔了23333333.
其实,我认为,
没有用到的时候你是无法确认他是不是好的,就算大家都说他很好,你没用到也体会不到,既然体会不到,那你就无法确定学了它该如何正确的使用,用了有什么好处,不用会有什么后果,所以我觉得,
当你发现你的代码再写下去就要成一坨翔的时候,才是该反思去学的时候。
当然,这样的试错成本也是很高的。我当然也因此肉痛过。至于如何低成本的学习,额,多写代码吧。
以上。