有幾個問題我有,使用匕首在Android mvp上實現GoogleApiClient?
第一,因爲我讀了一些文章,我應該實現LocationListener的,ConnectionCallback,在活動OnConnectionFailedListener接口,
是不是要單獨實施這些類在不同的文件中?
like below?
public class LocationListener implements
com.google.android.gms.location.LocationListener {
@Inject
Location mLastLocation;
@Override
public void onLocationChanged(Location location) {
// Assign the new location
mLastLocation = location;
// Displaying the new location on UI
}
}
在我的活動中是否正確我處理顯示mLastLocation屬性?
//Fields
@Inject
GoogleApiClient client;
Location mLastLocation;
//Fields
mLastLocation = LocationServices.FusedLocationApi.getLastLocation(client);
秒,我應該如何爲它編寫提供者方法?,我的猜測會是這樣的,你們會推薦什麼?
//Constructor
public LocationModule(Context context, GoogleApiClient.ConnectionCallbacks callback, GoogleApiClient.OnConnectionFailedListener listener) {
this.context = context;
this.callback = callback;
this.listener = listener;
}
@Provides
@Singleton
GoogleApiClient providesGoogleApi() {
return new GoogleApiClient.Builder(context)
.addOnConnectionFailedListener(listener)
.addConnectionCallbacks(callback)
.addApi(LocationServices.API)
.build();
}
最後,我應該在哪裏辦理的Android 6臺及以上設備的權限?,它是在視圖上,還是在演示者?
我聽說View必須如此愚蠢以至於你不需要測試它,我應該如何保持這個原則?
如果任何人都可以給我一個參考,或github示例代碼,這與我的案例相匹配,那將非常棒。