消息
This commit is contained in:
@@ -33,6 +33,7 @@ public ProgressDialog progressDialog;
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(getLayoutId(), null);
|
View view = inflater.inflate(getLayoutId(), null);
|
||||||
|
|
||||||
mDataBinding = DataBindingUtil.bind(view);
|
mDataBinding = DataBindingUtil.bind(view);
|
||||||
onCreateVew(inflater, savedInstanceState);
|
onCreateVew(inflater, savedInstanceState);
|
||||||
progressDialog=new ProgressDialog(getActivity());
|
progressDialog=new ProgressDialog(getActivity());
|
||||||
|
|||||||
@@ -7,39 +7,21 @@ import android.os.Bundle;
|
|||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.RadioGroup;
|
import android.widget.RadioGroup;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.internal.LinkedTreeMap;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import com.gyf.immersionbar.ImmersionBar;
|
import com.gyf.immersionbar.ImmersionBar;
|
||||||
import com.selectpicker.OptionsPopupWindow;
|
|
||||||
import com.sl.house_property.cart.CartFragment;
|
import com.sl.house_property.cart.CartFragment;
|
||||||
import com.sl.house_property.databinding.ActivityMainTabBinding;
|
import com.sl.house_property.databinding.ActivityMainTabBinding;
|
||||||
import com.sl.house_property.discovery.DiscoveryFragment;
|
import com.sl.house_property.discovery.DiscoveryFragment;
|
||||||
import com.sl.house_property.discovery.LikeFragment;
|
import com.sl.house_property.message.MessageFragment;
|
||||||
import com.sl.house_property.user.MyPropertyActivity;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import entity.MyHomequEntity;
|
|
||||||
import entity.RegisterUser;
|
|
||||||
import entity.SimpleEntity;
|
|
||||||
import http.ApiConfig;
|
|
||||||
import my_loader.Loader;
|
import my_loader.Loader;
|
||||||
import my_loader.Resultcode;
|
|
||||||
import rx.Subscription;
|
|
||||||
import rx.functions.Action1;
|
|
||||||
import tools.Config;
|
import tools.Config;
|
||||||
import utils.Md5;
|
|
||||||
import utils.SPUtils;
|
|
||||||
|
|
||||||
public class MainTabActivity extends BaseActivity<ActivityMainTabBinding>
|
public class MainTabActivity extends BaseActivity<ActivityMainTabBinding>
|
||||||
implements View.OnClickListener,
|
implements View.OnClickListener,
|
||||||
@@ -64,6 +46,7 @@ public class MainTabActivity extends BaseActivity<ActivityMainTabBinding>
|
|||||||
private Main3Fragment fragment2;
|
private Main3Fragment fragment2;
|
||||||
private CartFragment fragment3;
|
private CartFragment fragment3;
|
||||||
private Main4Fragment fragment4;
|
private Main4Fragment fragment4;
|
||||||
|
private MessageFragment messageFragment;
|
||||||
// private LikeFragment likeFragment;
|
// private LikeFragment likeFragment;
|
||||||
private Fragment currentFragment;
|
private Fragment currentFragment;
|
||||||
|
|
||||||
@@ -248,14 +231,14 @@ public class MainTabActivity extends BaseActivity<ActivityMainTabBinding>
|
|||||||
break;
|
break;
|
||||||
case R.id.button2:
|
case R.id.button2:
|
||||||
|
|
||||||
if (fragment2 == null) {
|
if (messageFragment == null) {
|
||||||
fragment2 = Main3Fragment.newInstance("", "");
|
messageFragment = MessageFragment.newInstance();
|
||||||
fragmentTransaction.add(R.id.mycontent, fragment2, "fragment2");
|
fragmentTransaction.add(R.id.mycontent, messageFragment, "fragment2");
|
||||||
} else {
|
} else {
|
||||||
fragmentTransaction.show(fragment2);
|
fragmentTransaction.show(messageFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentFragment = fragment2;
|
currentFragment = messageFragment;
|
||||||
break;
|
break;
|
||||||
case R.id.button3:
|
case R.id.button3:
|
||||||
// mDataBinding.getRoot().setBackground(getResources().getDrawable(R.drawable.background_slowly));
|
// mDataBinding.getRoot().setBackground(getResources().getDrawable(R.drawable.background_slowly));
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.sl.house_property.message;
|
||||||
|
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
|
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||||
|
import com.chad.library.adapter.base.BaseViewHolder;
|
||||||
|
import com.sl.house_property.R;
|
||||||
|
|
||||||
|
public class MessageAdapter extends BaseQuickAdapter<MessageEntity.StoreInfo, BaseViewHolder> {
|
||||||
|
public MessageAdapter() {
|
||||||
|
super(R.layout.item_message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void convert(BaseViewHolder baseViewHolder, MessageEntity.StoreInfo messageEntity) {
|
||||||
|
Glide.with(mContext).load(messageEntity.getImg()).apply(new RequestOptions().circleCrop())
|
||||||
|
.into(baseViewHolder.itemView.<ImageView>findViewById(R.id.iv));
|
||||||
|
baseViewHolder.setText(R.id.tv_name,messageEntity.getStore_name());
|
||||||
|
baseViewHolder.setText(R.id.tv_title,messageEntity.getTitle());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package com.sl.house_property.message;
|
||||||
|
|
||||||
|
import android.support.annotation.Keep;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@Keep
|
||||||
|
public class MessageEntity {
|
||||||
|
private ArrayList<StoreInfo> storeInfo;
|
||||||
|
private String userid;
|
||||||
|
|
||||||
|
public ArrayList<StoreInfo> getStoreInfo() {
|
||||||
|
return storeInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStoreInfo(ArrayList<StoreInfo> storeInfo) {
|
||||||
|
this.storeInfo = storeInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserid() {
|
||||||
|
return userid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserid(String userid) {
|
||||||
|
this.userid = userid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class StoreInfo{
|
||||||
|
private String title;
|
||||||
|
private String img;
|
||||||
|
private String store_name;
|
||||||
|
private String url;
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImg() {
|
||||||
|
return img;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImg(String img) {
|
||||||
|
this.img = img;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStore_name() {
|
||||||
|
return store_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStore_name(String store_name) {
|
||||||
|
this.store_name = store_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
package com.sl.house_property.message;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.internal.LinkedTreeMap;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.sl.house_property.R;
|
||||||
|
import com.sl.house_property.WebActivitytwo;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import entity.RegisterUser;
|
||||||
|
import http.ApiConfig;
|
||||||
|
import my_loader.Loader;
|
||||||
|
import my_loader.Resultcode;
|
||||||
|
import rx.functions.Action1;
|
||||||
|
import tools.Config;
|
||||||
|
import utils.Md5;
|
||||||
|
|
||||||
|
public class MessageFragment extends Fragment {
|
||||||
|
// private int pageIndex = 0;
|
||||||
|
private MessageAdapter adapter = null;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.fragment_message, null);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MessageFragment newInstance() {
|
||||||
|
MessageFragment fragment = new MessageFragment();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
|
||||||
|
fragment.setArguments(args);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
RecyclerView rv = view.findViewById(R.id.rv);
|
||||||
|
adapter = new MessageAdapter();
|
||||||
|
rv.setAdapter(adapter);
|
||||||
|
rv.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(BaseQuickAdapter baseQuickAdapter, View view, int i) {
|
||||||
|
WebActivitytwo.runActivity(getContext(), adapter.getData().get(i).getTitle(), adapter.getData().get(i).getUrl());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getData() {
|
||||||
|
RegisterUser user =
|
||||||
|
Config.getInstance(getContext()).getUser();
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
if (user != null) {
|
||||||
|
map.put("userid", user.getUserid());
|
||||||
|
} else {
|
||||||
|
map.put("userid", 0 + "");
|
||||||
|
}
|
||||||
|
map.put("app", "Store");
|
||||||
|
map.put("class", "GetMsgList");
|
||||||
|
map.put("sign", Md5.md5("Store" + "GetMsgList" + Md5.secret));
|
||||||
|
Loader mGankLoader = new Loader();
|
||||||
|
mGankLoader.getMovie(ApiConfig.BASE_URL, map).subscribe(new Action1<Resultcode>() {
|
||||||
|
@Override
|
||||||
|
public void call(Resultcode resultcode) {
|
||||||
|
if (!(resultcode.status == 0)) {
|
||||||
|
// getActivity().setToast(1, resultcode.msg);
|
||||||
|
Toast.makeText(getContext(), resultcode.msg, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
Gson gs = new Gson();
|
||||||
|
LinkedTreeMap adta = (LinkedTreeMap) resultcode.data;
|
||||||
|
String s = gs.toJson(adta);
|
||||||
|
Log.e("json", s);
|
||||||
|
|
||||||
|
|
||||||
|
MessageEntity messageEntity = gs.fromJson(s, MessageEntity.class);
|
||||||
|
|
||||||
|
adapter.setNewData(messageEntity.getStoreInfo());
|
||||||
|
}
|
||||||
|
}, new Action1<Throwable>() {
|
||||||
|
@Override
|
||||||
|
public void call(Throwable throwable) {
|
||||||
|
throwable.fillInStackTrace();
|
||||||
|
Toast.makeText(getContext(), getString(R.string.getdatafailure), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -63,6 +63,17 @@
|
|||||||
android:text="@string/news"
|
android:text="@string/news"
|
||||||
android:textColor="@color/radiobuttoncolor" />
|
android:textColor="@color/radiobuttoncolor" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/button2"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:button="@null"
|
||||||
|
android:drawableTop="@drawable/main_bottom_3"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="消息"
|
||||||
|
android:textColor="@color/radiobuttoncolor" />
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/button1"
|
android:id="@+id/button1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -75,7 +86,6 @@
|
|||||||
android:textColor="@color/radiobuttoncolor" />
|
android:textColor="@color/radiobuttoncolor" />
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:visibility="gone"
|
|
||||||
android:id="@+id/like"
|
android:id="@+id/like"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
@@ -84,10 +94,10 @@
|
|||||||
android:drawableTop="@drawable/main_bottom_like"
|
android:drawableTop="@drawable/main_bottom_like"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="点赞"
|
android:text="点赞"
|
||||||
android:textColor="@color/radiobuttoncolor" />
|
android:textColor="@color/radiobuttoncolor"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:visibility="gone"
|
|
||||||
android:id="@+id/button3"
|
android:id="@+id/button3"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
@@ -96,19 +106,20 @@
|
|||||||
android:drawableTop="@drawable/main_bottom_2"
|
android:drawableTop="@drawable/main_bottom_2"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="购物车"
|
android:text="购物车"
|
||||||
android:textColor="@color/radiobuttoncolor" />
|
|
||||||
|
|
||||||
<RadioButton
|
|
||||||
android:id="@+id/button2"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:button="@null"
|
|
||||||
android:drawableTop="@drawable/main_bottom_3"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/news3"
|
|
||||||
android:textColor="@color/radiobuttoncolor"
|
android:textColor="@color/radiobuttoncolor"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
<!--
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/button2"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:button="@null"
|
||||||
|
android:drawableTop="@drawable/main_bottom_3"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/news3"
|
||||||
|
android:textColor="@color/radiobuttoncolor"
|
||||||
|
android:visibility="gone" />-->
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/button4"
|
android:id="@+id/button4"
|
||||||
|
|||||||
51
app/src/main/res/layout/fragment_message.xml
Normal file
51
app/src/main/res/layout/fragment_message.xml
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?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"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/ll"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="45dp"
|
||||||
|
android:layout_marginTop="@dimen/mystatusbar">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="消息"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="16sp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<com.scwang.smartrefresh.layout.SmartRefreshLayout
|
||||||
|
android:id="@+id/sr"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@color/white"
|
||||||
|
app:srlEnableLoadMore="true"
|
||||||
|
app:srlDisableContentWhenLoading="true">
|
||||||
|
|
||||||
|
<com.scwang.smartrefresh.layout.header.ClassicsHeader
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<android.support.v7.widget.RecyclerView
|
||||||
|
android:id="@+id/rv"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<com.scwang.smartrefresh.layout.footer.ClassicsFooter
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
|
||||||
|
</LinearLayout>
|
||||||
52
app/src/main/res/layout/item_message.xml
Normal file
52
app/src/main/res/layout/item_message.xml
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
|
||||||
|
android:layout_height="60dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv"
|
||||||
|
android:layout_width="44dp"
|
||||||
|
android:layout_height="44dp"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:src="@color/red" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_toRightOf="@id/iv">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:lines="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="#333333"
|
||||||
|
android:text="哈哈哈" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_title"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="#999999"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:lines="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:text="哈哈哈哈哈" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:background="#b2b2b2" />
|
||||||
|
</RelativeLayout>
|
||||||
Reference in New Issue
Block a user