Skip to content

Commit 8ac103f

Browse files
committed
修改搜索的样式
1 parent b24ecee commit 8ac103f

File tree

11 files changed

+68
-60
lines changed

11 files changed

+68
-60
lines changed

app/src/main/java/net/coding/program/common/adapter/SearchMergeAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
5757
CircleImageView personImg = ViewHolder.get(convertView, R.id.personImg);
5858
TextView txtMergeName = ViewHolder.get(convertView, R.id.txtMergeName);
5959
TextView txtMergeBranch = ViewHolder.get(convertView, R.id.txtMergeBranch);
60-
TextView txtContent = ViewHolder.get(convertView, R.id.txtContent);
60+
// TextView txtContent = ViewHolder.get(convertView, R.id.txtContent);
6161
TextView txtBottomName = ViewHolder.get(convertView, R.id.txtBottomName);
6262
TextView bottomTime = ViewHolder.get(convertView, R.id.bottomTime);
6363
TextView bottomStatus = ViewHolder.get(convertView, R.id.bottomStatus);
@@ -69,7 +69,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
6969
txtMergeName.setText(bean.getSrcBranch());
7070

7171
txtMergeBranch.setText(bean.getDesBranch());
72-
HoloUtils.setHoloText(txtContent, key, bean.getBody());
72+
// HoloUtils.setHoloText(txtContent, key, bean.getBody());
7373
txtBottomName.setText(bean.getTitleIId() + " " + bean.getAuthor().name);
7474
SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm");
7575
bottomTime.setText(format.format(bean.getCreated_at()));

app/src/main/java/net/coding/program/common/adapter/SearchReslutAdapter.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public View getView(int position, View convertView, ViewGroup parent) {
5656
holder = new ViewHolder();
5757
holder.nameTask = (TextView) convertView.findViewById(R.id.nameTask);
5858
holder.iconTask = (ImageView) convertView.findViewById(R.id.iconTask);
59-
holder.descTask = (TextView) convertView.findViewById(R.id.descTask);
6059
holder.bottomName = (TextView) convertView.findViewById(R.id.bottomName);
6160
holder.bottomTime = (TextView) convertView.findViewById(R.id.bottomTime);
6261
holder.bottomHeartCount = (TextView) convertView.findViewById(R.id.bottomHeartCount);
@@ -67,21 +66,18 @@ public View getView(int position, View convertView, ViewGroup parent) {
6766
holder = (ViewHolder) convertView.getTag();
6867
}
6968
TaskObject.SingleTask bean = mData.get(position);
70-
HoloUtils.setHoloText(holder.nameTask, key, bean.creator.name);
71-
HoloUtils.setHoloText(holder.descTask, key, bean.description);
72-
holder.bottomName.setText(bean.owner.name);
69+
HoloUtils.setHoloText(holder.nameTask, key, bean.content);
70+
holder.bottomName.setText(bean.creator.name);
7371
SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm");
7472
holder.bottomTime.setText(format.format(bean.created_at));
7573
holder.bottomCommentCount.setText(bean.comments + "");
7674
holder.bottomHeartCount.setText("");
77-
ImageLoader.getInstance().displayImage(bean.creator.avatar, holder.iconTask, ImageLoadTool.optionsImage);
75+
ImageLoader.getInstance().displayImage(bean.owner.avatar, holder.iconTask, ImageLoadTool.optionsImage);
7876
return convertView;
7977
}
8078

81-
8279
static class ViewHolder {
8380
TextView nameTask;
84-
TextView descTask;
8581
TextView bottomName;
8682
TextView bottomTime;
8783
TextView bottomCommentCount;

app/src/main/java/net/coding/program/common/adapter/SearchTopicAdapter.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package net.coding.program.common.adapter;
22

33
import android.content.Context;
4-
import android.text.Html;
54
import android.view.View;
65
import android.view.ViewGroup;
76
import android.widget.BaseAdapter;
@@ -33,7 +32,6 @@ public SearchTopicAdapter(List<TopicObject> mData, Context context, String key)
3332
this.mData = mData;
3433
this.context = context;
3534
this.key = key;
36-
3735
}
3836

