This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'com.android.application' | |
android { | |
compileSdkVersion 22 | |
buildToolsVersion "22.0.1" | |
defaultConfig { | |
applicationId "com.survivingwithandroid.weathertest" | |
minSdkVersion 19 | |
targetSdkVersion 22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.survivingwithandroid.weathertest; | |
import android.support.v7.app.ActionBarActivity; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.view.Menu; | |
import android.view.MenuItem; | |
import com.survivingwithandroid.weather.lib.WeatherClient; | |
import com.survivingwithandroid.weather.lib.client.okhttp.WeatherDefaultClient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2014 Francesco Azzola | |
* Surviving with Android (http://www.survivingwithandroid.com) | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ContactAdapter extends | |
RecyclerView.Adapter<ContactAdapter.ContactViewHolder> { | |
private List<ContactInfo> contactList; | |
public ContactAdapter(List<ContactInfo> contactList) { | |
this.contactList = contactList; | |
} | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ContactViewHolder extends RecyclerView.ViewHolder { | |
protected TextView vName; | |
protected TextView vSurname; | |
protected TextView vEmail; | |
protected TextView vTitle; | |
public ContactViewHolder(View v) { | |
super(v); | |
vName = (TextView) v.findViewById(R.id.txtName); | |
vSurname = (TextView) v.findViewById(R.id.txtSurname); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ContactInfo { | |
protected String name; | |
protected String surname; | |
protected String email; | |
protected static final String NAME_PREFIX = "Name_"; | |
protected static final String SURNAME_PREFIX = "Surname_"; | |
protected static final String EMAIL_PREFIX = "email_"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<android.support.v7.widget.CardView | |
xmlns:card_view="http://schemas.android.com/apk/res-auto" | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/card_view" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
card_view:cardCornerRadius="4dp" | |
android:layout_margin="5dp"> | |
<RelativeLayout | |
android:layout_width="match_parent" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_my); | |
RecyclerView recList = (RecyclerView) findViewById(R.id.cardList); | |
recList.setHasFixedSize(true); | |
LinearLayoutManager llm = new LinearLayoutManager(this); | |
llm.setOrientation(LinearLayoutManager.VERTICAL); | |
recList.setLayoutManager(llm); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:paddingLeft="@dimen/activity_horizontal_margin" | |
android:paddingRight="@dimen/activity_horizontal_margin" | |
android:paddingTop="@dimen/activity_vertical_margin" | |
android:paddingBottom="@dimen/activity_vertical_margin" | |
tools:context=".MyActivity"> | |
<android.support.v7.widget.RecyclerView |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void doRequest() { | |
initClient(); | |
Request req = new Request.Builder() | |
.url(URL) | |
.get() | |
.build(); | |
client.newCall(req).enqueue(new Callback() { | |
@Override |
NewerOlder