FRUSTRO typeface

Posted by Unknown Senin, 26 Maret 2012 0 komentar
Today I've met one very interesting typeface. Its name FRUSTRO and it was created by designer Martzi Hegedűs with an idea of impossible objects in mind.
Impossible objects from Wikipedia:
An impossible object (also known as an impossible figure or an undecidable figure) is a type of optical illusion consisting of a two-dimensional figure which is instantly and subconsciously interpreted by the visual system as representing a projectionof a three-dimensional object although it is not geometrically possible for such an object to exist (at least not in the form interpreted by the visual system).
In most cases the impossibility becomes apparent after viewing the figure for a few seconds. However, the initial impression of a 3D object remains even after it has been contradicted. There are also more subtle examples of impossible objects where the impossibility does not become apparent spontaneously and it is necessary to consciously examine the geometry of the implied object to determine that it is impossible.


Do not hurry, find a moment to scan every FRUSTRO letter!


Baca Selengkapnya ....

Android: possible issues & solutions with configuration changes, part 2

Posted by Unknown Senin, 05 Maret 2012 0 komentar
Hello! Last time I was quite busy by creation of very cool and dynamic Android application for one of the world's largest mobile telecommunications company.
That is why the second part of the article about possible issues & solutions with configuration changes is coming only now. To be familiar with the topic I recommend you to read the first part of this article.

And now I want to share with you my solution for the mentioned topic. It's easy to use and it solves the task! This solution was evoked by Adobe Flex event model. As you may know I have extensive experience with Adobe Flex (it's Adobe's framework for creating Rich Internet Application). And one of the coolest Adobe Flex feature is its powerful event model. In general all Adobe Flex is event-driven, which gives us the perfect environment for creating loosely coupled components and system.

The same approach I wanted to apply in Android development.
The core idea of my solution is to have some kind of event bus:


















Ah no, not like this! I am joking! :D
The event bus we will have can be used to post results and subscribe to results of some specified event type. Thereby we will have loosely coupled system: components can notify and be notified by other components even without knowledge about each other.

So, let's take a look at this approach by example.
Imagine the common situation: you should make some work in the background thread. When a background task is completed you want to notify the caller about it.
How do we handle it with the suggested solution? Fairly simple!
1) define some event name, e.g. STOCKS_UPDATED
2) add a listener (which is a realization of EventCallback interface) to that event:
EventBus.subscribe(STOCKS_UPDATED, stocksCallback);
3)just post the result from the background task, when you want to notify listeners about some events (e.g. in onPostExecute method of some AsyncTask):
EventBus.postResult(STOCKS_UPDATED, result);
That's all! As you can see you can wire up your application components with minimum lines of code in an easy and reliable way!

Few notes:
a) you can add as many event listeners as you want
b) if you don't need listener anymore, just remove it:
EventBus.unsubscribe(STOCKS_UPDATED, mStocksCallback);
c) BaseEventResult is a base class for events results. It already has status and data fields.
If needed you can extend it to carry any kind of data you like. Or just subclass BaseEventResult to more specifiс event results (e.g. StockResult, BondResult, etc.)
d) if you keep event listeners as an Activity fields, then, as you already know, they will be destroyed with Activity itself when configuration changes occurs. To handle it: just add a listener at onResume and remove it at onPause.
@Override
protected void onResume() {
super.onResume();
EventBus.subscribe(STOCKS_UPDATED, mStocksCallback);
}

@Override
protected void onPause() {
EventBus.unsubscribe(STOCKS_UPDATED, mStocksCallback);
super.onPause();
}


I've prepared a sample project that demonstrates usage of my EventBus solution. You can download it here.

While this approach may be not perfect, I think it is quite good, because of it covers most of the common issues with configuration changes. Also it's very easy to use and highly extensible! Feel free to use it or share your thoughts about it with me! ;-)


Baca Selengkapnya ....

Android: better way to apply custom fonts

Posted by Unknown Senin, 27 Februari 2012 0 komentar

In one application I had to apply customer's brand font for all controls of the user interface.
Sounds like a pretty common task, right? Yeah, I was thinking the same.
But then I was surprised that Android doesn't provide simply and elegant way to do this.

So, in this article I will show you what Android provides us by default. Then I will share with you my solution, which allows you to apply custom fonts in a more simple and elegant way.

Situation:
you have a custom font that should be applied for entire application screen.

