If you think the Android project encrypted-camera listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Copyright (C) 2013 Jake Wharton//fromwww.java2s.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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.andrewreitz.encryptedcamera.ui.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
/** From https://github.com/JakeWharton/u2020/blob/master/src/main/java/com/jakewharton/u2020/ui/misc/BindableAdapter.java *//** An implementation of {@link android.widget.BaseAdapter} which uses the new/bind pattern for its views. */publicabstractclass BindableAdapter<T> extends BaseAdapter {
privatefinal Context context;
privatefinal LayoutInflater inflater;
public BindableAdapter(Context context) {
this.context = context;
this.inflater = LayoutInflater.from(context);
}
public Context getContext() {
return context;
}
@Override publicabstract T getItem(int position);
@Override publicfinal View getView(int position, View view, ViewGroup container) {
if (view == null) {
view = newView(inflater, position, container);
if (view == null) {
thrownew IllegalStateException("newView result must not be null.");
}
}
bindView(getItem(position), position, view);
return view;
}
/** Create a new instance of a view for the specified position. */publicabstract View newView(LayoutInflater inflater, int position, ViewGroup container);
/** Bind the data for the specified {@code position} to the view. */publicabstractvoid bindView(T item, int position, View view);
@Override publicfinal View getDropDownView(int position, View view, ViewGroup container) {
if (view == null) {
view = newDropDownView(inflater, position, container);
if (view == null) {
thrownew IllegalStateException("newDropDownView result must not be null.");
}
}
bindDropDownView(getItem(position), position, view);
return view;
}
/** Create a new instance of a drop-down view for the specified position. */public View newDropDownView(LayoutInflater inflater, int position, ViewGroup container) {
return newView(inflater, position, container);
}
/** Bind the data for the specified {@code position} to the drop-down view. */publicvoid bindDropDownView(T item, int position, View view) {
bindView(item, position, view);
}
}