1
This commit is contained in:
parent
1fe7c3ba86
commit
f4ce57882e
@ -0,0 +1,88 @@
|
||||
package com.jianrmg_v2.usermodel.Adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yutou.jianrmg_v2.basemodel.R;
|
||||
import com.yutou.jianrmg_v2.basemodel.Tools.Log;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MyItemGridViewAdapter extends BaseAdapter {
|
||||
public static class ItemData{
|
||||
private String title;
|
||||
private int imageUrl=-1;
|
||||
|
||||
public ItemData(int imageUrl, String title) {
|
||||
this.imageUrl = imageUrl;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public int getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
}
|
||||
private List<ItemData> list;
|
||||
private Context context;
|
||||
|
||||
public MyItemGridViewAdapter(List<ItemData> list, Context context) {
|
||||
this.list = list;
|
||||
this.context = context;
|
||||
Log.i("List Size",""+list.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int i) {
|
||||
return list.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int i, View view, ViewGroup viewGroup) {
|
||||
Item item=null;
|
||||
if(view==null){
|
||||
item=new Item();
|
||||
view= LayoutInflater.from(context).inflate(R.layout.item_my_gridview,null);
|
||||
item.imageView=view.findViewById(R.id.image);
|
||||
item.title=view.findViewById(R.id.title);
|
||||
view.setTag(item);
|
||||
}else{
|
||||
item= (Item) view.getTag();
|
||||
}
|
||||
if(list.get(i).imageUrl!=-1){
|
||||
item.imageView.setImageResource(list.get(i).getImageUrl());
|
||||
}
|
||||
item.title.setText(list.get(i).title);
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Log.i("点击"+list.get(i).getTitle());
|
||||
}
|
||||
});
|
||||
return view;
|
||||
}
|
||||
|
||||
private class Item{
|
||||
private ImageView imageView;
|
||||
private TextView title;
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package com.jianrmg_v2.usermodel;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.jianrmg_v2.usermodel.Adapters.MyItemGridViewAdapter;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.yutou.jianrmg_v2.basemodel.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.basemodel.Data.UUserdata;
|
||||
import com.yutou.jianrmg_v2.basemodel.Data.User;
|
||||
import com.yutou.jianrmg_v2.basemodel.Tools.Utils;
|
||||
import com.yutou.jianrmg_v2.resmodl.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import Interfaces.BaseFragmeneInerface;
|
||||
import jp.wasabeef.glide.transformations.BlurTransformation;
|
||||
|
||||
import static com.bumptech.glide.request.RequestOptions.bitmapTransform;
|
||||
|
||||
public class MainFragments implements BaseFragmeneInerface {
|
||||
private Context context;
|
||||
private ImageLoader imageLoader;
|
||||
private View view;
|
||||
private User user;
|
||||
private UUserdata udata;
|
||||
private TextView uname,item_title;
|
||||
private ImageView icon,item_icon,image_top;
|
||||
// private LinearLayout items;
|
||||
private ListView myItems;
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
this.context=context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
if(view==null){
|
||||
view=LayoutInflater.from(context).inflate(R.layout.fragment_my,null);
|
||||
uname=view.findViewById(R.id.uname);
|
||||
icon=view.findViewById(R.id.icon);
|
||||
item_title=view.findViewById(R.id.item_title);
|
||||
item_icon=view.findViewById(R.id.item_icon);
|
||||
image_top=view.findViewById(R.id.image_top);
|
||||
// items=view.findViewById(R.id.items);
|
||||
myItems=view.findViewById(R.id._my_items);
|
||||
}
|
||||
imageLoader= Utils.initImageLoader(context);
|
||||
initData();
|
||||
return view;
|
||||
}
|
||||
private void initData(){
|
||||
user= AppData.user;
|
||||
udata=AppData.userdata;
|
||||
if(udata==null)
|
||||
udata=new UUserdata();
|
||||
udata.setImage("https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=1209476926,1108056910&fm=58");
|
||||
if(user==null||user.getId()<1){
|
||||
uname.setText("未登录");
|
||||
icon.setImageResource(R.mipmap.ic_launcher);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
uname.setText(user.getName());
|
||||
imageLoader.displayImage(udata.getImage(),icon);
|
||||
Glide.with(context).load(udata.getImage()).apply(bitmapTransform(new BlurTransformation(25))).into(image_top);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
myItems.setAdapter(new MyItemGridViewAdapter(getItemData(),context));
|
||||
}
|
||||
private List<MyItemGridViewAdapter.ItemData> getItemData(){
|
||||
List<MyItemGridViewAdapter.ItemData> list=new ArrayList<>();
|
||||
list.add(new MyItemGridViewAdapter.ItemData(-1,"下载中心"));
|
||||
list.add(new MyItemGridViewAdapter.ItemData(-1,"收藏夹"));
|
||||
list.add(new MyItemGridViewAdapter.ItemData(-1,"问题/建议"));
|
||||
list.add(new MyItemGridViewAdapter.ItemData(-1,"设置"));
|
||||
/* list.add(new MyItemGridViewAdapter.ItemData(-1,""));
|
||||
list.add(new MyItemGridViewAdapter.ItemData(-1,""));
|
||||
list.add(new MyItemGridViewAdapter.ItemData(-1,""));
|
||||
list.add(new MyItemGridViewAdapter.ItemData(-1,""));*/
|
||||
return list;
|
||||
}
|
||||
@Override
|
||||
public void setIntent() {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user