diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index bfed3ba..8d92211 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/AppHome/build.gradle b/AppHome/build.gradle index b126d01..a15486e 100644 --- a/AppHome/build.gradle +++ b/AppHome/build.gradle @@ -28,6 +28,7 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:26.1.0' + implementation 'com.android.support:recyclerview-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' diff --git a/BaseModel/src/main/java/com/yutou/jianrmg_v2/basemodel/Fragments/My.java b/BaseModel/src/main/java/com/yutou/jianrmg_v2/basemodel/Fragments/My.java index 88f14f7..13a9587 100644 --- a/BaseModel/src/main/java/com/yutou/jianrmg_v2/basemodel/Fragments/My.java +++ b/BaseModel/src/main/java/com/yutou/jianrmg_v2/basemodel/Fragments/My.java @@ -1,8 +1,11 @@ package com.yutou.jianrmg_v2.basemodel.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; @@ -21,12 +24,14 @@ 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; @@ -38,69 +43,50 @@ 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(); } return my; } - private View view; - private User user; - private UUserdata udata; - private ImageLoader imageLoader; + 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 BaseFragmeneInerface() { + private Context context; - 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) { + ViewGroup.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + TextView textView = new TextView(context); + textView.setLayoutParams(params); + textView.setGravity(Gravity.CENTER); + textView.setText("未加载插件,请尝试重启"); + return textView; + } + + @Override + public void setIntent() { + + } + }; + } + } @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/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);