Bladeren bron

完成选择话题功能

hy 3 jaren geleden
bovenliggende
commit
92c3ba194f

+ 3 - 0
app/src/main/AndroidManifest.xml

@ -103,6 +103,9 @@
103 103
            android:name=".activity.VideoCompressionActivity"
104 104
            android:screenOrientation="portrait"/>
105 105
        <activity
106
            android:name=".activity.SelectTopicActivity"
107
            android:screenOrientation="portrait"/>
108
        <activity
106 109
            android:name=".activity.CarModelActivity"
107 110
            android:launchMode="singleTop"
108 111
            android:screenOrientation="portrait" />

+ 51 - 0
app/src/main/java/com/electric/chargingpile/activity/SelectTopicActivity.java

@ -0,0 +1,51 @@
1
package com.electric.chargingpile.activity;
2
3
import android.content.Context;
4
import android.content.Intent;
5
import android.os.Bundle;
6
import android.view.View;
7
import android.widget.TextView;
8
9
import androidx.annotation.Nullable;
10
import androidx.appcompat.app.AppCompatActivity;
11
import androidx.recyclerview.widget.LinearLayoutManager;
12
import androidx.recyclerview.widget.RecyclerView;
13
14
import com.electric.chargingpile.R;
15
import com.electric.chargingpile.adapter.CommentTopicAdapter;
16
import com.electric.chargingpile.util.BarColorUtil;
17
18
public class SelectTopicActivity  extends AppCompatActivity {
19
20
    private RecyclerView mRecyclerView;
21
    private TextView noDataText;
22
    private CommentTopicAdapter mAdapter;
23
24
    @Override
25
    protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
26
        super.onCreate(savedInstanceState);
27
        setContentView(R.layout.activity_slelect_topic);
28
        BarColorUtil.initStatusBarColor(this);
29
        initView();
30
    }
31
32
    private void initView() {
33
        findViewById(R.id.iv_back).setOnClickListener(v->{
34
            finish();
35
        });
36
37
        mRecyclerView = findViewById(R.id.topicRecycelrView);
38
        noDataText = findViewById(R.id.noDataText);
39
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
40
        mAdapter = new CommentTopicAdapter();
41
        mRecyclerView.setAdapter(mAdapter);
42
43
        noDataText.setVisibility(View.GONE);
44
        mRecyclerView.setVisibility(View.VISIBLE);
45
    }
46
47
    public static void actionStart(Context context){
48
        Intent intent = new Intent(context, SelectTopicActivity.class);
49
        context.startActivity(intent);
50
    }
51
}

+ 10 - 1
app/src/main/java/com/electric/chargingpile/activity/ZhanCommentActivity.java

@ -23,6 +23,7 @@ import android.os.Handler;
23 23
import android.os.Message;
24 24
import android.provider.MediaStore;
25 25
import android.text.Editable;
26
import android.text.Html;
26 27
import android.text.TextWatcher;
27 28
import android.util.Base64;
28 29
import android.util.Log;
@ -109,6 +110,8 @@ import okhttp3.Call;
109 110
import pub.devrel.easypermissions.AfterPermissionGranted;
110 111
import pub.devrel.easypermissions.EasyPermissions;
111 112
113
import static android.text.Html.FROM_HTML_MODE_LEGACY;
114
112 115
public class ZhanCommentActivity extends AppCompatActivity implements View.OnClickListener, EasyPermissions.PermissionCallbacks {
113 116
    private static final String TAG = "ZhanCommentActivity";
114 117
    private static final int PIC_NUM = 1;
@ -133,7 +136,7 @@ public class ZhanCommentActivity extends AppCompatActivity implements View.OnCli
133 136
    List<String> list;
134 137
    private String select_s = "";
135 138
    private String select_ss = "";
136
    private TextView tv_grade, tv_point,tv_zhan_name;
139
    private TextView tv_grade, tv_point,tv_zhan_name,topicText;
137 140
138 141
    private static String PHOTO_FILE_NAME = "";
139 142
    private static final String PHOTO_FILE_PATH = getPath(PhotoUtils.CACHE_DIR);
@ -217,6 +220,8 @@ public class ZhanCommentActivity extends AppCompatActivity implements View.OnCli
217 220
        rl_point = (RelativeLayout) findViewById(R.id.rl_point);
218 221
        tv_point = (TextView) findViewById(R.id.tv_point);
219 222
        tv_zhan_name = (TextView) findViewById(R.id.tv_zhan_name);
223
        topicText = (TextView) findViewById(R.id.topicText);
224
        topicText.setText(Html.fromHtml("<font color='#6AB650'>╋</font>  话题",FROM_HTML_MODE_LEGACY));
220 225
        animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.nn);
221 226
222 227
        relativeLayout = (RelativeLayout) findViewById(R.id.activity_zhan_comment);
@ -445,6 +450,10 @@ public class ZhanCommentActivity extends AppCompatActivity implements View.OnCli
445 450
        tv_zhan_name.setOnClickListener(v->{
446 451
            CommentHintDialog.newInstart().show(getSupportFragmentManager());
447 452
        });
