Increment counter on longClick - not working - Java for Android App Development

I've looked at several tutorials on how to count button clicks, but it's not working for me. Any ideas what I am doing wrong?
Code:
holder.mContainer.setOnLongClickListener(new View.OnLongClickListener() {
int count = 0;
@Override
public boolean onLongClick(View view) {
{
deleteItem(position);
count++;
Toast.makeText(ExampleActivity.appContext, "#" + String.valueOf(count), Toast.LENGTH_SHORT).show();
}
return true;
}
});
Basically, count remains at 1 always.
I'd be grateful for some pointers! Thanks!

My guess is because you declare int count = 0 in the first part which on every click is changing it back to zero so count++ will always be 0+1.
Sent from my HTC6535LVW using Tapatalk

thestraw0039 said:
My guess is because you declare int count = 0 in the first part which on every click is changing it back to zero so count++ will always be 0+1.
Sent from my HTC6535LVW using Tapatalk
Click to expand...
Click to collapse
Thanks for your reply, but removing that value unfortunately does not seem to help...

StrangerWeather said:
Thanks for your reply, but removing that value unfortunately does not seem to help...
Click to expand...
Click to collapse
Did you make count a global variable? Also try and change count++ to count = count +1.
Sent from my HTC6535LVW using Tapatalk

thestraw0039 said:
Did you make count a global variable? Also try and change count++ to count = count +1.
Sent from my HTC6535LVW using Tapatalk
Click to expand...
Click to collapse
Making it a global variable worked! Thanks, you're a star!

Related

Help Frozen After V6 SuperCharger

I just installed the V6 SuperCharger. Now after the Galazy S screen, I get the "force close" virbrate and it hangs there. I tried installing an "Update" zip for Froyo that I still had on the SD and to no avail. What do I do now?
Odin...
Sent from my SPH-D700 using Tapatalk
Curious, what settings did you apply in v6?
Sent from my SPH-D700 using Tapatalk
1 and 6. Oh well. Time to start over!
I believe the recommended settings were 9 and 11.
JBizzleFoSho said:
I believe the recommended settings were 9 and 11.
Click to expand...
Click to collapse
Yes. That's all I've used. No issues.
Sent from my SPH-D700 using Tapatalk
offtohavasu said:
1 and 6. Oh well. Time to start over!
Click to expand...
Click to collapse
1 is not a setting btw, just checks current status of minfrees and launcher. I have used 6 before with no issues...
Sent from my SPH-D700 using Tapatalk
JBizzleFoSho said:
I believe the recommended settings were 9 and 11.
Click to expand...
Click to collapse
Yeah, 9 and 11 have worked the best for me
Sent from my SPH-D700 using Tapatalk
JohnCorleone said:
Yeah, 9 and 11 have worked the best for me
Click to expand...
Click to collapse
When you say 9 AND 11, I'm assuming you mean 9 OR 11. I'm only seeing an option to set one value at a time...
Am I correct with this assumption?
You're right that you can only do one at a time. I should have said 9 then 11.
Sent from my SPH-D700 using XDA App
JBizzleFoSho said:
You're right that you can only do one at a time. I should have said 9 then 11.
Click to expand...
Click to collapse
Thanks for clarifying, but, see, here's where I'm not so clear: Do you first try 9, play around for a while and then set it to 11 when you feel like it? Or, is the actual setting a 2-step process (set to combination of 9 AND 11)?
familymedia said:
Thanks for clarifying, but, see, here's where I'm not so clear: Do you first try 9, play around for a while and then set it to 11 when you feel like it? Or, is the actual setting a 2-step process (set to combination of 9 AND 11)?
Click to expand...
Click to collapse
Run 9, run 11, reboot. Make sure you check run as root. I personally prefer 6,11

[How-To][Code] AirView Samsung Galaxy S4

