[Q] Something I don't understant about "Avoid Creating Objects". - Android Software Development

Hello,
I've reading the topic About Avoid Creating Objects in Designing for performance for android and says:
When extracting strings from a set of input data, try to return a substring of the original data, instead of creating a copy. You will create a new String object, but it will share the char[] with the data.
I don't understand it. Maybe I have to get a book of java, jeje.
Well, it's difficult to find information about this paragraph.
Could you write an example or explain it?
Thank you.

How I understand your quote, it works like show in this image:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
The above method is the suggested one. Here the returned substring of the original string still points internally to the original char[] array so there is no memory wasted.
In the second method a (shortened) copy of the original string is made, so you are wasting (in this example) 6 more bytes of memory.

Thank you.
Now I understand. In the better option you reuse the same array. So there is no need to create a new object.

Related

Good (splashscreen) idea for changing your SplashScreen

Yesterday I was browsing the Wizard area of the XDA FTP server and I bumped into a file called SplashscreenStuff.zip
So I downloaded it, read the ReadMe file and thought, this looks kinda easy, let's see if it's possible to change my SplashScreen (on a 2.18 Qtek Rom).
So I opened Photoshop looked at some existing splashscreen's and adjusted one to make it "my own".
The funny thing is, this SplashScreen can be useful if your device gets stolen (it is shown about 20 seconds on start-up on my device).
Take a look at it and if someone is interested in the Photoshop file, to adjust it to make it yours, feel free to leave a message here and I will make sure you get all the files you need.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Regards,
Molski
Anti theft tattoo ?
I would really like to know if this can really work as a anti-theft strategy. At worst, the "finder" of the device can flash a new ROM, can't he? Is there any really anti-theft strategy?
the picture is not displayed!!! why??
How can I make my own splashscreen?
try this thread
The tools are old, and they have been ported to ROM-kitchens also, but they do work.

[UTILITY]ApkManager (apkm) rework of AndroidSuite2012

Apkm (Apkmanager)
As a lot of features in AndroidSuite2012 were not used by the actual user I decided to release a single tool dedicated for decompiling apk's.
It has the same simple to use GUI as AndroidSuite but with less confusing buttons and a much lighter package.
The check box options are not yet implemented this is a alpha I was working on and decided to pull it from my dropbox and release.
Enjoy! Download below
PS Apktool might need replacing. Tomorrow I will update with the same method for decompiling used in AS2012.
apkm (ApkManager)
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
DOWNLOAD​​
Tutorial​
Visit slethen.net for more information on this tool and other things I've done
Hi I installed your great tool but I get this message
Error: Unable to access jarfile G:\ANDROID
What should I do to get away
Taxi341 said:
Hi I installed your great tool but I get this message
Error: Unable to access jarfile G:\ANDROID
What should I do to get away
Click to expand...
Click to collapse
This is normally caused if theres a space in the name of the folder. Make sure its not in a folder with a space in the name. Although I've never seen it say \ANDROID. Could you screen shot the program? And remember you need jre installed

[Library] GrilledUI

GrilledUI is a library to implement common UIs easily. Available UI types are: tabbed UI (TabActivity), master/metail flow (SectionActivity) and their hybrid (HybridActivity). These activity classes wrap everything you need to create your UI with just a few lines of code or even load tabs/sections and instaniate fragments from XML file. HybridActivity allows you to have tabs on phones and MDF on tablets. This way you can easily make your app tablet and phone friendly without torturing phone users with multiple activities.
Library comes with JavaDocs, multiple examples, in open source form, 2-clause BSD license and pre-ICS support (!). Pre-ICS devices are supported with the help of ActionBarSherlock.
GrilledUI lives on GitHub.
A small preview of what is possible:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Great, will take a look it.
Edit: I by mistake wrote is it possible to keep app in memory.
Sent from my SGS3
Akshay (Aky) said:
Great, will take a look it.
Is it possible to keep app in memory
Sent from my SGS3
Click to expand...
Click to collapse
What do you mean by keep app in memory?
have a look
have a look

{guide} better smali coding notepad++

smali syntax highlighting for notepad++​thanks to Jho for pointing out how to get code folding to work. i updated the syntax file and made a few other tweaks. the link and picture have been updated and here are the instructions for installing (tested with v5.9.6.1):
View -> User-Defined Dialogue...
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Click Import
Select smali_npp.xml
no picture here, use imagination
There will be a message box that says "Import successful."
Any new files you open should have syntax highlighting.
several people have asked for smali highlighting for notepad++. thanks to furrelkt for having already sent me an example. here's what i've come up with: https://sites.google.com/site/lohanplus/files/smali_npp.xml
for dark backgrounds, try this: https://sites.google.com/site/lohanplus/files/smali_npp_darkbg.xml
there are many limitations for notepad++'s user defined language. i could not get many tokens to highlight correctly, or as well as ultraedit or the highlighter used on this blog. perhaps a full lexer plugin could handle it. if you write one or make improvements to this xml, let me know.
iif i help u plz hit thanks button
Thanks for this, tested in lastest version of Notepad++ (6.6.3) and working!
In this version to import go to "language>define your language>import"
Thank you very much! ^^
Thank you! Tested on v7.5 working

[Question] Chinese watch face "line based" frames structure

hi,
I've try to understand watch face structure, but stuck on frame decoding. can anybody help me to figure out how it works?
at this time I can allocate frames and it's lines, seems figure out with palette, but cant understand line construction.
I wrote a little app to display data a bit more representative, so for sample:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
in frame definition it have a two bytes what I have a smooth understanding ("09" and "03" at screen).
seems first ("09") defines a palette type (1,2 - no palette), and second means a coding type. (0 is a plain, 3 is a some sort of compression)
so plain frames are ok, but I can't understand compressed lines.
as I understood, first 12 bits (1.5 byte) of a line, is a some count <= frame width. pixels defines as color id in one byte, but that's all.
can anyone help me figure it out?
app and few wf'ses are attached in zip
n.m. figured out:

Categories

Resources