Skip to content

Commit bce1692

Browse files
author
chao
committed
UI complete.
1 parent 71cdf0c commit bce1692

File tree

5 files changed

+25
-55
lines changed

5 files changed

+25
-55
lines changed

activitytaskview/src/main/java/cc/rome753/activitytask/model/ViewPool.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
import java.util.LinkedList;
88

9-
import cc.rome753.activitytask.view.ObserverTextView;
9+
import cc.rome753.activitytask.view.ATextView;
1010

1111
public class ViewPool {
1212

13-
LinkedList<ObserverTextView> pool = new LinkedList<>();
13+
LinkedList<ATextView> pool = new LinkedList<>();
1414
private static ViewPool factory = new ViewPool();
1515
public static ViewPool get() {
1616
return factory;
@@ -20,19 +20,19 @@ public void recycle(ViewGroup viewGroup) {
2020
if(viewGroup != null) {
2121
for(int i = 0; i < viewGroup.getChildCount(); i++) {
2222
View view = viewGroup.getChildAt(i);
23-
if(view instanceof ObserverTextView) {
24-
pool.add((ObserverTextView) view);
23+
if(view instanceof ATextView) {
24+
pool.add((ATextView) view);
2525
} else if(view instanceof ViewGroup) {
2626
recycle((ViewGroup) view);
2727
}
2828
}
2929
}
3030
}
3131

32-
public ObserverTextView getOne(Context context) {
33-
ObserverTextView view;
32+
public ATextView getOne(Context context) {
33+
ATextView view;
3434
if(pool.isEmpty()) {
35-
view = new ObserverTextView(context);
35+
view = new ATextView(context);
3636
} else {
3737
view = pool.remove();
3838
removeParent(view);

activitytaskview/src/main/java/cc/rome753/activitytask/view/ObserverTextView.java renamed to activitytaskview/src/main/java/cc/rome753/activitytask/view/ATextView.java

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,29 @@
44
import android.graphics.Color;
55
import android.text.SpannableString;
66
import android.text.Spanned;
7-
import android.text.TextUtils;
87
import android.text.style.AbsoluteSizeSpan;
98
import android.util.AttributeSet;
109

1110
import androidx.appcompat.widget.AppCompatTextView;
1211

13-
import java.util.Observable;
14-
import java.util.Observer;
15-
16-
import cc.rome753.activitytask.model.LifecycleInfo;
17-
1812
/**
1913
* change text color when update
2014
* Created by [email protected] on 2017/4/3.
2115
*/
2216

23-
public class ObserverTextView extends AppCompatTextView implements Observer{
17+
public class ATextView extends AppCompatTextView{
2418

2519
private static AbsoluteSizeSpan absoluteSizeSpan = new AbsoluteSizeSpan(8, true);
2620

27-
public ObserverTextView(Context context) {
21+
public ATextView(Context context) {
2822
this(context, null);
2923
}
3024

31-
public ObserverTextView(Context context, AttributeSet attrs) {
25+
public ATextView(Context context, AttributeSet attrs) {
3226
this(context, attrs, 0);
3327
}
3428

35-
public ObserverTextView(Context context, AttributeSet attrs, int defStyleAttr) {
29+
public ATextView(Context context, AttributeSet attrs, int defStyleAttr) {
3630
super(context, attrs, defStyleAttr);
3731
setMaxLines(1);
3832
setTextSize(10);
@@ -58,20 +52,4 @@ public void setInfoText(String s, String lifecycle) {
5852
setText(span);
5953
}
6054

61-
62-
@Override
63-
public void update(Observable o, Object arg){
64-
LifecycleInfo info = (LifecycleInfo) arg;
65-
String name;
66-
if(info.fragments != null) {
67-
name = info.fragments.get(0);
68-
} else {
69-
name = info.activity;
70-
}
71-
if(TextUtils.equals(name, String.valueOf(getTag()))) {
72-
String[] ss = getText().toString().split(" ");
73-
setText(ss[0] + " " + info.lifecycle);
74-
}
75-
}
76-
7755
}

activitytaskview/src/main/java/cc/rome753/activitytask/view/ActivityTaskView.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ private void moveToBorder() {
120120

121121
public void add(LifecycleInfo info) {
122122
FragmentTaskView view = new FragmentTaskView(getContext());
123+
view.setTitle(info.activity);
123124
view.setTag(info.activity);
124125
mContainer.addView(view, 0);
125126

@@ -149,7 +150,7 @@ private void notifyData() {
149150
TaskLayout layout = new TaskLayout(getContext());
150151
layout.setTitle(entry.getKey());
151152
for (String value : entry.getValue()) {
152-
ObserverTextView textView = ViewPool.get().getOne(getContext());
153+
ATextView textView = ViewPool.get().getOne(getContext());
153154
textView.setInfoText(value, aTree.getLifecycle(value));
154155
layout.addFirst(textView);
155156
}

activitytaskview/src/main/java/cc/rome753/activitytask/view/FragmentTaskView.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package cc.rome753.activitytask.view;
22

33
import android.content.Context;
4-
import android.graphics.Color;
54
import android.util.AttributeSet;
6-
import android.widget.LinearLayout;
75

86
import java.util.List;
97

@@ -16,7 +14,7 @@
1614
* Created by rome753 on 2017/3/31.
1715
*/
1816

19-
public class FragmentTaskView extends LinearLayout {
17+
public class FragmentTaskView extends TaskLayout {
2018

2119
FTree mTree = new FTree();
2220

@@ -26,8 +24,13 @@ public FragmentTaskView(Context context) {
2624

2725
public FragmentTaskView(Context context, AttributeSet attrs) {
2826
super(context, attrs);
29-
setOrientation(VERTICAL);
30-
setBackgroundColor(Color.parseColor("#333333"));
27+
setVisibility(GONE);
28+
}
29+
30+
@Override
31+
public void setTitle(String title) {
32+
String[] ss = title.split("@");
33+
tv.setText(ss[0]);
3134
}
3235

3336
public void add(LifecycleInfo info) {
@@ -47,17 +50,18 @@ public void update(LifecycleInfo info) {
4750

4851
private void notifyData(){
4952
ViewPool.get().recycle(this);
50-
removeAllViews();
53+
ll.removeAllViews();
5154
if(mTree != null){
5255
List<String> strings = mTree.convertToList();
5356
for(String s : strings){
54-
ObserverTextView textView = ViewPool.get().getOne(getContext());
57+
ATextView textView = ViewPool.get().getOne(getContext());
5558
String[] arr = s.split(String.valueOf('\u2500')); // -
5659
String name = arr[arr.length - 1];
5760
textView.setInfoText(s, mTree.getLifecycle(name));
58-
addView(textView);
61+
ll.addView(textView);
5962
}
6063
}
64+
setVisibility(ll.getChildCount() == 0 ? GONE : VISIBLE);
6165
}
6266

6367
}

activitytaskview/src/main/java/cc/rome753/activitytask/view/LifecycleObservable.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)