working on it ...

Filters

Explore Public Snippets

Sort by

Found 6 snippets

    public by stanchostanchev  1914  0  5  0

    Android

    change the color of ListView divider
    //hostActivity.lvLibraryList.setDivider(
    // new ColorDrawable(hostActivity.getResources().getColor(R.color.backcolor)));
    		
    		hostActivity.lvLibraryList.setDivider(new ColorDrawable(0x000000));
    		hostActivity.lvLibraryList.setDividerHeight(1);

    public by stanchostanchev  1680  0  5  0

    Android

    prevent thread to be run on lowest priority by default
    Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND
    				+ Process.THREAD_PRIORITY_MORE_FAVORABLE);

    public by stanchostanchev  2644  0  5  1

    Android

    JSON parsing with Jackson
    String response = event.getJsonLibraryMetadata();
    		JsonFactory jf = new JsonFactory();
    		try {
    			// Log.i("JSON", response);
    			JsonParser jp = jf.createParser(response);
    			while (jp.nextToken() != JsonToken.END_OBJECT) {
    				String token = jp.getCurrentName();
    				if ("ebooks".equals(token)) {
    					// System.out.println("ebooks :");
    					EBookDetails mEBookDetails = new EBookDetails();
    					// the next token will be '[' that means that we have an
    					// array
    					jp.nextToken();
    					// parse tokens until you find ']'
    					while (jp.nextToken() != JsonToken.END_ARRAY) {
    						// System.out.println(jp.getText());
    						String currentToken = jp.getCurrentName();
    
    						if ("cover_thumbnail".equals(currentToken)) {
    							jp.nextToken();
    						}
    						if ("scriptures".equals(currentToken)) {
    							jp.nextToken();
    						}
    						if ("sample".equals(currentToken)) {
    							jp.nextToken();
    						}
    						if ("created_at".equals(currentToken)) {
    							jp.nextToken();
    						}
    						if ("updated_at".equals(currentToken)) {
    							jp.nextToken();
    						}
    						if ("id".equals(currentToken)) {
    							jp.nextToken();
    							mEBookDetails.id = jp.getIntValue();// ("id");
    						}
    						if ("archived".equals(currentToken)) {
    							jp.nextToken();
    							mEBookDetails.isArchived = jp.getValueAsBoolean();
    							// .getBoolean("archived");
    						}
    						if ("title".equals(currentToken)) {
    							jp.nextToken();
    							mEBookDetails.title = jp.getValueAsString();// getString("title");
    							products.add(mEBookDetails.title);
    						}
    						if ("description".equals(currentToken)) {
    							jp.nextToken();
    							mEBookDetails.description = jp.getValueAsString();
    							// .getString("description");
    						}
    						if ("author".equals(currentToken)) {
    							jp.nextToken();
    							mEBookDetails.author = jp.getValueAsString();// .getString("author");
    						}
    						if ("file_name".equals(currentToken)) {
    							jp.nextToken();
    							mEBookDetails.file_name = jp.getValueAsString();// .getString("file_name");
    						}
    						if ("genres".equals(currentToken)) {
    							jp.skipChildren();
    							// while (jp.nextToken() != JsonToken.END_ARRAY) {
    							//
    							// }
    						}
    						if ("authors".equals(currentToken)) {
    							jp.skipChildren();
    							// while (jp.nextToken() != JsonToken.END_ARRAY) {
    							//
    							// }
    						}
    						if ("topics".equals(currentToken)) {
    							jp.skipChildren();
    							// while (jp.nextToken() != JsonToken.END_ARRAY) {
    							// }
    						}
    						if ("cover_url".equals(currentToken)) {
    							jp.nextToken();
    							mEBookDetails.cover_url = jp.getValueAsString();// .getString("cover_url");
    							// XXX- Stancho - speed optimization
    							String key = "B" + mEBookDetails.id;
    							// XXX- Stancho - speed optimization -
    							// reduce the number of String adding
    							app.book_list.put(key, mEBookDetails);
    							mEBookDetails = new EBookDetails();
    						}
    
    					}
    				}
    
    			}
    
    			jp.close();

    public by stanchostanchev  149435  0  5  0

    Android

    how to use TimerTask
    new Timer().schedule(new TimerTask() {
    				@Override
    				public void run() {
    					// ... your code goes here ...
    				}
    			}, 1000);

    public by stanchostanchev  1496  0  5  0

    Android

    change the speed of listview scrolling the higher is value of the setFriction argument, the slower is scrolling speed
    lvLibraryList.setFriction(ViewConfiguration.getScrollFriction() * 7);

    public by stanchostanchev  1734  0  5  0

    Android

    check android sdk
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
    	// ...
    }
    // see http://androidsnippets.com/check-the-current-sdkapi-version

    List Complete ( 6 snippets total )

    • Public Snippets
    • Channels Snippets