Search in sources :

Example 41 with SimpleDraweeView

use of com.facebook.drawee.view.SimpleDraweeView in project Rocket.Chat.Android by RocketChat.

the class RocketChatMessageAttachmentsLayout method showReferenceAttachment.

private void showReferenceAttachment(Attachment attachment, View attachmentView) {
    final View refBox = attachmentView.findViewById(R.id.ref_box);
    if (attachment.getThumbUrl() == null && attachment.getText() == null) {
        refBox.setVisibility(GONE);
        return;
    }
    refBox.setVisibility(VISIBLE);
    final SimpleDraweeView thumbImage = (SimpleDraweeView) refBox.findViewById(R.id.thumb);
    final String thumbUrl = attachment.getThumbUrl();
    if (TextUtils.isEmpty(thumbUrl)) {
        thumbImage.setVisibility(GONE);
    } else {
        thumbImage.setVisibility(VISIBLE);
        FrescoHelper.setupDraweeAndLoadImage(absolutize(thumbUrl), thumbImage);
    }
    final TextView refText = (TextView) refBox.findViewById(R.id.text);
    final String refString = attachment.getText();
    if (TextUtils.isEmpty(refString)) {
        refText.setVisibility(GONE);
    } else {
        refText.setVisibility(VISIBLE);
        refText.setText(refString);
    }
}
Also used : SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) TextView(android.widget.TextView) TextView(android.widget.TextView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View)

Example 42 with SimpleDraweeView

use of com.facebook.drawee.view.SimpleDraweeView in project Rocket.Chat.Android by RocketChat.

the class RocketChatMessageUrlsLayout method addMessageInlineImage.

private void addMessageInlineImage(WebContent webContent, boolean autoloadImages, String url) {
    final WebContentHeaders webContentHeaders = webContent.getHeaders();
    String contentType = webContentHeaders != null ? webContentHeaders.getContentType() : "";
    if (contentType != null && contentType.startsWith("image/") && ImageFormat.SUPPORTED_LIST.contains(contentType)) {
        final View inlineImageView = inflater.inflate(R.layout.message_inline_image, this, false);
        final SimpleDraweeView inlineImage = (SimpleDraweeView) inlineImageView.findViewById(R.id.message_inline_image);
        final View loadView = inlineImageView.findViewById(R.id.message_inline_image_load);
        loadImage(url, inlineImage, loadView, autoloadImages);
        addView(inlineImageView);
    }
}
Also used : SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) WebContentHeaders(chat.rocket.core.models.WebContentHeaders) TextView(android.widget.TextView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View)

Example 43 with SimpleDraweeView

use of com.facebook.drawee.view.SimpleDraweeView in project apps-android-commons by commons-app.

the class ShareActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    uploadController = new UploadController();
    setContentView(R.layout.activity_share);
    ButterKnife.bind(this);
    initBack();
    app = CommonsApplication.getInstance();
    backgroundImageView = (SimpleDraweeView) findViewById(R.id.backgroundImage);
    backgroundImageView.setHierarchy(GenericDraweeHierarchyBuilder.newInstance(getResources()).setPlaceholderImage(VectorDrawableCompat.create(getResources(), R.drawable.ic_image_black_24dp, getTheme())).setFailureImage(VectorDrawableCompat.create(getResources(), R.drawable.ic_error_outline_black_24dp, getTheme())).build());
    //Receive intent from ContributionController.java when user selects picture to upload
    Intent intent = getIntent();
    if (intent.getAction().equals(Intent.ACTION_SEND)) {
        mediaUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
        if (intent.hasExtra(UploadService.EXTRA_SOURCE)) {
            source = intent.getStringExtra(UploadService.EXTRA_SOURCE);
        } else {
            source = Contribution.SOURCE_EXTERNAL;
        }
        mimeType = intent.getType();
    }
    if (mediaUri != null) {
        mediaUriString = mediaUri.toString();
        backgroundImageView.setImageURI(mediaUriString);
        //Test SHA1 of image to see if it matches SHA1 of a file on Commons
        try {
            InputStream inputStream = getContentResolver().openInputStream(mediaUri);
            Timber.d("Input stream created from %s", mediaUriString);
            String fileSHA1 = Utils.getSHA1(inputStream);
            Timber.d("File SHA1 is: %s", fileSHA1);
            ExistingFileAsync fileAsyncTask = new ExistingFileAsync(fileSHA1, this);
            fileAsyncTask.execute();
        } catch (IOException e) {
            Timber.d(e, "IO Exception: ");
        }
    }
    if (savedInstanceState != null) {
        contribution = savedInstanceState.getParcelable("contribution");
    }
    requestAuthToken();
    Timber.d("Uri: %s", mediaUriString);
    Timber.d("Ext storage dir: %s", Environment.getExternalStorageDirectory());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        useNewPermissions = true;
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
            storagePermission = true;
        }
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
            locationPermission = true;
        }
    }
    // Check storage permissions if marshmallow or newer
    if (useNewPermissions && (!storagePermission || !locationPermission)) {
        if (!storagePermission && !locationPermission) {
            String permissionRationales = getResources().getString(R.string.storage_permission_rationale) + "\n" + getResources().getString(R.string.location_permission_rationale);
            snackbar = Snackbar.make(findViewById(android.R.id.content), permissionRationales, Snackbar.LENGTH_INDEFINITE).setAction(R.string.ok, new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    ActivityCompat.requestPermissions(ShareActivity.this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION }, 3);
                }
            });
            snackbar.show();
            View snackbarView = snackbar.getView();
            TextView textView = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text);
            textView.setMaxLines(3);
        } else if (!storagePermission) {
            Snackbar.make(findViewById(android.R.id.content), R.string.storage_permission_rationale, Snackbar.LENGTH_INDEFINITE).setAction(R.string.ok, new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    ActivityCompat.requestPermissions(ShareActivity.this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, 1);
                }
            }).show();
        } else if (!locationPermission) {
            Snackbar.make(findViewById(android.R.id.content), R.string.location_permission_rationale, Snackbar.LENGTH_INDEFINITE).setAction(R.string.ok, new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    ActivityCompat.requestPermissions(ShareActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, 2);
                }
            }).show();
        }
    } else if (useNewPermissions && storagePermission && !locationPermission) {
        getFileMetadata(true);
    } else if (!useNewPermissions || (storagePermission && locationPermission)) {
        getFileMetadata(true);
    }
}
Also used : InputStream(java.io.InputStream) Intent(android.content.Intent) TextView(android.widget.TextView) IOException(java.io.IOException) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) TextView(android.widget.TextView)

