Long time no Move blog Ah ~ First write a comparison of the basics of it ~ In fact, there are also mentioned in Java, but the use of more in the Android control.
So now to write the first callback:
The first is between the interface ~ In fact, it is quite special ~ this is a more common between activity and activity, it is not particularly stated:
@Override
protected void Onactivityresult (int requestcode, int resultcode, Intent data) {
Super.onactivityresult (Requestcode, ResultCode, data);
}
The second kind:
The callback between the interface and the adapter ~ or so to speak-is to put the control alternative to the time when the original activity needs to be in the parameters of the sub-assembly:
We take adapter as an example:
First 1. Inflace an interface and click events in the class you want to split
Public Inflace Onclickback {
void ();
}
Onclickback Mlistner;
public Message (Onclickback mlistner) {
This.mlistner = Mlistener;
}
Make a setting in the Click event:
if (Mlistener! = null) {
mlistener.void ();
} The
is called this message method at this time in the main interface. At this point can be called to the ~ is not really a difficult way to do:
for the main interface we implement two kinds of methods: and the Click event Implementation method: It can also become this but remember to inherit this method interface:
Then this is the interface and the sub-class callback:
In Android sometimes appear interface (1) call Interface (2) in the Call Interface (3), this time the interface (3) directly return the value to the interface (1) This time is not silly write onresultactivity, this is can ~ but very troublesome ~ if the interface is not activity. What about this time?
Then we also have a way. That's the bus event registration: Compile ' com.squareup:otto:1.3.8 ' for Android studio inherits this phrase. And then in a sub-assembly ~ This is my personal wording.
public class Ottoutil {
Private static final bus bus = new bus ();
public static Bus getinstance () {
return BUS;
}
}
This time to write a tool class ~ This is my own more like to do ~ no trouble to write more code
This time in the third interface to do a registration. Then it is called ottoutil.getinstance (). Resiger (this);(generally called in oncreate)
Remember this time there is a registration must be closed OH ~ ~ ~ so is the anti-ottoutil.getinstance (). Unresiger (this); (usually called in Ondetroy) see the situation to decide:
How to use it ~ In fact, there is no big difference, such as I pass value 1 to interface (1)
Set up a class to place int position: class name Goodjob:
In the interface (3) in the location of the click, or will be a step to write. An assignment is made to the value inside the Goodjob: Ottoutil.getinstace (). Post (Goodjob);
Inside the interface (1)
@Subscribe
public void Good (Goodjob b) {
}
This will make a callback ~ and perform a series of activities:
So here's a look at the issue of live recording:
Some time ago a person encountered this problem, then I helped him to find the problem: the main reason for the other side of the live interface is wider than the height: and our phone's camera problem is proportional, the proportion of the picture for other mobile phone is not the same
The classmate then changed the live recording interface to equal width and so on, resulting in a compression effect. So how do we deal with this at this time? That is to make a proportional conversion adjustment at the time of recording. This seat is in the camera's settings to find. This seat is not much to talk about ~ just mention it:
Then, there will be more and more blog now ~ recently more busy writing time is not so many ~ so you understand ha ~ can also ask questions ~ I will not regularly look at the ~
Android Basics Callback ~ and compression on some live recordings ———— Fox