Commit 54127ffd102ed962a04324441ea77977dbc12a37

Authored by 陶汉栋
0 parents

no message

Showing 175 changed files with 13161 additions and 0 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 175 files displayed.

.gitignore 0 → 100644
  1 +++ a/.gitignore
... ... @@ -0,0 +1,9 @@
  1 +*.iml
  2 +.gradle
  3 +/local.properties
  4 +/.idea/workspace.xml
  5 +/.idea/libraries
  6 +.DS_Store
  7 +/build
  8 +/captures
  9 +.externalNativeBuild
... ...
.idea/gradle.xml 0 → 100644
  1 +++ a/.idea/gradle.xml
... ... @@ -0,0 +1,19 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="GradleSettings">
  4 + <option name="linkedExternalProjectsSettings">
  5 + <GradleProjectSettings>
  6 + <option name="distributionType" value="DEFAULT_WRAPPED" />
  7 + <option name="externalProjectPath" value="$PROJECT_DIR$" />
  8 + <option name="modules">
  9 + <set>
  10 + <option value="$PROJECT_DIR$" />
  11 + <option value="$PROJECT_DIR$/app" />
  12 + <option value="$PROJECT_DIR$/mvpsdk" />
  13 + </set>
  14 + </option>
  15 + <option name="resolveModulePerSourceSet" value="false" />
  16 + </GradleProjectSettings>
  17 + </option>
  18 + </component>
  19 +</project>
0 20 \ No newline at end of file
... ...
.idea/misc.xml 0 → 100644
  1 +++ a/.idea/misc.xml
... ... @@ -0,0 +1,33 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="NullableNotNullManager">
  4 + <option name="myDefaultNullable" value="android.support.annotation.Nullable" />
  5 + <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
  6 + <option name="myNullables">
  7 + <value>
  8 + <list size="4">
  9 + <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
  10 + <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
  11 + <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
  12 + <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
  13 + </list>
  14 + </value>
  15 + </option>
  16 + <option name="myNotNulls">
  17 + <value>
  18 + <list size="4">
  19 + <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
  20 + <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
  21 + <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
  22 + <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
  23 + </list>
  24 + </value>
  25 + </option>
  26 + </component>
  27 + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
  28 + <output url="file://$PROJECT_DIR$/build/classes" />
  29 + </component>
  30 + <component name="ProjectType">
  31 + <option name="id" value="Android" />
  32 + </component>
  33 +</project>
0 34 \ No newline at end of file
... ...
.idea/modules.xml 0 → 100644
  1 +++ a/.idea/modules.xml
... ... @@ -0,0 +1,10 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="ProjectModuleManager">
  4 + <modules>
  5 + <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
  6 + <module fileurl="file://$PROJECT_DIR$/mvpsdk/mvpsdk.iml" filepath="$PROJECT_DIR$/mvpsdk/mvpsdk.iml" />
  7 + <module fileurl="file://$PROJECT_DIR$/parentwork.iml" filepath="$PROJECT_DIR$/parentwork.iml" />
  8 + </modules>
  9 + </component>
  10 +</project>
0 11 \ No newline at end of file
... ...
.idea/runConfigurations.xml 0 → 100644
  1 +++ a/.idea/runConfigurations.xml
... ... @@ -0,0 +1,12 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="RunConfigurationProducerService">
  4 + <option name="ignoredProducers">
  5 + <set>
  6 + <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
  7 + <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
  8 + <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
  9 + </set>
  10 + </option>
  11 + </component>
  12 +</project>
0 13 \ No newline at end of file
... ...
.idea/vcs.xml 0 → 100644
  1 +++ a/.idea/vcs.xml
... ... @@ -0,0 +1,6 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="VcsDirectoryMappings">
  4 + <mapping directory="$PROJECT_DIR$" vcs="Git" />
  5 + </component>
  6 +</project>
0 7 \ No newline at end of file
... ...
app/.gitignore 0 → 100644
  1 +++ a/app/.gitignore
... ... @@ -0,0 +1 @@
  1 +/build
... ...
app/build.gradle 0 → 100644
  1 +++ a/app/build.gradle
... ... @@ -0,0 +1,30 @@
  1 +apply plugin: 'com.android.application'
  2 +
  3 +android {
  4 + compileSdkVersion 26
  5 + defaultConfig {
  6 + applicationId "com.shunzhi.parent"
  7 + minSdkVersion 16
  8 + targetSdkVersion 26
  9 + versionCode 1
  10 + versionName "1.0"
  11 + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  12 + }
  13 + buildTypes {
  14 + release {
  15 + minifyEnabled false
  16 + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  17 + }
  18 + }
  19 +}
  20 +
  21 +dependencies {
  22 + implementation fileTree(include: ['*.jar'], dir: 'libs')
  23 + implementation 'com.android.support:appcompat-v7:26.1.0'
  24 + implementation 'com.android.support.constraint:constraint-layout:1.0.2'
  25 + implementation 'com.android.support:support-v4:26.1.0'
  26 + testImplementation 'junit:junit:4.12'
  27 + androidTestImplementation 'com.android.support.test:runner:1.0.1'
  28 + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
  29 + implementation project(':mvpsdk')
  30 +}
... ...
app/proguard-rules.pro 0 → 100644
  1 +++ a/app/proguard-rules.pro
... ... @@ -0,0 +1,21 @@
  1 +# Add project specific ProGuard rules here.
  2 +# You can control the set of applied configuration files using the
  3 +# proguardFiles setting in build.gradle.
  4 +#
  5 +# For more details, see
  6 +# http://developer.android.com/guide/developing/tools/proguard.html
  7 +
  8 +# If your project uses WebView with JS, uncomment the following
  9 +# and specify the fully qualified class name to the JavaScript interface
  10 +# class:
  11 +#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
  12 +# public *;
  13 +#}
  14 +
  15 +# Uncomment this to preserve the line number information for
  16 +# debugging stack traces.
  17 +#-keepattributes SourceFile,LineNumberTable
  18 +
  19 +# If you keep the line number information, uncomment this to
  20 +# hide the original source file name.
  21 +#-renamesourcefileattribute SourceFile
... ...
app/src/androidTest/java/com/shunzhi/parent/ExampleInstrumentedTest.java 0 → 100644
  1 +++ a/app/src/androidTest/java/com/shunzhi/parent/ExampleInstrumentedTest.java
... ... @@ -0,0 +1,26 @@
  1 +package com.shunzhi.parent;
  2 +
  3 +import android.content.Context;
  4 +import android.support.test.InstrumentationRegistry;
  5 +import android.support.test.runner.AndroidJUnit4;
  6 +
  7 +import org.junit.Test;
  8 +import org.junit.runner.RunWith;
  9 +
  10 +import static org.junit.Assert.*;
  11 +
  12 +/**
  13 + * Instrumented test, which will execute on an Android device.
  14 + *
  15 + * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
  16 + */
  17 +@RunWith(AndroidJUnit4.class)
  18 +public class ExampleInstrumentedTest {
  19 + @Test
  20 + public void useAppContext() throws Exception {
  21 + // Context of the app under test.
  22 + Context appContext = InstrumentationRegistry.getTargetContext();
  23 +
  24 + assertEquals("com.shunzhi.parent", appContext.getPackageName());
  25 + }
  26 +}
... ...
app/src/main/AndroidManifest.xml 0 → 100644
  1 +++ a/app/src/main/AndroidManifest.xml
... ... @@ -0,0 +1,24 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3 + package="com.shunzhi.parent">
  4 +
  5 + <application
  6 + android:name=".MyApplication"
  7 + android:allowBackup="true"
  8 + android:icon="@mipmap/ic_launcher"
  9 + android:label="@string/app_name"
  10 + android:roundIcon="@mipmap/ic_launcher_round"
  11 + android:supportsRtl="true"
  12 + android:theme="@style/AppTheme">
  13 + <activity android:name=".ui.MainActivity">
  14 + <intent-filter>
  15 + <action android:name="android.intent.action.MAIN" />
  16 +
  17 + <category android:name="android.intent.category.LAUNCHER" />
  18 + </intent-filter>
  19 + </activity>
  20 + <activity android:name=".ui.activity.LoginAndRegistActivity" />
  21 + <activity android:name=".ui.activity.StartActivity"></activity>
  22 + </application>
  23 +
  24 +</manifest>
0 25 \ No newline at end of file
... ...
app/src/main/java/com/shunzhi/parent/MyApplication.java 0 → 100644
  1 +++ a/app/src/main/java/com/shunzhi/parent/MyApplication.java
... ... @@ -0,0 +1,17 @@
  1 +package com.shunzhi.parent;
  2 +
  3 +import com.share.mvpsdk.global.GlobalApplication;
  4 +
  5 +/**
  6 + * Created by ToaHanDong on 2018/3/2.
  7 + */
  8 +
  9 +public class MyApplication extends GlobalApplication {
  10 +
  11 +
  12 + @Override
  13 + public void onCreate() {
  14 + super.onCreate();
  15 +
  16 + }
  17 +}
... ...
app/src/main/java/com/shunzhi/parent/ui/MainActivity.java 0 → 100644
  1 +++ a/app/src/main/java/com/shunzhi/parent/ui/MainActivity.java
... ... @@ -0,0 +1,15 @@
  1 +package com.shunzhi.parent.ui;
  2 +
  3 +import android.support.v7.app.AppCompatActivity;
  4 +import android.os.Bundle;
  5 +
  6 +import com.shunzhi.parent.R;
  7 +
  8 +public class MainActivity extends AppCompatActivity {
  9 +
  10 + @Override
  11 + protected void onCreate(Bundle savedInstanceState) {
  12 + super.onCreate(savedInstanceState);
  13 + setContentView(R.layout.activity_main);
  14 + }
  15 +}
... ...
app/src/main/java/com/shunzhi/parent/ui/activity/LoginAndRegistActivity.java 0 → 100644
  1 +++ a/app/src/main/java/com/shunzhi/parent/ui/activity/LoginAndRegistActivity.java
... ... @@ -0,0 +1,15 @@
  1 +package com.shunzhi.parent.ui.activity;
  2 +
  3 +import android.support.v7.app.AppCompatActivity;
  4 +import android.os.Bundle;
  5 +
  6 +import com.shunzhi.parent.R;
  7 +
  8 +public class LoginAndRegistActivity extends AppCompatActivity {
  9 +
  10 + @Override
  11 + protected void onCreate(Bundle savedInstanceState) {
  12 + super.onCreate(savedInstanceState);
  13 + setContentView(R.layout.activity_regist);
  14 + }
  15 +}
... ...
app/src/main/java/com/shunzhi/parent/ui/activity/StartActivity.java 0 → 100644
  1 +++ a/app/src/main/java/com/shunzhi/parent/ui/activity/StartActivity.java
... ... @@ -0,0 +1,15 @@
  1 +package com.shunzhi.parent.ui.activity;
  2 +
  3 +import android.support.v7.app.AppCompatActivity;
  4 +import android.os.Bundle;
  5 +
  6 +import com.shunzhi.parent.R;
  7 +
  8 +public class StartActivity extends AppCompatActivity {
  9 +
  10 + @Override
  11 + protected void onCreate(Bundle savedInstanceState) {
  12 + super.onCreate(savedInstanceState);
  13 + setContentView(R.layout.activity_start);
  14 + }
  15 +}
... ...
app/src/main/java/com/shunzhi/parent/ui/fragment/CePingFragment.java 0 → 100644
  1 +++ a/app/src/main/java/com/shunzhi/parent/ui/fragment/CePingFragment.java
... ... @@ -0,0 +1,109 @@
  1 +package com.shunzhi.parent.ui.fragment;
  2 +
  3 +import android.content.Context;
  4 +import android.net.Uri;
  5 +import android.os.Bundle;
  6 +import android.support.v4.app.Fragment;
  7 +import android.view.LayoutInflater;
  8 +import android.view.View;
  9 +import android.view.ViewGroup;
  10 +
  11 +import com.shunzhi.parent.R;
  12 +
  13 +/**
  14 + * A simple {@link Fragment} subclass.
  15 + * Activities that contain this fragment must implement the
  16 + * {@link CePingFragment.OnFragmentInteractionListener} interface
  17 + * to handle interaction events.
  18 + * Use the {@link CePingFragment#newInstance} factory method to
  19 + * create an instance of this fragment.
  20 + */
  21 +public class CePingFragment extends Fragment {
  22 + // TODO: Rename parameter arguments, choose names that match
  23 + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
  24 + private static final String ARG_PARAM1 = "param1";
  25 + private static final String ARG_PARAM2 = "param2";
  26 +
  27 + // TODO: Rename and change types of parameters
  28 + private String mParam1;
  29 + private String mParam2;
  30 +
  31 + private OnFragmentInteractionListener mListener;
  32 +
  33 + public CePingFragment() {
  34 + // Required empty public constructor
  35 + }
  36 +
  37 + /**
  38 + * Use this factory method to create a new instance of
  39 + * this fragment using the provided parameters.
  40 + *
  41 + * @param param1 Parameter 1.
  42 + * @param param2 Parameter 2.
  43 + * @return A new instance of fragment CePingFragment.
  44 + */
  45 + // TODO: Rename and change types and number of parameters
  46 + public static CePingFragment newInstance(String param1, String param2) {
  47 + CePingFragment fragment = new CePingFragment();
  48 + Bundle args = new Bundle();
  49 + args.putString(ARG_PARAM1, param1);
  50 + args.putString(ARG_PARAM2, param2);
  51 + fragment.setArguments(args);
  52 + return fragment;
  53 + }
  54 +
  55 + @Override
  56 + public void onCreate(Bundle savedInstanceState) {
  57 + super.onCreate(savedInstanceState);
  58 + if (getArguments() != null) {
  59 + mParam1 = getArguments().getString(ARG_PARAM1);
  60 + mParam2 = getArguments().getString(ARG_PARAM2);
  61 + }
  62 + }
  63 +
  64 + @Override
  65 + public View onCreateView(LayoutInflater inflater, ViewGroup container,
  66 + Bundle savedInstanceState) {
  67 + // Inflate the layout for this fragment
  68 + return inflater.inflate(R.layout.fragment_ce_ping, container, false);
  69 + }
  70 +
  71 + // TODO: Rename method, update argument and hook method into UI event
  72 + public void onButtonPressed(Uri uri) {
  73 + if (mListener != null) {
  74 + mListener.onFragmentInteraction(uri);
  75 + }
  76 + }
  77 +
  78 + @Override
  79 + public void onAttach(Context context) {
  80 + super.onAttach(context);
  81 + if (context instanceof OnFragmentInteractionListener) {
  82 + mListener = (OnFragmentInteractionListener) context;
  83 + } else {
  84 + throw new RuntimeException(context.toString()
  85 + + " must implement OnFragmentInteractionListener");
  86 + }
  87 + }
  88 +
  89 + @Override
  90 + public void onDetach() {
  91 + super.onDetach();
  92 + mListener = null;
  93 + }
  94 +
  95 + /**
  96 + * This interface must be implemented by activities that contain this
  97 + * fragment to allow an interaction in this fragment to be communicated
  98 + * to the activity and potentially other fragments contained in that
  99 + * activity.
  100 + * <p>
  101 + * See the Android Training lesson <a href=
  102 + * "http://developer.android.com/training/basics/fragments/communicating.html"
  103 + * >Communicating with Other Fragments</a> for more information.
  104 + */
  105 + public interface OnFragmentInteractionListener {
  106 + // TODO: Update argument type and name
  107 + void onFragmentInteraction(Uri uri);
  108 + }
  109 +}
... ...
app/src/main/java/com/shunzhi/parent/ui/fragment/ConsultFragment.java 0 → 100644
  1 +++ a/app/src/main/java/com/shunzhi/parent/ui/fragment/ConsultFragment.java
... ... @@ -0,0 +1,109 @@
  1 +package com.shunzhi.parent.ui.fragment;
  2 +
  3 +import android.content.Context;
  4 +import android.net.Uri;
  5 +import android.os.Bundle;
  6 +import android.support.v4.app.Fragment;
  7 +import android.view.LayoutInflater;
  8 +import android.view.View;
  9 +import android.view.ViewGroup;
  10 +
  11 +import com.shunzhi.parent.R;
  12 +
  13 +/**
  14 + * A simple {@link Fragment} subclass.
  15 + * Activities that contain this fragment must implement the
  16 + * {@link ConsultFragment.OnFragmentInteractionListener} interface
  17 + * to handle interaction events.
  18 + * Use the {@link ConsultFragment#newInstance} factory method to
  19 + * create an instance of this fragment.
  20 + */
  21 +public class ConsultFragment extends Fragment {
  22 + // TODO: Rename parameter arguments, choose names that match
  23 + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
  24 + private static final String ARG_PARAM1 = "param1";
  25 + private static final String ARG_PARAM2 = "param2";
  26 +
  27 + // TODO: Rename and change types of parameters
  28 + private String mParam1;
  29 + private String mParam2;
  30 +
  31 + private OnFragmentInteractionListener mListener;
  32 +
  33 + public ConsultFragment() {
  34 + // Required empty public constructor
  35 + }
  36 +
  37 + /**
  38 + * Use this factory method to create a new instance of
  39 + * this fragment using the provided parameters.
  40 + *
  41 + * @param param1 Parameter 1.
  42 + * @param param2 Parameter 2.
  43 + * @return A new instance of fragment ConsultFragment.
  44 + */
  45 + // TODO: Rename and change types and number of parameters
  46 + public static ConsultFragment newInstance(String param1, String param2) {
  47 + ConsultFragment fragment = new ConsultFragment();
  48 + Bundle args = new Bundle();
  49 + args.putString(ARG_PARAM1, param1);
  50 + args.putString(ARG_PARAM2, param2);
  51 + fragment.setArguments(args);
  52 + return fragment;
  53 + }
  54 +
  55 + @Override
  56 + public void onCreate(Bundle savedInstanceState) {
  57 + super.onCreate(savedInstanceState);
  58 + if (getArguments() != null) {
  59 + mParam1 = getArguments().getString(ARG_PARAM1);
  60 + mParam2 = getArguments().getString(ARG_PARAM2);
  61 + }
  62 + }
  63 +
  64 + @Override
  65 + public View onCreateView(LayoutInflater inflater, ViewGroup container,
  66 + Bundle savedInstanceState) {
  67 + // Inflate the layout for this fragment
  68 + return inflater.inflate(R.layout.fragment_zi_xun, container, false);
  69 + }
  70 +
  71 + // TODO: Rename method, update argument and hook method into UI event
  72 + public void onButtonPressed(Uri uri) {
  73 + if (mListener != null) {
  74 + mListener.onFragmentInteraction(uri);
  75 + }
  76 + }
  77 +
  78 + @Override
  79 + public void onAttach(Context context) {
  80 + super.onAttach(context);
  81 + if (context instanceof OnFragmentInteractionListener) {
  82 + mListener = (OnFragmentInteractionListener) context;
  83 + } else {
  84 + throw new RuntimeException(context.toString()
  85 + + " must implement OnFragmentInteractionListener");
  86 + }
  87 + }
  88 +
  89 + @Override
  90 + public void onDetach() {
  91 + super.onDetach();
  92 + mListener = null;
  93 + }
  94 +
  95 + /**
  96 + * This interface must be implemented by activities that contain this
  97 + * fragment to allow an interaction in this fragment to be communicated
  98 + * to the activity and potentially other fragments contained in that
  99 + * activity.
  100 + * <p>
  101 + * See the Android Training lesson <a href=
  102 + * "http://developer.android.com/training/basics/fragments/communicating.html"
  103 + * >Communicating with Other Fragments</a> for more information.
  104 + */
  105 + public interface OnFragmentInteractionListener {
  106 + // TODO: Update argument type and name
  107 + void onFragmentInteraction(Uri uri);
  108 + }
  109 +}
... ...
app/src/main/java/com/shunzhi/parent/ui/fragment/MineFragment.java 0 → 100644
  1 +++ a/app/src/main/java/com/shunzhi/parent/ui/fragment/MineFragment.java
... ... @@ -0,0 +1,109 @@
  1 +package com.shunzhi.parent.ui.fragment;
  2 +
  3 +import android.content.Context;
  4 +import android.net.Uri;
  5 +import android.os.Bundle;
  6 +import android.support.v4.app.Fragment;
  7 +import android.view.LayoutInflater;
  8 +import android.view.View;
  9 +import android.view.ViewGroup;
  10 +
  11 +import com.shunzhi.parent.R;
  12 +
  13 +/**
  14 + * A simple {@link Fragment} subclass.
  15 + * Activities that contain this fragment must implement the
  16 + * {@link MineFragment.OnFragmentInteractionListener} interface
  17 + * to handle interaction events.
  18 + * Use the {@link MineFragment#newInstance} factory method to
  19 + * create an instance of this fragment.
  20 + */
  21 +public class MineFragment extends Fragment {
  22 + // TODO: Rename parameter arguments, choose names that match
  23 + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
  24 + private static final String ARG_PARAM1 = "param1";
  25 + private static final String ARG_PARAM2 = "param2";
  26 +
  27 + // TODO: Rename and change types of parameters
  28 + private String mParam1;
  29 + private String mParam2;
  30 +
  31 + private OnFragmentInteractionListener mListener;
  32 +
  33 + public MineFragment() {
  34 + // Required empty public constructor
  35 + }
  36 +
  37 + /**
  38 + * Use this factory method to create a new instance of
  39 + * this fragment using the provided parameters.
  40 + *
  41 + * @param param1 Parameter 1.
  42 + * @param param2 Parameter 2.
  43 + * @return A new instance of fragment MineFragment.
  44 + */
  45 + // TODO: Rename and change types and number of parameters
  46 + public static MineFragment newInstance(String param1, String param2) {
  47 + MineFragment fragment = new MineFragment();
  48 + Bundle args = new Bundle();
  49 + args.putString(ARG_PARAM1, param1);
  50 + args.putString(ARG_PARAM2, param2);
  51 + fragment.setArguments(args);
  52 + return fragment;
  53 + }
  54 +
  55 + @Override
  56 + public void onCreate(Bundle savedInstanceState) {
  57 + super.onCreate(savedInstanceState);
  58 + if (getArguments() != null) {
  59 + mParam1 = getArguments().getString(ARG_PARAM1);
  60 + mParam2 = getArguments().getString(ARG_PARAM2);
  61 + }
  62 + }
  63 +
  64 + @Override
  65 + public View onCreateView(LayoutInflater inflater, ViewGroup container,
  66 + Bundle savedInstanceState) {
  67 + // Inflate the layout for this fragment
  68 + return inflater.inflate(R.layout.fragment_mine, container, false);
  69 + }
  70 +
  71 + // TODO: Rename method, update argument and hook method into UI event
  72 + public void onButtonPressed(Uri uri) {
  73 + if (mListener != null) {
  74 + mListener.onFragmentInteraction(uri);
  75 + }
  76 + }
  77 +
  78 + @Override
  79 + public void onAttach(Context context) {
  80 + super.onAttach(context);
  81 + if (context instanceof OnFragmentInteractionListener) {
  82 + mListener = (OnFragmentInteractionListener) context;
  83 + } else {
  84 + throw new RuntimeException(context.toString()
  85 + + " must implement OnFragmentInteractionListener");
  86 + }
  87 + }
  88 +
  89 + @Override
  90 + public void onDetach() {
  91 + super.onDetach();
  92 + mListener = null;
  93 + }
  94 +
  95 + /**
  96 + * This interface must be implemented by activities that contain this
  97 + * fragment to allow an interaction in this fragment to be communicated
  98 + * to the activity and potentially other fragments contained in that
  99 + * activity.
  100 + * <p>
  101 + * See the Android Training lesson <a href=
  102 + * "http://developer.android.com/training/basics/fragments/communicating.html"
  103 + * >Communicating with Other Fragments</a> for more information.
  104 + */
  105 + public interface OnFragmentInteractionListener {
  106 + // TODO: Update argument type and name
  107 + void onFragmentInteraction(Uri uri);
  108 + }
  109 +}
