I have a custom View with an "abc" String attribute
public class MyCustomView extends View {
private String abc;
}
Is possible to retrieve with an accessibility service the "abc" attribute when a "MyCustomView" is displayed on the user screen?
public List<AccessibilityNodeInfo> findAccessibilityNodeInfosByViewId (String viewId);
You can find the node of your custom view, by Id or Text
public List<AccessibilityNodeInfo> findAccessibilityNodeInfosByText (String text);
You can find the methods like this,
private List<CharSequence> getAllChildNodeText(AccessibilityNodeInfoCompat infoCompat) {
List<CharSequence> contents = new ArrayList<>();
if (infoCompat == null)
return contents;
if (infoCompat.getContentDescription() != null) {
contents.add(infoCompat.getContentDescription().toString().isEmpty() ? "unlabelled" : infoCompat.getContentDescription());
} else if (infoCompat.getText() != null) {
contents.add(infoCompat.getText().toString().isEmpty() ? "unlabelled" : infoCompat.getText());
} else {
getTextInChildren(infoCompat, contents);
}
if (infoCompat.isClickable()) {
if (infoCompat.getClassName().toString().contains(Button.class.getSimpleName())) {
if (contents.size() == 0) {
contents.add("Unlabelled button");
} else {
contents.add("button");
}
}
contents.add("Double tap to activate");
}
return contents;
}
private void getTextInChildren(AccessibilityNodeInfoCompat nodeInfoCompat, List<CharSequence> contents) {
if (nodeInfoCompat == null)
return;
if (!nodeInfoCompat.isScrollable()) {
if (nodeInfoCompat.getContentDescription() != null) {
contents.add(nodeInfoCompat.getContentDescription());
} else if (nodeInfoCompat.getText() != null) {
contents.add(nodeInfoCompat.getText());
}
if (nodeInfoCompat.getChildCount() > 0) {
for (int i = 0; i < nodeInfoCompat.getChildCount(); i++) {
if (nodeInfoCompat.getChild(i) != null) {
getTextInChildren(nodeInfoCompat.getChild(i), contents);
}
}
}
}
}
This is my Card Place and winner Card Animation Code inside
PlayerView.java class
private void startCardAnimation(int placeCardX, int placeCardY, int sourceX, int sourceY, ImageView placedCard, int cardId) {
placedCard.setImageDrawable(Card.cardImageNameFromId(mContext, cardId));
Animation animation = null;
if (placedCard.getId() == R.id.player_destination_card4)
animation= AnimationUtils.loadAnimation(mContext,R.anim.from_righttoleft);
else if (placedCard.getId() == R.id.player_destination_card1)
animation= AnimationUtils.loadAnimation(mContext,R.anim.from_bottomtotop);
else if (placedCard.getId() == R.id.player_destination_card2)
animation= AnimationUtils.loadAnimation(mContext,R.anim.from_lefttoright);
else if (placedCard.getId() == R.id.player_destination_card3)
animation= AnimationUtils.loadAnimation(mContext,R.anim.from_toptobottom);
placedCard.startAnimation(animation);
deleteCache(mContext);
}
public void placeCardAnimation(int cardId, ImageView placedCard) {
player_source_card.setVisibility(INVISIBLE);
placedCard.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
placedCard.getViewTreeObserver().removeGlobalOnLayoutListener(this);
int[] locations = new int[2];
placedCard.getLocationOnScreen(locations);
placeCardX1 = locations[0];
placeCardY1 = locations[1];
startCardAnimation(placeCardX1, placeCardY1, sourceCardX1, sourceCardY1, placedCard, cardId);
}
});
player_source_card.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
player_source_card.getViewTreeObserver().removeGlobalOnLayoutListener(this);
int[] locations = new int[2];
player_source_card.getLocationOnScreen(locations);
sourceCardX1 = locations[0];
sourceCardY1 = locations[1];
startCardAnimation(placeCardX1, placeCardY1, sourceCardX1, sourceCardY1, placedCard, cardId);
}
});
}
private void startWinnerAnimation(int placeCardX, int placeCardY, int sourceX, int sourceY, ImageView placedCard, int cardId) {
placedCard.setImageDrawable(Card.cardImageNameFromId(mContext, cardId));
TranslateAnimation animation = new TranslateAnimation(sourceX - placeCardX, 0, sourceY - placeCardY, 0);
animation.setDuration(2000);
animation.setFillAfter(true);
animation.setInterpolator(new ReverseInterpolator());
placedCard.startAnimation(animation);
animation.setAnimationListener(new Animation.AnimationListener() {
#Override
public void onAnimationStart(Animation animation) {
}
#Override
public void onAnimationEnd(Animation animation) {
placedCard.clearAnimation();
placedCard.setVisibility(GONE);
}
#Override
public void onAnimationRepeat(Animation animation) {
}
});
}
public void WinnerCardAnimation(int cardId, ImageView placedCard) {
player_source_card.setVisibility(INVISIBLE);
placedCard.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
placedCard.getViewTreeObserver().removeGlobalOnLayoutListener(this);
int[] locations = new int[2];
placedCard.getLocationOnScreen(locations);
placeCardX1 = locations[0];
placeCardY1 = locations[1];
startWinnerAnimation(placeCardX1, placeCardY1, sourceCardX1, sourceCardY1, placedCard, cardId);
}
});
player_source_card.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
player_source_card.getViewTreeObserver().removeGlobalOnLayoutListener(this);
int[] locations = new int[2];
player_source_card.getLocationOnScreen(locations);
sourceCardX1 = locations[0];
sourceCardY1 = locations[1];
startWinnerAnimation(placeCardX1, placeCardY1, sourceCardX1, sourceCardY1, placedCard, cardId);
}
});
}
Inside this code we will get current all user data and through card one by one and fetch detail of current table and user detail PlayCardTable.java class
private void getCurrentTableStatus() {
JSONObject jsonObject = new JSONObject();
if (ConstantData.isInternetAvailable(PlayCardTable.this))
try {
jsonObject.put(RequestParams.TABLEID, tableId);
} catch (JSONException e) {
e.printStackTrace();
}
ApplicationClass app = (ApplicationClass) getApplication();
app.mSocket.emit(RequestParams.GET_CURRENT_TABLE_STATUS, jsonObject);
app.mSocket.on(RequestParams.GET_CURRENT_TABLE_STATUS + "Reply" + tableId, args -> {
try {
String TableStatus = (String) args[0];
Log.d("CurrentTableStatus---", "" + TableStatus);
tablestatusjsonobject = new JSONObject(TableStatus);
Table tempTableStatus = Table.getParseStatus(tablestatusjsonobject, userId);
if (tempTableStatus.getTableId() == tableId) {
TIMERCOUNT = 0;
tableStatus = tempTableStatus;
Log.d("CurrentTableStatus---", "" + tableStatus.getTableId());
runOnUiThread(() -> {
if (playerImageViewByPlayerId == null
|| (playerImageViewByPlayerId.size() != tableStatus.getNoOfPlayers())) {
initplayerImageViewByPlayerId();
}
int joinPlayerWithTable = tableStatus.getPlayers().size();
if (tableStatus.getNoOfPlayers() == joinPlayerWithTable) {
if (tableStatus.getWinnerUserId() != 0 && tableStatus.getWinnerPoints() != 0) {
app.mSocket.off(RequestParams.GET_CURRENT_TABLE_STATUS + "Reply");
Log.d("User Id ", "Winner User Id : " + tableStatus.getWinnerUserId());
Log.d("Winner Point", "Winner Point: " + tableStatus.getWinnerPoints());
loadFragments(new ScoreBoardFragment(), "");
} else {
ConstantData.progressclose();
updatePlayerCard();
setUpPlayerData();
playturn();
if (!(tableStatus.isBidDone())) {
bidturn();
} else if (tableStatus.getMainSuit() != null && tableStatus.getMainSuit().equalsIgnoreCase("")) {
selctSuitAndFriends();
} else {
oldRoundCards = RoundCard.getOldRoundCardData(this);
if (oldRoundCards == null || oldRoundCards.isEmpty()) {
RoundCard.setOldRoundCardData(tableStatus.getRoundCards(), this);
oldRoundCards = RoundCard.getOldRoundCardData(this);
}
Log.d("ThrowCard---round", "" + tableStatus.getRoundCards().size() + "," + oldRoundCards.size());
RoundCard updatedThrownCards = getUpdatedThrownCards(oldRoundCards, tableStatus.getRoundCards());
if (updatedThrownCards != null && updatedThrownCards.getUserId() != userId) {
Objects.requireNonNull(playerImageViewByPlayerId.get(updatedThrownCards.getUserId())).placeCardAnimation(updatedThrownCards.getCardId(), placedCardPosition.get(updatedThrownCards.getUserId()));
Log.d("animation card-", updatedThrownCards.getCardId() + "," + updatedThrownCards.getUserId());
}
RoundCard.setOldRoundCardData(tableStatus.getRoundCards(), this);
maxBid();
partner();
selectPartnerCard();
setHukumData();
setAlreadyThrownCardOnTable(tableStatus.getRoundCards());
setUpClickForOtherPlayer();
}
}
} else {
ConstantData.progressclose();
ConstantData.Displayprogress(PlayCardTable.this, "Please Wait Players Joining With This Table");
}
});
}
} catch (JSONException e) {
e.printStackTrace();
Log.d("CurrentTableStatus---ex", e.toString());
}
});
}
This code For animation inside PlayCardTable.java
private void setAlreadyThrownCardOnTable(List<RoundCard> roundCards) {
try {
roundState = RoundState.getRoundState(PlayCardTable.this);
if (roundState != null) {
if (roundCards.size() == tableStatus.getNoOfPlayers()) {
if (roundState.getRoundAnimationState().equals(RoundAnimationRunning)) {
return;
} else if (roundState.getRoundAnimationState().equals(RoundInComplete)) {
roundState.setRoundAnimationState(RoundComplete);
roundState.save(this);
} else if (roundState.getRoundAnimationState().equals(RoundAnimationComplete)) {
roundCards.clear();
}
}
}
if (roundCards.size() != tableStatus.getNoOfPlayers()) {
if (roundCards.size() > 0) {
roundState = new RoundState(roundCards.get(0).getRoundNo(), RoundInComplete);
roundState.save(this);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
if (roundState != null) {
if (roundState.getRoundAnimationState().equals(RoundComplete)) {
new Handler().postDelayed(() -> {
try {
if (!tableStatus.getRoundCards().isEmpty()) {
if (tableStatus.getRoundCards().get(0).getRoundGoesTo() != 0) {
roundState.setRoundAnimationState(RoundAnimationRunning);
roundState.save(this);
placedCard4.setRotation(90);
placedCard2.setRotation(90);
for (int i = 0; i < placedCardPosition.size(); i++) {
playerImageViewByPlayerId.get(tableStatus.getRoundCards().get(0).getRoundGoesTo())
.WinnerCardAnimation(tableStatus.getRoundCards().get(i).getCardId(), placedCard1);
playerImageViewByPlayerId.get(tableStatus.getRoundCards().get(0).getRoundGoesTo())
.WinnerCardAnimation(tableStatus.getRoundCards().get(i).getCardId(), placedCard2);
playerImageViewByPlayerId.get(tableStatus.getRoundCards().get(0).getRoundGoesTo())
.WinnerCardAnimation(tableStatus.getRoundCards().get(i).getCardId(), placedCard3);
playerImageViewByPlayerId.get(tableStatus.getRoundCards().get(0).getRoundGoesTo())
.WinnerCardAnimation(tableStatus.getRoundCards().get(i).getCardId(), placedCard4);
}
new Handler().postDelayed(() -> {
roundState.setRoundAnimationState(RoundAnimationComplete);
roundState.save(PlayCardTable.this);
clearThrownCardOnTable();
}, 5000);
}
}
} catch (Exception ex) {
Log.e("", ex.toString());
}
roundCards.clear();
}, 1000);
}
}
if (roundCards.isEmpty())
clearThrownCardOnTable();
else {
for (int i = 0; i < roundCards.size(); i++) {
Drawable res = Card.cardImageNameFromId(PlayCardTable.this, roundCards.get(i).getCardId());
ImageView placedCardAsPerUserId = placedCardPosition.get(roundCards.get(i).getUserId());
if (placedCardAsPerUserId != null) {
placedCardAsPerUserId.setVisibility(View.VISIBLE);
placedCardAsPerUserId.setImageDrawable(res);
}
}
}
}
I am working on a card game in that I'm getting the issue in animation while placing the card in the game. In my case, there are 4 players who are playing game together. Turn by turn user will place card according , place card animation working fine until 4-5 turn , but as playing more round animation getting hang and after 7-8 round its totally stop working ,and after clear app from recent and again resume game than it's again working fine, again after 4-5 turn its getting hang, Here I attached video of my game, animation hanging and related code Please help me to resolve this animation issue.
Please Refer link for ios game animation we need that type of animation in Android
I have uses linphone library latest version. I want to display sip contacts status. here is my code.
LinphoneFriend[] friends = LinphoneManager.getLc().getFriendList();
if (!ContactsManager.getInstance().isContactPresenceDisabled() && friends != null && contact.hasAddress()) {
friendStatus.setVisibility(View.VISIBLE);
String friendSipAddress = "";
for (LinphoneNumberOrAddress noa : contact.getNumbersOrAddresses()) {
if (noa.isSIPAddress()) {
friendSipAddress = noa.getValue();
}
}
LinphoneFriend friend = null;
for (int i = 0; i < friends.length; i++) {
Log.e("Friend","Addr " + friends[i].getAddress().asStringUriOnly());
Log.e("Friend","Name " + friends[i].getAddress().getDisplayName());
if (friends[i].getAddress().asStringUriOnly().equalsIgnoreCase(friendSipAddress)) {
friend = friends[i];
break;
}
}
if(friend!=null) {
PresenceModel presenceModel = friend.getPresenceModel();
if (presenceModel != null) {
//PresenceActivityType presenceActivity = friends[0].getPresenceModel().getActivity().getType();
PresenceActivityType presenceActivity = presenceModel.getActivity().getType();
android.util.Log.e("Linphone",friend.getName()+" " + presenceActivity);
if (presenceActivity == PresenceActivityType.Online) {
friendStatus.setImageResource(R.drawable.led_connected);
} else if (presenceActivity == PresenceActivityType.Busy) {
friendStatus.setImageResource(R.drawable.led_error);
} else if (presenceActivity == PresenceActivityType.Away) {
friendStatus.setImageResource(R.drawable.led_inprogress);
} else if (presenceActivity == PresenceActivityType.OnThePhone) {
friendStatus.setImageResource(R.drawable.on_phone);
} else if (presenceActivity == PresenceActivityType.Offline) {
friendStatus.setImageResource(R.drawable.led_disconnected);
} else {
friendStatus.setImageResource(R.drawable.led_disconnected);
}
} else {
friendStatus.setImageResource(R.drawable.led_error);
//Log.e("Linphone", "led_error");
}
} else {
//Log.e("Friend","friend null");
}
} else {
Log.e("Friend","friend visibility gone");
friendStatus.setVisibility(View.INVISIBLE);
}
But LinphoneFriend object always give null PresenceModel. How to get presencemodel with status from linphonefriend?
I want to show fileds and attributes in popup when I clicked a point. But I get Null Pointer Exception. Why I return to me null? Can you help please? How can I do? I did like esri android sample. but it doesnt work.
/// long press to map
mapView.setOnLongPressListener(new OnLongPressListener() {
private static final long serialVersionUID = 1L;
// ArcGISFeatureLayer
private ArcGISFeatureLayer featureLay = null;
/// override onLongPress
#Override
public boolean onLongPress(final float v, final float v1) {
if (mapView.isLoaded()) {
if (progressDialog != null && progressDialog.isShowing()
&& count.intValue() == 0)
//dismiss dialog
progressDialog.dismiss();
// Get the point featurelayer
Layer[] layers = mapView.getLayers();
for (Layer layer : layers) {
if (layer instanceof ArcGISFeatureLayer) {
ArcGISFeatureLayer fl = (ArcGISFeatureLayer) layer;
if (fl.getGeometryType() == Geometry.Type.POINT) {
featureLay = fl;
break;
}
}
}
//// if featureLay null
if (featureLay == null)
return false;
ArcGISPopupInfo popupInfos = (ArcGISPopupInfo) featureLay.getPopupInfos();
///!!!!!!!!!!!!!!! return to me null////////////
if (popupInfos == null)
return false;
// Create a new feature
Point point = mapView.toMapPoint(v, v1);
Feature feature2;
FeatureType[] types = featureLay.getTypes();
if (types == null || types.length < 1) {
FeatureTemplate[] templates = featureLay
.getTemplates();
if (templates == null || templates.length < 1) {
feature2 = new Graphic(point, null);
} else {
feature2 = featureLay.createFeatureWithTemplate(
templates[0], point);
}
} else {
feature2 = featureLay.createFeatureWithType(
featureLay.getTypes()[0], point);
}
// Instantiate a PopupContainer
popupContainer = new PopupContainer(mapView);
// popup create
Popup popupp = featureLay.createPopup(mapView, 0, feature2);
popupContainer.addPopup(popupp);
popupp.setEditMode(true);
createEditorBar(featureLay, false);
// Create a dialog for the popups and display it.
popupDialog = new PopupDialog(mapView.getContext(),
popupContainer);
// show popup
popupDialog.show();
}
return true;
}
});
I add an item for the progressBar at the end for loading more, and when load finish, I remove this item before adding element at the end of adapter.
But the the item is not correctly removed.
if (arrayAdapter != null) {
arrayAdapter.list.add(null);
arrayAdapter.notifyItemInserted(arrayAdapter.getItemCount() - 1);
arrayAdapter.notifyItemRangeChanged(arrayAdapter.getItemCount(), arrayAdapter.getItemCount());
}
serverRequests.getQuestionsAnsweredInBackground(userID, type, startLoad, new GetQuestionCallBack() {
#Override
public void done(ArrayList<Question> questions) {
if (arrayAdapter != null) {
arrayAdapter.list.remove(arrayAdapter.getItemCount() - 1);
arrayAdapter.notifyItemRemoved(arrayAdapter.getItemCount());
arrayAdapter.notifyItemRangeChanged(arrayAdapter.getItemCount(), arrayAdapter.getItemCount());
}
if (questions != null) {
if (arrayAdapter == null) {
arrayAdapter = new QuestionsAnsweredAdapter(getActivity(), R.layout.layout_questions_answered_item, questions, QuestionsAnswered.this);
lvQuestionsAnswered.setAdapter(arrayAdapter);
listLayout.setVisibility(View.VISIBLE);
} else {
final int positionStart = arrayAdapter.getItemCount();
arrayAdapter.list.addAll(questions);
arrayAdapter.notifyItemRangeInserted(positionStart, questions.size());
}
startLoad += questions.size();
loading = true;
}
progressBar.setVisibility(View.GONE);
}
});
Before loading new data
if(!mIsloading)
{
arrayAdapter.list.add(null);
arrayAdapter.notifyItemInserted(arrayAdapter.list.size() - 1);
mIsloading = true;
}
After done with fetching data
serverRequests.getQuestionsAnsweredInBackground(userID, type, startLoad, new GetQuestionCallBack() {
#Override
public void done(ArrayList<Question> questions) {
if (arrayAdapter.list.size() > 0 && arrayAdapter.list.get(arrayAdapter.list.size() - 1) == null) {
arrayAdapter.list.remove(arrayAdapter.list.size() - 1);
arrayAdapter.list.notifyItemRemoved(arrayAdapter.list.size());
}
mIsloading = false;
}