问答相关页面整理
This commit is contained in:
@ -3,15 +3,32 @@ package com.gh.gamecenter;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.gamecenter.ask.QuestionsEditFragment;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.gamecenter.ask.questionsdetail.AnswerEditFragment;
|
||||
import com.gh.gamecenter.ask.questionsdetail.QuestionsDetailFragment;
|
||||
import com.gh.gamecenter.ask.questionsdetail.QuestionsInviteFragment;
|
||||
|
||||
/**
|
||||
* Created by khy on 7/12/17.
|
||||
*/
|
||||
|
||||
public class AskQuestionsDetailActivity extends BaseActivity {
|
||||
public class AskQuestionsDetailActivity extends BaseActivity implements FragmentManager.OnBackStackChangedListener {
|
||||
|
||||
public static final String QUESTIONS_DETAIL_ANSWER = "answer";
|
||||
public static final String QUESTIONS_DETAIL_INVITE = "invite";
|
||||
public static final String QUESTIONS_DETAIL_FOLD = "fold";
|
||||
public static final String QUESTIONS_DETAIL = "questions_detail";
|
||||
|
||||
private QuestionsDetailFragment mQuestionsDetailFragment;
|
||||
|
||||
private View mShareIv;
|
||||
private View mAnswerPost;
|
||||
|
||||
public static Intent getIntent(Context context) {
|
||||
return new Intent(context, AskQuestionsDetailActivity.class);
|
||||
@ -25,7 +42,122 @@ public class AskQuestionsDetailActivity extends BaseActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getSupportFragmentManager().beginTransaction().replace(
|
||||
R.id.layout_fragment_content, new QuestionsEditFragment()).commitAllowingStateLoss();
|
||||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addShareView() {
|
||||
RelativeLayout reuse_actionbar = mContentView.findViewById(R.id.reuse_actionbar);
|
||||
mShareIv = LayoutInflater.from(this).inflate(R.layout.menu_action_share, reuse_actionbar, false);
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mShareIv.getLayoutParams();
|
||||
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||
params.addRule(RelativeLayout.CENTER_VERTICAL);
|
||||
reuse_actionbar.addView(mShareIv, params);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public void show(String type) {
|
||||
showMenu(type);
|
||||
switch (type) {
|
||||
case QUESTIONS_DETAIL_ANSWER:
|
||||
showAnswerEdit(type);
|
||||
break;
|
||||
case QUESTIONS_DETAIL_INVITE:
|
||||
showQuestionsInvite(type);
|
||||
break;
|
||||
case QUESTIONS_DETAIL_FOLD:
|
||||
showDetailFold(type);
|
||||
break;
|
||||
case QUESTIONS_DETAIL:
|
||||
showQuestionsDetail(type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void showQuestionsDetail(String type) {
|
||||
mQuestionsDetailFragment = new QuestionsDetailFragment();
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.layout_fragment_content, mQuestionsDetailFragment)
|
||||
.commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
private void showDetailFold(String type) {
|
||||
|
||||
}
|
||||
|
||||
private void showQuestionsInvite(String type) {
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.addToBackStack(type)
|
||||
.replace(R.id.layout_fragment_content,
|
||||
new QuestionsInviteFragment(), null).commit();
|
||||
}
|
||||
|
||||
private void showAnswerEdit(String type) {
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.addToBackStack(type)
|
||||
.replace(R.id.layout_fragment_content,
|
||||
new AnswerEditFragment(), null).commit();
|
||||
}
|
||||
|
||||
private void showMenu(String type) {
|
||||
switch (type) {
|
||||
case QUESTIONS_DETAIL_ANSWER:
|
||||
if (mAnswerPost == null) {
|
||||
addAnswerPostView();
|
||||
} else {
|
||||
mAnswerPost.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (mShareIv != null && mShareIv.getVisibility() == View.VISIBLE)
|
||||
mShareIv.setVisibility(View.GONE);
|
||||
break;
|
||||
case QUESTIONS_DETAIL:
|
||||
if (mShareIv == null) {
|
||||
addShareView();
|
||||
} else {
|
||||
mShareIv.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (mAnswerPost != null && mAnswerPost.getVisibility() == View.VISIBLE)
|
||||
mAnswerPost.setVisibility(View.GONE);
|
||||
break;
|
||||
case QUESTIONS_DETAIL_INVITE:
|
||||
case QUESTIONS_DETAIL_FOLD:
|
||||
if (mShareIv != null && mShareIv.getVisibility() == View.VISIBLE)
|
||||
mShareIv.setVisibility(View.GONE);
|
||||
if (mAnswerPost != null && mAnswerPost.getVisibility() == View.VISIBLE)
|
||||
mAnswerPost.setVisibility(View.GONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackStackChanged() {
|
||||
if (mQuestionsDetailFragment.isVisible()) {
|
||||
showMenu(QUESTIONS_DETAIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,19 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Vibrator;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.view.GestureDetectorCompat;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.BaseActivity;
|
||||
@ -52,10 +59,30 @@ public class AskTabOrderActivity extends BaseActivity {
|
||||
mRvData = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
|
||||
mRvData.add(i);
|
||||
}
|
||||
|
||||
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.Callback() {
|
||||
final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.Callback() {
|
||||
@Override
|
||||
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
|
||||
if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) {
|
||||
viewHolder.itemView.setBackgroundColor(Color.LTGRAY);
|
||||
}
|
||||
if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) {
|
||||
//获取系统震动服务
|
||||
Vibrator vib = (Vibrator) getSystemService(Service.VIBRATOR_SERVICE);
|
||||
if (vib != null) vib.vibrate(70);
|
||||
}
|
||||
super.onSelectedChanged(viewHolder, actionState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
|
||||
super.clearView(recyclerView, viewHolder);
|
||||
viewHolder.itemView.setBackgroundColor(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
|
||||
|
||||
@ -89,6 +116,12 @@ public class AskTabOrderActivity extends BaseActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLongPressDragEnabled() {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
|
||||
|
||||
@ -101,5 +134,54 @@ public class AskTabOrderActivity extends BaseActivity {
|
||||
mAdapter = new AskTabOrderAdapter(this, mRvData);
|
||||
mAsktabOrderRv.setAdapter(mAdapter);
|
||||
|
||||
mAsktabOrderRv.addOnItemTouchListener(new OnRvLongClickListener(mAsktabOrderRv) {
|
||||
@Override
|
||||
public void onItemLongClick(RecyclerView.ViewHolder vh) {
|
||||
if (vh.getLayoutPosition() != 0)
|
||||
itemTouchHelper.startDrag(vh);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private abstract class OnRvLongClickListener implements RecyclerView.OnItemTouchListener {
|
||||
|
||||
private GestureDetectorCompat mGestureDetector;
|
||||
private RecyclerView recyclerView;
|
||||
|
||||
public OnRvLongClickListener(RecyclerView recyclerView) {
|
||||
this.recyclerView = recyclerView;
|
||||
mGestureDetector = new GestureDetectorCompat(recyclerView.getContext(), new ItemTouchHelperGestureListener());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
|
||||
mGestureDetector.onTouchEvent(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
|
||||
mGestureDetector.onTouchEvent(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
|
||||
|
||||
}
|
||||
|
||||
private class ItemTouchHelperGestureListener extends GestureDetector.SimpleOnGestureListener {
|
||||
|
||||
@Override
|
||||
public void onLongPress(MotionEvent e) {
|
||||
View child = recyclerView.findChildViewUnder(e.getX(), e.getY());
|
||||
if (child != null) {
|
||||
RecyclerView.ViewHolder vh = recyclerView.getChildViewHolder(child);
|
||||
onItemLongClick(vh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void onItemLongClick(RecyclerView.ViewHolder vh);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +88,6 @@ public class UserInfoEditActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
mEditType = getIntent().getStringExtra(KEY_EDITTYPE);
|
||||
|
||||
// 添加分享图标
|
||||
mSaveTv = (TextView) LayoutInflater.from(this).inflate(R.layout.menu_action_save, null);
|
||||
mSaveTv.setVisibility(View.GONE);
|
||||
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
|
||||
|
||||
@ -8,6 +8,7 @@ import android.view.ViewGroup;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.AskSelectGameItemViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.ReuseViewHolder;
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter;
|
||||
|
||||
/**
|
||||
@ -15,6 +16,7 @@ import com.lightgame.adapter.BaseRecyclerAdapter;
|
||||
*/
|
||||
|
||||
public class AskSelectGameAdapter extends BaseRecyclerAdapter {
|
||||
|
||||
private int mTitlePosition;
|
||||
|
||||
public AskSelectGameAdapter(Context context) {
|
||||
@ -33,13 +35,26 @@ public class AskSelectGameAdapter extends BaseRecyclerAdapter {
|
||||
case ItemViewType.ITEM_BODY:
|
||||
view = mLayoutInflater.inflate(R.layout.ask_selectgame_item, parent, false);
|
||||
return new AskSelectGameItemViewHolder(view);
|
||||
case ItemViewType.ITEM_FOOTER:
|
||||
view = mLayoutInflater.inflate(R.layout.ask_selectgame_footer, parent, false);
|
||||
return new ReuseViewHolder(view);
|
||||
case ItemViewType.ITEM_TOP:
|
||||
view = mLayoutInflater.inflate(R.layout.area_title_item, parent, false);
|
||||
return new ReuseViewHolder(view);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
|
||||
switch (getItemViewType(position)) {
|
||||
case ItemViewType.ITEM_BODY:
|
||||
break;
|
||||
case ItemViewType.ITEM_FOOTER:
|
||||
break;
|
||||
case ItemViewType.ITEM_TOP:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -12,7 +12,7 @@ import android.widget.TextView;
|
||||
import com.gh.base.adapter.FragmentAdapter;
|
||||
import com.gh.base.fragment.BaseFragment;
|
||||
import com.gh.gamecenter.AskSearchActivity;
|
||||
import com.gh.gamecenter.AskSelectGameActivity;
|
||||
import com.gh.gamecenter.NormalActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.lightgame.view.NoScrollableViewPager;
|
||||
|
||||
@ -59,7 +59,7 @@ public class AskFragment extends BaseFragment {
|
||||
public void onViewClicked(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.ask_selectgame:
|
||||
startActivityForResult(AskSelectGameActivity.getIntent(getContext()), 0x111);//todo
|
||||
NormalActivity.startFragment(getContext(), SelectGameFragment.class);
|
||||
break;
|
||||
case R.id.ask_search:
|
||||
startActivity(AskSearchActivity.getIntent(getContext()));
|
||||
|
||||
@ -10,7 +10,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.baselist.BaseListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
import com.gh.gamecenter.entity.NewsEntity;
|
||||
|
||||
@ -20,7 +20,7 @@ import java.util.List;
|
||||
* Created by khy on 2/12/17.
|
||||
*/
|
||||
|
||||
public class AskHotAdapter extends BaseListAdapter {
|
||||
public class AskHotAdapter extends ListAdapter {
|
||||
|
||||
private OnListClickListener mListClickListener;
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ import android.view.View;
|
||||
|
||||
import com.gh.gamecenter.AskQuestionsDetailActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.baselist.BaseListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListFragment;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
import com.gh.gamecenter.baselist.LoadType;
|
||||
@ -30,7 +30,7 @@ public class AskHotFragment extends ListFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BaseListAdapter provideListAdapter() {
|
||||
protected ListAdapter provideListAdapter() {
|
||||
return mAdapter == null ? mAdapter = new AskHotAdapter(getContext(), this) : mAdapter;
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +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.baselist.BaseListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
import com.gh.gamecenter.entity.NewsEntity;
|
||||
|
||||
@ -19,7 +19,7 @@ import java.util.List;
|
||||
* Created by khy on 5/12/17.
|
||||
*/
|
||||
|
||||
public class AskQuestionsBodyAdapter extends BaseListAdapter {
|
||||
public class AskQuestionsBodyAdapter extends ListAdapter {
|
||||
private OnListClickListener mListClickListener;
|
||||
private List<NewsEntity> mEntityList;
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ package com.gh.gamecenter.ask;
|
||||
import android.view.View;
|
||||
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.baselist.BaseListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListFragment;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
import com.gh.gamecenter.baselist.LoadType;
|
||||
@ -24,7 +24,7 @@ public class AskQuestionsBodyFragment extends ListFragment {
|
||||
private AskQuestionsBodyAdapter mAdapter;
|
||||
|
||||
@Override
|
||||
protected BaseListAdapter provideListAdapter() {
|
||||
protected ListAdapter provideListAdapter() {
|
||||
return mAdapter == null ? mAdapter = new AskQuestionsBodyAdapter(getContext(), this) : mAdapter;
|
||||
}
|
||||
|
||||
|
||||
@ -1,51 +1,51 @@
|
||||
package com.gh.gamecenter;
|
||||
package com.gh.gamecenter.ask;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.AskSelectGameAdapter;
|
||||
import com.gh.gamecenter.normal.NormalFragment;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
||||
/**
|
||||
* Created by khy on 6/12/17.
|
||||
* Created by khy on 11/12/17.
|
||||
*/
|
||||
|
||||
public class AskSelectGameActivity extends BaseActivity {
|
||||
public class SelectGameFragment extends NormalFragment {
|
||||
|
||||
@BindView(R.id.ask_selectgame_rv)
|
||||
RecyclerView mRecyclerView;
|
||||
@BindView(R.id.ask_selectgame_rv_title)
|
||||
TextView mRvTitle;
|
||||
|
||||
|
||||
private AskSelectGameAdapter mAdapter;
|
||||
|
||||
private LinearLayoutManager mLayoutManager;
|
||||
private RelativeLayout.LayoutParams mParams;
|
||||
|
||||
public static Intent getIntent(Context context) {
|
||||
return new Intent(context, AskSelectGameActivity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_ask_selectgame;
|
||||
return R.layout.fragment_ask_selectgame;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
initTitle(getString(R.string.ask_selectgame_title));
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
initTitle(getString(R.string.title_select_game));
|
||||
|
||||
mAdapter = new AskSelectGameAdapter(getContext());
|
||||
mParams = (RelativeLayout.LayoutParams) mRvTitle.getLayoutParams();
|
||||
mLayoutManager = new LinearLayoutManager(this);
|
||||
mLayoutManager = new LinearLayoutManager(getContext());
|
||||
mRecyclerView.setLayoutManager(mLayoutManager);
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||
@ -74,4 +74,5 @@ public class AskSelectGameActivity extends BaseActivity {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.gh.gamecenter.ask.entity
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Created by khy on 11/12/17.
|
||||
*/
|
||||
class CommunitiesEntity {
|
||||
|
||||
@SerializedName("_id")
|
||||
var id: String? = null
|
||||
|
||||
var name: String? = null
|
||||
|
||||
var status: String? = null
|
||||
|
||||
var vote: Int = 0
|
||||
|
||||
var game: CommunitiesGameEntity? = null
|
||||
|
||||
var me: MeEntity? = null
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.gh.gamecenter.ask.entity
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Created by khy on 11/12/17.
|
||||
*/
|
||||
class CommunitiesGameEntity {
|
||||
|
||||
@SerializedName("_id")
|
||||
var id: String? = null
|
||||
|
||||
var name: String? = null
|
||||
|
||||
var icon: String? = null
|
||||
|
||||
}
|
||||
11
app/src/main/java/com/gh/gamecenter/ask/entity/MeEntity.kt
Normal file
11
app/src/main/java/com/gh/gamecenter/ask/entity/MeEntity.kt
Normal file
@ -0,0 +1,11 @@
|
||||
package com.gh.gamecenter.ask.entity
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Created by khy on 11/12/17.
|
||||
*/
|
||||
class MeEntity {
|
||||
@SerializedName("is_community_voted")
|
||||
var isCommunityVoted: String? = null
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package com.gh.gamecenter.questionsdetail;
|
||||
package com.gh.gamecenter.ask.questionsdetail;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.gh.gamecenter.questionsdetail;
|
||||
package com.gh.gamecenter.ask.questionsdetail;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
@ -12,13 +12,16 @@ import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.ReuseViewHolder;
|
||||
import com.gh.gamecenter.ask.AskItemViewHolder;
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by khy on 7/12/17.
|
||||
*/
|
||||
|
||||
public class QuestionsDetailAdapter extends BaseRecyclerAdapter {
|
||||
public class QuestionsDetailAdapter extends ListAdapter {
|
||||
|
||||
private OnListClickListener mListClickListener;
|
||||
|
||||
@ -27,6 +30,16 @@ public class QuestionsDetailAdapter extends BaseRecyclerAdapter {
|
||||
mListClickListener = listClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> void provideListData(List<T> listData) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadChange(LoadStatus status) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == 0) {
|
||||
@ -0,0 +1,69 @@
|
||||
package com.gh.gamecenter.ask.questionsdetail;
|
||||
|
||||
import android.arch.lifecycle.Lifecycle;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.gh.gamecenter.AskQuestionsDetailActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListFragment;
|
||||
import com.gh.gamecenter.entity.NewsEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
import rx.Observable;
|
||||
|
||||
/**
|
||||
* Created by khy on 7/12/17.
|
||||
*/
|
||||
|
||||
public class QuestionsDetailFragment extends ListFragment {
|
||||
|
||||
@BindView(R.id.questionsdetail_answer)
|
||||
RelativeLayout mAnswer;
|
||||
@BindView(R.id.questionsdetail_invite)
|
||||
RelativeLayout mInvite;
|
||||
|
||||
QuestionsDetailAdapter mAdapter;
|
||||
|
||||
|
||||
@Override
|
||||
protected ListAdapter provideListAdapter() {
|
||||
return mAdapter == null ? mAdapter = new QuestionsDetailAdapter(getContext(), this) : mAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_questionsdetail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
}
|
||||
|
||||
@OnClick({R.id.questionsdetail_answer, R.id.questionsdetail_invite})
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.questionsdetail_answer:
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
|
||||
((AskQuestionsDetailActivity) getActivity()).show(AskQuestionsDetailActivity.QUESTIONS_DETAIL_ANSWER);
|
||||
break;
|
||||
case R.id.questionsdetail_invite:
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
|
||||
((AskQuestionsDetailActivity) getActivity()).show(AskQuestionsDetailActivity.QUESTIONS_DETAIL_INVITE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Observable<List<NewsEntity>> provideDataObservable() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package com.gh.gamecenter.questionsdetail;
|
||||
package com.gh.gamecenter.ask.questionsdetail;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.gh.gamecenter.questionsdetail;
|
||||
package com.gh.gamecenter.ask.questionsdetail;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@ -9,7 +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.baselist.BaseListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
|
||||
import java.util.List;
|
||||
@ -18,7 +18,7 @@ import java.util.List;
|
||||
* Created by khy on 7/12/17.
|
||||
*/
|
||||
|
||||
public class QuestionsInviteAdapter extends BaseListAdapter {
|
||||
public class QuestionsInviteAdapter extends ListAdapter {
|
||||
|
||||
private OnListClickListener mListClickListener;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.gh.gamecenter.questionsdetail;
|
||||
package com.gh.gamecenter.ask.questionsdetail;
|
||||
|
||||
import com.gh.gamecenter.baselist.BaseListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListFragment;
|
||||
import com.gh.gamecenter.entity.NewsEntity;
|
||||
|
||||
@ -22,7 +22,7 @@ public class QuestionsInviteFragment extends ListFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BaseListAdapter provideListAdapter() {
|
||||
protected ListAdapter provideListAdapter() {
|
||||
return mAdapter == null ? mAdapter = new QuestionsInviteAdapter(getContext(), this) : mAdapter;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package com.gh.gamecenter.questionsdetail;
|
||||
package com.gh.gamecenter.ask.questionsdetail;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.gh.gamecenter.questionsdetail;
|
||||
package com.gh.gamecenter.ask.questionsdetail;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
@ -9,7 +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.baselist.BaseListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
import com.gh.gamecenter.entity.NewsEntity;
|
||||
|
||||
@ -19,7 +19,7 @@ import java.util.List;
|
||||
* Created by khy on 8/12/17.
|
||||
*/
|
||||
|
||||
public class AskSearchAdapter extends BaseListAdapter {
|
||||
public class AskSearchAdapter extends ListAdapter {
|
||||
|
||||
private OnListClickListener mListClickListener;
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ package com.gh.gamecenter.ask.search;
|
||||
import android.view.View;
|
||||
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.baselist.BaseListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListFragment;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
import com.gh.gamecenter.baselist.LoadType;
|
||||
@ -26,14 +26,14 @@ public class AskSearchFragment extends ListFragment {
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_ask_search;
|
||||
}
|
||||
|
||||
// android:windowSoftInputMode = "stateVisible|adjustResize|adjustPan"
|
||||
@Override
|
||||
public Observable<List<NewsEntity>> provideDataObservable() {
|
||||
return RetrofitManager.getInstance(getContext()).getApi().getZiXun(getListOffset());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BaseListAdapter provideListAdapter() {
|
||||
protected ListAdapter provideListAdapter() {
|
||||
return mAdapter == null ? mAdapter = new AskSearchAdapter(getContext(), this) : mAdapter;
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ import java.util.List;
|
||||
* Created by khy on 10/11/17.
|
||||
*/
|
||||
|
||||
public abstract class BaseListAdapter extends BaseRecyclerAdapter {
|
||||
public abstract class ListAdapter extends BaseRecyclerAdapter {
|
||||
|
||||
protected static final int FOOTER_ITEM_COUNT = 1;
|
||||
|
||||
@ -18,7 +18,7 @@ public abstract class BaseListAdapter extends BaseRecyclerAdapter {
|
||||
|
||||
protected boolean mIsNetworkError;
|
||||
|
||||
public BaseListAdapter(Context context) {
|
||||
public ListAdapter(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ public abstract class ListFragment<T> extends BaseFragment implements
|
||||
|
||||
protected ListViewModel mListViewModel;
|
||||
|
||||
protected abstract BaseListAdapter provideListAdapter();
|
||||
protected abstract ListAdapter provideListAdapter();
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@ -84,7 +84,7 @@ class UserRepository {
|
||||
mApiService = RetrofitManager.getInstance(context).getApi();
|
||||
mAppDatabase = database;
|
||||
mCachedId = PreferenceManager.getDefaultSharedPreferences(context).getString(Constants.LOGIN_TOKEN_ID, null);
|
||||
checkLogin();
|
||||
if (!TextUtils.isEmpty(mCachedId)) checkLogin();
|
||||
}
|
||||
|
||||
protected void checkLogin() {
|
||||
|
||||
@ -1,54 +0,0 @@
|
||||
package com.gh.gamecenter.questionsdetail;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.gh.base.fragment.BaseFragment;
|
||||
import com.gh.gamecenter.R;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
|
||||
/**
|
||||
* Created by khy on 7/12/17.
|
||||
*/
|
||||
|
||||
public class QuestionsDetailFragment extends BaseFragment {
|
||||
|
||||
@BindView(R.id.questionsdetail_rv)
|
||||
RecyclerView mRecyclerView;
|
||||
@BindView(R.id.questionsdetail_answer)
|
||||
RelativeLayout mAnswer;
|
||||
@BindView(R.id.questionsdetail_invite)
|
||||
RelativeLayout mInvite;
|
||||
|
||||
QuestionsDetailAdapter mAdapter;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_questionsdetail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mAdapter = new QuestionsDetailAdapter(getContext(), this);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
}
|
||||
|
||||
@OnClick({R.id.questionsdetail_answer, R.id.questionsdetail_invite})
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.questionsdetail_answer:
|
||||
break;
|
||||
case R.id.questionsdetail_invite:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user