... ...
app/src/main/java/com/shunzhi/parent/ui/fragment/ReportFragment.java 0 → 100644
  1 +++ a/app/src/main/java/com/shunzhi/parent/ui/fragment/ReportFragment.java
... ... @@ -0,0 +1,109 @@
  1 +package com.shunzhi.parent.ui.fragment;
  2 +
  3 +import android.content.Context;
  4 +import android.net.Uri;
  5 +import android.os.Bundle;
  6 +import android.support.v4.app.Fragment;
  7 +import android.view.LayoutInflater;
  8 +import android.view.View;
  9 +import android.view.ViewGroup;
  10 +
  11 +import com.shunzhi.parent.R;
  12 +
  13 +/**
  14 + * A simple {@link Fragment} subclass.
  15 + * Activities that contain this fragment must implement the
  16 + * {@link ReportFragment.OnFragmentInteractionListener} interface
  17 + * to handle interaction events.
  18 + * Use the {@link ReportFragment#newInstance} factory method to
  19 + * create an instance of this fragment.
  20 + */
  21 +public class ReportFragment extends Fragment {
  22 + // TODO: Rename parameter arguments, choose names that match
  23 + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
  24 + private static final String ARG_PARAM1 = "param1";
  25 + private static final String ARG_PARAM2 = "param2";
  26 +
  27 + // TODO: Rename and change types of parameters
  28 + private String mParam1;
  29 + private String mParam2;
  30 +
  31 + private OnFragmentInteractionListener mListener;
  32 +
  33 + public ReportFragment() {
  34 + // Required empty public constructor
  35 + }
  36 +
  37 + /**
  38 + * Use this factory method to create a new instance of
  39 + * this fragment using the provided parameters.
  40 + *
  41 + * @param param1 Parameter 1.
  42 + * @param param2 Parameter 2.
  43 + * @return A new instance of fragment ReportFragment.
  44 + */
  45 + // TODO: Rename and change types and number of parameters
  46 + public static ReportFragment newInstance(String param1, String param2) {
  47 + ReportFragment fragment = new ReportFragment();
  48 + Bundle args = new Bundle();
  49 + args.putString(ARG_PARAM1, param1);
  50 + args.putString(ARG_PARAM2, param2);
  51 + fragment.setArguments(args);
  52 + return fragment;
  53 + }
  54 +
  55 + @Override
  56 + public void onCreate(Bundle savedInstanceState) {
  57 + super.onCreate(savedInstanceState);
  58 + if (getArguments() != null) {
  59 + mParam1 = getArguments().getString(ARG_PARAM1);
  60 + mParam2 = getArguments().getString(ARG_PARAM2);
  61 + }
  62 + }
  63 +
  64 + @Override
  65 + public View onCreateView(LayoutInflater inflater, ViewGroup container,
  66 + Bundle savedInstanceState) {
  67 + // Inflate the layout for this fragment
  68 + return inflater.inflate(R.layout.fragment_report, container, false);
  69 + }
  70 +
  71 + // TODO: Rename method, update argument and hook method into UI event
  72 + public void onButtonPressed(Uri uri) {
  73 + if (mListener != null) {
  74 + mListener.onFragmentInteraction(uri);
  75 + }
  76 + }
  77 +
  78 + @Override
  79 + public void onAttach(Context context) {
  80 + super.onAttach(context);
  81 + if (context instanceof OnFragmentInteractionListener) {
  82 + mListener = (OnFragmentInteractionListener) context;
  83 + } else {
  84 + throw new RuntimeException(context.toString()
  85 + + " must implement OnFragmentInteractionListener");
  86 + }
  87 + }
  88 +
  89 + @Override
  90 + public void onDetach() {
  91 + super.onDetach();
  92 + mListener = null;
  93 + }
  94 +
  95 + /**
  96 + * This interface must be implemented by activities that contain this
  97 + * fragment to allow an interaction in this fragment to be communicated
  98 + * to the activity and potentially other fragments contained in that
  99 + * activity.
  100 + * <p>
  101 + * See the Android Training lesson <a href=
  102 + * "http://developer.android.com/training/basics/fragments/communicating.html"
  103 + * >Communicating with Other Fragments</a> for more information.
  104 + */
  105 + public interface OnFragmentInteractionListener {
  106 + // TODO: Update argument type and name
  107 + void onFragmentInteraction(Uri uri);
  108 + }
  109 +}
... ...
app/src/main/java/com/shunzhi/parent/ui/fragment/loginandregistfragment/LoginAndRegistFragment.java 0 → 100644
  1 +++ a/app/src/main/java/com/shunzhi/parent/ui/fragment/loginandregistfragment/LoginAndRegistFragment.java
... ... @@ -0,0 +1,109 @@
  1 +package com.shunzhi.parent.ui.fragment.loginandregistfragment;
  2 +
  3 +import android.content.Context;
  4 +import android.net.Uri;
  5 +import android.os.Bundle;
  6 +import android.support.v4.app.Fragment;
  7 +import android.view.LayoutInflater;
  8 +import android.view.View;
  9 +import android.view.ViewGroup;
  10 +
  11 +import com.shunzhi.parent.R;
  12 +
  13 +/**
  14 + * A simple {@link Fragment} subclass.
  15 + * Activities that contain this fragment must implement the
  16 + * {@link LoginAndRegistFragment.OnFragmentInteractionListener} interface
  17 + * to handle interaction events.
  18 + * Use the {@link LoginAndRegistFragment#newInstance} factory method to
  19 + * create an instance of this fragment.
  20 + */
  21 +public class LoginAndRegistFragment extends Fragment {
  22 + // TODO: Rename parameter arguments, choose names that match
  23 + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
  24 + private static final String ARG_PARAM1 = "param1";
  25 + private static final String ARG_PARAM2 = "param2";
  26 +
  27 + // TODO: Rename and change types of parameters
  28 + private String mParam1;
  29 + private String mParam2;
  30 +
  31 + private OnFragmentInteractionListener mListener;
  32 +
  33 + public LoginAndRegistFragment() {
  34 + // Required empty public constructor
  35 + }
  36 +
  37 + /**
  38 + * Use this factory method to create a new instance of
  39 + * this fragment using the provided parameters.
  40 + *
  41 + * @param param1 Parameter 1.
  42 + * @param param2 Parameter 2.
  43 + * @return A new instance of fragment LoginAndRegistFragment.
  44 + */
  45 + // TODO: Rename and change types and number of parameters
  46 + public static LoginAndRegistFragment newInstance(String param1, String param2) {
  47 + LoginAndRegistFragment fragment = new LoginAndRegistFragment();
  48 + Bundle args = new Bundle();
  49 + args.putString(ARG_PARAM1, param1);
  50 + args.putString(ARG_PARAM2, param2);
  51 + fragment.setArguments(args);
  52 + return fragment;
  53 + }
  54 +
  55 + @Override
  56 + public void onCreate(Bundle savedInstanceState) {
  57 + super.onCreate(savedInstanceState);
  58 + if (getArguments() != null) {
  59 + mParam1 = getArguments().getString(ARG_PARAM1);
  60 + mParam2 = getArguments().getString(ARG_PARAM2);
  61 + }
  62 + }
  63 +
  64 + @Override
  65 + public View onCreateView(LayoutInflater inflater, ViewGroup container,
  66 + Bundle savedInstanceState) {
  67 + // Inflate the layout for this fragment
  68 + return inflater.inflate(R.layout.fragment_login_and_regist, container, false);
  69 + }
  70 +
  71 + // TODO: Rename method, update argument and hook method into UI event
  72 + public void onButtonPressed(Uri uri) {
  73 + if (mListener != null) {
  74 + mListener.onFragmentInteraction(uri);
  75 + }
  76 + }
  77 +
  78 + @Override
  79 + public void onAttach(Context context) {
  80 + super.onAttach(context);
  81 + if (context instanceof OnFragmentInteractionListener) {
  82 + mListener = (OnFragmentInteractionListener) context;
  83 + } else {
  84 + throw new RuntimeException(context.toString()
  85 + + " must implement OnFragmentInteractionListener");
  86 + }
  87 + }
  88 +
  89 + @Override
  90 + public void onDetach() {
  91 + super.onDetach();
  92 + mListener = null;
  93 + }
  94 +
  95 + /**
  96 + * This interface must be implemented by activities that contain this
  97 + * fragment to allow an interaction in this fragment to be communicated
  98 + * to the activity and potentially other fragments contained in that
  99 + * activity.
  100 + * <p>
  101 + * See the Android Training lesson <a href=
  102 + * "http://developer.android.com/training/basics/fragments/communicating.html"
  103 + * >Communicating with Other Fragments</a> for more information.
  104 + */
  105 + public interface OnFragmentInteractionListener {
  106 + // TODO: Update argument type and name
  107 + void onFragmentInteraction(Uri uri);
  108 + }
  109 +}
... ...
app/src/main/res/drawable-v24/ic_launcher_foreground.xml 0 → 100644
  1 +++ a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
... ... @@ -0,0 +1,34 @@
  1 +<vector xmlns:android="http://schemas.android.com/apk/res/android"
  2 + xmlns:aapt="http://schemas.android.com/aapt"
  3 + android:width="108dp"
  4 + android:height="108dp"
  5 + android:viewportHeight="108"
  6 + android:viewportWidth="108">
  7 + <path
  8 + android:fillType="evenOdd"
  9 + android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
  10 + android:strokeColor="#00000000"
  11 + android:strokeWidth="1">
  12 + <aapt:attr name="android:fillColor">
  13 + <gradient
  14 + android:endX="78.5885"
  15 + android:endY="90.9159"
  16 + android:startX="48.7653"
  17 + android:startY="61.0927"
  18 + android:type="linear">
  19 + <item
  20 + android:color="#44000000"
  21 + android:offset="0.0" />
  22 + <item
  23 + android:color="#00000000"
  24 + android:offset="1.0" />
  25 + </gradient>
  26 + </aapt:attr>
  27 + </path>
  28 + <path
  29 + android:fillColor="#FFFFFF"
  30 + android:fillType="nonZero"
  31 + android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
  32 + android:strokeColor="#00000000"
  33 + android:strokeWidth="1" />
  34 +</vector>
... ...
app/src/main/res/drawable/ic_launcher_background.xml 0 → 100644
  1 +++ a/app/src/main/res/drawable/ic_launcher_background.xml
... ... @@ -0,0 +1,170 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<vector xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:width="108dp"
  4 + android:height="108dp"
  5 + android:viewportHeight="108"
  6 + android:viewportWidth="108">
  7 + <path
  8 + android:fillColor="#26A69A"
  9 + android:pathData="M0,0h108v108h-108z" />
  10 + <path
  11 + android:fillColor="#00000000"
  12 + android:pathData="M9,0L9,108"
  13 + android:strokeColor="#33FFFFFF"
  14 + android:strokeWidth="0.8" />
  15 + <path
  16 + android:fillColor="#00000000"
  17 + android:pathData="M19,0L19,108"
  18 + android:strokeColor="#33FFFFFF"
  19 + android:strokeWidth="0.8" />
  20 + <path
  21 + android:fillColor="#00000000"
  22 + android:pathData="M29,0L29,108"
  23 + android:strokeColor="#33FFFFFF"
  24 + android:strokeWidth="0.8" />
  25 + <path
  26 + android:fillColor="#00000000"
  27 + android:pathData="M39,0L39,108"
  28 + android:strokeColor="#33FFFFFF"
  29 + android:strokeWidth="0.8" />
  30 + <path
  31 + android:fillColor="#00000000"
  32 + android:pathData="M49,0L49,108"
  33 + android:strokeColor="#33FFFFFF"
  34 + android:strokeWidth="0.8" />
  35 + <path
  36 + android:fillColor="#00000000"
  37 + android:pathData="M59,0L59,108"
  38 + android:strokeColor="#33FFFFFF"
  39 + android:strokeWidth="0.8" />
  40 + <path
  41 + android:fillColor="#00000000"
  42 + android:pathData="M69,0L69,108"
  43 + android:strokeColor="#33FFFFFF"
  44 + android:strokeWidth="0.8" />
  45 + <path
  46 + android:fillColor="#00000000"
  47 + android:pathData="M79,0L79,108"
  48 + android:strokeColor="#33FFFFFF"
  49 + android:strokeWidth="0.8" />
  50 + <path
  51 + android:fillColor="#00000000"
  52 + android:pathData="M89,0L89,108"
  53 + android:strokeColor="#33FFFFFF"
  54 + android:strokeWidth="0.8" />
  55 + <path
  56 + android:fillColor="#00000000"
  57 + android:pathData="M99,0L99,108"
  58 + android:strokeColor="#33FFFFFF"
  59 + android:strokeWidth="0.8" />
  60 + <path
  61 + android:fillColor="#00000000"
  62 + android:pathData="M0,9L108,9"
  63 + android:strokeColor="#33FFFFFF"
  64 + android:strokeWidth="0.8" />
  65 + <path
  66 + android:fillColor="#00000000"
  67 + android:pathData="M0,19L108,19"
  68 + android:strokeColor="#33FFFFFF"
  69 + android:strokeWidth="0.8" />
  70 + <path
  71 + android:fillColor="#00000000"
  72 + android:pathData="M0,29L108,29"
  73 + android:strokeColor="#33FFFFFF"
  74 + android:strokeWidth="0.8" />
  75 + <path
  76 + android:fillColor="#00000000"
  77 + android:pathData="M0,39L108,39"
  78 + android:strokeColor="#33FFFFFF"
  79 + android:strokeWidth="0.8" />
  80 + <path
  81 + android:fillColor="#00000000"
  82 + android:pathData="M0,49L108,49"
  83 + android:strokeColor="#33FFFFFF"
  84 + android:strokeWidth="0.8" />
  85 + <path
  86 + android:fillColor="#00000000"
  87 + android:pathData="M0,59L108,59"
  88 + android:strokeColor="#33FFFFFF"
  89 + android:strokeWidth="0.8" />
  90 + <path
  91 + android:fillColor="#00000000"
  92 + android:pathData="M0,69L108,69"
  93 + android:strokeColor="#33FFFFFF"
  94 + android:strokeWidth="0.8" />
  95 + <path
  96 + android:fillColor="#00000000"
  97 + android:pathData="M0,79L108,79"
  98 + android:strokeColor="#33FFFFFF"
  99 + android:strokeWidth="0.8" />
  100 + <path
  101 + android:fillColor="#00000000"
  102 + android:pathData="M0,89L108,89"
  103 + android:strokeColor="#33FFFFFF"
  104 + android:strokeWidth="0.8" />
  105 + <path
  106 + android:fillColor="#00000000"
  107 + android:pathData="M0,99L108,99"
  108 + android:strokeColor="#33FFFFFF"
  109 + android:strokeWidth="0.8" />
  110 + <path
  111 + android:fillColor="#00000000"
  112 + android:pathData="M19,29L89,29"
  113 + android:strokeColor="#33FFFFFF"
  114 + android:strokeWidth="0.8" />
  115 + <path
  116 + android:fillColor="#00000000"
  117 + android:pathData="M19,39L89,39"
  118 + android:strokeColor="#33FFFFFF"
  119 + android:strokeWidth="0.8" />
  120 + <path
  121 + android:fillColor="#00000000"
  122 + android:pathData="M19,49L89,49"
  123 + android:strokeColor="#33FFFFFF"
  124 + android:strokeWidth="0.8" />
  125 + <path
  126 + android:fillColor="#00000000"
  127 + android:pathData="M19,59L89,59"
  128 + android:strokeColor="#33FFFFFF"
  129 + android:strokeWidth="0.8" />
  130 + <path
  131 + android:fillColor="#00000000"
  132 + android:pathData="M19,69L89,69"
  133 + android:strokeColor="#33FFFFFF"
  134 + android:strokeWidth="0.8" />
  135 + <path
  136 + android:fillColor="#00000000"
  137 + android:pathData="M19,79L89,79"
  138 + android:strokeColor="#33FFFFFF"
  139 + android:strokeWidth="0.8" />
  140 + <path
  141 + android:fillColor="#00000000"
  142 + android:pathData="M29,19L29,89"
  143 + android:strokeColor="#33FFFFFF"
  144 + android:strokeWidth="0.8" />
  145 + <path
  146 + android:fillColor="#00000000"
  147 + android:pathData="M39,19L39,89"
  148 + android:strokeColor="#33FFFFFF"
  149 + android:strokeWidth="0.8" />
  150 + <path
  151 + android:fillColor="#00000000"
  152 + android:pathData="M49,19L49,89"
  153 + android:strokeColor="#33FFFFFF"
  154 + android:strokeWidth="0.8" />
  155 + <path
  156 + android:fillColor="#00000000"
  157 + android:pathData="M59,19L59,89"
  158 + android:strokeColor="#33FFFFFF"
  159 + android:strokeWidth="0.8" />
  160 + <path
  161 + android:fillColor="#00000000"
  162 + android:pathData="M69,19L69,89"
  163 + android:strokeColor="#33FFFFFF"
  164 + android:strokeWidth="0.8" />
  165 + <path
  166 + android:fillColor="#00000000"
  167 + android:pathData="M79,19L79,89"
  168 + android:strokeColor="#33FFFFFF"
  169 + android:strokeWidth="0.8" />
  170 +</vector>
... ...
app/src/main/res/layout/activity_main.xml 0 → 100644
  1 +++ a/app/src/main/res/layout/activity_main.xml
... ... @@ -0,0 +1,18 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:app="http://schemas.android.com/apk/res-auto"
  4 + xmlns:tools="http://schemas.android.com/tools"
  5 + android:layout_width="match_parent"
  6 + android:layout_height="match_parent"
  7 + tools:context="com.shunzhi.parent.ui.MainActivity">
  8 +
  9 + <TextView
  10 + android:layout_width="wrap_content"
  11 + android:layout_height="wrap_content"
  12 + android:text="Hello World!"
  13 + app:layout_constraintBottom_toBottomOf="parent"
  14 + app:layout_constraintLeft_toLeftOf="parent"
  15 + app:layout_constraintRight_toRightOf="parent"
  16 + app:layout_constraintTop_toTopOf="parent" />
  17 +
  18 +</FrameLayout>
... ...
app/src/main/res/layout/activity_regist.xml 0 → 100644
  1 +++ a/app/src/main/res/layout/activity_regist.xml
... ... @@ -0,0 +1,9 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:app="http://schemas.android.com/apk/res-auto"
  4 + xmlns:tools="http://schemas.android.com/tools"
  5 + android:layout_width="match_parent"
  6 + android:layout_height="match_parent"
  7 + tools:context="com.shunzhi.parent.ui.activity.LoginAndRegistActivity">
  8 +
  9 +</android.support.constraint.ConstraintLayout>
... ...
app/src/main/res/layout/activity_start.xml 0 → 100644
  1 +++ a/app/src/main/res/layout/activity_start.xml
... ... @@ -0,0 +1,9 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:app="http://schemas.android.com/apk/res-auto"
  4 + xmlns:tools="http://schemas.android.com/tools"
  5 + android:layout_width="match_parent"
  6 + android:layout_height="match_parent"
  7 + tools:context="com.shunzhi.parent.ui.activity.StartActivity">
  8 +
  9 +</android.support.constraint.ConstraintLayout>
... ...
app/src/main/res/layout/fragment_ce_ping.xml 0 → 100644
  1 +++ a/app/src/main/res/layout/fragment_ce_ping.xml
... ... @@ -0,0 +1,13 @@
  1 +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2 + xmlns:tools="http://schemas.android.com/tools"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="match_parent"
  5 + tools:context="com.shunzhi.parent.ui.fragment.CePingFragment">
  6 +
  7 + <!-- TODO: Update blank fragment layout -->
  8 + <TextView
  9 + android:layout_width="match_parent"
  10 + android:layout_height="match_parent"
  11 + android:text="@string/hello_blank_fragment" />
  12 +
  13 +</FrameLayout>
... ...
app/src/main/res/layout/fragment_login_and_regist.xml 0 → 100644
  1 +++ a/app/src/main/res/layout/fragment_login_and_regist.xml
... ... @@ -0,0 +1,13 @@
  1 +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2 + xmlns:tools="http://schemas.android.com/tools"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="match_parent"
  5 + tools:context="com.shunzhi.parent.ui.fragment.loginandregistfragment.LoginAndRegistFragment">
  6 +
  7 + <!-- TODO: Update blank fragment layout -->
  8 + <TextView
  9 + android:layout_width="match_parent"
  10 + android:layout_height="match_parent"
  11 + android:text="@string/hello_blank_fragment" />
  12 +
  13 +</FrameLayout>
... ...
app/src/main/res/layout/fragment_mine.xml 0 → 100644
  1 +++ a/app/src/main/res/layout/fragment_mine.xml
... ... @@ -0,0 +1,13 @@
  1 +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2 + xmlns:tools="http://schemas.android.com/tools"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="match_parent"
  5 + tools:context="com.shunzhi.parent.ui.fragment.MineFragment">
  6 +
  7 + <!-- TODO: Update blank fragment layout -->
  8 + <TextView
  9 + android:layout_width="match_parent"
  10 + android:layout_height="match_parent"
  11 + android:text="@string/hello_blank_fragment" />
  12 +
  13 +</FrameLayout>
... ...
app/src/main/res/layout/fragment_report.xml 0 → 100644
  1 +++ a/app/src/main/res/layout/fragment_report.xml
... ... @@ -0,0 +1,13 @@
  1 +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2 + xmlns:tools="http://schemas.android.com/tools"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="match_parent"
  5 + tools:context="com.shunzhi.parent.ui.fragment.ReportFragment">
  6 +
  7 + <!-- TODO: Update blank fragment layout -->
  8 + <TextView
  9 + android:layout_width="match_parent"
  10 + android:layout_height="match_parent"
  11 + android:text="@string/hello_blank_fragment" />
  12 +
  13 +</FrameLayout>
... ...
app/src/main/res/layout/fragment_zi_xun.xml 0 → 100644
  1 +++ a/app/src/main/res/layout/fragment_zi_xun.xml
... ... @@ -0,0 +1,13 @@
  1 +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2 + xmlns:tools="http://schemas.android.com/tools"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="match_parent"
  5 + tools:context="com.shunzhi.parent.ui.fragment.ConsultFragment">
  6 +
  7 + <!-- TODO: Update blank fragment layout -->
  8 + <TextView
  9 + android:layout_width="match_parent"
  10 + android:layout_height="match_parent"
  11 + android:text="@string/hello_blank_fragment" />
  12 +
  13 +</FrameLayout>
... ...
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml 0 → 100644
  1 +++ a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
... ... @@ -0,0 +1,5 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
  3 + <background android:drawable="@drawable/ic_launcher_background" />
  4 + <foreground android:drawable="@drawable/ic_launcher_foreground" />
  5 +</adaptive-icon>
0 6 \ No newline at end of file
... ...
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml 0 → 100644
  1 +++ a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
... ... @@ -0,0 +1,5 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
  3 + <background android:drawable="@drawable/ic_launcher_background" />
  4 + <foreground android:drawable="@drawable/ic_launcher_foreground" />
  5 +</adaptive-icon>
0 6 \ No newline at end of file
... ...
app/src/main/res/mipmap-hdpi/ic_launcher.png 0 → 100644

2.98 KB

app/src/main/res/mipmap-hdpi/ic_launcher_round.png 0 → 100644

4.91 KB

app/src/main/res/mipmap-mdpi/ic_launcher.png 0 → 100644

2.05 KB

app/src/main/res/mipmap-mdpi/ic_launcher_round.png 0 → 100644

2.79 KB

app/src/main/res/mipmap-xhdpi/ic_launcher.png 0 → 100644

4.46 KB

app/src/main/res/mipmap-xhdpi/ic_launcher_round.png 0 → 100644

6.93 KB

app/src/main/res/mipmap-xxhdpi/ic_launcher.png 0 → 100644

6.31 KB

app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png 0 → 100644

10.4 KB

app/src/main/res/mipmap-xxxhdpi/ic_launcher.png 0 → 100644

9.03 KB

app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png 0 → 100644

15.2 KB

