Search in sources :

Example 1 with SimpleDraweeView

use of com.facebook.drawee.view.SimpleDraweeView in project remusic by aa112901.

the class RadioDetailActivity method setHeaderView.

private void setHeaderView() {
    albumArt = (ImageView) findViewById(R.id.album_art);
    albumTitle = (TextView) findViewById(R.id.album_title);
    albumArtSmall = (SimpleDraweeView) findViewById(R.id.playlist_art);
    LinearLayout downAll = (LinearLayout) headerViewContent.findViewById(R.id.playlist_down);
    downAll.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            new AlertDialog.Builder(RadioDetailActivity.this).setTitle("要下载音乐吗").setPositiveButton(RadioDetailActivity.this.getString(R.string.sure), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    int len = mList.size();
                    for (int i = 0; i < len; i++) {
                        Down.downMusic(MainApplication.context, mList.get(i).getSong_id(), mList.get(i).getSong_name(), artistName);
                    }
                    dialog.dismiss();
                }
            }).setNegativeButton(RadioDetailActivity.this.getString(R.string.cancel), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).show();
        }
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) ImageView(android.widget.ImageView) ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) TextView(android.widget.TextView) TintImageView(com.bilibili.magicasakura.widgets.TintImageView) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayout(android.widget.LinearLayout)

Example 2 with SimpleDraweeView

use of com.facebook.drawee.view.SimpleDraweeView in project BigImageViewer by Piasy.

the class FrescoImageLoader method showThumbnail.

@Override
public View showThumbnail(BigImageView parent, Uri thumbnail, int scaleType) {
    SimpleDraweeView thumbnailView = (SimpleDraweeView) LayoutInflater.from(parent.getContext()).inflate(R.layout.ui_fresco_thumbnail, parent, false);
    DraweeController controller = Fresco.newDraweeControllerBuilder().setUri(thumbnail).build();
    switch(scaleType) {
        case BigImageView.INIT_SCALE_TYPE_CENTER_CROP:
            thumbnailView.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP);
            break;
        case BigImageView.INIT_SCALE_TYPE_CENTER_INSIDE:
            thumbnailView.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.CENTER_INSIDE);
        default:
            break;
    }
    thumbnailView.setController(controller);
    return thumbnailView;
}
Also used : SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) DraweeController(com.facebook.drawee.interfaces.DraweeController)

Example 3 with SimpleDraweeView

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

the class RocketChatMessageUrlsLayout method appendUrlView.

private void appendUrlView(WebContent webContent, boolean autoloadImages) {
    final String url = webContent.getUrl();
    addMessageInlineImage(webContent, autoloadImages, url);
    // see Rocket.Chat:packages/rocketchat-oembed/client/oembedUrlWidget.coffee
    final Map<WebContentMeta.Type, WebContentMeta> webContentMetaMap = webContent.getMetaMap();
    if (webContentMetaMap == null || webContentMetaMap.size() == 0) {
        return;
    }
    final String imageURL = webContent.getMetaImage();
    WebContentParsedUrl parsedUrl = webContent.getParsedUrl();
    String host = parsedUrl != null ? parsedUrl.getHost() : null;
    View embedUrl = inflater.inflate(R.layout.message_inline_embed_url, this, false);
    ((TextView) embedUrl.findViewById(R.id.hostname)).setText(host);
    ((TextView) embedUrl.findViewById(R.id.title)).setText(webContent.getMetaTitle());
    ((TextView) embedUrl.findViewById(R.id.description)).setText(removeQuote(webContent.getMetaDescription()));
    final SimpleDraweeView image = (SimpleDraweeView) embedUrl.findViewById(R.id.image);
    if (TextUtils.isEmpty(imageURL)) {
        image.setVisibility(View.GONE);
    } else {
        FrescoHelper.setupDraweeAndLoadImage(imageURL, image);
        image.setVisibility(View.VISIBLE);
    }
    embedUrl.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            getContext().startActivity(intent);
        }
    });
    addView(embedUrl);
}
Also used : SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) WebContentParsedUrl(chat.rocket.core.models.WebContentParsedUrl) TextView(android.widget.TextView) Intent(android.content.Intent) WebContentMeta(chat.rocket.core.models.WebContentMeta) TextView(android.widget.TextView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View)

Example 4 with SimpleDraweeView

use of com.facebook.drawee.view.SimpleDraweeView in project fresco by facebook.

the class MainActivity method findAndPrepare.

private SimpleDraweeView findAndPrepare(@IdRes int viewId) {
    SimpleDraweeView view = (SimpleDraweeView) findViewById(viewId);
    view.getHierarchy().setProgressBarImage(new ProgressBarDrawable());
    return view;
}
Also used : SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) ProgressBarDrawable(com.facebook.drawee.drawable.ProgressBarDrawable)

Example 5 with SimpleDraweeView

