Friday, May 9, 2014

English Grammar Preposition

A preposition is a word governing, and usually coming in front of, a noun or pronoun and expressing a relation to another word or element,as in:
  1. She left before breakfast.
  2. What did you come for?
    (For what did you come?)

English Grammar Preposition List

There are about 150 prepositions in English. Yet this is a very small number when you think of the thousands of other words (nouns, verbs etc). Prepositions are important words. We use individual prepositions more frequently than other individual words. In fact, the prepositions of, to and in are among the ten most frequent words in English. Here is a short list of 70 of the more common one-word prepositions. Many of these prepositions have more than one meaning. Please refer to a dictionary for precise meaning and usage.
1. aboard 2. about 3. above 4. across
5. after 6. against 7. along 8. amid
9. among 10. anti 11. around 12. as
13. at 14. before 15. behind 16. below
17. beneath 18. beside 19. besides 20. between
21. beyond 22. but 23. by 24. concerning
25. considering 26. despite 27. down 28. during
29. except 30. excepting 31. excluding 32. following
33. for 34. from 35. in 36. inside
37. into 38. like 39. minus 40. near
41. of 42. off 43. on 44. onto
45. opposite 46. outside 47. over 48. past
49. per 50. plus 51. regarding 52. round
53. save 54. since 55. than 56. through
57. to 58. toward 59. towards 60. under
61. underneath 62. unlike 63. until 64. up
65. upon 66. versus 67. via 68. with
69. within 70. without ... ...

English Grammar Preposition Rules