453
        topicText.setOnClickListener(v->{
454
            //跳转至话题页
455
            SelectTopicActivity.actionStart(this);
456
        });
448 457
    }
449 458
450 459
    public void Init() {

+ 71 - 0
app/src/main/java/com/electric/chargingpile/adapter/CommentTopicAdapter.java

@ -0,0 +1,71 @@
1
package com.electric.chargingpile.adapter;
2
3
import android.view.LayoutInflater;
4
import android.view.View;
5
import android.view.ViewGroup;
6
import android.widget.TextView;
7
8
import androidx.annotation.NonNull;
9
import androidx.recyclerview.widget.RecyclerView;
10
11
import com.electric.chargingpile.R;
12
13
import org.jetbrains.annotations.NotNull;
14
import org.w3c.dom.Text;
15
16
public class CommentTopicAdapter extends RecyclerView.Adapter<CommentTopicAdapter.ViewHolder> {
17
18
    private OnItemClickListener mListener;
19
20
    public OnItemClickListener getListener() {
21
        return mListener;
22
    }
23
24
    public void setListener(OnItemClickListener mListener) {
25
        this.mListener = mListener;
26
    }
27
28
    public interface OnItemClickListener {
29
        void onItemClick(int pos);
30
    }
31
32
    @NonNull
33
    @NotNull
34
    @Override
35
    public ViewHolder onCreateViewHolder(@NonNull @NotNull ViewGroup parent, int viewType) {
36
        View rootView = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_item_topic, parent, false);
37
        return new ViewHolder(rootView);
38
    }
39
40
    @Override
41
    public void onBindViewHolder(@NonNull @NotNull ViewHolder holder, int position) {
42
        holder.title.setText("标题"+position);
43
        holder.participateText.setText("内容够"+position+"参与");
44
        holder.onlookersText.setText("标题"+position+"围观");
45
        holder.itemView.setOnClickListener(v->{
46
            if (mListener!=null)
47
                mListener.onItemClick(position);
48
        });
49
    }
50
51
    @Override
52
    public int getItemCount() {
53
        return 20;
54
    }
55
56
    public static class ViewHolder extends RecyclerView.ViewHolder {
57
58
        private final TextView participateText;
59
        private final TextView title;
60
        private final TextView onlookersText;
61
62
        public ViewHolder(@NonNull @NotNull View itemView) {
63
            super(itemView);
64
            title = itemView.findViewById(R.id.title);
65
            participateText = itemView.findViewById(R.id.participateText);
66
            onlookersText = itemView.findViewById(R.id.onlookersText);
67
        }
68
    }
69
70
71
}

+ 9 - 0
app/src/main/res/drawable/bg_topic_tab.xml

@ -0,0 +1,9 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3
    <item android:width="66dp" android:height="28dp">
4
        <shape android:shape="rectangle">
5
            <stroke android:width="1dp" android:color="#ffdedede" />
6
            <corners android:radius="4dp" />
7
        </shape>
8
    </item>
9
</selector>

+ 67 - 0
app/src/main/res/layout/activity_slelect_topic.xml

@ -0,0 +1,67 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    android:layout_width="match_parent"
4
    android:layout_height="match_parent"
5
    xmlns:app="http://schemas.android.com/apk/res-auto"
6
    xmlns:tools="http://schemas.android.com/tools">
7
    <RelativeLayout
8
        app:layout_constraintTop_toTopOf="parent"
9
        app:layout_constraintEnd_toEndOf="parent"
10
        app:layout_constraintStart_toStartOf="parent"
11
        android:id="@+id/rl_title"
12
        android:layout_width="match_parent"
13
        android:layout_height="130px"
14
        android:layout_alignParentStart="true"
15
        android:layout_alignParentLeft="true"
16
        android:layout_alignParentTop="true"
17
        android:background="@color/title_background">
18
19
        <TextView
20
            android:textStyle="bold"
21
            android:layout_centerInParent="true"
22
            android:layout_width="wrap_content"
23
            android:layout_height="wrap_content"
24
            android:text="选择话题"
25
            android:textColor="#ff1a1b1f"
26
            android:textSize="18sp"
27
            />
28
        <ImageView
29
            android:id="@+id/iv_back"
30
            android:layout_width="wrap_content"
31
            android:layout_height="match_parent"
32
            android:layout_alignParentLeft="true"
33
            android:layout_centerVertical="true"
34
            android:contentDescription="@null"
35
            android:paddingLeft="12dp"
36
            android:paddingTop="4dp"
37
            android:paddingRight="12dp"
38
            android:paddingBottom="4dp"
39
            android:src="@drawable/icon_lvback1119"
40
            app:tint="#69B355" />
41
    </RelativeLayout>
42
43
    <androidx.recyclerview.widget.RecyclerView
44
        android:id="@+id/topicRecycelrView"
45
        android:layout_width="match_parent"
46
        android:layout_height="0dp"
47
        android:visibility="gone"
48
        tools:visibility="visible"
49
        app:layout_constraintBottom_toBottomOf="parent"
50
        app:layout_constraintEnd_toEndOf="parent"