Solution:
1) Android's default #1:
You can refer by id view controls, and apply typeface for each of them. In case of one view it looks not so scary:
Typeface customFont = Typeface.createFromAsset(this.getAssets(), "fonts/YourCustomFont.ttf");
TextView view = (TextView) findViewById(R.id.activity_main_header);
view.setTypeface(customFont);
But in case of many TextView, Buttons, etc. view at your screen you will not love this approach, I can assure you! :D

2) Android's default #2:
You can create subclass for each TextView, Button, etc. and apply custom font in the constructor:
public class BrandTextView extends TextView {

public BrandTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public BrandTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public BrandTextView(Context context) {
super(context);
}
public void setTypeface(Typeface tf, int style) {
if (style == Typeface.BOLD) {
super.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/YourCustomFont_Bold.ttf"));
} else {
super.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/YourCustomFont.ttf"));
}
}
}

Then just use that custom views instead of standard ones (i.e. BrandTextView instead of TextView).
<com.your.package.BrandTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="View with custom font"/>
<com.your.package.BrandTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="View with custom font and bold typeface"/>
Also, you can even add your own attribute to set required font directly via XML. To make you will need to define your own declare-styleable attributes and parse attributes in the constructor.
In order not to describe the basic things, I just point for a good article by Kevin Dion with an
example of custom attributes implementation:
http://kevindion.com/2011/01/custom-xml-attributes-for-android-widgets/

In general solution #2 not so bad and has it's own advantages (for example, to switch between regular, bold, etc. fonts based on specified "typeface" attribute value). But in my opinion it's still too heavy and requires a lot of boilerplate-code for such a simple task as applying custom font.

3) My solution:
the ideal solution would be to define custom theme and apply it to entire application or Activity.
But unfortunately Android's android:typeface attribute can only use inbuilt fonts, but not the custom fonts (e.g. from the assets). That is why we can't get away from the loading and applying fonts at runtime in Java code.
So I decided to create a helper class to make it as simple, as possible.
The usage of it looks like:
FontHelper.applyFont(context, findViewById(R.id.activity_root), "fonts/YourCustomFont.ttf");
And this one string will apply custom font for all TextView based controls (TextView, Button, RadioButton, ToggleButton, etc.) at your screen regardless of their layout hierarchy! ;-)
Standard (left) and Custom (right) fonts usage.

How this was done? Fairly simple:
public static void applyFont(final Context context, final View root, final String fontName) {
try {
if (root instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) root;
for (int i = 0; i < viewGroup.getChildCount(); i++)
applyFont(context, viewGroup.getChildAt(i), fontName);
} else if (root instanceof TextView)
((TextView) root).setTypeface(Typeface.createFromAsset(context.getAssets(), fontName));
} catch (Exception e) {
Log.e(TAG, String.format("Error occured when trying to apply %s font for %s view", fontName, root));
e.printStackTrace();
}
}
As you can see there is nothing more then looking for TextView based views at all levels of layout hierarchy.
You can download sample project with usage of FontHelper here.



Baca Selengkapnya ....

Android: possible issues & solutions with configuration changes, part 1

Posted by Unknown Rabu, 15 Februari 2012 0 komentar

In this article I want to review the situation that occurs in the development of almost every Android application, the problems that may arise, as well as solutions to handle them.

Situation:
your application needs to receive some data via network from the back-end.

For example, user goes to some screen, appropriate Activity object initiates a network call to request XML or JSON data to parse it and show in the UI. So, typical implementation scheme could be:
in a separate thread (to prevent UI blocking) make HTTP request, receive response and parse it. When thread has finished the task, you need to notify someone (usually the caller, or Activity) that data was received and ready to be shown.

Usually, you can meet implementation with AsyncTask (as a worker thread) that has a reference to a caller Activity or some callback object. And this will work without issues until the device configuration changes.

Problem:
when the configuration of the device changes, then you may find unexpected behavior and even crashes (for example, if you will try to dismiss progress dialog at onPostExecute method of the AsyncTask object). Why? Unless you specify otherwise, a configuration change (screen orientation, input devices, language, etc) will cause your current Activity to be destroyed, going through the normal activity lifecycle process. This is done because any application resource, including layout files, can change based on any configuration value.

So, if your current Activity was destroyed and re-created, while the worker thread was active, then at worker thread completion moment you will have non actual references to a caller Activity, callback, etc.
The key questions is: how to guarantee, that worker thread will have valid return point reference at the moment of completion?


Solutions:
While, described problem is very common, Android doesn't suggest one proven and proper way to handle it. So, I will show several possible solutions with their pros and cons.

