我有改造的问题.我对这个图书馆很陌生,所以任何帮助都对我意义重大.我正在尝试从应用程序登录到基于本教程制作的服务器(http:// localhost/task_manager/v1/login),并在结果中获取有关用户信息的json.
MainActivity.java
private void requestData() {
String email = "ch@ro.me";
String password = "chrome11";
//retrofit tworzenie polecenia
RestAdapter adapter = new RestAdapter.Builder()
.setEndpoint(ENDPOINT)
.build();
//tworzenie api klasy flowers
UsersAPI api = adapter.create(UsersAPI.class);
api.login(email, password, new Callback < User > () {@
Override
public void failure(final RetrofitError error) {
android.util.Log.i("example", "Error, body: " + error.getBody().toString());
}@
Override
public void success(User user, Response response) {
// Do something with the User object returned
//Log.d("hello", response.toString());
}
}); …Run Code Online (Sandbox Code Playgroud) 我在检查是否使用浓缩咖啡显示吐司时遇到问题。我正在上课:
import android.os.IBinder;
import android.support.test.espresso.Root;
import android.view.WindowManager;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
public class ToastMatcher extends TypeSafeMatcher<Root> {
@Override
public void describeTo(Description description) {
description.appendText("is toast");
}
@Override
public boolean matchesSafely(Root root) {
int type = root.getWindowLayoutParams().get().type;
if ((type == WindowManager.LayoutParams.TYPE_TOAST)) {
IBinder windowToken = root.getDecorView().getWindowToken();
IBinder appToken = root.getDecorView().getApplicationWindowToken();
if (windowToken == appToken) {
// windowToken == appToken means this window isn't contained by any other windows.
// if it was a window for an activity, it would have TYPE_BASE_APPLICATION. …Run Code Online (Sandbox Code Playgroud)