android-ibc-forum

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit b97722c7d7e90fc83748770af46022b2941bfdd9
parent 395b9c16be077b42b3f5621baa150df2d083dac5
Author: Jan Dankert <devnull@localhost>
Date:   Tue, 31 Jan 2012 23:24:22 +0100

Überflüssige Klassen entfernt.

Diffstat:
src/de/mtbnews/android/adapter/MapContentAdapter.java | 153-------------------------------------------------------------------------------
src/org/xmlrpc/android/XMLRPCServer.java | 105-------------------------------------------------------------------------------
2 files changed, 0 insertions(+), 258 deletions(-)

diff --git a/src/de/mtbnews/android/adapter/MapContentAdapter.java b/src/de/mtbnews/android/adapter/MapContentAdapter.java @@ -1,153 +0,0 @@ -/** - * - */ -package de.mtbnews.android.adapter; - -import java.util.List; -import java.util.Map; - -import android.content.Context; -import android.opengl.Visibility; -import android.text.format.DateFormat; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.LinearLayout; -import android.widget.TextView; -import de.mtbnews.android.R; - -/** - * @author dankert - * @Deprecated use ListEntryContentAdapter - */ -@Deprecated -public class MapContentAdapter extends BaseAdapter -{ - - /** Remember our context so we can use it when constructing views. */ - private Context mContext; - - /** - * Hold onto a copy of the entire Contact List. - */ - - private LayoutInflater inflator; - - private String dateKey; - private String titleKey; - private String descriptionKey; - - private List<Map<String, Object>> map; - - public MapContentAdapter(Context context, List<Map<String, Object>> map, - String dateKey, String titleKey, String descriptionKey) - { - mContext = context; - inflator = (LayoutInflater) context - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - this.map = map; - this.dateKey = dateKey; - this.titleKey = titleKey; - this.descriptionKey = descriptionKey; - } - - public int getCount() - { - return map.size(); - } - - public Object getItem(int position) - { - return map.get(position); - } - - /** Use the array index as a unique id. */ - public long getItemId(int position) - { - return position; - - } - - /** - * @param convertView - * The old view to overwrite, if one is passed - * @returns a ContactEntryView that holds wraps around an ContactEntry - */ - public View getView(int position, View convertView, ViewGroup parent) - { - - Map<String, Object> e = map.get(position); - - final ViewHolder viewHolder; - - if (convertView == null) - { - - convertView = inflator.inflate(R.layout.rss_item, null); - - // Linken Rand ggf. erhöhen. - // LinearLayout.LayoutParams params2 = new - // LinearLayout.LayoutParams( - // LinearLayout.LayoutParams.FILL_PARENT, - // LinearLayout.LayoutParams.WRAP_CONTENT); - // params2.setMargins(20,0,0,0); - // view.setLayoutParams(params2); - - viewHolder = new ViewHolder(); - viewHolder.datum = (TextView) convertView - .findViewById(R.id.item_date); - viewHolder.name = (TextView) convertView - .findViewById(R.id.item_title); - viewHolder.desc = (TextView) convertView - .findViewById(R.id.item_description); - convertView.setTag(viewHolder); - } - else - { - viewHolder = (ViewHolder) convertView.getTag(); - } - - if (dateKey != null) - { - viewHolder.datum.setText(DateFormat.getDateFormat( - parent.getContext()).format(e.get(dateKey)) - + " " - + DateFormat.getTimeFormat(parent.getContext()).format( - e.get(dateKey))); - } - else - { - viewHolder.datum.setVisibility(View.INVISIBLE); - } - - if (titleKey != null) - { - viewHolder.name.setText(new String((byte[]) e.get(titleKey))); - } - - if (descriptionKey != null) - { - - if (e.get(descriptionKey) != null) - viewHolder.desc.setText(new String((byte[]) e - .get(descriptionKey))); - else - viewHolder.desc.setText(""); - } - else - { - viewHolder.desc.setText(""); - } - - return convertView; - } - - static class ViewHolder - { - TextView datum; - TextView name; - TextView desc; - } - -} diff --git a/src/org/xmlrpc/android/XMLRPCServer.java b/src/org/xmlrpc/android/XMLRPCServer.java @@ -1,104 +0,0 @@ -package org.xmlrpc.android; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.Reader; -import java.io.StringWriter; -import java.net.Socket; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -import org.xmlpull.v1.XmlPullParserFactory; - -import android.util.Log; - -public class XMLRPCServer extends XMLRPCCommon { - - private static final String RESPONSE = - "HTTP/1.1 200 OK\n" + - "Connection: close\n" + - "Content-Type: text/xml\n" + - "Content-Length: "; - private static final String NEWLINES = "\n\n"; - private XMLRPCSerializer iXMLRPCSerializer; - - public XMLRPCServer() { - iXMLRPCSerializer = new XMLRPCSerializer(); - } - - public MethodCall readMethodCall(Socket socket) throws IOException, XmlPullParserException - { - MethodCall methodCall = new MethodCall(); - InputStream inputStream = socket.getInputStream(); - - XmlPullParser pullParser = xmlPullParserFromSocket(inputStream); - - pullParser.nextTag(); - pullParser.require(XmlPullParser.START_TAG, null, Tag.METHOD_CALL); - pullParser.nextTag(); - pullParser.require(XmlPullParser.START_TAG, null, Tag.METHOD_NAME); - - methodCall.setMethodName(pullParser.nextText()); - - pullParser.nextTag(); - pullParser.require(XmlPullParser.START_TAG, null, Tag.PARAMS); - pullParser.nextTag(); // <param> - - do { - //Log.d(Tag.LOG, "type=" + pullParser.getEventType() + ", tag=" + pullParser.getName()); - pullParser.require(XmlPullParser.START_TAG, null, Tag.PARAM); - pullParser.nextTag(); // <value> - - Object param = iXMLRPCSerializer.deserialize(pullParser); - methodCall.params.add(param); // add to return value - - pullParser.nextTag(); - pullParser.require(XmlPullParser.END_TAG, null, Tag.PARAM); - pullParser.nextTag(); // <param> or </params> - - } while (!pullParser.getName().equals(Tag.PARAMS)); // </params> - - return methodCall; - } - - XmlPullParser xmlPullParserFromSocket(InputStream socketInputStream) throws IOException, XmlPullParserException { - String line; - BufferedReader br = new BufferedReader(new InputStreamReader(socketInputStream)); - while ((line = br.readLine()) != null && line.length() > 0); // eat the HTTP POST headers - - XmlPullParser pullParser = XmlPullParserFactory.newInstance().newPullParser(); - pullParser.setInput(br); - return pullParser; - } - - public void respond(Socket socket, Object[] params) throws IOException { - - String content = methodResponse(params); - String response = RESPONSE + (content.length()) + NEWLINES + content; - OutputStream outputStream = socket.getOutputStream(); - outputStream.write(response.getBytes()); - outputStream.flush(); - outputStream.close(); - socket.close(); - Log.d(Tag.LOG, "response:" + response); - } - - private String methodResponse(Object[] params) - throws IllegalArgumentException, IllegalStateException, IOException { - StringWriter bodyWriter = new StringWriter(); - serializer.setOutput(bodyWriter); - serializer.startDocument(null, null); - serializer.startTag(null, Tag.METHOD_RESPONSE); - - serializeParams(params); - - serializer.endTag(null, Tag.METHOD_RESPONSE); - serializer.endDocument(); - - return bodyWriter.toString(); - } -}- \ No newline at end of file