|
|
@ -1,11 +1,17 @@
|
|
|
|
package com.example.leudaemialikeme.Fragment;
|
|
|
|
package com.example.leudaemialikeme.Fragment;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.app.ActionBar;
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.util.DisplayMetrics;
|
|
|
|
import android.util.DisplayMetrics;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
|
|
|
|
import android.view.MotionEvent;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
|
|
|
|
import android.widget.Button;
|
|
|
|
import android.widget.HorizontalScrollView;
|
|
|
|
import android.widget.HorizontalScrollView;
|
|
|
|
|
|
|
|
import android.widget.ImageButton;
|
|
|
|
|
|
|
|
import android.widget.PopupWindow;
|
|
|
|
import android.widget.RadioButton;
|
|
|
|
import android.widget.RadioButton;
|
|
|
|
import android.widget.RadioGroup;
|
|
|
|
import android.widget.RadioGroup;
|
|
|
|
|
|
|
|
|
|
|
@ -13,6 +19,9 @@ import androidx.fragment.app.Fragment;
|
|
|
|
import androidx.fragment.app.FragmentManager;
|
|
|
|
import androidx.fragment.app.FragmentManager;
|
|
|
|
import androidx.viewpager.widget.ViewPager;
|
|
|
|
import androidx.viewpager.widget.ViewPager;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.example.leudaemialikeme.Activity.GoAnswerActivity;
|
|
|
|
|
|
|
|
import com.example.leudaemialikeme.Activity.SendInvitationActivity;
|
|
|
|
|
|
|
|
import com.example.leudaemialikeme.Activity.SendQuestionActivity;
|
|
|
|
import com.example.leudaemialikeme.Adapter.InvitationPageFragmentAdapter;
|
|
|
|
import com.example.leudaemialikeme.Adapter.InvitationPageFragmentAdapter;
|
|
|
|
import com.example.leudaemialikeme.R;
|
|
|
|
import com.example.leudaemialikeme.R;
|
|
|
|
|
|
|
|
|
|
|
@ -24,6 +33,11 @@ public class CommunityFragment extends Fragment implements ViewPager.OnPageChang
|
|
|
|
private HorizontalScrollView hvChannel=null; //单选按钮组可滚动动
|
|
|
|
private HorizontalScrollView hvChannel=null; //单选按钮组可滚动动
|
|
|
|
private String[] channelList = {"关注","全部","经验","扫雷","康复","科普","问答"}; //默认的内导航栏目
|
|
|
|
private String[] channelList = {"关注","全部","经验","扫雷","康复","科普","问答"}; //默认的内导航栏目
|
|
|
|
private InvitationPageFragmentAdapter adapter; //viewPager 的适配器
|
|
|
|
private InvitationPageFragmentAdapter adapter; //viewPager 的适配器
|
|
|
|
|
|
|
|
private PopupWindow popupWindow;
|
|
|
|
|
|
|
|
private ImageButton tab_add;
|
|
|
|
|
|
|
|
private Button bar_send_invitation;
|
|
|
|
|
|
|
|
private Button bar_send_question;
|
|
|
|
|
|
|
|
private Button bar_answer;
|
|
|
|
|
|
|
|
|
|
|
|
public CommunityFragment() {
|
|
|
|
public CommunityFragment() {
|
|
|
|
// Required empty public constructor
|
|
|
|
// Required empty public constructor
|
|
|
@ -34,6 +48,7 @@ public class CommunityFragment extends Fragment implements ViewPager.OnPageChang
|
|
|
|
Bundle savedInstanceState) {
|
|
|
|
Bundle savedInstanceState) {
|
|
|
|
if(view==null){
|
|
|
|
if(view==null){
|
|
|
|
view=inflater.inflate(R.layout.fragment_community, container, false);
|
|
|
|
view=inflater.inflate(R.layout.fragment_community, container, false);
|
|
|
|
|
|
|
|
tab_add = (ImageButton)view.findViewById(R.id.tab_add);
|
|
|
|
viewPager=(ViewPager)view.findViewById(R.id.vpNewsList);
|
|
|
|
viewPager=(ViewPager)view.findViewById(R.id.vpNewsList);
|
|
|
|
initViewPager(); //设置 ViewPager
|
|
|
|
initViewPager(); //设置 ViewPager
|
|
|
|
|
|
|
|
|
|
|
@ -49,6 +64,53 @@ public class CommunityFragment extends Fragment implements ViewPager.OnPageChang
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
tab_add.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
|
|
//获取自定义菜单的布局文件
|
|
|
|
|
|
|
|
View popupWindow_view=getLayoutInflater().inflate(R.layout.community_menu,null,false);
|
|
|
|
|
|
|
|
//创建popupWindow实例,设置菜单的宽度和高度
|
|
|
|
|
|
|
|
popupWindow = new PopupWindow(popupWindow_view, ActionBar.LayoutParams.WRAP_CONTENT,ActionBar.LayoutParams.WRAP_CONTENT,true);
|
|
|
|
|
|
|
|
//设置菜单显示在按钮的下面
|
|
|
|
|
|
|
|
popupWindow.showAsDropDown(view.findViewById(R.id.tab_add),0,0);
|
|
|
|
|
|
|
|
//单机其它位置隐藏菜单
|
|
|
|
|
|
|
|
popupWindow_view.setOnTouchListener(new View.OnTouchListener(){
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean onTouch(View v, MotionEvent event){
|
|
|
|
|
|
|
|
//如果菜单存在并且处于显示状态
|
|
|
|
|
|
|
|
if (popupWindow!=null&&popupWindow.isShowing()){
|
|
|
|
|
|
|
|
popupWindow.dismiss();//关闭菜单
|
|
|
|
|
|
|
|
popupWindow=null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
bar_send_invitation = (Button)popupWindow_view.findViewById(R.id.bar_send_invitation);
|
|
|
|
|
|
|
|
bar_send_question = (Button)popupWindow_view.findViewById(R.id.bar_send_question);
|
|
|
|
|
|
|
|
bar_answer = (Button)popupWindow_view.findViewById(R.id.bar_answer);
|
|
|
|
|
|
|
|
bar_send_invitation.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
|
|
Intent intent=new Intent(getActivity(), SendInvitationActivity.class);
|
|
|
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
bar_send_question.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
|
|
Intent intent=new Intent(getActivity(), SendQuestionActivity.class);
|
|
|
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
bar_answer.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
|
|
Intent intent=new Intent(getActivity(), GoAnswerActivity.class);
|
|
|
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return view;
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -104,4 +166,5 @@ public class CommunityFragment extends Fragment implements ViewPager.OnPageChang
|
|
|
|
int len=left+width/2-screenWidth/2;
|
|
|
|
int len=left+width/2-screenWidth/2;
|
|
|
|
hvChannel.smoothScrollTo(len,0);
|
|
|
|
hvChannel.smoothScrollTo(len,0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|