I didn't find a Thread with a guide for use the AirView in SGS4 so I did it.
In AndroidManifest.xml
Code:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
[B] <meta-data android:name="com.sec.android.airview.enable" android:value="true" />
<intent-filter>
<action android:name="com.sec.android.airview.HOVER" />
</intent-filter>[/B]
<activity
android:name="edu.uanl.secondapp.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
[B]<intent-filter>
<action android:name="com.sec.android.airview.HOVER" />
</intent-filter>[/B]
</activity>
</application>
You can use It this way:
Code:
View rootView = inflater.inflate(R.layout.fragment_main_dummy, container, false);
TextView dummyTextView = (TextView) rootView.findViewById(R.id.section_label);
dummyTextView.setText("Something Here");
[B] dummyTextView.setOnHoverListener(new View.OnHoverListener()[/B] {
[user=439709]@override[/user]
public boolean onHover(View view, MotionEvent motionEvent) {
switch(motionEvent.getAction()){
case 9: // Enter Hovered
case 10: // Leave Hovered
view.setBackgroundColor(Color.TRANSPARENT);
view.setScaleX((float)1.0);
view.setScaleY((float)1.0);
break;
case 7: // On Hover
view.setBackgroundColor(Color.RED);
view.setScaleX((float)2.0);
view.setScaleY((float)2.0);
break;
}
Log.wtf("Something", "I'm Being Hovered" + motionEvent.getAction());
return false;
}
});
dummyTextView.setHovered(true);
If this thread is repeated, or this is not the place to post it, my apologies I'm a semi-noob on this.
Hope this can help you.
Delete this thread if is innapropiate or something
A link to download Samsung Airview SDK and setting up samsungs cust. emulator will be handy
After all not all have an S4
Sent from my GT-S5302 using Tapatalk 2
Cool thread.
Thanks. :good:
Is that that fancy "I dont have to touch my screen" stuff? lol.
Cool how to. thanks!
http://developer.samsung.com/home.do
samsung developer site.
sak-venom1997 said:
A link to download Samsung Airview SDK and setting up samsungs cust. emulator will be handy
After all not all have an S4
Sent from my GT-S5302 using Tapatalk 2
Click to expand...
Click to collapse
sadly we don't have one sdk for this...
yet...
out of ideas said:
Is that that fancy "I dont have to touch my screen" stuff? lol.
Cool how to. thanks!
http://developer.samsung.com/home.do
samsung developer site.
Click to expand...
Click to collapse
that one itself.
Sent from my GT-I9505 using xda premium
furbyx92 said:
sadly we don't have one sdk for this...
yet...
that one itself.
Sent from my GT-I9505 using xda premium
Click to expand...
Click to collapse
No SDK yet what do these people want to do ?
No SDK for Ir Blaster to
Why the heck do they add so cool features when they dont' want developers to play with it
No apps using this feature will mean they're as good as one
they should learn from Google they never delay there SDK s
sak-venom1997 said:
No SDK yet what do these people want to do ?
No SDK for Ir Blaster to
Why the heck do they add so cool features when they dont' want developers to play with it
No apps using this feature will mean they're as good as one
they should learn from Google they never delay there SDK s
Click to expand...
Click to collapse
and this feature is the easy one.
Sent from my GT-I9505 using xda premium
furbyx92 said:
and this feature is the easy one.
Sent from my GT-I9505 using xda premium
Click to expand...
Click to collapse
You cant say the same for ir blaster
Sent from my GT-S5302 using Tapatalk 2
Yeah, I know... but I keep trying.
Thanks, nice example to kickstart a Samsung Smart App Challenge project.

Translucent/Transparent app

Hey! I am currently doing an app that will be half transparent so you can see what's behind it and interact with the apps behind my window. I searched the web and found some cool stuff but nothing that made me able to interact with apps behind, only half transparent!
Please help!
Sent from my GT-N7105 using xda premium
addemod said:
Hey! I am currently doing an app that will be half transparent so you can see what's behind it and interact with the apps behind my window. I searched the web and found some cool stuff but nothing that made me able to interact with apps behind, only half transparent!
Please help!
Sent from my GT-N7105 using xda premium
Click to expand...
Click to collapse
If you want to interact with the background, you'll need to go with a floating app here. Otherwise, there was a guide somewhere in the forum..
Hope this helps you.
addemod said:
Hey! I am currently doing an app that will be half transparent so you can see what's behind it and interact with the apps behind my window. I searched the web and found some cool stuff but nothing that made me able to interact with apps behind, only half transparent!
Please help!
Click to expand...
Click to collapse
To make your app transparent, modify your java as these:
Code:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowManager.LayoutParams params = this.getWindow().getAttributes();
/**
* 0.2 means 20% opaque. Here 1 is 100% opaque.
*/
params.alpha = 0.2f;
}
To make a button or any image transparent in your app you can add android:alpha="0.1" to your mainfest of the layout xml file
SimplicityApks said:
If you want to interact with the background, you'll need to go with a floating app here. Otherwise, there was a guide somewhere in the forum..
Click to expand...
Click to collapse
Do you mean this one? http://forum.xda-developers.com/showthread.php?t=2443882
nikwen said:
Do you mean this one? http://forum.xda-developers.com/showthread.php?t=2443882
Click to expand...
Click to collapse
Exactly, should be the same lib, isn't it? And yeah, fixed the link, I somehow deleted the last digit... Sorry
SimplicityApks said:
Exactly, should be the same lib, isn't it? And yeah, fixed the link, I somehow deleted the last digit... Sorry
Click to expand...
Click to collapse
No, it's not.
The tutorial I posted uses no library at all.
Differences:
More difficult
No default window frame
More customization options
nikwen said:
No, it's not.
The tutorial I posted uses no library at all.
Differences:
More difficult
No default window frame
More customization options
Click to expand...
Click to collapse
You're right, then that one is a lot easier..! :good:
Thanks guys! I used standout window and managed to make a Window but the problem is, you should be able to click behind the 50% transparent window.. anyway, thanks!
Sent from my GT-N7105 using xda premium

