/**
* 从一段微博中提取除微博用户名子之外的内容算法:字符串截取算法
* 例如:@zhang dsfsdfsd @uuu @000 fdsfdss "
*
* 输出: dsfsdfsd fdsfdss
*
* 输出结果要求:每一个小段的正文内容前后有一个 空格。
* @return
* @author zxy
*/
public static String filterWeiboContent(String temp){
char chs[]= temp.toCharArray();
int i=0;
boolean end = false;
StringBuffer buf = new StringBuffer();
while(i<=chs.length-1){
if(end){
break;
}
char ch = chs[i];
if(ch == '@'){
buf.append(' ');//后面加空格
while(true){
int later = i+1;
if(later==temp.length()){
buf.append(' ');
end = true;
break;
}
ch = chs[i++];
if(ch == ' '){
break;
}
}
}else{
i++;
//前面有一个空格了
if(ch!=' '){
buf.append(ch);
}
}
}
return buf.toString();
}
如题,左右的时候需要预加载,所有要知道方向,但是原来的控件没有这个方法,所有,修改了下,代码如下做一个备份,欢迎指正!
1 package com.meityitian.app.views;
2
3 import android.content.Context;
4 import android.support.v4.view.ViewPager;
5 import android.util.AttributeSet;
6 import android.util.Log;
7
8 import com.meityitian.app.utils.Debug;
9
10 /**
11 * 重写,添加了判定滑动方向的方法
12 * @author zxy
13 *
14 */
15 public class meityitianViewPager extends ViewPager {
16 private boolean left = false;
17 private boolean right = false;
18 private boolean isScrolling = false;
19 private int lastValue = -1;
20 private ChangeViewCallback changeViewCallback = null;
21
22 public meityitianViewPager(Context context, AttributeSet attrs) {
23 super(context, attrs);
24 init();
25 }
26
27 public meityitianViewPager(Context context) {
28 super(context);
29 init();
30 }
31
32 /**
33 * init method .
34 */
35 private void init() {
36 setOnPageChangeListener(listener);
37 }
38
39 /**
40 * listener ,to get move direction .
41 */
42 public OnPageChangeListener listener = new OnPageChangeListener() {
43 @Override
44 public void onPageScrollStateChanged(int arg0) {
45 if (arg0 == 1) {
46 isScrolling = true;
47 } else {
48 isScrolling = false;
49 }
50
51 Debug.infoByTag("meityitianViewPager",
52 "meityitianViewPager onPageScrollStateChanged : arg0:"
53 + arg0);
54 if (arg0 == 2) {
55 Debug.infoByTag("meityitianViewPager",
56 "meityitianViewPager onPageScrollStateChanged direction left ? "
57 + left);
58 Debug.infoByTag("meityitianViewPager",
59 "meityitianViewPager onPageScrollStateChanged direction right ? "
60 + right);
61 //notify ....
62 if(changeViewCallback!=null){
63 changeViewCallback.changeView(left, right);
64 }
65 right = left = false;
66 }
67
68 }
69
70 @Override
71 public void onPageScrolled(int arg0, float arg1, int arg2) {
72 if (isScrolling) {
73 if (lastValue > arg2) {
74 // 递减,向右侧滑动
75 right = true;
76 left = false;
77 } else if (lastValue < arg2) {
78 // 递减,向右侧滑动
79 right = false;
80 left = true;
81 } else if (lastValue == arg2) {
82 right = left = false;
83 }
84 }
85 Log.i("meityitianViewPager",
86 "meityitianViewPager onPageScrolled last :arg2 ,"
87 + lastValue + ":" + arg2);
88 lastValue = arg2;
89 }
90
91 @Override
92 public void onPageSelected(int arg0) {
93 if(changeViewCallback!=null){
94 changeViewCallback.getCurrentPageIndex(arg0);
95 }
96 }
97 };
98
99 /**
100 * 得到是否向右侧滑动
101 * @return true 为右滑动
102 */
103 public boolean getMoveRight(){
104 return right;
105 }
106
107 /**
108 * 得到是否向左侧滑动
109 * @return true 为左做滑动
110 */
111 public boolean getMoveLeft(){
112 return left;
113 }
114
115 /**
116 * 滑动状态改变回调
117 * @author zxy
118 *
119 */
120 public interface ChangeViewCallback{
121 /**
122 * 切换视图 ?决定于left和right 。
123 * @param left
124 * @param right
125 */
126 public void changeView(boolean left,boolean right);
127 public void getCurrentPageIndex(int index);
128 }
129
130 /**
131 * set ...
132 * @param callback
133 */
134 public void setChangeViewCallback(ChangeViewCallback callback){
135 changeViewCallback = callback;
136 }
137 }
---- by meiyitian
伤不起的垂直领域,这个题目有点儿怪呢!首先要看站在谁的角度,如果站在一个综合领域的行业老大老说,这句话就是对的,如果站在从事垂直领域的人士来说,就恰恰相反!
举例来说比较合适
百度:搜索老大 ,酷讯 :垂直领域票务搜索
淘宝:电商老大,京东:3c老大(后期转型忽略之)
赶集、58 :分类信息老大 ,农享网:农产品垂直分类领域
。。。。。。。
老大,综合能力强,力求全面发展,往往某一个领域忽略了,就被其他的垂直领域的人顶上做了起来!事实上,老大是不可能把所有事情都做的,因为很多原因嘛!
垂直领域从业者,往往对自己的领域熟悉,并且专注,提供的服务在质量上一定是比老大好,所以,老大在这方面没有优势!
发展
老大收购某一垂直领域的老大,老大弄出来一个类似的产品打击垂直领域的老大,当然是哪个领域要老大看得上才行哈!
个人建议:
老大怎么办?提供一个平台,自己没有涉及到的地方,让别人去完善,因为平台是自己的,所以,收益还是可以自己掌握的!
垂直领域老大怎么办?好好发展自己的垂直领域,提供个性化优质服务,有余力再扩大领域,同时要和老大搞好关系,和业界保持好关系和合作!
微博只是一个形式
时下,微博大火大热,大有超过传统的SNS、社区的趋势。。。。。
究竟是什么让微博那么火?是那140字,还是那140字?
不可否认的是,在人们生活节奏加快,信息流动频繁的情况下,140字可以一定程度上满足人们对信息碎片和信息流量的渴求:人们可以在极短的时间内阅读一切他们关注的信息。。。
另外,微博还呈现了以往SNS、社区所没有表现出来的个人媒体时代,人人都是直播间,人人都是记者站,这在一定程度上确保了信息的真实性和时效性。国内的微博更是在Twitter的基础上做出了微创新,神马游戏、应用、、、、、、应有仅有,让人们不仅能看好,也让他们玩好!
另外一点也是比较重要的是,认证、名人。认证,让消息真实性无可挑剔,名人更是用名人效应来聚集了大量用户;
假如有另外一种媒体,也有上面分析的相关属性,即使没有140字的限制,也一样会发展很好!
所有,Twitter只是一种形式..........
微博流动性、大容量、真实性、自媒体。。。。等信息相关属性,是微博的杀手锏!!!
by --- meiyitian
前几天放到163上没人理,还是把这块砖扔出来吧!希望高人有更简洁的算法
163 链接:http://meiyitianabc.blog.163.com/blog/static/1050221272011113133756827/
文章正文
/**
* 21 size 算法
* @param maxSize 需要读取的最大数量
* @param list 集合
* @param current 当前所在位置
* @return 根据当前位置提取的集合
* @author meiyitian(zxy)
*/
public static ArrayList<Integer> getTwitterBy21(int maxSize,ArrayList<Integer> list ,int current){
int MAX = maxSize;
if(list==null||current<0||current>list.size()-1){
returnnull;
}
if(list.size()-1<=MAX){
return list;
}
ArrayList<Integer> tempList = new ArrayList<Integer>();
int temp = 0;
int offsetleft = 0;
int offsetright = 0;
int start =0;
int end =0;
int shouldDistance = (int) Math.round(MAX/2);
MAX = shouldDistance*2;
//search for offsetleft position .
temp = current;
for(int i=0;i<shouldDistance;i++){
temp = temp -1;
if(temp<=0){
offsetleft = i;
break;
}
offsetleft = i;
}
//search for offsetright position .
temp = current;
for(int i=0;i<shouldDistance;i++){
temp = temp+1;
if(temp>=list.size()){
offsetright = i;
break;
}
offsetright = i;
}
int distance = Math.abs(offsetright + offsetleft);
if((distance+1)<MAX){
System.out.println(""+"21:current ,(distance+1)<MAX");
if(offsetleft<shouldDistance-1){
end = current+offsetright + (MAX-distance);
if(end >list.size()-1){
end = list.size();
}
//start = current - offsetleft;
start = Math.round((MAX -2 -end )/2);
if(start<0){
start=0;
}
System.out.println(""+"21:current ,offsetleft<shouldDistance");
}else if(offsetright<shouldDistance-1){
start = current - offsetleft -(MAX-distance)+1;
if(start<0){
start =0;
}
//end = current + offsetright-1;
end = MAX-2+2*start;
if(end>list.size()){
end = list.size();
}
System.out.println(""+"21:current ,offsetright<shouldDistance");
}else if(offsetright ==offsetleft){
start = current - offsetleft-1;
if(start<0){
start = 0;
}
end = current+offsetright+1;
if(end>list.size()){
end = list.size();
}
}
}
//add ...
for(int i = start ;i<end;i++){
tempList.add(list.get(i));
}
System.out.println(""+"21:size ,"+tempList.size());
return tempList;
}
