Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev
This commit is contained in:
@ -140,6 +140,7 @@
|
||||
-keep class com.gh.common.view.** {*;}
|
||||
-keep class com.gh.gamecenter.db.info.** {*;}
|
||||
-keep class com.gh.gamecenter.entity.** {*;}
|
||||
-keep class com.gh.gamecenter.ask.entity.** {*;}
|
||||
-keep class com.gh.gamecenter.retrofit.** {*;}
|
||||
-keep class com.gh.gamecenter.eventbus.** {*;}
|
||||
-keep class * extends rx.Subscriber
|
||||
|
||||
@ -20,7 +20,7 @@ import rx.schedulers.Schedulers
|
||||
object CollectionUtils {
|
||||
|
||||
enum class CollectionType {
|
||||
toolkit, article
|
||||
toolkit, article, answer
|
||||
}
|
||||
|
||||
fun postCollection(context: Context, content: String, type: CollectionType, listener: OnCollectionListener) {
|
||||
@ -29,6 +29,7 @@ object CollectionUtils {
|
||||
val postCollection = when (type) {
|
||||
CollectionType.article -> RetrofitManager.getInstance(context).getApi().postCollectionArticle(body)
|
||||
CollectionType.toolkit -> RetrofitManager.getInstance(context).getApi().postCollectionTools(body)
|
||||
CollectionType.answer -> RetrofitManager.getInstance(context).getApi().postCollectionAnswer(content)
|
||||
}
|
||||
postCollection
|
||||
.subscribeOn(Schedulers.io())
|
||||
@ -37,6 +38,7 @@ object CollectionUtils {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener.onSuccess()
|
||||
if(type != CollectionType.answer)
|
||||
EventBus.getDefault().post(EBCollectionChanged(JSONObject(content).getString("_id"), true, type))
|
||||
}
|
||||
|
||||
@ -65,6 +67,7 @@ object CollectionUtils {
|
||||
when (type) {
|
||||
CollectionType.article -> postCollection = RetrofitManager.getInstance(context).getApi().deletaCollectionArticle(id)
|
||||
CollectionType.toolkit -> postCollection = RetrofitManager.getInstance(context).getApi().deleteCollectionTools(id)
|
||||
CollectionType.answer -> postCollection = RetrofitManager.getInstance(context).getApi().deleteCollectionAnswer(id)
|
||||
}
|
||||
postCollection
|
||||
.subscribeOn(Schedulers.io())
|
||||
@ -73,6 +76,7 @@ object CollectionUtils {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener.onSuccess()
|
||||
if(type != CollectionType.answer)
|
||||
EventBus.getDefault().post(EBCollectionChanged(id, false, type))
|
||||
}
|
||||
|
||||
@ -87,6 +91,9 @@ object CollectionUtils {
|
||||
val postCollection = when (type) {
|
||||
CollectionType.article -> RetrofitManager.getInstance(context).getApi().patchCollectionArticle(id)
|
||||
CollectionType.toolkit -> RetrofitManager.getInstance(context).getApi().patchCollectionTools(id)
|
||||
else -> {
|
||||
return
|
||||
}
|
||||
}
|
||||
postCollection
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
@ -27,7 +27,7 @@ object ConcernUtils {
|
||||
.postConcern(body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>(){
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener?.onSuccess()
|
||||
@ -46,7 +46,7 @@ object ConcernUtils {
|
||||
.deleteConcern(gameId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>(){
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener?.onSuccess()
|
||||
@ -75,6 +75,42 @@ object ConcernUtils {
|
||||
})
|
||||
}
|
||||
|
||||
fun deleteConcernQuestions(context: Context, questionsId: String, listener: onConcernListener?) {
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
.deleteConcernQuestions(questionsId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener?.onSuccess()
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
listener?.onError()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun postConcernQuestions(context: Context, questionsId: String, listener: onConcernListener?) {
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
.postConcernQuestions(questionsId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener?.onSuccess()
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
listener?.onError()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
interface onConcernListener {
|
||||
fun onSuccess()
|
||||
|
||||
@ -56,7 +56,11 @@ public class EntranceUtils {
|
||||
public static final String KEY_PROLIST = "provinceList";
|
||||
public static final String KEY_ORDER = "order";
|
||||
public static final String KEY_TAGTYPE = "tagType";
|
||||
public static final String KEY_ANSWER_ID = "answerId";
|
||||
public static final String KEY_ANSWER_CONTENT = "answerContent";
|
||||
public static final String KEY_QUESTIONS_ID = "questionsId";
|
||||
public static final String KEY_QUESTIONS_TITLE = "questionsTitle";
|
||||
public static final String KEY_QUESTIONS_PATCH = "questionsPatch";
|
||||
|
||||
public static void jumpActivity(Context context, Bundle bundle) {
|
||||
|
||||
|
||||
@ -9,7 +9,6 @@ import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.gamecenter.ask.questionsdetail.AnswerEditFragment;
|
||||
import com.gh.gamecenter.ask.questionsdetail.AnswerFoldFragment;
|
||||
@ -28,10 +27,10 @@ public class AskQuestionsDetailActivity extends BaseActivity implements Fragment
|
||||
public static final String QUESTIONS_DETAIL = "questions_detail";
|
||||
|
||||
private QuestionsDetailFragment mQuestionsDetailFragment;
|
||||
private AnswerEditFragment mAnswerEditFragment;
|
||||
// private AnswerEditFragment mAnswerEditFragment;
|
||||
|
||||
private View mShareIv;
|
||||
private View mAnswerPost;
|
||||
// private View mAnswerPost;
|
||||
|
||||
private String mQuestionsId;
|
||||
|
||||
@ -54,26 +53,24 @@ public class AskQuestionsDetailActivity extends BaseActivity implements Fragment
|
||||
getSupportFragmentManager().addOnBackStackChangedListener(this);
|
||||
show(QUESTIONS_DETAIL);
|
||||
|
||||
findViewById(R.id.actionbar_rl_back)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mQuestionsDetailFragment.isVisible()) {
|
||||
finish();
|
||||
} else {
|
||||
getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onHandleBackPressed() {
|
||||
if (mQuestionsDetailFragment.isVisible()) {
|
||||
finish();
|
||||
} else {
|
||||
getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (view == mAnswerPost) {
|
||||
mAnswerEditFragment.postAnswer();
|
||||
} else if (view == mShareIv) {
|
||||
// if (view == mAnswerPost) {
|
||||
// mAnswerEditFragment.postAnswer();
|
||||
// } else
|
||||
if (view == mShareIv) {
|
||||
|
||||
}
|
||||
}
|
||||
@ -88,16 +85,16 @@ public class AskQuestionsDetailActivity extends BaseActivity implements Fragment
|
||||
mShareIv.setOnClickListener(this);
|
||||
}
|
||||
|
||||
private void addAnswerPostView() {
|
||||
RelativeLayout reuse_actionbar = mContentView.findViewById(R.id.reuse_actionbar);
|
||||
mAnswerPost = LayoutInflater.from(this).inflate(R.layout.menu_action_post, reuse_actionbar, false);
|
||||
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
|
||||
DisplayUtils.dip2px(this, 48), DisplayUtils.dip2px(this, 24));
|
||||
params.addRule(RelativeLayout.CENTER_VERTICAL);
|
||||
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||
reuse_actionbar.addView(mAnswerPost, params);
|
||||
mAnswerPost.setOnClickListener(this);
|
||||
}
|
||||
// private void addAnswerPostView() {
|
||||
// RelativeLayout reuse_actionbar = mContentView.findViewById(R.id.reuse_actionbar);
|
||||
// mAnswerPost = LayoutInflater.from(this).inflate(R.layout.menu_action_post, reuse_actionbar, false);
|
||||
// RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
|
||||
// DisplayUtils.dip2px(this, 48), DisplayUtils.dip2px(this, 24));
|
||||
// params.addRule(RelativeLayout.CENTER_VERTICAL);
|
||||
// params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||
// reuse_actionbar.addView(mAnswerPost, params);
|
||||
// mAnswerPost.setOnClickListener(this);
|
||||
// }
|
||||
|
||||
public void show(String type) {
|
||||
showMenu(type);
|
||||
@ -144,26 +141,31 @@ public class AskQuestionsDetailActivity extends BaseActivity implements Fragment
|
||||
}
|
||||
|
||||
private void showAnswerEdit(String type) {
|
||||
mAnswerEditFragment = new AnswerEditFragment();
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.addToBackStack(type)
|
||||
.replace(R.id.layout_fragment_content, mAnswerEditFragment)
|
||||
.commitAllowingStateLoss();
|
||||
// mAnswerEditFragment = AnswerEditFragment.getInstance(mQuestionsId, mQuestionsDetailFragment.getQuestionsTitle());
|
||||
// getSupportFragmentManager()
|
||||
// .beginTransaction()
|
||||
// .addToBackStack(type)
|
||||
// .replace(R.id.layout_fragment_content, mAnswerEditFragment)
|
||||
// .commitAllowingStateLoss();
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(EntranceUtils.KEY_QUESTIONS_ID, mQuestionsId);
|
||||
bundle.putString(EntranceUtils.KEY_QUESTIONS_TITLE, mQuestionsDetailFragment.getQuestionsTitle());
|
||||
NormalActivity.startFragment(this, AnswerEditFragment.class, bundle);
|
||||
}
|
||||
|
||||
private void showMenu(String type) {
|
||||
switch (type) {
|
||||
case QUESTIONS_DETAIL_ANSWER:
|
||||
setNavigationTitle("编辑答案");
|
||||
if (mAnswerPost == null) {
|
||||
addAnswerPostView();
|
||||
} else {
|
||||
mAnswerPost.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (mShareIv != null && mShareIv.getVisibility() == View.VISIBLE)
|
||||
mShareIv.setVisibility(View.GONE);
|
||||
break;
|
||||
// case QUESTIONS_DETAIL_ANSWER:
|
||||
// setNavigationTitle("编辑答案");
|
||||
// if (mAnswerPost == null) {
|
||||
// addAnswerPostView();
|
||||
// } else {
|
||||
// mAnswerPost.setVisibility(View.VISIBLE);
|
||||
// }
|
||||
// if (mShareIv != null && mShareIv.getVisibility() == View.VISIBLE)
|
||||
// mShareIv.setVisibility(View.GONE);
|
||||
// break;
|
||||
case QUESTIONS_DETAIL:
|
||||
setNavigationTitle("问题详情");
|
||||
if (mShareIv == null) {
|
||||
@ -171,22 +173,22 @@ public class AskQuestionsDetailActivity extends BaseActivity implements Fragment
|
||||
} else {
|
||||
mShareIv.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (mAnswerPost != null && mAnswerPost.getVisibility() == View.VISIBLE)
|
||||
mAnswerPost.setVisibility(View.GONE);
|
||||
// if (mAnswerPost != null && mAnswerPost.getVisibility() == View.VISIBLE)
|
||||
// mAnswerPost.setVisibility(View.GONE);
|
||||
break;
|
||||
case QUESTIONS_DETAIL_INVITE:
|
||||
setNavigationTitle("达人推荐");
|
||||
if (mShareIv != null && mShareIv.getVisibility() == View.VISIBLE)
|
||||
mShareIv.setVisibility(View.GONE);
|
||||
if (mAnswerPost != null && mAnswerPost.getVisibility() == View.VISIBLE)
|
||||
mAnswerPost.setVisibility(View.GONE);
|
||||
// if (mAnswerPost != null && mAnswerPost.getVisibility() == View.VISIBLE)
|
||||
// mAnswerPost.setVisibility(View.GONE);
|
||||
break;
|
||||
case QUESTIONS_DETAIL_FOLD:
|
||||
setNavigationTitle("折叠答案");
|
||||
if (mShareIv != null && mShareIv.getVisibility() == View.VISIBLE)
|
||||
mShareIv.setVisibility(View.GONE);
|
||||
if (mAnswerPost != null && mAnswerPost.getVisibility() == View.VISIBLE)
|
||||
mAnswerPost.setVisibility(View.GONE);
|
||||
// if (mAnswerPost != null && mAnswerPost.getVisibility() == View.VISIBLE)
|
||||
// mAnswerPost.setVisibility(View.GONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,6 +139,7 @@ public class AskTabOrderActivity extends BaseActivity {
|
||||
int fromPosition = viewHolder.getAdapterPosition();//得到拖动ViewHolder的position
|
||||
int toPosition = target.getAdapterPosition();//得到目标ViewHolder的position
|
||||
|
||||
if (toPosition == 0) return false;
|
||||
if (fromPosition < toPosition) {
|
||||
for (int i = fromPosition; i < toPosition; i++) {
|
||||
Collections.swap(mTagList, i, i + 1);
|
||||
|
||||
@ -128,11 +128,10 @@ public class NormalActivity extends BaseActivity implements ToolbarController, T
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
List<Fragment> fragments = getSupportFragmentManager().getFragments();
|
||||
for (Fragment fragment : fragments) {
|
||||
fragment.onActivityResult(requestCode, resultCode, data);
|
||||
public void onBackPressed() {
|
||||
if (mTargetFragment instanceof NormalFragment && !((NormalFragment) mTargetFragment).onBackPressed()) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,24 +1,36 @@
|
||||
package com.gh.gamecenter.ask;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.common.util.CheckLoginUtils;
|
||||
import com.gh.common.util.CollectionUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.view.RichEditor;
|
||||
import com.gh.gamecenter.NormalActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ask.entity.AnswerDetailEntity;
|
||||
import com.gh.gamecenter.ask.entity.AnswerEntity;
|
||||
import com.gh.gamecenter.ask.entity.MeEntity;
|
||||
import com.gh.gamecenter.ask.questionsdetail.AnswerEditFragment;
|
||||
import com.gh.gamecenter.entity.UserEntity;
|
||||
import com.gh.gamecenter.normal.NormalFragment;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.lightgame.config.CommonDebug;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.HttpException;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
@ -31,8 +43,8 @@ public class AskAnswerDetailFragment extends NormalFragment {
|
||||
|
||||
@BindView(R.id.answer_detail_title)
|
||||
TextView mTitle;
|
||||
@BindView(R.id.answer_detail_content)
|
||||
RichEditor mContent;
|
||||
@BindView(R.id.answer_detail_Rd)
|
||||
RichEditor mRichEditor;
|
||||
@BindView(R.id.answer_detail_time)
|
||||
TextView mTime;
|
||||
@BindView(R.id.answer_detail_edit)
|
||||
@ -45,11 +57,18 @@ public class AskAnswerDetailFragment extends NormalFragment {
|
||||
SimpleDraweeView mUsericon;
|
||||
@BindView(R.id.answer_detail_username)
|
||||
TextView mUsername;
|
||||
@BindView(R.id.reuse_no_connection)
|
||||
View mNoConn;
|
||||
@BindView(R.id.answer_detail_loading)
|
||||
View mLoading;
|
||||
@BindView(R.id.answer_detail_content)
|
||||
View mContent;
|
||||
|
||||
private static final int ANSWER_PATCH_REQUEST = 100;
|
||||
|
||||
private AnswerEntity mAnswerEntity;
|
||||
private AnswerDetailEntity mDetailEntity;
|
||||
|
||||
// todo 逐步完善
|
||||
public static AskAnswerDetailFragment getInstance(AnswerEntity entity) {
|
||||
AskAnswerDetailFragment fragment = new AskAnswerDetailFragment();
|
||||
Bundle args = new Bundle();
|
||||
@ -63,6 +82,15 @@ public class AskAnswerDetailFragment extends NormalFragment {
|
||||
return R.layout.fragment_answer_detail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == Activity.RESULT_OK && requestCode == ANSWER_PATCH_REQUEST) {
|
||||
mDetailEntity.setContent(data.getStringExtra(EntranceUtils.KEY_ANSWER_CONTENT));
|
||||
initView();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -72,6 +100,73 @@ public class AskAnswerDetailFragment extends NormalFragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
setNavigationTitle(getString(R.string.answer_detail_title));
|
||||
initMenu(R.menu.menu_web);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMenuItemClick(MenuItem menuItem) {
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.menu_share:
|
||||
toast(R.string.share);
|
||||
break;
|
||||
case R.id.menu_collect:
|
||||
if (!mDetailEntity.getMe().isAnswerFavorite()) {
|
||||
CollectionUtils.INSTANCE.postCollection(getContext(), mAnswerEntity.getId()
|
||||
, CollectionUtils.CollectionType.answer, new CollectionUtils.OnCollectionListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
toast(R.string.collection_success);
|
||||
MeEntity me = mDetailEntity.getMe();
|
||||
me.setAnswerFavorite(true);
|
||||
mDetailEntity.setMe(me);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
toast(R.string.collection_failure);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
CollectionUtils.INSTANCE.deleteCollection(getContext(), mAnswerEntity.getId()
|
||||
, CollectionUtils.CollectionType.answer, new CollectionUtils.OnCollectionListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
MeEntity me = mDetailEntity.getMe();
|
||||
me.setAnswerFavorite(false);
|
||||
mDetailEntity.setMe(me);
|
||||
if (CommonDebug.IS_DEBUG)
|
||||
toast("取消收藏成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
toast(R.string.collection_cancel_failure);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick({R.id.answer_detail_edit, R.id.answer_detail_vote})
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.answer_detail_edit:
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(EntranceUtils.KEY_ANSWER_ID, mAnswerEntity.getId());
|
||||
bundle.putString(EntranceUtils.KEY_QUESTIONS_TITLE, mAnswerEntity.getQuestions().getTitle());
|
||||
bundle.putString(EntranceUtils.KEY_ANSWER_CONTENT, mDetailEntity.getContent());
|
||||
NormalActivity.startFragmentForResult(getContext(), AnswerEditFragment.class, bundle, ANSWER_PATCH_REQUEST);
|
||||
break;
|
||||
case R.id.answer_detail_vote:
|
||||
CheckLoginUtils.checkLogin(getContext(), this::postVote);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
RetrofitManager.getInstance(getContext()).getApi()
|
||||
.getAnswerDetail(mAnswerEntity.getId())
|
||||
@ -81,7 +176,70 @@ public class AskAnswerDetailFragment extends NormalFragment {
|
||||
@Override
|
||||
public void onResponse(AnswerDetailEntity response) {
|
||||
super.onResponse(response);
|
||||
initView(response);
|
||||
mDetailEntity = response;
|
||||
initView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException e) {
|
||||
super.onFailure(e);
|
||||
mNoConn.setVisibility(View.VISIBLE);
|
||||
mLoading.setVisibility(View.GONE);
|
||||
mContent.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
UserEntity user = mDetailEntity.getUser();
|
||||
if (user != null) {
|
||||
ImageUtils.Companion.display(mUsericon, user.getIcon());
|
||||
mUsername.setText(user.getName());
|
||||
}
|
||||
|
||||
if (mDetailEntity.getMe().isAnswerOwn()) {
|
||||
mEditBtn.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mEditBtn.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
mTitle.setText(mAnswerEntity.getQuestions().getTitle());
|
||||
|
||||
mRichEditor.setHtml(mDetailEntity.getContent());
|
||||
mRichEditor.setInputEnabled(false);
|
||||
|
||||
mNoConn.setVisibility(View.GONE);
|
||||
mLoading.setVisibility(View.GONE);
|
||||
mContent.setVisibility(View.VISIBLE);
|
||||
|
||||
initVote();
|
||||
}
|
||||
|
||||
private void initVote() {
|
||||
mVoteCount.setText(getString(R.string.ask_vote_count, mAnswerEntity.getVote()));
|
||||
|
||||
if (mDetailEntity.getMe().isAnswerVoted()) {
|
||||
mVote.setImageResource(R.drawable.answer_detail_vote);
|
||||
} else {
|
||||
mVote.setImageResource(R.drawable.answer_detail_unvote);
|
||||
}
|
||||
}
|
||||
|
||||
private void postVote() {
|
||||
RetrofitManager.getInstance(getContext()).getApi()
|
||||
.postAnswerVote(mAnswerEntity.getId())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<ResponseBody>() {
|
||||
@Override
|
||||
public void onResponse(ResponseBody response) {
|
||||
super.onResponse(response);
|
||||
MeEntity me = mDetailEntity.getMe();
|
||||
me.setAnswerVoted(true);
|
||||
mDetailEntity.setMe(me);
|
||||
int vote = mAnswerEntity.getVote() + 1;
|
||||
mAnswerEntity.setVote(vote);
|
||||
initVote();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -90,22 +248,4 @@ public class AskAnswerDetailFragment extends NormalFragment {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initView(AnswerDetailEntity entity) {
|
||||
UserEntity user = entity.getUser();
|
||||
if (user != null) {
|
||||
ImageUtils.Companion.display(mUsericon, user.getIcon());
|
||||
mUsername.setText(user.getName());
|
||||
}
|
||||
|
||||
MeEntity me = entity.getMe();
|
||||
if (me != null && me.isCommunityVoted()) {
|
||||
mEditBtn.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
mTitle.setText("");
|
||||
mVoteCount.setText(getString(R.string.ask_vote_count, entity.getVote()));
|
||||
mContent.setHtml(entity.getContent());
|
||||
mContent.setInputEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,6 +37,7 @@ public class AskQuestionsHotFragment extends ListFragment {
|
||||
|
||||
@Override
|
||||
public void onListClick(View view, int position, Object data) {
|
||||
List<QuestionsEntity> questionsList;
|
||||
switch (view.getId()) {
|
||||
case R.id.footerview_item:
|
||||
if (mAdapter.isNetworkError()) {
|
||||
@ -45,9 +46,19 @@ public class AskQuestionsHotFragment extends ListFragment {
|
||||
}
|
||||
break;
|
||||
case R.id.ask_item_constraintlayout:
|
||||
List<QuestionsEntity> questionsList = (List<QuestionsEntity>) data;
|
||||
break;
|
||||
case R.id.ask_item_title:
|
||||
questionsList = (List<QuestionsEntity>) data;
|
||||
startActivity(AskQuestionsDetailActivity.getIntent(getContext(), questionsList.get(position).getQuestion().getId()));
|
||||
break;
|
||||
case R.id.ask_item_content:
|
||||
questionsList = (List<QuestionsEntity>) data;
|
||||
|
||||
|
||||
// Bundle bundle = new Bundle();
|
||||
// bundle.putParcelable(AnswerEntity.TAG, entityList.get(position));
|
||||
// NormalActivity.startFragment(getContext(), AskAnswerDetailFragment.class, bundle);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ public class AskQuestionsHotViewHolder extends BaseRecyclerViewHolder {
|
||||
@BindView(R.id.ask_item_username)
|
||||
TextView mAskUsername;
|
||||
@BindView(R.id.ask_item_title)
|
||||
public TextView mAskTitle;
|
||||
TextView mAskTitle;
|
||||
@BindView(R.id.ask_item_content)
|
||||
TextView mAskContent;
|
||||
@BindView(R.id.ask_item_img)
|
||||
@ -40,6 +40,8 @@ public class AskQuestionsHotViewHolder extends BaseRecyclerViewHolder {
|
||||
public AskQuestionsHotViewHolder(View itemView, Object data, OnListClickListener listClickListener) {
|
||||
super(itemView, data, listClickListener);
|
||||
itemView.setOnClickListener(this);
|
||||
mAskTitle.setOnClickListener(this);
|
||||
mAskContent.setOnClickListener(this);
|
||||
}
|
||||
|
||||
public void initQuestionsHotViewHolder(Context context, QuestionsEntity entity) {
|
||||
@ -56,7 +58,10 @@ public class AskQuestionsHotViewHolder extends BaseRecyclerViewHolder {
|
||||
}
|
||||
List<String> images = entity.getImages();
|
||||
if (images != null && images.size() > 0) {
|
||||
mAskImg.setVisibility(View.VISIBLE);
|
||||
ImageUtils.Companion.display(mAskImg, images.get(0));
|
||||
} else {
|
||||
mAskImg.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,6 @@ import com.gh.base.OnListClickListener;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
||||
import com.gh.gamecenter.ask.entity.QuestionsEntity;
|
||||
import com.gh.gamecenter.ask.entity.Questions;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
@ -24,7 +23,7 @@ public class AskQuestionsNewBodyAdapter extends ListAdapter {
|
||||
|
||||
private OnListClickListener mListClickListener;
|
||||
|
||||
private List<QuestionsEntity> mEntityList;
|
||||
private List<Questions> mEntityList;
|
||||
|
||||
|
||||
public AskQuestionsNewBodyAdapter(Context context, OnListClickListener listClickListener) {
|
||||
@ -34,7 +33,7 @@ public class AskQuestionsNewBodyAdapter extends ListAdapter {
|
||||
|
||||
@Override
|
||||
protected <T> void provideListData(List<T> listData) {
|
||||
mEntityList = (List<QuestionsEntity>) listData;
|
||||
mEntityList = (List<Questions>) listData;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@ -69,7 +68,7 @@ public class AskQuestionsNewBodyAdapter extends ListAdapter {
|
||||
return new FooterViewHolder(view, null, mListClickListener);
|
||||
case ItemViewType.ITEM_BODY:
|
||||
view = mLayoutInflater.inflate(R.layout.ask_questions_new_item, parent, false);
|
||||
return new AskQuestionsNewViewHolder(view, null, mListClickListener);
|
||||
return new AskQuestionsNewViewHolder(view, mEntityList, mListClickListener);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@ -79,13 +78,7 @@ public class AskQuestionsNewBodyAdapter extends ListAdapter {
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
switch (getItemViewType(position)) {
|
||||
case ItemViewType.ITEM_BODY:
|
||||
QuestionsEntity askEntity = mEntityList.get(position);
|
||||
AskQuestionsNewViewHolder askHolder = (AskQuestionsNewViewHolder) holder;
|
||||
askHolder.mAnswerCount.setText(mContext.getString(R.string.ask_answer_count, askEntity.getAnswers()));
|
||||
Questions question = askEntity.getQuestion();
|
||||
if (question != null) {
|
||||
askHolder.mTitle.setText(question.getTitle());
|
||||
}
|
||||
((AskQuestionsNewViewHolder) holder).initAskQuestionsNewViewHolder(mEntityList.get(position));
|
||||
break;
|
||||
case ItemViewType.ITEM_FOOTER:
|
||||
FooterViewHolder footerViewHolder = (FooterViewHolder) holder;
|
||||
|
||||
@ -4,8 +4,9 @@ import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
|
||||
import com.gh.gamecenter.AskQuestionsDetailActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ask.entity.QuestionsEntity;
|
||||
import com.gh.gamecenter.ask.entity.Questions;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListFragment;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
@ -26,13 +27,11 @@ public class AskQuestionsNewBodyFragment extends ListFragment {
|
||||
|
||||
private AskQuestionsNewBodyAdapter mAdapter;
|
||||
|
||||
private String mCommunityId;
|
||||
private String mType;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mCommunityId = UserManager.getInstance().getCommunityId(getContext());
|
||||
mType = getArguments().getString(AskQuestionsNewFragment.ASK_QUESTIONS_TYPE);
|
||||
}
|
||||
|
||||
@ -43,8 +42,9 @@ public class AskQuestionsNewBodyFragment extends ListFragment {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Observable<List<QuestionsEntity>> provideDataObservable() {
|
||||
return RetrofitManager.getInstance(getContext()).getApi().getAskQuestions(mCommunityId, mType, getListOffset());
|
||||
public Observable<List<Questions>> provideDataObservable() {
|
||||
return RetrofitManager.getInstance(getContext()).getApi()
|
||||
.getAskQuestions(UserManager.getInstance().getCommunityId(getContext()), mType, getListOffset());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -56,6 +56,10 @@ public class AskQuestionsNewBodyFragment extends ListFragment {
|
||||
mListViewModel.load(LoadType.RETRY);
|
||||
}
|
||||
break;
|
||||
case R.id.ask_questions_new_item:
|
||||
List<Questions> questionsList = (List<Questions>) data;
|
||||
startActivity(AskQuestionsDetailActivity.getIntent(getContext(), questionsList.get(position).getId()));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import android.widget.TextView;
|
||||
import com.gh.base.BaseRecyclerViewHolder;
|
||||
import com.gh.base.OnListClickListener;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ask.entity.Questions;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
||||
@ -22,5 +23,11 @@ public class AskQuestionsNewViewHolder extends BaseRecyclerViewHolder {
|
||||
|
||||
public AskQuestionsNewViewHolder(View itemView, Object data, OnListClickListener listClickListener) {
|
||||
super(itemView, data, listClickListener);
|
||||
itemView.setOnClickListener(this);
|
||||
}
|
||||
|
||||
public void initAskQuestionsNewViewHolder(Questions questions) {
|
||||
mAnswerCount.setText(itemView.getContext().getString(R.string.ask_answer_count, questions.getAnswerCount()));
|
||||
mTitle.setText(questions.getTitle());
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@ -22,19 +23,37 @@ import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.fragment.WaitingDialogFragment;
|
||||
import com.gh.common.util.CheckLoginUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.GsonUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ask.entity.QuestionsDetailEntity;
|
||||
import com.gh.gamecenter.manager.UserManager;
|
||||
import com.gh.gamecenter.normal.NormalFragment;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.gh.gamecenter.suggest.SuggestPicAdapter;
|
||||
import com.google.android.flexbox.FlexboxLayout;
|
||||
import com.lightgame.utils.Util_System_Keyboard;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.HttpException;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
import static com.gh.gamecenter.SuggestionActivity.MEDIA_STORE_REQUEST;
|
||||
|
||||
@ -57,6 +76,10 @@ public class QuestionsEditFragment extends NormalFragment {
|
||||
|
||||
private SuggestPicAdapter mAdapter;
|
||||
|
||||
private WaitingDialogFragment mPostDialog;
|
||||
|
||||
private List<String> mTagList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
@ -98,10 +121,16 @@ public class QuestionsEditFragment extends NormalFragment {
|
||||
return R.layout.fragment_questions_edit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getCommunitiesTags();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
setNavigationTitle("");
|
||||
setNavigationTitle("社区对应的游戏名字");
|
||||
mPicRv.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.HORIZONTAL, false));
|
||||
|
||||
// 意见反馈上传图片列表
|
||||
@ -115,24 +144,132 @@ public class QuestionsEditFragment extends NormalFragment {
|
||||
mPicRv.setAdapter(mAdapter);
|
||||
}
|
||||
|
||||
@OnClick({R.id.questionsedit_tag_add})
|
||||
@OnClick({R.id.questionsedit_tag_add, R.id.questionsedit_post})
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.questionsedit_tag_add) {
|
||||
showAddTagDialog();
|
||||
switch (v.getId()) {
|
||||
case R.id.questionsedit_tag_add:
|
||||
showAddTagDialog();
|
||||
break;
|
||||
case R.id.questionsedit_post:
|
||||
mPostDialog = WaitingDialogFragment.newInstance(getString(R.string.vote_post));
|
||||
mPostDialog.show(getChildFragmentManager(), null);
|
||||
|
||||
CheckLoginUtils.checkLogin(getContext(), () -> {
|
||||
ImageUtils.Companion.postImageArr(getContext(), mAdapter.getFileList(), new ImageUtils.OnPostImageListener() {
|
||||
@Override
|
||||
public void postError() {
|
||||
mPostDialog.dismissAllowingStateLoss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postSuccess(@NotNull HashMap<String, String> imgMap) {
|
||||
List<String> imgs = new ArrayList<>();
|
||||
for (String s : imgMap.keySet()) {
|
||||
imgs.add(imgMap.get(s));
|
||||
}
|
||||
postQuestions(imgs);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void getCommunitiesTags() {
|
||||
|
||||
RetrofitManager.getInstance(getContext()).getApi()
|
||||
.getCommunitiesTags(UserManager.getInstance().getCommunityId(getContext()))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<List<String>>() {
|
||||
@Override
|
||||
public void onResponse(List<String> response) {
|
||||
for (String s : response) {
|
||||
addTag(s, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException e) {
|
||||
Utils.log("QuestionsEdit-> getCommunitiesTags: onFailure");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void addTag(String tag) {
|
||||
private void postQuestions(List<String> imgs) {
|
||||
String title = mTitle.getText().toString();
|
||||
if (TextUtils.isEmpty(title)) {
|
||||
toast("标题不能为空");
|
||||
mPostDialog.dismissAllowingStateLoss();
|
||||
return;
|
||||
}
|
||||
String content = mContent.getText().toString();
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
toast("内容不能为空");
|
||||
mPostDialog.dismissAllowingStateLoss();
|
||||
return;
|
||||
}
|
||||
|
||||
QuestionsDetailEntity entity = new QuestionsDetailEntity();
|
||||
entity.setTitle(title);
|
||||
entity.setTags(mTagList);
|
||||
entity.setImages(imgs);
|
||||
entity.setDescription(content);
|
||||
String jsonBody = GsonUtils.Companion.getInstance().toJson(entity);
|
||||
Utils.log("postQuestions->Body:" + jsonBody);
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"), jsonBody);
|
||||
RetrofitManager.getInstance(getContext()).getApi()
|
||||
.postQuestions(body, UserManager.getInstance().getCommunityId(getContext()))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<ResponseBody>() {
|
||||
@Override
|
||||
public void onResponse(ResponseBody response) {
|
||||
super.onResponse(response);
|
||||
mPostDialog.dismissAllowingStateLoss();
|
||||
toast("提交成功");
|
||||
if (getActivity() != null) getActivity().finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException e) {
|
||||
super.onFailure(e);
|
||||
mPostDialog.dismissAllowingStateLoss();
|
||||
toast("提交失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addTag(String tag, boolean isDefault) {
|
||||
View view = LayoutInflater.from(getContext()).inflate(R.layout.questionsdedit_tag_item, null);
|
||||
TextView tagTv = (TextView) view;
|
||||
tagTv.setText(tag);
|
||||
if (!isDefault) {
|
||||
tagTv.setBackgroundResource(R.drawable.comment_border_bg);
|
||||
tagTv.setTextColor(ContextCompat.getColor(getContext(), R.color.theme));
|
||||
}
|
||||
FlexboxLayout.LayoutParams params = new FlexboxLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, DisplayUtils.dip2px(getContext(), 5), DisplayUtils.dip2px(getContext(), 15), DisplayUtils.dip2px(getContext(), 5));
|
||||
tagTv.setLayoutParams(params);
|
||||
mTagFl.addView(view, 0);
|
||||
mTagList.add(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListClick(View view, int position, Object data) {
|
||||
super.onListClick(view, position, data);
|
||||
List<String> picList = (List<String>) data;
|
||||
if (position == mAdapter.getItemCount() - 1 && picList.size() < 5) {
|
||||
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
startActivityForResult(intent, MEDIA_STORE_REQUEST);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// todo 重构
|
||||
private void showAddTagDialog() {
|
||||
final Dialog dialog = new Dialog(getContext());
|
||||
|
||||
@ -154,7 +291,7 @@ public class QuestionsEditFragment extends NormalFragment {
|
||||
Utils.toast(getContext(), getString(R.string.vote_empty_hint));
|
||||
return true;
|
||||
}
|
||||
addTag(nickname);
|
||||
addTag(nickname, false);
|
||||
dialog.dismiss();
|
||||
return true;
|
||||
}
|
||||
@ -181,7 +318,7 @@ public class QuestionsEditFragment extends NormalFragment {
|
||||
Utils.toast(getContext(), getString(R.string.vote_empty_hint));
|
||||
return;
|
||||
}
|
||||
addTag(nickname);
|
||||
addTag(nickname, false);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
@ -205,15 +342,5 @@ public class QuestionsEditFragment extends NormalFragment {
|
||||
}, 300);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListClick(View view, int position, Object data) {
|
||||
super.onListClick(view, position, data);
|
||||
List<String> picList = (List<String>) data;
|
||||
if (position == mAdapter.getItemCount() - 1 && picList.size() < 5) {
|
||||
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
startActivityForResult(intent, MEDIA_STORE_REQUEST);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ import com.gh.common.view.VerticalItemDecoration;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.AskSelectGameAdapter;
|
||||
import com.gh.gamecenter.ask.entity.AskGameSelectEntity;
|
||||
import com.gh.gamecenter.ask.entity.MeEntity;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListFragment;
|
||||
import com.gh.gamecenter.manager.UserManager;
|
||||
@ -115,7 +116,10 @@ public class SelectGameFragment extends ListFragment {
|
||||
case R.id.ask_selectgame_item_votebtn:
|
||||
CheckLoginUtils.checkLogin(getContext(), () -> {
|
||||
List<AskGameSelectEntity> mEntityList = (List<AskGameSelectEntity>) data;
|
||||
vote(mEntityList.get(position).getId());
|
||||
AskGameSelectEntity askGameSelectEntity = mEntityList.get(position);
|
||||
MeEntity me = askGameSelectEntity.getMe();
|
||||
if (me == null || !me.isCommunityVoted())
|
||||
vote(askGameSelectEntity.getId());
|
||||
});
|
||||
break;
|
||||
|
||||
@ -135,10 +139,11 @@ public class SelectGameFragment extends ListFragment {
|
||||
String string = response.string();
|
||||
JSONObject object = new JSONObject(string);
|
||||
int vote = object.getInt("vote");
|
||||
if (vote == 200) { // todo 测试不通过
|
||||
toast(R.string.vote_success);
|
||||
mAdapter.voteSuccess(communityId);
|
||||
if (vote == 200) {
|
||||
|
||||
}
|
||||
toast(R.string.vote_success);
|
||||
mAdapter.voteSuccess(communityId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@ -11,9 +11,9 @@ class AnswerDetailEntity() : Parcelable {
|
||||
|
||||
var content: String? = null
|
||||
|
||||
var time: Long? = null
|
||||
var time: AskTimeEntity? = null
|
||||
|
||||
var me: MeEntity? = null
|
||||
var me: MeEntity = MeEntity()
|
||||
|
||||
var user: UserEntity? = null
|
||||
|
||||
@ -21,14 +21,14 @@ class AnswerDetailEntity() : Parcelable {
|
||||
|
||||
constructor(parcel: Parcel) : this() {
|
||||
content = parcel.readString()
|
||||
time = parcel.readValue(Long::class.java.classLoader) as? Long
|
||||
time = parcel.readParcelable(AskTimeEntity::class.java.classLoader)
|
||||
user = parcel.readParcelable(UserEntity::class.java.classLoader)
|
||||
vote = parcel.readInt()
|
||||
}
|
||||
|
||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||
parcel.writeString(content)
|
||||
parcel.writeValue(time)
|
||||
parcel.writeParcelable(time, flags)
|
||||
parcel.writeParcelable(user, flags)
|
||||
parcel.writeInt(vote)
|
||||
}
|
||||
|
||||
@ -21,9 +21,13 @@ class AnswerEntity() : Parcelable {
|
||||
|
||||
var user: UserEntity? = null
|
||||
|
||||
@SerializedName("question")
|
||||
var questions: Questions = Questions()
|
||||
|
||||
constructor(parcel: Parcel) : this() {
|
||||
id = parcel.readString()
|
||||
brief = parcel.readString()
|
||||
questions = parcel.readParcelable(Questions::class.java.classLoader)
|
||||
images = parcel.createStringArrayList()
|
||||
vote = parcel.readInt()
|
||||
user = parcel.readParcelable(UserEntity::class.java.classLoader)
|
||||
@ -32,6 +36,7 @@ class AnswerEntity() : Parcelable {
|
||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||
parcel.writeString(id)
|
||||
parcel.writeString(brief)
|
||||
parcel.writeParcelable(questions, flags)
|
||||
parcel.writeStringList(images)
|
||||
parcel.writeInt(vote)
|
||||
parcel.writeParcelable(user, flags)
|
||||
|
||||
@ -7,6 +7,7 @@ import com.google.gson.annotations.SerializedName
|
||||
* Created by khy on 11/12/17.
|
||||
*/
|
||||
class AskOpenEntity {
|
||||
|
||||
@SerializedName("_id")
|
||||
var id: String? = null
|
||||
|
||||
|
||||
@ -1,13 +1,45 @@
|
||||
package com.gh.gamecenter.ask.entity
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
|
||||
/**
|
||||
* Created by khy on 11/12/17.
|
||||
*/
|
||||
class AskTimeEntity {
|
||||
class AskTimeEntity() : Parcelable {
|
||||
|
||||
var create: Long? = null
|
||||
|
||||
var update: Long? = null
|
||||
|
||||
var open: Long? = null
|
||||
|
||||
constructor(parcel: Parcel) : this() {
|
||||
create = parcel.readValue(Long::class.java.classLoader) as? Long
|
||||
update = parcel.readValue(Long::class.java.classLoader) as? Long
|
||||
open = parcel.readValue(Long::class.java.classLoader) as? Long
|
||||
}
|
||||
|
||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||
parcel.writeValue(create)
|
||||
parcel.writeValue(update)
|
||||
parcel.writeValue(open)
|
||||
}
|
||||
|
||||
override fun describeContents(): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val CREATOR: Parcelable.Creator<AskTimeEntity> = object : Parcelable.Creator<AskTimeEntity> {
|
||||
override fun createFromParcel(parcel: Parcel): AskTimeEntity {
|
||||
return AskTimeEntity(parcel)
|
||||
}
|
||||
|
||||
override fun newArray(size: Int): Array<AskTimeEntity?> {
|
||||
return arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12,4 +12,16 @@ class MeEntity {
|
||||
|
||||
@SerializedName("is_expert_invited")
|
||||
var isExpertInvited: Boolean = false
|
||||
|
||||
@SerializedName("is_answer_voted")
|
||||
var isAnswerVoted: Boolean = false
|
||||
|
||||
@SerializedName("is_answer_own")
|
||||
var isAnswerOwn: Boolean = false
|
||||
|
||||
@SerializedName("is_answer_favorite")
|
||||
var isAnswerFavorite: Boolean = false
|
||||
|
||||
@SerializedName("is_question_followed")
|
||||
var isQuestionFollowed: Boolean = false
|
||||
}
|
||||
@ -1,19 +1,45 @@
|
||||
package com.gh.gamecenter.ask.entity
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Created by khy on 11/12/17.
|
||||
*/
|
||||
class Questions {
|
||||
class Questions() : Parcelable {
|
||||
|
||||
@SerializedName("_id")
|
||||
var id: String? = null
|
||||
|
||||
var title: String? = null
|
||||
|
||||
var answers: String? = null
|
||||
|
||||
@SerializedName("answer_count")
|
||||
var answersCount: Int = 0
|
||||
var answerCount: Int = 0
|
||||
|
||||
constructor(parcel: Parcel) : this() {
|
||||
id = parcel.readString()
|
||||
title = parcel.readString()
|
||||
answerCount = parcel.readInt()
|
||||
}
|
||||
|
||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||
parcel.writeString(id)
|
||||
parcel.writeString(title)
|
||||
parcel.writeInt(answerCount)
|
||||
}
|
||||
|
||||
override fun describeContents(): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
companion object CREATOR : Parcelable.Creator<Questions> {
|
||||
override fun createFromParcel(parcel: Parcel): Questions {
|
||||
return Questions(parcel)
|
||||
}
|
||||
|
||||
override fun newArray(size: Int): Array<Questions?> {
|
||||
return arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package com.gh.gamecenter.ask.questionsdetail
|
||||
package com.gh.gamecenter.ask.entity
|
||||
|
||||
/**
|
||||
* Created by khy on 18/12/17.
|
||||
@ -14,4 +14,6 @@ class QuestionsDetailEntity {
|
||||
var images: List<String> = ArrayList()
|
||||
|
||||
var answers: Int = 0
|
||||
|
||||
var me: MeEntity = MeEntity()
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
package com.gh.gamecenter.ask.myask;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.gh.base.OnListClickListener;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
||||
import com.gh.gamecenter.ask.AskQuestionsNewViewHolder;
|
||||
import com.gh.gamecenter.ask.entity.Questions;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by khy on 20/12/17.
|
||||
*/
|
||||
|
||||
class ConcernQuestionsAdapter extends ListAdapter {
|
||||
|
||||
private OnListClickListener mListClickListener;
|
||||
|
||||
private List<Questions> mEntityList;
|
||||
|
||||
|
||||
public ConcernQuestionsAdapter(Context context, OnListClickListener listClickListener) {
|
||||
super(context);
|
||||
mListClickListener = listClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> void provideListData(List<T> listData) {
|
||||
mEntityList = (List<Questions>) listData;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadChange(LoadStatus status) {
|
||||
switch (status) {
|
||||
case OVER:
|
||||
mIsOver = true;
|
||||
break;
|
||||
case ERROR:
|
||||
mIsNetworkError = true;
|
||||
break;
|
||||
case RETRY:
|
||||
mIsNetworkError = false;
|
||||
break;
|
||||
}
|
||||
notifyItemChanged(getItemCount() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == getItemCount() - 1) return ItemViewType.ITEM_FOOTER;
|
||||
return ItemViewType.ITEM_BODY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view;
|
||||
switch (viewType) {
|
||||
case ItemViewType.ITEM_FOOTER:
|
||||
view = mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false);
|
||||
return new FooterViewHolder(view, null, mListClickListener);
|
||||
case ItemViewType.ITEM_BODY:
|
||||
view = mLayoutInflater.inflate(R.layout.ask_questions_new_item, parent, false);
|
||||
return new AskQuestionsNewViewHolder(view, mEntityList, mListClickListener);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
switch (getItemViewType(position)) {
|
||||
case ItemViewType.ITEM_BODY:
|
||||
((AskQuestionsNewViewHolder) holder).initAskQuestionsNewViewHolder(mEntityList.get(position));
|
||||
|
||||
break;
|
||||
case ItemViewType.ITEM_FOOTER:
|
||||
FooterViewHolder footerViewHolder = (FooterViewHolder) holder;
|
||||
footerViewHolder.initItemPadding();
|
||||
footerViewHolder.initFooterViewHolder(mIsNetworkError, mIsOver, R.string.ask_loadover_hint);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mEntityList == null || mEntityList.isEmpty() ? 0 : mEntityList.size() + FOOTER_ITEM_COUNT;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package com.gh.gamecenter.ask.myask;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.gh.gamecenter.AskQuestionsDetailActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ask.entity.Questions;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListFragment;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import rx.Observable;
|
||||
|
||||
/**
|
||||
* Created by khy on 20/12/17.
|
||||
*/
|
||||
|
||||
public class ConcernQuestionsFragment extends ListFragment {
|
||||
|
||||
private ConcernQuestionsAdapter mAdapter;
|
||||
|
||||
@Override
|
||||
protected ListAdapter provideListAdapter() {
|
||||
return mAdapter == null ? mAdapter = new ConcernQuestionsAdapter(getContext(), this) : mAdapter;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Observable<List<Questions>> provideDataObservable() {
|
||||
return RetrofitManager.getInstance(getContext()).getApi().getConcernQuestions(getListOffset());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListClick(View view, int position, Object data) {
|
||||
if (view.getId() == R.id.ask_questions_new_item) {
|
||||
List<Questions> questionsList = (List<Questions>) data;
|
||||
startActivity(AskQuestionsDetailActivity.getIntent(getContext(), questionsList.get(position).getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package com.gh.gamecenter.ask.myask;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.gh.base.OnListClickListener;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
||||
import com.gh.gamecenter.ask.entity.AnswerEntity;
|
||||
import com.gh.gamecenter.ask.questionsdetail.AnswerViewHolder;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by khy on 20/12/17.
|
||||
*/
|
||||
|
||||
class MyAnswerAdapter extends ListAdapter {
|
||||
|
||||
private OnListClickListener mListClickListener;
|
||||
|
||||
private List<AnswerEntity> mEntityList;
|
||||
|
||||
MyAnswerAdapter(Context context, OnListClickListener listClickListener) {
|
||||
super(context);
|
||||
mListClickListener = listClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> void provideListData(List<T> listData) {
|
||||
mEntityList = (List<AnswerEntity>) listData;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadChange(LoadStatus status) {
|
||||
switch (status) {
|
||||
case OVER:
|
||||
mIsOver = true;
|
||||
break;
|
||||
case ERROR:
|
||||
mIsNetworkError = true;
|
||||
break;
|
||||
case RETRY:
|
||||
mIsNetworkError = false;
|
||||
break;
|
||||
}
|
||||
notifyItemChanged(getItemCount() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == getItemCount() - 1) return ItemViewType.ITEM_FOOTER;
|
||||
return ItemViewType.ITEM_BODY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view;
|
||||
switch (viewType) {
|
||||
case ItemViewType.ITEM_FOOTER:
|
||||
view = mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false);
|
||||
return new FooterViewHolder(view, null, mListClickListener);
|
||||
case ItemViewType.ITEM_BODY:
|
||||
view = mLayoutInflater.inflate(R.layout.ask_answer_item, parent, false);
|
||||
return new AnswerViewHolder(view, mEntityList, mListClickListener);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
switch (getItemViewType(position)) {
|
||||
case ItemViewType.ITEM_BODY:
|
||||
((AnswerViewHolder) holder).initMyAnswerViewHolder(mEntityList.get(position));
|
||||
break;
|
||||
case ItemViewType.ITEM_FOOTER:
|
||||
FooterViewHolder footerViewHolder = (FooterViewHolder) holder;
|
||||
footerViewHolder.initItemPadding();
|
||||
footerViewHolder.initFooterViewHolder(mIsNetworkError, mIsOver, R.string.ask_loadover_hint);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mEntityList == null || mEntityList.isEmpty() ? 0 : mEntityList.size() + FOOTER_ITEM_COUNT;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package com.gh.gamecenter.ask.myask;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import com.gh.gamecenter.NormalActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ask.AskAnswerDetailFragment;
|
||||
import com.gh.gamecenter.ask.entity.AnswerEntity;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListFragment;
|
||||
import com.gh.gamecenter.manager.UserManager;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import rx.Observable;
|
||||
|
||||
/**
|
||||
* Created by khy on 20/12/17.
|
||||
*/
|
||||
|
||||
public class MyAnswerFragment extends ListFragment {
|
||||
|
||||
private MyAnswerAdapter mAdapter;
|
||||
|
||||
@Override
|
||||
protected ListAdapter provideListAdapter() {
|
||||
return mAdapter == null ? mAdapter = new MyAnswerAdapter(getContext(), this) : mAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Observable<List<AnswerEntity>> provideDataObservable() {
|
||||
return RetrofitManager.getInstance(getContext()).getApi().getMyAnswers(UserManager.getInstance().getUserId(), getListOffset());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListClick(View view, int position, Object data) {
|
||||
if (view.getId() == R.id.ask_answer_item_constraintlayout) {
|
||||
List<AnswerEntity> entityList = (List<AnswerEntity>) data;
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable(AnswerEntity.TAG, entityList.get(position));
|
||||
NormalActivity.startFragment(getContext(), AskAnswerDetailFragment.class, bundle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.gh.gamecenter.ask.myask;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.normal.NormalFragment;
|
||||
|
||||
/**
|
||||
* Created by khy on 20/12/17.
|
||||
*/
|
||||
|
||||
public class MyAskFragment extends NormalFragment {
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_myask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
setNavigationTitle(R.string.myask);
|
||||
getChildFragmentManager().beginTransaction()
|
||||
.replace(R.id.layout_fragment_content, new MyAskWrapperFragment()).commitAllowingStateLoss();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
package com.gh.gamecenter.ask.myask;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.gh.base.fragment.BaseFragment_ViewPager_Checkable;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.RandomUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
||||
/**
|
||||
* Created by khy on 20/12/17.
|
||||
*/
|
||||
|
||||
public class MyAskWrapperFragment extends BaseFragment_ViewPager_Checkable {
|
||||
|
||||
@BindView(R.id.myask_slide_line)
|
||||
View mSlideLine;
|
||||
|
||||
private int mWindowWidth;
|
||||
private LinearLayout.LayoutParams mLayoutParams;
|
||||
|
||||
@Override
|
||||
protected boolean getSmoothScroll() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getCheckableGroupId() {
|
||||
return R.id.lightgame_tab_container;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_wrapper_myask;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getViewPagerId() {
|
||||
return R.id.lightgame_tab_viewpager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initFragmentList(List<Fragment> fragments) {
|
||||
fragments.add(new ConcernQuestionsFragment());
|
||||
fragments.add(new MyQuestionsFragment());
|
||||
fragments.add(new MyAnswerFragment());
|
||||
fragments.add(new MyDraftFragment());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
DisplayMetrics outMetrics = new DisplayMetrics();
|
||||
getActivity().getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
|
||||
mWindowWidth = outMetrics.widthPixels / 4;
|
||||
mLayoutParams = new LinearLayout.LayoutParams(mWindowWidth / 2, DisplayUtils.dip2px(getActivity(), 2));
|
||||
mLayoutParams.leftMargin = RandomUtils.getInt(mWindowWidth * (mCheckedIndex + 0.25f));
|
||||
mSlideLine.setLayoutParams(mLayoutParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
super.onPageScrolled(position, positionOffset, positionOffsetPixels);
|
||||
if (positionOffset != 0) {
|
||||
mLayoutParams.leftMargin = RandomUtils.getInt(mWindowWidth * (position + positionOffset + 0.25f));
|
||||
mSlideLine.setLayoutParams(mLayoutParams);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package com.gh.gamecenter.ask.myask;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.gh.base.OnListClickListener;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
||||
import com.gh.gamecenter.ask.entity.AnswerEntity;
|
||||
import com.gh.gamecenter.ask.questionsdetail.AnswerViewHolder;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by khy on 20/12/17.
|
||||
*/
|
||||
|
||||
class MyDraftAdapter extends ListAdapter {
|
||||
|
||||
private OnListClickListener mListClickListener;
|
||||
|
||||
private List<AnswerEntity> mEntityList;
|
||||
|
||||
MyDraftAdapter(Context context, OnListClickListener listClickListener) {
|
||||
super(context);
|
||||
mListClickListener = listClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> void provideListData(List<T> listData) {
|
||||
mEntityList = (List<AnswerEntity>) listData;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadChange(LoadStatus status) {
|
||||
switch (status) {
|
||||
case OVER:
|
||||
mIsOver = true;
|
||||
break;
|
||||
case ERROR:
|
||||
mIsNetworkError = true;
|
||||
break;
|
||||
case RETRY:
|
||||
mIsNetworkError = false;
|
||||
break;
|
||||
}
|
||||
notifyItemChanged(getItemCount() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == getItemCount() - 1) return ItemViewType.ITEM_FOOTER;
|
||||
return ItemViewType.ITEM_BODY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view;
|
||||
switch (viewType) {
|
||||
case ItemViewType.ITEM_FOOTER:
|
||||
view = mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false);
|
||||
return new FooterViewHolder(view, null, mListClickListener);
|
||||
case ItemViewType.ITEM_BODY:
|
||||
view = mLayoutInflater.inflate(R.layout.ask_answer_item, parent, false);
|
||||
return new AnswerViewHolder(view, mEntityList, mListClickListener);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
switch (getItemViewType(position)) {
|
||||
case ItemViewType.ITEM_BODY:
|
||||
((AnswerViewHolder) holder).initAnswerViewHolder(mContext, mEntityList.get(position));
|
||||
break;
|
||||
case ItemViewType.ITEM_FOOTER:
|
||||
FooterViewHolder footerViewHolder = (FooterViewHolder) holder;
|
||||
footerViewHolder.initItemPadding();
|
||||
footerViewHolder.initFooterViewHolder(mIsNetworkError, mIsOver, R.string.ask_loadover_hint);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mEntityList == null || mEntityList.isEmpty() ? 0 : mEntityList.size() + FOOTER_ITEM_COUNT;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.gh.gamecenter.ask.myask;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.gh.gamecenter.ask.entity.AnswerEntity;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListFragment;
|
||||
import com.gh.gamecenter.manager.UserManager;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import rx.Observable;
|
||||
|
||||
/**
|
||||
* Created by khy on 20/12/17.
|
||||
*/
|
||||
|
||||
public class MyDraftFragment extends ListFragment {
|
||||
|
||||
private MyDraftAdapter mAdapter;
|
||||
|
||||
@Override
|
||||
protected ListAdapter provideListAdapter() {
|
||||
return mAdapter == null ? mAdapter = new MyDraftAdapter(getContext(), this) : mAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChanged(@Nullable Object o) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Observable<List<AnswerEntity>> provideDataObservable() {
|
||||
return RetrofitManager.getInstance(getContext()).getApi().getMyAnswerDrafts(UserManager.getInstance().getUserId(), getListOffset());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
package com.gh.gamecenter.ask.myask;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.gh.base.OnListClickListener;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
||||
import com.gh.gamecenter.ask.AskQuestionsNewViewHolder;
|
||||
import com.gh.gamecenter.ask.entity.Questions;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by khy on 20/12/17.
|
||||
*/
|
||||
|
||||
public class MyQuestionsAdapter extends ListAdapter {
|
||||
|
||||
private OnListClickListener mListClickListener;
|
||||
|
||||
private List<Questions> mEntityList;
|
||||
|
||||
|
||||
public MyQuestionsAdapter(Context context, OnListClickListener listClickListener) {
|
||||
super(context);
|
||||
mListClickListener = listClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> void provideListData(List<T> listData) {
|
||||
mEntityList = (List<Questions>) listData;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadChange(LoadStatus status) {
|
||||
switch (status) {
|
||||
case OVER:
|
||||
mIsOver = true;
|
||||
break;
|
||||
case ERROR:
|
||||
mIsNetworkError = true;
|
||||
break;
|
||||
case RETRY:
|
||||
mIsNetworkError = false;
|
||||
break;
|
||||
}
|
||||
notifyItemChanged(getItemCount() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == getItemCount() - 1) return ItemViewType.ITEM_FOOTER;
|
||||
return ItemViewType.ITEM_BODY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view;
|
||||
switch (viewType) {
|
||||
case ItemViewType.ITEM_FOOTER:
|
||||
view = mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false);
|
||||
return new FooterViewHolder(view, null, mListClickListener);
|
||||
case ItemViewType.ITEM_BODY:
|
||||
view = mLayoutInflater.inflate(R.layout.ask_questions_new_item, parent, false);
|
||||
return new AskQuestionsNewViewHolder(view, mEntityList, mListClickListener);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
switch (getItemViewType(position)) {
|
||||
case ItemViewType.ITEM_BODY:
|
||||
((AskQuestionsNewViewHolder) holder).initAskQuestionsNewViewHolder(mEntityList.get(position));
|
||||
|
||||
break;
|
||||
case ItemViewType.ITEM_FOOTER:
|
||||
FooterViewHolder footerViewHolder = (FooterViewHolder) holder;
|
||||
footerViewHolder.initItemPadding();
|
||||
footerViewHolder.initFooterViewHolder(mIsNetworkError, mIsOver, R.string.ask_loadover_hint);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mEntityList == null || mEntityList.isEmpty() ? 0 : mEntityList.size() + FOOTER_ITEM_COUNT;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package com.gh.gamecenter.ask.myask;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.gh.gamecenter.AskQuestionsDetailActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ask.entity.Questions;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListFragment;
|
||||
import com.gh.gamecenter.manager.UserManager;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import rx.Observable;
|
||||
|
||||
/**
|
||||
* Created by khy on 20/12/17.
|
||||
*/
|
||||
|
||||
public class MyQuestionsFragment extends ListFragment {
|
||||
|
||||
private MyQuestionsAdapter mAdapter;
|
||||
|
||||
@Override
|
||||
protected ListAdapter provideListAdapter() {
|
||||
return mAdapter == null ? mAdapter = new MyQuestionsAdapter(getContext(), this) : mAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Observable<List<Questions>> provideDataObservable() {
|
||||
return RetrofitManager.getInstance(getContext()).getApi().getMyQuestions(UserManager.getInstance().getUserId(), getListOffset());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListClick(View view, int position, Object data) {
|
||||
if (view.getId() == R.id.ask_questions_new_item) {
|
||||
List<Questions> questionsList = (List<Questions>) data;
|
||||
startActivity(AskQuestionsDetailActivity.getIntent(getContext(), questionsList.get(position).getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.gamecenter.ask.questionsdetail;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
@ -7,21 +8,29 @@ import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.fragment.BaseFragment;
|
||||
import com.gh.base.fragment.WaitingDialogFragment;
|
||||
import com.gh.common.util.CheckLoginUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.view.RichEditor;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.base.fragment.WaitingDialogFragment;
|
||||
import com.gh.gamecenter.normal.NormalFragment;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.halo.assistant.fragment.user.SelectPortraitFragment;
|
||||
import com.lightgame.config.CommonDebug;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -29,12 +38,19 @@ import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.HttpException;
|
||||
import rx.Observable;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Created by khy on 7/12/17.
|
||||
*/
|
||||
|
||||
public class AnswerEditFragment extends BaseFragment {
|
||||
public class AnswerEditFragment extends NormalFragment {
|
||||
@BindView(R.id.answer_edit_title)
|
||||
TextView mTitle;
|
||||
@BindView(R.id.answer_edit_content)
|
||||
@ -48,6 +64,32 @@ public class AnswerEditFragment extends BaseFragment {
|
||||
|
||||
private WaitingDialogFragment postDialog;
|
||||
|
||||
private String mAnswerId;
|
||||
private String mAnswerContent;
|
||||
|
||||
private String mQuestionsId;
|
||||
private String mQuestionsTitle;
|
||||
|
||||
// public static AnswerEditFragment getInstance(String questionsId, String questionsTitle) {
|
||||
// AnswerEditFragment fragment = new AnswerEditFragment();
|
||||
// Bundle args = new Bundle();
|
||||
// args.putString(EntranceUtils.KEY_QUESTIONS_ID, questionsId);
|
||||
// args.putString(EntranceUtils.KEY_QUESTIONS_TITLE, questionsTitle);
|
||||
// fragment.setArguments(args);
|
||||
// return fragment;
|
||||
// }
|
||||
|
||||
// public static AnswerEditFragment getInstanceByPatch(String mAnswerId, String questionsTitle, String content) {
|
||||
// AnswerEditFragment fragment = new AnswerEditFragment();
|
||||
// Bundle args = new Bundle();
|
||||
// args.putString(EntranceUtils.KEY_ANSWER_ID, mAnswerId);
|
||||
// args.putString(EntranceUtils.KEY_QUESTIONS_TITLE, questionsTitle);
|
||||
// args.putString(EntranceUtils.KEY_ANSWER_CONTENT, content);
|
||||
// fragment.setArguments(args);
|
||||
// return fragment;
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
@ -74,6 +116,18 @@ public class AnswerEditFragment extends BaseFragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Bundle arguments = getArguments();
|
||||
if (arguments != null) {
|
||||
mAnswerId = arguments.getString(EntranceUtils.KEY_ANSWER_ID);
|
||||
mAnswerContent = arguments.getString(EntranceUtils.KEY_ANSWER_CONTENT);
|
||||
mQuestionsId = arguments.getString(EntranceUtils.KEY_QUESTIONS_ID);
|
||||
mQuestionsTitle = arguments.getString(EntranceUtils.KEY_QUESTIONS_TITLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_answer_edit;
|
||||
@ -82,7 +136,22 @@ public class AnswerEditFragment extends BaseFragment {
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
setNavigationTitle(R.string.answer_detail_title);
|
||||
initMenu(R.menu.menu_concern);
|
||||
|
||||
mTitle.setText(mQuestionsTitle);
|
||||
mEditContent.setPadding(20, 15, 20, 15);
|
||||
|
||||
if (!TextUtils.isEmpty(mAnswerId)) {
|
||||
mEditContent.setHtml(mAnswerContent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMenuItemClick(MenuItem menuItem) {
|
||||
if (menuItem.getItemId() == R.id.menu_concern) {
|
||||
postAnswer();
|
||||
}
|
||||
}
|
||||
|
||||
public void postAnswer() {
|
||||
@ -98,10 +167,10 @@ public class AnswerEditFragment extends BaseFragment {
|
||||
}
|
||||
String answerContent = mEditContent.getHtml();
|
||||
for (String s : imgMap.keySet()) {
|
||||
answerContent = answerContent.replace(FILE_HOST + s, imgMap.get(s)); // todo 需要测试
|
||||
answerContent = answerContent.replace(FILE_HOST + s, imgMap.get(s));
|
||||
}
|
||||
postDialog.dismissAllowingStateLoss();
|
||||
|
||||
post(answerContent);
|
||||
|
||||
if (CommonDebug.IS_DEBUG) Utils.log("answerEditHtml:" + answerContent);
|
||||
}
|
||||
@ -114,6 +183,102 @@ public class AnswerEditFragment extends BaseFragment {
|
||||
});
|
||||
}
|
||||
|
||||
private void post(String editContent) {
|
||||
JSONObject content = new JSONObject();
|
||||
try {
|
||||
content.put("content", editContent);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"), content.toString());
|
||||
Observable<ResponseBody> observable;
|
||||
if (!TextUtils.isEmpty(mAnswerId)) {
|
||||
observable = RetrofitManager.getInstance(getContext()).getApi().patchQuestionAnswer(body, mAnswerId);
|
||||
} else {
|
||||
observable = RetrofitManager.getInstance(getContext()).getApi().postQuestionAnswer(body, mQuestionsId);
|
||||
}
|
||||
observable
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<ResponseBody>() {
|
||||
@Override
|
||||
public void onResponse(ResponseBody response) {
|
||||
super.onResponse(response);
|
||||
postDialog.dismissAllowingStateLoss();
|
||||
toast("提交成功");
|
||||
if (getActivity() != null) {
|
||||
if (!TextUtils.isEmpty(mAnswerId)) {
|
||||
Intent data = new Intent();
|
||||
data.putExtra(EntranceUtils.KEY_ANSWER_CONTENT, editContent);
|
||||
getActivity().setResult(Activity.RESULT_OK, data);
|
||||
}
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException e) {
|
||||
super.onFailure(e);
|
||||
postDialog.dismissAllowingStateLoss();
|
||||
toast("提交失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed() {
|
||||
if (TextUtils.isEmpty(mEditContent.getHtml())) {
|
||||
return false;
|
||||
} else {
|
||||
showBackDialog();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void showBackDialog() {
|
||||
DialogUtils.showAlertDialog(getActivity(), "提示", "确定要退出吗?退出后答案将保存到草稿箱"
|
||||
, "继续写", " 退出", null, new DialogUtils.CancelListener() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
saveAnswerDrafts();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void saveAnswerDrafts() {
|
||||
String editContent = mEditContent.getHtml();
|
||||
if (TextUtils.isEmpty(editContent)) {
|
||||
getActivity().finish();
|
||||
return;
|
||||
}
|
||||
JSONObject content = new JSONObject();
|
||||
try {
|
||||
content.put("content", editContent);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"), content.toString());
|
||||
RetrofitManager.getInstance(getContext()).getApi()
|
||||
.postAnswerDrafts(body, mQuestionsId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<ResponseBody>() {
|
||||
@Override
|
||||
public void onResponse(ResponseBody response) {
|
||||
super.onResponse(response);
|
||||
toast("已保存到草稿箱");
|
||||
if (getActivity() != null) getActivity().finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException e) {
|
||||
super.onFailure(e);
|
||||
toast("保存失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@OnClick({R.id.answer_edit_img_icon})
|
||||
public void onClick(View view) {
|
||||
if (view.getId() == R.id.answer_edit_img_icon) {
|
||||
|
||||
@ -9,8 +9,7 @@ import com.gh.base.OnListClickListener;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
||||
import com.gh.gamecenter.ask.AskQuestionsHotViewHolder;
|
||||
import com.gh.gamecenter.ask.entity.QuestionsEntity;
|
||||
import com.gh.gamecenter.ask.entity.AnswerEntity;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
|
||||
@ -24,7 +23,7 @@ public class AnswerFoldAdapter extends ListAdapter {
|
||||
|
||||
private OnListClickListener mListClickListener;
|
||||
|
||||
private List<QuestionsEntity> mEntityList;
|
||||
private List<AnswerEntity> mEntityList;
|
||||
|
||||
public AnswerFoldAdapter(Context context, OnListClickListener listClickListener) {
|
||||
super(context);
|
||||
@ -33,13 +32,24 @@ public class AnswerFoldAdapter extends ListAdapter {
|
||||
|
||||
@Override
|
||||
protected <T> void provideListData(List<T> listData) {
|
||||
mEntityList = (List<QuestionsEntity>) listData;
|
||||
mEntityList = (List<AnswerEntity>) listData;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadChange(LoadStatus status) {
|
||||
|
||||
switch (status) {
|
||||
case OVER:
|
||||
mIsOver = true;
|
||||
break;
|
||||
case ERROR:
|
||||
mIsNetworkError = true;
|
||||
break;
|
||||
case RETRY:
|
||||
mIsNetworkError = false;
|
||||
break;
|
||||
}
|
||||
notifyItemChanged(getItemCount() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -56,8 +66,8 @@ public class AnswerFoldAdapter extends ListAdapter {
|
||||
view = mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false);
|
||||
return new FooterViewHolder(view, null, mListClickListener);
|
||||
case ItemViewType.ITEM_BODY:
|
||||
view = mLayoutInflater.inflate(R.layout.ask_questions_hot_item, parent, false);
|
||||
return new AskQuestionsHotViewHolder(view, mEntityList, mListClickListener);
|
||||
view = mLayoutInflater.inflate(R.layout.ask_answer_item, parent, false);
|
||||
return new AnswerViewHolder(view, mEntityList, mListClickListener);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@ -67,7 +77,7 @@ public class AnswerFoldAdapter extends ListAdapter {
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
switch (getItemViewType(position)) {
|
||||
case ItemViewType.ITEM_BODY:
|
||||
((AskQuestionsHotViewHolder) holder).initQuestionsHotViewHolder(mContext, mEntityList.get(position));
|
||||
((AnswerViewHolder) holder).initAnswerViewHolder(mContext, mEntityList.get(position));
|
||||
break;
|
||||
case ItemViewType.ITEM_FOOTER:
|
||||
FooterViewHolder footerViewHolder = (FooterViewHolder) holder;
|
||||
@ -79,6 +89,6 @@ public class AnswerFoldAdapter extends ListAdapter {
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 0;
|
||||
return mEntityList == null || mEntityList.isEmpty() ? 0 : mEntityList.size() + FOOTER_ITEM_COUNT;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.gamecenter.ask.entity.QuestionsEntity;
|
||||
import com.gh.gamecenter.ask.entity.AnswerEntity;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListFragment;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
@ -39,7 +39,7 @@ public class AnswerFoldFragment extends ListFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Observable<List<QuestionsEntity>> provideDataObservable() {
|
||||
public Observable<List<AnswerEntity>> provideDataObservable() {
|
||||
return RetrofitManager.getInstance(getContext()).getApi().getQuestionsAnswer(mQuestionsId, true);
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,75 @@
|
||||
package com.gh.gamecenter.ask.questionsdetail;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.base.BaseRecyclerViewHolder;
|
||||
import com.gh.base.OnListClickListener;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ask.entity.AnswerEntity;
|
||||
import com.gh.gamecenter.entity.UserEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
||||
/**
|
||||
* Created by khy on 19/12/17.
|
||||
*/
|
||||
|
||||
public class AnswerViewHolder extends BaseRecyclerViewHolder {
|
||||
|
||||
@BindView(R.id.ask_answer_item_usericon)
|
||||
SimpleDraweeView mUsericon;
|
||||
@BindView(R.id.ask_answer_item_username)
|
||||
TextView mUsername;
|
||||
@BindView(R.id.ask_answer_item_content)
|
||||
TextView mContent;
|
||||
@BindView(R.id.ask_answer_item_img)
|
||||
SimpleDraweeView mImg;
|
||||
@BindView(R.id.ask_answer_item_votecount)
|
||||
TextView mVotecount;
|
||||
@BindView(R.id.ask_answer_item_title)
|
||||
TextView mQuestionTitle;
|
||||
|
||||
public AnswerViewHolder(View itemView, Object data, OnListClickListener listClickListener) {
|
||||
super(itemView, data, listClickListener);
|
||||
itemView.setOnClickListener(this);
|
||||
}
|
||||
|
||||
public void initAnswerViewHolder(Context context, AnswerEntity entity) {
|
||||
mContent.setText(entity.getBrief());
|
||||
mVotecount.setText(context.getString(R.string.ask_vote_count, entity.getVote()));
|
||||
UserEntity user = entity.getUser();
|
||||
if (user != null) {
|
||||
mUsername.setText(user.getName());
|
||||
ImageUtils.Companion.display(mUsericon, user.getIcon());
|
||||
}
|
||||
List<String> images = entity.getImages();
|
||||
if (images != null && images.size() > 0) {
|
||||
mImg.setVisibility(View.VISIBLE);
|
||||
ImageUtils.Companion.display(mImg, images.get(0));
|
||||
} else {
|
||||
mImg.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void initMyAnswerViewHolder(AnswerEntity entity) {
|
||||
mUsername.setVisibility(View.GONE);
|
||||
mUsericon.setVisibility(View.GONE);
|
||||
mQuestionTitle.setVisibility(View.VISIBLE);
|
||||
mQuestionTitle.setText(entity.getQuestions().getTitle());
|
||||
mContent.setText(entity.getBrief());
|
||||
mVotecount.setText(itemView.getContext().getString(R.string.ask_vote_count, entity.getVote()));
|
||||
List<String> images = entity.getImages();
|
||||
if (images != null && images.size() > 0) {
|
||||
mImg.setVisibility(View.VISIBLE);
|
||||
ImageUtils.Companion.display(mImg, images.get(0));
|
||||
} else {
|
||||
mImg.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.gamecenter.ask.questionsdetail;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -13,11 +14,13 @@ import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.ReuseViewHolder;
|
||||
import com.gh.gamecenter.ask.AskQuestionsHotViewHolder;
|
||||
import com.gh.gamecenter.ask.entity.QuestionsEntity;
|
||||
import com.gh.gamecenter.ask.entity.AnswerEntity;
|
||||
import com.gh.gamecenter.ask.entity.MeEntity;
|
||||
import com.gh.gamecenter.ask.entity.QuestionsDetailEntity;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
import com.google.android.flexbox.FlexboxLayout;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -29,11 +32,11 @@ public class QuestionsDetailAdapter extends ListAdapter {
|
||||
|
||||
private OnListClickListener mListClickListener;
|
||||
|
||||
private List<QuestionsEntity> mEntityList;
|
||||
private List<AnswerEntity> mEntityList;
|
||||
|
||||
private QuestionsDetailEntity mQuestionsDetailEntity;
|
||||
|
||||
public QuestionsDetailAdapter(Context context, OnListClickListener listClickListener) {
|
||||
QuestionsDetailAdapter(Context context, OnListClickListener listClickListener) {
|
||||
super(context);
|
||||
mListClickListener = listClickListener;
|
||||
}
|
||||
@ -43,9 +46,13 @@ public class QuestionsDetailAdapter extends ListAdapter {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public String getQuestionsTitle() {
|
||||
return mQuestionsDetailEntity != null ? mQuestionsDetailEntity.getTitle() : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> void provideListData(List<T> listData) {
|
||||
mEntityList = (List<QuestionsEntity>) listData;
|
||||
mEntityList = (List<AnswerEntity>) listData;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@ -76,8 +83,8 @@ public class QuestionsDetailAdapter extends ListAdapter {
|
||||
view = mLayoutInflater.inflate(R.layout.questionsdetail_footer_item, parent, false);
|
||||
return new ReuseViewHolder(view, null, mListClickListener);
|
||||
case ItemViewType.ITEM_BODY:
|
||||
view = mLayoutInflater.inflate(R.layout.ask_questions_hot_item, parent, false);
|
||||
return new AskQuestionsHotViewHolder(view, mEntityList, mListClickListener);
|
||||
view = mLayoutInflater.inflate(R.layout.ask_answer_item, parent, false);
|
||||
return new AnswerViewHolder(view, mEntityList, mListClickListener);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@ -92,9 +99,8 @@ public class QuestionsDetailAdapter extends ListAdapter {
|
||||
break;
|
||||
case ItemViewType.ITEM_FOOTER:
|
||||
break;
|
||||
case ItemViewType.ITEM_BODY: //todo 还是把答案Item和问题ITEM分开写吧 虽然都一样
|
||||
((AskQuestionsHotViewHolder) holder).initQuestionsHotViewHolder(mContext, mEntityList.get(position - 1));
|
||||
((AskQuestionsHotViewHolder) holder).mAskTitle.setVisibility(View.GONE);
|
||||
case ItemViewType.ITEM_BODY:
|
||||
((AnswerViewHolder) holder).initAnswerViewHolder(mContext, mEntityList.get(position - ListAdapter.TOP_ITEM_COUNT));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -121,6 +127,8 @@ public class QuestionsDetailAdapter extends ListAdapter {
|
||||
View view = LayoutInflater.from(mContext).inflate(R.layout.questionsdedit_tag_item, null);
|
||||
TextView tagTv = (TextView) view;
|
||||
tagTv.setText(tag);
|
||||
tagTv.setBackgroundResource(R.drawable.comment_border_bg);
|
||||
tagTv.setTextColor(ContextCompat.getColor(mContext, R.color.theme));
|
||||
FlexboxLayout.LayoutParams params = new FlexboxLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, DisplayUtils.dip2px(mContext, 5), DisplayUtils.dip2px(mContext, 15),
|
||||
@ -129,6 +137,12 @@ public class QuestionsDetailAdapter extends ListAdapter {
|
||||
holder.mTagRl.addView(view, 0);
|
||||
}
|
||||
|
||||
if (mQuestionsDetailEntity.getMe().isQuestionFollowed()) {
|
||||
holder.mConcern.setText(R.string.concerned);
|
||||
} else {
|
||||
holder.mConcern.setText(R.string.concern_questions);
|
||||
}
|
||||
|
||||
holder.mTitle.setText(mQuestionsDetailEntity.getTitle());
|
||||
holder.mDes.setText(mQuestionsDetailEntity.getDescription());
|
||||
holder.mAnswercount.setText(mContext.getString(R.string.ask_answer_count, mQuestionsDetailEntity.getAnswers()));
|
||||
@ -143,10 +157,20 @@ public class QuestionsDetailAdapter extends ListAdapter {
|
||||
if (mEntityList != null) {
|
||||
index += mEntityList.size();
|
||||
}
|
||||
|
||||
if (mQuestionsDetailEntity != null || mEntityList != null) {
|
||||
index++;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
void onConcern(boolean isSuccess) {
|
||||
MeEntity me = mQuestionsDetailEntity.getMe();
|
||||
me.setQuestionFollowed(isSuccess);
|
||||
mQuestionsDetailEntity.setMe(me);
|
||||
notifyItemChanged(0);
|
||||
}
|
||||
|
||||
boolean isConcernQuestions() {
|
||||
return mQuestionsDetailEntity.getMe().isQuestionFollowed();
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,13 +6,15 @@ import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.gh.common.util.ConcernUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.gamecenter.AskQuestionsDetailActivity;
|
||||
import com.gh.gamecenter.NormalActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ask.AskAnswerDetailFragment;
|
||||
import com.gh.gamecenter.ask.entity.AnswerEntity;
|
||||
import com.gh.gamecenter.ask.entity.QuestionsEntity;
|
||||
import com.gh.gamecenter.ask.entity.Questions;
|
||||
import com.gh.gamecenter.ask.entity.QuestionsDetailEntity;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListFragment;
|
||||
import com.gh.gamecenter.baselist.LoadType;
|
||||
@ -74,6 +76,12 @@ public class QuestionsDetailFragment extends ListFragment {
|
||||
getQuestionsDetail();
|
||||
}
|
||||
|
||||
// 列表数据为空也要正常显示(有列表头)
|
||||
@Override
|
||||
public void onLoadEmpty() {
|
||||
onLoadDone();
|
||||
}
|
||||
|
||||
@OnClick({R.id.questionsdetail_answer, R.id.questionsdetail_invite})
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
@ -89,7 +97,7 @@ public class QuestionsDetailFragment extends ListFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Observable<List<QuestionsEntity>> provideDataObservable() {
|
||||
public Observable<List<AnswerEntity>> provideDataObservable() {
|
||||
return RetrofitManager.getInstance(getContext()).getApi().getQuestionsAnswer(mQuestionsId, false);
|
||||
}
|
||||
|
||||
@ -101,18 +109,54 @@ public class QuestionsDetailFragment extends ListFragment {
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
|
||||
((AskQuestionsDetailActivity) getActivity()).show(AskQuestionsDetailActivity.QUESTIONS_DETAIL_FOLD);
|
||||
break;
|
||||
case R.id.ask_item_constraintlayout:
|
||||
List<QuestionsEntity> entityList = (List<QuestionsEntity>) data;
|
||||
QuestionsEntity questionsEntity = entityList.get(position - 1);
|
||||
case R.id.ask_answer_item_constraintlayout:
|
||||
List<AnswerEntity> entityList = (List<AnswerEntity>) data;
|
||||
AnswerEntity entity = entityList.get(position - ListAdapter.TOP_ITEM_COUNT);
|
||||
Questions questions = entity.getQuestions();
|
||||
questions.setTitle(mAdapter.getQuestionsTitle());
|
||||
entity.setQuestions(questions);
|
||||
Bundle bundle = new Bundle();
|
||||
AnswerEntity value = new AnswerEntity();
|
||||
value.setId(questionsEntity.getId());
|
||||
bundle.putParcelable(AnswerEntity.TAG, value);
|
||||
bundle.putParcelable(AnswerEntity.TAG, entity);
|
||||
NormalActivity.startFragment(getContext(), AskAnswerDetailFragment.class, bundle);
|
||||
break;
|
||||
|
||||
case R.id.questionsdetail_item_concern:
|
||||
|
||||
if (!mAdapter.isConcernQuestions()) {
|
||||
ConcernUtils.INSTANCE.postConcernQuestions(getContext(), mQuestionsId
|
||||
, new ConcernUtils.onConcernListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
mAdapter.onConcern(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ConcernUtils.INSTANCE.deleteConcernQuestions(getContext(), mQuestionsId
|
||||
, new ConcernUtils.onConcernListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
mAdapter.onConcern(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public String getQuestionsTitle() {
|
||||
return mAdapter.getQuestionsTitle();
|
||||
}
|
||||
|
||||
public void getQuestionsDetail() {
|
||||
RetrofitManager.getInstance(getContext()).getApi()
|
||||
.getQuestionsById(mQuestionsId)
|
||||
|
||||
@ -10,6 +10,7 @@ import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
||||
import com.gh.gamecenter.ask.entity.InviteEntity;
|
||||
import com.gh.gamecenter.ask.entity.MeEntity;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
|
||||
@ -36,6 +37,7 @@ public class QuestionsInviteAdapter extends ListAdapter {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
// todo 这里逻辑其实都一个的 整理到 ListAdapter
|
||||
@Override
|
||||
protected void loadChange(LoadStatus status) {
|
||||
switch (status) {
|
||||
@ -72,10 +74,10 @@ public class QuestionsInviteAdapter extends ListAdapter {
|
||||
return new QuestionsInviteTopItemViewHolder(view, null, mListClickListener);
|
||||
case ItemViewType.ITEM_FOOTER:
|
||||
view = mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false);
|
||||
return new FooterViewHolder(view, mEntityList, mListClickListener);
|
||||
return new FooterViewHolder(view, null, mListClickListener);
|
||||
case ItemViewType.ITEM_BODY:
|
||||
view = mLayoutInflater.inflate(R.layout.questionsinvite_item, parent, false);
|
||||
return new QuestionsInviteViewHolder(view, null, mListClickListener);
|
||||
return new QuestionsInviteViewHolder(view, mEntityList, mListClickListener);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@ -97,6 +99,19 @@ public class QuestionsInviteAdapter extends ListAdapter {
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mEntityList != null ? mEntityList.size() + 2 : 2;
|
||||
return mEntityList != null ? mEntityList.size() + TOP_ITEM_COUNT + FOOTER_ITEM_COUNT : TOP_ITEM_COUNT + FOOTER_ITEM_COUNT;
|
||||
}
|
||||
|
||||
public void inviteSucces(String id) {
|
||||
for (InviteEntity inviteEntity : mEntityList) {
|
||||
if (id.equals(inviteEntity.getId())) {
|
||||
MeEntity me = inviteEntity.getMe();
|
||||
if (me == null) me = new MeEntity();
|
||||
me.setExpertInvited(true);
|
||||
inviteEntity.setMe(me);
|
||||
notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,14 +5,26 @@ import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ask.entity.InviteEntity;
|
||||
import com.gh.gamecenter.ask.entity.MeEntity;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListFragment;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.HttpException;
|
||||
import rx.Observable;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Created by khy on 7/12/17.
|
||||
@ -39,6 +51,11 @@ public class QuestionsInviteFragment extends ListFragment {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadEmpty() {
|
||||
loadDone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Observable<List<InviteEntity>> provideDataObservable() {
|
||||
return RetrofitManager.getInstance(getContext()).getApi().getInviteExperts(mQuestionsId, getListOffset());
|
||||
@ -51,7 +68,46 @@ public class QuestionsInviteFragment extends ListFragment {
|
||||
|
||||
@Override
|
||||
public void onListClick(View view, int position, Object data) {
|
||||
super.onListClick(view, position, data);
|
||||
switch (view.getId()) {
|
||||
case R.id.questionsinvite_item_invite:
|
||||
List<InviteEntity> mEntityList = (List<InviteEntity>) data;
|
||||
InviteEntity inviteEntity = mEntityList.get(position - ListAdapter.TOP_ITEM_COUNT);
|
||||
MeEntity me = inviteEntity.getMe();
|
||||
if (me == null || !me.isExpertInvited())
|
||||
postInvite(inviteEntity.getId());
|
||||
break;
|
||||
case R.id.questionsinvite_top_item_invite:
|
||||
// 第三方邀请(QQ/微信/微博)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void postInvite(String expertId) {
|
||||
JSONObject object = new JSONObject();
|
||||
try {
|
||||
object.put("expert_id", expertId);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"), object.toString());
|
||||
RetrofitManager.getInstance(getContext()).getApi()
|
||||
.postInvite(body, mQuestionsId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<ResponseBody>() {
|
||||
@Override
|
||||
public void onResponse(ResponseBody response) {
|
||||
super.onResponse(response);
|
||||
mAdapter.inviteSucces(expertId);
|
||||
toast(R.string.invite_success);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException e) {
|
||||
super.onFailure(e);
|
||||
toast(R.string.invite_failure);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ public class QuestionsInviteViewHolder extends BaseRecyclerViewHolder {
|
||||
mInvite.setBackgroundResource(R.drawable.comment_border_bg);
|
||||
}
|
||||
|
||||
// mAnswercount.setText(entity.getAnswerCount()); // todo 提示View找不到
|
||||
// mVotecount.setText(entity.getVote());
|
||||
mAnswercount.setText(context.getString(R.string.ask_answer_count, entity.getAnswerCount()));
|
||||
mVotecount.setText(context.getString(R.string.ask_vote_count, entity.getVote()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ public class AskSearchAdapter extends ListAdapter {
|
||||
Questions question = searchEntity.getQuestion();
|
||||
if (question != null) {
|
||||
askHolder.mTitle.setText(Html.fromHtml(question.getTitle()));
|
||||
askHolder.mAnswercount.setText(mContext.getString(R.string.ask_answer_count, question.getAnswersCount()));
|
||||
askHolder.mAnswercount.setText(mContext.getString(R.string.ask_answer_count, question.getAnswerCount()));
|
||||
}
|
||||
askHolder.mContent.setText(Html.fromHtml(searchEntity.getBrief()));
|
||||
break;
|
||||
|
||||
@ -3,6 +3,7 @@ package com.gh.gamecenter.ask.search;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import com.gh.gamecenter.AskQuestionsDetailActivity;
|
||||
import com.gh.gamecenter.NormalActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ask.QuestionsEditFragment;
|
||||
@ -56,7 +57,8 @@ public class AskSearchFragment extends ListFragment {
|
||||
break;
|
||||
case R.id.ask_search_item:
|
||||
List<AskSearchEntity> list = (List<AskSearchEntity>) data;
|
||||
|
||||
String id = list.get(position).getQuestion().getId();
|
||||
startActivity(AskQuestionsDetailActivity.getIntent(getContext(), id));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -24,5 +24,6 @@ public class AskSearchItemViewHolder extends BaseRecyclerViewHolder {
|
||||
|
||||
public AskSearchItemViewHolder(View itemView, Object data, OnListClickListener listClickListener) {
|
||||
super(itemView, data, listClickListener);
|
||||
itemView.setOnClickListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,8 @@ import java.util.List;
|
||||
|
||||
public abstract class ListAdapter extends BaseRecyclerAdapter {
|
||||
|
||||
protected static final int FOOTER_ITEM_COUNT = 1;
|
||||
public static final int FOOTER_ITEM_COUNT = 1;
|
||||
public static final int TOP_ITEM_COUNT = 1;
|
||||
|
||||
protected boolean mIsOver;
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package com.gh.gamecenter.entity
|
||||
import android.arch.persistence.room.Entity
|
||||
import android.arch.persistence.room.PrimaryKey
|
||||
import android.support.annotation.NonNull
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Created by khy on 17/07/17.
|
||||
@ -14,6 +15,9 @@ class UserInfoEntity {
|
||||
@NonNull
|
||||
var id: String? = null
|
||||
|
||||
@SerializedName("_id")
|
||||
var userId: String? = null
|
||||
|
||||
var name: String? = null
|
||||
|
||||
var icon: String? = null
|
||||
|
||||
@ -11,7 +11,7 @@ import com.gh.gamecenter.entity.UserInfoEntity;
|
||||
/**
|
||||
* Created by khy on 28/11/17.
|
||||
*/
|
||||
@Database(entities = {LoginTokenEntity.class, UserInfoEntity.class}, version = 1, exportSchema = false)
|
||||
@Database(entities = {LoginTokenEntity.class, UserInfoEntity.class}, version = 2, exportSchema = false)
|
||||
public abstract class AppDatabase extends RoomDatabase {
|
||||
|
||||
public abstract UserInfoDao userInfoDao();
|
||||
@ -36,7 +36,12 @@ public abstract class AppDatabase extends RoomDatabase {
|
||||
}
|
||||
|
||||
private static AppDatabase buildDatabase(Context context) {
|
||||
return Room.databaseBuilder(context, AppDatabase.class, DATABASE_NAME).allowMainThreadQueries().build();
|
||||
return Room.databaseBuilder(context, AppDatabase.class, DATABASE_NAME)
|
||||
//TODO 不允许主线程查询
|
||||
.allowMainThreadQueries()
|
||||
//TODO 提供db升级的策略而不是强行销毁
|
||||
.fallbackToDestructiveMigration()
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -54,6 +54,13 @@ public class UserManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
if (mUserInfoEntity != null) {
|
||||
return mUserInfoEntity.getUserId();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setCommunityId(Context context, String communityId) {
|
||||
if (!mCommunityId.equals(communityId)) {
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit().putString(COMMUNITY_ID, communityId).apply();
|
||||
|
||||
@ -27,4 +27,8 @@ public abstract class NormalFragment extends BaseFragment {
|
||||
public void onMenuItemClick(MenuItem menuItem) {
|
||||
|
||||
}
|
||||
|
||||
public boolean onBackPressed () {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,11 +25,13 @@ import com.gh.gamecenter.InstallActivity;
|
||||
import com.gh.gamecenter.LibaoActivity;
|
||||
import com.gh.gamecenter.LoginActivity;
|
||||
import com.gh.gamecenter.MessageActivity;
|
||||
import com.gh.gamecenter.NormalActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ShareGhActivity;
|
||||
import com.gh.gamecenter.SuggestSelectActivity;
|
||||
import com.gh.gamecenter.SuggestionActivity;
|
||||
import com.gh.gamecenter.UserInfoActivity;
|
||||
import com.gh.gamecenter.ask.myask.MyAskFragment;
|
||||
import com.gh.gamecenter.entity.AppEntity;
|
||||
import com.gh.gamecenter.entity.LoginTokenEntity;
|
||||
import com.gh.gamecenter.entity.MessageUnreadEntity;
|
||||
@ -108,6 +110,8 @@ public class PersonalFragment extends BaseFragment implements Observer<ApiRespon
|
||||
View mLoginMessgeHint;
|
||||
@BindView(R.id.user_icon_hint)
|
||||
View mIconHint;
|
||||
@BindView(R.id.personal_ask)
|
||||
View mPersonalAsk;
|
||||
|
||||
public final static String LOGIN_TAG = "login_tag"; //登入标识
|
||||
public final static String LOGOUT_TAG = "logout_tag"; // 登出标识
|
||||
@ -176,7 +180,7 @@ public class PersonalFragment extends BaseFragment implements Observer<ApiRespon
|
||||
|
||||
@OnClick({R.id.personal_login_qq, R.id.personal_login_wechat, R.id.personal_login_weibo, R.id.personal_user_icon,
|
||||
R.id.personal_user_name, R.id.personal_game, R.id.personal_libao, R.id.personal_share, R.id.personal_suggestion,
|
||||
R.id.personal_setting})
|
||||
R.id.personal_setting, R.id.personal_ask})
|
||||
public void onViewClicked(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.personal_login_qq:
|
||||
@ -244,6 +248,9 @@ public class PersonalFragment extends BaseFragment implements Observer<ApiRespon
|
||||
DataCollectionUtils.uploadClick(getActivity(), "设置图标", "我的光环");
|
||||
new IntentFactory.Builder(getContext()).setFragment(SettingsFragment.class).setEntrance("(我的光环)").start();
|
||||
break;
|
||||
case R.id.personal_ask:
|
||||
NormalActivity.startFragment(getContext(), MyAskFragment.class);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -72,13 +72,13 @@ class OkHttpNetworkInterceptor implements Interceptor {
|
||||
Response response = chain.proceed(request);
|
||||
|
||||
// 404 Not Found
|
||||
if (response.code() == 404) {
|
||||
response = response.newBuilder()
|
||||
.code(200)
|
||||
.message("OK")
|
||||
.body(EMPTY_ARRAY_BODY)
|
||||
.build();
|
||||
}
|
||||
// if (response.code() == 404) {
|
||||
// response = response.newBuilder()
|
||||
// .code(200)
|
||||
// .message("OK")
|
||||
// .body(EMPTY_ARRAY_BODY)
|
||||
// .build();
|
||||
// }
|
||||
|
||||
// 缓存设置
|
||||
if (NetworkUtils.isNetworkConnected(mContext)) {
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
package com.gh.gamecenter.retrofit.service;
|
||||
|
||||
import com.gh.gamecenter.ask.entity.AnswerDetailEntity;
|
||||
import com.gh.gamecenter.ask.entity.AnswerEntity;
|
||||
import com.gh.gamecenter.ask.entity.AskGameSelectEntity;
|
||||
import com.gh.gamecenter.ask.entity.AskSearchEntity;
|
||||
import com.gh.gamecenter.ask.entity.AskTagGroupsEntity;
|
||||
import com.gh.gamecenter.ask.entity.InviteEntity;
|
||||
import com.gh.gamecenter.ask.entity.Questions;
|
||||
import com.gh.gamecenter.ask.entity.QuestionsDetailEntity;
|
||||
import com.gh.gamecenter.ask.entity.QuestionsEntity;
|
||||
import com.gh.gamecenter.ask.questionsdetail.QuestionsDetailEntity;
|
||||
import com.gh.gamecenter.entity.AppEntity;
|
||||
import com.gh.gamecenter.entity.CommentEntity;
|
||||
import com.gh.gamecenter.entity.CommentnumEntity;
|
||||
@ -704,8 +706,8 @@ public interface ApiService {
|
||||
/**
|
||||
* 获取社区首页-问题列表
|
||||
*/
|
||||
@GET("communities/{community_id}/questions")
|
||||
Observable<List<QuestionsEntity>> getAskQuestions(@Path("community_id") String communityId, @Query("type_group") String type, @Query("offset") int offset);
|
||||
@GET("communities/{community_id}/questions?view=digest")
|
||||
Observable<List<Questions>> getAskQuestions(@Path("community_id") String communityId, @Query("type_group") String type, @Query("offset") int offset);
|
||||
|
||||
/**
|
||||
* 获取社区首页栏目
|
||||
@ -723,7 +725,7 @@ public interface ApiService {
|
||||
* 社区问题的答案列表
|
||||
*/
|
||||
@GET("questions/{questions_id}/answers?view=digest")
|
||||
Observable<List<QuestionsEntity>> getQuestionsAnswer(@Path("questions_id") String questionsId, @Query("fold") boolean isFold);
|
||||
Observable<List<AnswerEntity>> getQuestionsAnswer(@Path("questions_id") String questionsId, @Query("fold") boolean isFold);
|
||||
|
||||
/**
|
||||
* 获取社区达人列表
|
||||
@ -731,6 +733,12 @@ public interface ApiService {
|
||||
@GET("questions/{questions_id}/experts")
|
||||
Observable<List<InviteEntity>> getInviteExperts(@Path("questions_id") String questionsId, @Query("offset") int offset);
|
||||
|
||||
/**
|
||||
* 邀请达人回答社区问题
|
||||
*/
|
||||
@POST("questions/{questions_id}:invite")
|
||||
Observable<ResponseBody> postInvite(@Body RequestBody body, @Path("questions_id") String questionsId);
|
||||
|
||||
/**
|
||||
* 搜索社区问题
|
||||
*/
|
||||
@ -746,12 +754,91 @@ public interface ApiService {
|
||||
/**
|
||||
* 对社区问题进行回答
|
||||
*/
|
||||
@POST("/questions/{question_id}/answers")
|
||||
Observable<ResponseBody> postQuestionAnswer(@Path("community_id") String questionsId);
|
||||
@POST("questions/{question_id}/answers")
|
||||
Observable<ResponseBody> postQuestionAnswer(@Body RequestBody body, @Path("question_id") String questionsId);
|
||||
|
||||
/**
|
||||
* 对社区问题进行回答
|
||||
*/
|
||||
@PATCH("answers/{answer_id}")
|
||||
Observable<ResponseBody> patchQuestionAnswer(@Body RequestBody body, @Path("answer_id") String answerId);
|
||||
|
||||
/**
|
||||
* 答案详情
|
||||
*/
|
||||
@GET("answers/{answer_id}")
|
||||
@GET("answers/{answer_id}?view=detail")
|
||||
Observable<AnswerDetailEntity> getAnswerDetail(@Path("answer_id") String answerId);
|
||||
|
||||
/**
|
||||
* 获取社区问题标签
|
||||
*/
|
||||
@GET("communities/{community_id}/tags")
|
||||
Observable<List<String>> getCommunitiesTags(@Path("community_id") String communityId);
|
||||
|
||||
/**
|
||||
* 添加社区问题
|
||||
*/
|
||||
@POST("communities/{community_id}/questions")
|
||||
Observable<ResponseBody> postQuestions(@Body RequestBody body, @Path("community_id") String communityId);
|
||||
|
||||
/**
|
||||
* 对社区答案点赞
|
||||
*/
|
||||
@POST("answers/{answer_id}:vote")
|
||||
Observable<ResponseBody> postAnswerVote(@Path("answer_id") String answerId);
|
||||
|
||||
/**
|
||||
* 获取用户的问题列表
|
||||
*/
|
||||
@GET("users/{user_id}/questions")
|
||||
Observable<List<Questions>> getMyQuestions(@Path("user_id") String userId, @Query("offset") int offset);
|
||||
|
||||
/**
|
||||
* 获取用户的答案列表
|
||||
*/
|
||||
@GET("users/{user_id}/answers")
|
||||
Observable<List<AnswerEntity>> getMyAnswers(@Path("user_id") String userId, @Query("offset") int offset);
|
||||
|
||||
/**
|
||||
* 获取用户的草稿列表
|
||||
*/
|
||||
@GET("users/{user_id}/answer_drafts")
|
||||
Observable<List<AnswerEntity>> getMyAnswerDrafts(@Path("user_id") String userId, @Query("offset") int offset);
|
||||
|
||||
/**
|
||||
* 获取用户的关注问题列表
|
||||
*/
|
||||
@GET("questions/concern")
|
||||
Observable<List<Questions>> getConcernQuestions(@Query("offset") int offset);
|
||||
|
||||
/**
|
||||
* 收藏答案
|
||||
*/
|
||||
@POST("favorite/answers/{answer_id}")
|
||||
Observable<ResponseBody> postCollectionAnswer(@Path("answer_id") String answerId);
|
||||
|
||||
/**
|
||||
* 取消收藏答案
|
||||
*/
|
||||
@DELETE("favorite/answers/{answer_id}")
|
||||
Observable<ResponseBody> deleteCollectionAnswer(@Path("answer_id") String answerId);
|
||||
|
||||
/**
|
||||
* 关注问题
|
||||
*/
|
||||
@POST("questions/{question_id}:follow")
|
||||
Observable<ResponseBody> postConcernQuestions(@Path("question_id") String questionsId);
|
||||
|
||||
/**
|
||||
* 取消关注问题
|
||||
*/
|
||||
@POST("questions/{question_id}:unfollow")
|
||||
Observable<ResponseBody> deleteConcernQuestions(@Path("question_id") String questionsId);
|
||||
|
||||
|
||||
/**
|
||||
* 保存用户答案的草稿
|
||||
*/
|
||||
@POST("questions/{question_id}:follow")
|
||||
Observable<ResponseBody> postAnswerDrafts(@Body RequestBody body, @Path("question_id") String questionsId);
|
||||
}
|
||||
@ -318,7 +318,8 @@ public class SettingsFragment extends BaseFragment {
|
||||
.setNegativeButton("确认", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
checkSizeIndex = radioGroup.getCheckedRadioButtonId() % 4;
|
||||
int checkedRadioButtonId = radioGroup.getCheckedRadioButtonId();
|
||||
checkSizeIndex = checkedRadioButtonId % 4;
|
||||
|
||||
if (checkSizeIndex == 0) {
|
||||
checkSizeIndex = 4;
|
||||
|
||||
BIN
app/src/main/res/drawable-xxhdpi/personal_ask_icon.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/personal_ask_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
75
app/src/main/res/layout/ask_answer_item.xml
Normal file
75
app/src/main/res/layout/ask_answer_item.xml
Normal file
@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android = "http://schemas.android.com/apk/res/android"
|
||||
xmlns:app = "http://schemas.android.com/apk/res-auto"
|
||||
android:id = "@+id/ask_answer_item_constraintlayout"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "wrap_content"
|
||||
android:background = "@drawable/reuse_listview_item_style"
|
||||
android:paddingBottom = "12dp"
|
||||
android:paddingLeft = "20dp"
|
||||
android:paddingRight = "20dp"
|
||||
android:paddingTop = "15dp" >
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id = "@+id/ask_answer_item_usericon"
|
||||
style = "@style/frescoStyle"
|
||||
android:layout_width = "30dp"
|
||||
android:layout_height = "30dp"
|
||||
app:layout_constraintLeft_toLeftOf = "@id/ask_answer_item_constraintlayout"
|
||||
app:layout_constraintTop_toTopOf = "@id/ask_answer_item_constraintlayout" />
|
||||
|
||||
<TextView
|
||||
android:id = "@+id/ask_answer_item_username"
|
||||
android:layout_width = "wrap_content"
|
||||
android:layout_height = "wrap_content"
|
||||
android:layout_marginLeft = "10dp"
|
||||
android:maxLength = "10"
|
||||
android:textColor = "@color/title"
|
||||
android:textSize = "14sp"
|
||||
app:layout_constraintBottom_toBottomOf = "@id/ask_answer_item_usericon"
|
||||
app:layout_constraintLeft_toRightOf = "@id/ask_answer_item_usericon"
|
||||
app:layout_constraintTop_toTopOf = "@id/ask_answer_item_usericon" />
|
||||
|
||||
<TextView
|
||||
android:id = "@+id/ask_answer_item_title"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "wrap_content"
|
||||
android:layout_marginTop = "10dp"
|
||||
android:maxLines = "2"
|
||||
android:textColor = "@color/black"
|
||||
android:textSize = "16sp"
|
||||
android:textStyle = "bold"
|
||||
android:visibility = "gone"
|
||||
app:layout_constraintTop_toBottomOf = "@id/ask_answer_item_usericon" />
|
||||
|
||||
<TextView
|
||||
android:id = "@+id/ask_answer_item_content"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "wrap_content"
|
||||
android:layout_marginTop = "10dp"
|
||||
android:ellipsize = "end"
|
||||
android:maxLines = "3"
|
||||
android:textColor = "@color/title"
|
||||
android:textSize = "14sp"
|
||||
app:layout_constraintTop_toBottomOf = "@id/ask_answer_item_title" />
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id = "@+id/ask_answer_item_img"
|
||||
style = "@style/frescoStyle"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "wrap_content"
|
||||
android:layout_marginTop = "10dp"
|
||||
app:layout_constraintTop_toBottomOf = "@id/ask_answer_item_content"
|
||||
app:viewAspectRatio = "2.3" />
|
||||
|
||||
<TextView
|
||||
android:id = "@+id/ask_answer_item_votecount"
|
||||
android:layout_width = "wrap_content"
|
||||
android:layout_height = "wrap_content"
|
||||
android:layout_marginTop = "12dp"
|
||||
android:textColor = "@color/hint"
|
||||
android:textSize = "11sp"
|
||||
app:layout_constraintTop_toBottomOf = "@id/ask_answer_item_img" />
|
||||
|
||||
|
||||
</android.support.constraint.ConstraintLayout >
|
||||
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android = "http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/ask_questions_new_item"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "wrap_content"
|
||||
android:background = "@drawable/reuse_listview_item_style"
|
||||
|
||||
@ -1,107 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android = "http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android = "http://schemas.android.com/apk/res/android"
|
||||
xmlns:app = "http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "match_parent"
|
||||
android:layout_marginTop = "8dp"
|
||||
android:background = "@android:color/white" >
|
||||
android:layout_height = "match_parent" >
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
<ScrollView
|
||||
android:id = "@+id/answer_detail_content"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "wrap_content"
|
||||
android:paddingLeft = "20dp"
|
||||
android:paddingRight = "20dp" >
|
||||
android:layout_height = "match_parent"
|
||||
android:layout_marginTop = "8dp"
|
||||
android:background = "@android:color/white"
|
||||
android:visibility = "gone" >
|
||||
|
||||
<TextView
|
||||
android:id = "@+id/answer_detail_title"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "50dp"
|
||||
android:drawableLeft = "@drawable/answer_edit_questions_icon"
|
||||
android:drawablePadding = "10dp"
|
||||
android:gravity = "center_vertical"
|
||||
android:textSize = "16sp"
|
||||
android:textStyle = "bold" />
|
||||
|
||||
<View
|
||||
android:id = "@+id/answer_detail_line2"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "1dp"
|
||||
android:layout_below = "@id/answer_edit_title"
|
||||
android:background = "@color/background"
|
||||
app:layout_constraintTop_toBottomOf = "@id/answer_detail_title" />
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id = "@+id/answer_detail_usericon"
|
||||
style = "@style/frescoStyle"
|
||||
android:layout_width = "30dp"
|
||||
android:layout_height = "30dp"
|
||||
android:layout_marginTop = "15dp"
|
||||
app:layout_constraintLeft_toLeftOf = "parent"
|
||||
app:layout_constraintTop_toBottomOf = "@id/answer_detail_line2" />
|
||||
|
||||
<TextView
|
||||
android:id = "@+id/answer_detail_username"
|
||||
android:layout_width = "wrap_content"
|
||||
android:layout_height = "wrap_content"
|
||||
android:layout_marginLeft = "10dp"
|
||||
android:maxLength = "10"
|
||||
android:textColor = "@color/title"
|
||||
android:textSize = "14sp"
|
||||
app:layout_constraintBottom_toTopOf = "@+id/answer_detail_content"
|
||||
app:layout_constraintLeft_toRightOf = "@id/answer_detail_usericon"
|
||||
app:layout_constraintTop_toBottomOf = "@id/answer_detail_line2" />
|
||||
|
||||
<com.gh.common.view.RichEditor
|
||||
android:id = "@+id/answer_detail_content"
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "wrap_content"
|
||||
android:layout_marginTop = "15dp"
|
||||
app:layout_constraintLeft_toLeftOf = "parent"
|
||||
app:layout_constraintRight_toRightOf = "parent"
|
||||
app:layout_constraintTop_toBottomOf = "@id/answer_detail_usericon" />
|
||||
android:paddingLeft = "20dp"
|
||||
android:paddingRight = "20dp"
|
||||
android:paddingBottom="20dp">
|
||||
|
||||
<TextView
|
||||
android:id = "@+id/answer_detail_time"
|
||||
android:layout_width = "wrap_content"
|
||||
android:layout_height = "wrap_content"
|
||||
android:layout_marginTop = "10dp"
|
||||
android:textColor = "@color/title"
|
||||
android:textSize = "14sp"
|
||||
app:layout_constraintRight_toRightOf = "parent"
|
||||
app:layout_constraintTop_toBottomOf = "@id/answer_detail_content" />
|
||||
<TextView
|
||||
android:id = "@+id/answer_detail_title"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "50dp"
|
||||
android:drawableLeft = "@drawable/answer_edit_questions_icon"
|
||||
android:drawablePadding = "10dp"
|
||||
android:gravity = "center_vertical"
|
||||
android:textSize = "16sp"
|
||||
android:textStyle = "bold" />
|
||||
|
||||
<TextView
|
||||
android:id = "@+id/answer_detail_edit"
|
||||
android:layout_width = "wrap_content"
|
||||
android:layout_height = "wrap_content"
|
||||
android:layout_marginTop = "15dp"
|
||||
android:text = "修改答案"
|
||||
android:textColor = "@color/theme"
|
||||
android:textSize = "14sp"
|
||||
app:layout_constraintRight_toRightOf = "parent"
|
||||
app:layout_constraintTop_toBottomOf = "@id/answer_detail_time" />
|
||||
<View
|
||||
android:id = "@+id/answer_detail_line2"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "1dp"
|
||||
android:background = "@color/background"
|
||||
app:layout_constraintTop_toBottomOf = "@id/answer_detail_title" />
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id = "@+id/answer_detail_usericon"
|
||||
style = "@style/frescoStyle"
|
||||
android:layout_width = "30dp"
|
||||
android:layout_height = "30dp"
|
||||
android:layout_marginTop = "15dp"
|
||||
app:layout_constraintLeft_toLeftOf = "parent"
|
||||
app:layout_constraintTop_toBottomOf = "@id/answer_detail_line2" />
|
||||
|
||||
<TextView
|
||||
android:id = "@+id/answer_detail_username"
|
||||
android:layout_width = "wrap_content"
|
||||
android:layout_height = "wrap_content"
|
||||
android:layout_marginLeft = "10dp"
|
||||
android:maxLength = "10"
|
||||
android:textColor = "@color/title"
|
||||
android:textSize = "14sp"
|
||||
app:layout_constraintBottom_toTopOf = "@+id/answer_detail_Rd"
|
||||
app:layout_constraintLeft_toRightOf = "@id/answer_detail_usericon"
|
||||
app:layout_constraintTop_toBottomOf = "@id/answer_detail_line2" />
|
||||
|
||||
<com.gh.common.view.RichEditor
|
||||
android:id = "@+id/answer_detail_Rd"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "wrap_content"
|
||||
android:layout_marginTop = "15dp"
|
||||
app:layout_constraintLeft_toLeftOf = "parent"
|
||||
app:layout_constraintRight_toRightOf = "parent"
|
||||
app:layout_constraintTop_toBottomOf = "@id/answer_detail_usericon" />
|
||||
|
||||
<TextView
|
||||
android:id = "@+id/answer_detail_time"
|
||||
android:layout_width = "wrap_content"
|
||||
android:layout_height = "wrap_content"
|
||||
android:layout_marginTop = "10dp"
|
||||
android:textColor = "@color/title"
|
||||
android:textSize = "14sp"
|
||||
app:layout_constraintRight_toRightOf = "parent"
|
||||
app:layout_constraintTop_toBottomOf = "@id/answer_detail_Rd" />
|
||||
|
||||
<TextView
|
||||
android:id = "@+id/answer_detail_edit"
|
||||
android:layout_width = "wrap_content"
|
||||
android:layout_height = "wrap_content"
|
||||
android:layout_marginTop = "15dp"
|
||||
android:text = "修改答案"
|
||||
android:textColor = "@color/theme"
|
||||
android:textSize = "14sp"
|
||||
app:layout_constraintRight_toRightOf = "parent"
|
||||
app:layout_constraintTop_toBottomOf = "@id/answer_detail_time" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id = "@+id/answer_detail_vote"
|
||||
android:layout_width = "wrap_content"
|
||||
android:layout_height = "wrap_content"
|
||||
android:src = "@drawable/answer_detail_unvote"
|
||||
app:layout_constraintLeft_toLeftOf = "parent"
|
||||
app:layout_constraintRight_toRightOf = "parent"
|
||||
app:layout_constraintTop_toBottomOf = "@id/answer_detail_edit" />
|
||||
<ImageView
|
||||
android:id = "@+id/answer_detail_vote"
|
||||
android:layout_width = "wrap_content"
|
||||
android:layout_height = "wrap_content"
|
||||
android:src = "@drawable/answer_detail_unvote"
|
||||
app:layout_constraintLeft_toLeftOf = "parent"
|
||||
app:layout_constraintRight_toRightOf = "parent"
|
||||
app:layout_constraintTop_toBottomOf = "@id/answer_detail_edit" />
|
||||
|
||||
<TextView
|
||||
android:id = "@+id/answer_detail_vote_count"
|
||||
android:layout_width = "wrap_content"
|
||||
android:layout_height = "wrap_content"
|
||||
android:layout_marginTop = "20dp"
|
||||
android:text = "赞同"
|
||||
android:textColor = "@color/theme"
|
||||
android:textSize = "14sp"
|
||||
app:layout_constraintLeft_toLeftOf = "parent"
|
||||
app:layout_constraintRight_toRightOf = "parent"
|
||||
app:layout_constraintTop_toBottomOf = "@id/answer_detail_vote" />
|
||||
<TextView
|
||||
android:id = "@+id/answer_detail_vote_count"
|
||||
android:layout_width = "wrap_content"
|
||||
android:layout_height = "wrap_content"
|
||||
android:layout_marginTop = "20dp"
|
||||
android:text = "赞同"
|
||||
android:textColor = "@color/theme"
|
||||
android:textSize = "14sp"
|
||||
app:layout_constraintLeft_toLeftOf = "parent"
|
||||
app:layout_constraintRight_toRightOf = "parent"
|
||||
app:layout_constraintTop_toBottomOf = "@id/answer_detail_vote" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout >
|
||||
</ScrollView >
|
||||
</android.support.constraint.ConstraintLayout >
|
||||
</ScrollView >
|
||||
|
||||
<include layout = "@layout/reuse_no_connection" />
|
||||
|
||||
<com.gc.materialdesign.views.ProgressBarCircularIndeterminate
|
||||
android:id = "@+id/answer_detail_loading"
|
||||
android:layout_width = "40dp"
|
||||
android:layout_height = "40dp"
|
||||
android:layout_centerInParent = "true"
|
||||
android:background = "@color/theme" />
|
||||
</RelativeLayout >
|
||||
5
app/src/main/res/layout/fragment_myask.xml
Normal file
5
app/src/main/res/layout/fragment_myask.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android = "http://schemas.android.com/apk/res/android"
|
||||
android:id = "@id/layout_fragment_content"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "match_parent" />
|
||||
@ -245,6 +245,37 @@
|
||||
|
||||
</RelativeLayout >
|
||||
|
||||
<View
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "1dp" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id = "@+id/personal_ask"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "48dp"
|
||||
android:background = "@drawable/reuse_listview_item_style"
|
||||
android:paddingLeft = "18dp"
|
||||
android:paddingRight = "18dp" >
|
||||
|
||||
<ImageView
|
||||
android:id = "@+id/personal_ask_icon"
|
||||
android:layout_width = "18dp"
|
||||
android:layout_height = "18dp"
|
||||
android:layout_centerVertical = "true"
|
||||
android:layout_marginRight = "18dp"
|
||||
android:src = "@drawable/personal_ask_icon" />
|
||||
|
||||
<TextView
|
||||
android:layout_width = "wrap_content"
|
||||
android:layout_height = "wrap_content"
|
||||
android:layout_centerVertical = "true"
|
||||
android:layout_toRightOf = "@+id/personal_ask_icon"
|
||||
android:text = "@string/personal_ask"
|
||||
android:textColor = "@color/title"
|
||||
android:textSize = "15sp" />
|
||||
|
||||
</RelativeLayout >
|
||||
|
||||
<View
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "8dp" />
|
||||
|
||||
@ -96,6 +96,7 @@
|
||||
android:lineSpacingMultiplier = "1.2"
|
||||
android:minLines = "2"
|
||||
android:padding = "20dp"
|
||||
android:maxLength="30"
|
||||
android:textColorHint = "@color/content"
|
||||
android:textCursorDrawable = "@drawable/cursor_color"
|
||||
android:textSize = "13sp" />
|
||||
|
||||
72
app/src/main/res/layout/fragment_wrapper_myask.xml
Normal file
72
app/src/main/res/layout/fragment_wrapper_myask.xml
Normal file
@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "match_parent"
|
||||
android:orientation = "vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "wrap_content"
|
||||
android:background = "@android:color/white"
|
||||
android:orientation = "vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:id = "@id/lightgame_tab_container"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "35dp"
|
||||
android:orientation = "horizontal" >
|
||||
|
||||
<CheckedTextView
|
||||
android:layout_width = "0dp"
|
||||
android:layout_height = "match_parent"
|
||||
android:layout_weight = "1"
|
||||
android:gravity = "center"
|
||||
android:text = "关注问题"
|
||||
android:textAlignment = "center"
|
||||
android:textColor = "@color/text_tabbar_style" />
|
||||
|
||||
<CheckedTextView
|
||||
android:layout_width = "0dp"
|
||||
android:layout_height = "match_parent"
|
||||
android:layout_weight = "1"
|
||||
android:gravity = "center"
|
||||
android:text = "我的问题"
|
||||
android:textAlignment = "center"
|
||||
android:textColor = "@color/text_tabbar_style" />
|
||||
|
||||
<CheckedTextView
|
||||
android:layout_width = "0dp"
|
||||
android:layout_height = "match_parent"
|
||||
android:layout_weight = "1"
|
||||
android:gravity = "center"
|
||||
android:text = "我的答案"
|
||||
android:textAlignment = "center"
|
||||
android:textColor = "@color/text_tabbar_style" />
|
||||
|
||||
|
||||
<CheckedTextView
|
||||
android:layout_width = "0dp"
|
||||
android:layout_height = "match_parent"
|
||||
android:layout_weight = "1"
|
||||
android:gravity = "center"
|
||||
android:text = "我的草稿"
|
||||
android:textAlignment = "center"
|
||||
android:textColor = "@color/text_tabbar_style" />
|
||||
|
||||
</LinearLayout >
|
||||
|
||||
<View
|
||||
android:id = "@+id/myask_slide_line"
|
||||
android:layout_width = "wrap_content"
|
||||
android:layout_height = "2dp"
|
||||
android:background = "@color/theme" />
|
||||
|
||||
</LinearLayout >
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id = "@id/lightgame_tab_viewpager"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "match_parent"
|
||||
android:overScrollMode = "never" />
|
||||
|
||||
</LinearLayout >
|
||||
@ -37,7 +37,6 @@
|
||||
app:layout_constraintLeft_toRightOf = "@id/questionsinvite_item_icon"
|
||||
app:layout_constraintTop_toBottomOf = "@id/questionsinvite_item_name" >
|
||||
|
||||
|
||||
<TextView
|
||||
android:id = "@+id/questionsinvite_item_answercount"
|
||||
android:layout_width = "wrap_content"
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
android:layout_height = "match_parent" >
|
||||
|
||||
<ImageView
|
||||
android:id = "@+id/actionbar_iv_back"
|
||||
android:layout_width = "17dp"
|
||||
android:layout_height = "17dp"
|
||||
android:layout_centerInParent = "true"
|
||||
|
||||
@ -462,9 +462,9 @@
|
||||
<string name = "ask_search_questions_hint" >点我提问</string >
|
||||
<string name = "quesionsdetail_fold_hint" >查看折叠答案</string >
|
||||
<string name = "ask_game_suggestion" >没有我的游戏?点击提交</string >
|
||||
|
||||
<string name = "ask_answer_count">%1$d 回答</string>
|
||||
<string name = "ask_vote_count">%1$d 赞同</string>
|
||||
|
||||
<string name = "ask_answer_count" >%1$d 回答</string >
|
||||
<string name = "ask_vote_count" >%1$d 赞同</string >
|
||||
<string name = "voted" >已投</string >
|
||||
<string name = "vote" >投票</string >
|
||||
<string name = "title_libao" >礼包中心</string >
|
||||
@ -475,5 +475,12 @@
|
||||
<string name = "menu_collect" >收藏</string >
|
||||
<string name = "menu_concern" >关注</string >
|
||||
<string name = "receive_instruction" >操作说明</string >
|
||||
<string name = "answer_detail_title" >答案详情</string >
|
||||
<string name = "invite_success" >邀请成功</string >
|
||||
<string name = "invite_failure" >邀请失败</string >
|
||||
|
||||
<string name = "personal_ask" >我的问答</string >
|
||||
<string name = "myask" >我的问答</string >
|
||||
<string name = "concerned" >已关注</string >
|
||||
|
||||
</resources >
|
||||
|
||||
@ -7,8 +7,8 @@ ext {
|
||||
targetSdkVersion = 22
|
||||
|
||||
// application info
|
||||
versionCode = 21
|
||||
versionName = "3.0"
|
||||
versionCode = 22
|
||||
versionName = "3.1"
|
||||
applicationId = "com.gh.gamecenter"
|
||||
|
||||
//Libraries
|
||||
|
||||
@ -21,7 +21,7 @@ org.gradle.parallel=true
|
||||
channel_file=channel.txt
|
||||
|
||||
# tinker patch version_name
|
||||
PATCH_VERSION_NAME=3.0.2
|
||||
PATCH_VERSION_NAME=3.1
|
||||
|
||||
# Third-party keys
|
||||
DEBUG_UMENG_APPKEY=58e5b0b9c62dca35a00005e6
|
||||
|
||||
Submodule libraries/LGLibrary updated: c20470d8f7...85db236c8d
Reference in New Issue
Block a user