app/src/main/res/values/colors.xml 0 → 100644
  1 +++ a/app/src/main/res/values/colors.xml
... ... @@ -0,0 +1,6 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<resources>
  3 + <color name="colorPrimary">#3F51B5</color>
  4 + <color name="colorPrimaryDark">#303F9F</color>
  5 + <color name="colorAccent">#FF4081</color>
  6 +</resources>
... ...
app/src/main/res/values/strings.xml 0 → 100644
  1 +++ a/app/src/main/res/values/strings.xml
... ... @@ -0,0 +1,6 @@
  1 +<resources>
  2 + <string name="app_name">parent</string>
  3 +
  4 + <!-- TODO: Remove or change this placeholder text -->
  5 + <string name="hello_blank_fragment">Hello blank fragment</string>
  6 +</resources>
... ...
app/src/main/res/values/styles.xml 0 → 100644
  1 +++ a/app/src/main/res/values/styles.xml
... ... @@ -0,0 +1,11 @@
  1 +<resources>
  2 +
  3 + <!-- Base application theme. -->
  4 + <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
  5 + <!-- Customize your theme here. -->
  6 + <item name="colorPrimary">@color/colorPrimary</item>
  7 + <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
  8 + <item name="colorAccent">@color/colorAccent</item>
  9 + </style>
  10 +
  11 +</resources>
... ...
app/src/test/java/com/shunzhi/parent/ExampleUnitTest.java 0 → 100644
  1 +++ a/app/src/test/java/com/shunzhi/parent/ExampleUnitTest.java
... ... @@ -0,0 +1,17 @@
  1 +package com.shunzhi.parent;
  2 +
  3 +import org.junit.Test;
  4 +
  5 +import static org.junit.Assert.*;
  6 +
  7 +/**
  8 + * Example local unit test, which will execute on the development machine (host).
  9 + *
  10 + * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
  11 + */
  12 +public class ExampleUnitTest {
  13 + @Test
  14 + public void addition_isCorrect() throws Exception {
  15 + assertEquals(4, 2 + 2);
  16 + }
  17 +}
0 18 \ No newline at end of file
... ...
build.gradle 0 → 100644
  1 +++ a/build.gradle
... ... @@ -0,0 +1,66 @@
  1 +// Top-level build file where you can add configuration options common to all sub-projects/modules.
  2 +
  3 +buildscript {
  4 +
  5 + repositories {
  6 + google()
  7 + jcenter()
  8 + }
  9 + dependencies {
  10 + classpath 'com.android.tools.build:gradle:3.0.1'
  11 +
  12 +
  13 + // NOTE: Do not place your application dependencies here; they belong
  14 + // in the individual module build.gradle files
  15 + }
  16 +}
  17 +
  18 +allprojects {
  19 + repositories {
  20 + google()
  21 + jcenter()
  22 + }
  23 +}
  24 +
  25 +task clean(type: Delete) {
  26 + delete rootProject.buildDir
  27 +}
  28 +
  29 +ext {
  30 + // Sdk and tools
  31 + minSdkVersion = 16
  32 + targetSdkVersion = 26
  33 + compileSdkVersion = 26
  34 + buildToolsVersion = '26.0.2'
  35 +
  36 + // App dependencies
  37 + supportLibraryVersion = '26.1.0'
  38 + guavaVersion = '18.0'
  39 + junitVersion = '4.12'
  40 + mockitoVersion = '1.10.19'
  41 + powerMockito = '1.6.2'
  42 + hamcrestVersion = '1.3'
  43 + runnerVersion = '0.4.1'
  44 + rulesVersion = '0.4.1'
  45 + espressoVersion = '2.2.1'
  46 + retrofitVersion = '2.2.0'
  47 + okhttploggingVersion = '3.4.1'
  48 + okhttpVersion = '3.4.1'
  49 + rxjavaVersion = '2.0.1'
  50 + rxandroidVersion = '2.0.1'
  51 + rxbindingVersion = '2.0.0'
  52 + rxPerssionsVersion = '0.9.4@aar'
  53 + glideVersion = '3.6.1'
  54 + glideokhttpVersion = '1.3.1'
  55 + photoviewVersion = '1.2.4'
  56 + butterknifeVersion = '8.4.0'
  57 + fragmentationVersion = '1.1.6'
  58 + loggerVersion = '1.15'
  59 + circleImageviewVersion = '2.1.0'
  60 + BaseRecyclerViewAdapterHelperVersion = '2.9.34'
  61 + SwtichButtonVersion = '1.4.6'
  62 + PhotoViewVersion = '1.4.1'
  63 + BottomSheetVersion = '1.3.0@aar'
  64 + glideTransformationVersion = '2.0.1'
  65 +}
  66 +
... ...
gradle.properties 0 → 100644
  1 +++ a/gradle.properties
... ... @@ -0,0 +1,17 @@
  1 +# Project-wide Gradle settings.
  2 +
  3 +# IDE (e.g. Android Studio) users:
  4 +# Gradle settings configured through the IDE *will override*
  5 +# any settings specified in this file.
  6 +
  7 +# For more details on how to configure your build environment visit
  8 +# http://www.gradle.org/docs/current/userguide/build_environment.html
  9 +
  10 +# Specifies the JVM arguments used for the daemon process.
  11 +# The setting is particularly useful for tweaking memory settings.
  12 +org.gradle.jvmargs=-Xmx1536m
  13 +
  14 +# When configured, Gradle will run in incubating parallel mode.
  15 +# This option should only be used with decoupled projects. More details, visit
  16 +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
  17 +# org.gradle.parallel=true
... ...
gradle/wrapper/gradle-wrapper.jar 0 → 100644
No preview for this file type
gradle/wrapper/gradle-wrapper.properties 0 → 100644
  1 +++ a/gradle/wrapper/gradle-wrapper.properties
... ... @@ -0,0 +1,6 @@
  1 +#Tue Feb 27 14:00:51 CST 2018
  2 +distributionBase=GRADLE_USER_HOME
  3 +distributionPath=wrapper/dists
  4 +zipStoreBase=GRADLE_USER_HOME
  5 +zipStorePath=wrapper/dists
  6 +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
... ...
gradlew 0 → 100644
  1 +++ a/gradlew
