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.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.remoteyourcam.usb.GestureDetector;
import com.remoteyourcam.usb.GestureDetector.GestureHandler;
import com.remoteyourcam.usb.PictureView;
import com.remoteyourcam.usb.R;
import com.remoteyourcam.usb.ptp.Camera;
import com.remoteyourcam.usb.ptp.model.LiveViewData;
publicclass PictureFragment extends SessionFragment implements Camera.RetrieveImageListener, GestureHandler {
publicstatic PictureFragment newInstance(int objectHandle) {
Bundle args = new Bundle();
args.putInt("handle", objectHandle);
PictureFragment f = new PictureFragment();
f.setArguments(args);
return f;
}
private Handler handler;
private PictureView pictureView;
privateint objectHandle;
private Bitmap picture;
private GestureDetector gestureDetector;
private ProgressBar progressBar;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
handler = new Handler();
objectHandle = getArguments().getInt("handle");
View view = inflater.inflate(R.layout.picture_frag, container, false);
pictureView = (PictureView) view.findViewById(R.id.image1);
progressBar = (ProgressBar) view.findViewById(R.id.progress);
gestureDetector = new GestureDetector(getActivity(), this);
pictureView.setOnTouchListener(new OnTouchListener() {
@Override
publicboolean onTouch(View v, MotionEvent event) {
gestureDetector.onTouch(event);
return true;
}
});
return view;
}
@Override
publicvoid onStart() {
super.onStart();
getActivity().getActionBar().hide();
if (camera() == null) {
} elseif (picture == null) {
camera().retrieveImage(this, objectHandle);
}
}
@Override
publicvoid onStop() {
super.onStop();
if (isRemoving()) {
getActivity().getActionBar().show();
}
}
@Override
publicvoid enableUi(boolean enabled) {
}
@Override
publicvoid cameraStarted(Camera camera) {
}
@Override
publicvoid cameraStopped(Camera camera) {
}
@Override
publicvoid propertyChanged(int property, int value) {
}
@Override
publicvoid propertyDescChanged(int property, int[] values) {
}
@Override
publicvoid setCaptureBtnText(String text) {
}
@Override
publicvoid focusStarted() {
}
@Override
publicvoid focusEnded(boolean hasFocused) {
}
@Override
publicvoid liveViewStarted() {
}
@Override
publicvoid liveViewStopped() {
}
@Override
publicvoid liveViewData(LiveViewData data) {
}
@Override
publicvoid capturedPictureReceived(int objectHandle, String filename, Bitmap thumbnail, Bitmap bitmap) {
}
@Override
publicvoid objectAdded(int handle, int format) {
}
@Override
publicvoid onImageRetrieved(int objectHandle, final Bitmap image) {
handler.post(new Runnable() {
@Override
publicvoid run() {
if (image == null) {
if (inStart) {
Toast.makeText(getActivity(), getString(R.string.error_loading_image), Toast.LENGTH_LONG)
.show();
}
if (isAdded()) {
getFragmentManager().popBackStack();
}
} else {
progressBar.setVisibility(View.GONE);
pictureView.setPicture(image);
}
}
});
}
@Override
publicvoid onLongTouch(float posx, float posy) {
}
@Override
publicvoid onPinchZoom(float pX, float pY, float distInPixel) {
pictureView.zoomAt(pX, pY, distInPixel);
}
@Override
publicvoid onTouchMove(float dx, float dy) {
pictureView.pan(dx, dy);
}
@Override
publicvoid onFling(float velx, float vely) {
pictureView.fling(velx, vely);
}
@Override
publicvoid onStopFling() {
pictureView.stopFling();
}
}