如何从初始屏幕的url中预加载图像?

时间:2019-08-31 16:21:58

标签: android firebase picasso

我有一个聊天应用程序,我想在用户处于启动屏幕时加载用户个人资料图像。实际上,我希望初始化所有内容(启动屏幕除外),将其隐藏1秒钟。但是启动结束时加载的图像就像没有启动屏幕一样。

我正在使用recyclerview并在firebase上获取数据。打开时,图片会一点点出现。

@Override
    public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int position) {

 ...
        viewHolder.nickname.setText(odialog.getNickname());

        Picasso.get()
                .load(odialog.getProfil_pic())
                .centerCrop()
                .fit()
                .noFade()

                .into(viewHolder.profile_image);
...


飞溅活动。


public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setTheme(R.style.SplashTheme);
        super.onCreate(savedInstanceState);

        new Handler().postDelayed(new Runnable() {

            /*
             * Showing splash screen with a timer. This will be useful when you
             * want to show case your app logo / company
             */

            @Override
            public void run() {
                // This method will be executed once the timer is over
                // Start your app dashboard activity
                Intent i = new Intent(SplashActivity.this, MainActivity.class);
                startActivity(i);

                // close this activity
                finish();
            }
        }, 2000);

我找到了解决方法[与对话框飞溅] [1] https://blog.iangclifton.com/2011/01/01/android-splash-screens-done-right/

0 个答案:

没有答案