1) android:configChanges="orientation"
This is the simplest and... definitely not the best solution.
All you need to do is to add to the activity declaration in the manifest attribute "android:configChanges" and specify configuration changes types you want to handle by yourself. For example:
     <activity
            android:name=".activity.HomeActivity"
            android:label="@string/home_name"
            android:configChanges="orientation"/>
But, handling the configuration change by yourself can make it much more difficult to use alternative resources, because the system does not apply them for you automatically. So, according to Android team recommendation, this technique should be considered a last resort when you must avoid restarts due to a configuration change and it is not recommended for most applications.

2) retaining an object during a configuration change
Activity has well defined lifecycle and we can retain some state object between runtime configuration change. So, you may override onRetainNonConfigurationInstance method to return the object, that keeps references to running worker instances (e.g. AsynTask objects). Then when your activity is created again, call getLastNonConfigurationInstance to recover your state object and update AsyncTask's references to caller, callback, etc.
You can read more about it here:
http://developer.android.com/guide/topics/resources/runtime-changes.html
Also, onRetainNonConfigurationInstance/getLastNonConfigurationInstance pair is useful to retain and restore partially downloaded data (instead of re-fetch the data from the scratch).
While this approach works pretty well, I don't like that I had to define a class for state object that keeps references to running AsyncTask instances and all other stuff.

3) Ordered Broadcast and IntentService
This approach is well described by Murk Murphy (author of the great "The Busy Coder’s Guide to ..." books series). So give a word to him:
http://commonsware.com/blog/2010/08/11/activity-notification-ordered-broadcast.html

4) Event Bus
This approach was designed by me, while I was thinking about easy to use solution, to be notified when some background task becomes completed. The powerful and easy to use event dispatching model of Adobe Flex was an inspiration. I will describe this approach in details in the second part of this article. It will come soon, so be in touch! ;-)



Baca Selengkapnya ....

Happy New Year 2012, my friends!

Posted by Unknown Sabtu, 31 Desember 2011 0 komentar

Yeah, New Year 2012 has come! And I am pretty happy with this, because I can say honestly "2011 year, you were a nice time, full of great events, ideas and changes both in my personal and professional lives. Thank you for everything, take rest now".

So, 2012 year of the Dragon is here, and I am sure - it will be amazing and sooooo cool, as a dragon is! ;-)





Baca Selengkapnya ....

Adobe Flex: useful stuff for mobile development, part 2

Posted by Unknown Selasa, 13 Desember 2011 0 komentar
This is the second part of my post about Adobe Flex usage at mobile platforms.
In this post I want to show you several good sample projects of Adobe Flex usage on mobile platforms. All of them have source codes available for download. So if you're interested in cross-platform application creation with Adobe Flex this is a good way for a quick dive! ;)

Adobe engineers team has made a great progress with AIR runtime, and now Adobe Flex applications on mobile platforms (Android, iOS, etc.) show good performance and list of available features. At the same time, evangelists team has prepared a bunch of demo projects for popularizing of Adobe Flex as technology for cross-platform development.


Expense tracker application





The Expense Tracker Reference Application is a sample application created with Flex 4.6. It will introduce you to the major updates in the Flex 4.6 SDK, and demonstrate best practices for designing and developing a CRUD-based experience for mobile, tablet, and web platforms. The three Flex 4.6 Reference Applications use the ViewNavigatorApplication class as an application base for screen management, the ItemRenderer and LabeltItemRenderer/IconItemRenderer classes for list controls, and the MultiDPIBitmapSource and RuntimeDPI providers as means to manage different DPIs on different devices.
More info and source code:


Shopping cart application























The Shopping Cart Reference Application is a sample application created with Flex 4.5. It will introduce you to the major updates in the Flex 4.5 SDK, and demonstrate best practices for designing and developing a shopping experience for both mobile and web platforms. The three Flex 4.5 Reference Applications use the ViewNavigatorApplication class as an application base for screen management, the ItemRenderer and LabeltItemRenderer/IconItemRenderer classes for list controls, and the MultiDPIBitmapSource and RuntimeDPI providers as means to manage different DPIs on different devices.
More info and source code:
http://www.adobe.com/devnet/flex/samples/shopping-cart-application.html


Sales dashboard application























The Sales Dashboard Reference Application is a sample application created with Flex 4.6. It will introduce you to the major updates in the Flex 4.6 SDK, and demonstrate best practices for designing and developing an enterprise sales dashboard experience for mobile, tablet, and web platforms. The three Flex 4.6 Reference Applications use the ViewNavigatorApplication class as an application base for screen management, the ItemRenderer and LabeltItemRenderer/IconItemRenderer classes for list controls, and the MultiDPIBitmapSource and RuntimeDPI providers as means to manage different DPIs on different devices.
More info and source code:
http://www.adobe.com/devnet/flex/samples/sales-dashboard-application.html


