From 1fe7c3ba86e0679da2c97e18012c88fd42577dc4 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Thu, 19 Apr 2018 10:50:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=AD=E5=BF=83=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/caches/build_file_checksums.ser | Bin 906 -> 906 bytes AppHome/build.gradle | 1 + .../jianrmg_v2/basemodel/Fragments/My.java | 94 ++++++++---------- .../basemodel/views/MainActivity.java | 2 +- UserModel/build.gradle | 16 ++- app/build.gradle | 1 + .../com/yutou/jianrmg_v2/Fragments/My.java | 76 ++++---------- .../com/yutou/jianrmg_v2/LoadingActivity.java | 19 ++-- .../com/yutou/jianrmg_v2/MainActivity.java | 2 +- 9 files changed, 88 insertions(+), 123 deletions(-) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index bfed3ba16955b595fa38c363a851c30e7a527742..8d922115bbf729290ed6d4a2ab54946f68c7b6db 100644 GIT binary patch delta 77 zcmV-T0J8sz2Z{%fnFG66BC(uI0TBGrZRR getItemData(){ - List 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; + + return baseFragmeneInerface.onCreateView(inflater, container, savedInstanceState); } + } diff --git a/BaseModel/src/main/java/com/yutou/jianrmg_v2/basemodel/views/MainActivity.java b/BaseModel/src/main/java/com/yutou/jianrmg_v2/basemodel/views/MainActivity.java index d4a197f..f41ab24 100644 --- a/BaseModel/src/main/java/com/yutou/jianrmg_v2/basemodel/views/MainActivity.java +++ b/BaseModel/src/main/java/com/yutou/jianrmg_v2/basemodel/views/MainActivity.java @@ -41,7 +41,7 @@ public class MainActivity extends AppCompatActivity { list.add(Home.init(this)); list.add(GameData.init(this)); list.add(MGList.init(this)); - list.add(My.init()); + list.add(My.init(this)); ViewPagerAdapter adapter=new ViewPagerAdapter(getSupportFragmentManager(),list); viewPager.setAdapter(adapter); diff --git a/UserModel/build.gradle b/UserModel/build.gradle index 0f6f2d4..5acffd0 100644 --- a/UserModel/build.gradle +++ b/UserModel/build.gradle @@ -1,18 +1,19 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 27 + compileSdkVersion 26 defaultConfig { minSdkVersion 21 - targetSdkVersion 27 + targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } buildTypes { @@ -27,8 +28,17 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:appcompat-v7:27.1.1' + implementation 'com.android.support:appcompat-v7:26.1.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' + + //图片流缓存 + implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' + //FastJson + implementation 'com.alibaba:fastjson:1.2.41' + //毛玻璃 + implementation 'jp.wasabeef:glide-transformations:3.0.0' + api project(path: ':BaseModel') + api project(path: ':ResModl') } diff --git a/app/build.gradle b/app/build.gradle index d38a4c6..8fea898 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -68,5 +68,6 @@ dependencies { api project(path: ':AppHome') api project(path: ':MgListModel') api project(path: ':ResModl') + api project(path: ':UserModel') } diff --git a/app/src/main/java/com/yutou/jianrmg_v2/Fragments/My.java b/app/src/main/java/com/yutou/jianrmg_v2/Fragments/My.java index 3750164..bc496d4 100644 --- a/app/src/main/java/com/yutou/jianrmg_v2/Fragments/My.java +++ b/app/src/main/java/com/yutou/jianrmg_v2/Fragments/My.java @@ -1,12 +1,16 @@ package com.yutou.jianrmg_v2.Fragments; +import android.app.Activity; +import android.content.Context; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; @@ -17,11 +21,13 @@ 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.R; +import com.yutou.jianrmg_v2.basemodel.Tools.Log; import com.yutou.jianrmg_v2.basemodel.Tools.Utils; 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; @@ -33,69 +39,29 @@ import static com.bumptech.glide.request.RequestOptions.bitmapTransform; public class My extends Fragment { public static My my; - public static My init(){ + private BaseFragmeneInerface baseFragmeneInerface; + public static My init(Activity activity){ if(my==null){ my=new My(); + my.baseFragmeneInerface.init(activity); } return my; } - private View view; - private User user; - private UUserdata udata; - private ImageLoader imageLoader; - - private TextView uname,item_title; - private ImageView icon,item_icon,image_top; - // private LinearLayout items; - private ListView myItems; + public My(){ + try { + this.baseFragmeneInerface = (BaseFragmeneInerface) AppData.plugsin.get("my.jar").loadClass("com.yutou.jianrmg_v2.mglistmodel.MainFragments").newInstance(); + } catch (Exception e) { + e.printStackTrace(); + Log.i("个人中心插件加载失败"); + baseFragmeneInerface =new com.jianrmg_v2.usermodel.MainFragments(); + } + } @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - if(view==null){ - view=LayoutInflater.from(getContext()).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(getContext()); - 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(this).load(udata.getImage()).apply(bitmapTransform(new BlurTransformation(25))).into(image_top); - }catch (Exception e){ - e.printStackTrace(); - } - myItems.setAdapter(new MyItemGridViewAdapter(getItemData(),getContext())); - } - private List getItemData(){ - List 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; + + return baseFragmeneInerface.onCreateView(inflater, container, savedInstanceState); } + } diff --git a/app/src/main/java/com/yutou/jianrmg_v2/LoadingActivity.java b/app/src/main/java/com/yutou/jianrmg_v2/LoadingActivity.java index fe77294..67e5f06 100644 --- a/app/src/main/java/com/yutou/jianrmg_v2/LoadingActivity.java +++ b/app/src/main/java/com/yutou/jianrmg_v2/LoadingActivity.java @@ -73,18 +73,18 @@ public class LoadingActivity extends AppCompatActivity { start(); } }catch (Exception e){ - + e.printStackTrace(); } } @Override public void httpError(Exception e) { - + e.printStackTrace(); } }); }catch (Exception e){ - + e.printStackTrace(); } } private void initData(){ @@ -114,17 +114,17 @@ public class LoadingActivity extends AppCompatActivity { } ready(1); }catch (Exception e){ - + e.printStackTrace(); } } @Override public void httpError(Exception e) { - + e.printStackTrace(); } }); }catch (Exception e){ - + e.printStackTrace(); } } private void initGamePackName(){ @@ -144,11 +144,11 @@ public class LoadingActivity extends AppCompatActivity { @Override public void httpError(Exception e) { - + e.printStackTrace(); } }); }catch (Exception e){ - + e.printStackTrace(); } } private void initUser(){ @@ -178,7 +178,7 @@ public class LoadingActivity extends AppCompatActivity { } }); }catch (Exception e){ - + e.printStackTrace(); } } @@ -244,6 +244,7 @@ public class LoadingActivity extends AppCompatActivity { private int readys=0; private void ready(int i){ readys+=i; + Log.i(readys+""); if(readys==3){ handler.postDelayed(new Runnable() { @Override diff --git a/app/src/main/java/com/yutou/jianrmg_v2/MainActivity.java b/app/src/main/java/com/yutou/jianrmg_v2/MainActivity.java index 72458a6..cc0934f 100644 --- a/app/src/main/java/com/yutou/jianrmg_v2/MainActivity.java +++ b/app/src/main/java/com/yutou/jianrmg_v2/MainActivity.java @@ -42,7 +42,7 @@ public class MainActivity extends AppCompatActivity { list.add(Home.init(this)); list.add(GameData.init(this)); list.add(MGList.init(this)); - list.add(My.init()); + list.add(My.init(this)); ViewPagerAdapter adapter=new ViewPagerAdapter(getSupportFragmentManager(),list); viewPager.setAdapter(adapter);