Tuesday, 29 October 2013

Battlefield 3 for free - legal

Aktywując klucz G433-XWLD-ZBW8-JWUC-JDSW dostajemy na Originie darmowego Battlefielda 3. Kod zadziała każdemu, nie jest jednorazowy.

Use this key till midnight and you will get legal BC3.
Reference to this info: link

Thursday, 10 October 2013

Excercise question for DEV Android, are you able solve the problem?

John created own lazyAdapter. His constructor had 3 arguments, first is for activity and the last two are for storing data. John decided add new elments by on his own.

John wanted first clear lazyAdapter's data and then add by his addItem method new items.

After compilation he noticed that something gone wrong. Images loaded correctly but somehow titles were not right.

Fields: images are storing urls in String, titles are storing titles of something in String.

Q:Can you figure out what was in title's text?

Q:What was causing the problem?

Q:How many elements will be in adapter in array titles after calling getView?

Picture #1

Picture #2

Monday, 7 October 2013

System UI has stopped working - probably solution for CyanogenMod

Here is one of the most topics about this bug LINK
I'm using S3 mini, I changed base wallpaper to another my own without any features. Just simple wallpapaper which was just screenshot of my phone. Seems it fixed the problem so far...
Just make sure you made reboot just for in case.

Thursday, 3 October 2013

Noobroom Latest Additions apk for Android

Here is my private project. I'm planing add to apk ability like watching movies.
This app can checks what was added recently and shows it with poster preview.


Loading can take quite long to parse, but it works. Sorry for that.
This long loading is because the app parses titles every time you run it.
Images are loaded once. When each of them is downloaded, it will be loaded only from cache then.
In this way server won't be too much overloaded.

Wednesday, 2 October 2013

Parsing html elements to readable string

Lets say we have title in html page : Big & small
Our target is get this result in textView: Big & small
Solution is to use: Html.fromHtml(String string)
Example: Html.fromHtml("Big & small")
In any problem you can cast .toString() after but I think it is not urgent.

Android 2.x.x not showing hint text in edittext

Here is the solution, add to xml:
android:ellipsize="end"

OnBackPressed for fragments

Here is one of most common problems which is connected with onBackPressedFunction - how to implement onBackPressed() in Android Fragments?

And here is also my solution by using listeners to handle custom onBackPressed

According to @HaMMeRed answer here is pseudocode how should it works.
Lets say that your main activity is called BaseActivity (like in SlidingMenu example).
Here are the steps:

First we need create interface and class which implements its interface to have generic method

-1. Create class interface OnBackPressedListener

 public interface OnBackPressedListener {  
   public void doBack();  
 }  

0. Create class which implements skills of OnBackPressedListener

 public class BaseBackPressedListener implements OnBackPressedListener {  
   private final FragmentActivity activity;  
   public BaseBackPressedListener(FragmentActivity activity) {  
     this.activity = activity;  
   }  
   @Override  
   public void doBack() {  
     activity.getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);  
   }  
 }  

Since now, we will work on our code BaseActivity and its fragments..

1. Create private listener on top of your class
   
 protected OnBackPressedListener onBackPressedListener;  

2. Create method to set listener

 public void setOnBackPressedListener(OnBackPressedListener onBackPressedListener) {  
   this.onBackPressedListener = onBackPressedListener;  
 }  

3. In Override onBackPressed implement something like that

 @Override  
 public void onBackPressed() {  
   if (onBackPressedListener != null)  
     onBackPressedListener.doBack();  
   else  
     super.onBackPressed();  

4. in your fragment in onCreateView you should add our listener

 @Override  
 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {  
   activity = getActivity();  
   ((BaseActivity)activity).setOnBackPressedListener(new BaseBackPressedListener(activity));  
   View view = ... ;  
 //stuff with view  
   return view;  
 }  

Now if you click back button listener should find custom class with custom onBackPressed reaction