There is one very simple rule about prepositions. And, unlike most rules, this rule has no exceptions.
Rule
A preposition is followed by a "noun". It is never followed by a verb.
By "noun" we include:
  1. noun (dog, money, love)
  2. proper noun (name) (Bangkok, Mary)


  • pronoun (you, him, us)
  • noun group (my first job)
  • gerund (swimming)
  • A preposition cannot be followed by a verb. If we want to follow a preposition by a verb, we must use the "-ing" form which is really a gerund or verb in noun form. In the following sentences, why is "to" followed by a verb? That should be impossible, according to the above rule:
    I would like to go now.
    She used to smoke. Here are some examples:
    Subject + verb preposition "noun"
    The food is on the table.
    She lives in Japan.
    Tara is looking for you.
    The letter is under your blue book.
    Pascal is used to English people.
    She isn't used to working.
    I ate before coming.

    Answer to Quick Quiz: In these sentences, "to" is not a preposition. It is part of the infinitive
    ("to go", "to smoke").
    Prepositions of Place:
    at, in, on
    In general, we use:
    1. at for a POINT
    2. in for an ENCLOSED SPACE
    3. on for a SURFACE
    at in on
    POINT ENCLOSED SPACE SURFACE
    at the corner in the garden on the wall
    at the bus stop in London on the ceiling
    at the door in France on the door
    at the top of the page in a box on the cover
    at the end of the road in my pocket on the floor
    at the entrance in my wallet on the carpet
    at the crossroads in a building on the menu
    at the entrance in a car on a page

    Look at these examples:


  • Jane is waiting for you at the bus stop.
  • The shop is at the end of the street.
  • My plane stopped at Dubai and Hanoi and arrived in Bangkok two hours late.
  • When will you arrive at the office?
  • Do you work in an office?
  • I have a meeting in New York.
  • Do you live in Japan?
  • Jupiter is in the Solar System.
  • The author's name is on the cover of the book.
  • There are no prices on this menu.
  • You are standing on my foot.
  • There was a "no smoking" sign on the wall.
  • I live on the 7th floor at 21 Oxford Street in London.


  • Notice the use of the prepositions of place at, in and on in these standard expressions:
    at in on
    at home in a car on a bus
    at work in a taxi on a train
    at school in a helicopter on a plane
    at university in a boat on a ship
    at college in a lift (elevator) on a bicycle, on a motorbike
    at the top in the newspaper on a horse, on an elephant
    at the bottom in the sky on the radio, on television
    at the side in a row on the left, on the right
    at reception in Oxford Street on the way

    Prepositions of Time: at, in, on
    We use:


  • at for a PRECISE TIME
  • in for MONTHS, YEARS, CENTURIES and LONG PERIODS
  • on for DAYS and DATES

  • at in on
    PRECISE TIME MONTHS, YEARS, CENTURIES and LONG PERIODS DAYS and DATES
    at 3 o'clock in May on Sunday
    at 10.30am in summer on Tuesdays
    at noon in the summer on 6 March
    at dinnertime in 1990 on 25 Dec. 2010
    at bedtime in the 1990s on Christmas Day
    at sunrise in the next century on Independence Day
    at sunset in the Ice Age on my birthday
    at the moment in the past/future on New Year's Eve

    Look at these examples:


  • I have a meeting at 9am.
  • The shop closes at midnight.
  • Jane went home at lunchtime.
  • In England, it often snows in December.
  • Do you think we will go to Jupiter in the future?
  • There should be a lot of progress in the next century.
  • Do you work on Mondays?
  • Her birthday is on 20 November.
  • Where will you be on New Year's Day?


  • Notice the use of the preposition of time at in the following standard expressions:
    Expression Example
    at night The stars shine at night.
    at the weekend I don't usually work at the weekend.
    at Christmas/Easter I stay with my family at Christmas.
    at the same time We finished the test at the same time.
    at present He's not home at present. Try later.

    Notice the use of the prepositions of time in and on in these common expressions:
    in on
    in the morning on Tuesday morning
    in the mornings on Saturday mornings
    in the afternoon(s) on Sunday afternoons
    in the evening(s) on Monday evening

    When we say last, next, every, this we do not also use at, in, on.


  • I went to London last June. (not in last June)
  • He's coming back next Tuesday. (not on next Tuesday)
  • I go home every Easter. (not at every Easter)
  • We'll call you this evening. (not in this evening)
  • Wednesday, December 25, 2013

    Singleton Pattern in Volley library

    Singleton Pattern in Volley library

    Google recommends that you use a common RequestQueue object for your app in the form of a Singleton. 


    import android.content.Context;
    import android.graphics.Bitmap;
    import android.support.v4.util.LruCache;

    import com.android.volley.RequestQueue;
    import com.android.volley.toolbox.ImageLoader;
    import com.android.volley.toolbox.Volley;

    public class VolleySingleton {
    private static VolleySingleton mInstance = null;
    private RequestQueue mRequestQueue;
    private ImageLoader mImageLoader;

    private VolleySingleton(Context context){
    mRequestQueue = Volley.newRequestQueue(context);
    mImageLoader = new ImageLoader(this.mRequestQueue, new ImageLoader.ImageCache() {
    private final LruCache<String, Bitmap> mCache = new LruCache<String, Bitmap>(10);
    public void putBitmap(String url, Bitmap bitmap) {
    mCache.put(url, bitmap);
    }
    public Bitmap getBitmap(String url) {
    return mCache.get(url);
    }
    });
    }

    public static VolleySingleton getInstance(Context context){
    if(mInstance == null){
    mInstance = new VolleySingleton(context);
    }
    return mInstance;
    }

    public RequestQueue getRequestQueue(){
    return this.mRequestQueue;
    }

    public ImageLoader getImageLoader(){
    return this.mImageLoader;
    }

    }

    use this
    RequestQueue queue = VolleySingleton.getInstance(context).getRequestQueue();

    //or


    mImageLoader = VolleySingleton.getInstance(context).getImageLoader();

    Handle image in Android from Url

    Setting up the Android Google Volley ImageLoader for NetworkImageView
    -----------------------------------------------------------

    <com.android.volley.toolbox.NetworkImageView
    android:id="@+id/twitter_avatar"
    android:layout_width="48dp"
    android:layout_height="48dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentTop="true"
    android:layout_marginRight="6dip"
    />

    NetworkImageView avatar = (NetworkImageView)view.findViewById(R.id.twitter_avatar);
    avatar.setImageUrl("http://someurl.com/image.png",mImageLoader);

    Or

    mRequestQueue = Volley.newRequestQueue(context);
    mImageLoader = new ImageLoader(mRequestQueue, new ImageLoader.ImageCache() {
    private final LruCache<String, Bitmap> mCache = new LruCache<String, Bitmap>(10);
    public void putBitmap(String url, Bitmap bitmap) {
    mCache.put(url, bitmap);
    }
    public Bitmap getBitmap(String url) {
    return mCache.get(url);
    }
    });
    NetworkImageView avatar = (NetworkImageView)view.findViewById(R.id.twitter_avatar);

    avatar.setImageUrl("http://someurl.com/image.png",mImageLoader);

    Spring for Android

                           Spring for Android




    add the below code in you gradle file in android studio 
    -----
    dependencies {
    compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
    compile 'org.springframework.android:spring-android-auth:1.0.1.RELEASE'
    compile 'org.springframework.android:spring-android-core:1.0.1.RELEASE'
    }
    add this in your activity
    The following example illustrates how to search Google:

    "services/search/web?v=1.0&q={query}";

    // Create a new RestTemplate instance
    RestTemplate restTemplate = new RestTemplate();

    // Add the String message converter
    restTemplate.getMessageConverters().add(new StringHttpMessageConverter());

    // Make the HTTP GET request, marshaling the response to a String

    String result = restTemplate.getForObject(url, String.class, "Android");

    Android – Volley Library

                               Android – Volley Library


    Volley is a library that makes networking for Android apps easier and most importantly, faster.

    Advantages of using Volley:
                             Volley automatically schedule all network requests. It means that Volley will be taking                                  care of all the network requests your app executes for fetching response or image                                     from web.
                            Volley provides transparent disk and memory caching.
                          Volley provides powerful cancellation request API. It means that you can cancel a single                             request or you can set blocks or scopes of requests to cancel.
                         Volley provides powerful customization abilities.
                        Volley provides Debugging and tracing tools

    How to get started?
        Clone the Volley project
           Import the code into your project
           Clone the Volley project: