Code Monkey home page Code Monkey logo

netmera-mobiblogger's Introduction

#What is Mobi Blogger Netmera Platform is a cloud platform (PaaS) optimized for mobile applications. Netmera offers a cloud based content & data repository. With simple APIs and mobile SDKs it is easy to store, retrieve, search and query data & content on the cloud. Mobi Blogger is a sample mobile application, developed for android systems, and uses Netmera APIs for server side interactions. It is a basic mobile blogger application, where users can add, edit, display and delete their blogs with server side operations. Since this is a sample project, the users may manage text and photo type contents. #Usage

private void initAPI(){
	NetmeraClient.init(getApplicationContext(), GeneralConstants.SECURITY_KEY);
}

##Netmera Content Object Storing content in Netmera mobile service is done by creating NetmeraContent object which contains key-value pairs of data.

##Netmera Service Ojbect NetmeraService object is used to retrieve contents by its search and get methods. Many query options defined to help finding exact object easily. There are also search methods which gets the contents with the given range of locations.

###Create Content Following code is used to create content object. First a netmera content object is created with a key, then several data are added to this object as key-value pairs. Data is added when create() function is called.

	NetmeraContent cc = new NetmeraContent(GeneralConstants.DATA_TABLE_NAME);
	cc.add(GeneralConstants.KEY_TITLE, title.getText().toString());
	cc.add(GeneralConstants.KEY_DESCRIPTION, description.getText().toString());
	cc.create();

For adding photo object, the procedure is a little different, image is set as NetmeraMedia object.

	byte[] bytes = HttpUtils.toByteArray(new File (path));	
	NetmeraMedia file = new NetmeraMedia(bytes);
	cc.add(GeneralConstants.KEY_PHOTOS + i, file);
	cc.create();

###Delete Content Following code can be used to delete content from the Netmera repository. In order to delete content either set path to find and delete content or first call get() or search() methods and then delete the retrieved NetmeraContent object.

	path = (String) getIntent().getExtras().get(GeneralConstants.KEY_PATH);
	NetmeraContent cc = new NetmeraContent(GeneralConstants.DATA_TABLE_NAME);
	cc.setPath(path);
	cc.delete();

###Get Content In order to get the data you need to know the path. In Netmera repository each content has a unique path.

	NetmeraService service = new NetmeraService(GeneralConstants.DATA_TABLE_NAME);
	service.setPath(path);		
	NetmeraContent ctx = service.get();
	titleText.setText(ctx.getString(GeneralConstants.KEY_TITLE));
	contentText.setText(ctx.getString(GeneralConstants.KEY_DESCRIPTION));

For getting photo from the repository, following code can be used:

	NetmeraMedia media = ctx.getNetmeraMedia("file" + mediaCount);
	String url = media.getUrl(NetmeraMedia.PhotoSize.SMALL);
	byte[] imageBytes = media.getData();
	Bitmap bmp = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);

###Search The following code searches the content and returns the list of NetmeraContent objects. If you set searchText then it will search the content repository and retrieve the results which contains the searchText. If searchText is not set then it returns all the content that matches with the objectName.

	NetmeraService cs = new NetmeraService(GeneralConstants.DATA_TABLE_NAME);
	List<NetmeraContent> ccList = cs.search();

###Update Content First the object to be edited is fetched, then the edit operation is just like adding. The only difference is that update() function is called instead of create() function.

	path = (String) getIntent().getExtras().get(GeneralConstants.KEY_PATH);
	NetmeraContent cc = new NetmeraContent(GeneralConstants.DATA_TABLE_NAME);
	cc.setPath(path);
	cc.add(GeneralConstants.KEY_TITLE, titleText);
	cc.add(GeneralConstants.KEY_DESCRIPTION, descriptionText);
	String path = photoPaths.get(i-numberOfPhotos);
	byte[] bytes = HttpUtils.toByteArray(new File (path));	
	NetmeraMedia file = new NetmeraMedia(bytes);
	cc.add(GeneralConstants.KEY_PHOTOS, file);

TODO

netmera-mobiblogger's People

Contributors

dogugunozkaya avatar turankonan avatar gncmustafa avatar cagryinside avatar erdemlal avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.