If you think the Android project remoteyourcam-usb 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 2013 Nils Assbeck, Guersel Ayaz and Michael Zoech
*//www.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.remoteyourcam.usb.view;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.remoteyourcam.usb.R;
publicclass GalleryAdapter extends BaseAdapter {
publicstaticclass ViewHolder {
int objectHandle;
AspectRatioImageView image1;
TextView filename;
TextView dimension;
TextView date;
boolean done;
}
privateint handles[] = newint[0];
privatefinal LayoutInflater inflater;
privateint thumbWidth;
privateint thumbHeight;
privateboolean reversed;
privatefinal GalleryFragment galleryFragment;
public GalleryAdapter(Context context, GalleryFragment galleryFragment) {
this.galleryFragment = galleryFragment;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
publicvoid setHandles(int handles[]) {
this.handles = handles;
notifyDataSetChanged();
}
publicvoid setReverseOrder(boolean reversed) {
if (this.reversed == reversed) {
return;
}
this.reversed = reversed;
notifyDataSetChanged();
}
@Override
publicint getCount() {
return handles.length;
}
publicint getItemHandle(int position) {
return handles[reversed ? handles.length - position - 1 : position];
}
@Override
publicInteger getItem(int position) {
return handles[reversed ? handles.length - position - 1 : position];
}
@Override
publiclong getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
view = inflater.inflate(R.layout.gallery_list_item, parent, false);
ViewHolder holder = new ViewHolder();
view.setTag(holder);
holder.image1 = (AspectRatioImageView) view.findViewById(R.id.image1);
holder.filename = (TextView) view.findViewById(R.id.filename_field);
holder.dimension = (TextView) view.findViewById(R.id.dimension_field);
holder.date = (TextView) view.findViewById(R.id.date_field);
}
ViewHolder holder = (ViewHolder)view.getTag();
holder.image1.setImageBitmap(null);
holder.image1.setExpectedDimensions(thumbWidth, thumbHeight);
holder.objectHandle = getItemHandle(position);
holder.filename.setText("");
holder.dimension.setText("");
holder.date.setText("");
holder.done = false;
galleryFragment.onNewListItemCreated(holder);
return view;
}
publicvoid setThumbDimensions(int width, int height) {
this.thumbWidth = width;
this.thumbHeight = height;
}
}