51
        app:layout_constraintStart_toStartOf="parent"
52
        app:layout_constraintTop_toBottomOf="@+id/rl_title"
53
        tools:listitem="@layout/layout_item_topic" />
54
55
    <TextView
56
        android:visibility="visible"
57
        android:id="@+id/noDataText"
58
        android:layout_width="wrap_content"
59
        android:layout_height="wrap_content"
60
        android:text="没有相关话题"
61
        android:textColor="#ff7b7b7b"
62
        android:textSize="14sp"
63
        app:layout_constraintBottom_toBottomOf="parent"
64
        app:layout_constraintEnd_toEndOf="parent"
65
        app:layout_constraintStart_toStartOf="parent"
66
        app:layout_constraintTop_toBottomOf="@+id/rl_title" />
67
</androidx.constraintlayout.widget.ConstraintLayout>

+ 17 - 2
app/src/main/res/layout/activity_zhan_comment.xml

@ -36,12 +36,12 @@
36 36
        android:background="@color/title_background">
37 37
38 38
        <TextView
39
            android:drawablePadding="5dp"
40
            android:drawableEnd="@drawable/ic_comm_hint"
41 39
            android:id="@+id/tv_zhan_name"
42 40
            android:layout_width="wrap_content"
43 41
            android:layout_height="wrap_content"
44 42
            android:layout_centerInParent="true"
43
            android:drawableEnd="@drawable/ic_comm_hint"
44
            android:drawablePadding="5dp"
45 45
            android:text="发表评论"
46 46
            android:textColor="#222222"
47 47
            android:textSize="16sp" />
@ -198,6 +198,20 @@
198 198
                android:textSize="13sp"
199 199
                android:visibility="visible" />
200 200
201
202
            <TextView
203
                android:layout_marginBottom="13dp"
204
                android:id="@+id/topicText"
205
                android:background="@drawable/bg_topic_tab"
206
                android:layout_width="66dp"
207
                android:layout_height="28dp"
208
                android:layout_marginStart="15dp"
209
                android:gravity="center"
210
                android:text="╋  话题"
211
                android:textColor="#ff0e0e0e"
212
                android:textSize="13sp" />
213
214
201 215
            <GridView
202 216
                android:id="@+id/noScrollgridview"
203 217
                android:layout_width="match_parent"
@ -272,6 +286,7 @@
272 286
                    android:textColor="@color/white"
273 287
                    android:textSize="19sp" />
274 288
            </LinearLayout>
289
275 290
            <TextView
276 291
                android:layout_width="wrap_content"
277 292
                android:layout_height="wrap_content"

+ 58 - 0
app/src/main/res/layout/layout_item_topic.xml

@ -0,0 +1,58 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    android:layout_width="match_parent"
4
    xmlns:app="http://schemas.android.com/apk/res-auto"
5
    xmlns:tools="http://schemas.android.com/tools"
6
    android:padding="12dp"
7
    android:layout_height="wrap_content">
8
    <TextView
9
        app:layout_constraintTop_toTopOf="parent"
10
        app:layout_constraintStart_toStartOf="parent"
11
        android:id="@+id/topicImg"
12
        android:layout_width="wrap_content"
13
        android:layout_height="wrap_content"
14
        android:text="#"
15
        android:textColor="#3EC34C"
16
        android:textSize="13sp"
17
        />
18
19
    <TextView
20
        android:textStyle="bold"
21
        android:ellipsize="end"
22
        android:maxLines="1"
23
        android:layout_width="0dp"
24
        android:layout_height="wrap_content"
25
        android:layout_marginStart="4dp"
26
        tools:text="首届电动车主代表海选"
27
        android:textColor="#ff0e0e0e"
28
        android:textSize="14sp"
29
        app:layout_constraintBottom_toBottomOf="@+id/topicImg"
30
        android:id="@+id/title"
31
        app:layout_constraintEnd_toEndOf="parent"
32
        app:layout_constraintStart_toEndOf="@+id/topicImg"
33
        app:layout_constraintTop_toTopOf="@+id/topicImg" />
34
    <TextView
35
        android:id="@+id/participateText"
36
        android:layout_marginTop="8dp"
37
        app:layout_constraintStart_toStartOf="parent"
38
        app:layout_constraintTop_toBottomOf="@+id/topicImg"
39
        android:layout_width="wrap_content"
40
        android:layout_height="wrap_content"
41
        tools:text="1492车主参与"
42
        android:textColor="#ff7b7b7b"
43
        android:textSize="12sp"
44
        />
45
    <TextView
46
        android:id="@+id/onlookersText"
47
        android:layout_marginStart="16dp"
48
        app:layout_constraintBottom_toBottomOf="@+id/participateText"
49
        app:layout_constraintTop_toTopOf="@+id/participateText"
50
        app:layout_constraintStart_toEndOf="@+id/participateText"
51
        android:layout_width="wrap_content"
52
        android:layout_height="wrap_content"
53
        tools:text="1492车主围观"
54
        android:textColor="#ff7b7b7b"
55
        android:textSize="12sp"
56
        />
57
58
</androidx.constraintlayout.widget.ConstraintLayout>