3937
@Override
@@ -59,7 +57,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
5957
holder = new ViewHolder();
6058
holder.nameTask = (TextView) convertView.findViewById(R.id.nameTask);
6159
holder.iconTask = (ImageView) convertView.findViewById(R.id.iconTask);
62-
holder.descTask = (TextView) convertView.findViewById(R.id.descTask);
60+
// holder.descTask = (TextView) convertView.findViewById(R.id.descTask);
6361
holder.bottomName = (TextView) convertView.findViewById(R.id.bottomName);
6462
holder.bottomTime = (TextView) convertView.findViewById(R.id.bottomTime);
6563
holder.bottomHeartCount = (TextView) convertView.findViewById(R.id.bottomHeartCount);
@@ -71,7 +69,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
7169
}
7270
TopicObject bean = mData.get(position);
7371
HoloUtils.setHoloText(holder.nameTask, key, bean.title);
74-
HoloUtils.setHoloText(holder.descTask, key, Html.fromHtml(bean.content).toString());
72+
// HoloUtils.setHoloText(holder.descTask, key, Html.fromHtml(bean.content).toString());
7573
holder.bottomName.setText(bean.owner.name);
7674
SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm");
7775
holder.bottomTime.setText(format.format(bean.created_at));
@@ -127,7 +125,7 @@ public boolean isPublicProject() {
127125

128126
static class ViewHolder {
129127
TextView nameTask;
130-
TextView descTask;
128+
// TextView descTask;
131129
TextView bottomName;
132130
TextView bottomTime;
133131
TextView bottomCommentCount;

app/src/main/java/net/coding/program/model/MergeObject.java

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

77
import net.coding.program.common.Global;
88

9+
import org.json.JSONArray;
910
import org.json.JSONException;
1011
import org.json.JSONObject;
1112

@@ -133,7 +134,12 @@ public MergeObject(JSONObject json) throws JSONException {
133134
title = json.optString("title");
134135
iid = json.optInt("iid");
135136
author_id = json.optInt("author_id");
136-
body = json.optJSONArray("body").getString(0);
137+
JSONArray body = json.optJSONArray("body");
138+
if (body != null && body.length() > 0) {
139+
this.body = body.getString(0);
140+
} else {
141+
this.body = "";
142+
}
137143
merge_status = json.optString("merge_status");
138144
path = ProjectObject.translatePath(json.optString("path", ""));
139145
created_at = json.optLong("created_at");

app/src/main/java/net/coding/program/model/TaskObject.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,16 @@ public static class SingleTask implements Serializable {
192192
public String description = "";
193193

194194
public SingleTask(JSONObject json) throws JSONException {
195+
this(json, false);
196+
}
197+
198+
public SingleTask(JSONObject json, boolean useRaw) throws JSONException {
195199
comments = json.optInt("comments");
196-
content = Html.fromHtml(json.optString("content")).toString();
200+
this.content = json.optString("content", "");
201+
if (!useRaw) {
202+
this.content = Html.fromHtml(content).toString();
203+
}
204+
197205
created_at = json.optLong("created_at");
198206

199207
if (json.has("creator")) {

app/src/main/java/net/coding/program/search/SearchFramgentAdapter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ public class SearchFramgentAdapter extends FragmentStatePagerAdapter {
1212

1313

1414
private static final String[] TITLES = {"项目", "任务", "讨论", "冒泡", "文件", "用户", "合并请求", "pull请求"};
15-
private static final String[] tab = {"projects", "tasks", "project_topics", "tweets", "files", "friends", "merge_requests", "pull_requests"};
16-
private String key;
15+
public static final String MERGE_REQUEST = "merge_requests";
16+
private static final String[] tab = {"projects", "tasks", "project_topics", "tweets", "files", "friends", MERGE_REQUEST, "pull_requests"};
1717

18+
private String key;
1819

1920
public SearchFramgentAdapter(FragmentManager fm, String key) {
2021
super(fm);
@@ -26,7 +27,6 @@ public CharSequence getPageTitle(int position) {
2627
return TITLES[position];
2728
}
2829

29-
3030
@Override
3131
public Fragment getItem(int position) {
3232
switch (position) {

app/src/main/java/net/coding/program/search/SearchMergeRequestsFragment.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
@EFragment(R.layout.fragment_search_list)
3030
public class SearchMergeRequestsFragment extends RefreshBaseFragment {
3131
private static final String TAG = SearchTaskFragment.class.getSimpleName();
32-
final String url = Global.HOST_API + "/esearch/all?q=%s";
32+
final String url = Global.HOST_API + "/esearch/%s?q=%s";
3333
final String tmp = "&types=%s&pageSize=10";
3434
ArrayList<MergeObject> mData = new ArrayList<>();
3535
String page = "&page=%s";
@@ -111,7 +111,8 @@ public void setKeyword(String keyword) {
111111

112112
private String getUrl(int pos) {
113113
String tag = "";
114-
tag = String.format(url, getKeyword()) + String.format(tmp, getTabPrams()) + String.format(page, pos + "");
114+
String type = tabPrams.equals(SearchFramgentAdapter.MERGE_REQUEST) ? "mr" : "pr";
115+
tag = String.format(url, type, getKeyword()) + String.format(tmp, getTabPrams()) + String.format(page, pos + "");
115116
return tag;
116117
}
117118

@@ -134,12 +135,7 @@ public void parseJson(int code, JSONObject respanse, String tag, int pos, Object
134135
if (pos == 1) {
135136
mData.clear();
136137
}
137-
JSONArray array;
138-
if (getUrl(pos).contains("merge_requests")) {
139-
array = respanse.getJSONObject("data").getJSONObject("merge_requests").getJSONArray("list");
140-
} else {
141-
array = respanse.getJSONObject("data").getJSONObject("pull_requests").getJSONArray("list");
142-
}
138+
JSONArray array = respanse.getJSONObject("data").getJSONArray("list");
143139
for (int i = 0; i < array.length(); ++i) {
144140
JSONObject item = array.getJSONObject(i);
145141
MergeObject oneData = new MergeObject(item);

app/src/main/java/net/coding/program/search/SearchTaskFragment.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import net.coding.program.common.network.RefreshBaseFragment;
1212
import net.coding.program.model.TaskObject;
1313
import net.coding.program.task.add.TaskAddActivity_;
14+
import net.coding.program.task.add.TaskJumpParams;
1415

1516
import org.androidannotations.annotations.AfterViews;
1617
import org.androidannotations.annotations.EFragment;
@@ -59,7 +60,8 @@ protected void init() {
5960

6061
@ItemClick
6162
final void listView(TaskObject.SingleTask itemData) {
62-
TaskAddActivity_.intent(this).mSingleTask(itemData).start();
63+
TaskJumpParams params = new TaskJumpParams(itemData.project.project_path, itemData.getId());
64+
TaskAddActivity_.intent(this).mJumpParams(params).start();
6365
}
6466

6567
AbsListView.OnScrollListener mOnScrollListener = new AbsListView.OnScrollListener() {
@@ -125,7 +127,7 @@ public void parseJson(int code, JSONObject respanse, String tag, int pos, Object
125127
JSONArray array = respanse.getJSONObject("data").getJSONObject("tasks").getJSONArray("list");
126128
for (int i = 0; i < array.length(); ++i) {
127129
JSONObject item = array.getJSONObject(i);
128-
TaskObject.SingleTask oneData = new TaskObject.SingleTask(item);
130+
TaskObject.SingleTask oneData = new TaskObject.SingleTask(item, true);
129131
mData.add(oneData);
130132
}
131133
emptyView.setVisibility(mData.size() == 0 ? View.VISIBLE : View.GONE);

app/src/main/java/net/coding/program/task/add/TaskJumpParams.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,22 @@ public TaskJumpParams(String user, String project, String task) {
1616
projectName = project;
1717
taskId = task;
1818
}
19+
20+
public TaskJumpParams(String projectPath, int taskId) {
21+
String userPrefix = "/t/";
22+
String projectPrefix = "/p/";
23+
int userStart = projectPath.indexOf(userPrefix);
24+
if (userStart == -1) {
25+
userStart = 0;
26+
}
27+
int projectStart = projectPath.indexOf(projectPrefix);
28+
if (projectStart < userStart) {
29+
projectStart = userStart;
30+
}
31+
32+
userKey = projectPath.substring(userStart + userPrefix.length(), projectStart);
33+
projectName = projectPath.substring(projectStart + projectPrefix.length(), projectPath.length());
34+
this.taskId = String.valueOf(taskId);
35+
}
36+
1937
}

app/src/main/res/layout/search_merge_list.xml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,25 @@
6464
android:textColor="@color/color_4E90BF"
6565
android:textSize="14sp" />
6666

67-
<TextView
68-
android:id="@+id/txtContent"
69-
android:layout_width="wrap_content"
70-
android:layout_height="wrap_content"
71-
android:layout_alignLeft="@+id/txtTitle"
72-
android:layout_below="@+id/txtMergeName"
73-
android:layout_marginTop="6.5dp"
74-
android:ellipsize="end"
75-
android:maxLines="2"
76-
android:minLines="1"
77-
android:text="kshdkahsdkj"
78-
android:textColor="@color/font_6"
79-
android:textSize="15sp" />
67+
<!--<TextView-->
68+
<!--android:id="@+id/txtContent"-->
69+
<!--android:layout_width="wrap_content"-->
70+
<!--android:layout_height="wrap_content"-->
71+
<!--android:layout_alignLeft="@+id/txtTitle"-->
72+
<!--android:layout_below="@+id/txtMergeName"-->
73+
<!--android:layout_marginTop="6.5dp"-->
74+
<!--android:ellipsize="end"-->
75+
<!--android:maxLines="2"-->
76+
<!--android:minLines="1"-->
77+
<!--android:text="kshdkahsdkj"-->
78+
<!--android:textColor="@color/font_6"-->
79+
<!--android:textSize="15sp" />-->
8080

8181
<LinearLayout
8282
android:layout_width="match_parent"
8383
android:layout_height="wrap_content"
8484
android:layout_alignLeft="@+id/txtTitle"
85-
android:layout_below="@+id/txtContent"
85+
android:layout_below="@+id/txtMergeName"
8686
android:layout_marginTop="19dp"
8787
android:orientation="horizontal">
8888

0 commit comments

Comments
 (0)