代码图片布局创意等等所有的一切都归原创者所有
我已经分不清谁是原创
如要用于商业,请遵守相关法则
主要的代码就是SyncStatusPanel.java
山寨的还不够干净利落,有些代码可能无用
package org.xkit.android.demo;
import android.app.Activity;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
@SuppressWarnings("unused")
public class SyncStatusPanel extends RelativeLayout {
private class SetIconUIThread implements Runnable {
private int image;
public SetIconUIThread() {
}
public void run() {
if (image != 0) {
sourceIconView.setImageResource(image);
} else {
sourceIconView.setImageResource(0);
}
}
public void setIcon(int image) {
this.image = image;
}
}
private class SetStatusIconUIThread implements Runnable {
private int image;
public SetStatusIconUIThread() {
}
public void run() {
if (image != 0) {
statusIconView.setImageResource(image);
} else {
statusIconView.setImageResource(0);
}
}
public void setIcon(int image) {
this.image = image;
}
}
private class SetStatusStringUIThread implements Runnable {
private String text;
public SetStatusStringUIThread() {
}
public void run() {
statusTextView.setText(text);
}
public void setText(String value) {
this.text = value;
}
}
private class SetTitleUIThread implements Runnable {
private String title;
public SetTitleUIThread() {
}
public void run() {
titleTextView.setText(title);
}
public void setTitle(String title) {
this.title = title;
}
}
protected static final int BOTTOM_PADDING = 8;
private static final int DISABLED_TEXT_COLOR = 0xFF7F7F7F;
private static final int ENABLED_TEXT_COLOR = 0xFF000000;
protected static final int SOURCE_ICON_LEFT_PADDING = 4;
protected static final int SOURCE_ICON_RIGHT_PADDING = 4;
private static final int STATUS_FONT_SIZE = 12;
protected static final int STATUS_ICON_R_PADDING = 4;
protected static final int STATUS_L_PADDING = 12;
private static final int TITLE_FONT_SIZE = 20;
protected static final int TITLE_L_PADDING = 5;
protected static final int TOP_PADDING = 8;
protected Activity activity;
protected SetIconUIThread setIconUIThread = new SetIconUIThread();
protected SetStatusIconUIThread setStatusIconUIThread = new SetStatusIconUIThread();
protected SetStatusStringUIThread setStatusStringUIThread = new SetStatusStringUIThread();
protected SetTitleUIThread setTitleUIThread = new SetTitleUIThread();
protected ImageView sourceIconView;
protected ImageView statusIconView;
protected TextView statusTextView;
protected TextView titleTextView;
// 每个元素的ID
protected final int D1 = 0X514001, D2 = 0X514002, D3 = 0X514003,
D4 = 0X514004;
public SyncStatusPanel(Activity activity) {
super(activity);
this.activity = activity;
statusIconView = createStatusIcon(activity);
sourceIconView = createSourceIcon(activity);
titleTextView = createTitleText(activity);
statusTextView = createStatusText(activity);
RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
params1.addRule(RelativeLayout.CENTER_VERTICAL);
params1.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
addView(sourceIconView, params1);
RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
params2.addRule(RelativeLayout.CENTER_VERTICAL);
params2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
addView(statusIconView, params2);
RelativeLayout.LayoutParams params3 = new RelativeLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
params3
.addRule(RelativeLayout.RIGHT_OF,
sourceIconView.getId());
params3.addRule(RelativeLayout.ALIGN_PARENT_TOP);
params3.addRule(RelativeLayout.LEFT_OF, statusIconView.getId());
addView(titleTextView, params3);
RelativeLayout.LayoutParams params4 = new RelativeLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
params4
.addRule(RelativeLayout.RIGHT_OF,
sourceIconView.getId());
params4.addRule(RelativeLayout.BELOW, titleTextView.getId());
params4.addRule(RelativeLayout.LEFT_OF, statusIconView.getId());
addView(statusTextView, params4);
setBackgroundResource(R.drawable.sync_status_panel);
}
protected int adaptSizeToDensity(int size) {
return (int) (size * getContext().getResources()
.getDisplayMetrics().density);
}
protected ImageView createSourceIcon(Activity activity) {
ImageView sourceIconView = new ImageView(activity);
sourceIconView.setPadding(
adaptSizeToDensity(SOURCE_ICON_LEFT_PADDING),
adaptSizeToDensity(TOP_PADDING),
adaptSizeToDensity(SOURCE_ICON_RIGHT_PADDING),
adaptSizeToDensity(BOTTOM_PADDING));
sourceIconView.setId(D1);
return sourceIconView;
}
protected ImageView createStatusIcon(Activity activity) {
ImageView statusIconView = new ImageView(activity);
statusIconView.setAdjustViewBounds(true);
statusIconView.setMaxHeight(adaptSizeToDensity(32));
statusIconView.setMaxWidth(adaptSizeToDensity(32));
statusIconView.setId(D2);
return statusIconView;
}
protected TextView createStatusText(Activity activity) {
TextView statusTextView = new TextView(activity);
statusTextView.setPadding(adaptSizeToDensity(STATUS_L_PADDING),
0, 0, 0);
statusTextView.setTextSize(STATUS_FONT_SIZE);
statusTextView.setTextColor(ENABLED_TEXT_COLOR);
statusTextView.setBackgroundColor(android.R.color.black);
statusTextView.setId(D3);
return statusTextView;
}
protected TextView createTitleText(Activity activity) {
TextView titleTextView = new TextView(activity);
titleTextView.setTextSize(TITLE_FONT_SIZE);
titleTextView.setPadding(adaptSizeToDensity(TITLE_L_PADDING),
adaptSizeToDensity(TOP_PADDING), 0, 0);
titleTextView.setTextColor(ENABLED_TEXT_COLOR); // COLOR
titleTextView.setId(D4);
return titleTextView;
}
public void setIcon(int image) {
setIconUIThread.setIcon(image);
activity.runOnUiThread(setIconUIThread);
}
public void setStatusIcon(int image) {
setStatusIconUIThread.setIcon(image);
activity.runOnUiThread(setStatusIconUIThread);
}
public void setStatusString(String value) {
setStatusStringUIThread.setText(value);
activity.runOnUiThread(setStatusStringUIThread);
}
public void setTitle(String value) {
setTitleUIThread.setTitle(value);
activity.runOnUiThread(setTitleUIThread);
}
}
这个类代码很少,但是还是可以学到些基本知识
比如为什么要用Runnable来更新UI
adaptSizeToDensity方法的目的
用XML来定义背景图形
RelativeLayout基本知识
等等等等
调用方法如下:
LinearLayout lll = (LinearLayout) findViewById(R.id.boxes);
LinearLayout.LayoutParams ll1Params = new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT);
SyncStatusPanel ssp = new SyncStatusPanel(this); // 这个是我们自定义的
ssp.setIcon(R.drawable.icon_calendar);
ssp.setTitle("日程安排");
ssp.setStatusString("上次同步在 2010-01-01 12:23:32");
ssp.setStatusIcon(R.drawable.icon_complete);
lll.addView(ssp, ll1Params);
直接上图
山寨:
原图:
https://android-client.forge.funambol.org/
估计我这直接叫抄袭吧,姑且叫它学习
- 大小: 11.5 KB
分享到:
相关推荐
本文将深入探讨Funambol的编译过程,以及与之相关的技术要点。 首先,我们要了解Funambol的基本架构。Funambol是一个基于Java的平台,它的核心功能是实现数据的双向同步,包括联系人、日历、任务等个人信息管理...
Funambol是一款开源同步平台,专门设计用于移动设备与服务器之间的数据同步,尤其注重于个人信息管理(PIM)数据,如日历、联系人、任务和邮件。它基于云技术,提供了一个双向同步解决方案,使得用户可以在不同设备...
- **持久化存储架构**:版本1.1中增加了对持久化存储的支持,这是数据同步服务的核心需求之一。 - **安全架构**:版本1.2中加入了安全相关的架构设计,确保了数据传输的安全性。 - **同步过程**:版本1.3中新增了...
Funambol DS是一种基于SyncML协议的云同步服务,它主要用于客户端和云端的数据同步,包括通讯录、日历、视频和文件等内容。本文主要探讨了Funambol DS在通讯录同步方面的实现机制。 首先,Funambol DS和DM(Device ...
Funambol客户端与服务器同步工具,Funambol provides apps for smartphones, tablets and computers such as iPhone, Android, BlackBerry, Symbian, Windows Mobile (Windows Phone coming soon), Windows PC and ...
Funambol Sync Client for Android is a client to synchronize PIM Data of Android devices with any SyncML aware server. For the moment, it is an experimental project to explore the possibility of the...
改造funambol_dm_server源码为eclipse工程, 方便测试研究, 内附SQL脚本, 可作为OTA相关项目的研究参照, funambol_dm_server完全遵照SYNCML协议, 对SYNCML的深入研究比较有帮助. 包内是个EAR工程, 包含EJB和WEB两部分...
Funambol DM Server是一款基于开放源代码的移动设备管理(Mobile Device Management,MDM)解决方案,专注于OMA(Open Mobile Alliance)设备管理协议。在3.5.2这个版本中,它提供了对各种智能设备的远程管理和配置...
《Funambol Mobile:开源同步你的电子邮件和其他数据至移动设备》是一本由Packt Publishing在2009年12月出版的技术书籍,作者为Stefano Fornari。本书主要介绍了如何利用Funambol 7.1这一强大的开源工具来实现移动...
funambol-dm-server 移动设备管理服务器端源代码
基于Funambol的J2ME客户端设计文档,不仅是一份技术指南,更是移动应用开发领域的重要参考。它揭示了SyncML和Funambol如何协同工作,解决了移动应用开发中的数据同步和设备兼容性问题。通过遵循这些最佳实践,开发者...
Funambol是一个开源的同步平台,它支持多种设备和应用之间的数据同步,主要利用SyncML协议来实现。本文将深入探讨Funambol C++ API 7.0.0及其相关知识点,包括SyncML协议、Funambol SDK以及C++编程在其中的应用。 ...
Funambol架构是一种开源的云同步平台,专为移动设备和服务器之间的数据同步设计,它采用了SyncML(Synchronization Markup Language)作为同步协议。本文主要探讨了如何利用Funambol进行云数据同步,并深入理解...
Funambol是一款开源的同步服务器软件,主要用于移动设备与服务器之间的数据同步,如日历、联系人、邮件等。在Android开发环境中,Eclipse是最常用的集成开发环境(IDE)。本篇将详细介绍如何在Eclipse中配置Funambol...
funambol SyncML全套工程包括Server、EJB和Web。并附加全部Jar包集合及数据库SQL脚本,方便学习使用,对SyncML想要的深入研究的朋友较有用。 可作为OTA相关项目的研究参照。 funambol SyncML完全遵照SyncML协议,包内...
Funambol是一个开源的同步平台,它主要用于移动设备与服务器之间的数据同步,如日历、联系人、任务等。在Android平台上,Funambol提供了Android Sync Client,它是一个客户端应用程序,使得用户能够方便地将手机上的...