This commit is contained in:
2018-04-13 15:47:23 +08:00
parent d60fd6b2df
commit 8c51f52a2c
208 changed files with 8975 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yutou.jianrmg_v2.apphome" >
</manifest>

View 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;
}
}

View 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();
}

View File

@@ -0,0 +1,85 @@
package com.yutou.jianrmg_v2.apphome.Adapters;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.alibaba.fastjson.JSON;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.yutou.jianrmg_v2.apphome.Datas.MAppHome;
import com.yutou.jianrmg_v2.basemodel.Tools.Utils;
import com.yutou.jianrmg_v2.resmodl.R;
import com.yutou.jianrmg_v2.basemodel.Tools.Log;
import com.yutou.jianrmg_v2.basemodel.views.WebActivity;
import cn.lemon.view.adapter.BaseViewHolder;
import cn.lemon.view.adapter.RecyclerAdapter;
;import static android.view.Gravity.BOTTOM;
import static android.view.Gravity.CENTER;
/**
* Created by 58381 on 2018/1/23.
*/
public class HomeRecyclerAdapter extends RecyclerAdapter<MAppHome> {
private ImageLoader imageLoader;
private Activity activity;
public HomeRecyclerAdapter(Context context) {
super(context);
this.activity= (Activity) context;
imageLoader = Utils.initImageLoader(context);
}
@Override
public BaseViewHolder<MAppHome> onCreateBaseViewHolder(ViewGroup parent, int viewType) {
return new CardRecordHolder(parent, R.layout.item_home);
}
private class CardRecordHolder extends BaseViewHolder<MAppHome> {
private ImageView icon;
private TextView name;
public CardRecordHolder(ViewGroup parent, int layoutId) {
super(parent, 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);
}
}
}
}

View File