Sample application for tablet with latest Flex 4.6 components





















The Flex 4.6 SDK features used in the application are:
  • SplitViewNavigator with state handling (uses new properties to put the first view in a Callout when in portrait mode due to screen space)
  • New Callout component
  • New CalloutButton component
  • New SpinnerList component (and corresponding SpinnerListContainer)
  • New ToggleSwitch component
  • Dynamic Splash Screen
  • Soft Keyboard Type handling (showing the numeric soft keyboard for example)
More info and source code:
http://devgirl.org/2011/10/31/flex-mobile-development-building-tablet-apps-full-example-with-source-code/


Game of Flex for tablets























If you want to check the source code of the app, you’ll learn:
  • How to use the new SplitViewNavigator architecture (portrait and landscape layouts on tablet devices)
  • How to display HTML content inside a Flex app
  • How to access the camera to take pictures
  • How to use the BusyIndicator, ToggleSwitch and List components
  • How to enable multi-touch
  • How to manage your views
  • How to use the accelerometer
  • How to create custom AS3 item renderers for your lists
  • How to access the local SQLite database
  • How to use native extensions
  • How to set up the new DateSpinner component
  • How to display callout popups
  • How to set up the software keyboard to match your needs
  • How to declare spinner lists
More info and source code:
http://www.riagora.com/2011/12/game-of-flex-on-tablets/



Blue Chips application





















The application demonstrates extensive usage of chart components and new Flex 4.6 components that target tablet development.
Description and video:
http://www.riaspace.com/2011/12/flex-4-6-bluechips-demo/
Source code:
https://github.com/pwalczyszyn/BlueChips


When you will start creation of your own mobile application with Adobe Flex, don't forget about performance optimization. It's quite important to provide responsive user interface with seamless interaction.
There is an article that will be quite useful for that purpose:
Flex mobile performance checklist

Have fun! :)


Baca Selengkapnya ....

Adobe Flex: useful stuff for mobile development, part 1

Posted by Unknown Sabtu, 10 Desember 2011 0 komentar
About one week ago Adobe released Flex SDK 4.6 and Flash Builder 4.6. The main goal of these releases was mobile and especially tablet development. And in this post I want to share some stuff that will inspire and motivate you for mobile development with Adobe technologies.

As the official Adobe blog says, the Flex 4.6 release was built on the mobile capabilities introduced in Flex 4.5, enabling you to:
  • create tablet apps with multiple views and adaptive layouts
  • use new tablet focused UI components, including Callout, SpinnerList, and ToggleButton controls
  • add text inputs with OS-specific interfaces and interactions to your apps
  • package AIR runtime with your application
  • have better integration and usage of ActionScript Native Extensions
In my opinion one of the coolest features is Adobe AIR Captive runtime. Why? Because the ability to package AIR runtime with your application into one file (APK for Android, IPA for iOS, etc.) guarantees the ability to run Flash/Flex/AIR applications and games in proper runtime.

ActionScript Native Extentions is also a great feature. It's a bridge between your Flex mobile app and a native library that can extend the capabilities of the Flex SDK. You can find a list of native extensions such as Notifications, Vibration, Gyroscope API, etc. here:

Also Flex 4.6 contains several new Spark components which will be especially useful in the mobile development for tablet devices:

SplitViewNavigator
One of the most common uses of SplitViewNavigator is the creation of User Interface screen based on a design pattern known as Master/Detail. 























Callout and CalloutButton
The component extends SkinnablePopUpContainer, inherits its all functionality and provides a relatively positioned arrow. This fully skinnable component can contain any kind of content, from a group of components to entire Views.
Figure 2. A basic Callout.


SpinnerList and DateSpinner, that components look & feel are very similar to native iOS spinner components.
Figure 4. The SpinnerList component.

Figure 5. The DateSpinner control.


ToggleButton










Soft Keyboard Parameters
Soft Keyboard Parameters allows you to modify the look of your mobile/tablet soft keyboard to display the best layout for specific text input format: number, email, punctuation, url, contact or default. For example, if you have text input for ZIP code, you can write something like that:
<s:TextInput softKeyboardType="number"/>


In the second part of that article I will show you several examples of nice mobile and cross-platform applications built with Adobe Flex. Many of them are open sourced, so you will be able to investigate their code to improve your skills. See u! ;-)






Baca Selengkapnya ....
Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of android illegal.