Commit 9db19690 by 倪力烽

first commit

parents
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<component name="CopyrightManager">
<settings default="" />
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/myapplication" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectInspectionProfilesVisibleTreeState">
<entry key="Project Default">
<profile-state>
<expanded-state>
<State>
<id />
</State>
<State>
<id>Android</id>
</State>
<State>
<id>Android &gt; Lint &gt; Correctness</id>
</State>
<State>
<id>Android &gt; Lint &gt; Internationalization</id>
</State>
<State>
<id>Android &gt; Lint &gt; Security</id>
</State>
<State>
<id>Android &gt; Lint &gt; Usability &gt; Typography</id>
</State>
<State>
<id>Assignment issuesGroovy</id>
</State>
<State>
<id>Bitwise operation issuesJava</id>
</State>
<State>
<id>C/C++</id>
</State>
<State>
<id>Class structureJava</id>
</State>
<State>
<id>Code style issuesJava</id>
</State>
<State>
<id>Concurrency annotation issuesJava</id>
</State>
<State>
<id>Control flow issuesJava</id>
</State>
<State>
<id>CorrectnessLintAndroid</id>
</State>
<State>
<id>GeneralC/C++</id>
</State>
<State>
<id>Gradle</id>
</State>
<State>
<id>Groovy</id>
</State>
<State>
<id>Internationalization issuesJava</id>
</State>
<State>
<id>Java</id>
</State>
<State>
<id>Java language level migration aidsJava</id>
</State>
<State>
<id>LintAndroid</id>
</State>
<State>
<id>Performance issuesJava</id>
</State>
<State>
<id>Probable bugsGradle</id>
</State>
<State>
<id>Probable bugsGroovy</id>
</State>
<State>
<id>Probable bugsJava</id>
</State>
<State>
<id>Resource management issuesJava</id>
</State>
<State>
<id>Security issuesJava</id>
</State>
<State>
<id>Threading issuesGroovy</id>
</State>
<State>
<id>Threading issuesJava</id>
</State>
<State>
<id>Type checksC/C++</id>
</State>
</expanded-state>
</profile-state>
</entry>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/EBike-Administrer-Tool.iml" filepath="$PROJECT_DIR$/EBike-Administrer-Tool.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/myapplication/myapplication.iml" filepath="$PROJECT_DIR$/myapplication/myapplication.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.senthink.ebike_administrer_tool"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
/*rotrofit*/
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.3.0'
/*rx-android-java*/
compile 'io.reactivex:rxjava:+'
compile 'com.squareup.retrofit:adapter-rxjava:+'
compile 'com.trello:rxlifecycle:+'
compile 'com.trello:rxlifecycle-components:+'
compile 'com.google.code.gson:gson:2.2.4'
//butterknife
compile 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
compile 'com.jakewharton:butterknife:5.1.1'
compile 'com.jakewharton:butterknife:5.1.1'
compile 'com.android.support:design:25.3.1'
compile files('/Users/ni/Documents/lierda/lierda_project/EBike-Administrer-Tool/libs/android-async-http-1.4.6.jar')
compile files('/Users/ni/Documents/lierda/lierda_project/EBike-Administrer-Tool/libs/org.apache.http.legacy.jar')
}
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/ni/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package com.senthink.ebike_administrer_tool;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.senthink.ebike_administrer_tool", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.senthink.ebike_administrer_tool" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity android:name=".LoginActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"/>
</application>
</manifest>
\ No newline at end of file
package com.senthink.ebike_administrer_tool;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.v7.app.AppCompatActivity;
import com.senthink.ebike_administrer_tool.utils.UIUtils;
/**
* @Description :
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/6
*/
public class BaseActivity extends AppCompatActivity {
protected final String TAG = getClass().getSimpleName();
public static BaseActivity activity;
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
// TODO: 16/9/1 add the third service. eg.umeng ...
activity = this;
((MyApplication) UIUtils.getContext()).addActivity(this);
init();
}
@Override
protected void onResume() {
super.onResume();
activity = this;
}
@Override
protected void onPause() {
super.onPause();
activity = null;
}
private void init() {
initData();
initEvents();
}
/***
* 初始化事件(监听事件等事件绑定)
*/
protected void initEvents() {
}
/**
* 绑定数据
*/
protected void initData() {
}
/**
* activity退出时将activity移出栈
*/
@Override
protected void onDestroy() {
super.onDestroy();
((MyApplication) UIUtils.getContext()).removeActivity(this);
}
}
package com.senthink.ebike_administrer_tool;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;
import com.senthink.ebike_administrer_tool.bean.LoginUser;
import com.senthink.ebike_administrer_tool.presenter.impl.LoginPresenterImpl;
import com.senthink.ebike_administrer_tool.view.LoginView;
import butterknife.BindView;
import butterknife.ButterKnife;
public class LoginActivity extends BaseActivity implements LoginView{
@BindView(R.id.et_username)
EditText userNameEt;
@BindView(R.id.et_password)
EditText pswEt;
@BindView(R.id.btn_login)
Button loginBtn;
@BindView(R.id.checkBox2)
CheckBox rememberCb;
private LoginPresenterImpl mLoginPresenter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_login);
ButterKnife.bind(this);
mLoginPresenter = new LoginPresenterImpl(this);
initView();
}
public void initView() {
loginBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mLoginPresenter.login();
}
});
}
@Override
public String getUserName() {
return userNameEt.getText().toString();
}
@Override
public String getPassWord() {
return pswEt.getText().toString();
}
@Override
public void showLoading() {
}
@Override
public void hideLoading() {
}
@Override
public void toLoginActivity(LoginUser loginUser) {
Toast.makeText(this, loginUser.getUserName() +
" login success , to MainActivity", Toast.LENGTH_SHORT).show();
saveInfo(loginUser);
Intent intent = new Intent();
intent.setClass(LoginActivity.this,MainActivity.class);
startActivity(intent);
}
@Override
public void showFailedError(String msg) {
Toast.makeText(this,
msg, Toast.LENGTH_SHORT).show();
}
/**
* @Description: 保存信息
* @param loginUser
* */
private void saveInfo(LoginUser loginUser) {
SharedPreferences preference = getSharedPreferences("loginUser", Context.MODE_PRIVATE);
SharedPreferences.Editor editor=preference.edit();
editor.putString("username", loginUser.getUserName());
editor.putString("password", loginUser.getPassWord());
editor.commit();
}
}
package com.senthink.ebike_administrer_tool;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.senthink.ebike_administrer_tool.fragment.DispatchFragment;
import com.senthink.ebike_administrer_tool.fragment.HandleIssueFragment;
import com.senthink.ebike_administrer_tool.fragment.MyInformationFragment;
import com.senthink.ebike_administrer_tool.fragment.ReplaceBatteryFragment;
import com.senthink.ebike_administrer_tool.fragment.SafeGuardFragment;
import butterknife.BindView;
/**
* @Description :
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/7
*/
public class MainActivity extends BaseActivity {
//Tab 文字
private final int[] TAB_TITLES = new int[]
{R.string.replace_battery,R.string.safeguard,
R.string.handl_issue,R.string.dispatch,R.string.me};
//Tab 图片
private final int[] TAB_IMGS = new int[]
{R.drawable.tab_replace_battery,R.drawable.tab_safegurad,
R.drawable.tab_handler_issue,R.drawable.tab_dispatch,R.drawable.tab_me};
private final Fragment[] TAB_FRAGMENT = new Fragment[]
{new ReplaceBatteryFragment(),new SafeGuardFragment(),new HandleIssueFragment()
,new DispatchFragment(),new MyInformationFragment()};
private static final int COUNT = 5;
@BindView(R.id.tablayout)
TabLayout mTabLayout;
@BindView(R.id.viewpager)
ViewPager mViewPager;
private MyViewPagerAdapter viewPagerAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_main);
initViews();
}
private void initViews() {
mTabLayout = (TabLayout)findViewById(R.id.tablayout);
setTabs(mTabLayout,this.getLayoutInflater(),TAB_TITLES,TAB_IMGS);
viewPagerAdapter = new MyViewPagerAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.viewpager);
mViewPager.setAdapter(viewPagerAdapter);
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));
mTabLayout.setOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
}
/**
* @description: 设置添加Tab
*/
private void setTabs(TabLayout tabLayout, LayoutInflater inflater, int[] tabTitlees, int[] tabImgs){
for (int i = 0; i < tabImgs.length; i++) {
TabLayout.Tab tab = tabLayout.newTab();
View view = inflater.inflate(R.layout.layout_tab_custom,null);
tab.setCustomView(view);
TextView tvTitle = (TextView)view.findViewById(R.id.tv_tab);
tvTitle.setText(tabTitlees[i]);
ImageView imgTab = (ImageView) view.findViewById(R.id.img_tab);
imgTab.setImageResource(tabImgs[i]);
tabLayout.addTab(tab);
}
}
/**
* @description: ViewPager 适配器
*/
private class MyViewPagerAdapter extends FragmentPagerAdapter {
public MyViewPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public android.support.v4.app.Fragment getItem(int position) {
return TAB_FRAGMENT[position];
}
@Override
public int getCount() {
return COUNT;
}
}
}
package com.senthink.ebike_administrer_tool;
import android.app.Application;
import android.content.Context;
import android.support.v7.app.AppCompatDelegate;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
/**
* @Description :
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/6
*/
public class MyApplication extends Application{
public final static String TAG = "BaseApplication";
public final static boolean DEBUG = true;
private static MyApplication myApplication;
private static int mainTid;
/**
* Activity集合,来管理所有的Activity
*/
private static List<BaseActivity> activities;
static {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
}
public static Application getContext() {
return myApplication;
}
@Override
public void onCreate() {
super.onCreate();
myApplication = this;
activities = new LinkedList<>();
mainTid = android.os.Process.myTid();
}
/**
* 获取application
*
* @return
*/
public static Context getApplication() {
return myApplication;
}
/**
* 获取主线程ID
*
* @return
*/
public static int getMainTid() {
return mainTid;
}
/**
* 添加一个Activity
*
* @param activity
*/
public void addActivity(BaseActivity activity) {
activities.add(activity);
}
/**
* 结束一个Activity
*
* @param activity
*/
public void removeActivity(BaseActivity activity) {
activities.remove(activity);
}
/**
* 结束当前所有Activity
*/
public static void clearActivities() {
ListIterator<BaseActivity> iterator = activities.listIterator();
BaseActivity activity;
while (iterator.hasNext()) {
activity = iterator.next();
if (activity != null) {
activity.finish();
}
}
}
/**
* 退出应运程序
*/
public static void quiteApplication() {
clearActivities();
System.exit(0);
}
}
package com.senthink.ebike_administrer_tool.api;
import com.senthink.ebike_administrer_tool.MyApplication;
import com.senthink.ebike_administrer_tool.utils.NetWorkUtil;
import java.io.File;
import java.io.IOException;
import okhttp3.Cache;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
/**
* @Description :
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/6
*/
public class ApiManager {
public static ApiManager apiManage = null;
private static final Interceptor REWRITE_CACHE_CONTROL_INTERCEPTOR = new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Response originalResponse = chain.proceed(chain.request());
if (NetWorkUtil.isNetWorkAvailable(MyApplication.getApplication())) {
int maxAge = 60; // 在线缓存在1分钟内可读取
return originalResponse.newBuilder()
.removeHeader("Pragma") // 删除原有头部的字段
.removeHeader("Cache-Control") // 删除原有头部的字段
.header("Cache-Control", "public, max-age=" + maxAge) // 替换为这些字段,以达到重写头部,存入缓存的功能
.build();
} else {
int maxStale = 60 * 60 * 24 * 28; // 离线时缓存保存4周
return originalResponse.newBuilder()
.removeHeader("Pragma")
.removeHeader("Cache-Control")
.header("Cache-Control", "public, only-if-cached, max-stale=" + maxStale)
.build();
}
}
};
public LoginApi loginApi;
public UserApi userApi;
private Object monitor = new Object();
// private static File httpCacheDirectory = new File(MyApplication.getContext().getCacheDir(), "zhihuCache");
// private static int cacheSize = 10 * 1024 * 1024; // 10 MiB
// private static Cache cache = new Cache(httpCacheDirectory, cacheSize);
// 预请求的header信息
private static final class OptionsInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request.Builder builder = chain.request().newBuilder();
Request requst = builder.addHeader("Content-type", "application/json")
.addHeader("Accept", "application/json").build();
return chain.proceed(requst);
}
}
private static OkHttpClient client = new OkHttpClient.Builder() // client 中添加了以下属性
// .addNetworkInterceptor(REWRITE_CACHE_CONTROL_INTERCEPTOR)
// .addInterceptor(new LoginInterceptor())
.build();
public static ApiManager getInstance() {
if (apiManage == null) {
synchronized (ApiManager.class) {
if (apiManage == null) {
apiManage = new ApiManager();
}
}
}
return apiManage;
}
public LoginApi postUserInfo() {
if (loginApi == null) {
synchronized (monitor) {
if (loginApi == null) {
loginApi = new Retrofit.Builder()
.baseUrl("http://10.200.2.109:9051/")
// .baseUrl("http://10.200.0.51:9051/auth")
// .client(client)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(LoginApi.class);
}
}
}
return loginApi;
}
/**
* @Description 获取Id
* */
public UserApi getUserId() {
if (userApi == null) {
synchronized (monitor) {
if (userApi == null) {
userApi = new Retrofit.Builder()
.baseUrl("http://10.200.2.109:9011/")
.client(client)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(UserApi.class);
}
}
}
return userApi;
}
}
package com.senthink.ebike_administrer_tool.api;
import com.squareup.okhttp.RequestBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.OPTIONS;
import retrofit2.http.POST;
import rx.Observable;
/**
* @Description :
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/3
*/
public interface LoginApi {
@POST("auth")
Observable<RequestBody> userLogin(@Body RequestBody bean);// <LoginUser>为请求结果后的实体类,即账号密码;route为进行post请求的实体类
}
package com.senthink.ebike_administrer_tool.api;
import com.senthink.ebike_administrer_tool.bean.GetUserByName;
import com.senthink.ebike_administrer_tool.bean.GetUserInfoById;
import retrofit2.http.GET;
import retrofit2.http.Path;
import rx.Observable;
/**
* @Description : 获取个人信息的api
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/7
*/
public interface UserApi {
// 通过userName获得userId
@GET("challenger/user/me/{loginName}")
Observable<GetUserByName> getUserId(@Path("loginName") String userName);
@GET("app/user/me/{userId}")
Observable<GetUserInfoById> getUserInfo(@Path("userId") int userId);
}
package com.senthink.ebike_administrer_tool.asynchttp;
import android.content.Context;
import android.util.Log;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import org.apache.http.HttpEntity;
/**
* 异步Http通信客户端类
*
* @author wangxy 创建时间:2015-6-30
*
*/
public class AsyncClient {
private AsyncHttpClient MCLIENT = new AsyncHttpClient();
public AsyncClient(){
MCLIENT.setTimeout(20 * 1000);
MCLIENT.setConnectTimeout(20 * 1000);
MCLIENT.setResponseTimeout(20 * 1000);
}
public void get(String url, RequestParams params,
AsyncHttpResponseHandler responseHandler) {
// MCLIENT.removeAllHeaders();
MCLIENT.addHeader("Accept", "application/json");
//MCLIENT.addHeader("charset", "utf-8");
MCLIENT.get(url, params, responseHandler);
}
public void post(String url, RequestParams params,
AsyncHttpResponseHandler responseHandler) {
// MCLIENT.removeAllHeaders();
MCLIENT.addHeader("Accept", "application/json");
MCLIENT.post(url, params, responseHandler);
}
public void post(Context context, String url, HttpEntity entity,
String contentType, AsyncHttpResponseHandler responseHandler) {
SetHttpHeader();
MCLIENT.post(context, url, entity, contentType, responseHandler);
}
public void put(String url, RequestParams params,
AsyncHttpResponseHandler responseHandler) {
MCLIENT.removeAllHeaders();
MCLIENT.put(url, params, responseHandler);
}
public void put(Context context, String url, HttpEntity entity,
String contentType, AsyncHttpResponseHandler responseHandler) {
SetHttpHeader();
MCLIENT.put(context, url, entity, contentType, responseHandler);
}
public void SetHttpHeader() {
MCLIENT.addHeader("Content-Type", "application/json");
MCLIENT.addHeader("Accept", "application/json");
}
public void RemoveHttpHeader() {
MCLIENT.removeAllHeaders();
}
public void CancelAllRequest() {
MCLIENT.cancelAllRequests(true);
Log.i("appLog", "取消网络操作");
}
public void CancelRequest(Context context) {
MCLIENT.cancelRequests(context, true);
Log.i("appLog", "取消网络操作");
}
}
package com.senthink.ebike_administrer_tool.asynchttp;
import android.content.Context;
import android.util.Log;
import com.loopj.android.http.JsonHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import org.apache.http.Header;
import org.apache.http.entity.StringEntity;
import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HTTP;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException;
/**
* 异步Http通信类
*
* @author wangxy 创建时间:2015-6-30
*
*/
public class AsyncHttp {
private Context mcontext;
private AsyncClient asyncClient = new AsyncClient();
public AsyncHttp(Context context) {
this.mcontext = context;
}
public void GetHttpClient(String url, final HttpCallback callback) {
try {
asyncClient.get(url, null, new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers,
JSONObject response) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode, response);
}
@Override
public void onSuccess(int statusCode, Header[] headers,
String responseString) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode, responseString);
}
@Override
public void onFailure(int statusCode, Header[] headers,
Throwable throwable, JSONObject errorResponse) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode, errorResponse);
Log.i("appLog", "statusCode=" + statusCode);
Log.i("appLog", "headers=" + headers);
Log.i("appLog", "throwable=" + throwable.toString());
Log.i("appLog", "errorResponse=" + errorResponse);
}
@Override
public void onFailure(int statusCode, Header[] headers,
String responseString, Throwable throwable) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode, responseString);
Log.i("appLog", "statusCode=" + statusCode);
Log.i("appLog", "headers=" + headers);
Log.i("appLog", "throwable=" + throwable.toString());
Log.i("appLog", "responseString=" + responseString);
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void PostHttpClient(String url, final HttpCallback callback) {
try {
asyncClient.post(url, null, new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers,
JSONObject response) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode, response);
}
@Override
public void onSuccess(int statusCode, Header[] headers,
String responseString) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode, responseString);
}
@Override
public void onFailure(int statusCode, Header[] headers,
Throwable throwable, JSONObject errorResponse) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode, errorResponse);
Log.i("appLog", "statusCode=" + statusCode);
Log.i("appLog", "headers=" + headers);
Log.i("appLog", "throwable=" + throwable.toString());
Log.i("appLog", "errorResponse=" + errorResponse);
}
@Override
public void onFailure(int statusCode, Header[] headers,
String responseString, Throwable throwable) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode, responseString);
Log.i("appLog", "statusCode=" + statusCode);
Log.i("appLog", "headers=" + headers);
Log.i("appLog", "throwable=" + throwable.toString());
Log.i("appLog", "responseString=" + responseString);
}
});
} catch (Exception ex) {
}
}
public void PostHttpClient(String url, RequestParams params,
final HttpCallback callback) {
try {
asyncClient.post(url, params, new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers,
JSONObject response) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode, response);
}
@Override
public void onSuccess(int statusCode, Header[] headers,
String responseString) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode, responseString);
}
@Override
public void onFailure(int statusCode, Header[] headers,
Throwable throwable, JSONObject errorResponse) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode, errorResponse);
Log.i("appLog", "statusCode=" + statusCode);
Log.i("appLog", "headers=" + headers);
Log.i("appLog", "throwable=" + throwable.toString());
Log.i("appLog", "errorResponse=" + errorResponse);
}
@Override
public void onFailure(int statusCode, Header[] headers,
String responseString, Throwable throwable) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode, responseString);
Log.i("appLog", "statusCode=" + statusCode);
Log.i("appLog", "headers=" + headers);
Log.i("appLog", "throwable=" + throwable.toString());
Log.i("appLog", "responseString=" + responseString);
}
});
} catch (Exception ex) {
}
}
public void PostHttpClient(String url, JSONObject object,
final HttpCallback callback) {
try {
StringEntity entity = new StringEntity(object.toString(), "utf-8");
entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,
"application/json"));
asyncClient.post(mcontext, url, entity, null,
new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers,
JSONObject response) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode, response);
}
@Override
public void onSuccess(int statusCode, Header[] headers,
String responseString) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode,
responseString);
}
@Override
public void onFailure(int statusCode, Header[] headers,
Throwable throwable, JSONObject errorResponse) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode,
errorResponse);
Log.i("appLog", "statusCode=" + statusCode);
Log.i("appLog", "headers=" + headers);
Log.i("appLog", "throwable=" + throwable.toString());
Log.i("appLog", "errorResponse=" + errorResponse);
}
@Override
public void onFailure(int statusCode, Header[] headers,
String responseString, Throwable throwable) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode,
responseString);
Log.i("appLog", "statusCode=" + statusCode);
Log.i("appLog", "headers=" + headers);
Log.i("appLog", "throwable=" + throwable.toString());
Log.i("appLog", "responseString=" + responseString);
}
});
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void PutHttpClient(String url, RequestParams params,
final HttpCallback callback) {
try {
asyncClient.put(url, params, new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers,
JSONObject response) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode, response);
}
@Override
public void onSuccess(int statusCode, Header[] headers,
String responseString) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode, responseString);
}
@Override
public void onFailure(int statusCode, Header[] headers,
Throwable throwable, JSONObject errorResponse) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode, errorResponse);
Log.i("appLog", "statusCode=" + statusCode);
Log.i("appLog", "headers=" + headers);
Log.i("appLog", "throwable=" + throwable.toString());
Log.i("appLog", "errorResponse=" + errorResponse);
}
@Override
public void onFailure(int statusCode, Header[] headers,
String responseString, Throwable throwable) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode, responseString);
Log.i("appLog", "statusCode=" + statusCode);
Log.i("appLog", "headers=" + headers);
Log.i("appLog", "throwable=" + throwable.toString());
Log.i("appLog", "responseString=" + responseString);
}
});
} catch (Exception ex) {
}
}
public void PutHttpClient(String url, JSONObject object,
final HttpCallback callback) {
try {
StringEntity entity = new StringEntity(object.toString(), "utf-8");
entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,
"application/json"));
asyncClient.put(mcontext, url, entity, null,
new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers,
JSONObject response) {
// TODO Auto-generated method stub
Log.i("PushActivity", "statusCode=" + statusCode);
Log.i("PushActivity", "headers=" + headers);
Log.i("PushActivity",
"response=" + response.toString());
callback.HttpCallbackResult(statusCode, response);
}
@Override
public void onSuccess(int statusCode, Header[] headers,
String responseString) {
// TODO Auto-generated method stub
Log.i("PushActivity", "statusCode=" + statusCode);
Log.i("PushActivity", "headers=" + headers);
Log.i("PushActivity", "response=" + responseString);
callback.HttpCallbackResult(statusCode,
responseString);
}
@Override
public void onFailure(int statusCode, Header[] headers,
Throwable throwable, JSONObject errorResponse) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode,
errorResponse);
Log.i("PushActivity", "statusCode=" + statusCode);
Log.i("PushActivity", "headers=" + headers);
Log.i("PushActivity",
"throwable=" + throwable.toString());
Log.i("PushActivity", "errorResponse="
+ errorResponse);
}
@Override
public void onFailure(int statusCode, Header[] headers,
String responseString, Throwable throwable) {
// TODO Auto-generated method stub
callback.HttpCallbackResult(statusCode,
responseString);
Log.i("PushActivity", "statusCode=" + statusCode);
Log.i("PushActivity", "headers=" + headers);
Log.i("PushActivity",
"throwable=" + throwable.toString());
Log.i("PushActivity", "responseString="
+ responseString);
}
});
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void CancelAllRequest() {
try {
asyncClient.CancelAllRequest();
} catch (Exception ex) {
}
}
public void CancelRequest() {
try {
asyncClient.CancelRequest(this.mcontext);
} catch (Exception ex) {
}
}
}
package com.senthink.ebike_administrer_tool.asynchttp;
import org.json.JSONObject;
/**
* 异步Http通信回调接口
* @author wangxy
* 创建时间:2015-6-30
*
*/
public interface HttpCallback {
public void HttpCallbackResult(int code, JSONObject response);
public void HttpCallbackResult(int code, String response);
}
package com.senthink.ebike_administrer_tool.bean;
import com.google.gson.annotations.SerializedName;
/**
* @Description :
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/7
*/
public class GetUserByName {
@SerializedName("data")
private UserByName userByName;
public void setUserByName(UserByName userByName) {
this.userByName = userByName;
}
public UserByName getUserByName() {
return userByName;
}
}
package com.senthink.ebike_administrer_tool.bean;
/**
* @Description : 个人信息bean
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/7
*/
public class GetUserInfoById {
/**
* id : 6
* loginName : xjl
* password : $2a$10$1y4WJRKepAStrwlZQxyxa.nrqL/KvFtYnHLk8i8N0qX8gIpThprLS
* realName : null
* telephone : null
* email : null
* address : null
* regTime : 1494481961000
* endTime : null
* orgCode : 10
* comName : kksks;
* productId : ADMIN
* userTypeId : 2
* userType : null
* chooseZoom : null
* state : 0
* stateName : null
* parentId : 0
* parentName : null
* direct : null
* businessType : null
* rejectReason : null
* rejectTime : null
* totalDealer : null
* userTypeName : null
* roles : null
* orgId : null
* companyName : null
* storeName : null
* accountDvc : null
* storeAddress : null
* storeUserName : null
* storeTel : null
* openid : null
* idCard : null
* depositState : null
* remark :
*/
private int id;
private String loginName;
private String password;
private String realName;
private String telephone;
private Object email;
private Object address;
private long regTime;
private Object endTime;
private String orgCode;
private String comName;
private String productId;
private int userTypeId;
private Object userType;
private Object chooseZoom;
private int state;
private Object stateName;
private int parentId;
private Object parentName;
private Object direct;
private Object businessType;
private Object rejectReason;
private Object rejectTime;
private Object totalDealer;
private Object userTypeName;
private Object roles;
private Object orgId;
private Object companyName;
private Object storeName;
private Object accountDvc;
private Object storeAddress;
private Object storeUserName;
private Object storeTel;
private Object openid;
private Object idCard;
private Object depositState;
private String remark;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getLoginName() {
return loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRealName() {
return realName;
}
public void setRealName(String realName) {
this.realName = realName;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public Object getEmail() {
return email;
}
public void setEmail(Object email) {
this.email = email;
}
public Object getAddress() {
return address;
}
public void setAddress(Object address) {
this.address = address;
}
public long getRegTime() {
return regTime;
}
public void setRegTime(long regTime) {
this.regTime = regTime;
}
public Object getEndTime() {
return endTime;
}
public void setEndTime(Object endTime) {
this.endTime = endTime;
}
public String getOrgCode() {
return orgCode;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public String getComName() {
return comName;
}
public void setComName(String comName) {
this.comName = comName;
}
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public int getUserTypeId() {
return userTypeId;
}
public void setUserTypeId(int userTypeId) {
this.userTypeId = userTypeId;
}
public Object getUserType() {
return userType;
}
public void setUserType(Object userType) {
this.userType = userType;
}
public Object getChooseZoom() {
return chooseZoom;
}
public void setChooseZoom(Object chooseZoom) {
this.chooseZoom = chooseZoom;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public Object getStateName() {
return stateName;
}
public void setStateName(Object stateName) {
this.stateName = stateName;
}
public int getParentId() {
return parentId;
}
public void setParentId(int parentId) {
this.parentId = parentId;
}
public Object getParentName() {
return parentName;
}
public void setParentName(Object parentName) {
this.parentName = parentName;
}
public Object getDirect() {
return direct;
}
public void setDirect(Object direct) {
this.direct = direct;
}
public Object getBusinessType() {
return businessType;
}
public void setBusinessType(Object businessType) {
this.businessType = businessType;
}
public Object getRejectReason() {
return rejectReason;
}
public void setRejectReason(Object rejectReason) {
this.rejectReason = rejectReason;
}
public Object getRejectTime() {
return rejectTime;
}
public void setRejectTime(Object rejectTime) {
this.rejectTime = rejectTime;
}
public Object getTotalDealer() {
return totalDealer;
}
public void setTotalDealer(Object totalDealer) {
this.totalDealer = totalDealer;
}
public Object getUserTypeName() {
return userTypeName;
}
public void setUserTypeName(Object userTypeName) {
this.userTypeName = userTypeName;
}
public Object getRoles() {
return roles;
}
public void setRoles(Object roles) {
this.roles = roles;
}
public Object getOrgId() {
return orgId;
}
public void setOrgId(Object orgId) {
this.orgId = orgId;
}
public Object getCompanyName() {
return companyName;
}
public void setCompanyName(Object companyName) {
this.companyName = companyName;
}
public Object getStoreName() {
return storeName;
}
public void setStoreName(Object storeName) {
this.storeName = storeName;
}
public Object getAccountDvc() {
return accountDvc;
}
public void setAccountDvc(Object accountDvc) {
this.accountDvc = accountDvc;
}
public Object getStoreAddress() {
return storeAddress;
}
public void setStoreAddress(Object storeAddress) {
this.storeAddress = storeAddress;
}
public Object getStoreUserName() {
return storeUserName;
}
public void setStoreUserName(Object storeUserName) {
this.storeUserName = storeUserName;
}
public Object getStoreTel() {
return storeTel;
}
public void setStoreTel(Object storeTel) {
this.storeTel = storeTel;
}
public Object getOpenid() {
return openid;
}
public void setOpenid(Object openid) {
this.openid = openid;
}
public Object getIdCard() {
return idCard;
}
public void setIdCard(Object idCard) {
this.idCard = idCard;
}
public Object getDepositState() {
return depositState;
}
public void setDepositState(Object depositState) {
this.depositState = depositState;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
package com.senthink.ebike_administrer_tool.bean;
/**
* @Description : 将账号密码转化为json格式
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/6
*/
public class LoginBean {
/**
* password : 123456
* username : xjl
*/
private String password;
private String username;
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
package com.senthink.ebike_administrer_tool.bean;
/**
* @Description :
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/3
*/
public class LoginBody {
String userName;
String passWord;
public void setUserName(String userName) {
this.userName = userName;
}
public void setPassWord(String passWord) {
this.passWord = passWord;
}
public String getUserName() {
return userName;
}
public String getPassWord() {
return passWord;
}
}
package com.senthink.ebike_administrer_tool.bean;
/**
* @Description : 存储账号和密码的bean
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/2
*/
public class LoginUser {
private String code;
private String userName;
private String passWord;
public String getPassWord() {
return passWord;
}
public void setPassWord(String passWord) {
this.passWord = passWord;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
package com.senthink.ebike_administrer_tool.bean;
import com.google.gson.annotations.SerializedName;
/**
* @Description :
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/7
*/
public class UserByName {
@SerializedName("productId")
private String productId;
@SerializedName("userId")
private int userId;
@SerializedName("orgCode")
private String orgCode;
@SerializedName("loginName")
private String loginName;
public void setUserId(int userId) {
this.userId = userId;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public void setProductId(String productId) {
this.productId = productId;
}
public String getLoginName() {
return loginName;
}
public String getOrgCode() {
return orgCode;
}
public String getProductId() {
return productId;
}
public int getUserId() {
return userId;
}
}
package com.senthink.ebike_administrer_tool.common;
/**
* @Description :
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/3
*/
public class Common {
private static final String BASE_URL = "http://10.200.2.109:9051";
}
package com.senthink.ebike_administrer_tool.fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.senthink.ebike_administrer_tool.R;
/**
* @Description : 调度界面
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/7
*/
public class DispatchFragment extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_dispatch,container,false);
}
}
package com.senthink.ebike_administrer_tool.fragment;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.senthink.ebike_administrer_tool.R;
/**
* @Description : 异常处理界面
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/7
*/
public class HandleIssueFragment extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_handle_issue,container,false);
}
}
package com.senthink.ebike_administrer_tool.fragment;
import android.content.Context;
import android.content.SharedPreferences;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.senthink.ebike_administrer_tool.MyApplication;
import com.senthink.ebike_administrer_tool.R;
import com.senthink.ebike_administrer_tool.bean.GetUserInfoById;
import com.senthink.ebike_administrer_tool.bean.LoginUser;
import com.senthink.ebike_administrer_tool.presenter.MyInforPresenter;
import com.senthink.ebike_administrer_tool.presenter.impl.MyInforPresenterImpl;
import com.senthink.ebike_administrer_tool.view.IMyInformationFragment;
import butterknife.BindColor;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* @Description : 个人信息界面
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/7
*/
public class MyInformationFragment extends Fragment implements IMyInformationFragment,View.OnClickListener{
MyInforPresenterImpl myInforPresenter;
@BindView(R.id.tv_real_name)
TextView mRealNameTv;
@BindView(R.id.tv_password)
TextView mPasswordTv;
@BindView(R.id.tv_telphone)
TextView mTelphoneTv;
@BindView(R.id.tv_username)
TextView mUserNmaeTv;
@BindView(R.id.iv_modify_password)
ImageView mModifyPswIv;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_me,container,false);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this,view);
initData();
}
/**
* @Description 初始化数据
* */
private void initData() {
myInforPresenter = new MyInforPresenterImpl(this);
myInforPresenter.getUserInfo("xjl");
}
/**
* @Description 获取信息失败
* @param msg 错误信息
* */
@Override
public void getInformationFailed(String msg) {
}
/**
* @Description 提交信息失败
* @param msg 失败原因
* */
@Override
public void postInformationFailed(String msg) {
}
/**
* 扫描设备
* */
@Override
public void scan() {
}
/**
* @Description 获取信息之后,显示在界面上
* @param user 用户信息bean,主要包括
* */
@Override
public void updateInfor(GetUserInfoById user) {
SharedPreferences sharedPreferences = getContext()
.getSharedPreferences("loginUser", Context.MODE_PRIVATE);
String loginName = sharedPreferences.getString("username","");
String password = sharedPreferences.getString("password","");
user.setLoginName(loginName);
user.setPassword(password);
if (user.getRealName().equals("null")) {
mRealNameTv.setText("null");
}else {
mRealNameTv.setText(user.getRealName());
}
if (user.getTelephone().equals("null")) {
mTelphoneTv.setText("null");
}else {
mRealNameTv.setText(user.getTelephone());
}
mPasswordTv.setText(password); // 设置密码
mUserNmaeTv.setText(loginName);
}
@Override
public void onClick(View v) {
int id = v.getId();
switch (id) {
case R.id.iv_modify_password:
modifyPassword();
break;
}
}
/**
* @Description 修改密码
* */
private void modifyPassword() {
myInforPresenter.modifyPassword();
}
}
package com.senthink.ebike_administrer_tool.fragment;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.senthink.ebike_administrer_tool.R;
/**
* @Description : 更换电池界面
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/7
*/
public class ReplaceBatteryFragment extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_replace_battery,container,false);
}
}
package com.senthink.ebike_administrer_tool.fragment;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.senthink.ebike_administrer_tool.R;
/**
* @Description : 维护界面
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/7
*/
public class SafeGuardFragment extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_safeguard,container,false);
}
}
package com.senthink.ebike_administrer_tool.model;
/**
* @Description :
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/2
*/
public interface BasePresenter {
void unsubscribe();
}
package com.senthink.ebike_administrer_tool.model;
import com.senthink.ebike_administrer_tool.model.callback.LoginCallback;
/**
* @Description :
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/2
*/
public interface LoginModel{
void login(String userName, String passWord, LoginCallback mCallback);
}
package com.senthink.ebike_administrer_tool.model;
import com.senthink.ebike_administrer_tool.model.callback.UserInfoCallback;
/**
* @Description :
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/7
*/
public interface UserInfoModel extends BasePresenter{
void getUserIdByUserName(String userName,UserInfoCallback callback);
void getUserInfoById(int id, UserInfoCallback callback);
}
package com.senthink.ebike_administrer_tool.model.callback;
import com.senthink.ebike_administrer_tool.bean.LoginUser;
/**
* @Description :
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/3
*/
public interface LoginCallback {
void loginSuccess(LoginUser loginUser);
void loginFailed(String msg);
}
package com.senthink.ebike_administrer_tool.model.callback;
import com.senthink.ebike_administrer_tool.bean.GetUserInfoById;
/**
* @Description : 个人信息的回调
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/8
*/
public interface UserInfoCallback {
/** 获取信息成功 */
void getInfoSuccess(GetUserInfoById user);
/** 获取信息失败 */
void getInfoFailed(String msg);
/** 修改密码成功 */
void modifySuccess();
/** 修改密码失败 */
void modifyFailed(String msg);
}
package com.senthink.ebike_administrer_tool.model.impl;
import com.senthink.ebike_administrer_tool.model.BasePresenter;
import rx.Subscription;
import rx.subscriptions.CompositeSubscription;
/**
* @Description : 解除事件的订阅
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/3
*/
public class BasePresenterImpl implements BasePresenter {
private CompositeSubscription mCompositeSubscription;
protected void addSubscription(Subscription s) {
if (this.mCompositeSubscription == null) {
this.mCompositeSubscription = new CompositeSubscription();
}
this.mCompositeSubscription.add(s);
}
@Override
public void unsubscribe() {
// TODO: 16/8/17 find when unsubcrible
if (this.mCompositeSubscription != null) {
this.mCompositeSubscription.unsubscribe();
}
}
}
package com.senthink.ebike_administrer_tool.model.impl;
import com.senthink.ebike_administrer_tool.MyApplication;
import com.senthink.ebike_administrer_tool.api.LoginApi;
import com.senthink.ebike_administrer_tool.asynchttp.AsyncHttp;
import com.senthink.ebike_administrer_tool.asynchttp.HttpCallback;
import com.senthink.ebike_administrer_tool.bean.LoginBean;
import com.senthink.ebike_administrer_tool.bean.LoginUser;
import com.senthink.ebike_administrer_tool.model.callback.LoginCallback;
import com.senthink.ebike_administrer_tool.model.LoginModel;
import org.json.JSONException;
import org.json.JSONObject;
/**
* @Description : 实现对用户名、密码的检验
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/2
*/
public class LoginModelImpl implements LoginModel {
private LoginApi loginApi;
private static final String TAG = LoginModel.class.getSimpleName();
// private RequestBody bean;
private LoginBean bean = new LoginBean();
private LoginUser loginUser = new LoginUser();
@Override
public void login(final String userName, final String passWord, final LoginCallback mCallback) {
// TODO: 2017/6/3 用户名、密码的具体验证逻辑
AsyncHttp http = new AsyncHttp(MyApplication.getContext());
JSONObject obj = new JSONObject();
String url = "http://10.200.2.109:9051/auth";
try {
obj.put("password", passWord);
obj.put("username", userName);
} catch (JSONException e) {
e.printStackTrace();
}
http.PostHttpClient(url, obj, new HttpCallback( ){
@Override
public void HttpCallbackResult(int code, JSONObject response) {
// TODO Auto-generated method stub
if(code==200) {
// saveInfo(userName,passWord,response.getString("token"));
loginUser.setUserName(userName);
loginUser.setPassWord(passWord);
// loginUser.setToken(response.getString("token"));
// saveInfo(loginUser);
mCallback.loginSuccess(loginUser);
}else {
mCallback.loginFailed("Invalid username or password");
}
}
@Override
public void HttpCallbackResult(int code, String response) {
// TODO Auto-generated method stub
}
});
}
// /**
// * @Description: 保存信息
// * @param loginUser
// * */
// private void saveInfo(LoginUser loginUser) {
// SharedPreferences preference = MyApplication.getApplication()
// .getSharedPreferences("loginUser", Context.MODE_PRIVATE);
// SharedPreferences.Editor editor=preference.edit();
// editor.putString("username",loginUser.getUserName());
// editor.putString("password",loginUser.getPassWord());
// editor.commit();
// }
}
package com.senthink.ebike_administrer_tool.model.impl;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import com.senthink.ebike_administrer_tool.MyApplication;
import com.senthink.ebike_administrer_tool.api.ApiManager;
import com.senthink.ebike_administrer_tool.api.UserApi;
import com.senthink.ebike_administrer_tool.asynchttp.AsyncClient;
import com.senthink.ebike_administrer_tool.asynchttp.AsyncHttp;
import com.senthink.ebike_administrer_tool.asynchttp.HttpCallback;
import com.senthink.ebike_administrer_tool.bean.GetUserByName;
import com.senthink.ebike_administrer_tool.bean.GetUserInfoById;
import com.senthink.ebike_administrer_tool.model.LoginModel;
import com.senthink.ebike_administrer_tool.model.UserInfoModel;
import com.senthink.ebike_administrer_tool.model.callback.UserInfoCallback;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import rx.Observer;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
/**
* @Description :
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/7
*/
public class UserInfoModelImpl extends BasePresenterImpl implements UserInfoModel {
UserApi userApi;
private static final String TAG = UserInfoModelImpl.class.getSimpleName();
@Override
public void getUserIdByUserName(String userName, final UserInfoCallback callback) {
userApi = ApiManager.getInstance().getUserId();
StringBuilder url = new StringBuilder().append("http://10.200.2.109:9011/challenger/user/get/");
url.append(userName);
AsyncHttp http = new AsyncHttp(MyApplication.getContext());
http.GetHttpClient(url.toString(), new HttpCallback() {
@Override
public void HttpCallbackResult(int code, JSONObject response) {
if (code == 200) {
try {
JSONObject obj = response.getJSONObject("data");
int id = obj.getInt("userId");
Log.i(TAG, "HttpCallbackResult: " + id);
getUserInfoById(id,callback);
} catch (JSONException e) {
e.printStackTrace();
}
}else {
Log.i(TAG, "请求失败,code =" + code);
}
}
@Override
public void HttpCallbackResult(int code, String response) {
}
});
}
@Override
public void getUserInfoById(int id, final UserInfoCallback callback) {
StringBuilder url = new StringBuilder().append("http://10.200.2.109:9011/challenger/app/user/me/");
url.append(id);
AsyncHttp http = new AsyncHttp(MyApplication.getContext());
http.GetHttpClient(url.toString(), new HttpCallback() {
@Override
public void HttpCallbackResult(int code, JSONObject response) {
if (code == 200) {
try {
JSONObject obj = response.getJSONObject("data");
String name = obj.getString("realName"); // 真实姓名
String userName = obj.getString("loginName");
String tel = obj.getString("telephone");
String psw = obj.getString("password");
Log.i(TAG, "HttpCallbackResult: " + name);
Log.i(TAG, "HttpCallbackResult: " + tel);
GetUserInfoById user = new GetUserInfoById();
user.setRealName(name);
user.setTelephone(tel);
callback.getInfoSuccess(user);
} catch (JSONException e) {
e.printStackTrace();
}
}else {
callback.getInfoFailed("信息请求失败");
}
}
@Override
public void HttpCallbackResult(int code, String response) {
}
});
}
}
package com.senthink.ebike_administrer_tool.presenter;
import com.senthink.ebike_administrer_tool.model.BasePresenter;
/**
* @Description :
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/2
*/
public interface LoginPresenter{
void login();
}
package com.senthink.ebike_administrer_tool.presenter;
import com.senthink.ebike_administrer_tool.model.BasePresenter;
/**
* @Description :
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/7
*/
public interface MyInforPresenter {
/** 获取用户信息 */
void getUserInfo(String name);
/** 修改密码 */
void modifyPassword(String psw);
}
package com.senthink.ebike_administrer_tool.presenter.impl;
import android.util.Log;
import com.senthink.ebike_administrer_tool.bean.LoginUser;
import com.senthink.ebike_administrer_tool.model.callback.LoginCallback;
import com.senthink.ebike_administrer_tool.model.impl.LoginModelImpl;
import com.senthink.ebike_administrer_tool.presenter.LoginPresenter;
import com.senthink.ebike_administrer_tool.view.LoginView;
/**
* @Description : LoginPresenter的实例化
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/3
*/
public class LoginPresenterImpl implements LoginPresenter {
private LoginModelImpl loginImpl;
private LoginView loginView;
private String TAG = LoginPresenterImpl.class.getSimpleName();
public LoginPresenterImpl(LoginView loginView) {
this.loginView = loginView;
this.loginImpl = new LoginModelImpl();
}
@Override
public void login() {
loginView.showLoading();
loginImpl.login(loginView.getUserName(), loginView.getPassWord(), new LoginCallback() {
@Override
public void loginSuccess(LoginUser loginUser) {
loginView.toLoginActivity(loginUser);
loginView.hideLoading();
loginView.toLoginActivity(loginUser);// 去View层处理存储数据的操作
}
@Override
public void loginFailed(String msg) {
loginView.showFailedError(msg);
loginView.hideLoading();
Log.i(TAG, "loginFailed: ");
}
});
}
}
package com.senthink.ebike_administrer_tool.presenter.impl;
import com.senthink.ebike_administrer_tool.bean.GetUserInfoById;
import com.senthink.ebike_administrer_tool.model.callback.UserInfoCallback;
import com.senthink.ebike_administrer_tool.model.impl.BasePresenterImpl;
import com.senthink.ebike_administrer_tool.model.impl.UserInfoModelImpl;
import com.senthink.ebike_administrer_tool.presenter.MyInforPresenter;
import com.senthink.ebike_administrer_tool.view.IMyInformationFragment;
/**
* @Description : MyInforPresenter的实例化
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/7
*/
public class MyInforPresenterImpl implements MyInforPresenter {
private UserInfoModelImpl userInfoModel;
private IMyInformationFragment fragment;
public MyInforPresenterImpl(IMyInformationFragment myInformationFragment) {
this.fragment = myInformationFragment;
userInfoModel = new UserInfoModelImpl();
}
@Override
public void getUserInfo(String name) {
userInfoModel.getUserIdByUserName(name, new UserInfoCallback() {
@Override
public void getInfoSuccess(GetUserInfoById user) {
fragment.updateInfor(user);
}
@Override
public void getInfoFailed(String msg) {
}
@Override
public void modifySuccess() {
}
@Override
public void modifyFailed(String msg) {
}
});
}
/**
* @Description 修改密码
* @param psw 密码
* */
@Override
public void modifyPassword(String psw) {
}
}
package com.senthink.ebike_administrer_tool.utils;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import java.lang.reflect.Type;
/**
* Description : Json转换工具类
* Author : lauren
* Email : lauren.liuling@gmail.com
* Blog : http://www.liuling123.com
* Date : 15/12/17
*/
public class JsonUtils {
private static Gson mGson = new Gson();
/**
* 将对象准换为json字符串
* @param object
* @param <T>
* @return
*/
public static <T> String serialize(T object) {
return mGson.toJson(object);
}
/**
* 将json字符串转换为对象
* @param json
* @param clz
* @param <T>
* @return
*/
public static <T> T deserialize(String json, Class<T> clz) throws JsonSyntaxException {
return mGson.fromJson(json, clz);
}
/**
* 将json对象转换为实体对象
* @param json
* @param clz
* @param <T>
* @return
* @throws JsonSyntaxException
*/
public static <T> T deserialize(JsonObject json, Class<T> clz) throws JsonSyntaxException {
return mGson.fromJson(json, clz);
}
/**
* 将json字符串转换为对象
* @param json
* @param type
* @param <T>
* @return
*/
public static <T> T deserialize(String json, Type type) throws JsonSyntaxException {
return mGson.fromJson(json, type);
}
}
package com.senthink.ebike_administrer_tool.utils;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
public class NetWorkUtil {
private NetWorkUtil() {}
/**
* 判断网络是否可用
*
* @param context
* @return
*/
public static boolean isNetWorkAvailable(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
return networkInfo != null && networkInfo.isConnected();
}
/**
* 检测wifi是否连接
*
* @return
*/
public static boolean isWifiConnected(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
return networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_WIFI;
}
/**
* 检测3G是否连接
*
* @return
*/
public static boolean is3gConnected(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
return networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_MOBILE;
}
}
package com.senthink.ebike_administrer_tool.utils;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import com.senthink.ebike_administrer_tool.BaseActivity;
import com.senthink.ebike_administrer_tool.MyApplication;
import com.senthink.ebike_administrer_tool.R;
/**
* Author :hymanme
* Email :hymanme@163.com
* Created at 2015/7/27
*/
public class UIUtils {
public static Context getContext() {
return MyApplication.getApplication();
}
/**
* 页面跳转
*
* @param intent
*/
public static void startActivity(Intent intent) {
// 如果不在activity里去打开activity 需要指定任务栈 需要设置标签
if (BaseActivity.activity == null) {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getContext().startActivity(intent);
} else {
BaseActivity.activity.startActivity(intent);
}
}
// /**
// * 分享
// *
// * @param context
// * @param content 分享内容
// * @param uri 分享图片uri
// */
// public static void share(Context context, String content, Uri uri) {
// Intent shareIntent = new Intent();
// shareIntent.setAction(Intent.ACTION_SEND);
// if (uri != null) {
// shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
// shareIntent.setType("image/*");
// //当用户选择短信时使用sms_body取得文字
// shareIntent.putExtra("sms_body", content);
// } else {
// shareIntent.setType("text/plain");
// }
// shareIntent.putExtra(Intent.EXTRA_TEXT, content);
// context.startActivity(Intent.createChooser(shareIntent, context.getString(R.string.share_dialog_title)));
// }
}
package com.senthink.ebike_administrer_tool.view;
/**
* @Description : fragment的一些公共接口
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/7
*/
public interface IBaseFragment {
// 获取信息失败
void getInformationFailed(String msg);
// post信息失败
void postInformationFailed(String msg);
// 扫一扫
void scan();
}
package com.senthink.ebike_administrer_tool.view;
import com.senthink.ebike_administrer_tool.bean.GetUserInfoById;
import com.senthink.ebike_administrer_tool.bean.LoginUser;
/**
* @Description : 更新信息
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/7
*/
public interface IMyInformationFragment extends IBaseFragment{
void updateInfor(GetUserInfoById user);
}
package com.senthink.ebike_administrer_tool.view;
import com.senthink.ebike_administrer_tool.bean.LoginUser;
/**
* @Description :
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/2
*/
public interface LoginView {
String getUserName();
String getPassWord();
void showLoading();
void hideLoading();
void toLoginActivity(LoginUser loginUser);
void showFailedError(String msg);
}
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="false" android:drawable="@color/tab_background_normal"/>
<item android:state_selected="true" android:drawable="@color/tab_background_selected"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:bottomLeftRadius="20dp"
android:bottomRightRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp"/>
<solid android:color="@color/login_button_color"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:drawable="@drawable/icon_x_bai"></item>
<item android:state_selected="true" android:drawable="@drawable/icon_x_bai"></item>
<item android:state_focused="true" android:drawable="@drawable/icon_x_bai"></item>
<item android:drawable="@drawable/icon_x_bai"></item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp"/>
<padding android:left="5dp"/>
<solid android:color="@color/login_frame_color"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="false" android:drawable="@drawable/icon_ddzx_n"/>
<item android:state_selected="true" android:drawable="@drawable/icon_ddzx_s"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="false" android:drawable="@drawable/icon_yccl_n"/>
<item android:state_selected="true" android:drawable="@drawable/icon_yccl_s"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="false" android:drawable="@drawable/icon_wo_n"/>
<item android:state_selected="true" android:drawable="@drawable/icon_wo_s"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="false" android:drawable="@drawable/icon_ghdc_n"/>
<item android:state_selected="true" android:drawable="@drawable/icon_ghdc_s"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="false" android:drawable="@drawable/icon_wh_n"/>
<item android:state_selected="true" android:drawable="@drawable/icon_wh_s"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:color="@color/tab_tv_selected"></item>
<item android:state_selected="false" android:color="@color/tab_tv_normal"></item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="hello world"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="异常处理"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="@color/background_color_grey"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:id="@+id/iv_logo"/>
<LinearLayout
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:layout_width="match_parent"
android:layout_height="180dp"
android:orientation="vertical"
android:background="@color/tab_background_normal"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:orientation="horizontal">
<TextView
android:gravity="center"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/user_info_name"/>
<TextView
android:id="@+id/tv_real_name"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
tools:text="nnn"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/background_color_white"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:orientation="horizontal">
<TextView
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:text="@string/user_info_tel"/>
<TextView
android:id="@+id/tv_telphone"
android:layout_alignParentRight="true"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="match_parent"
tools:text="111111111"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/background_color_white"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:orientation="horizontal">
<TextView
android:layout_alignParentLeft="true"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/user_info_username"/>
<TextView
android:id="@+id/tv_username"
android:layout_alignParentRight="true"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="match_parent"
tools:text="safegaurd"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/background_color_white"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:orientation="horizontal">
<TextView
android:gravity="center"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/user_info_password"/>
<TextView
android:id="@+id/tv_password"
android:layout_toLeftOf="@+id/iv_modify_password"
android:gravity="center"
android:password="true"
android:layout_width="wrap_content"
android:layout_height="match_parent"
tools:text="111111111"/>
<ImageView
android:layout_alignParentRight="true"
android:paddingLeft="10dp"
android:gravity="center"
android:id="@+id/iv_modify_password"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/icon_jt_you"/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="更换"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="维护"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:gravity="center_horizontal"
android:orientation="vertical"
android:background="@color/login_background"
tools:context=".LoginActivity">
<!-- Login progress -->
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:id="@+id/iv_logo"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:text="账号"
android:textColor="@color/login_text_color"
android:layout_width="70dp"
android:textSize="@dimen/login_text_size"
android:layout_height="match_parent"
android:gravity="center"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/login_input_frame"
android:orientation="horizontal"
>
<EditText
android:paddingLeft="10dp"
android:id="@+id/et_username"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.9"
android:background="@drawable/login_input_frame"
android:ems="10"
android:inputType="textPersonName"
android:text="xjl"
android:textColor="@color/login_text_color" />
<Button
android:id="@+id/bt_username_delete"
android:visibility="invisible"
android:layout_marginEnd="10dp"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="@drawable/login_edittext_selector" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:text="密码"
android:textSize="@dimen/login_text_size"
android:textColor="@color/login_text_color"
android:layout_width="70dp"
android:layout_height="match_parent"
android:gravity="center"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/login_input_frame"
android:orientation="horizontal"
>
<EditText
android:paddingLeft="10dp"
android:id="@+id/et_password"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@null"
android:ems="10"
android:layout_weight="0.9"
android:inputType="textPersonName"
android:text="123456"
android:textColor="@color/login_text_color" />
<Button
android:id="@+id/bt_password_delete"
android:layout_marginEnd="10dp"
android:visibility="invisible"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="@drawable/login_edittext_selector" />
</LinearLayout>
</LinearLayout>
<CheckBox
android:id="@+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="70dp"
android:layout_marginTop="10dp"
android:text="记住密码"
android:textColor="@color/login_text_color" />
<Button
android:layout_marginTop="20dp"
android:id="@+id/btn_login"
android:layout_width="319dp"
android:layout_height="wrap_content"
android:background="@drawable/login_btn"
android:textColor="@color/black"
android:text="登陆" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
></android.support.v4.view.ViewPager>
<android.support.design.widget.TabLayout
android:id="@+id/tablayout"
android:layout_width="match_parent"
android:layout_height="@dimen/tab_height"
style="@style/CustomTab"
></android.support.design.widget.TabLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ImageView
android:id="@+id/img_tab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
<TextView
android:id="@+id/tv_tab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="@drawable/tv_tab_selector"
/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="login_background">#2c3547</color>
<color name="login_text_color">#ffffff</color>
<color name="login_frame_color">#565d6b</color>
<color name="login_button_color">#fadc57</color>
<color name="black">#000000</color>
<color name="tab_background_normal">#ffffff</color>
<color name="tab_tv_normal">#252e41</color>
<color name="tab_tv_selected">#ffffff</color>
<color name="tab_indicator">#ffffff</color>
<color name="tab_background_selected">#252e41</color>
<color name="background_color_grey">#f1f1f1</color>
<color name="background_color_white">#e2e2e2</color>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="login_text_size">20sp</dimen>
<dimen name="tab_height">60dp</dimen>
</resources>
\ No newline at end of file
<resources>
<string name="app_name">EBike-Administrer-Tool</string>
<string name="action_sign_in">登陆</string>
<string name="replace_battery">更换电池</string>
<string name="safeguard">维护</string>
<string name="handl_issue">异常处理</string>
<string name="dispatch">调度</string>
<string name="me">我</string>
<string name="user_info_tel">手机</string>
<string name="user_info_name">名称</string>
<string name="user_info_username">用户名</string>
<string name="user_info_password">密码</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="CustomTab" parent="Widget.Design.TabLayout" >
<item name="tabIndicatorColor">@color/tab_indicator</item>
<item name="tabTextColor">@color/tab_tv_normal</item>
<item name="tabSelectedTextColor">@color/login_text_color</item>
<item name="tabBackground">@drawable/bg_tab_border_selecter</item>
<item name="tabIndicatorHeight">0dp</item>
</style>
</resources>
package com.senthink.ebike_administrer_tool;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Thu Jun 01 23:31:53 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a loginUser-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
include ':app', ':myapplication'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment