Win a copy of Head First Android this week in the Android forum!

Lilly Rose

Ranch Hand
+ Follow
since Aug 22, 2017
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Lilly Rose

Here is my Service- ProxyKillSwitchRepository.java

it has a method which calls retrofit enqueue


and this been called in the same service in the method


I'm calling this service in the another activity file SupportWebViewActivity.java in the Intent() and I also want to access in the enum block on this activity


When I debug  through it, the instance is getting created and reaching the backend call but it is not coming back with response, it is just returning null as is it coming out the the mWebService.proxyKillSwitch().getAppConfig().enqueue().

I don't see anything it is reaching @Override public void onFailure(), the Is it because of any time with the enqueue call?

I did try to use @Inject annotation on the Service ProxyKillSwitchRepository in the activity SupportWebViewActivity,
@Inject
protected ProxyKillSwitchRepository proxyKillSwitchRepository;

this is coming fine and I see all the values of it, only problem I can't access this injected field in the enum or static Intent().

How to access the @Inject field in the static block?


6 months ago
Hello,

I'm trying to access non static content in the static block, how to do it.
I tried to create an instance of the repository that I want to access which has retrofit OkHttpCall, which is failing when I create a new instance of that service.
I know we have @PostConstruct to use in spring, but it is not recognizing in the android studio, what is the annotation for it in the android?
I need to use non static service which returns a url need to be used in Intent() block.

Please help me on it.
6 months ago
Yes I tested it, it is working fine.I indent the code in project...sorry didn't copy it here properly... thanks for your help. I appreciate it.
2 years ago
2 years ago
String beginningString = "Your amounts of ", endingString = " are going to added to your account within three days.;
StringBuilder amount = new StringBuilder();
StringBuilder message = new StringBuilder();
if(CollectionUtils.isNotEmpty(list)){
int size = list.size();
switch (size){
case 1:
message.append("Your amount of $").append(list.get(0)).append(" is pending processing and will post to your account within one to two business days.");
break;
case 2:
message.append(beginningString).append(("$"+list.get(0)+ " and $" + list.get(1))).append(endingString);
break;
default:
for (int i = 0; i < size; i++) {
if (i == size - 1) {
amount.append("and $").append(list.get(i));
message.append(beginningString).append(amount).append(endingString);
break;
}
amount.append("$"+list.get(i) + ", ");
}
}
}

I fixed most of them...can you verify whether it need any more update to make the code more efficient?
2 years ago
okay..I will use the normal standard for loop. Got another question...about StringBuilder..which way of using is performance efficient of these examples.

eg:
msg.append("Your amount of  " + " " +"$" + amounts[0]+" "+"is going to added to your account within three days.");

msg.append("Your amounts of ").append(" ").append("$").append(amounts[0]).append(" ").append("is going to added to your account within three days.");

Can you explain me which way is good to use? thanks.
2 years ago
Yes I tried to run it..it is working fine...just want to make sure the code I wrote is efficient one...I will update the code as you suggested and test it..got curious on another one about default block...

default:

               for(int i=0;i<length;i++){

                   if(i==length-1){
                       amt.append( "and"+" "+"$"+amounts[i]);
                       msg.append( str1 + amt + str2);
                       break;
                   }
                   amt.append( "$"+amounts[i]+", ");
               }


How to use other way of for loop on this block?
"for(int i : amounts)"
how to make a if check here  if I use this "for loop"?

Please let me know
2 years ago


please guide to write this code more efficiently.

Thanks.
2 years ago
I trying to write code which needs to add delimiter , and also use 'and' for the last amount.
my string will vary depends on the input.
ex:
One amount:
• "Your amount of $DD.CC is going to added to your account within three days."

Multiple amounts:
• “Your amounts of $DD.CC and $DD.CC are going to added to your account within three days."
• “Your amounts of $DD.CC, $DD.CC, and $DD.CC are going to added to your account within three days."
• “Your amounts of $DD.CC, $DD.CC, $DD.CC, and $DD.CC are going to added to your account within three days."

Multiple amounts may increase.


I used switch/case:

Can you provide me a good code.

Thanks.
2 years ago
Yes, I'm using that in a test case but it is giving me null pointer exception.


help me with the code to not to get NPE
3 years ago
Hello,

I'm new in  writing Junit test cases. I'm getting an error " The method when(T) in the type Mockito is not applicable for the arguments (void)" , when I'm trying to Mockito on my service void method.
How do I hook up my service in the @Before method set up.
the @Before method was already generated by other member in team, I need to hook up my service in that inorder to avoid null pointer exception.

Here is service looks like



can you please help how to Mock void method in the @Before method.
3 years ago
I developed a mobile app, which provides id cards and more stuff, I want hook my id cards in to apple wallet.
what back end work need to be done to get with apple wallet.

3 years ago
iOS
Thank you so much for your quick responses, I got lot of knowledge through this and I appreciate your help. It makes sense for me the approach you've provided.
I figured it out a solution for it, I used properties file where I stored all the json response-path as a key/value pair. where I filtered the key from the request.getRequestURI(). I could able to go forward now and the interceptor is working well.
3 years ago