/* * Copyright 2012 Tallinn University Centre for Educational Technology * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package ee.htk.dippler.app.entities; import android.os.Parcel; import android.os.Parcelable; import android.text.Html; public class Blogpost implements Parcelable { private int post_id = 0; private String title; private String body; private String excerpt; private String posted_on; public int getPost_id() { return post_id; } public void setPost_id(int post_id) { this.post_id = post_id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getPosted_on() { return posted_on; } public void setPosted_on(String posted_on) { //Thu Nov 24 17:02:50 EET 2011 this.posted_on = posted_on; } public void setBody(String body) { this.body = body; //Build excerpt too, this saves us a lot of object in the list view creation when scrolling String tmp_body = Html.fromHtml(body).toString(); if ( tmp_body.length() > 110 ) { excerpt = tmp_body.substring(0, 110); if ( excerpt.endsWith(".") ) { excerpt = excerpt + ".."; } else { excerpt = excerpt + "..."; } } else { excerpt = tmp_body; } } public String getBody() { return this.body; } public String getExcerpt() { return this.excerpt; } @Override public int describeContents() { // TODO Auto-generated method stub return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(body); dest.writeString(posted_on); dest.writeString(title); dest.writeString(excerpt); dest.writeInt(post_id); } public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { public Blogpost createFromParcel(Parcel in) { return new Blogpost(in); } public Blogpost[] newArray(int size) { return new Blogpost[size]; } }; private Blogpost(Parcel in) { body = in.readString(); posted_on = in.readString(); title = in.readString(); excerpt = in.readString(); post_id = in.readInt(); } public Blogpost() { } }