Reputation: 579
i am trying to do a flipcard app in which there is gridview of images showing a same image ,say a card_back .
On clicking each image,it flips showing another image which is different for every item of gridview,say a card_front.
if 2 cards are showing their card_front image,aftr 1 second both gets automatically flipped to show the card_back.
what i am trying to do is that in this 1-2 seconds,the user should not be able to click any of the other items.or even if he clicks,no card should be flipped in those 2 seconds.How can i do this.Is it possible to use a transparent view that covers the whole of the gridview and make it visible only for those 2 seconds.Can someone please help me out.
gridview.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View v, int position, long id)
{
pos=position;
findViewById(R.id.view1).setBackgroundColor(getResources().getColor(android.R.color.transparent));
switch(flippedCardCounter)
{
case 0:
flippedCardCounter++; //increase counter
v1=v;
startFlipAnimation(imageView,v1);
break;
//flippedCardCounter = 1 -> one card flipped
case 1:
flippedCardCounter++; //increase counter
v2=v;
startFlipAnimation(imageView,v2);
im1=((ViewHolder) v1.getTag()).img;
im2=((ViewHolder) v2.getTag()).img;
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
startUnflipAnimation(im1,v1);
startUnflipAnimation(im2,v2);
}
},1000);
break;
//flippedCardCounter = 2 -> hide two flipped card, flip one card
case 2:
flippedCardCounter = 0;
flippedCardCounter++; //increase counter
startFlipAnimation(imageView,v);
v1=v2=v;
break;
}
}
});
Upvotes: 0
Views: 136
Reputation:
Maybe this help
public class MyClass{
....
private volatile boolean isLock=false;
gridview.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View v, int position, long id)
{
if(isLock){return;}
pos=position;
findViewById(R.id.view1).setBackgroundColor(getResources().getColor(android.R.color.transparent));
switch(flippedCardCounter)
{
case 0:
flippedCardCounter++; //increase counter
v1=v;
startFlipAnimation(imageView,v1);
break;
//flippedCardCounter = 1 -> one card flipped
case 1:
flippedCardCounter++; //increase counter
isLock=true;
v2=v;
startFlipAnimation(imageView,v2);
im1=((ViewHolder) v1.getTag()).img;
im2=((ViewHolder) v2.getTag()).img;
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
////////////////////////
////////////////////////
startUnflipAnimation(im1,v1);
startUnflipAnimation(im2,v2);
isLock=false;
}
},1000);
break;
//flippedCardCounter = 2 -> hide two flipped card, flip one card
case 2:
flippedCardCounter = 0;
flippedCardCounter++; //increase counter
startFlipAnimation(imageView,v);
v1=v2=v;
break;
}
}
});
....
}
You may set the isLock
variable anywhere you like to disable clocking. I hope I could give some hand!
Upvotes: 1