So here you can see my onCreates and
in my onCreate,
I've done most of these tasks.
So first of all my three buttons are my
mSignInButton, mSignOutButton, and
mRevokeButton.
And these I just find them
using findViewById and
passing in the ordered id of the button.
These are objects that I've declared.
Two of them are button and
one of them is one of sign in buttons.
I'm also saying the TextView status,
I'm just, again, sign_in_status
is my TextView, and allocating this
to the local object called mStatus.
So then, for the three buttons, I set
an OnClickListener, and I just set it to
this, so then this class becomes
the callback for OnClickListener.
And then finally, I'm saying, for
my GoogleApiClient, I've defined
a local Google API client here.
If I scroll up,
you can see here where I've defined it.
It's a private GoogleApiClient and
GoogleApiClient.
I've done the same with the buttons and
the textView.
And so now here, I'm just assigning my
GoogleApiClient to the output of this
function, buildApiClient.
I've created that function here, and
this just builds the API client.
It uses the Plus.API
as we had discussed.
And it just does the usual API Client
stuff, adding the ConnectionCallbacks,
adding the OnConnectionFailedListener,
adding the API,
but also adding Scope as we've defined.
So we're going to use the PROFILE Scope
and we do it in this way.
Now we'll build that and then return it.
So now in my onCreate,
I'm going to get a Google API client And
it's going to be built
by this helper function.
And it's going to be one to use
the Plus.API and PROFILE scope.
Pretty straight forward, right?
تستطيع هنا مشاهدة onCreates
وفي onCreate،
انتهيت من معظم هذه المهام.
أولاً، الأزرار الثلاث هيmSignInButton ، mSignOutButton، و
mRevokeButton.
وقد تمكنت من العثور عليها فورًا باستخدام findViewById و
تمرير المعرف المرتب للزر.
هذه هي الكائنات التي أعلنت عنها.
اثنان منها زران
والآخر أحد أزرار تسجيل الدخول.
ومرة أخرى أقول إن حالة TextView
هي sign_in_status
في TextView وأخصص
ذلك للكائن المحلي الذي يسمى mStatus.
لهذه الأزرار الثلاث، قمت بتعيين
OnClickListener، وقمت بتعيينه إلى
هذا، إذًا تصبح هذه الفئة
إعادة استدعاء لـ OnClickListener.
وأخيرًا، أقول
إنني قمت بتعريف عميل Google API
محلي لـ GoogleApiClient هنا.
إذا قمت بالتمرير لأعلى،
فيمكنك هنا مشاهدة المكان الذي قمت بتعريفه فيه.
إنه GoogleApiClient
وGoogleApiClient خاص.
لقد فعلت نفس الشيء مع الأزرار
وtextView.
والآن هنا، أقوم بتعيين
GoogleApiClient إلى مخرجات هذه
الدالة، buildApiClient.
لقد قمت بإنشاء تلك الدالة هنا
وهي تقوم بإنشاء عميل API.
وتستخدم Plus.API
كما سبق مناقشته.
وتقوم بمهام عميل API المعتادة،
مع إضافة ConnectionCallbacks،
إضافة OnConnectionFailedListener،
وإضافة API،
وكذلك إضافة Scope كما قمنا بتعريفه.
سوف نستخدم PROFILE Scope
ونقوم بذلك بهذه الطريقة.
الآن لقد قمنا بإنشائها ثم إرجاعها.
والآن في onCreate،
سوف أحصل على عميل Google API و
أقوم بإنشائه
باستخدام دالة مساعدة.
وسوف يكون واحدًا يستخدم
نطاق Plus.API وPROFILE.
الأمر مباشر وواضح، أليس كذلك؟
Aqui você vê meus onCreates.
No meu onCreate,
fiz a maioria dessas tarefas.
Antes de tudo,
meus 3 botões são:
mSignInButton, mSignOutButton,
e mRevokeButton.
E eu os encontro
usando findViewById
e passando na ID ordenada
do botão.
Estes são objetos
que defini.
Dois deles são botões e o
outro é um dos botões para entrar.
Também estou informando o status TextView,
novamente, sign_in_status
é o meu TextView, e alocando isso
no objeto local chamado mStatus.
Para os 3 botões,
defini um OnClickListener,
apenas defini como "this".
Assim, essa classe se torna
o callback de OnClickListener.
Por fim, estou informando que,
para o meu GoogleApiClient,
defini um cliente
Google API local aqui.
Se eu rolar para cima,
você verá aqui
onde eu o defini.
É um private GoogleApiClient
e mGoogleApiClient.
Fiz o mesmo
com os botões e o TextView.
E aqui estou
atribuindo meu mGoogleApiClient
para a saída da função
buildApiClient.
Criei aquela função aqui,
e ela apenas compila o cliente API.
Ela usa o Plus.API,
como discutimos.
E ela faz as tarefas
normais do cliente API,
adicionando o ConnectionCallbacks,
adicionando o OnConnectionFailedListener,
adicionando a API,
mas ela também adiciona o Scope,
como definimos.
Então, vamos usar o PROFILE
em Scope dessa forma.
Agora compilaremos
e retornaremos.
Agora, no meu onCreate,
obterei um cliente Google API,
que será compilado
por essa função inicial.
Esse cliente usará
o Plus.API e o escopo PROFILE.
Muito simples, certo?
您在这里看到的
是我的 onCreate,
在我的 onCreate 中,
我完成了大部分的任务。
首先,三个按钮分别是
mSignInButton、mSignOutButton 和
mRevokeButton。
我刚刚发现它们都使用
findViewById,
并且按照按钮的排列 ID 进行传递。
这些是我们讲过的对象。
其中两个是按钮,
一个是登录按钮。
我还说到了 TextView 状态,
再说一次,sign_in_status 是 TextView,
我将这一状态分配给
了本地对象 mStatus。
因此,对于这三个按钮,我设置了
OnClickListener,并将其设置为此值,
这样,此类就成为了
OnClickListener 的回调。
最后,我要说的是,对于
我的 GoogleApiClient,我在这里已经定义
了一个本地 Google API 客户端。
如果向上滚动,
将显示对其进行定义的位置。
它是私有 GoogleApiClient 和
GoogleApiClient。
我也对按钮和 textView 执行了
相同的操作。
在这里,我刚刚将我的
GoogleApiClient 分配给此函数
的输出 buildApiClient。
我已在这里创建了该函数,且
这只是构建了 API 客户端。
正如我们先前讨论的那样,它
使用了 Plus.API。
它只是执行了常规 API Client
操作,并添加了 ConnectionCallbacks、
OnConnectionFailedListener
和 API,
还添加了已定义的作用域。
因此,我们将使用 PROFILE 作用域,
我们将按此操作。
现在,我们将构建该作用域并返回它。
在 onCreate 中,
我将获得 Google API 客户端,
并将由此辅助函数
构建它。
它将使用
Plus.API 和 PROFILE 作用域。
很简单,是吧?