@@ -0,0 +1,120 @@
package com.yutou.jianrmg_v2.apphome.Datas;
public class MAppHome {
/**
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_home.id
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
*/
private Integer id;
/**
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_home.name
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
*/
private String name;
/**
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_home.icon
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
*/
private String icon;
/**
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_home.url
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
*/
private String url;
/**
* This field was generated by MyBatis Generator. This field corresponds to the database column m_app_home.isshow
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
*/
private Integer isshow;
/**
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_home.id
* @return the value of m_app_home.id
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
*/
public Integer getId() {
return id;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_home.id
* @param id the value for m_app_home.id
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
*/
public void setId(Integer id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_home.name
* @return the value of m_app_home.name
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
*/
public String getName() {
return name;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_home.name
* @param name the value for m_app_home.name
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
*/
public void setName(String name) {
this.name = name;
}
/**
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_home.icon
* @return the value of m_app_home.icon
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
*/
public String getIcon() {
return icon;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_home.icon
* @param icon the value for m_app_home.icon
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
*/
public void setIcon(String icon) {
this.icon = icon;
}
/**
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_home.url
* @return the value of m_app_home.url
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
*/
public String getUrl() {
return url;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_home.url
* @param url the value for m_app_home.url
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
*/
public void setUrl(String url) {
this.url = url;
}
/**
* This method was generated by MyBatis Generator. This method returns the value of the database column m_app_home.isshow
* @return the value of m_app_home.isshow
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
*/
public Integer getIsshow() {
return isshow;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of the database column m_app_home.isshow
* @param isshow the value for m_app_home.isshow
* @mbg.generated Tue Jan 23 12:06:19 CST 2018
*/
public void setIsshow(Integer isshow) {
this.isshow = isshow;
}
}

View File

@@ -0,0 +1,249 @@
package com.yutou.jianrmg_v2.apphome;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.NotificationCompat;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutCompat;
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.RemoteViews;
import android.widget.TextView;
import android.widget.Toast;
import com.alibaba.fastjson.JSON;
import com.bigkoo.convenientbanner.ConvenientBanner;
import com.bigkoo.convenientbanner.holder.CBViewHolderCreator;
import com.bigkoo.convenientbanner.holder.Holder;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.yutou.jianrmg_v2.apphome.Adapters.HomeRecyclerAdapter;
import com.yutou.jianrmg_v2.apphome.Datas.MAppHome;
import com.yutou.jianrmg_v2.basemodel.Data.MBanner;
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.Tools.Log;
import com.yutou.jianrmg_v2.basemodel.Tools.Utils;
import com.yutou.jianrmg_v2.basemodel.views.WebActivity;
import com.yutou.jianrmg_v2.basemodel.R;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import Interfaces.BaseFragmeneInerface;
import cn.lemon.view.RefreshRecyclerView;
import cn.lemon.view.adapter.Action;
public class MainFragmene implements BaseFragmeneInerface {
private ConvenientBanner banner;
private RefreshRecyclerView recyclerView;
private HomeRecyclerAdapter adapter;
private View view;
private List<MAppHome> datas;
private int min=0, max=10;
private boolean isInit=true;
private Handler handler;
private ImageLoader imageLoader;
private Context context;
@Override
public void init(Context context) {
this.context=context;
}
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
if(view!=null)
return view;
view=new RefreshRecyclerView(context);
imageLoader= Utils.initImageLoader(context);
handler=new Handler();
initBanner();
init(-1);
//Toast.makeText(context,"这是插件",Toast.LENGTH_LONG).show();
TextView textView=new TextView(context);
textView.setText("插件");
return view;
}
@Override
public void setIntent() {
}
public void init(int index) {
initView(view);
}
private void initBanner(){
HttpUtils.get(HttpApi.HOME_URL + HttpApi.BANNER, new HttpInterface() {
@Override
public void httpError(Exception e) {
e.printStackTrace();
}
@Override
public void httpGetData(String string, int code) {
final List<MBanner> array;
try {
Log.i("banner",string);
JSONObject json=new JSONObject(string);
if(json.getInt("code")==100){
array= JSON.parseArray(json.getString("data"),MBanner.class);
}else{
array=new ArrayList<>();
}
Log.i(""+(handler==null));
handler.post(new Runnable() {
@Override
public void run() {
setBanner(array);
}
});
}catch (Exception e){
e.printStackTrace();
}
}
});
}
private void setBanner( List<MBanner> list){
banner.setCanLoop(true);
banner.startTurning(2000);
banner.setPages(new CBViewHolderCreator(){
@Override
public Object createHolder() {
return new Banner();
}
},list).setPageIndicatorAlign(ConvenientBanner.PageIndicatorAlign.ALIGN_PARENT_RIGHT);
}
private void initView(View view){
Log.i("初始化主页");
banner=new ConvenientBanner(context);
ViewGroup.LayoutParams params=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,400);
banner.setLayoutParams(params);
recyclerView= (RefreshRecyclerView) view;
recyclerView.setSwipeRefreshColors(0xFF437845,0xFFE44F98,0xFF2FAC21);
recyclerView.setLayoutManager(new GridLayoutManager(context,3));
adapter=new com.yutou.jianrmg_v2.apphome.Adapters.HomeRecyclerAdapter(context);
adapter.setHeader(banner);
TextView endText=new TextView(context);
endText.setLayoutParams(new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Utils.getPixelsFromDp(((Activity) context),48)));
endText.setTextSize(16);
endText.setGravity(Gravity.CENTER);
endText.setText(" --已经没有了--");
adapter.setFooter(endText);
recyclerView.setAdapter(adapter);
recyclerView.setRefreshAction(new Action() {
@Override
public void onAction() {
min=0;
max=10;
isInit=true;
initData();
}
});
recyclerView.setLoadMoreAction(new Action() {
@Override
public void onAction() {
if(isInit){
recyclerView.showNoMore();
}else {
min = max;
max += 10;
initData();
}
}
});
recyclerView.showSwipeRefresh();
initData();
}
private void initData(){
try {
datas=new ArrayList<>();
Log.i("载入数据");
JSONObject json=new JSONObject();
HttpUtils.post(HttpApi.HOME_URL + HttpApi.MG_HOME_LIST, json, new HttpInterface() {
@Override
public void httpError(Exception e) {
}
@Override
public void httpGetData(String string, int code) {
Log.i(HttpApi.MG_HOME_LIST,string);
try{
JSONObject json=new JSONObject(string);
if(json.getInt("code")==100){
datas= JSON.parseArray(json.getString("data"), MAppHome.class);
}
handler.post(new Runnable() {
@Override
public void run() {
setData();
}
});
}catch (Exception e){
e.printStackTrace();
}
}
});
}catch (Exception e){
e.printStackTrace();
}
}
private void setData(){
if(datas.size()>0){
adapter.clear();
adapter.addAll(datas);
recyclerView.dismissSwipeRefresh();
recyclerView.getRecyclerView().scrollToPosition(0);
}else{
adapter.addAll(datas);
}
}
private class Banner implements Holder<MBanner> {
private ImageView imageView;
@Override
public View createView(Context context) {
imageView = new ImageView(context);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
return imageView;
}
@Override
public void UpdateUI(final Context context, int position, final MBanner data) {
imageLoader.displayImage(data.getUrl(),imageView);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(data.getClick()!=null&&data.getClick().contains("webhttp")){
Intent intent=new Intent(context, WebActivity.class);
intent.putExtra("url",data.getClick().replace("webhttp","http"));
context.startActivity(intent);
}else {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(data.getClick()));
MainFragmene.this.context.startActivity(intent);
}
}
});
}
}
}

View File

@@ -0,0 +1,3 @@
<resources>
<string name="app_name">AppHome</string>
</resources>