[q]Making Xposed module(nullpointer"

I am trying to implement recents clear button using xposed framework.
I am getting nullpointer exception at com.android.systemui.recent.recentverticalscrollview.getchildcontentview
Code:
mRecentsClearButton = (ImageView) view.findViewById(res.getIdentifier("clear_all_button", "id", PACKAGE_NAME));
mRecentsClearButton.setClickable(true);
mRecentsClearButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ViewGroup mRecentsContainer = (ViewGroup) XposedHelpers.getObjectField(
param.thisObject, "mRecentsContainer");
// passing null parameter in this case is our action flag to remove all views
mRecentsContainer.removeAllViewsInLayout();
}
});
Sent from my GT-S5570 using XDA Premium 4 mobile app
arpitkh96 said:
I am trying to implement recents clear button using xposed framework.
I am getting nullpointer exception at com.android.systemui.recent.recentverticalscrollview.getchildcontentview
Code:
mRecentsClearButton = (ImageView) view.findViewById(res.getIdentifier("clear_all_button", "id", PACKAGE_NAME));
mRecentsClearButton.setClickable(true);
mRecentsClearButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ViewGroup mRecentsContainer = (ViewGroup) XposedHelpers.getObjectField(
param.thisObject, "mRecentsContainer");
// passing null parameter in this case is our action flag to remove all views
mRecentsContainer.removeAllViewsInLayout();
}
});
Sent from my GT-S5570 using XDA Premium 4 mobile app
Click to expand...
Click to collapse
please post the exact line that gives NPE !
make sure you get the field names right Xposed Modules can be a pain to debug !!!
Sent from my GT-S5302 using Tapatalk 2
Here is the full code.please dont read comments they are not related to code.i am trying to make this for ics 4.04.NPE comes when mRecentsClearButton is pressed.the 3 imageviews are already present in systemui.apk of the particular rom for which i am making this module.
The line mRecentsContainor.removeAllViewInLayout causes npe.
This code is inspired from gravitybox module(for jb) source code.this module had line
mRecentsContainor.removeViewInLayout(null);
Which also doesnt works.
Code:
package com.mycompany.myapp;
import android.content.res.*;
import android.view.*;
import android.widget.*;
import de.robv.android.xposed.*;
import de.robv.android.xposed.callbacks.XC_LoadPackage.*;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
public class main implements IXposedHookLoadPackage {
public static final String CLASS_RECENT_PANEL_VIEW = "com.android.systemui.recent.RecentsPanelView";
private static ImageView mRecentsClearButton;
private static ImageView mgoogle;
private static ImageView mtasker;
//private static Field fieldAnimateScreenLights;
public static final String PACKAGE_NAME = "com.android.systemui";
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
if (!lpparam.packageName.equals(PACKAGE_NAME))
return;
findAndHookMethod( CLASS_RECENT_PANEL_VIEW , lpparam.classLoader, "onFinishInflate", new XC_MethodHook() {
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
View view = (View) param.thisObject;
Resources res = view.getResources();
// GM2 already has this image view so remove it if exists
// create and inject new ImageView and set onClick listener to handle action
mRecentsClearButton = (ImageView) view.findViewById(res.getIdentifier("clear_all_button", "id", PACKAGE_NAME));
mRecentsClearButton.setClickable(true);
mRecentsClearButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ViewGroup mRecentsContainer = (ViewGroup) XposedHelpers.getObjectField(
param.thisObject, "mRecentsContainer");
// passing null parameter in this case is our action flag to remove all views
mRecentsContainer.removeAllViewsInLayout();
}
});
mgoogle= (ImageView) view.findViewById(res.getIdentifier("mgoogle", "id", PACKAGE_NAME));
mgoogle.setClickable(true);
mgoogle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
mtasker= (ImageView) view.findViewById(res.getIdentifier("mtasker", "id", PACKAGE_NAME));
mtasker.setClickable(true);
mtasker.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
});
}
}
Mtasker and mgoogle's onclick listener are empty because they are wip
Sent from my GT-S5570 using XDA Premium 4 mobile app
Log.sorry cant provide better one
Sent from my GT-S5570 using XDA Premium 4 mobile app
@arpitkh96
removeAllViews()
try calling above method on mRecent.....
this should work!
Sent from my GT-S5302 using Tapatalk 2
sak-venom1997 said:
@arpitkh96
removeAllViews()
try calling above method on mRecent.....
this should work!
Sent from my GT-S5302 using Tapatalk 2
Click to expand...
Click to collapse
Same error.
Problem is something else
Sent from my GT-S5570 using XDA Premium 4 mobile app
arpitkh96 said:
Same error.
Problem is something else
Sent from my GT-S5570 using XDA Premium 4 mobile app
Click to expand...
Click to collapse
try checking for mRecen.... != null
Sent from my GT-S5302 using Tapatalk 2
Do you mean
if(mRecentContainor!=null){mRecentsContainor.removeallView()}
Sent from my GT-S5570 using XDA Premium 4 mobile app
arpitkh96 said:
Do you mean
if(mRecentContainor!=null){mRecentsContainor.removeallView()}
Sent from my GT-S5570 using XDA Premium 4 mobile app
Click to expand...
Click to collapse
yes just to ensure the feild isnt null though i think its not !
Sent from my GT-S5302 using Tapatalk 2
sak-venom1997 said:
yes just to ensure the feild isnt null though i think its not !
Sent from my GT-S5302 using Tapatalk 2
Click to expand...
Click to collapse
Didn't work
Sent from my GT-S5570 using XDA Premium 4 mobile app

