Paginator issue

Discussion in 'Android App Developers' started by phabion, Aug 16, 2013.

  1. phabion
    Offline

    phabion New Member

    Joined:
    Aug 15, 2013
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi community!
    This is my first question.
    I have to create a class called Paginator. It’s contructor will take 4 parameters: a TextView tv, a String content (including new line and line feed), int pageWidth (expected page width), int pageHeight (expected page height). This class should provide these functions in return:
    1. startAutoPagination() – this method does the heavy work (the pagination process). The method should return paging information (some data called pagingInfo of type JSONObject).
    2. loadPagingInformation(JSONObject pagingInfo) – this method load pre-generated paging information (pagingInfo).
    3. getPagingInformation() - return generated paging data (in JSONObject format).
    4. getPageCount() - return number of pages needed to fit the content.
    5. getPage(int pageNumber) - return the content of the requested page.
    Additional Word wrap is expected.
    The main purpose it to speed up the pagination process for very long string (500 pages of content). So everytime we want to do pagination for some content, we call startAutoPagination() method. This method does the pagination and must cache some data (pagingInfo in this case or something else that I still don’t know exactly) for the first time viewing the content. If later we attempt to view the same content, we must use already cached data for that content to speed up the process of pagination.
    So I decided to design my Pagination class like this. I want to know your opinion if this design is good or should I make some changes.
    Here is my design of class Paginator:
    Code:
    class Paginator {
    	JSONObject pagingInfo;	
    	public Pagninator(TextView tv, String content, int pageWidth, int pageHeight){};
    	public void loadPagingInformation(JSONObject pagingInfo){};
    	public void startAutoPagination(){
    		if (contentIsNew) // meaning this is the firs time viewing the string content
    		{
    			// do pagination
    			// set pagingInfo for this content			
    		}
    		else
    			loadPagingInformation(pagingInfo);		
    	}
    
    	//returns generated paging data (in JSONObject format).
    	public JSONObject getPagingInformation(){};	
    
    	//returns number of pages needed to fit the content.
    	public int getPageCount(){};
    
    	//returns the content of the requested page.
    	public String getPage(int pageNumber){};
    }
    
    And here is how we use the class:
    Code:
    Paginator p = new Paginator(tv, content, 30, 60);
    p.startAutoPagination();
    
    Any suggestion would be appreciated!