This file contains hidden or 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 OnlineCacheInterceptor implements Interceptor { | |
| @Override | |
| public okhttp3.Response intercept(Chain chain) throws IOException { | |
| okhttp3.Response response = chain.proceed(chain.request()); | |
| CacheControl cacheControl = new CacheControl.Builder() | |
| .maxAge(30, TimeUnit.SECONDS) | |
| .build(); | |
| return response.newBuilder() | |
| .header("Cache-Control", cacheControl.toString()) |
This file contains hidden or 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 OfflineCacheInterceptor implements Interceptor { | |
| private boolean isOnline; | |
| public OfflineCacheInterceptor(boolean isOnline) { | |
| this.isOnline = isOnline; | |
| } | |
| @Override | |
| public okhttp3.Response intercept(Chain chain) throws IOException { |
This file contains hidden or 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 DataDeserializerTest extends BaseDeserializerTest { | |
| private Gson gson; | |
| @Before | |
| public void setUp() { | |
| gson = new GsonBuilder() | |
| .registerTypeAdapter(DataModel.class, new DataDeserializer()) | |
| .create(); | |
| } |
This file contains hidden or 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 interface RowType {} |
This file contains hidden or 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 ImageRowType implements RowType { | |
| private String text; | |
| public ImageRowType(String text) { | |
| this.text = text; | |
| } | |
| public String getText() { | |
| return text; |
This file contains hidden or 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 TextRowType implements RowType { | |
| private String header; | |
| private String text; | |
| public TextRowType(String header, String text) { | |
| this.header = header; | |
| this.text = text; | |
| } |
This file contains hidden or 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 interface RowType { | |
| int BUTTON_ROW_TYPE = 0; | |
| int IMAGE_ROW_TYPE = 1; | |
| int TEXT_ROW_TYPE = 2; | |
| } |
This file contains hidden or 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 MultipleTypesAdapter extends RecyclerView.Adapter { | |
| private List<RowType> dataSet; | |
| public MultipleTypesAdapter(List<RowType> dataSet) { | |
| this.dataSet = dataSet; | |
| } | |
| @Override | |
| public int getItemViewType(int position) { |
This file contains hidden or 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 ViewHolderFactory { | |
| public static class ButtonViewHolder extends RecyclerView.ViewHolder { | |
| public Button button; | |
| public ButtonViewHolder(View itemView) { | |
| super(itemView); | |
| button = (Button) itemView.findViewById(R.id.button); | |
| } |