/*
* Copyright (C) 2015 Taeho Kim <jyte82@gmail.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.androidhuman.zoomablesample;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.drawable.ProgressBarDrawable;
import com.facebook.drawee.drawable.ScalingUtils;
import com.facebook.drawee.generic.GenericDraweeHierarchy;
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
import com.facebook.drawee.interfaces.DraweeController;
import com.facebook.samples.zoomable.ZoomableDraweeView;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
public class ZoomableActivity extends AppCompatActivity {
public static final String KEY_TITLE = "title";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Uri data = getIntent().getData();
if (null == data) {
throw new IllegalArgumentException("No data to display");
}
String title = getIntent().getStringExtra(KEY_TITLE);
if (title != null) {
setTitle(title);
}
Fresco.initialize(this);
setContentView(R.layout.activity_zoomable);
ZoomableDraweeView view = (ZoomableDraweeView) findViewById(R.id.zoomable);
DraweeController ctrl = Fresco.newDraweeControllerBuilder().setUri(
data).setTapToRetryEnabled(true).build();
GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources())
.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
.setProgressBarImage(new ProgressBarDrawable())
.build();
view.setController(ctrl);
view.setHierarchy(hierarchy);
}
@Override
protected void onDestroy() {
super.onDestroy();
Fresco.shutDown();
}
}