目前我有一些与此相关的内容
public class SomeActivity extends AppCompatActivity
{
public AppCompatImageView myFavPicture;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_some);
myFavPicture = (AppCompatImageView) findViewById(R.id.my_fav_picture);
}
public void setPictureToRed()
{
myFavPicture.setImageResource(R.color.red);
}
public void setPictureToLink(Uri link)
{
Picasso.with(this).load(link).into(myFavPicture);
}
}
我目前遇到的问题是担心setPictureToRed
和setPictureToLink
如果我打电话给setPictureToLink(someLink)
,然后在毕加索完全加载图片之前立即拨打setPictureToRed
- 我担心毕加索会稍后回来并覆盖红色图片(这不是我想要的)
有没有办法做这样的事情?
public void setPictureToRed()
{
// flush all previous loads for "myFavPicture" to avoid race conditions
Picasso.with(this).flush(myFavPicture);
myFavPicture.setImageResource(R.color.red);
}
答案 0 :(得分:1)
user@dev:~/dev/kernel-sandbox$ make
sudo make -C /lib/modules/4.10.0-35-generic/build M=/home/user/dev/kernel-sandbox modules
make: Entering directory '/usr/src/linux-headers-4.10.0-35-generic'
CC [M] /home/user/dev/kernel-sandbox/lkm.o
In file included from ./arch/x86/include/asm/preempt.h:6:0,
from ./include/linux/preempt.h:59,
from ./include/linux/spinlock.h:50,
from ./include/linux/seqlock.h:35,
from ./include/linux/time.h:5,
from ./include/linux/stat.h:18,
from ./include/linux/module.h:10,
from /home/user/dev/kernel-sandbox/lkm.c:3:
/home/user/dev/kernel-sandbox/lkm.c: In function ‘hello_init’:
./include/linux/thread_info.h:21:54: error: ‘current’ undeclared (first use in this function)
#define current_thread_info() ((struct thread_info *)current)
^
./include/asm-generic/current.h:6:24: note: in expansion of macro ‘current_thread_info’
#define get_current() (current_thread_info()->task)
^
./include/asm-generic/current.h:7:17: note: in expansion of macro ‘get_current’
#define current get_current()
^
/home/user/dev/kernel-sandbox/lkm.c:13:17: note: in expansion of macro ‘current’
current->comm, current->pid);
^
./include/linux/thread_info.h:21:54: note: each undeclared identifier is reported only once for each function it appears in
#define current_thread_info() ((struct thread_info *)current)
^
./include/asm-generic/current.h:6:24: note: in expansion of macro ‘current_thread_info’
#define get_current() (current_thread_info()->task)
^
./include/asm-generic/current.h:7:17: note: in expansion of macro ‘get_current’
#define current get_current()
^
/home/user/dev/kernel-sandbox/lkm.c:13:17: note: in expansion of macro ‘current’
current->comm, current->pid);
^
scripts/Makefile.build:301: recipe for target '/home/user/dev/kernel-sandbox/lkm.o' failed
make[1]: *** [/home/user/dev/kernel-sandbox/lkm.o] Error 1
Makefile:1524: recipe for target '_module_/home/user/dev/kernel-sandbox' failed
make: *** [_module_/home/user/dev/kernel-sandbox] Error 2
make: Leaving directory '/usr/src/linux-headers-4.10.0-35-generic'
Makefile:3: recipe for target 'all' failed
make: *** [all] Error 2