Example 44 with SimpleDraweeView

use of com.facebook.drawee.view.SimpleDraweeView in project BestPracticeApp by pop1234o.

the class MainActivity method loadImageByFresco.

/**
 * ================================
 * 源码解析:https://www.jianshu.com/p/265c628a0d59
 * 内部网络层用的HttpUrlConnection,当然你可以自己配置成Okhttp
 * 整个fresco结构类似于MVC
 * DraweeView,负责显示加载好的图片,相当于V
 * DraweeHierarchy,组织和维护Drawable对象(封装了Drawable)相当于M
 * DraweeController,负责和image loader(就是image pipeline)交互来加载图片,相当于C
 * ----------------------
 * 里面使用了Builder模式,策略模式,
 *
 * @param url
 * @param imageView
 */
private void loadImageByFresco(String url, ImageView imageView) {
    // 流程图
    getResources().getDrawable(R.drawable.fresco);
    Uri uri = Uri.parse(url);
    SimpleDraweeView draweeView = (SimpleDraweeView) findViewById(R.id.my_image_view);
    // 下载gif或者webp后自动播放
    // DraweeController controller = Fresco.newDraweeControllerBuilder()
    // .setUri(uri)
    // .setAutoPlayAnimations(true) .build();
    // draweeView.setController(controller);
    // 代码中使用Drawees
    /*   GenericDraweeHierarchyBuilder builder =
                new GenericDraweeHierarchyBuilder(getResources());
        GenericDraweeHierarchy hierarchy = builder
                .setFadeDuration(300)
                .setPlaceholderImage(R.mipmap.ic_launcher_round)
                .build();
        draweeView.setHierarchy(hierarchy);*/
    draweeView.setImageURI(uri);
}
Also used : SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) Uri(android.net.Uri)

Example 45 with SimpleDraweeView

use of com.facebook.drawee.view.SimpleDraweeView in project lzc_app_lib by httplzc.

the class VideoPlayer method setThumbImg.

public void setThumbImg(Uri uri, int width, int height) {
    SimpleDraweeView simpleDraweeView = (SimpleDraweeView) thumbImageView;
    FunUntil.loadImg(width, height, simpleDraweeView, uri);
}
Also used : SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView)

Aggregations

SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)58 View (android.view.View)30 TextView (android.widget.TextView)20 Uri (android.net.Uri)8 DraweeController (com.facebook.drawee.interfaces.DraweeController)8 Intent (android.content.Intent)6 ImageView (android.widget.ImageView)5 RecyclerView (android.support.v7.widget.RecyclerView)4 Button (android.widget.Button)4 TintImageView (com.bilibili.magicasakura.widgets.TintImageView)4 RoundingParams (com.facebook.drawee.generic.RoundingParams)4 Animatable (android.graphics.drawable.Animatable)3 ViewGroup (android.view.ViewGroup)3 AdapterView (android.widget.AdapterView)3 CompoundButton (android.widget.CompoundButton)3 LinearLayout (android.widget.LinearLayout)3 SwitchCompat (androidx.appcompat.widget.SwitchCompat)3 BaseControllerListener (com.facebook.drawee.controller.BaseControllerListener)3 ControllerListener (com.facebook.drawee.controller.ControllerListener)3 ProgressBarDrawable (com.facebook.drawee.drawable.ProgressBarDrawable)3