blob: d44861b7fc79d036c1331b8a7d852f4ee883ede8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
package com.mapswithme.maps.base;
import android.content.Intent;
import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.mapswithme.maps.auth.Authorizer;
import com.mapswithme.maps.auth.TargetFragmentCallback;
/**
* A base toolbar fragment which is responsible for the <b>authorization flow</b>,
* starting from the getting an auth token from a social network and passing it to the core
* to get user authorized for the MapsMe server (Passport).
*/
public abstract class BaseToolbarAuthFragment extends BaseMwmToolbarFragment
implements Authorizer.Callback, TargetFragmentCallback
{
@NonNull
private final Authorizer mAuthorizer = new Authorizer(this);
protected void authorize()
{
mAuthorizer.authorize();
}
@Override
@CallSuper
public void onStart()
{
super.onStart();
mAuthorizer.attach(this);
}
@Override
@CallSuper
public void onStop()
{
super.onStop();
mAuthorizer.detach();
}
@Override
public void onTargetFragmentResult(int resultCode, @Nullable Intent data)
{
mAuthorizer.onTargetFragmentResult(resultCode, data);
}
@Override
public boolean isTargetAdded()
{
return isAdded();
}
protected boolean isAuthorized()
{
return mAuthorizer.isAuthorized();
}
}
|