[GUIDE][COOLTOOL] Display CPU + GPU temperatures in statusbar (no root/xposed needed)

Hi friends, as i see people complaining about temperature but they dont know the actual cpu temperature (and the people like me who wants to do extensive monitoring on top of all apps) , i decided to write an easy to follow guide on how to monitor these temperatures in statusbar.
You need cooltool from playstore installed, no root or xposed is needed for this operation.
i configured my statusbar to show as less as possible in cooltool, so only CPU usage, CPU0, CPU1 and GPU temperatures will be displayed after following these steps.
These steps may apply for other devices too, but please note that the sysfs paths may differ from device to device and even from android version to another.
1. Open up cooltool and swipe to the second tab ''labels''.
2. Make sure CPU usage, Custom Label 1, Custom Label 2, and Custom Label 3 are ticked and the rest is unticked.
3. Hit ''Fine Tuning'' below
4. Hit ''Custom Label 1'' and configure like this:
Code:
Prefix: G1:
Postfix:
Path: /sys/devices/virtual/thermal/thermal_zone12/temp
Regex: (\d+)
Replacement Pattern: $1
5. Hit ''Custom Label 2'' and configure like this:
Code:
Prefix: C1
Postfix:
Path: /sys/devices/virtual/thermal/thermal_zone7/temp
Regex: (\d+)
Replacement Pattern: $1
6. Hit ''Custom Label 3'' and configure like this:
Code:
Prefix: C2
Postfix:
Path: /sys/devices/virtual/thermal/thermal_zone13/temp
Regex: (\d+)
Replacement Pattern: $1
7. Hit ''OK''
Now it should show in statusbar, if not, hit ''Show Panel''.
You can theme it to your likings and align it in the spot that suits u best via the various sliders and settings, just play with it.
Additionally, u can disable notification via settings>apps>cooltool>notifications
If all done, things should look like attached screenshots.
G1 = GPU temperature
C1 = CPU0 temperature
C2 = CPU1 temperature
Thank you!
Xperia Z5 E6653 w/ Tapatalk
how about cpu freq avg ?
Thermal engine table detail
RyTekk said:
Thermal engine table detail
Click to expand...
Click to collapse
I found something online for our 810 dragon sensor mapping. I think OP's mapping is correct here.
See the link below, there is a link to our 810 mapping.
https://developer.qualcomm.com/forum/qdn-forums/software/snapdragon-profiler/29435
viperc said:
I found something online for our 810 dragon sensor mapping. I think OP's mapping is correct here.
See the link below, there is a link to our 810 mapping.
https://developer.qualcomm.com/forum/qdn-forums/software/snapdragon-profiler/29435
Click to expand...
Click to collapse
Yah, I didn't tell OP was wrong, I just post the detail for who are interested in it
RyTekk said:
Yah, I didn't tell OP was wrong, I just post the detail for who are interested in it
Click to expand...
Click to collapse
:good: there's a lot of sensor information in that link also. Sharing it so maybe someone will find them useful
RyTekk said:
Thermal engine table detail
Click to expand...
Click to collapse
Yeah there's some information in /sys/module/msm_thermal/sensor_info too but I asked @Tommy-Geenexus for confirmation and I trust him.
Sent from my E6653 using XDA-Developers mobile app
langeveld024 said:
Yeah there's some information in /sys/module/msm_thermal/sensor_info too but I asked @Tommy-Geenexus for confirmation and I trust him.
Sent from my E6653 using XDA-Developers mobile app
Click to expand...
Click to collapse
I took from sonydevxperia's github so it should be right, and the link to CAF above also point out exactly as mine.
RyTekk said:
I took from sonydevxperia's github so it should be right, and the link to CAF above also point out exactly as mine.
Click to expand...
Click to collapse
You should not trust the Open-Source Sony AOSP more than Qualcomm Engineers (in general you should not trust anyone involved in the Sony AOSP project too much )
Tommy-Geenexus said:
You should not trust the Open-Source Sony AOSP more than Qualcomm Engineers (in general you should not trust anyone involved in the Sony AOSP project too much )
Click to expand...
Click to collapse
LOL thanks for your words :laugh:. Btw, do you know how to fix "make [1] nothing to be done for "dtbs""? Maybe we'll talking via PM or something that I can contact with you for not to off-topic
RyTekk said:
LOL thanks for your words :laugh:. Btw, do you know how to fix "make [1] nothing to be done for "dtbs""? Maybe we'll talking via PM or something that I can contact with you for not to off-topic
Click to expand...
Click to collapse
Nothing to be fixed there, it works properly. No changes to dtb's, no recompilation needed.
You try to getting into Kernel hacking?
If you need assistance, mail me or drop me a pm.
RyTekk said:
for not to off-topic
Click to expand...
Click to collapse
I don't mind a bit off-topic in my threads
Sent from my E6653 using XDA-Developers mobile app
langeveld024 said:
I don't mind a bit off-topic in my threads
Sent from my E6653 using XDA-Developers mobile app
Click to expand...
Click to collapse
Bro, help me, one of them didnt work. I tried to used your guide on my z5 premium.
Oohhlala said:
Bro, help me, one of them didnt work. I tried to used your guide on my z5 premium.
Click to expand...
Click to collapse
Which one doesn't work?
Sent from my E6653 using XDA-Developers mobile app
langeveld024 said:
Which one doesn't work?
Sent from my E6653 using XDA-Developers mobile app
Click to expand...
Click to collapse
C1 didnt show the temp
Oohhlala said:
C1 didnt show the temp
Click to expand...
Click to collapse
Can u be a bit more specific? What did it show then?
Sent from my E6653 using XDA-Developers mobile app
langeveld024 said:
I don't mind a bit off-topic in my threads
Sent from my E6653 using XDA-Developers mobile app
Click to expand...
Click to collapse
langeveld024 said:
Can u be a bit more specific? What did it show then?
Sent from my E6653 using XDA-Developers mobile app
Click to expand...
Click to collapse
C1 show !IO. Z5 and z5 premium have 4 cores cpu. How to show temp of all. Thanks
Oohhlala said:
C1 show !IO. Z5 and z5 premium have 4 cores cpu. How to show temp of all. Thanks
Click to expand...
Click to collapse
Then u didn't fill in the regex field. (\d+)
U have to fill in exactly as mentioned in OP.
Also, since COOLTOOL only allows for setting 3 custom labels, we can't set up temperature per core. But does it matter? No. Important thing is to check cpu0 and cpu0 and GPU.
Sent from my E6653 using XDA-Developers mobile app
Perfect! Thank you

Categories

Resources