|
@ -1,6 +1,9 @@
|
1
|
1
|
package com.electric.chargingpile.activity;
|
2
|
2
|
|
|
3
|
import android.content.BroadcastReceiver;
|
3
|
4
|
import android.content.Intent;
|
|
5
|
import android.os.Handler;
|
|
6
|
import android.os.Message;
|
4
|
7
|
import android.support.annotation.Nullable;
|
5
|
8
|
import android.support.constraint.ConstraintLayout;
|
6
|
9
|
import android.support.v4.app.Fragment;
|
|
@ -25,6 +28,7 @@ import com.electric.chargingpile.R;
|
25
|
28
|
import com.electric.chargingpile.application.MainApplication;
|
26
|
29
|
import com.electric.chargingpile.data.ChatBeanLab;
|
27
|
30
|
import com.electric.chargingpile.data.ChatRecommendBean;
|
|
31
|
import com.electric.chargingpile.iview.ChatVerticalViewPager;
|
28
|
32
|
import com.electric.chargingpile.manager.ProfileManager;
|
29
|
33
|
import com.electric.chargingpile.util.CircleTransform;
|
30
|
34
|
import com.electric.chargingpile.util.CommonParams;
|
|
@ -50,7 +54,6 @@ import org.w3c.dom.Text;
|
50
|
54
|
import java.util.HashMap;
|
51
|
55
|
import java.util.Map;
|
52
|
56
|
|
53
|
|
import fr.castorflex.android.verticalviewpager.VerticalViewPager;
|
54
|
57
|
import okhttp3.Call;
|
55
|
58
|
|
56
|
59
|
public class ChatContentListActivity extends AppCompatActivity {
|
|
@ -66,6 +69,20 @@ public class ChatContentListActivity extends AppCompatActivity {
|
66
|
69
|
public static boolean isFirstPlay;
|
67
|
70
|
private ChatContentAdapter chatContentAdapter;
|
68
|
71
|
private boolean isFirstShowNetworkDialog = true;
|
|
72
|
private ChatVerticalViewPager verticalViewPager;
|
|
73
|
private static final int UPDATE_VERTICAL_VIEW_PAGER_SCROLL = 1;
|
|
74
|
|
|
75
|
private Handler handler = new Handler() {
|
|
76
|
@Override
|
|
77
|
public void handleMessage(Message msg) {
|
|
78
|
switch (msg.what) {
|
|
79
|
case UPDATE_VERTICAL_VIEW_PAGER_SCROLL:
|
|
80
|
boolean isScroll = (boolean)msg.obj;
|
|
81
|
verticalViewPager.setScroll(isScroll);
|
|
82
|
break;
|
|
83
|
}
|
|
84
|
}
|
|
85
|
};
|
69
|
86
|
|
70
|
87
|
@Override
|
71
|
88
|
protected void onCreate(Bundle savedInstanceState) {
|
|
@ -112,8 +129,8 @@ public class ChatContentListActivity extends AppCompatActivity {
|
112
|
129
|
from = getIntent().getStringExtra("from");
|
113
|
130
|
index = getIntent().getIntExtra("index", 0);
|
114
|
131
|
|
115
|
|
final VerticalViewPager verticalViewPager = findViewById(R.id.verticalViewPager);
|
116
|
|
chatContentAdapter = new ChatContentAdapter(getSupportFragmentManager());
|
|
132
|
verticalViewPager = findViewById(R.id.verticalViewPager);
|
|
133
|
chatContentAdapter = new ChatContentAdapter(getSupportFragmentManager(), handler);
|
117
|
134
|
verticalViewPager.setAdapter(chatContentAdapter);
|
118
|
135
|
verticalViewPager.setCurrentItem(index);
|
119
|
136
|
verticalViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
|
@ -183,14 +200,17 @@ public class ChatContentListActivity extends AppCompatActivity {
|
183
|
200
|
public class ChatContentAdapter extends FragmentPagerAdapter {
|
184
|
201
|
|
185
|
202
|
public Map<String, ChatContentFragment> map = new HashMap<>();
|
|
203
|
private Handler handler;
|
186
|
204
|
|
187
|
|
public ChatContentAdapter(FragmentManager fm) {
|
|
205
|
public ChatContentAdapter(FragmentManager fm, Handler handler) {
|
188
|
206
|
super(fm);
|
|
207
|
this.handler = handler;
|
189
|
208
|
}
|
190
|
209
|
|
191
|
210
|
@Override
|
192
|
211
|
public android.support.v4.app.Fragment getItem(int i) {
|
193
|
212
|
ChatContentFragment fragment = ChatContentFragment.newInstance(i, from);
|
|
213
|
fragment.handler = handler;
|
194
|
214
|
map.put(i + "", fragment);
|
195
|
215
|
return fragment;
|
196
|
216
|
}
|
|
@ -203,6 +223,7 @@ public class ChatContentListActivity extends AppCompatActivity {
|
203
|
223
|
|
204
|
224
|
|
205
|
225
|
public static class ChatContentFragment extends Fragment implements View.OnClickListener {
|
|
226
|
private Handler handler;
|
206
|
227
|
private static final String ARG_INDEX = "index";
|
207
|
228
|
private static final String ARG_FROM = "from";
|
208
|
229
|
private VideoPlayer videoPlayer;
|
|
@ -339,6 +360,8 @@ public class ChatContentListActivity extends AppCompatActivity {
|
339
|
360
|
rootView.findViewById(R.id.comment).setOnClickListener(this);
|
340
|
361
|
allCommentsContainer.setOnClickListener(this);
|
341
|
362
|
allComments.setOnClickListener(this);
|
|
363
|
rootView.findViewById(R.id.allCommentsClose).setOnClickListener(this);
|
|
364
|
rootView.findViewById(R.id.bWriteComment).setOnClickListener(this);
|
342
|
365
|
}
|
343
|
366
|
|
344
|
367
|
@Override
|
|
@ -372,13 +395,30 @@ public class ChatContentListActivity extends AppCompatActivity {
|
372
|
395
|
break;
|
373
|
396
|
case R.id.writeComment: // 评论列表
|
374
|
397
|
case R.id.comment:
|
|
398
|
setViewPagerScroll(false);
|
375
|
399
|
allCommentsContainer.setVisibility(View.VISIBLE);
|
376
|
400
|
break;
|
|
401
|
case R.id.allCommentsClose: // 关闭评论
|
377
|
402
|
case R.id.allCommentsContainer:
|
|
403
|
setViewPagerScroll(true);
|
378
|
404
|
allCommentsContainer.setVisibility(View.GONE);
|
379
|
405
|
break;
|
|
406
|
case R.id.bWriteComment: // 写评论
|
|
407
|
|
|
408
|
break;
|
380
|
409
|
}
|
|
410
|
}
|
381
|
411
|
|
|
412
|
private void setViewPagerScroll(final boolean isScroll) {
|
|
413
|
new Thread(new Runnable() {
|
|
414
|
@Override
|
|
415
|
public void run() {
|
|
416
|
Message message = new Message();
|
|
417
|
message.what = UPDATE_VERTICAL_VIEW_PAGER_SCROLL;
|
|
418
|
message.obj = isScroll;
|
|
419
|
handler.sendMessage(message);
|
|
420
|
}
|
|
421
|
}).start();
|
382
|
422
|
}
|
383
|
423
|
|
384
|
424
|
private void initCommonView(final View rootView, final ChatRecommendBean bean) {
|