use of com.facebook.drawee.view.SimpleDraweeView in project GitTest by xiaoxige.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    testView = (TestView) findViewById(R.id.testView);
    testView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            MainActivityPermissionsDispatcher.showCameraWithPermissionCheck(MainActivity.this);
        }
    });
    try {
        ApplicationInfo appInfo = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);
        String appMV = appInfo.metaData.getString("MTA_CHANNEL");
        Toast.makeText(MainActivity.this, "appMV = " + appMV, Toast.LENGTH_SHORT).show();
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    simpleDraweeView = (SimpleDraweeView) findViewById(R.id.simpleDraweeView);
    testView.setProgress(100, false);
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            testView.setProgress(3, true);
        }
    }, 2000);
    GenericDraweeHierarchy hierarchy = simpleDraweeView.getHierarchy();
    RoundingParams roundingParams = new RoundingParams();
    roundingParams.setBorder(Color.RED, 10);
    roundingParams.setRoundAsCircle(true);
    hierarchy.setRoundingParams(roundingParams);
    simpleDraweeView.setHierarchy(hierarchy);
    ControllerListener listener = new BaseControllerListener() {

        @Override
        public void onFinalImageSet(String id, @Nullable Object imageInfo, @Nullable Animatable animatable) {
            super.onFinalImageSet(id, imageInfo, animatable);
        }
    };
    DraweeController controller = Fresco.newDraweeControllerBuilder().setUri(new Uri.Builder().scheme(UriUtil.LOCAL_RESOURCE_SCHEME).path(String.valueOf(R.mipmap.ic_launcher)).build()).setOldController(simpleDraweeView.getController()).setControllerListener(listener).build();
    simpleDraweeView.setController(controller);
    /**
     * 网络相关(retrofit+rxjava+rxlife+stetho)
     */
    OkHttpClient client = new OkHttpClient.Builder().connectTimeout(5000, TimeUnit.SECONDS).readTimeout(5000, TimeUnit.SECONDS).writeTimeout(5000, TimeUnit.SECONDS).addNetworkInterceptor(new Interceptor() {

        @Override
        public okhttp3.Response intercept(Chain chain) throws IOException {
            Request request = chain.request();
            Headers headers = request.headers();
            Headers build = headers.newBuilder().add("version", "1.0").add("token", "xiaoxige").build();
            request = request.newBuilder().headers(build).build();
            Log.e("TAG", "url = " + request.url().uri().toString());
            String method = request.method();
            if (method.equals("GET") || method.equals("DELETE")) {
                HttpUrl url = request.url();
                HttpUrl httpUrl = url.newBuilder().addQueryParameter("xiaoxige", "one").addQueryParameter("zhuxiaoan", "two").build();
                request = request.newBuilder().url(httpUrl).build();
            } else {
                RequestBody body = request.body();
                if (body != null) {
                    Buffer buffer = new Buffer();
                    body.writeTo(buffer);
                    String readUtf8 = buffer.readUtf8();
                    // 可能需要对body进行加密
                    // TODO: 2017/11/3
                    RequestBody requestBody = RequestBody.create(body.contentType(), readUtf8);
                    request = request.newBuilder().method(method, requestBody).build();
                }
            }
            return chain.proceed(request);
        }
    }).addNetworkInterceptor(new StethoInterceptor()).build();
    Retrofit retrofit = new Retrofit.Builder().baseUrl("http://www.baidu.com").addConverterFactory(ScalarsConverterFactory.create()).addConverterFactory(GsonConverterFactory.create()).client(client).build();
    final NetApi api = retrofit.create(NetApi.class);
    Flowable flowable = Flowable.create(new FlowableOnSubscribe<String>() {

        @Override
        public void subscribe(@NonNull FlowableEmitter<String> flowableEmitter) throws Exception {
            String response = MainActivity.execute(api.getBaiduWeb());
            if (TextUtils.isEmpty(response)) {
                flowableEmitter.onError(new Exception());
                return;
            }
            flowableEmitter.onNext(response);
            flowableEmitter.onComplete();
        }
    }, BackpressureStrategy.LATEST).compose(bindUntilEvent(ActivityEvent.DESTROY)).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io());
    flowable.subscribe(new XXGSubscriber<String>() {

        @Override
        public void xxgNext(String o) {
            super.xxgNext(o);
            Log.e("TAG", "o = " + o);
        }

        @Override
        public void xxgError(Throwable t) {
            super.xxgError(t);
            Log.e("TAG", "t = " + t.getMessage());
        }

        @Override
        public void xxgComplete() {
            super.xxgComplete();
            Log.e("TAG", "Complete");
        }
    });
}
Also used : OkHttpClient(okhttp3.OkHttpClient) GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) DraweeController(com.facebook.drawee.interfaces.DraweeController) Headers(okhttp3.Headers) ApplicationInfo(android.content.pm.ApplicationInfo) Uri(android.net.Uri) PackageManager(android.content.pm.PackageManager) BaseControllerListener(com.facebook.drawee.controller.BaseControllerListener) NonNull(io.reactivex.annotations.NonNull) FlowableEmitter(io.reactivex.FlowableEmitter) Interceptor(okhttp3.Interceptor) StethoInterceptor(com.facebook.stetho.okhttp3.StethoInterceptor) RoundingParams(com.facebook.drawee.generic.RoundingParams) RequestBody(okhttp3.RequestBody) Buffer(okio.Buffer) FlowableOnSubscribe(io.reactivex.FlowableOnSubscribe) Request(okhttp3.Request) Handler(android.os.Handler) ControllerListener(com.facebook.drawee.controller.ControllerListener) BaseControllerListener(com.facebook.drawee.controller.BaseControllerListener) IOException(java.io.IOException) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) HttpUrl(okhttp3.HttpUrl) IOException(java.io.IOException) Response(retrofit2.Response) Retrofit(retrofit2.Retrofit) Animatable(android.graphics.drawable.Animatable) StethoInterceptor(com.facebook.stetho.okhttp3.StethoInterceptor) Nullable(javax.annotation.Nullable) Flowable(io.reactivex.Flowable)

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