... ... @@ -0,0 +1,160 @@
  1 +#!/usr/bin/env bash
  2 +
  3 +##############################################################################
  4 +##
  5 +## Gradle start up script for UN*X
  6 +##
  7 +##############################################################################
  8 +
  9 +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
  10 +DEFAULT_JVM_OPTS=""
  11 +
  12 +APP_NAME="Gradle"
  13 +APP_BASE_NAME=`basename "$0"`
  14 +
  15 +# Use the maximum available, or set MAX_FD != -1 to use that value.
  16 +MAX_FD="maximum"
  17 +
  18 +warn ( ) {
  19 + echo "$*"
  20 +}
  21 +
  22 +die ( ) {
  23 + echo
  24 + echo "$*"
  25 + echo
  26 + exit 1
  27 +}
  28 +
  29 +# OS specific support (must be 'true' or 'false').
  30 +cygwin=false
  31 +msys=false
  32 +darwin=false
  33 +case "`uname`" in
  34 + CYGWIN* )
  35 + cygwin=true
  36 + ;;
  37 + Darwin* )
  38 + darwin=true
  39 + ;;
  40 + MINGW* )
  41 + msys=true
  42 + ;;
  43 +esac
  44 +
  45 +# Attempt to set APP_HOME
  46 +# Resolve links: $0 may be a link
  47 +PRG="$0"
  48 +# Need this for relative symlinks.
  49 +while [ -h "$PRG" ] ; do
  50 + ls=`ls -ld "$PRG"`
  51 + link=`expr "$ls" : '.*-> \(.*\)$'`
  52 + if expr "$link" : '/.*' > /dev/null; then
  53 + PRG="$link"
  54 + else
  55 + PRG=`dirname "$PRG"`"/$link"
  56 + fi
  57 +done
  58 +SAVED="`pwd`"
  59 +cd "`dirname \"$PRG\"`/" >/dev/null
  60 +APP_HOME="`pwd -P`"
  61 +cd "$SAVED" >/dev/null
  62 +
  63 +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
  64 +
  65 +# Determine the Java command to use to start the JVM.
  66 +if [ -n "$JAVA_HOME" ] ; then
  67 + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
  68 + # IBM's JDK on AIX uses strange locations for the executables
  69 + JAVACMD="$JAVA_HOME/jre/sh/java"
  70 + else
  71 + JAVACMD="$JAVA_HOME/bin/java"
  72 + fi
  73 + if [ ! -x "$JAVACMD" ] ; then
  74 + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
  75 +
  76 +Please set the JAVA_HOME variable in your environment to match the
  77 +location of your Java installation."
  78 + fi
  79 +else
  80 + JAVACMD="java"
  81 + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
  82 +
  83 +Please set the JAVA_HOME variable in your environment to match the
  84 +location of your Java installation."
  85 +fi
  86 +
  87 +# Increase the maximum file descriptors if we can.
  88 +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
  89 + MAX_FD_LIMIT=`ulimit -H -n`
  90 + if [ $? -eq 0 ] ; then
  91 + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
  92 + MAX_FD="$MAX_FD_LIMIT"
  93 + fi
  94 + ulimit -n $MAX_FD
  95 + if [ $? -ne 0 ] ; then
  96 + warn "Could not set maximum file descriptor limit: $MAX_FD"
  97 + fi
  98 + else
  99 + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
  100 + fi
  101 +fi
  102 +
  103 +# For Darwin, add options to specify how the application appears in the dock
  104 +if $darwin; then
  105 + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
  106 +fi
  107 +
  108 +# For Cygwin, switch paths to Windows format before running java
  109 +if $cygwin ; then
  110 + APP_HOME=`cygpath --path --mixed "$APP_HOME"`
  111 + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
  112 + JAVACMD=`cygpath --unix "$JAVACMD"`
  113 +
  114 + # We build the pattern for arguments to be converted via cygpath
  115 + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
  116 + SEP=""
  117 + for dir in $ROOTDIRSRAW ; do
  118 + ROOTDIRS="$ROOTDIRS$SEP$dir"
  119 + SEP="|"
  120 + done
  121 + OURCYGPATTERN="(^($ROOTDIRS))"
  122 + # Add a user-defined pattern to the cygpath arguments
  123 + if [ "$GRADLE_CYGPATTERN" != "" ] ; then
  124 + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
  125 + fi
  126 + # Now convert the arguments - kludge to limit ourselves to /bin/sh
  127 + i=0
  128 + for arg in "$@" ; do
  129 + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
  130 + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
  131 +
  132 + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
  133 + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
  134 + else
  135 + eval `echo args$i`="\"$arg\""
  136 + fi
  137 + i=$((i+1))
  138 + done
  139 + case $i in
  140 + (0) set -- ;;
  141 + (1) set -- "$args0" ;;
  142 + (2) set -- "$args0" "$args1" ;;
  143 + (3) set -- "$args0" "$args1" "$args2" ;;
  144 + (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
  145 + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
  146 + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
  147 + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
  148 + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
  149 + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
  150 + esac
  151 +fi
  152 +
  153 +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
  154 +function splitJvmOpts() {
  155 + JVM_OPTS=("$@")
  156 +}
  157 +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
  158 +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
  159 +
  160 +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
... ...
gradlew.bat 0 → 100644
  1 +++ a/gradlew.bat
... ... @@ -0,0 +1,90 @@
  1 +@if "%DEBUG%" == "" @echo off
  2 +@rem ##########################################################################
  3 +@rem
  4 +@rem Gradle startup script for Windows
  5 +@rem
  6 +@rem ##########################################################################
  7 +
  8 +@rem Set local scope for the variables with windows NT shell
  9 +if "%OS%"=="Windows_NT" setlocal
  10 +
  11 +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
  12 +set DEFAULT_JVM_OPTS=
  13 +
  14 +set DIRNAME=%~dp0
  15 +if "%DIRNAME%" == "" set DIRNAME=.
  16 +set APP_BASE_NAME=%~n0
  17 +set APP_HOME=%DIRNAME%
  18 +
  19 +@rem Find java.exe
  20 +if defined JAVA_HOME goto findJavaFromJavaHome
  21 +
  22 +set JAVA_EXE=java.exe
  23 +%JAVA_EXE% -version >NUL 2>&1
  24 +if "%ERRORLEVEL%" == "0" goto init
  25 +
  26 +echo.
  27 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
  28 +echo.
  29 +echo Please set the JAVA_HOME variable in your environment to match the
  30 +echo location of your Java installation.
  31 +
  32 +goto fail
  33 +
  34 +:findJavaFromJavaHome
  35 +set JAVA_HOME=%JAVA_HOME:"=%
  36 +set JAVA_EXE=%JAVA_HOME%/bin/java.exe
  37 +
  38 +if exist "%JAVA_EXE%" goto init
  39 +
  40 +echo.
  41 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
  42 +echo.
  43 +echo Please set the JAVA_HOME variable in your environment to match the
  44 +echo location of your Java installation.
  45 +
  46 +goto fail
  47 +
  48 +:init
  49 +@rem Get command-line arguments, handling Windowz variants
  50 +
  51 +if not "%OS%" == "Windows_NT" goto win9xME_args
  52 +if "%@eval[2+2]" == "4" goto 4NT_args
  53 +
  54 +:win9xME_args
  55 +@rem Slurp the command line arguments.
  56 +set CMD_LINE_ARGS=
  57 +set _SKIP=2
  58 +
  59 +:win9xME_args_slurp
  60 +if "x%~1" == "x" goto execute
  61 +
  62 +set CMD_LINE_ARGS=%*
  63 +goto execute
  64 +
  65 +:4NT_args
  66 +@rem Get arguments from the 4NT Shell from JP Software
  67 +set CMD_LINE_ARGS=%$
  68 +
  69 +:execute
  70 +@rem Setup the command line
  71 +
  72 +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
  73 +
  74 +@rem Execute Gradle
  75 +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
  76 +
  77 +:end
  78 +@rem End local scope for the variables with windows NT shell
  79 +if "%ERRORLEVEL%"=="0" goto mainEnd
  80 +
  81 +:fail
  82 +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
  83 +rem the _cmd.exe /c_ return code!
  84 +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
  85 +exit /b 1
  86 +
  87 +:mainEnd
  88 +if "%OS%"=="Windows_NT" endlocal
  89 +
  90 +:omega
... ...
mvpsdk/.gitignore 0 → 100644
  1 +++ a/mvpsdk/.gitignore
... ... @@ -0,0 +1 @@
  1 +/build
... ...
mvpsdk/build.gradle 0 → 100644
  1 +++ a/mvpsdk/build.gradle
... ... @@ -0,0 +1,102 @@
  1 +apply plugin: 'com.android.library'
  2 +
  3 +android {
  4 + compileSdkVersion rootProject.ext.compileSdkVersion
  5 + buildToolsVersion rootProject.ext.buildToolsVersion
  6 +
  7 +
  8 + defaultConfig {
  9 + minSdkVersion rootProject.ext.minSdkVersion
  10 + targetSdkVersion rootProject.ext.targetSdkVersion
  11 + versionCode 1
  12 + versionName "1.0"
  13 +
  14 + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  15 +
  16 + }
  17 +
  18 + buildTypes {
  19 + def BOOLEAN = "boolean"
  20 + def TRUE = "true"
  21 + def FALSE = "false"
  22 + def IS_SHOW_LOG = "IS_SHOW_LOG"
  23 +
  24 + release {
  25 + minifyEnabled false
  26 + buildConfigField BOOLEAN, IS_SHOW_LOG, FALSE
  27 + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  28 + }
  29 + }
  30 + publishNonDefault true
  31 +}
  32 +//repositories {
  33 +// flatDir {
  34 +// dirs 'libs' //this way we can find the .aar file in libs folder
  35 +// }
  36 +// google()
  37 +//}
  38 +dependencies {
  39 + implementation fileTree(dir: 'libs', include: ['*.jar'])
  40 +
  41 + implementation 'com.android.support:appcompat-v7:26.1.0'
  42 + testImplementation 'junit:junit:4.12'
  43 + androidTestImplementation 'com.android.support.test:runner:1.0.1'
  44 + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
  45 +
  46 + // Android support
  47 + compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
  48 + compile "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
  49 + compile "com.android.support:design:$rootProject.supportLibraryVersion"
  50 + compile "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
  51 +
  52 + // Retrofit
  53 + compile "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
  54 + compile "com.squareup.retrofit2:converter-gson:$rootProject.retrofitVersion"
  55 + compile "com.squareup.retrofit2:adapter-rxjava2:$rootProject.retrofitVersion"
  56 + compile "com.squareup.okhttp3:logging-interceptor:$rootProject.okhttploggingVersion"
  57 + compile "com.squareup.okhttp3:okhttp:$rootProject.okhttpVersion"
  58 +
  59 + // RxJava
  60 + compile "io.reactivex.rxjava2:rxjava:$rootProject.rxjavaVersion"
  61 + compile "io.reactivex.rxjava2:rxandroid:$rootProject.rxandroidVersion"
  62 + compile "com.jakewharton.rxbinding2:rxbinding:$rootProject.rxbindingVersion"
  63 +
  64 + // Glide
  65 + compile "com.github.bumptech.glide:glide:$rootProject.glideVersion"
  66 + compile "com.github.bumptech.glide:okhttp-integration:$rootProject.glideokhttpVersion"
  67 + compile "jp.wasabeef:glide-transformations:$rootProject.glideTransformationVersion"
  68 +
  69 + //Butterknife
  70 + compile "com.jakewharton:butterknife:$rootProject.butterknifeVersion"
  71 + annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
  72 +
  73 + //fragmentation
  74 + compile "me.yokeyword:fragmentation:$rootProject.fragmentationVersion"
  75 +
  76 + //Logger
  77 + compile "com.orhanobut:logger:$rootProject.loggerVersion"
  78 +
  79 + //circle imageview
  80 + compile "de.hdodenhof:circleimageview:$rootProject.circleImageviewVersion"
  81 +
  82 + //BaseRecyclerViewAdapterHelper
  83 + compile "com.github.CymChad:BaseRecyclerViewAdapterHelper:$rootProject.BaseRecyclerViewAdapterHelperVersion"
  84 +
  85 + //SwitchButton
  86 + compile "com.kyleduo.switchbutton:library:$rootProject.SwtichButtonVersion"
  87 +
  88 + //PhotoView
  89 + compile "com.bm.photoview:library:$rootProject.PhotoViewVersion"
  90 +
  91 + compile "com.cocosw:bottomsheet:$rootProject.BottomSheetVersion"
  92 +
  93 + //permissions
  94 + compile "com.tbruyelle.rxpermissions2:rxpermissions:$rootProject.rxPerssionsVersion"
  95 +
  96 + //timber
  97 + compile 'com.jakewharton.timber:timber:4.5.1'
  98 +
  99 + //jiaozivideoplayer
  100 + compile 'cn.jzvd:jiaozivideoplayer:6.2.7'
  101 +// compile(name: 'jiaozivideoplayer-6.2.3', ext: 'aar')
  102 +}
... ...
mvpsdk/proguard-rules.pro 0 → 100644
  1 +++ a/mvpsdk/proguard-rules.pro
... ... @@ -0,0 +1,21 @@
  1 +# Add project specific ProGuard rules here.
  2 +# You can control the set of applied configuration files using the
  3 +# proguardFiles setting in build.gradle.
  4 +#
  5 +# For more details, see
  6 +# http://developer.android.com/guide/developing/tools/proguard.html
  7 +
  8 +# If your project uses WebView with JS, uncomment the following
  9 +# and specify the fully qualified class name to the JavaScript interface
  10 +# class:
  11 +#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
  12 +# public *;
  13 +#}
  14 +
  15 +# Uncomment this to preserve the line number information for
  16 +# debugging stack traces.
  17 +#-keepattributes SourceFile,LineNumberTable
  18 +
  19 +# If you keep the line number information, uncomment this to
  20 +# hide the original source file name.
  21 +#-renamesourcefileattribute SourceFile
... ...
mvpsdk/src/androidTest/java/com/share/mvpsdk/ExampleInstrumentedTest.java 0 → 100644
  1 +++ a/mvpsdk/src/androidTest/java/com/share/mvpsdk/ExampleInstrumentedTest.java
... ... @@ -0,0 +1,26 @@
  1 +package com.share.mvpsdk;
  2 +
  3 +import android.content.Context;
  4 +import android.support.test.InstrumentationRegistry;
  5 +import android.support.test.runner.AndroidJUnit4;
  6 +
  7 +import org.junit.Test;
  8 +import org.junit.runner.RunWith;
  9 +
  10 +import static org.junit.Assert.*;
  11 +
  12 +/**
  13 + * Instrumented test, which will execute on an Android device.
  14 + *
  15 + * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
  16 + */
  17 +@RunWith(AndroidJUnit4.class)
  18 +public class ExampleInstrumentedTest {
  19 + @Test
  20 + public void useAppContext() throws Exception {
  21 + // Context of the app under test.
  22 + Context appContext = InstrumentationRegistry.getTargetContext();
  23 +
  24 + assertEquals("com.share.mvpsdk.test", appContext.getPackageName());
  25 + }
  26 +}
... ...
mvpsdk/src/main/AndroidManifest.xml 0 → 100644
  1 +++ a/mvpsdk/src/main/AndroidManifest.xml
... ... @@ -0,0 +1,2 @@
  1 +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  2 + package="com.share.mvpsdk" />
... ...
mvpsdk/src/main/java/com/share/mvpsdk/AppManager.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/AppManager.java
... ... @@ -0,0 +1,111 @@
  1 +package com.share.mvpsdk;
  2 +
  3 +import android.annotation.SuppressLint;
  4 +import android.app.Activity;
  5 +import android.app.ActivityManager;
  6 +import android.content.Context;
  7 +
  8 +import java.util.Stack;
  9 +
  10 +/**
  11 + * Created by Horrarndoo on 2017/4/5.
  12 + * <p>
  13 + * AppManager 管理Activity栈
  14 + */
  15 +
  16 +public class AppManager {
  17 + private static Stack<Activity> activityStack;
  18 + private static AppManager instance;
  19 +
  20 + private AppManager() {
  21 + }
  22 +
  23 + /**
  24 + * 单一实例
  25 + */
  26 + public static AppManager getAppManager() {
  27 + if (instance == null) {
  28 + instance = new AppManager();
  29 + }
  30 + return instance;
  31 + }
  32 +
  33 + /**
  34 + * 添加Activity到堆栈
  35 + */
  36 + public void addActivity(Activity activity) {
  37 + if (activityStack == null) {
  38 + activityStack = new Stack<Activity>();
  39 + }
  40 + activityStack.add(activity);
  41 + }
  42 +
  43 + /**
  44 + * 获取当前Activity(堆栈中最后一个压入的)
  45 + */
  46 + public Activity currentActivity() {
  47 + Activity activity = activityStack.lastElement();
  48 + return activity;
  49 + }
  50 +
  51 + /**
  52 + * 结束当前Activity(堆栈中最后一个压入的)
  53 + */
  54 + public void finishActivity() {
  55 + Activity activity = activityStack.lastElement();
  56 + finishActivity(activity);
  57 + }
  58 +
  59 + /**
  60 + * 结束指定的Activity
  61 + */
  62 + public void finishActivity(Activity activity) {
  63 + if (activity != null) {
  64 + activityStack.remove(activity);
  65 + activity.finish();
  66 + activity = null;
  67 + }
  68 + }
  69 +
  70 + /**
  71 + * 结束指定类名的Activity
  72 + */
  73 + public void finishActivity(Class<?> cls) {
  74 + for (Activity activity : activityStack) {
  75 + if (activity.getClass().equals(cls)) {
  76 + finishActivity(activity);
  77 + }
  78 + }
  79 + }
  80 +
  81 + /**
  82 + * 结束所有Activity
  83 + */
  84 + public void finishAllActivity() {
  85 + for (int i = 0, size = activityStack.size(); i < size; i++) {
  86 + if (null != activityStack.get(i)) {
  87 + activityStack.get(i).finish();
  88 + }
  89 + }
  90 + activityStack.clear();
  91 + }
  92 +
  93 + /**
  94 + * 退出应用程序
  95 + */
  96 + @SuppressLint("MissingPermission")
  97 + public void AppExit(Context context) {
  98 + try {
  99 + finishAllActivity();
  100 + ActivityManager activityMgr =
  101 + (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
  102 + activityMgr.killBackgroundProcesses(context.getPackageName());
  103 + System.exit(0);
  104 + } catch (Exception e) {
  105 + }
  106 + }
  107 +
  108 + public boolean isAppExit() {
  109 + return activityStack == null || activityStack.isEmpty();
  110 + }
  111 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/RxManager.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/RxManager.java
... ... @@ -0,0 +1,23 @@
  1 +package com.share.mvpsdk;
  2 +
  3 +
  4 +import io.reactivex.disposables.CompositeDisposable;
  5 +import io.reactivex.disposables.Disposable;
  6 +
  7 +/**
  8 + * Created by Horrarndoo on 2017/9/12.
  9 + * <p>
  10 + * 用于管理Rxjava 注册订阅和取消订阅
  11 + */
  12 +
  13 +public class RxManager {
  14 + private CompositeDisposable mCompositeDisposable = new CompositeDisposable();// 管理订阅者者
  15 +
  16 + public void register(Disposable d) {
  17 + mCompositeDisposable.add(d);
  18 + }
  19 +
  20 + public void unSubscribe() {
  21 + mCompositeDisposable.dispose();// 取消订阅
  22 + }
  23 +}
0 24 \ No newline at end of file
... ...
mvpsdk/src/main/java/com/share/mvpsdk/adapter/FragmentAdapter.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/adapter/FragmentAdapter.java
... ... @@ -0,0 +1,42 @@
  1 +package com.share.mvpsdk.adapter;
  2 +
  3 +
  4 +import android.support.v4.app.Fragment;
  5 +import android.support.v4.app.FragmentManager;
  6 +import android.support.v4.app.FragmentStatePagerAdapter;
  7 +import android.support.v4.view.PagerAdapter;
  8 +import android.view.ViewGroup;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * Created by Horrarndoo on 2017/9/7.
  14 + * <p>
  15 + */
  16 +public class FragmentAdapter extends FragmentStatePagerAdapter {
  17 + private List<Fragment> fragments;
  18 +
  19 + public FragmentAdapter(FragmentManager fm, List<Fragment> fragments) {
  20 + super(fm);
  21 + this.fragments = fragments;
  22 + }
  23 +
  24 + @Override
  25 + public Fragment getItem(int position) {
  26 + return fragments.get(position);
  27 + }
  28 +
  29 + @Override
  30 + public int getCount() {
  31 + return fragments == null ? 0 : fragments.size();
  32 + }
  33 +
  34 + public int getItemPosition(Object object) {
  35 + return PagerAdapter.POSITION_NONE;
  36 + }
  37 +
  38 + @Override
  39 + public void destroyItem(ViewGroup container, int position, Object object) {
  40 + // super.destroyItem(container, position, object);
  41 + }
  42 +}
0 43 \ No newline at end of file
... ...
mvpsdk/src/main/java/com/share/mvpsdk/anim/AnimManager.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/anim/AnimManager.java
... ... @@ -0,0 +1,75 @@
  1 +package com.share.mvpsdk.anim;
  2 +
  3 +import android.content.Context;
  4 +import android.os.Build;
  5 +import android.support.annotation.NonNull;
  6 +import android.view.View;
  7 +import android.view.animation.AnimationUtils;
  8 +
  9 +/**
  10 + * Created by Horrarndoo on 2017/9/11.
  11 + * <p>
  12 + */
  13 +
  14 +public class AnimManager {
  15 + /**
  16 + * Alpha and scaleX 动画
  17 + * Alpha 0->1
  18 + * ScaleX 0.8->1
  19 + *
  20 + * @param context context
  21 + * @param view view
  22 + * @param startDelay 动画开始前延时(ms)
  23 + * @param duration 动画持续时间(ms)
  24 + */
  25 + public static void animAlphaAndScaleX(Context context, @NonNull View view, int startDelay, int
  26 + duration) {
  27 + view.setAlpha(0f);
  28 + view.setScaleX(0.8f);
  29 +
  30 + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  31 + view.animate()
  32 + .alpha(1f)
  33 + .scaleX(1f)
  34 + .setStartDelay(startDelay)
  35 + .setDuration(duration)
  36 + .setInterpolator(AnimUtils.getFastOutSlowInInterpolator(context))
  37 + .start();
  38 + }else{
  39 + view.animate()
  40 + .alpha(1f)
  41 + .scaleX(1f)
  42 + .setStartDelay(startDelay)
  43 + .setDuration(duration)
  44 + .setInterpolator(AnimationUtils.loadInterpolator(context, android.R.interpolator.linear))
  45 + .start();
  46 + }
  47 + }
  48 +
  49 + /**
  50 + * Alpha and scale X Y 动画
  51 + * Alpha 0->1
  52 + * ScaleX 0->1
  53 + * ScaleY 0->1
  54 + *
  55 + * @param context context
  56 + * @param view view
  57 + * @param startDelay 动画开始前延时(ms)
  58 + * @param duration 动画持续时间(ms)
  59 + */
  60 + public static void animAlphaAndScale(Context context, @NonNull View view, int startDelay, int
  61 + duration) {
  62 + view.setAlpha(0f);
  63 + view.setScaleX(0f);
  64 + view.setScaleY(0f);
  65 +
  66 + view.animate()
  67 + .alpha(1f)
  68 + .scaleX(1f)
  69 + .scaleY(1f)
  70 + .setStartDelay(startDelay)
  71 + .setDuration(duration)
  72 + .setInterpolator(AnimationUtils.loadInterpolator(context,
  73 + android.R.interpolator.overshoot)).start();
  74 + }
  75 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/anim/AnimUtils.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/anim/AnimUtils.java
... ... @@ -0,0 +1,330 @@
  1 +/*
  2 + * Copyright 2015 Google Inc.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +
  17 +package com.share.mvpsdk.anim;
  18 +
  19 +import android.animation.Animator;
  20 +import android.animation.TimeInterpolator;
  21 +import android.content.Context;
  22 +import android.os.Build;
  23 +import android.support.annotation.RequiresApi;
  24 +import android.transition.Transition;
  25 +import android.util.ArrayMap;
  26 +import android.util.Property;
  27 +import android.view.animation.AnimationUtils;
  28 +import android.view.animation.Interpolator;
  29 +
  30 +import java.util.ArrayList;
  31 +
  32 +/**
  33 + * Utility methods for working with animations.
  34 + */
  35 +public class AnimUtils {
  36 +
  37 + private AnimUtils() { }
  38 +
  39 + private static Interpolator fastOutSlowIn;
  40 + private static Interpolator fastOutLinearIn;
  41 + private static Interpolator linearOutSlowIn;
  42 +
  43 + public static Interpolator getFastOutSlowInInterpolator(Context context) {
  44 + if (fastOutSlowIn == null) {
  45 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  46 + fastOutSlowIn = AnimationUtils.loadInterpolator(context,
  47 + android.R.interpolator.fast_out_slow_in);
  48 + }
  49 + }
  50 + return fastOutSlowIn;
  51 + }
  52 +
  53 + public static Interpolator getFastOutLinearInInterpolator(Context context) {
  54 + if (fastOutLinearIn == null) {
  55 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  56 + fastOutLinearIn = AnimationUtils.loadInterpolator(context,
  57 + android.R.interpolator.fast_out_linear_in);
  58 + }
  59 + }
  60 + return fastOutLinearIn;
  61 + }
  62 +
  63 + public static Interpolator getLinearOutSlowInInterpolator(Context context) {
  64 + if (linearOutSlowIn == null) {
  65 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  66 + linearOutSlowIn = AnimationUtils.loadInterpolator(context,
  67 + android.R.interpolator.linear_out_slow_in);
  68 + }
  69 + }
  70 + return linearOutSlowIn;
  71 + }
  72 +
  73 + /**
  74 + * Linear interpolate between a and b with parameter t.
  75 + */
  76 + public static float lerp(float a, float b, float t) {
  77 + return a + (b - a) * t;
  78 + }
  79 +
  80 +
  81 + /**
  82 + * An implementation of {@link Property} to be used specifically with fields of
  83 + * type
  84 + * <code>float</code>. This type-specific subclass enables performance benefit by allowing
  85 + * calls to a {@link #set(Object, Float) set()} function that takes the primitive
  86 + * <code>float</code> type and avoids autoboxing and other overhead associated with the
  87 + * <code>Float</code> class.
  88 + *
  89 + * @param <T> The class on which the Property is declared.
  90 + **/
  91 + public static abstract class FloatProperty<T> extends Property<T, Float> {
  92 + public FloatProperty(String name) {
  93 + super(Float.class, name);
  94 + }
  95 +
  96 + /**
  97 + * A type-specific override of the {@link #set(Object, Float)} that is faster when dealing
  98 + * with fields of type <code>float</code>.
  99 + */
  100 + public abstract void setValue(T object, float value);
  101 +
  102 + @Override
  103 + final public void set(T object, Float value) {
  104 + setValue(object, value);
  105 + }
  106 + }
  107 +
  108 + /**
  109 + * An implementation of {@link Property} to be used specifically with fields of
  110 + * type
  111 + * <code>int</code>. This type-specific subclass enables performance benefit by allowing
  112 + * calls to a {@link #set(Object, Integer) set()} function that takes the primitive
  113 + * <code>int</code> type and avoids autoboxing and other overhead associated with the
  114 + * <code>Integer</code> class.
  115 + *
  116 + * @param <T> The class on which the Property is declared.
  117 + */
  118 + public static abstract class IntProperty<T> extends Property<T, Integer> {
  119 +
  120 + public IntProperty(String name) {
  121 + super(Integer.class, name);
  122 + }
  123 +
  124 + /**
  125 + * A type-specific override of the {@link #set(Object, Integer)} that is faster when dealing
  126 + * with fields of type <code>int</code>.
  127 + */
  128 + public abstract void setValue(T object, int value);
  129 +
  130 + @Override
  131 + final public void set(T object, Integer value) {
  132 + setValue(object, value.intValue());
  133 + }
  134 +
  135 + }
  136 +
  137 + /**
  138 + * https://halfthought.wordpress.com/2014/11/07/reveal-transition/
  139 + * <p/>
  140 + * Interrupting Activity transitions can yield an OperationNotSupportedException when the
  141 + * transition tries to pause the animator. Yikes! We can fix this by wrapping the Animator:
  142 + */
  143 + @RequiresApi(api = Build.VERSION_CODES.KITKAT)
  144 + public static class NoPauseAnimator extends Animator {
  145 + private final Animator mAnimator;
  146 + private final ArrayMap<AnimatorListener, AnimatorListener> mListeners =
  147 + new ArrayMap<AnimatorListener, AnimatorListener>();
  148 +
  149 + public NoPauseAnimator(Animator animator) {
  150 + mAnimator = animator;
  151 + }
  152 +
  153 + @RequiresApi(api = Build.VERSION_CODES.KITKAT)
  154 + @Override
  155 + public void addListener(AnimatorListener listener) {
  156 + AnimatorListener wrapper = new AnimatorListenerWrapper(this, listener);
  157 + if (!mListeners.containsKey(listener)) {
  158 + mListeners.put(listener, wrapper);
  159 + mAnimator.addListener(wrapper);
  160 + }
  161 + }
  162 +
  163 + @Override
  164 + public void cancel() {
  165 + mAnimator.cancel();
  166 + }
  167 +
  168 + @Override
  169 + public void end() {
  170 + mAnimator.end();
  171 + }
  172 +
  173 + @Override
  174 + public long getDuration() {
  175 + return mAnimator.getDuration();
  176 + }
  177 +
  178 + @Override
  179 + public TimeInterpolator getInterpolator() {
  180 + return mAnimator.getInterpolator();
  181 + }
  182 +
  183 + @Override
  184 + public void setInterpolator(TimeInterpolator timeInterpolator) {
  185 + mAnimator.setInterpolator(timeInterpolator);
  186 + }
  187 +
  188 + @Override
  189 + public ArrayList<AnimatorListener> getListeners() {
  190 + return new ArrayList<AnimatorListener>(mListeners.keySet());
  191 + }
  192 +
  193 + @Override
  194 + public long getStartDelay() {
  195 + return mAnimator.getStartDelay();
  196 + }
  197 +
  198 + @Override
  199 + public void setStartDelay(long delayMS) {
  200 + mAnimator.setStartDelay(delayMS);
  201 + }
  202 +
  203 + @Override
  204 + public boolean isPaused() {
  205 + return mAnimator.isPaused();
  206 + }
  207 +
  208 + @Override
  209 + public boolean isRunning() {
  210 + return mAnimator.isRunning();
  211 + }
  212 +
  213 + @Override
  214 + public boolean isStarted() {
  215 + return mAnimator.isStarted();
  216 + }
  217 +
  218 + /* We don't want to override pause or resume methods because we don't want them
  219 + * to affect mAnimator.
  220 + public void pause();
  221 +
  222 + public void resume();
  223 +
  224 + public void addPauseListener(AnimatorPauseListener listener);
  225 +
  226 + public void removePauseListener(AnimatorPauseListener listener);
  227 + */
  228 +
  229 + @Override
  230 + public void removeAllListeners() {
  231 + mListeners.clear();
  232 + mAnimator.removeAllListeners();
  233 + }
  234 +
  235 + @Override
  236 + public void removeListener(AnimatorListener listener) {
  237 + AnimatorListener wrapper = mListeners.get(listener);
  238 + if (wrapper != null) {
  239 + mListeners.remove(listener);
  240 + mAnimator.removeListener(wrapper);
  241 + }
  242 + }
  243 +
  244 + @Override
  245 + public Animator setDuration(long durationMS) {
  246 + mAnimator.setDuration(durationMS);
  247 + return this;
  248 + }
  249 +
  250 + @Override
  251 + public void setTarget(Object target) {
  252 + mAnimator.setTarget(target);
  253 + }
  254 +
  255 + @Override
  256 + public void setupEndValues() {
  257 + mAnimator.setupEndValues();
  258 + }
  259 +
  260 + @Override
  261 + public void setupStartValues() {
  262 + mAnimator.setupStartValues();
  263 + }
  264 +
  265 + @Override
  266 + public void start() {
  267 + mAnimator.start();
  268 + }
  269 + }
  270 +
  271 + static class AnimatorListenerWrapper implements Animator.AnimatorListener {
  272 + private final Animator mAnimator;
  273 + private final Animator.AnimatorListener mListener;
  274 +
  275 + public AnimatorListenerWrapper(Animator animator, Animator.AnimatorListener listener) {
  276 + mAnimator = animator;
  277 + mListener = listener;
  278 + }
  279 +
  280 + @Override
  281 + public void onAnimationStart(Animator animator) {
  282 + mListener.onAnimationStart(mAnimator);
  283 + }
  284 +
  285 + @Override
  286 + public void onAnimationEnd(Animator animator) {
  287 + mListener.onAnimationEnd(mAnimator);
  288 + }
  289 +
  290 + @Override
  291 + public void onAnimationCancel(Animator animator) {
  292 + mListener.onAnimationCancel(mAnimator);
  293 + }
  294 +
  295 + @Override
  296 + public void onAnimationRepeat(Animator animator) {
  297 + mListener.onAnimationRepeat(mAnimator);
  298 + }
  299 + }
  300 +
  301 + @RequiresApi(api = Build.VERSION_CODES.KITKAT)
  302 + public static class TransitionListenerAdapter implements Transition.TransitionListener {
  303 +
  304 + @Override
  305 + public void onTransitionStart(Transition transition) {
  306 +
  307 + }
  308 +
  309 + @Override
  310 + public void onTransitionEnd(Transition transition) {
  311 +
  312 + }
  313 +
  314 + @Override
  315 + public void onTransitionCancel(Transition transition) {
  316 +
  317 + }
  318 +
  319 + @Override
  320 + public void onTransitionPause(Transition transition) {
  321 +
  322 + }
  323 +
  324 + @Override
  325 + public void onTransitionResume(Transition transition) {
  326 +
  327 + }
  328 + }
  329 +
  330 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/anim/ToolbarAnimManager.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/anim/ToolbarAnimManager.java
... ... @@ -0,0 +1,93 @@
  1 +package com.share.mvpsdk.anim;
  2 +
  3 +import android.content.Context;
  4 +import android.support.annotation.NonNull;
  5 +import android.support.v7.widget.ActionMenuView;
  6 +import android.support.v7.widget.Toolbar;
  7 +import android.view.View;
  8 +import android.widget.ImageButton;
  9 +import android.widget.TextView;
  10 +
  11 +/**
  12 + * Created by Horrarndoo on 2017/9/11.
  13 + * <p>
  14 + * Toolbar动画Manager
  15 + */
  16 +
  17 +public class ToolbarAnimManager {
  18 + /**
  19 + * Toolbar 进场动画
  20 + * <p>
  21 + * Textview&ActionMenuView渐变动画
  22 + *
  23 + * @param context context
  24 + * @param toolbar toolbar
  25 + */
  26 + public static void animIn(Context context, @NonNull Toolbar toolbar) {
  27 + ImageButton ibIcon = null;
  28 + TextView tvTitle = null;
  29 + ActionMenuView amvTheme = null;
  30 + int childCount = toolbar.getChildCount();
  31 + for (int i = 0; i < childCount; i++) {
  32 + View child = toolbar.getChildAt(i);
  33 + if(child instanceof ImageButton) {
  34 + ibIcon = (ImageButton) child;
  35 + continue;
  36 + }
  37 +
  38 + if (child instanceof ActionMenuView) {
  39 + amvTheme = (ActionMenuView) child;
  40 + continue;
  41 + }
  42 +
  43 + if (child instanceof TextView)
  44 + tvTitle = (TextView) child;
  45 + }
  46 +
  47 + if(ibIcon != null)
  48 + animNavigationIcon(context, ibIcon);
  49 +
  50 + if(tvTitle != null)
  51 + animTitle(context, tvTitle);
  52 +
  53 + if(amvTheme != null)
  54 + animMenu(context, amvTheme);
  55 + }
  56 +
  57 + /**
  58 + * Toolbar Title动画
  59 + * <p>
  60 + * NavigationIcon渐变动画
  61 + *
  62 + * @param context context
  63 + * @param imageButton 执行动画的view
  64 + */
  65 + public static void animNavigationIcon(Context context, @NonNull ImageButton imageButton) {
  66 + AnimManager.animAlphaAndScaleX(context, imageButton, 500, 900);
  67 + }
  68 +
  69 + /**
  70 + * Toolbar Title动画
  71 + * <p>
  72 + * ActionMenuView渐变动画
  73 + *
  74 + * @param context context
  75 + * @param textView 执行动画的view
  76 + */
  77 + public static void animTitle(Context context, @NonNull TextView textView) {
  78 + AnimManager.animAlphaAndScaleX(context, textView, 500, 900);
  79 + }
  80 +
  81 + /**
  82 + * Toolbar ActionMenuView动画
  83 + * <p>
  84 + * ActionMenuView渐变动画
  85 + *
  86 + * @param context context
  87 + * @param avm 执行动画的view
  88 + */
  89 + public static void animMenu(Context context, @NonNull ActionMenuView avm) {
  90 + AnimManager.animAlphaAndScale(context, avm, 500, 200); // filter
  91 + AnimManager.animAlphaAndScale(context, avm, 700, 200); // overflow
  92 + }
  93 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/base/BaseModel.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/base/BaseModel.java
... ... @@ -0,0 +1,11 @@
  1 +package com.share.mvpsdk.base;
  2 +
  3 +/**
  4 + * Created by Horrarndoo on 2017/4/25.
  5 + * base model类
  6 + */
  7 +
  8 +public abstract class BaseModel {
  9 + public BaseModel() {
  10 + }
  11 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/base/BasePresenter.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/base/BasePresenter.java
... ... @@ -0,0 +1,53 @@
  1 +package com.share.mvpsdk.base;
  2 +
  3 +import android.support.annotation.NonNull;
  4 +
  5 +import com.share.mvpsdk.RxManager;
  6 +
  7 +
  8 +/**
  9 + * Created by Horrarndoo on 2017/4/25.
  10 + * <p>
  11 + * base presenter
  12 + */
  13 +
  14 +public abstract class BasePresenter<M, V> {
  15 + public M mIModel;
  16 + public V mIView;
  17 + protected RxManager mRxManager = new RxManager();
  18 +
  19 + /**
  20 + * 返回presenter想持有的Model引用
  21 + *
  22 + * @return presenter持有的Model引用
  23 + */
  24 + public abstract M getModel();
  25 +
  26 + /**
  27 + * 绑定IModel和IView的引用
  28 + *
  29 + * @param m model
  30 + * @param v view
  31 + */
  32 + public void attachMV(@NonNull M m, @NonNull V v) {
  33 + this.mIModel = m;
  34 + this.mIView = v;
  35 + this.onStart();
  36 + }
  37 +
  38 + /**
  39 + * 解绑IModel和IView
  40 + */
  41 + public void detachMV() {
  42 + mRxManager.unSubscribe();
  43 + mIView = null;
  44 + mIModel = null;
  45 + }
  46 +
  47 + /**
  48 + * IView和IModel绑定完成立即执行
  49 + * <p>
  50 + * 实现类实现绑定完成后的逻辑,例如数据初始化等,界面初始化, 更新等
  51 + */
  52 + public abstract void onStart();
  53 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/base/IBaseActivity.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/base/IBaseActivity.java
... ... @@ -0,0 +1,35 @@
  1 +package com.share.mvpsdk.base;
  2 +
  3 +import android.os.Bundle;
  4 +import android.support.annotation.NonNull;
  5 +
  6 +/**
  7 + * Created by Horrarndoo on 2017/9/6.
  8 + * <p>
  9 + * BaseActivity接口
  10 + */
  11 +
  12 +public interface IBaseActivity extends IBaseView {
  13 + /**
  14 + * 跳往新的Activity
  15 + *
  16 + * @param clz 要跳往的Activity
  17 + */
  18 + void startNewActivity(@NonNull Class<?> clz);
  19 +
  20 + /**
  21 + * 跳往新的Activity
  22 + *
  23 + * @param clz 要跳往的Activity
  24 + * @param bundle 携带的bundle数据
  25 + */
  26 + void startNewActivity(@NonNull Class<?> clz, Bundle bundle);
  27 +
  28 + /**
  29 + * 跳往新的Activity
  30 + * @param clz 要跳转的Activity
  31 + * @param bundle bundel数据
  32 + * @param requestCode requestCode
  33 + */
  34 + void startNewActivityForResult(@NonNull Class<?> clz, Bundle bundle, int requestCode);
  35 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/base/IBaseFragment.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/base/IBaseFragment.java
... ... @@ -0,0 +1,92 @@
  1 +package com.share.mvpsdk.base;
  2 +
  3 +import android.app.Activity;
  4 +import android.os.Bundle;
  5 +import android.support.annotation.NonNull;
  6 +
  7 +import me.yokeyword.fragmentation.SupportFragment;
  8 +
  9 +/**
  10 + * Created by Horrarndoo on 2017/9/6.
  11 + * <p>
  12 + * BaseFragment接口
  13 + */
  14 +
  15 +public interface IBaseFragment extends IBaseView {
  16 + /**
  17 + * 出栈到目标fragment
  18 + *
  19 + * @param targetFragmentClass 目标fragment
  20 + * @param includeTargetFragment 是否包含该fragment
  21 + * true 目标fragment也出栈
  22 + * <p>
  23 + * false 出栈到目标fragment,目标fragment不出栈
  24 + */
  25 + void popToFragment(Class<?> targetFragmentClass, boolean includeTargetFragment);
  26 +
  27 + /**
  28 + * 跳往新的Fragment
  29 + *
  30 + * @param supportFragment 要跳往的Fragment(继承自supportFragment)
  31 + */
  32 + void startNewFragment(@NonNull SupportFragment supportFragment);
  33 +
  34 + /**
  35 + * 跳往新的Fragment,并出栈当前fragment
  36 + *
  37 + * @param supportFragment 要跳往的Fragment(继承自supportFragment)
  38 + */
  39 + void startNewFragmentWithPop(@NonNull SupportFragment supportFragment);
  40 +
  41 + /**
  42 + * 跳往新的Fragment
  43 + *
  44 + * @param supportFragment 要跳往的Fragment(继承自supportFragment)
  45 + * @param requestCode requestCode
  46 + */
  47 + void startNewFragmentForResult(@NonNull SupportFragment supportFragment, int requestCode);
  48 +
  49 + /**
  50 + * 设置Fragment返回Result
  51 + *
  52 + * @param resultCode resultCode
  53 + * @param data result data
  54 + */
  55 + void setOnFragmentResult(int resultCode, Bundle data);
  56 +
  57 + /**
  58 + * 跳往新的Activity
  59 + *
  60 + * @param clz 要跳往的Activity
  61 + */
  62 + void startNewActivity(@NonNull Class<?> clz);
  63 +
  64 + /**
  65 + * 跳往新的Activity
  66 + *
  67 + * @param clz 要跳往的Activity
  68 + * @param bundle 携带的bundle数据
  69 + */
  70 + void startNewActivity(@NonNull Class<?> clz, Bundle bundle);
  71 +
  72 + /**
  73 + * 跳往新的Activity
  74 + *
  75 + * @param clz 要跳转的Activity
  76 + * @param bundle bundel数据
  77 + * @param requestCode requestCode
  78 + */
  79 + void startNewActivityForResult(@NonNull Class<?> clz, Bundle bundle, int requestCode);
  80 +
  81 + /**
  82 + * 返回当前fragment是否可见
  83 + * @return 当前fragment是否可见
  84 + */
  85 + boolean isVisiable();
  86 +
  87 + /**
  88 + * 返回当前fragment绑定的activity
  89 + * @return activity
  90 + */
  91 + Activity getBindActivity();
  92 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/base/IBaseModel.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/base/IBaseModel.java
... ... @@ -0,0 +1,9 @@
  1 +package com.share.mvpsdk.base;
  2 +
  3 +/**
  4 + * Created by Horrarndoo on 2017/4/25.
  5 + * base model接口
  6 + */
  7 +
  8 +public interface IBaseModel {
  9 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/base/IBaseView.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/base/IBaseView.java
... ... @@ -0,0 +1,47 @@
  1 +package com.share.mvpsdk.base;
  2 +
  3 +import android.support.annotation.NonNull;
  4 +
  5 +/**
  6 + * Created by Horrarndoo on 2017/5/2.
  7 + * fragment base view接口
  8 + */
  9 +
  10 +public interface IBaseView {
  11 + /**
  12 + * 初始化presenter
  13 + * <p>
  14 + * 此方法返回的presenter对象不可为空
  15 + */
  16 + @NonNull
  17 + BasePresenter initPresenter();
  18 +
  19 + /**
  20 + * 显示toast消息
  21 + *
  22 + * @param msg 要显示的toast消息字符串
  23 + */
  24 + void showToast(String msg);
  25 +
  26 + /**
  27 + * 显示等待dialog
  28 + *
  29 + * @param waitMsg 等待消息字符串
  30 + */
  31 + void showWaitDialog(String waitMsg);
  32 +
  33 + /**
  34 + * 隐藏等待dialog
  35 + */
  36 + void hideWaitDialog();
  37 +
  38 + /**
  39 + * 隐藏键盘
  40 + */
  41 + void hideKeybord();
  42 +
  43 + /**
  44 + * 回退
  45 + */
  46 + void back();
  47 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/base/activity/BaseCompatActivity.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/base/activity/BaseCompatActivity.java
... ... @@ -0,0 +1,249 @@
  1 +package com.share.mvpsdk.base.activity;
  2 +
  3 +import android.content.Context;
  4 +import android.content.Intent;
  5 +import android.content.pm.ActivityInfo;
  6 +import android.os.Bundle;
  7 +import android.support.v7.app.AppCompatDelegate;
  8 +import android.support.v7.widget.Toolbar;
  9 +import android.view.View;
  10 +import android.view.inputmethod.InputMethodManager;
  11 +
  12 +
  13 +import com.share.mvpsdk.AppManager;
  14 +import com.share.mvpsdk.R;
  15 +import com.share.mvpsdk.global.GlobalApplication;
  16 +import com.share.mvpsdk.utils.AppUtils;
  17 +import com.share.mvpsdk.utils.SpUtils;
  18 +import com.share.mvpsdk.utils.StatusBarUtils;
  19 +import com.share.mvpsdk.utils.ThemeUtils;
  20 +import com.share.mvpsdk.widgets.WaitPorgressDialog;
  21 +
  22 +import butterknife.ButterKnife;
  23 +import me.yokeyword.fragmentation.SupportActivity;
  24 +import me.yokeyword.fragmentation.anim.DefaultVerticalAnimator;
  25 +import me.yokeyword.fragmentation.anim.FragmentAnimator;
  26 +
  27 +/**
  28 + * Created by Horrarndoo on 2017/9/7.
  29 + * <p>
  30 + * BaseActivity
  31 + */
  32 +
  33 +public abstract class BaseCompatActivity extends SupportActivity {
  34 + protected GlobalApplication mApplication;
  35 + protected WaitPorgressDialog mWaitPorgressDialog;
  36 + protected Context mContext;//全局上下文对象
  37 + protected boolean isTransAnim;
  38 +
  39 + static {
  40 + //5.0以下兼容vector
  41 + AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
  42 + }
  43 +
  44 + @Override
  45 + protected void onCreate(Bundle savedInstanceState) {
  46 + super.onCreate(savedInstanceState);
  47 + init(savedInstanceState);
  48 + }
  49 +
  50 + @Override
  51 + protected void onDestroy() {
  52 + super.onDestroy();
  53 + AppManager.getAppManager().finishActivity(this);
  54 + }
  55 +
  56 + @Override
  57 + public FragmentAnimator onCreateFragmentAnimator() {
  58 + //fragment切换使用默认Vertical动画
  59 + return new DefaultVerticalAnimator();
  60 + }
  61 +
  62 + private void init(Bundle savedInstanceState) {
  63 + setTheme(ThemeUtils.themeArr[SpUtils.getThemeIndex(this)][
  64 + SpUtils.getNightModel(this) ? 1 : 0]);
  65 + setContentView(getLayoutId());
  66 + ButterKnife.bind(this);
  67 + StatusBarUtils.setTransparent(this);
  68 + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  69 + initData();
  70 + initView(savedInstanceState);
  71 + AppManager.getAppManager().addActivity(this);
  72 + }
  73 +
  74 + public void reload() {
  75 + Intent intent = getIntent();
  76 + overridePendingTransition(0, 0);
  77 + intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  78 + finish();
  79 + overridePendingTransition(0, 0);
  80 + startActivity(intent);
  81 + }
  82 +
  83 + /**
  84 + * 初始化数据
  85 + * <p>
  86 + * 子类可以复写此方法初始化子类数据
  87 + */
  88 + protected void initData() {
  89 + mContext = AppUtils.getContext();
  90 + mApplication = GlobalApplication.getInstance();
  91 + mWaitPorgressDialog = new WaitPorgressDialog(this);
  92 + isTransAnim = true;
  93 + }
  94 +
  95 + /**
  96 + * 初始化view
  97 + * <p>
  98 + * 子类实现 控件绑定、视图初始化等内容
  99 + *
  100 + * @param savedInstanceState savedInstanceState
  101 + */
  102 + protected abstract void initView(Bundle savedInstanceState);
  103 +
  104 + /**
  105 + * 获取当前layouty的布局ID,用于设置当前布局
  106 + * <p>
  107 + * 交由子类实现
  108 + *
  109 + * @return layout Id
  110 + */
  111 + protected abstract int getLayoutId();
  112 +
  113 + /**
  114 + * 显示提示框
  115 + *
  116 + * @param msg 提示框内容字符串
  117 + */
  118 + protected void showProgressDialog(String msg) {
  119 + mWaitPorgressDialog.setMessage(msg);
  120 + mWaitPorgressDialog.show();
  121 + }
  122 +
  123 + /**
  124 + * 隐藏提示框
  125 + */
  126 + protected void hideProgressDialog() {
  127 + if (mWaitPorgressDialog != null) {
  128 + mWaitPorgressDialog.dismiss();
  129 + }
  130 + }
  131 +
  132 + /**
  133 + * [页面跳转]
  134 + *
  135 + * @param clz 要跳转的Activity
  136 + */
  137 + public void startActivity(Class<?> clz) {
  138 + startActivity(new Intent(this, clz));
  139 + if (isTransAnim)
  140 + overridePendingTransition(R.anim.activity_start_zoom_in, R.anim
  141 + .activity_start_zoom_out);
  142 + }
  143 +
  144 + /**
  145 + * [页面跳转]
  146 + *
  147 + * @param clz 要跳转的Activity
  148 + * @param intent intent
  149 + */
  150 + public void startActivity(Class<?> clz, Intent intent) {
  151 + intent.setClass(this, clz);
  152 + startActivity(intent);
  153 + if (isTransAnim)
  154 + overridePendingTransition(R.anim.activity_start_zoom_in, R.anim
  155 + .activity_start_zoom_out);
  156 + }
  157 +
  158 + /**
  159 + * [携带数据的页面跳转]
  160 + *
  161 + * @param clz 要跳转的Activity
  162 + * @param bundle bundel数据
  163 + */
  164 + public void startActivity(Class<?> clz, Bundle bundle) {
  165 + Intent intent = new Intent();
  166 + intent.setClass(this, clz);
  167 + if (bundle != null) {
  168 + intent.putExtras(bundle);
  169 + }
  170 + startActivity(intent);
  171 + if (isTransAnim)
  172 + overridePendingTransition(R.anim.activity_start_zoom_in, R.anim
  173 + .activity_start_zoom_out);
  174 + }
  175 +
  176 + /**
  177 + * [含有Bundle通过Class打开编辑界面]
  178 + *
  179 + * @param clz 要跳转的Activity
  180 + * @param bundle bundel数据
  181 + * @param requestCode requestCode
  182 + */
  183 + public void startActivityForResult(Class<?> clz, Bundle bundle,
  184 + int requestCode) {
  185 + Intent intent = new Intent();
  186 + intent.setClass(this, clz);
  187 + if (bundle != null) {
  188 + intent.putExtras(bundle);
  189 + }
  190 + startActivityForResult(intent, requestCode);
  191 + if (isTransAnim)
  192 + overridePendingTransition(R.anim.activity_start_zoom_in, R.anim
  193 + .activity_start_zoom_out);
  194 + }
  195 +
  196 + @Override
  197 + public void finish() {
  198 + super.finish();
  199 + if (isTransAnim)
  200 + overridePendingTransition(R.anim.activity_finish_trans_in, R.anim
  201 + .activity_finish_trans_out);
  202 + }
  203 +
  204 + /**
  205 + * 隐藏键盘
  206 + *
  207 + * @return 隐藏键盘结果
  208 + * <p>
  209 + * true:隐藏成功
  210 + * <p>
  211 + * false:隐藏失败
  212 + */
  213 + protected boolean hiddenKeyboard() {
  214 + //点击空白位置 隐藏软键盘
  215 + InputMethodManager mInputMethodManager = (InputMethodManager) getSystemService
  216 + (INPUT_METHOD_SERVICE);
  217 + return mInputMethodManager.hideSoftInputFromWindow(this
  218 + .getCurrentFocus().getWindowToken(), 0);
  219 + }
  220 +
  221 + protected void initTitleBar(Toolbar toolbar, String title) {
  222 + toolbar.setTitle(title);
  223 + setSupportActionBar(toolbar);
  224 + getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  225 + getSupportActionBar().setDisplayShowHomeEnabled(true);
  226 + toolbar.setNavigationIcon(R.mipmap.ic_arrow_back_white);
  227 + toolbar.setNavigationOnClickListener(new View.OnClickListener() {
  228 + @Override
  229 + public void onClick(View view) {
  230 + onBackPressedSupport();
  231 + }
  232 + });
  233 + }
  234 +
  235 + /**
  236 + * 是否使用overridePendingTransition过度动画
  237 + * @return 是否使用overridePendingTransition过度动画,默认使用
  238 + */
  239 + protected boolean isTransAnim() {
  240 + return isTransAnim;
  241 + }
  242 +
  243 + /**
  244 + * 设置是否使用overridePendingTransition过度动画
  245 + */
  246 + protected void setIsTransAnim(boolean b){
  247 + isTransAnim = b;
  248 + }
  249 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/base/activity/BaseMVPCompatActivity.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/base/activity/BaseMVPCompatActivity.java
... ... @@ -0,0 +1,94 @@
  1 +package com.share.mvpsdk.base.activity;
  2 +
  3 +import android.os.Bundle;
  4 +import android.support.annotation.NonNull;
  5 +
  6 +import com.share.mvpsdk.base.BasePresenter;
  7 +import com.share.mvpsdk.base.IBaseActivity;
  8 +import com.share.mvpsdk.base.IBaseModel;
  9 +import com.share.mvpsdk.utils.ToastUtils;
  10 +
  11 +
  12 +/**
  13 + * Created by Horrarndoo on 2017/4/6.
  14 + * <p>
  15 + * Mvp Activity基类
  16 + */
  17 +public abstract class BaseMVPCompatActivity<P extends BasePresenter, M extends IBaseModel> extends
  18 + BaseCompatActivity implements IBaseActivity {
  19 + /**
  20 + * presenter 具体的presenter由子类确定
  21 + */
  22 + protected P mPresenter;
  23 +
  24 + /**
  25 + * model 具体的model由子类确定
  26 + */
  27 + private M mIMode;
  28 +
  29 + /**
  30 + * 初始化数据
  31 + * <p>
  32 + * 子类可以复写此方法初始化子类数据
  33 + */
  34 + protected void initData() {
  35 + super.initData();
  36 + mPresenter = (P) initPresenter();
  37 + if (mPresenter != null) {
  38 + mIMode = (M) mPresenter.getModel();
  39 + if (mIMode != null) {
  40 + mPresenter.attachMV(mIMode, this);
  41 + }
  42 + //Logger.d("attach M V success.");
  43 + }
  44 + }
  45 +
  46 + @Override
  47 + protected void onDestroy() {
  48 + super.onDestroy();
  49 + if (mPresenter != null) {
  50 + mPresenter.detachMV();
  51 + //Logger.d("detach M V success.");
  52 + }
  53 + }
  54 +
  55 + @Override
  56 + public void showWaitDialog(String msg) {
  57 + showProgressDialog(msg);
  58 + }
  59 +
  60 + @Override
  61 + public void hideWaitDialog() {
  62 + hideProgressDialog();
  63 + }
  64 +
  65 + @Override
  66 + public void showToast(String msg) {
  67 + ToastUtils.showToast(msg);
  68 + }
  69 +
  70 + @Override
  71 + public void startNewActivity(@NonNull Class<?> clz) {
  72 + startActivity(clz);
  73 + }
  74 +
  75 + @Override
  76 + public void startNewActivity(@NonNull Class<?> clz, Bundle bundle) {
  77 + startActivity(clz, bundle);
  78 + }
  79 +
  80 + @Override
  81 + public void startNewActivityForResult(@NonNull Class<?> clz, Bundle bundle, int requestCode) {
  82 + startActivityForResult(clz, bundle, requestCode);
  83 + }
  84 +
  85 + @Override
  86 + public void hideKeybord() {
  87 + hiddenKeyboard();
  88 + }
  89 +
  90 + @Override
  91 + public void back() {
  92 + super.onBackPressedSupport();
  93 + }
  94 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/base/adapter/BaseRecyclerViewAdapter.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/base/adapter/BaseRecyclerViewAdapter.java
... ... @@ -0,0 +1,79 @@
  1 +package com.share.mvpsdk.base.adapter;
  2 +
  3 +import android.support.v7.widget.RecyclerView;
  4 +import android.view.ViewGroup;
  5 +
  6 +
  7 +import java.util.ArrayList;
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * Created by ToaHanDong on 2017/3/23.
  12 + */
  13 +
  14 +public abstract class BaseRecyclerViewAdapter<T> extends RecyclerView.Adapter<BaseRecyclerViewHolder> {
  15 +
  16 + private List<T> data = new ArrayList<>();
  17 + public OnItemClickListener onItemClickListener;
  18 + public OnItemLongClickListener onItemLongClickListener;
  19 +
  20 + @Override
  21 + public BaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  22 + return null;
  23 + }
  24 +
  25 + @Override
  26 + public void onBindViewHolder(BaseRecyclerViewHolder holder, int position) {
  27 + holder.onBindViewHolder(data.get(getPosition(position)), getPosition(position));
  28 + }
  29 +
  30 +
  31 + @Override
  32 + public int getItemCount() {
  33 + return data.size();
  34 + }
  35 +
  36 + public void addAll(List<T> data) {
  37 + removeAll();
  38 + if (data!=null)
  39 + this.data.addAll(data);
  40 + notifyDataSetChanged();
  41 + }
  42 +
  43 + public void removeAll() {
  44 + data.clear();
  45 + }
  46 +
  47 + public void remove(int position) {
  48 + data.remove(position);
  49 + }
  50 +
  51 + public void notift() {
  52 + notifyDataSetChanged();
  53 + }
  54 +
  55 + public void remove(T object) {
  56 + data.remove(object);
  57 + }
  58 +
  59 + public List<T> getData() {
  60 + return data;
  61 + }
  62 +
  63 + public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
  64 + this.onItemClickListener = onItemClickListener;
  65 + }
  66 +
  67 + public void setOnItemLongClickListener(OnItemLongClickListener onItemLongClickListener) {
  68 + this.onItemLongClickListener = onItemLongClickListener;
  69 + }
  70 +
  71 + private int getPosition(int position) {
  72 + return position;
  73 +// if (data.size() <= 9) {
  74 +// return position;
  75 +// }
  76 +// return position % (data.size());
  77 + }
  78 +
  79 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/base/adapter/BaseRecyclerViewHolder.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/base/adapter/BaseRecyclerViewHolder.java
... ... @@ -0,0 +1,22 @@
  1 +package com.share.mvpsdk.base.adapter;
  2 +
  3 +import android.support.v7.widget.RecyclerView;
  4 +import android.view.View;
  5 +
  6 +/**
  7 + * Created by ToaHanDong on 2017/3/23.
  8 + */
  9 +
  10 +public abstract class BaseRecyclerViewHolder<T> extends RecyclerView.ViewHolder {
  11 +
  12 + public BaseRecyclerViewHolder(View itemView) {
  13 + super(itemView);
  14 + }
  15 +
  16 + public abstract void onBindViewHolder(T object, final int position);
  17 +
  18 + void OnBaseBindViewHolder(T Object,int position){
  19 + onBindViewHolder(Object,position);
  20 + }
  21 +
  22 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/base/adapter/OnItemClickListener.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/base/adapter/OnItemClickListener.java
... ... @@ -0,0 +1,10 @@
  1 +package com.share.mvpsdk.base.adapter;
  2 +
  3 +/**
  4 + * Created by ToaHanDong on 2017/3/23.
  5 + */
  6 +
  7 +public interface OnItemClickListener<T> {
  8 +
  9 + void onItemClickListener(T object, int position);
  10 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/base/adapter/OnItemLongClickListener.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/base/adapter/OnItemLongClickListener.java
... ... @@ -0,0 +1,10 @@
  1 +package com.share.mvpsdk.base.adapter;
  2 +
  3 +/**
  4 + * Created by ToaHanDong on 2017/3/23.
  5 + */
  6 +
  7 +public interface OnItemLongClickListener<T> {
  8 +
  9 + void onItemLongClickListener(T object, int position);
  10 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/base/entity/BaseEntity.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/base/entity/BaseEntity.java
... ... @@ -0,0 +1,47 @@
  1 +package com.share.mvpsdk.base.entity;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +/**
  6 + * Created by ToaHanDong on 2017/4/27.
  7 + */
  8 +
  9 +public class BaseEntity<T> implements Serializable {
  10 +
  11 + private int status;
  12 + private String message;
  13 + private T data;
  14 +
  15 + public int getStatus() {
  16 + return status;
  17 + }
  18 +
  19 + public void setStatus(int status) {
  20 + this.status = status;
  21 + }
  22 +
  23 + public String getMessage() {
  24 + return message;
  25 + }
  26 +
  27 + public void setMessage(String message) {
  28 + this.message = message;
  29 + }
  30 +
  31 + public T getData() {
  32 + return data;
  33 + }
  34 +
  35 + public void setData(T data) {
  36 + this.data = data;
  37 + }
  38 +
  39 + @Override
  40 + public String toString() {
  41 + return "BaseEntity{" +
  42 + "status=" + status +
  43 + ", message='" + message + '\'' +
  44 + ", data=" + data +
  45 + '}';
  46 + }
  47 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/base/entity/BaseListEntity.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/base/entity/BaseListEntity.java
... ... @@ -0,0 +1,48 @@
  1 +package com.share.mvpsdk.base.entity;
  2 +
  3 +import java.io.Serializable;
  4 +import java.util.List;
  5 +
  6 +/**
  7 + * Created by ToaHanDong on 2017/6/6.
  8 + */
  9 +
  10 +public class BaseListEntity<T> implements Serializable {
  11 +
  12 + private int status;
  13 + private String message;
  14 + private List<T> data;
  15 +
  16 + public int getStatus() {
  17 + return status;
  18 + }
  19 +
  20 + public void setStatus(int status) {
  21 + this.status = status;
  22 + }
  23 +
  24 + public String getMessage() {
  25 + return message;
  26 + }
  27 +
  28 + public void setMessage(String message) {
  29 + this.message = message;
  30 + }
  31 +
  32 + public List<T> getData() {
  33 + return data;
  34 + }
  35 +
  36 + public void setData(List<T> data) {
  37 + this.data = data;
  38 + }
  39 +
  40 + @Override
  41 + public String toString() {
  42 + return "BaseListEntity{" +
  43 + "status=" + status +
  44 + ", message='" + message + '\'' +
  45 + ", data=" + data +
  46 + '}';
  47 + }
  48 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/base/fragment/BaseCompatFragment.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/base/fragment/BaseCompatFragment.java
... ... @@ -0,0 +1,153 @@
  1 +package com.share.mvpsdk.base.fragment;
  2 +
  3 +import android.app.Activity;
  4 +import android.content.Context;
  5 +import android.content.pm.ActivityInfo;
  6 +import android.os.Bundle;
  7 +import android.support.annotation.LayoutRes;
  8 +import android.support.annotation.Nullable;
  9 +import android.util.Log;
  10 +import android.view.LayoutInflater;
  11 +import android.view.View;
  12 +import android.view.ViewGroup;
  13 +
  14 +
  15 +import com.share.mvpsdk.global.GlobalApplication;
  16 +import com.share.mvpsdk.utils.AppUtils;
  17 +import com.share.mvpsdk.widgets.WaitPorgressDialog;
  18 +
  19 +import butterknife.ButterKnife;
  20 +import butterknife.Unbinder;
  21 +import me.yokeyword.fragmentation.SupportFragment;
  22 +import timber.log.Timber;
  23 +
  24 +/**
  25 + * Created by Horrarndoo on 2017/9/26.
  26 + * <p>
  27 + */
  28 +
  29 +public abstract class BaseCompatFragment extends SupportFragment {
  30 +
  31 + protected String TAG;
  32 + protected Context mContext;
  33 + protected Activity mActivity;
  34 + protected GlobalApplication mApplication;
  35 + protected WaitPorgressDialog mWaitPorgressDialog;
  36 +// private Unbinder binder;
  37 +
  38 + @Override
  39 + public void onAttach(Context context) {
  40 + mActivity = (Activity) context;
  41 + mContext = context;
  42 + super.onAttach(context);
  43 + }
  44 +
  45 + @Override
  46 + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable
  47 + Bundle savedInstanceState) {
  48 + if (getLayoutView() != null) {
  49 + return getLayoutView();
  50 + } else {
  51 + // return inflater.inflate(getLayoutId(), null);
  52 + return inflater.inflate(getLayoutId(), container, false);
  53 + }
  54 + }
  55 +
  56 + @Override
  57 + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  58 + ButterKnife.bind(this, view);
  59 + super.onViewCreated(view, savedInstanceState);
  60 + mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  61 + TAG = getClass().getSimpleName();
  62 + getBundle(getArguments());
  63 + initData();
  64 + initUI(view, savedInstanceState);
  65 + }
  66 +
  67 +
  68 + @Override
  69 + public void onDestroyView() {
  70 + super.onDestroyView();
  71 +// if (binder != null)
  72 +// binder.unbind();
  73 + }
  74 +
  75 + @Override
  76 + public void onDetach() {
  77 + super.onDetach();
  78 + }
  79 +
  80 + @Override
  81 + public void onDestroy() {
  82 + super.onDestroy();
  83 + }
  84 +
  85 + @LayoutRes
  86 + public abstract int getLayoutId();
  87 +
  88 + public View getLayoutView() {
  89 + return null;
  90 + }
  91 +
  92 + /**
  93 + * 得到Activity传进来的值
  94 + */
  95 + public void getBundle(Bundle bundle) {
  96 + }
  97 +
  98 + /**
  99 + * 初始化UI
  100 + */
  101 + public abstract void initUI(View view, @Nullable Bundle savedInstanceState);
  102 +
  103 + /**
  104 + * 在监听器之前把数据准备好
  105 + */
  106 + public void initData() {
  107 + mWaitPorgressDialog = new WaitPorgressDialog(mActivity);
  108 + mContext = AppUtils.getContext();
  109 + mApplication = GlobalApplication.getInstance();
  110 + }
  111 +
  112 + /**
  113 + * 处理回退事件
  114 + *
  115 + * @return true 事件已消费
  116 + * <p>
  117 + * false 事件向上传递
  118 + */
  119 + @Override
  120 + public boolean onBackPressedSupport() {
  121 + if (getFragmentManager().getBackStackEntryCount() > 1) {
  122 + //如果当前存在fragment>1,当前fragment出栈
  123 + pop();
  124 + } else {
  125 + //已经退栈到root fragment,交由Activity处理回退事件
  126 + return false;
  127 + }
  128 + return true;
  129 + }
  130 +
  131 + /**
  132 + * 显示提示框
  133 + *
  134 + * @param msg 提示框内容字符串
  135 + */
  136 + protected void showProgressDialog(String msg) {
  137 + if (mWaitPorgressDialog.isShowing()) {
  138 + mWaitPorgressDialog.dismiss();
  139 + }
  140 +
  141 + mWaitPorgressDialog.setMessage(msg);
  142 + mWaitPorgressDialog.show();
  143 + }
  144 +
  145 + /**
  146 + * 隐藏提示框
  147 + */
  148 + protected void hideProgressDialog() {
  149 + if (mWaitPorgressDialog != null) {
  150 + mWaitPorgressDialog.dismiss();
  151 + }
  152 + }
  153 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/base/fragment/BaseMVPCompatFragment.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/base/fragment/BaseMVPCompatFragment.java
... ... @@ -0,0 +1,128 @@
  1 +package com.share.mvpsdk.base.fragment;
  2 +
  3 +import android.app.Activity;
  4 +import android.os.Bundle;
  5 +import android.support.annotation.NonNull;
  6 +import android.widget.Toast;
  7 +
  8 +
  9 +import com.share.mvpsdk.base.BasePresenter;
  10 +import com.share.mvpsdk.base.IBaseFragment;
  11 +import com.share.mvpsdk.base.IBaseModel;
  12 +import com.share.mvpsdk.base.activity.BaseCompatActivity;
  13 +import com.share.mvpsdk.utils.ToastUtils;
  14 +
  15 +import me.yokeyword.fragmentation.SupportFragment;
  16 +
  17 +/**
  18 + * Created by Horrarndoo on 2017/9/6.
  19 + * <p>
  20 + * Mvp Fragment基类
  21 + * <p>
  22 + * 实现IBaseView方法、绑定butterknife
  23 + */
  24 +
  25 +public abstract class BaseMVPCompatFragment<P extends BasePresenter, M extends IBaseModel> extends
  26 + BaseCompatFragment implements IBaseFragment {
  27 + public P mPresenter;
  28 + public M mIMode;
  29 +
  30 + /**
  31 + * 在监听器之前把数据准备好
  32 + */
  33 + public void initData() {
  34 + super.initData();
  35 +
  36 + mPresenter = (P) initPresenter();
  37 + if (mPresenter != null) {
  38 + mIMode = (M) mPresenter.getModel();
  39 + if (mIMode != null) {
  40 + mPresenter.attachMV(mIMode, this);
  41 + }
  42 + }
  43 + }
  44 +
  45 + @Override
  46 + public void onDestroy() {
  47 + super.onDestroy();
  48 + if (mPresenter != null) {
  49 + mPresenter.detachMV();
  50 + }
  51 + }
  52 +
  53 + @Override
  54 + public void showWaitDialog(String msg) {
  55 + showProgressDialog(msg);
  56 + }
  57 +
  58 + @Override
  59 + public void hideWaitDialog() {
  60 + hideProgressDialog();
  61 + }
  62 +
  63 + @Override
  64 + public void showToast(String msg) {
  65 + ToastUtils.showToast(mContext, msg, Toast.LENGTH_SHORT);
  66 + }
  67 +
  68 + @Override
  69 + public void back() {
  70 + this.onBackPressedSupport();
  71 + }
  72 +
  73 + @Override
  74 + public void startNewFragment(@NonNull SupportFragment supportFragment) {
  75 + start(supportFragment);
  76 + }
  77 +
  78 + @Override
  79 + public void startNewFragmentWithPop(@NonNull SupportFragment supportFragment) {
  80 + startWithPop(supportFragment);
  81 + }
  82 +
  83 + @Override
  84 + public void startNewFragmentForResult(@NonNull SupportFragment supportFragment, int
  85 + requestCode) {
  86 + startForResult(supportFragment, requestCode);
  87 + }
  88 +
  89 + @Override
  90 + public void popToFragment(Class<?> targetFragmentClass, boolean includeTargetFragment) {
  91 + popTo(targetFragmentClass, includeTargetFragment);
  92 + }
  93 +
  94 + @Override
  95 + public void hideKeybord() {
  96 + hideSoftInput();
  97 + }
  98 +
  99 + @Override
  100 + public void setOnFragmentResult(int ResultCode, Bundle data) {
  101 + setFragmentResult(ResultCode, data);
  102 + }
  103 +
  104 + @Override
  105 + public void startNewActivity(@NonNull Class<?> clz) {
  106 + ((BaseCompatActivity) mActivity).startActivity(clz);
  107 + }
  108 +
  109 + @Override
  110 + public void startNewActivity(@NonNull Class<?> clz, Bundle bundle) {
  111 + ((BaseCompatActivity) mActivity).startActivity(clz, bundle);
  112 + }
  113 +
  114 + @Override
  115 + public void startNewActivityForResult(@NonNull Class<?> clz, Bundle bundle, int requestCode) {
  116 + ((BaseCompatActivity) mActivity).startActivityForResult(clz, bundle, requestCode);
  117 + }
  118 +
  119 + @Override
  120 + public boolean isVisiable() {
  121 + return isSupportVisible();
  122 + }
  123 +
  124 + @Override
  125 + public Activity getBindActivity() {
  126 + return mActivity;
  127 + }
  128 +}
0 129 \ No newline at end of file
... ...
mvpsdk/src/main/java/com/share/mvpsdk/base/fragment/BaseRecycleFragment.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/base/fragment/BaseRecycleFragment.java
... ... @@ -0,0 +1,68 @@
  1 +package com.share.mvpsdk.base.fragment;
  2 +
  3 +import android.os.Bundle;
  4 +import android.support.annotation.Nullable;
  5 +import android.view.LayoutInflater;
  6 +import android.view.View;
  7 +import android.view.ViewGroup;
  8 +
  9 +import com.share.mvpsdk.R;
  10 +import com.share.mvpsdk.base.BasePresenter;
  11 +import com.share.mvpsdk.base.IBaseModel;
  12 +
  13 +
  14 +/**
  15 + * Created by Horrarndoo on 2017/10/17.
  16 + * <p>
  17 + * 带RecycleView加载状态view的fragment,主要用于显示加载中、空界面、加载失败等状态界面显示
  18 + */
  19 +
  20 +public abstract class BaseRecycleFragment<P extends BasePresenter, M extends IBaseModel> extends
  21 + BaseMVPCompatFragment<P, M> {
  22 + /**
  23 + * 网络异常View
  24 + */
  25 + protected View errorView;
  26 + /**
  27 + * loadingView
  28 + */
  29 + protected View loadingView;
  30 + /**
  31 + * 没有内容view
  32 + */
  33 + protected View emptyView;
  34 +
  35 + @Override
  36 + public void onLazyInitView(@Nullable Bundle savedInstanceState) {
  37 + super.onLazyInitView(savedInstanceState);
  38 + showLoading();
  39 + }
  40 +
  41 + @Override
  42 + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable
  43 + Bundle savedInstanceState) {
  44 + errorView = inflater.inflate(R.layout.view_network_error, container, false);
  45 + loadingView = inflater.inflate(R.layout.view_loading, container, false);
  46 + emptyView = inflater.inflate(R.layout.view_empty, container, false);
  47 + errorView.setOnClickListener(new View.OnClickListener() {
  48 + @Override
  49 + public void onClick(View v) {
  50 + showLoading();
  51 + onErrorViewClick(v);
  52 + }
  53 + });
  54 + return super.onCreateView(inflater, container, savedInstanceState);
  55 + }
  56 +
  57 + /**
  58 + * 网络异常view被点击时触发,由子类实现
  59 + *
  60 + * @param view view
  61 + */
  62 + protected abstract void onErrorViewClick(View view);
  63 +
  64 + /**
  65 + * 显示加载中view,由子类实现
  66 + */
  67 + protected abstract void showLoading();
  68 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/config/DBConfig.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/config/DBConfig.java
... ... @@ -0,0 +1,16 @@
  1 +package com.share.mvpsdk.config;
  2 +
  3 +/**
  4 + * Created by Horrarndoo on 2017/9/13.
  5 + * <p>
  6 + * 数据库全局常量
  7 + */
  8 +
  9 +public class DBConfig {
  10 + public static final String DB_NAME = "db_name_yizhi";
  11 + public static final String TABLE_ZHIHU = "table_zhihu";
  12 + public static final String TABLE_WANGYI = "table_top_news";
  13 + public static final String TABLE_WEIXIN = "table_weixin";
  14 + public static final String TABLE_GANKIO_DAY = "table_gank_io_day";
  15 + public static final String TABLE_GANKIO_CUSTOM = "table_gank_io_custom";
  16 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/config/ItemState.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/config/ItemState.java
... ... @@ -0,0 +1,19 @@
  1 +package com.share.mvpsdk.config;
  2 +
  3 +/**
  4 + * Created by Horrarndoo on 2017/9/13.
  5 + * <p>
  6 + * item状态全局常量
  7 + */
  8 +
  9 +public class ItemState {
  10 + /**
  11 + * 已读状态
  12 + */
  13 + public static final int STATE_IS_READ = 1;
  14 +
  15 + /**
  16 + * 非已读状态
  17 + */
  18 + public static final int STATE_IS_NO_READ = 0;
  19 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/global/GlobalApplication.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/global/GlobalApplication.java
... ... @@ -0,0 +1,67 @@
  1 +package com.share.mvpsdk.global;
  2 +
  3 +import android.app.Application;
  4 +import android.content.Context;
  5 +import android.os.Handler;
  6 +
  7 +import com.orhanobut.logger.LogLevel;
  8 +import com.orhanobut.logger.Logger;
  9 +
  10 +import timber.log.Timber;
  11 +
  12 +
  13 +/**
  14 + * Created by Horrarndoo on 2017/9/1.
  15 + * <p>
  16 + * 全局Application
  17 + */
  18 +
  19 +public class GlobalApplication extends Application {
  20 + private static final String LOG_TAG = "YZ_LOGGER";
  21 + protected static Context context;
  22 + protected static Handler handler;
  23 + protected static int mainThreadId;
  24 + private static GlobalApplication mApp;
  25 +
  26 + public static synchronized GlobalApplication getInstance() {
  27 + return mApp;
  28 + }
  29 +
  30 + @Override
  31 + public void onCreate() {
  32 + super.onCreate();
  33 + context = getApplicationContext();
  34 + handler = new Handler();
  35 + mainThreadId = android.os.Process.myTid();
  36 + mApp=this;
  37 + //LogLevel.FULL : LogLevel.NONE
  38 + Logger.init(LOG_TAG).logLevel(LogLevel.FULL);
  39 + }
  40 +
  41 + /**
  42 + * 获取上下文对象
  43 + *
  44 + * @return context
  45 + */
  46 + public static Context getContext() {
  47 + return context;
  48 + }
  49 +
  50 + /**
  51 + * 获取全局handler
  52 + *
  53 + * @return 全局handler
  54 + */
  55 + public static Handler getHandler() {
  56 + return handler;
  57 + }
  58 +
  59 + /**
  60 + * 获取主线程id
  61 + *
  62 + * @return 主线程id
  63 + */
  64 + public static int getMainThreadId() {
  65 + return mainThreadId;
  66 + }
  67 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/helper/BottomNavigationViewHelper.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/helper/BottomNavigationViewHelper.java
... ... @@ -0,0 +1,37 @@
  1 +package com.share.mvpsdk.helper;
  2 +
  3 +import android.support.design.internal.BottomNavigationItemView;
  4 +import android.support.design.internal.BottomNavigationMenuView;
  5 +import android.support.design.widget.BottomNavigationView;
  6 +import android.util.Log;
  7 +
  8 +import java.lang.reflect.Field;
  9 +
  10 +/**
  11 + * Created by Horrarndoo on 2017/9/22.
  12 + * <p>
  13 + * BottomNavigationView禁止3个item以上动画切换效果
  14 + */
  15 +public class BottomNavigationViewHelper {
  16 + public static void disableShiftMode(BottomNavigationView view) {
  17 + BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0);
  18 + try {
  19 + Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
  20 + shiftingMode.setAccessible(true);
  21 + shiftingMode.setBoolean(menuView, false);
  22 + shiftingMode.setAccessible(false);
  23 + for (int i = 0; i < menuView.getChildCount(); i++) {
  24 + BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i);
  25 + //noinspection RestrictedApi
  26 + item.setShiftingMode(false);
  27 + // set once again checked value, so view will be updated
  28 + //noinspection RestrictedApi
  29 + item.setChecked(item.getItemData().isChecked());
  30 + }
  31 + } catch (NoSuchFieldException e) {
  32 + Log.e("BNVHelper", "Unable to get shift mode field", e);
  33 + } catch (IllegalAccessException e) {
  34 + Log.e("BNVHelper", "Unable to change value of shift mode", e);
  35 + }
  36 + }
  37 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/helper/RetrofitCreateHelper.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/helper/RetrofitCreateHelper.java
... ... @@ -0,0 +1,56 @@
  1 +package com.share.mvpsdk.helper;
  2 +
  3 +
  4 +
  5 +import com.share.mvpsdk.helper.okhttp.CacheInterceptor;
  6 +import com.share.mvpsdk.helper.okhttp.HttpCache;
  7 +import com.share.mvpsdk.helper.okhttp.TrustManager;
  8 +
  9 +import java.util.concurrent.TimeUnit;
  10 +
  11 +import okhttp3.OkHttpClient;
  12 +import okhttp3.logging.HttpLoggingInterceptor;
  13 +import retrofit2.Retrofit;
  14 +import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
  15 +import retrofit2.converter.gson.GsonConverterFactory;
  16 +
  17 +/**
  18 + * Created by Horrarndoo on 2017/9/7.
  19 + * <p>
  20 + */
  21 +
  22 +public class RetrofitCreateHelper {
  23 + private static final int TIMEOUT_READ = 20;
  24 + private static final int TIMEOUT_CONNECTION = 10;
  25 + private static final HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor()
  26 + .setLevel(HttpLoggingInterceptor.Level.BODY);
  27 + private static CacheInterceptor cacheInterceptor = new CacheInterceptor();
  28 + private static OkHttpClient okHttpClient = new OkHttpClient.Builder()
  29 + //SSL证书
  30 + .sslSocketFactory(TrustManager.getUnsafeOkHttpClient())
  31 + .hostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER)
  32 + //打印日志
  33 + .addInterceptor(interceptor)
  34 + //设置Cache拦截器
  35 + .addNetworkInterceptor(cacheInterceptor)
  36 + .addInterceptor(cacheInterceptor)
  37 + .cache(HttpCache.getCache())
  38 + //time out
  39 + .connectTimeout(TIMEOUT_CONNECTION, TimeUnit.SECONDS)
  40 + .readTimeout(TIMEOUT_READ, TimeUnit.SECONDS)
  41 + .writeTimeout(TIMEOUT_READ, TimeUnit.SECONDS)
  42 + //失败重连
  43 + .retryOnConnectionFailure(true)
  44 + .build();
  45 +
  46 + public static <T> T createApi(Class<T> clazz, String url) {
  47 + Retrofit retrofit = new Retrofit.Builder()
  48 + .baseUrl(url)
  49 + .client(okHttpClient)
  50 + .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
  51 + .addConverterFactory(GsonConverterFactory.create())
  52 + .build();
  53 + return retrofit.create(clazz);
  54 + }
  55 +}
  56 +
... ...
mvpsdk/src/main/java/com/share/mvpsdk/helper/RxHelper.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/helper/RxHelper.java
... ... @@ -0,0 +1,76 @@
  1 +package com.share.mvpsdk.helper;
  2 +
  3 +
  4 +import io.reactivex.BackpressureStrategy;
  5 +import io.reactivex.Flowable;
  6 +import io.reactivex.FlowableEmitter;
  7 +import io.reactivex.FlowableOnSubscribe;
  8 +import io.reactivex.Observable;
  9 +import io.reactivex.ObservableEmitter;
  10 +import io.reactivex.ObservableOnSubscribe;
  11 +import io.reactivex.ObservableSource;
  12 +import io.reactivex.ObservableTransformer;
  13 +import io.reactivex.android.schedulers.AndroidSchedulers;
  14 +import io.reactivex.schedulers.Schedulers;
  15 +
  16 +/**
  17 + * Created by Horrarndoo on 2017/9/12.
  18 + * <p>
  19 + */
  20 +public class RxHelper {
  21 + /**
  22 + * 统一线程处理
  23 + * <p>
  24 + * 发布事件io线程,接收事件主线程
  25 + */
  26 + public static <T> ObservableTransformer<T, T> rxSchedulerHelper() {//compose处理线程
  27 + return new ObservableTransformer<T, T>() {
  28 +
  29 + @Override
  30 + public ObservableSource<T> apply(Observable<T> upstream) {
  31 + return upstream.subscribeOn(Schedulers.io())
  32 + .observeOn(AndroidSchedulers.mainThread());
  33 + }
  34 + };
  35 + }
  36 +
  37 + /**
  38 + * 生成Flowable
  39 + *
  40 + * @param t
  41 + * @return Flowable
  42 + */
  43 + public static <T> Flowable<T> createFlowable(final T t) {
  44 + return Flowable.create(new FlowableOnSubscribe<T>() {
  45 + @Override
  46 + public void subscribe(FlowableEmitter<T> emitter) throws Exception {
  47 + try {
  48 + emitter.onNext(t);
  49 + emitter.onComplete();
  50 + } catch (Exception e) {
  51 + emitter.onError(e);
  52 + }
  53 + }
  54 + }, BackpressureStrategy.BUFFER);
  55 + }
  56 +
  57 + /**
  58 + * 生成Observable
  59 + *
  60 + * @param t
  61 + * @return Flowable
  62 + */
  63 + public static <T> Observable<T> createObservable(final T t) {
  64 + return Observable.create(new ObservableOnSubscribe<T>() {
  65 + @Override
  66 + public void subscribe(ObservableEmitter<T> emitter) throws Exception {
  67 + try {
  68 + emitter.onNext(t);
  69 + emitter.onComplete();
  70 + } catch (Exception e) {
  71 + emitter.onError(e);
  72 + }
  73 + }
  74 + });
  75 + }
  76 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/helper/okhttp/CacheInterceptor.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/helper/okhttp/CacheInterceptor.java
... ... @@ -0,0 +1,84 @@
  1 +package com.share.mvpsdk.helper.okhttp;
  2 +
  3 +
  4 +
  5 +import com.share.mvpsdk.utils.AppUtils;
  6 +import com.share.mvpsdk.utils.NetworkConnectionUtils;
  7 +
  8 +import java.io.IOException;
  9 +
  10 +import okhttp3.CacheControl;
  11 +import okhttp3.Interceptor;
  12 +import okhttp3.Request;
  13 +import okhttp3.Response;
  14 +
  15 +import static com.share.mvpsdk.utils.HttpUtils.getUserAgent;
  16 +
  17 +
  18 +/**
  19 + * Created by Horrarndoo on 2017/9/12.
  20 + * <p>
  21 + * CacheInterceptor
  22 + */
  23 +public class CacheInterceptor implements Interceptor {
  24 +
  25 + @Override
  26 + public Response intercept(Chain chain) throws IOException {
  27 + Request request = chain.request();
  28 + if (NetworkConnectionUtils.isNetworkConnected(AppUtils.getContext())) {
  29 + // 有网络时, 缓存1小时
  30 + int maxAge = 60 * 60;
  31 + request = request.newBuilder()
  32 + .removeHeader("User-Agent")
  33 + .header("User-Agent", getUserAgent())
  34 + .build();
  35 +
  36 + Response response = chain.proceed(request);
  37 + return response.newBuilder()
  38 + .removeHeader("Pragma")
  39 + .removeHeader("Cache-Control")
  40 + .header("Cache-Control", "public, max-age=" + maxAge)
  41 + .build();
  42 + } else {
  43 + // 无网络时,缓存为4周
  44 + int maxStale = 60 * 60 * 24 * 28;
  45 + request = request.newBuilder()
  46 + .cacheControl(CacheControl.FORCE_CACHE)
  47 + .removeHeader("User-Agent")
  48 + .header("User-Agent", getUserAgent())
  49 + .build();
  50 +
  51 + Response response = chain.proceed(request);
  52 + return response.newBuilder()
  53 + .removeHeader("Pragma")
  54 + .removeHeader("Cache-Control")
  55 + .header("Cache-Control", "public, only-if-cached, max-stale=" + maxStale)
  56 + .build();
  57 + }
  58 +
  59 + // Request request = chain.request();
  60 + // if (!NetworkConnectionUtils.isConnected(AppUtils.getContext())) {
  61 + // request = request.newBuilder()
  62 + // .cacheControl(CacheControl.FORCE_CACHE)
  63 + // .build();
  64 + // }
  65 + // Response response = chain.proceed(request);
  66 + // if (NetworkConnectionUtils.isConnected(AppUtils.getContext())) {
  67 + // int maxAge = 0;
  68 + // // 有网络时, 不缓存, 最大保存时长为0
  69 + // response.newBuilder()
  70 + // .header("Cache-Control", "public, max-age=" + maxAge)
  71 + // .removeHeader("Pragma")
  72 + // .build();
  73 + // } else {
  74 + // // 无网络时,设置超时为4周
  75 + // int maxStale = 60 * 60 * 24 * 28;
  76 + // response.newBuilder()
  77 + // .header("Cache-Control", "public, only-if-cached, max-stale=" +
  78 + // maxStale)
  79 + // .removeHeader("Pragma")
  80 + // .build();
  81 + // }
  82 + // return response;
  83 + }
  84 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/helper/okhttp/HttpCache.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/helper/okhttp/HttpCache.java
... ... @@ -0,0 +1,28 @@
  1 +package com.share.mvpsdk.helper.okhttp;
  2 +
  3 +
  4 +import android.os.Environment;
  5 +
  6 +import com.share.mvpsdk.utils.AppUtils;
  7 +
  8 +import java.io.File;
  9 +
  10 +import okhttp3.Cache;
  11 +
  12 +/**
  13 + * Created by Horrarndoo on 2017/9/12.
  14 + * <p>
  15 + */
  16 +public class HttpCache {
  17 +
  18 + private static final int HTTP_RESPONSE_DISK_CACHE_MAX_SIZE = 50 * 1024 * 1024;
  19 +
  20 + public static Cache getCache() {
  21 + File file=new File(Environment.getExternalStorageDirectory() + File
  22 + .separator + "data/NetCache");
  23 + if (!file.getParentFile().exists())file.getParentFile().mkdirs();
  24 + if (!file.exists())file.mkdirs();
  25 + return new Cache(file,
  26 + HTTP_RESPONSE_DISK_CACHE_MAX_SIZE);
  27 + }
  28 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/helper/okhttp/NetInterceptor.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/helper/okhttp/NetInterceptor.java
... ... @@ -0,0 +1,49 @@
  1 +package com.share.mvpsdk.helper.okhttp;
  2 +
  3 +
  4 +import com.share.mvpsdk.utils.AppUtils;
  5 +import com.share.mvpsdk.utils.NetworkConnectionUtils;
  6 +
  7 +import java.io.IOException;
  8 +
  9 +import okhttp3.Interceptor;
  10 +import okhttp3.Request;
  11 +import okhttp3.Response;
  12 +
  13 +import static com.share.mvpsdk.utils.HttpUtils.getUserAgent;
  14 +
  15 +
  16 +/**
  17 + * Created by Horrarndoo on 2017/9/18.
  18 + * <p>
  19 + * 有网络时的缓存拦截器
  20 + */
  21 +
  22 +public class NetInterceptor implements Interceptor{
  23 + @Override
  24 + public Response intercept(Chain chain) throws IOException {
  25 + // 有网络时, 缓存1分钟, 最大保存时长为60s
  26 + int maxAge = 60;
  27 + Request request = chain.request();
  28 +
  29 + if (NetworkConnectionUtils.isNetworkConnected(AppUtils.getContext())) {
  30 + request = request.newBuilder()
  31 + .removeHeader("User-Agent")
  32 + .header("User-Agent", getUserAgent())
  33 + // .header("User-Agent", "Mozilla/5.0 (Windows NT 6.1;
  34 + // WOW64) AppleWebKit/537.36" +
  35 + // " (KHTML, like Gecko) Chrome/50.0.2661.102
  36 + // Safari/537.36")
  37 + .build();
  38 +
  39 + Response response = chain.proceed(request);
  40 + return response.newBuilder()
  41 + .removeHeader("Pragma")
  42 + .removeHeader("Cache-Control")
  43 + .header("Cache-Control", "public, max-age=" + maxAge)
  44 + .build();
  45 + }
  46 +
  47 + return chain.proceed(request);
  48 + }
  49 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/helper/okhttp/NoNetInterceptor.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/helper/okhttp/NoNetInterceptor.java
... ... @@ -0,0 +1,50 @@
  1 +package com.share.mvpsdk.helper.okhttp;
  2 +
  3 +
  4 +import com.share.mvpsdk.utils.AppUtils;
  5 +import com.share.mvpsdk.utils.NetworkConnectionUtils;
  6 +
  7 +import java.io.IOException;
  8 +
  9 +import okhttp3.CacheControl;
  10 +import okhttp3.Interceptor;
  11 +import okhttp3.Request;
  12 +import okhttp3.Response;
  13 +
  14 +import static com.share.mvpsdk.utils.HttpUtils.getUserAgent;
  15 +
  16 +/**
  17 + * Created by Horrarndoo on 2017/9/18.
  18 + * <p>
  19 + * 无网络时的缓存拦截器
  20 + */
  21 +
  22 +public class NoNetInterceptor implements Interceptor {
  23 + @Override
  24 + public Response intercept(Chain chain) throws IOException {
  25 + // 无网络时,设置超时为4周
  26 + int maxStale = 60 * 60 * 24 * 28;
  27 + Request request = chain.request();
  28 +
  29 + if (!NetworkConnectionUtils.isNetworkConnected(AppUtils.getContext())) {
  30 + request = request.newBuilder()
  31 + .cacheControl(CacheControl.FORCE_CACHE)
  32 + .removeHeader("User-Agent")
  33 + .header("User-Agent", getUserAgent())
  34 + // .header("User-Agent", "Mozilla/5.0 (Windows NT 6.1;
  35 + // WOW64) AppleWebKit/537.36" +
  36 + // " (KHTML, like Gecko) Chrome/50.0.2661.102
  37 + // Safari/537.36")
  38 + .build();
  39 +
  40 + Response response = chain.proceed(request);
  41 + return response.newBuilder()
  42 + .removeHeader("Pragma")
  43 + .removeHeader("Cache-Control")
  44 + .header("Cache-Control", "public, only-if-cached, max-stale=" + maxStale)
  45 + .build();
  46 + }
  47 +
  48 + return chain.proceed(request);
  49 + }
  50 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/helper/okhttp/TrustManager.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/helper/okhttp/TrustManager.java
... ... @@ -0,0 +1,54 @@
  1 +package com.share.mvpsdk.helper.okhttp;
  2 +
  3 +import java.security.cert.CertificateException;
  4 +import java.security.cert.X509Certificate;
  5 +
  6 +import javax.net.ssl.SSLContext;
  7 +import javax.net.ssl.SSLSocketFactory;
  8 +import javax.net.ssl.X509TrustManager;
  9 +
  10 +/**
  11 + * Created by Horrarndoo on 2017/9/12.
  12 + * <p>
  13 + */
  14 +public class TrustManager {
  15 +
  16 + public static SSLSocketFactory getUnsafeOkHttpClient() {
  17 + try {
  18 + // Create a trust manager that does not validate certificate chains
  19 + final X509TrustManager[] trustAllCerts = new X509TrustManager[]{new X509TrustManager() {
  20 + @Override
  21 + public void checkClientTrusted(
  22 + X509Certificate[] chain,
  23 + String authType) throws CertificateException {
  24 + }
  25 +
  26 + @Override
  27 + public void checkServerTrusted(
  28 + X509Certificate[] chain,
  29 + String authType) throws CertificateException {
  30 + }
  31 +
  32 + @Override
  33 + public X509Certificate[] getAcceptedIssuers() {
  34 + return new X509Certificate[0];
  35 + }
  36 + }};
  37 +
  38 + // Install the all-trusting trust manager
  39 + final SSLContext sslContext = SSLContext.getInstance("TLS");
  40 + sslContext.init(null, trustAllCerts,
  41 + new java.security.SecureRandom());
  42 + // Create an ssl socket factory with our all-trusting manager
  43 + final SSLSocketFactory sslSocketFactory = sslContext
  44 + .getSocketFactory();
  45 +
  46 +
  47 + return sslSocketFactory;
  48 + } catch (Exception e) {
  49 + throw new RuntimeException(e);
  50 + }
  51 +
  52 + }
  53 +}
  54 +
... ...
mvpsdk/src/main/java/com/share/mvpsdk/rxbus/BusData.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/rxbus/BusData.java
... ... @@ -0,0 +1,34 @@
  1 +package com.share.mvpsdk.rxbus;
  2 +
  3 +/**
  4 + * RxBus data
  5 + * Created by gorden on 2016/7/8.
  6 + */
  7 +public class BusData {
  8 + String id;
  9 + String status;
  10 +
  11 + public BusData() {
  12 + }
  13 +
  14 + public BusData(String id, String status) {
  15 + this.id = id;
  16 + this.status = status;
  17 + }
  18 +
  19 + public String getId() {
  20 + return id;
  21 + }
  22 +
  23 + public void setId(String id) {
  24 + this.id = id;
  25 + }
  26 +
  27 + public String getStatus() {
  28 + return status;
  29 + }
  30 +
  31 + public void setStatus(String status) {
  32 + this.status = status;
  33 + }
  34 +}
0 35 \ No newline at end of file
... ...
mvpsdk/src/main/java/com/share/mvpsdk/rxbus/RxBus.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/rxbus/RxBus.java
... ... @@ -0,0 +1,355 @@
  1 +package com.share.mvpsdk.rxbus;
  2 +
  3 +import java.lang.reflect.Method;
  4 +import java.util.ArrayList;
  5 +import java.util.HashMap;
  6 +import java.util.Iterator;
  7 +import java.util.List;
  8 +import java.util.Map;
  9 +
  10 +import io.reactivex.BackpressureStrategy;
  11 +import io.reactivex.Flowable;
  12 +import io.reactivex.Scheduler;
  13 +import io.reactivex.android.schedulers.AndroidSchedulers;
  14 +import io.reactivex.disposables.Disposable;
  15 +import io.reactivex.functions.Consumer;
  16 +import io.reactivex.functions.Function;
  17 +import io.reactivex.functions.Predicate;
  18 +import io.reactivex.schedulers.Schedulers;
  19 +import io.reactivex.subjects.PublishSubject;
  20 +import io.reactivex.subjects.Subject;
  21 +
  22 +/**
  23 + * RxBus
  24 + * Created by gorden on 2016/5/12.
  25 + * update 2017/3/1
  26 + */
  27 +@SuppressWarnings("unused")
  28 +public class RxBus {
  29 + public static final String LOG_BUS = "RXBUS_LOG";
  30 + private static volatile RxBus defaultInstance;
  31 +
  32 + private Map<Class, List<Disposable>> subscriptionsByEventType = new HashMap<>();
  33 +
  34 + private Map<Object, List<Class>> eventTypesBySubscriber = new HashMap<>();
  35 +
  36 + private Map<Class, List<SubscriberMethod>> subscriberMethodByEventType = new HashMap<>();
  37 +
  38 + private final Subject<Object> bus;
  39 +
  40 + private RxBus() {
  41 + this.bus = PublishSubject.create().toSerialized();
  42 + }
  43 +
  44 + public static RxBus get() {
  45 + RxBus rxBus = defaultInstance;
  46 + if (defaultInstance == null) {
  47 + synchronized (RxBus.class) {
  48 + rxBus = defaultInstance;
  49 + if (defaultInstance == null) {
  50 + rxBus = new RxBus();
  51 + defaultInstance = rxBus;
  52 + }
  53 + }
  54 + }
  55 + return rxBus;
  56 + }
  57 +
  58 + /**
  59 + * 根据传递的 eventType 类型返回特定类型(eventType)的 被观察者
  60 + *
  61 + * @param eventType 事件类型
  62 + * @return return
  63 + */
  64 + private <T> Flowable<T> toObservable(Class<T> eventType) {
  65 + return bus.toFlowable(BackpressureStrategy.BUFFER).ofType(eventType);
  66 + }
  67 +
  68 + /**
  69 + * 根据传递的code和 eventType 类型返回特定类型(eventType)的 被观察者
  70 + *
  71 + * @param code 事件code
  72 + * @param eventType 事件类型
  73 + */
  74 + private <T> Flowable<T> toObservable(final int code, final Class<T> eventType) {
  75 + return bus.toFlowable(BackpressureStrategy.BUFFER).ofType(Message.class)
  76 + .filter(new Predicate<Message>() {
  77 + @Override
  78 + public boolean test(Message o) throws Exception {
  79 + return o.getCode() == code && eventType.isInstance(o.getObject());
  80 + }
  81 + }).map(new Function<Message, Object>() {
  82 + @Override
  83 + public Object apply(Message o) throws Exception {
  84 + return o.getObject();
  85 + }
  86 + }).cast(eventType);
  87 + }
  88 +
  89 + /**
  90 + * 注册
  91 + *
  92 + * @param subscriber 订阅者
  93 + */
  94 + public void register(Object subscriber) {
  95 + Class<?> subClass = subscriber.getClass();
  96 + Method[] methods = subClass.getDeclaredMethods();
  97 + for (Method method : methods) {
  98 + if (method.isAnnotationPresent(Subscribe.class)) {
  99 + //获得参数类型
  100 + Class[] parameterType = method.getParameterTypes();
  101 + //参数不为空 且参数个数为1
  102 + if (parameterType != null && parameterType.length == 1) {
  103 +
  104 + Class eventType = parameterType[0];
  105 +
  106 + addEventTypeToMap(subscriber, eventType);
  107 + Subscribe sub = method.getAnnotation(Subscribe.class);
  108 + int code = sub.code();
  109 + ThreadMode threadMode = sub.threadMode();
  110 +
  111 + SubscriberMethod subscriberMethod = new SubscriberMethod(subscriber, method, eventType, code, threadMode);
  112 + addSubscriberToMap(eventType, subscriberMethod);
  113 +
  114 + addSubscriber(subscriberMethod);
  115 + } else if (parameterType == null || parameterType.length == 0) {
  116 +
  117 + Class eventType = BusData.class;
  118 +
  119 + addEventTypeToMap(subscriber, eventType);
  120 + Subscribe sub = method.getAnnotation(Subscribe.class);
  121 + int code = sub.code();
  122 + ThreadMode threadMode = sub.threadMode();
  123 +
  124 + SubscriberMethod subscriberMethod = new SubscriberMethod(subscriber, method, eventType, code, threadMode);
  125 + addSubscriberToMap(eventType, subscriberMethod);
  126 +
  127 + addSubscriber(subscriberMethod);
  128 +
  129 + }
  130 + }
  131 + }
  132 + }
  133 +
  134 +
  135 + /**
  136 + * 将event的类型以订阅中subscriber为key保存到map里
  137 + *
  138 + * @param subscriber 订阅者
  139 + * @param eventType event类型
  140 + */
  141 + private void addEventTypeToMap(Object subscriber, Class eventType) {
  142 + List<Class> eventTypes = eventTypesBySubscriber.get(subscriber);
  143 + if (eventTypes == null) {
  144 + eventTypes = new ArrayList<>();
  145 + eventTypesBySubscriber.put(subscriber, eventTypes);
  146 + }
  147 +
  148 + if (!eventTypes.contains(eventType)) {
  149 + eventTypes.add(eventType);
  150 + }
  151 + }
  152 +
  153 + /**
  154 + * 将注解方法信息以event类型为key保存到map中
  155 + *
  156 + * @param eventType event类型
  157 + * @param subscriberMethod 注解方法信息
  158 + */
  159 + private void addSubscriberToMap(Class eventType, SubscriberMethod subscriberMethod) {
  160 + List<SubscriberMethod> subscriberMethods = subscriberMethodByEventType.get(eventType);
  161 + if (subscriberMethods == null) {
  162 + subscriberMethods = new ArrayList<>();
  163 + subscriberMethodByEventType.put(eventType, subscriberMethods);
  164 + }
  165 +
  166 + if (!subscriberMethods.contains(subscriberMethod)) {
  167 + subscriberMethods.add(subscriberMethod);
  168 + }
  169 + }
  170 +
  171 + /**
  172 + * 将订阅事件以event类型为key保存到map,用于取消订阅时用
  173 + *
  174 + * @param eventType event类型
  175 + * @param disposable 订阅事件
  176 + */
  177 + private void addSubscriptionToMap(Class eventType, Disposable disposable) {
  178 + List<Disposable> disposables = subscriptionsByEventType.get(eventType);
  179 + if (disposables == null) {
  180 + disposables = new ArrayList<>();
  181 + subscriptionsByEventType.put(eventType, disposables);
  182 + }
  183 +
  184 + if (!disposables.contains(disposable)) {
  185 + disposables.add(disposable);
  186 + }
  187 + }
  188 +
  189 + /**
  190 + * 用RxJava添加订阅者
  191 + *
  192 + * @param subscriberMethod d
  193 + */
  194 + @SuppressWarnings("unchecked")
  195 + private void addSubscriber(final SubscriberMethod subscriberMethod) {
  196 + Flowable flowable;
  197 + if (subscriberMethod.code == -1) {
  198 + flowable = toObservable(subscriberMethod.eventType);
  199 + } else {
  200 + flowable = toObservable(subscriberMethod.code, subscriberMethod.eventType);
  201 + }
  202 + Disposable subscription = postToObservable(flowable, subscriberMethod)
  203 + .subscribe(new Consumer<Object>() {
  204 + @Override
  205 + public void accept(Object o) throws Exception {
  206 + callEvent(subscriberMethod, o);
  207 + }
  208 + });
  209 +
  210 + addSubscriptionToMap(subscriberMethod.subscriber.getClass(), subscription);
  211 + }
  212 +
  213 + /**
  214 + * 用于处理订阅事件在那个线程中执行
  215 + *
  216 + * @param observable d
  217 + * @param subscriberMethod d
  218 + * @return Observable
  219 + */
  220 + private Flowable postToObservable(Flowable observable, SubscriberMethod subscriberMethod) {
  221 + Scheduler scheduler;
  222 + switch (subscriberMethod.threadMode) {
  223 + case MAIN:
  224 + scheduler = AndroidSchedulers.mainThread();
  225 + break;
  226 +
  227 + case NEW_THREAD:
  228 + scheduler = Schedulers.newThread();
  229 + break;
  230 +
  231 + case CURRENT_THREAD:
  232 + scheduler = Schedulers.trampoline();
  233 + break;
  234 + default:
  235 + throw new IllegalStateException("Unknown thread mode: " + subscriberMethod.threadMode);
  236 + }
  237 + return observable.observeOn(scheduler);
  238 + }
  239 +
  240 + /**
  241 + * 回调到订阅者的方法中
  242 + *
  243 + * @param method code
  244 + * @param object obj
  245 + */
  246 + private void callEvent(SubscriberMethod method, Object object) {
  247 + Class eventClass = object.getClass();
  248 + List<SubscriberMethod> methods = subscriberMethodByEventType.get(eventClass);
  249 + if (methods != null && methods.size() > 0) {
  250 + for (SubscriberMethod subscriberMethod : methods) {
  251 + Subscribe sub = subscriberMethod.method.getAnnotation(Subscribe.class);
  252 + int c = sub.code();
  253 + if (c == method.code && method.subscriber.equals(subscriberMethod.subscriber) && method.method.equals(subscriberMethod.method)) {
  254 + subscriberMethod.invoke(object);
  255 + }
  256 +
  257 + }
  258 + }
  259 + }
  260 +
  261 + /**
  262 + * 取消注册
  263 + *
  264 + * @param subscriber object
  265 + */
  266 + public void unRegister(Object subscriber) {
  267 + List<Class> subscribedTypes = eventTypesBySubscriber.get(subscriber);
  268 + if (subscribedTypes != null) {
  269 + for (Class<?> eventType : subscribedTypes) {
  270 + unSubscribeByEventType(subscriber.getClass());
  271 + unSubscribeMethodByEventType(subscriber, eventType);
  272 + }
  273 + eventTypesBySubscriber.remove(subscriber);
  274 + }
  275 + }
  276 +
  277 + /**
  278 + * subscriptions unsubscribe
  279 + *
  280 + * @param eventType eventType
  281 + */
  282 + private void unSubscribeByEventType(Class eventType) {
  283 + List<Disposable> disposables = subscriptionsByEventType.get(eventType);
  284 + if (disposables != null) {
  285 + Iterator<Disposable> iterator = disposables.iterator();
  286 + while (iterator.hasNext()) {
  287 + Disposable disposable = iterator.next();
  288 + if (disposable != null && !disposable.isDisposed()) {
  289 + disposable.dispose();
  290 + iterator.remove();
  291 + }
  292 + }
  293 + }
  294 + }
  295 +
  296 + /**
  297 + * 移除subscriber对应的subscriberMethods
  298 + *
  299 + * @param subscriber subscriber
  300 + * @param eventType eventType
  301 + */
  302 + private void unSubscribeMethodByEventType(Object subscriber, Class eventType) {
  303 + List<SubscriberMethod> subscriberMethods = subscriberMethodByEventType.get(eventType);
  304 + if (subscriberMethods != null) {
  305 + Iterator<SubscriberMethod> iterator = subscriberMethods.iterator();
  306 + while (iterator.hasNext()) {
  307 + SubscriberMethod subscriberMethod = iterator.next();
  308 + if (subscriberMethod.subscriber.equals(subscriber)) {
  309 + iterator.remove();
  310 + }
  311 + }
  312 + }
  313 + }
  314 +
  315 + public void send(int code, Object o) {
  316 + bus.onNext(new Message(code, o));
  317 + }
  318 +
  319 + public void send(Object o) {
  320 + bus.onNext(o);
  321 + }
  322 +
  323 + public void send(int code) {
  324 + bus.onNext(new Message(code, new BusData()));
  325 + }
  326 +
  327 + private class Message {
  328 + private int code;
  329 + private Object object;
  330 +
  331 + public Message() {
  332 + }
  333 +
  334 + private Message(int code, Object o) {
  335 + this.code = code;
  336 + this.object = o;
  337 + }
  338 +
  339 + private int getCode() {
  340 + return code;
  341 + }
  342 +
  343 + public void setCode(int code) {
  344 + this.code = code;
  345 + }
  346 +
  347 + private Object getObject() {
  348 + return object;
  349 + }
  350 +
  351 + public void setObject(Object object) {
  352 + this.object = object;
  353 + }
  354 + }
  355 +}
0 356 \ No newline at end of file
... ...
mvpsdk/src/main/java/com/share/mvpsdk/rxbus/Subscribe.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/rxbus/Subscribe.java
... ... @@ -0,0 +1,21 @@
  1 +package com.share.mvpsdk.rxbus;
  2 +
  3 +import java.lang.annotation.Documented;
  4 +import java.lang.annotation.ElementType;
  5 +import java.lang.annotation.Retention;
  6 +import java.lang.annotation.RetentionPolicy;
  7 +import java.lang.annotation.Target;
  8 +
  9 +
  10 +/**
  11 + * Rxbus
  12 + * Created by gorden on 2016/7/23.
  13 + */
  14 +@Documented
  15 +@Target(ElementType.METHOD)
  16 +@Retention(RetentionPolicy.RUNTIME)
  17 +public @interface Subscribe {
  18 + int code() default -1;
  19 +
  20 + ThreadMode threadMode() default ThreadMode.CURRENT_THREAD;
  21 +}
0 22 \ No newline at end of file
... ...
mvpsdk/src/main/java/com/share/mvpsdk/rxbus/SubscriberMethod.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/rxbus/SubscriberMethod.java
... ... @@ -0,0 +1,44 @@
  1 +package com.share.mvpsdk.rxbus;
  2 +
  3 +import java.lang.reflect.InvocationTargetException;
  4 +import java.lang.reflect.Method;
  5 +
  6 +/**
  7 + *
  8 + * Created by gorden on 2016/7/23.
  9 + */
  10 +public class SubscriberMethod {
  11 + public Method method;
  12 + public ThreadMode threadMode;
  13 + public Class<?> eventType;
  14 + public Object subscriber;
  15 + public int code;
  16 +
  17 + public SubscriberMethod(Object subscriber, Method method, Class<?> eventType, int code,ThreadMode threadMode) {
  18 + this.method = method;
  19 + this.threadMode = threadMode;
  20 + this.eventType = eventType;
  21 + this.subscriber = subscriber;
  22 + this.code = code;
  23 + }
  24 +
  25 +
  26 + /**
  27 + * 调用方法
  28 + * @param o 参数
  29 + */
  30 + public void invoke(Object o){
  31 + try {
  32 + Class[] parameterType = method.getParameterTypes();
  33 + if(parameterType != null && parameterType.length == 1){
  34 + method.invoke(subscriber, o);
  35 + }else if(parameterType == null || parameterType.length == 0){
  36 + method.invoke(subscriber);
  37 + }
  38 + } catch (IllegalAccessException e) {
  39 + e.printStackTrace();
  40 + } catch (InvocationTargetException e) {
  41 + e.printStackTrace();
  42 + }
  43 + }
  44 +}
0 45 \ No newline at end of file
... ...
mvpsdk/src/main/java/com/share/mvpsdk/rxbus/ThreadMode.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/rxbus/ThreadMode.java
... ... @@ -0,0 +1,23 @@
  1 +package com.share.mvpsdk.rxbus;
  2 +
  3 +/**
  4 + *
  5 + * Created by gorden on 2016/7/23.
  6 + */
  7 +public enum ThreadMode {
  8 + /**
  9 + * current thread
  10 + */
  11 + CURRENT_THREAD,
  12 +
  13 + /**
  14 + * android main thread
  15 + */
  16 + MAIN,
  17 +
  18 +
  19 + /**
  20 + * new thread
  21 + */
  22 + NEW_THREAD
  23 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/utils/AppUtils.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/utils/AppUtils.java
... ... @@ -0,0 +1,185 @@
  1 +package com.share.mvpsdk.utils;
  2 +
  3 +import android.annotation.SuppressLint;
  4 +import android.content.ClipData;
  5 +import android.content.ClipboardManager;
  6 +import android.content.Context;
  7 +import android.content.Intent;
  8 +import android.content.pm.PackageInfo;
  9 +import android.content.pm.PackageManager;
  10 +import android.net.Uri;
  11 +import android.os.Environment;
  12 +import android.os.Handler;
  13 +import android.telephony.TelephonyManager;
  14 +import android.util.Log;
  15 +import android.view.inputmethod.InputMethodManager;
  16 +import android.widget.EditText;
  17 +
  18 +
  19 +import com.share.mvpsdk.global.GlobalApplication;
  20 +
  21 +import java.io.File;
  22 +
  23 +import timber.log.Timber;
  24 +
  25 +/**
  26 + * Created by Horrarndoo on 2017/8/31.
  27 + * <p>
  28 + * App工具类
  29 + */
  30 +public class AppUtils {
  31 +
  32 + /**
  33 + * 获取上下文对象
  34 + *
  35 + * @return 上下文对象
  36 + */
  37 + public static Context getContext() {
  38 + return GlobalApplication.getContext();
  39 + }
  40 +
  41 + /**
  42 + * 获取全局handler
  43 + *
  44 + * @return 全局handler
  45 + */
  46 + public static Handler getHandler() {
  47 + return GlobalApplication.getHandler();
  48 + }
  49 +
  50 + /**
  51 + * 获取主线程id
  52 + *
  53 + * @return 主线程id
  54 + */
  55 + public static int getMainThreadId() {
  56 + return GlobalApplication.getMainThreadId();
  57 + }
  58 +
  59 + /**
  60 + * 获取版本名称
  61 + */
  62 + public static String getAppVersionName(Context context) {
  63 + String versionName = "";
  64 + try {
  65 + // ---get the package info---
  66 + PackageManager pm = context.getPackageManager();
  67 + PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
  68 + versionName = pi.versionName;
  69 + if (versionName == null || versionName.length() <= 0) {
  70 + return "";
  71 + }
  72 + } catch (Exception e) {
  73 + Log.e("VersionInfo", "Exception", e);
  74 + }
  75 + return versionName;
  76 + }
  77 +
  78 + /**
  79 + * 获取版本号
  80 + */
  81 + public static int getAppVersionCode(Context context) {
  82 + int versioncode = -1;
  83 + try {
  84 + // ---get the package info---
  85 + PackageManager pm = context.getPackageManager();
  86 + PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
  87 + versioncode = pi.versionCode;
  88 + } catch (Exception e) {
  89 + Log.e("VersionInfo", "Exception", e);
  90 + }
  91 + return versioncode;
  92 + }
  93 +
  94 + @SuppressLint("MissingPermission")
  95 + public static String getIMEI(Context context) {
  96 + TelephonyManager tm = (TelephonyManager) context.getSystemService(Context
  97 + .TELEPHONY_SERVICE);
  98 + return tm.getDeviceId();
  99 + }
  100 +
  101 + /**
  102 + * 显示软键盘
  103 + */
  104 + public static void openSoftInput(EditText et) {
  105 + InputMethodManager inputMethodManager = (InputMethodManager) et.getContext()
  106 + .getSystemService(Context.INPUT_METHOD_SERVICE);
  107 + inputMethodManager.showSoftInput(et, InputMethodManager.HIDE_NOT_ALWAYS);
  108 + }
  109 +
  110 + /**
  111 + * 隐藏软键盘
  112 + */
  113 + public static void hideSoftInput(EditText et) {
  114 + InputMethodManager inputMethodManager = (InputMethodManager) et.getContext()
  115 + .getSystemService(Context.INPUT_METHOD_SERVICE);
  116 + inputMethodManager.hideSoftInputFromWindow(et.getWindowToken(), InputMethodManager
  117 + .HIDE_NOT_ALWAYS);
  118 + }
  119 +
  120 + /**
  121 + * 获取SD卡路径
  122 + *
  123 + * @return 如果sd卡不存在则返回null
  124 + */
  125 + public static File getSDPath() {
  126 + File sdDir = null;
  127 + boolean sdCardExist = Environment.getExternalStorageState().equals(Environment
  128 + .MEDIA_MOUNTED); //判断sd卡是否存在
  129 + if (sdCardExist) {
  130 + sdDir = Environment.getExternalStorageDirectory();//获取跟目录
  131 + }
  132 + return sdDir;
  133 + }
  134 +
  135 + /**
  136 + * 安装文件
  137 + *
  138 + * @param data
  139 + */
  140 + public static void promptInstall(Context context, Uri data) {
  141 + Intent promptInstall = new Intent(Intent.ACTION_VIEW)
  142 + .setDataAndType(data, "application/vnd.android.package-archive");
  143 + // FLAG_ACTIVITY_NEW_TASK 可以保证安装成功时可以正常打开 app
  144 + promptInstall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  145 + context.startActivity(promptInstall);
  146 + }
  147 +
  148 + public static void copy2clipboard(Context context, String text) {
  149 + ClipboardManager cm = (ClipboardManager) context.getSystemService(Context
  150 + .CLIPBOARD_SERVICE);
  151 + ClipData clip = ClipData.newPlainText("clip", text);
  152 + cm.setPrimaryClip(clip);
  153 + }
  154 +
  155 + /**
  156 + * 判断是否运行在主线程
  157 + *
  158 + * @return true:当前线程运行在主线程
  159 + * fasle:当前线程没有运行在主线程
  160 + */
  161 + public static boolean isRunOnUIThread() {
  162 + // 获取当前线程id, 如果当前线程id和主线程id相同, 那么当前就是主线程
  163 + int myTid = android.os.Process.myTid();
  164 + if (myTid == getMainThreadId()) {
  165 + return true;
  166 + }
  167 + return false;
  168 + }
  169 +
  170 + /**
  171 + * 运行在主线程
  172 + *
  173 + * @param r 运行的Runnable对象
  174 + */
  175 + public static void runOnUIThread(Runnable r) {
  176 + if (isRunOnUIThread()) {
  177 + // 已经是主线程, 直接运行
  178 + r.run();
  179 + } else {
  180 + // 如果是子线程, 借助handler让其运行在主线程
  181 + Log.d("66666","getHander="+getHandler()+"r="+r);
  182 + getHandler().post(r);
  183 + }
  184 + }
  185 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/utils/DBUtils.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/utils/DBUtils.java
... ... @@ -0,0 +1,108 @@
  1 +package com.share.mvpsdk.utils;
  2 +
  3 +import android.content.ContentValues;
  4 +import android.content.Context;
  5 +import android.database.Cursor;
  6 +import android.database.sqlite.SQLiteDatabase;
  7 +import android.database.sqlite.SQLiteOpenHelper;
  8 +
  9 +import com.share.mvpsdk.config.DBConfig;
  10 +
  11 +
  12 +/**
  13 + * Created by Horrarndoo on 2017/8/31.
  14 + * <p>
  15 + * 数据库工具类
  16 + */
  17 +public class DBUtils {
  18 + public static final String CREATE_TABLE_IF_NOT_EXISTS = "create table if not exists %s " +
  19 + "(id integer primary key autoincrement,key text unique,is_read integer)";
  20 +
  21 + private static DBUtils sDBUtis;
  22 + private SQLiteDatabase mSQLiteDatabase;
  23 +
  24 + private DBUtils(Context context) {
  25 + mSQLiteDatabase = new DBHelper(context, DBConfig.DB_NAME + ".db")
  26 + .getWritableDatabase();
  27 + }
  28 +
  29 + public static synchronized DBUtils getDB(Context context) {
  30 + if (sDBUtis == null) {
  31 + synchronized (DBUtils.class) {
  32 + if (sDBUtis == null)
  33 + sDBUtis = new DBUtils(context);
  34 + }
  35 + }
  36 + return sDBUtis;
  37 + }
  38 +
  39 + /**
  40 + * 插入一个item已读状态到数据表
  41 + *
  42 + * @param table 数据表名
  43 + * @param key key值
  44 + * @param value 数据值
  45 + * @return 插入结果
  46 + */
  47 + public boolean insertRead(final String table, String key, int value) {
  48 + Cursor cursor = mSQLiteDatabase.query(table, null, null, null, null, null, "id asc");
  49 + //最多缓存200条
  50 + if (cursor.getCount() > 200 && cursor.moveToNext()) {
  51 + mSQLiteDatabase.delete(table, "id=?", new String[]{String.valueOf(cursor.getInt
  52 + (cursor.getColumnIndex("id")))});
  53 + }
  54 + cursor.close();
  55 + final ContentValues contentValues = new ContentValues();
  56 + contentValues.put("key", key);
  57 + contentValues.put("is_read", value);
  58 + return (mSQLiteDatabase.insertWithOnConflict(table, null, contentValues, SQLiteDatabase
  59 + .CONFLICT_REPLACE) > 0);
  60 + }
  61 +
  62 + /**
  63 + * 判断item是否已经阅读过
  64 + *
  65 + * @param table 数据表名
  66 + * @param key key值
  67 + * @param value
  68 + * @return
  69 + */
  70 + public boolean isRead(String table, String key, int value) {
  71 + boolean isRead = false;
  72 + Cursor cursor = mSQLiteDatabase.query(table, null, "key=?", new String[]{key}, null,
  73 + null, null);
  74 + if (cursor.moveToNext() && (cursor.getInt(cursor.getColumnIndex("is_read")) == value)) {
  75 + isRead = true;
  76 + }
  77 + cursor.close();
  78 + return isRead;
  79 + }
  80 +
  81 + public class DBHelper extends SQLiteOpenHelper {
  82 +
  83 + public DBHelper(Context context, String name) {
  84 + super(context, name, null, 1);
  85 + }
  86 +
  87 + @Override
  88 + public void onCreate(SQLiteDatabase db) {
  89 + //onCreate()方法只有数据库第一次被创建时才会调用,若数据库已存在,此方法不会被调用
  90 + }
  91 +
  92 + @Override
  93 + public void onOpen(SQLiteDatabase db) {
  94 + super.onOpen(db);
  95 + //数据库打开时就会被调用,将插入新表的操作方到onOpen中
  96 + db.execSQL(String.format(CREATE_TABLE_IF_NOT_EXISTS, DBConfig.TABLE_ZHIHU));
  97 + db.execSQL(String.format(CREATE_TABLE_IF_NOT_EXISTS, DBConfig.TABLE_WANGYI));
  98 + db.execSQL(String.format(CREATE_TABLE_IF_NOT_EXISTS, DBConfig.TABLE_WEIXIN));
  99 + db.execSQL(String.format(CREATE_TABLE_IF_NOT_EXISTS, DBConfig.TABLE_GANKIO_DAY));
  100 + db.execSQL(String.format(CREATE_TABLE_IF_NOT_EXISTS, DBConfig.TABLE_GANKIO_CUSTOM));
  101 + }
  102 +
  103 + @Override
  104 + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  105 + //只有数据库进行版本升级时被调用
  106 + }
  107 + }
  108 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/utils/DateUtils.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/utils/DateUtils.java
... ... @@ -0,0 +1,250 @@
  1 +package com.share.mvpsdk.utils;
  2 +
  3 +import android.text.TextUtils;
  4 +import android.text.format.DateFormat;
  5 +
  6 +import java.text.ParseException;
  7 +import java.text.SimpleDateFormat;
  8 +import java.util.Calendar;
  9 +import java.util.Date;
  10 +import java.util.Locale;
  11 +
  12 +/**
  13 + * Created by Horrarndoo on 2017/8/31.
  14 + * <p>
  15 + * 日期时间工具类
  16 + */
  17 +public class DateUtils {
  18 +
  19 + public static final long ONE_SECOND_MILLIONS = 1000;
  20 + public static final long ONE_MINUTE_MILLIONS = 60 * ONE_SECOND_MILLIONS;
  21 + public static final long ONE_HOUR_MILLIONS = 60 * ONE_MINUTE_MILLIONS;
  22 + public static final long ONE_DAY_MILLIONS = 24 * ONE_HOUR_MILLIONS;
  23 + public static final int DAY_OF_YEAR = 365;
  24 +
  25 + // 日期格式为 2016-02-03 17:04:58
  26 + public static final String PATTERN_DATE = "yyyy年MM月dd日";
  27 + public static final String PATTERN_TIME = "HH:mm:ss";
  28 + public static final String PATTERN_SPLIT = " ";
  29 + public static final String PATTERN = PATTERN_DATE + PATTERN_SPLIT + PATTERN_TIME;
  30 +
  31 + public static String getShortTime(String dateStr) {
  32 + String str;
  33 +
  34 + Date date = str2date(dateStr);
  35 + Date curDate = new Date();
  36 +
  37 + long durTime = curDate.getTime() - date.getTime();
  38 + int dayDiff = calculateDayDiff(date, curDate);
  39 +
  40 + if (durTime <= 10 * ONE_MINUTE_MILLIONS) {
  41 + str = "刚刚";
  42 + } else if (durTime < ONE_HOUR_MILLIONS) {
  43 + str = durTime / ONE_MINUTE_MILLIONS + "分钟前";
  44 + } else if (dayDiff == 0) {
  45 + str = durTime / ONE_HOUR_MILLIONS + "小时前";
  46 + } else if (dayDiff == -1) {
  47 + str = "昨天" + DateFormat.format("HH:mm", date);
  48 + } else if (isSameYear(date, curDate) && dayDiff < -1) {
  49 + str = DateFormat.format("MM-dd", date).toString();
  50 + } else {
  51 + str = DateFormat.format("yyyy-MM", date).toString();
  52 + }
  53 +
  54 + return str;
  55 + }
  56 +
  57 +
  58 +
  59 + /**
  60 + * 获取日期 PATTERN_DATE 部分
  61 + */
  62 + public static String getDate(String date) {
  63 + if (TextUtils.isEmpty(date) || !date.contains(PATTERN_SPLIT)) {
  64 + return "";
  65 + }
  66 + return date.split(PATTERN_SPLIT)[0];
  67 + }
  68 +
  69 + /**
  70 + * 原有日期上累加月
  71 + *
  72 + * @return 累加后的日期 PATTERN_DATE 部分
  73 + */
  74 + public static String addMonth(String date, int moonCount) {
  75 + //如果date为空 就用当前时间
  76 + if (TextUtils.isEmpty(date)) {
  77 + SimpleDateFormat df = new SimpleDateFormat(PATTERN_DATE + PATTERN_SPLIT + PATTERN_TIME);
  78 + date = df.format(new Date());
  79 + }
  80 + Calendar calendar = str2calendar(date);
  81 + calendar.add(Calendar.MONTH, moonCount);
  82 + return getDate(calendar2str(calendar));
  83 + }
  84 +
  85 + /**
  86 + * 计算天数差
  87 + */
  88 + public static int calculateDayDiff(Date targetTime, Date compareTime) {
  89 + boolean sameYear = isSameYear(targetTime, compareTime);
  90 + if (sameYear) {
  91 + return calculateDayDiffOfSameYear(targetTime, compareTime);
  92 + } else {
  93 + int dayDiff = 0;
  94 +
  95 + // 累计年数差的整年天数
  96 + int yearDiff = calculateYearDiff(targetTime, compareTime);
  97 + dayDiff += yearDiff * DAY_OF_YEAR;
  98 +
  99 + // 累计同一年内的天数
  100 + dayDiff += calculateDayDiffOfSameYear(targetTime, compareTime);
  101 +
  102 + return dayDiff;
  103 + }
  104 + }
  105 +
  106 + /**
  107 + * 计算同一年内的天数差
  108 + */
  109 + public static int calculateDayDiffOfSameYear(Date targetTime, Date compareTime) {
  110 + if (targetTime == null || compareTime == null) {
  111 + return 0;
  112 + }
  113 +
  114 + Calendar tarCalendar = Calendar.getInstance();
  115 + tarCalendar.setTime(targetTime);
  116 + int tarDayOfYear = tarCalendar.get(Calendar.DAY_OF_YEAR);
  117 +
  118 + Calendar compareCalendar = Calendar.getInstance();
  119 + compareCalendar.setTime(compareTime);
  120 + int comDayOfYear = compareCalendar.get(Calendar.DAY_OF_YEAR);
  121 +
  122 + return tarDayOfYear - comDayOfYear;
  123 + }
  124 +
  125 + /**
  126 + * 计算年数差
  127 + */
  128 + public static int calculateYearDiff(Date targetTime, Date compareTime) {
  129 + if (targetTime == null || compareTime == null) {
  130 + return 0;
  131 + }
  132 +
  133 + Calendar tarCalendar = Calendar.getInstance();
  134 + tarCalendar.setTime(targetTime);
  135 + int tarYear = tarCalendar.get(Calendar.YEAR);
  136 +
  137 + Calendar compareCalendar = Calendar.getInstance();
  138 + compareCalendar.setTime(compareTime);
  139 + int comYear = compareCalendar.get(Calendar.YEAR);
  140 +
  141 + return tarYear - comYear;
  142 + }
  143 +
  144 + /**
  145 + * 计算月数差
  146 + *
  147 + * @param targetTime
  148 + * @param compareTime
  149 + * @return
  150 + */
  151 + public static int calculateMonthDiff(String targetTime, String compareTime) {
  152 + return calculateMonthDiff(str2date(targetTime, PATTERN_DATE),
  153 + str2date(compareTime, PATTERN_DATE));
  154 + }
  155 +
  156 + /**
  157 + * 计算月数差
  158 + *
  159 + * @param targetTime
  160 + * @param compareTime
  161 + * @return
  162 + */
  163 + public static int calculateMonthDiff(Date targetTime, Date compareTime) {
  164 + Calendar tarCalendar = Calendar.getInstance();
  165 + tarCalendar.setTime(targetTime);
  166 + int tarYear = tarCalendar.get(Calendar.YEAR);
  167 + int tarMonth = tarCalendar.get(Calendar.MONTH);
  168 +
  169 + Calendar compareCalendar = Calendar.getInstance();
  170 + compareCalendar.setTime(compareTime);
  171 + int comYear = compareCalendar.get(Calendar.YEAR);
  172 + int comMonth = compareCalendar.get(Calendar.MONTH);
  173 + return ((tarYear - comYear) * 12 + tarMonth - comMonth);
  174 +
  175 + }
  176 +
  177 + /**
  178 + * 是否为同一年
  179 + */
  180 + public static boolean isSameYear(Date targetTime, Date compareTime) {
  181 + if (targetTime == null || compareTime == null) {
  182 + return false;
  183 + }
  184 +
  185 + Calendar tarCalendar = Calendar.getInstance();
  186 + tarCalendar.setTime(targetTime);
  187 + int tarYear = tarCalendar.get(Calendar.YEAR);
  188 +
  189 + Calendar compareCalendar = Calendar.getInstance();
  190 + compareCalendar.setTime(compareTime);
  191 + int comYear = compareCalendar.get(Calendar.YEAR);
  192 +
  193 + return tarYear == comYear;
  194 + }
  195 +
  196 + public static Date str2date(String str, String format) {
  197 + Date date = null;
  198 + try {
  199 + if (str != null) {
  200 + SimpleDateFormat sdf = new SimpleDateFormat(format);
  201 + date = sdf.parse(str);
  202 + }
  203 + } catch (ParseException e) {
  204 + e.printStackTrace();
  205 + }
  206 + return date;
  207 + }
  208 +
  209 + public static Date str2date(String str) {
  210 + return str2date(str, PATTERN);
  211 + }
  212 +
  213 + public static String date2str(Date date) {
  214 + return date2str(date, PATTERN);
  215 + }
  216 +
  217 + public static String date2str(Date date, String format) {
  218 + SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.CHINA);
  219 + return sdf.format(date);
  220 + }
  221 +
  222 + public static Calendar str2calendar(String str) {
  223 + Calendar calendar = null;
  224 + Date date = str2date(str);
  225 + if (date != null) {
  226 + calendar = Calendar.getInstance();
  227 + calendar.setTime(date);
  228 + }
  229 + return calendar;
  230 + }
  231 +
  232 +
  233 + public static Calendar str2calendar(String str, String format) {
  234 + Calendar calendar = null;
  235 + Date date = str2date(str, format);
  236 + if (date != null) {
  237 + calendar = Calendar.getInstance();
  238 + calendar.setTime(date);
  239 + }
  240 + return calendar;
  241 + }
  242 +
  243 + public static String calendar2str(Calendar calendar) {
  244 + return date2str(calendar.getTime());
  245 + }
  246 +
  247 + public static String calendar2str(Calendar calendar, String format) {
  248 + return date2str(calendar.getTime(), format);
  249 + }
  250 +}
... ...
mvpsdk/src/main/java/com/share/mvpsdk/utils/DialogUtils.java 0 → 100644
  1 +++ a/mvpsdk/src/main/java/com/share/mvpsdk/utils/DialogUtils.java
... ... @@ -0,0 +1,60 @@
  1 +package com.share.mvpsdk.utils;
  2 +
  3 +import android.app.Dialog;
  4 +import android.app.ProgressDialog;
  5 +import android.content.Context;
  6 +import android.content.DialogInterface;
  7 +import android.support.v7.app.AlertDialog;
  8 +
  9 +import com.share.mvpsdk.R;
  10 +
  11 +
  12 +/**
  13 + * Created by Horrarndoo on 2017/8/31.
  14 + * <p>
  15 + * 对话框工具类, 提供常用对话框显示, 使用support.v7包内的AlertDialog样式
  16 + */
  17 +public class DialogUtils {
  18 +
  19 + public static Dialog createProgressDialog(Context context) {
  20 + return createProgressDialog(context, true);
  21 + }
  22 +
  23 + public static Dialog createProgressDialog(Context context, boolean needCancle) {
  24 + ProgressDialog dialog = new ProgressDialog(context);
  25 + dialog.setMessage("Loading ...");
  26 + dialog.setCancelable(needCancle);
  27 + dialog.setCanceledOnTouchOutside(false);
  28 + return dialog;
  29 + }
  30 +
  31 + public static Dialog showCommonDialog(Context context, String message,
  32 + DialogInterface.OnClickListener listener) {
  33 + return showCommonDialog(context, message, context.getString(R.string.dialog_positive),
  34 + context.getString(R.string.dialog_negative), listener);
  35 + }
  36 +
  37 + public static Dialog showCommonDialog(Context context, String message, String positiveText,
  38 + String negativeText, DialogInterface.OnClickListener
  39 + listener) {
  40 + return new AlertDialog.Builder(context)
  41 + .setMessage(message)
  42 + .setPositiveButton(positiveText, listener)
  43 + .setNegativeButton(negativeText, null)
  44 + .show();
  45 + }
  46 +
  47 + public static Dialog showConfirmDialog(Context context, String message,
  48 + DialogInterface.OnClickListener listener) {
  49 + return showConfirmDialog(context, message, context.getString(R.string.dialog_positive),
  50 + listener);
  51 + }
  52 +
  53 + public static Dialog showConfirmDialog(Context context, String message, String positiveText,
  54 + DialogInterface.OnClickListener listener) {
  55 + return new AlertDialog.Builder(context)
  56 + .setMessage(message)
  57 + .setPositiveButton(positiveText, listener)
  58 + .show();
  59 + }
  60 +}
... ...