init
This commit is contained in:
31
app/src/main/java/Interfaces/BaseActivityInterface.java
Normal file
31
app/src/main/java/Interfaces/BaseActivityInterface.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package Interfaces;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
|
||||
/**
|
||||
* Created by 58381 on 2018/2/27.
|
||||
*/
|
||||
|
||||
public interface BaseActivityInterface {
|
||||
void onCreate(Bundle savedInstanceState, LinearLayout layout, Context context, Intent intent);
|
||||
void onRestart();
|
||||
void onResume();
|
||||
void onPause();
|
||||
void onDestroy();
|
||||
void getIntent(Intent intent);
|
||||
boolean onKeyDown(int keyCode, KeyEvent event);
|
||||
boolean onKeyUp(int keyCode, KeyEvent event);
|
||||
boolean onTouchEvent(MotionEvent event);
|
||||
Data getData();
|
||||
class Data{
|
||||
private String type;
|
||||
private String url;
|
||||
|
||||
}
|
||||
}
|
||||
15
app/src/main/java/Interfaces/BaseFragmeneInerface.java
Normal file
15
app/src/main/java/Interfaces/BaseFragmeneInerface.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package Interfaces;
|
||||
|
||||
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;
|
||||
|
||||
public interface BaseFragmeneInerface {
|
||||
void init(Context context);
|
||||
View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState);
|
||||
void setIntent();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.yutou.jianrmg_v2.Adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.yutou.jianrmg_v2.R;
|
||||
import com.yutou.jianrmg_v2.basemodel.Data.MAppHome;
|
||||
import com.yutou.jianrmg_v2.basemodel.Tools.Log;
|
||||
import com.yutou.jianrmg_v2.basemodel.Tools.Utils;
|
||||
import com.yutou.jianrmg_v2.basemodel.views.WebActivity;
|
||||
|
||||
|
||||
import cn.lemon.view.adapter.BaseViewHolder;
|
||||
import cn.lemon.view.adapter.RecyclerAdapter;
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* Created by 58381 on 2018/1/23.
|
||||
*/
|
||||
|
||||
public class HomeRecyclerAdapter extends RecyclerAdapter<MAppHome> {
|
||||
private ImageLoader imageLoader;
|
||||
|
||||
public HomeRecyclerAdapter(Context context) {
|
||||
super(context);
|
||||
imageLoader = Utils.initImageLoader(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseViewHolder<MAppHome> onCreateBaseViewHolder(ViewGroup parent, int viewType) {
|
||||
View view=new View(getContext());
|
||||
Log.i("首页数据",getData().size()+"");
|
||||
return new CardRecordHolder(parent, R.layout.item_home);
|
||||
}
|
||||
|
||||
private class CardRecordHolder extends BaseViewHolder<MAppHome> {
|
||||
private ImageView icon;
|
||||
private TextView name;
|
||||
|
||||
|
||||
public CardRecordHolder(ViewGroup view,int layoutId) {
|
||||
super(view,layoutId);
|
||||
icon = findViewById(R.id.image);
|
||||
name = findViewById(R.id.title);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(MAppHome data) {
|
||||
super.setData(data);
|
||||
Log.i("首页收据", JSON.toJSONString(data));
|
||||
if (data.getIcon() != null && "null".equals(data.getIcon()))
|
||||
imageLoader.displayImage(data.getIcon(), icon);
|
||||
name.setText(data.getName() + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemViewClick(MAppHome data) {
|
||||
super.onItemViewClick(data);
|
||||
if (data.getUrl() != null && data.getUrl().contains("webhttp")) {
|
||||
Intent intent = new Intent(getContext(),WebActivity.class);
|
||||
// intent.setAction(Intent.ACTION_VIEW);
|
||||
// intent.setData(Uri.parse(data.getUrl()));
|
||||
intent.putExtra("url", data.getUrl().replace("webhttp", "http"));
|
||||
getContext().startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
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.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yutou.jianrmg_v2.basemodel.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.basemodel.Tools.Log;
|
||||
import com.yutou.jianrmg_v2.basemodel.services.DownloadService;
|
||||
import com.yutou.jianrmg_v2.gamedatamodel.MainFragmene;
|
||||
|
||||
import Interfaces.BaseFragmeneInerface;
|
||||
|
||||
|
||||
/**
|
||||
* Created by 58381 on 2018/1/21.
|
||||
*/
|
||||
|
||||
public class GameData extends Fragment {
|
||||
private static GameData gameData;
|
||||
private DownloadService service;
|
||||
private Activity activity;
|
||||
private BaseFragmeneInerface baseFragmene;
|
||||
|
||||
public static GameData init(Activity activity){
|
||||
if(gameData==null){
|
||||
gameData=new GameData();
|
||||
gameData.baseFragmene.init(activity);
|
||||
}
|
||||
return gameData;
|
||||
}
|
||||
public GameData(){
|
||||
try {
|
||||
baseFragmene= (BaseFragmeneInerface) AppData.plugsin.get("rx.jar").loadClass("com.yutou.jianrmg_v2.gamedatamodel.MainFragmene").newInstance();
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
Log.i("加载数据模块失败");
|
||||
baseFragmene=new MainFragmene();
|
||||
}
|
||||
}
|
||||
|
||||
private void setActivity(Activity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@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(getContext());
|
||||
textView.setLayoutParams(params);
|
||||
textView.setGravity(Gravity.CENTER);
|
||||
textView.setText("Hello World");
|
||||
return textView;*/
|
||||
return baseFragmene.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
}
|
||||
61
app/src/main/java/com/yutou/jianrmg_v2/Fragments/Home.java
Normal file
61
app/src/main/java/com/yutou/jianrmg_v2/Fragments/Home.java
Normal file
@@ -0,0 +1,61 @@
|
||||
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.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
import com.yutou.jianrmg_v2.basemodel.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.basemodel.Tools.Log;
|
||||
import com.yutou.jianrmg_v2.apphome.MainFragmene;
|
||||
|
||||
import Interfaces.BaseFragmeneInerface;
|
||||
|
||||
/**
|
||||
* Created by 58381 on 2018/1/20.
|
||||
*/
|
||||
|
||||
public class Home extends Fragment {
|
||||
private static Home home;
|
||||
|
||||
|
||||
private BaseFragmeneInerface baseFragmene;
|
||||
|
||||
public static Home init(Activity activity){
|
||||
Toast.makeText(activity,"默认主页",Toast.LENGTH_LONG).show();
|
||||
if(home==null){
|
||||
home=new Home();
|
||||
home.baseFragmene.init(activity);
|
||||
}
|
||||
return home;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Home(){
|
||||
try {
|
||||
baseFragmene= (BaseFragmeneInerface) AppData.plugsin.get("home.jar").loadClass("com.yutou.jianrmg_v2.apphome.MainFragmene").newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.i("热插件加载失败,启用默认");
|
||||
baseFragmene=new MainFragmene();
|
||||
}
|
||||
baseFragmene.init(getContext());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return baseFragmene.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
|
||||
}
|
||||
53
app/src/main/java/com/yutou/jianrmg_v2/Fragments/MGList.java
Normal file
53
app/src/main/java/com/yutou/jianrmg_v2/Fragments/MGList.java
Normal file
@@ -0,0 +1,53 @@
|
||||
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.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yutou.jianrmg_v2.basemodel.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.basemodel.Tools.Log;
|
||||
import com.yutou.jianrmg_v2.mglistmodel.MainFragments;
|
||||
|
||||
import Interfaces.BaseFragmeneInerface;
|
||||
|
||||
|
||||
/**
|
||||
* Created by 58381 on 2018/1/23.
|
||||
*/
|
||||
|
||||
public class MGList extends Fragment {
|
||||
private static MGList modView;
|
||||
private BaseFragmeneInerface baseFragmeneInerface;
|
||||
|
||||
public static MGList init(Activity activity) {
|
||||
if (modView == null) {
|
||||
modView = new MGList();
|
||||
modView.baseFragmeneInerface.init(activity);
|
||||
}
|
||||
return modView;
|
||||
}
|
||||
|
||||
public MGList() {
|
||||
try {
|
||||
this.baseFragmeneInerface = (BaseFragmeneInerface) AppData.plugsin.get("mglist.jar").loadClass("com.yutou.jianrmg_v2.mglistmodel.MainFragments").newInstance();
|
||||
} catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
Log.i("魔改列表插件加载失败");
|
||||
baseFragmeneInerface = new MainFragments();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return baseFragmeneInerface.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
}
|
||||
101
app/src/main/java/com/yutou/jianrmg_v2/Fragments/My.java
Normal file
101
app/src/main/java/com/yutou/jianrmg_v2/Fragments/My.java
Normal file
@@ -0,0 +1,101 @@
|
||||
package com.yutou.jianrmg_v2.Fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
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.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.yutou.jianrmg_v2.basemodel.Adapters.MyItemGridViewAdapter;
|
||||
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.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import jp.wasabeef.glide.transformations.BlurTransformation;
|
||||
|
||||
import static com.bumptech.glide.request.RequestOptions.bitmapTransform;
|
||||
|
||||
|
||||
/**
|
||||
* Created by 58381 on 2018/2/22.
|
||||
*/
|
||||
|
||||
public class My extends Fragment {
|
||||
public static My my;
|
||||
public static My init(){
|
||||
if(my==null){
|
||||
my=new My();
|
||||
}
|
||||
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;
|
||||
|
||||
@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<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;
|
||||
}
|
||||
}
|
||||
261
app/src/main/java/com/yutou/jianrmg_v2/LoadingActivity.java
Normal file
261
app/src/main/java/com/yutou/jianrmg_v2/LoadingActivity.java
Normal file
@@ -0,0 +1,261 @@
|
||||
package com.yutou.jianrmg_v2;
|
||||
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RemoteViews;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yutou.jianrmg_v2.basemodel.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.basemodel.Data.MGamePackname;
|
||||
import com.yutou.jianrmg_v2.basemodel.Data.SConfig;
|
||||
import com.yutou.jianrmg_v2.basemodel.Data.User;
|
||||
import com.yutou.jianrmg_v2.basemodel.Interfaces.HttpInterface;
|
||||
import com.yutou.jianrmg_v2.basemodel.Network.HttpApi;
|
||||
import com.yutou.jianrmg_v2.basemodel.Network.HttpUtils;
|
||||
import com.yutou.jianrmg_v2.basemodel.R;
|
||||
import com.yutou.jianrmg_v2.basemodel.Tools.ConfigUtils;
|
||||
import com.yutou.jianrmg_v2.basemodel.Tools.Log;
|
||||
import com.yutou.jianrmg_v2.basemodel.Tools.Utils;
|
||||
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* Created by 58381 on 2018/1/18.
|
||||
*/
|
||||
|
||||
public class LoadingActivity extends AppCompatActivity {
|
||||
private LinearLayout loginLayout;
|
||||
private Button login,reg;
|
||||
private TextView notlogin,uname,password;
|
||||
private ImageView icon;
|
||||
private Handler handler;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_loading);
|
||||
Utils.setImmersion(this);
|
||||
handler=new Handler();
|
||||
initViews();
|
||||
initData();
|
||||
}
|
||||
private void login(String name, String pass){
|
||||
try{
|
||||
JSONObject json=new JSONObject();
|
||||
json.put("uname",name);
|
||||
json.put("pass",pass);
|
||||
HttpUtils.post(HttpApi.HOME_URL + HttpApi.USER_LOGIN, json, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
try{
|
||||
JSONObject json=new JSONObject(string);
|
||||
if(json.getInt("code")==100){
|
||||
AppData.user=JSON.parseObject(json.getJSONObject("data").toString(),User.class);
|
||||
AppData.Token=json.getString("token");
|
||||
ConfigUtils.init().save(ConfigUtils.token,AppData.Token);
|
||||
ConfigUtils.init().save(ConfigUtils.uid,AppData.user.getId());
|
||||
start();
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
private void initData(){
|
||||
/* if(RootUtils.su()) {
|
||||
RootUtils root = RootUtils.init(this);
|
||||
root.exec("cp /sdcard/jianRMG/1/aaa.txt /data/data/com.huanmeng.zhanjian2/");
|
||||
root.exec("cp /sdcard/jianRMG/1/aaa.txt /data/data/com.huanmeng.zhanjian2/files/");
|
||||
root.exec("mkdir /data/data/com.huanmeng.zhanjian2/files/bbb/");
|
||||
}else{
|
||||
Log.i("获取ROOT失败");
|
||||
}*/
|
||||
|
||||
initGamePackName();
|
||||
initConfig();
|
||||
initUser();
|
||||
|
||||
}
|
||||
private void initConfig(){
|
||||
try{
|
||||
HttpUtils.get(HttpApi.HOME_URL + HttpApi.MG_CONFIG, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
try {
|
||||
JSONObject json=new JSONObject(string);
|
||||
if(json!=null&&json.getInt("code")==100){
|
||||
AppData.appConfig=JSON.parseObject(json.getJSONObject("data").toString(), SConfig.class);
|
||||
}
|
||||
ready(1);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
private void initGamePackName(){
|
||||
try{
|
||||
HttpUtils.get(HttpApi.HOME_URL + HttpApi.MOD_GAME_PACKNAME, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
try {
|
||||
Log.i(HttpApi.MOD_GAME_PACKNAME,string);
|
||||
JSONObject json=new JSONObject(string);
|
||||
AppData.packnames= JSON.parseArray(json.getJSONArray("data").toString(), MGamePackname.class);
|
||||
ready(1);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
private void initUser(){
|
||||
try {
|
||||
JSONObject json=new JSONObject();
|
||||
json.put("token",AppData.Token);
|
||||
json.put("uid",AppData.user.getId());
|
||||
HttpUtils.post(HttpApi.HOME_URL + HttpApi.USER_TEST, json, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
try{
|
||||
JSONObject json=new JSONObject(string);
|
||||
if(json.getInt("code")==100){
|
||||
JSONObject data=json.getJSONObject("data").getJSONObject("data");
|
||||
AppData.user=JSON.parseObject(data.getJSONObject("user").toString(),User.class);
|
||||
ConfigUtils.init().save(ConfigUtils.collection,data.getJSONArray("collection"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
ready(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
ready(1);
|
||||
}
|
||||
});
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
private void initViews(){
|
||||
loginLayout=findViewById(R.id.loginLayout);
|
||||
login=findViewById(R.id.login);
|
||||
notlogin=findViewById(R.id.notlogin);
|
||||
icon=findViewById(R.id.icon);
|
||||
uname=findViewById(R.id.uname);
|
||||
password=findViewById(R.id.password);
|
||||
|
||||
notlogin.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
start();
|
||||
}
|
||||
});
|
||||
login.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String name=uname.getText().toString();
|
||||
String pass=password.getText().toString();
|
||||
if(Utils.testStringIsNull(name,pass)){
|
||||
Utils.toast(LoadingActivity.this,"账号/密码 不能为空");
|
||||
return;
|
||||
}
|
||||
login(name,pass);
|
||||
}
|
||||
});
|
||||
}
|
||||
public void start(){
|
||||
Intent intent=new Intent(LoadingActivity.this,MainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
private void showLogin(){
|
||||
Animation iconAnim= AnimationUtils.loadAnimation(this,R.anim.loading_icon);
|
||||
Animation loginAnim=AnimationUtils.loadAnimation(this,R.anim.loading_login);
|
||||
iconAnim.setAnimationListener(new MyAnimListener());
|
||||
loginAnim.setAnimationListener(new MyAnimListener());
|
||||
icon.startAnimation(iconAnim);
|
||||
loginLayout.setAlpha(0f);
|
||||
loginLayout.setVisibility(View.VISIBLE);
|
||||
loginLayout.startAnimation(loginAnim);
|
||||
|
||||
}
|
||||
private class MyAnimListener implements Animation.AnimationListener{
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
loginLayout.setAlpha(1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
|
||||
}
|
||||
}
|
||||
private int readys=0;
|
||||
private void ready(int i){
|
||||
readys+=i;
|
||||
if(readys==3){
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(Utils.testStringIsNull(AppData.Token)){
|
||||
showLogin();
|
||||
}else{
|
||||
start();
|
||||
}
|
||||
|
||||
}
|
||||
},0);
|
||||
}
|
||||
}
|
||||
}
|
||||
73
app/src/main/java/com/yutou/jianrmg_v2/MainActivity.java
Normal file
73
app/src/main/java/com/yutou/jianrmg_v2/MainActivity.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package com.yutou.jianrmg_v2;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.yutou.jianrmg_v2.Fragments.GameData;
|
||||
import com.yutou.jianrmg_v2.Fragments.Home;
|
||||
import com.yutou.jianrmg_v2.Fragments.MGList;
|
||||
import com.yutou.jianrmg_v2.Fragments.My;
|
||||
import com.yutou.jianrmg_v2.basemodel.Adapters.ViewPagerAdapter;
|
||||
import com.yutou.jianrmg_v2.resmodl.R;
|
||||
import com.yutou.jianrmg_v2.basemodel.Tools.ActivitysManager;
|
||||
import com.yutou.jianrmg_v2.basemodel.views.LoadingActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.majiajie.pagerbottomtabstrip.NavigationController;
|
||||
import me.majiajie.pagerbottomtabstrip.PageNavigationView;
|
||||
import me.majiajie.pagerbottomtabstrip.listener.OnTabItemSelectedListener;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private PageNavigationView tab;
|
||||
private ViewPager viewPager;
|
||||
private NavigationController navigationController;
|
||||
private List<Fragment> list;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
ActivitysManager.finishActivity(LoadingActivity.class);
|
||||
initViews();
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
tab = findViewById(R.id.tab);
|
||||
viewPager = findViewById(R.id.pager);
|
||||
list=new ArrayList<>();
|
||||
list.add(Home.init(this));
|
||||
list.add(GameData.init(this));
|
||||
list.add(MGList.init(this));
|
||||
list.add(My.init());
|
||||
|
||||
ViewPagerAdapter adapter=new ViewPagerAdapter(getSupportFragmentManager(),list);
|
||||
viewPager.setAdapter(adapter);
|
||||
viewPager.setCurrentItem(0);
|
||||
navigationController = tab.material()
|
||||
.addItem(R.drawable.icon_home, R.drawable.icon_home_select, "主页")
|
||||
.addItem(R.drawable.icon_data, R.drawable.icon_data_select, "数据")
|
||||
.addItem(R.drawable.icon_mg, R.drawable.icon_mg_select, "魔改")
|
||||
.addItem(R.drawable.icon_my, R.drawable.icon_my_select, "个人中心")
|
||||
.build();
|
||||
navigationController.addTabItemSelectedListener(new OnTabItemSelectedListener() {
|
||||
@Override
|
||||
public void onSelected(int index, int old) {
|
||||
switch (index) {
|
||||
}
|
||||
viewPager.setCurrentItem(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRepeat(int index) {
|
||||
|
||||
}
|
||||
});
|
||||
navigationController.setupWithViewPager(viewPager);
|
||||
navigationController.setSelect(0);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user