作者 zhangtao

拉取项目

正在显示 49 个修改的文件 包含 4779 行增加0 行删除

要显示太多修改。

为保证性能只显示 49 of 49+ 个文件。

*.iml
.gradle
/local.properties
/.idea/caches/build_file_checksums.ser
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
.DS_Store
/build
/captures
.externalNativeBuild
... ...
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</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" />
</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="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="7">
<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="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="6">
<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" />
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" 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="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
... ...
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
... ...
/build
... ...
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/cpp/native-lib.cpp )
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( # Specifies the target library.
native-lib
# Links the target library to the log library
# included in the NDK.
${log-lib} )
\ No newline at end of file
... ...
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.hh.xuetubao"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ""
}
}
}
buildTypes {
release {
minifyEnabled false
// minifyEnabled true // 是否混淆
// shrinkResources true // 是否去除无效的资源文件
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true // 是否混淆
shrinkResources true // 是否去除无效的资源文件
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// 混淆规则
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '27.1.1'
}
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.0.1'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
api 'com.squareup.okhttp3:logging-interceptor:3.11.0'
api 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
/* implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.jcodecraeer:xrecyclerview:1.5.9'*/
implementation 'com.android.support:recyclerview-v7:28.1.1'
implementation 'com.jcodecraeer:xrecyclerview:1.5.9'
implementation 'fm.jiecao:jiecaovideoplayer:5.5.2'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'jp.wasabeef:glide-transformations:2.0.0'
implementation 'fm.jiecao:jiecaovideoplayer:5.5'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation files('libs/AMap3DMap_7.1.0_AMapSearch_7.1.0_AMapLocation_4.7.2_20191030.jar')
}
... ...
不能预览此文件类型
不能预览此文件类型
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# 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
#指定压缩级别
-optimizationpasses 5
#不跳过非公共的库的类成员
-dontskipnonpubliclibraryclassmembers
#混淆时采用的算法
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
#把混淆类中的方法名也混淆了
-useuniqueclassmembernames
#优化时允许访问并修改有修饰符的类和类的成员
-allowaccessmodification
#将文件来源重命名为“SourceFile”字符串
-renamesourcefileattribute SourceFile
#保留行号
-keepattributes SourceFile,LineNumberTable
#保持泛型
-keepattributes Signature
#保持所有实现 Serializable 接口的类成员
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
#Fragment不需要在AndroidManifest.xml中注册,需要额外保护下
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.app.Fragment
# 保持测试相关的代码
-dontnote junit.framework.**
-dontnote junit.runner.**
-dontwarn android.test.**
-dontwarn android.support.test.**
-dontwarn org.junit.**
#okhttp
-dontwarn okhttp3.**
-keep class okhttp3.**{*;}
#okio
-dontwarn okio.**
-keep class okio.**{*;}
-keep class com.orhanobut.logger.**{*;}
# Retrofit
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
-dontwarn rx.*
-dontwarn sun.misc.**
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
long producerIndex;
long consumerIndex;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
rx.internal.util.atomic.LinkedQueueNode producerNode;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
rx.internal.util.atomic.LinkedQueueNode consumerNode;
}
# Gson
-keep class com.google.gson.stream.** { *; }
-keepattributes EnclosingMethod
-keep class com.hh.xuetubao.**{*;}
-keep class com.hh.xuetubao.bean.**{*;}
# In order to prevent proguard asmack source code
-keep class com.kenai.jbosh.** {*; }
-keep class com.novell.sasl.client.** {*; }
-keep class de.measite.smack.** {*; }
-keep class org.** {*; }
# Do not strip any method/class that is annotated with @DoNotStrip
-keep @com.facebook.common.internal.DoNotStrip class *
-keepclassmembers class * {
@com.facebook.common.internal.DoNotStrip *;
}
# Do not strip any method/class that is annotated with @DoNotOptimize
-keep @com.facebook.soloader.DoNotOptimize class *
-keepclassmembers class * {
@com.facebook.soloader.DoNotOptimize *;
}
#保持所有实现 Serializable 接口的类成员
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
#3D 地图 V5.0.0之前:
-keep class com.amap.api.maps.**{*;}
-keep class com.autonavi.amap.mapcore.*{*;}
-keep class com.amap.api.trace.**{*;}
#3D 地图 V5.0.0之后:
-keep class com.amap.api.maps.**{*;}
-keep class com.autonavi.**{*;}
-keep class com.amap.api.trace.**{*;}
#定位
-keep class com.amap.api.location.**{*;}
-keep class com.amap.api.fence.**{*;}
-keep class com.autonavi.aps.amapapi.model.**{*;}
#搜索
-keep class com.amap.api.services.**{*;}
#2D地图
-keep class com.amap.api.maps2d.**{*;}
-keep class com.amap.api.mapcore2d.**{*;}
#导航
-keep class com.amap.api.navi.**{*;}
-keep class com.autonavi.**{*;}
... ...
package com.hh.xuetubao;
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.*;
/**
* Instrumented 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() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.hh.xuetubao", appContext.getPackageName());
}
}
... ...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hh.xuetubao">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<!-- 允许程序访问WiFi网络信息 -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- 允许程序读写手机状态和身份 -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- 允许程序访问CellID或WiFi热点来获取粗略的位置 -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:name=".MyApplication"
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/NoTheme"
android:usesCleartextTraffic="true">
<meta-data
android:name="com.amap.api.v2.apikey"
android:value="64d9479176ae933006f461633143e1a6" />
<service android:name="com.amap.api.location.APSService" />
<activity
android:name=".activity.study.StudyActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait" />
<activity
android:name=".activity.study.CourseDetailActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="portrait" />
<activity
android:name=".activity.study.VipActivity"
android:screenOrientation="portrait" />
<activity
android:name=".MainActivity"
android:launchMode="singleTask">
<!-- <intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>-->
</activity>
<activity
android:name=".activity.personal.InfromationActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.personal.ResumeActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.personal.MessageActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.personal.MoneyActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.personal.DeliveryActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.study.StudyNoteActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.work.JobHuntActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.work.CompanyActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.work.CompanyDetailActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.work.OfficeDetailActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.work.OneClickDeliveryActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.pratice.PracticeActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.pratice.AnswerSheetActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.pratice.AnswerResultActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.login.LoginActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activity.personal.MoneyHistoryActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.personal.MessageDetailActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.pratice.PriacticeDistActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.pratice.MockExamActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.pratice.AnswerActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.pratice.AnswerMarkActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.pratice.TestScoreActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.pratice.AnswerWrongActivity"
android:screenOrientation="portrait" />
</application>
</manifest>
\ No newline at end of file
... ...
#include <jni.h>
#include <string>
extern "C" JNIEXPORT jstring JNICALL
Java_com_hh_xuetubao_MainActivity_stringFromJNI(
JNIEnv* env,
jobject /* this */) {
std::string hello = "Hello from C++";
return env->NewStringUTF(hello.c_str());
}
... ...
package com.hh.xuetubao;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.RadioButton;
import com.hh.xuetubao.activity.pratice.PracticeActivity;
import com.hh.xuetubao.activity.study.StudyActivity;
import com.hh.xuetubao.activity.work.JobHuntActivity;
import com.hh.xuetubao.fragment.HomeFragment;
import com.hh.xuetubao.fragment.MineFragment;
import com.hh.xuetubao.fragment.PraticeWrongFragment;
import com.hh.xuetubao.model.MainModel;
import com.hh.xuetubao.mvp.BaseMvpActivity;
import com.hh.xuetubao.mvp.CommonPresenter;
import com.hh.xuetubao.mvp.ICommonView;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* 主页面
*/
public class MainActivity extends BaseMvpActivity<CommonPresenter, MainModel> implements ICommonView, View.OnClickListener {
@BindView(R.id.rl_home)
RadioButton rlHome;
@BindView(R.id.rl_study)
RadioButton rlStudy;
@BindView(R.id.rl_job)
RadioButton rlJob;
@BindView(R.id.rl_biancheng)
RadioButton rlBiancheng;
@BindView(R.id.rl_mine)
RadioButton rlMine;
private FragmentTransaction transaction;
private MineFragment mineFragment;
private HomeFragment homeFragment;
private PraticeWrongFragment wrongFragment;
@Override
public void initView() {
/* //添加变色标志
this.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
//导航栏颜色
getWindow().setNavigationBarColor(Color.parseColor("#fcfcfc"));
//状态栏颜色
getWindow().setStatusBarColor(Color.parseColor("#fcfcfc"));*/
homeFragment = new HomeFragment();
transaction = getSupportFragmentManager().beginTransaction();
transaction.add(R.id.frame, homeFragment);
transaction.show(homeFragment);
transaction.commit();
rlHome.setChecked(true);
rlHome.setOnClickListener(this);
rlStudy.setOnClickListener(this);
rlJob.setOnClickListener(this);
rlBiancheng.setOnClickListener(this);
rlMine.setOnClickListener(this);
wrongFragment = new PraticeWrongFragment();
}
@Override
public int initLayout() {
return R.layout.activity_mine;
}
@Override
public void initData() {
}
@Override
public CommonPresenter getPresenter() {
return new CommonPresenter();
}
@Override
public MainModel getModel() {
return new MainModel();
}
@Override
public void getData(Object o, int api, int intent) {
}
@Override
public void onComplete(int api) {
}
@Override
public void onError(Throwable e, int api) {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
@Override
public void onClick(View v) {
transaction = getSupportFragmentManager().beginTransaction();
mineFragment = new MineFragment();
homeFragment = new HomeFragment();
switch (v.getId()) {
case R.id.rl_home:
transaction.replace(R.id.frame, homeFragment);
transaction.commit();
break;
case R.id.rl_study:
startActivity(new Intent(this, StudyActivity.class));
break;
case R.id.rl_job:
startActivity(new Intent(this, JobHuntActivity.class));
break;
case R.id.rl_biancheng:
startActivity(new Intent(this, PracticeActivity.class));
break;
case R.id.rl_mine:
transaction.replace(R.id.frame, mineFragment);
transaction.commit();
break;
}
}
/* private Fragment f;
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (f instanceof PraticeWrongFragment) {
PraticeWrongFragment.onKeyDown(keyCode, event);
}
return false;
}*/
@Override
protected void onResume() {
super.onResume();
rlHome.setChecked(true);
}
}
... ...
package com.hh.xuetubao;
import android.app.Application;
import android.content.Context;
public class MyApplication extends Application {
public static MyApplication sMyApplication;
@Override
public void onCreate() {
super.onCreate();
sMyApplication = this;
}
public static MyApplication getMyApplication() {
return sMyApplication;
}
public static Context getContext() {
return sMyApplication.getApplicationContext();
}
}
... ...
package com.hh.xuetubao;
import com.hh.xuetubao.bean.AddressBean;
import com.hh.xuetubao.bean.AnswerBean;
import com.hh.xuetubao.bean.CertListBean;
import com.hh.xuetubao.bean.ChapterLstBean;
import com.hh.xuetubao.bean.CompanyBean;
import com.hh.xuetubao.bean.CompanyDetailBean;
import com.hh.xuetubao.bean.CompanySearchBody;
import com.hh.xuetubao.bean.CourseDetailInfoBean;
import com.hh.xuetubao.bean.DoExerciseBean;
import com.hh.xuetubao.bean.FreeCourseBean;
import com.hh.xuetubao.bean.HotJobBean;
import com.hh.xuetubao.bean.JobSearchBody;
import com.hh.xuetubao.bean.LearningRecordDataBean;
import com.hh.xuetubao.bean.MsgListBean;
import com.hh.xuetubao.bean.MyLearningInfoBean;
import com.hh.xuetubao.bean.OfficeDetailBean;
import com.hh.xuetubao.bean.PQbean;
import com.hh.xuetubao.bean.QuestionBankLstBean;
import com.hh.xuetubao.bean.ResumeDetailBean;
import com.hh.xuetubao.bean.ResumedJobListBean;
import com.hh.xuetubao.bean.TranscriptBean;
import com.hh.xuetubao.bean.UserBean;
import io.reactivex.Observable;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
public interface MyServer {
/**
* 学习首页-获取免费课程列表接口
*
* @param pageIndex
* @param pageSize
* @return
*/
@GET("GetFreeLessonsLst")
Observable<FreeCourseBean> getFreeLessonsLst(@Query("pageIndex") int pageIndex, @Query("pageSize") int pageSize);
/**
* 练习目录接口
*
* @return
*/
@GET("GetCatalogLst")
Observable<DoExerciseBean> getCatalogLst();
/**
* 1.3获取认证课程列表接口
*
* @param accountOid 当前用户OID
* @param catalogOid 认证目录OID
* @return
*/
@GET("GetLessonLstByCatalogOid")
Observable<FreeCourseBean> getLessonLstByCatalogOid(@Query("accountOid") String accountOid, @Query("catalogOid") String catalogOid);
/**
* 课程详情接口
*
* @param lessonOid 课程ID
* @return
*/
@GET("GetCourseDetailInfo")
Observable<CourseDetailInfoBean> GetCourseDetailInfo(@Query("lessonOid") String lessonOid);
/**
* 课程目录接口
*
* @param accountOid 用户ID
* @param lessonOid 课程ID
* @return
*/
@GET("GetChapterLstByLessonOid")
Observable<ChapterLstBean> GetChapterLstByLessonOid(@Query("accountOid") String accountOid, @Query("lessonOid") String lessonOid);
/**
* 保存学习进度接口
*
* @param accountOid 用户ID
* @param currentLessonOid 当前资源所在课程IDGetCourseDetailInfo
* @param currentChapterOid 当前资源所在章ID
* @param currentSectionOid 当前资源所在节ID
* @param currentResourceOid 当前资源ID
* @param currentDuration 当前这次视频累计播放时间
* @param currentProgress 当前视频进度条的进度
* @param currentTotalLen 当前视频总时长
* @return
*/
@POST("InsertLearningProgress")
Observable<UserBean> InsertLearningProgress(@Query("accountOid") String accountOid, @Query("currentLessonOid") String currentLessonOid,
@Query("currentChapterOid") String currentChapterOid, @Query("currentSectionOid") String currentSectionOid,
@Query("currentResourceOid") String currentResourceOid, @Query("currentDuration") int currentDuration,
@Query("currentProgress") int currentProgress, @Query("currentTotalLen") int currentTotalLen);
/**
* 我的学习-用户信息接口 accountOid 用户ID
*
* @param accountOid 用户ID
* @return
*/
@GET("GetMyLearningInfo")
Observable<MyLearningInfoBean> GetMyLearningInfo(@Query("accountOid") String accountOid);
/**
* 我的学习-柱状图数据接口
*
* @param accountOid 用户ID
* @return
*/
@GET("GetLearningDurationChartData")
Observable<UserBean> GetLearningDurationChartData(@Query("accountOid") String accountOid);
/**
* 我的学习-学习记录列表接口
*
* @param accountOid 用户ID
* @param pageIndex
* @param pageSize
* @return
*/
@GET("GetLearningRecordData")
Observable<LearningRecordDataBean> GetLearningRecordData(@Query("accountOid") String accountOid, @Query("pageIndex") int pageIndex, @Query("pageSize") int pageSize);
/**
* 1.1发送验证码接口
*
* @param mobileNumber
* @param type 0:手机和验证码登录时发送,1:微信或手机号码绑定时发送
* @return
*/
@GET("SendValidateCode")
Observable<UserBean> sendValidateCode(@Query("mobileNumber") String mobileNumber, @Query("type") int type);
/**
* 手机验证码登录接口
*
* @param mobileNumber
* @param verCode 验证码
* @return
*/
@GET("MobileLogin")
Observable<UserBean> mobileLogin(@Query("mobileNumber") String mobileNumber, @Query("verCode") String verCode);
/**
* 微信登录接口
*
* @param wxOpenId 微信用户的OpenId
* @return
*/
@GET("WeixinLogin")
Observable<UserBean> WeixinLogin(@Query("wxOpenId") String wxOpenId);
/**
* 微信登录绑定接口
*
* @param wxOpenId 微信用户的OpenId
* @param mobileNumber 手机号码
* @param verCode 验证码
* @return
*/
@GET("SaveWxBinding")
Observable<UserBean> SaveWxBinding(@Query("wxOpenId") String wxOpenId, @Query("mobileNumber") String mobileNumber, @Query("verCode") String verCode);
/**
* 账号密码登录接口
*
* @param account 账号
* @param password 密码
* @return
*/
@GET("AccountLogin")
Observable<UserBean> AccountLogin(@Query("account") String account, @Query("password") String password);
/**
* 手机号码绑定接口
*
* @param account 用户账号
* @param mobileNumber 手机号码
* @param verCode 验证码
* @return
*/
@POST("SaveAccountBinding")
Observable<UserBean> SaveAccountBinding(@Query("account") String account, @Query("mobileNumber") String mobileNumber, @Query("verCode") String verCode);
/**
* 获取热门课程列表接口
*
* @param num 获取的数量
* @return
*/
@GET("GetHotLessonLst")
Observable<FreeCourseBean> GetHotLessonLst(@Query("num") int num);
/**
* 获取题库列表接口
*
* @param num 获取的数量
* @return
*/
@GET("GetQuestionBankLst")
Observable<QuestionBankLstBean> GetQuestionBankLst(@Query("num") int num);
/**
* 热门企业列表接口
*
* @param Count 查询数量
* @return
*/
@GET("HotCompanyList")
Observable<CompanyBean> HotCompanyList(@Query("Count") int Count);
/**
* 热门职位列表接口
*
* @param Count
* @return
*/
@GET("HotJobList")
Observable<HotJobBean> HotJobList(@Query("Count") int Count);
/**
* 查询职位列表接口
*
* @param jobSearchBody
* @return
*/
@POST("JobSearch")
Observable<HotJobBean> JobSearch(@Body JobSearchBody jobSearchBody);
/**
* 查询企业列表接口
*
* @param jobSearchBody
* @return
*/
@POST("CompanySearch")
Observable<CompanyBean> CompanySearch(@Body CompanySearchBody jobSearchBody);
/**
* 职位详情接口
*
* @param JobOid 职位ID
* @param AccountOid 用户ID
* @return
*/
@GET("JobDetailInfo")
Observable<OfficeDetailBean> JobDetailInfo(@Query("JobOid") String JobOid, @Query("AccountOid") String AccountOid);
/**
* 企业详情接口
*
* @param CompanyOid 职位ID
* @return
*/
@GET("CompanyDetailInfo")
Observable<CompanyDetailBean> CompanyDetailInfo(@Query("CompanyOid") String CompanyOid);
/**
* 获取默认图片接口
*
* @param ImgType 可选参数:HeadPic(头像图片),CoverPic(封面图片)
* @return
*/
@GET("GetDefaultPic")
Observable<UserBean> GetDefaultPic(@Query("ImgType") String ImgType);
/**
* 获取个人中心头部信息接口
*
* @param AccountOid 用户ID
* @return
*/
@GET("GetHeadInfo")
Observable<UserBean> GetHeadInfo(@Query("AccountOid") String AccountOid);
/**
* 获取基本信息接口
*
* @param AccountOid
* @return
*/
@GET("UserInfo")
Observable<UserBean> UserInfo(@Query("AccountOid") String AccountOid);
/**
* 修改基本信息接口
*
* @param AccountOid 用户ID
* @param UpdateType 修改类型,可选参数为:UserName,Sex,Company,WebSite
* @param Value 修改值,当类型为Sex时,男为0,女为1,当类型是WebSite时,应传入URL绝对路径
* @return
*/
@POST("UpdateUserInfo")
Observable<UserBean> UpdateUserInfo(@Query("AccountOid") String AccountOid, @Query("UpdateType") String UpdateType, @Query("Value") String Value);
/**
* 获取消息列表接口
*
* @param AccountOid 用户ID
* @param MsgType 消息类型,可选参数 系统消息:System,互动消息:Interaction
* @param Page
* @param PageSize
* @return
*/
@POST("MsgList")
Observable<MsgListBean> MsgList(@Query("AccountOid") String AccountOid, @Query("MsgType") String MsgType, @Query("Page") int Page, @Query("PageSize") int PageSize);
/**
* 变更消息已读状态接口
*
* @param MsgOid 消息ID
* @return
*/
@POST("SetNewsStatusByRead")
Observable<UserBean> SetNewsStatusByRead(@Query("MsgOid") String MsgOid);
/**
* 获取消息内容接口
*
* @param MsgOid 消息ID
* @return
*/
@GET("GetMsgContent")
Observable<UserBean> GetMsgContent(@Query("MsgOid") String MsgOid);
/**
* 获取未读消息数量接口
*
* @param AccountOid
* @return
*/
@GET("GetUserUnReadMsgCount")
Observable<UserBean> GetUserUnReadMsgCount(@Query("AccountOid") String AccountOid);
/**
* 获取PQ币数量接口
*
* @param AccountOid
* @return
*/
@GET("GetUserPQCoin")
Observable<UserBean> GetUserPQCoin(@Query("AccountOid") String AccountOid);
/**
* 获取简历信息接口
*
* @param AccountOid
* @return
*/
@POST("ResumeDetailInfo")
Observable<ResumeDetailBean> ResumeDetailInfo(@Query("AccountOid") String AccountOid);
/**
* 已投递职位列表接口
*
* @param Page
* @param PageSize
* @param AccountOid
* @return
*/
@POST("ResumedJobList")
Observable<ResumedJobListBean> ResumedJobList(@Query("Page") int Page, @Query("PageSize") int PageSize, @Query("AccountOid") String AccountOid);
/**
* 获取用户认证证书列表接口
*
* @param AccountOid
* @param Page
* @param PageSize
* @return
*/
@GET("UserCertList")
Observable<CertListBean> UserCertList(@Query("AccountOid") String AccountOid, @Query("Page") int Page, @Query("PageSize") int PageSize);
/**
* 获取PQ币历史列表接口
*
* @param AccountOid
* @param searchType 可选参数 收入:Incoming,支出:Payout。不填、空字符串或者null为全部
* @param Page
* @param PageSize
* @return
*/
@GET("PQCoinRecord")
Observable<PQbean> PQCoinRecord(@Query("AccountOid") String AccountOid, @Query("searchType") String searchType, @Query("Page") int Page, @Query("PageSize") int PageSize);
/**
* 一键投递接口
*
* @param JobOids 职位ID字符串,多个时中间逗号分隔
* @param ResumeOid 要投递的简历的唯一ID
* @return
*/
@POST("SubmitResume")
Observable<UserBean> SubmitResume(@Query("JobOids") String JobOids, @Query("ResumeOid") String ResumeOid);
/**
* 企业职位列表接口
*
* @param Count 数量
* @param CompanyOid 公司ID
* @param IsUnResumed 是否仅查询未投递简历的职位,True时仅查询未投递简历的职位,false时查询全部职位
* @param ResumeOid 简历唯一ID
* @return
*/
@GET("CompanyJobList")
Observable<HotJobBean> CompanyJobList(@Query("Count") int Count, @Query("CompanyOid") String CompanyOid, @Query("IsUnResumed") boolean IsUnResumed, @Query("ResumeOid") String ResumeOid);
/**
* 获取省份列表接口
*
* @param IsAll 当为true时,返回列表会包含,”不限”这一项
* @return
*/
@GET("GetProvinceList")
Observable<AddressBean> GetProvinceList(@Query("IsAll") boolean IsAll);
/**
* 获取城市列表接口
*
* @param ProvinceId 省份唯一id
* @param IsAll 当为true时,返回列表会包含,”不限”这一项
* @return
*/
@GET("GetCityListByProvince")
Observable<AddressBean> GetCityListByProvince(@Query("ProvinceId") String ProvinceId, @Query("IsAll") boolean IsAll);
/**
* 获取职位查询属性列表接口
*
* @param PropType 行业领域 = 0,工作职能 =1,公司性质=3,公司规模=4,薪资范围= 5,工作性质 =6,工作经验 = 7,学历= 8
* @param IsAll 当为true时,返回列表会包含,”不限”这一项
* @return
*/
@GET("GetJobPropList")
Observable<AddressBean> GetJobPropList(@Query("PropType") int PropType, @Query("IsAll") boolean IsAll);
/**
* 获取模拟题基本信息接口
*
* @param catalogOid 题库分类ID
* @param accountOid 用户ID
* @return
*/
@GET("GetSimExerciseInfo")
Observable<UserBean> GetSimExerciseInfo(@Query("catalogOid") String catalogOid, @Query("accountOid") String accountOid);
/**
* 获取模拟题列表接口
*
* @param catalogOid
* @param accountOid
* @return
*/
@GET("GetSimExamQuestions")
Observable<AnswerBean> GetSimExamQuestions(@Query("catalogOid") String catalogOid, @Query("accountOid") String accountOid);
/**
* 获取成绩单信息接口
*
* @param catalogOid
* @param accountOid
* @return
*/
@GET("GetSimExamReportInfo")
Observable<TranscriptBean> GetSimExamReportInfo(@Query("catalogOid") String catalogOid, @Query("accountOid") String accountOid);
/**
* 保存错题信息接口
*
* @param accountOid
* @param questionOid 题目ID
* @param wrongQuestionType 错题类型.0:练习,1:模拟题
* @return
*/
@POST("InsertWrongQuestion")
Observable<UserBean> InsertWrongQuestion(@Query("accountOid") String accountOid, @Query("questionOid") String questionOid, @Query("wrongQuestionType") int wrongQuestionType);
/**
* 获取错题目录列表接口
*
* @param accountOid
* @return
*/
@GET("GetWrongCatalogLst")
Observable<AnswerBean> GetWrongCatalogLst(@Query("accountOid") String accountOid);
/**
* 获取错题列表接口
*
* @param accountOidRemoveWrongQuestion
* @param catalogOid 当前目录ID
* @param wrongQuestionType 错题类型,0:练习的错题,1:模拟题的错题
* @return
*/
@GET("GetWrongQuestionsByCatalogOid")
Observable<AnswerBean> GetWrongQuestionsByCatalogOid(@Query("accountOid") String accountOid, @Query("catalogOid") String catalogOid, @Query("wrongQuestionType") int wrongQuestionType);
/**
* 删除用户错题接口
*
* @param accountOid
* @param catalogOid
* @param wrongQuestionType
* @return
*/
@GET("RemoveWrongQuestion")
Observable<AnswerBean> RemoveWrongQuestion(@Query("accountOid") String accountOid, @Query("catalogOid") String catalogOid, @Query("wrongQuestionType") int wrongQuestionType);
/**
* 获取随机习题列表接口
*
* @param catalogOid
* @param randomNum
* @param accountOid
* @return
*/
@GET("GetRandomQuestions")
Observable<AnswerBean> GetRandomQuestions(@Query("catalogOid") String catalogOid, @Query("randomNum") int randomNum, @Query("accountOid") String accountOid);
}
\ No newline at end of file
... ...
package com.hh.xuetubao.Utils;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
public class BaseObsever implements Observer {
private Disposable d;
@Override
public void onSubscribe(Disposable d) {
this.d = d;
}
@Override
public void onNext(Object value) {
}
@Override
public void onError(Throwable e) {
dispose();
}
@Override
public void onComplete() {
dispose();
}
private void dispose() {
if (d != null && d.isDisposed()) {
d.dispose();
}
}
}
... ...
package com.hh.xuetubao.Utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;
@SuppressLint("AppCompatCustomView")
public class CircleImageView extends ImageView {
private Paint mPaint; //画笔
private int mRadius; //圆形图片的半径
private float mScale; //图片的缩放比例
private Bitmap bitmap;
public CircleImageView(Context context) {
super(context);
}
public CircleImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CircleImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
//因为是圆形图片,所以应该让宽高保持一致
int size = Math.min(getMeasuredWidth(), getMeasuredHeight());
mRadius = size / 2;
setMeasuredDimension(size, size);
}
@Override
protected void onDraw(Canvas canvas) {
mPaint = new Paint();
// Bitmap bitmap = drawableToBitmap(getDrawable());
Drawable drawable = getDrawable();
if(null!=drawable) {
Bitmap bitmap = drawableToBitmap(drawable);
//初始化BitmapShader,传入bitmap对象
BitmapShader bitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
//计算缩放比例
mScale = (mRadius * 2.0f) / Math.min(bitmap.getHeight(), bitmap.getWidth());
Matrix matrix = new Matrix();
matrix.setScale(mScale, mScale);
bitmapShader.setLocalMatrix(matrix);
mPaint.setShader(bitmapShader);
//画圆形,指定好中心点坐标、半径、画笔
canvas.drawCircle(mRadius, mRadius, mRadius, mPaint);
}
}
//写一个drawble转BitMap的方法
private Bitmap drawableToBitmap(Drawable drawable) {
if (drawable instanceof BitmapDrawable) {
BitmapDrawable bd = (BitmapDrawable) drawable;
return bd.getBitmap();
}
int w = drawable.getIntrinsicWidth();
int h = drawable.getIntrinsicHeight();
bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, w, h);
drawable.draw(canvas);
return bitmap;
}
}
... ...
package com.hh.xuetubao.Utils;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.ScrollView;
public class CustomScrollView extends ScrollView {
//回调监听接口
private OnScrollChangeListener mOnScrollChangeListener;
//标识是否滑动到顶部
private boolean isScrollToStart = false;
//标识是否滑动到底部
private boolean isScrollToEnd = false;
private static final int CODE_TO_START = 0x001;
private static final int CODE_TO_END = 0x002;
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case CODE_TO_START:
//重置标志“滑动到顶部”时的标志位
isScrollToStart = false;
break;
case CODE_TO_END:
//重置标志“滑动到底部”时的标志位
isScrollToEnd = false;
break;
default:
break;
}
}
};
public CustomScrollView(Context context) {
super(context);
}
public CustomScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
if (mOnScrollChangeListener != null) {
Log.i("CustomScrollView", "scrollY:" + getScrollY());
//滚动到顶部,ScrollView存在回弹效果效应(这里只会调用两次,如果用<=0,会多次触发)
if (getScrollY() == 0) {
//过滤操作,优化为一次调用
if (!isScrollToStart) {
isScrollToStart = true;
mHandler.sendEmptyMessageDelayed(CODE_TO_START, 200);
Log.e("CustomScrollView", "toStart");
mOnScrollChangeListener.onScrollToStart();
}
} else {
View contentView = getChildAt(0);
if (contentView != null && contentView.getMeasuredHeight() == (getScrollY() + getHeight())) {
//滚动到底部,ScrollView存在回弹效果效应
//优化,只过滤第一次
if (!isScrollToEnd) {
isScrollToEnd = true;
mHandler.sendEmptyMessageDelayed(CODE_TO_END, 200);
Log.e("CustomScrollView", "toEnd,scrollY:" + getScrollY());
mOnScrollChangeListener.onScrollToEnd();
}
}
}
}
}
//滑动监听接口
public interface OnScrollChangeListener {
//滑动到顶部时的回调
void onScrollToStart();
//滑动到底部时的回调
void onScrollToEnd();
}
public void setOnScrollChangeListener(OnScrollChangeListener onScrollChangeListener) {
mOnScrollChangeListener = onScrollChangeListener;
}
}
... ...
package com.hh.xuetubao.Utils;
import android.content.Context;
import android.os.Environment;
import java.io.File;
import java.math.BigDecimal;
public class DataCleanManager {
/**
* @param context
* @return
* @throws Exception 获取当前缓存
*/
public static String getTotalCacheSize(Context context) throws Exception {
long cacheSize = getFolderSize(context.getCacheDir());
if (Environment.getExternalStorageState().equals(
Environment.MEDIA_MOUNTED)) {
cacheSize += getFolderSize(context.getExternalCacheDir());
}
return getFormatSize(cacheSize);
}
/**
* @param context 删除缓存
*/
public static void clearAllCache(Context context) {
deleteDir(context.getCacheDir());
if (Environment.getExternalStorageState().equals(
Environment.MEDIA_MOUNTED)) {
deleteDir(context.getExternalCacheDir());
}
}
private static boolean deleteDir(File dir) {
if (dir != null && dir.isDirectory()) {
String[] children = dir.list();
int size = 0;
if (children != null) {
size = children.length;
for (int i = 0; i < size; i++) {
boolean success = deleteDir(new File(dir, children[i]));
if (!success) {
return false;
}
}
}
}
if (dir == null) {
return true;
} else {
return dir.delete();
}
}
// 获取文件
// Context.getExternalFilesDir() --> SDCard/Android/data/你的应用的包名/files/
// 目录,一般放一些长时间保存的数据
// Context.getExternalCacheDir() -->
// SDCard/Android/data/你的应用包名/cache/目录,一般存放临时缓存数据
public static long getFolderSize(File file) throws Exception {
long size = 0;
try {
File[] fileList = file.listFiles();
int size2 = 0;
if (fileList != null) {
size2 = fileList.length;
for (int i = 0; i < size2; i++) {
// 如果下面还有文件
if (fileList[i].isDirectory()) {
size = size + getFolderSize(fileList[i]);
} else {
size = size + fileList[i].length();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return size;
}
/**
* 格式化单位
* 计算缓存的大小
*
* @param size
* @return
*/
public static String getFormatSize(double size) {
double kiloByte = size / 1024;
if (kiloByte < 1) {
// return size + "Byte";
return "0K";
}
double megaByte = kiloByte / 1024;
if (megaByte < 1) {
BigDecimal result1 = new BigDecimal(Double.toString(kiloByte));
return result1.setScale(2, BigDecimal.ROUND_HALF_UP)
.toPlainString() + "KB";
}
double gigaByte = megaByte / 1024;
if (gigaByte < 1) {
BigDecimal result2 = new BigDecimal(Double.toString(megaByte));
return result2.setScale(2, BigDecimal.ROUND_HALF_UP)
.toPlainString() + "MB";
}
double teraBytes = gigaByte / 1024;
if (teraBytes < 1) {
BigDecimal result3 = new BigDecimal(Double.toString(gigaByte));
return result3.setScale(2, BigDecimal.ROUND_HALF_UP)
.toPlainString() + "GB";
}
BigDecimal result4 = new BigDecimal(teraBytes);
return result4.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString()
+ "TB";
}
}
... ...
package com.hh.xuetubao.Utils;
import android.util.Log;
import com.hh.xuetubao.MyApplication;
import com.hh.xuetubao.MyServer;
import java.io.File;
import java.util.concurrent.TimeUnit;
import okhttp3.Cache;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
public class HttpUtils {
public static HttpUtils sHttpUtils;
public HttpUtils() {
}
public static HttpUtils getInstance() {
if (sHttpUtils == null) {
sHttpUtils = new HttpUtils();
}
return sHttpUtils;
}
public MyServer getServer(String url) {
return new Retrofit.Builder()
.baseUrl(url)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.client(getClientWithoutCache())
.build()
.create(MyServer.class);
}
public OkHttpClient getClientWithoutCache() {
return new OkHttpClient.Builder()
.cache(new Cache(new File(MyApplication.getContext().getCacheDir(), "HttpCache"), 10 * 1024 * 1024))
.connectTimeout(6 * 1000, TimeUnit.SECONDS)
.readTimeout(6, TimeUnit.SECONDS)
.writeTimeout(6, TimeUnit.SECONDS)
.addInterceptor(getLogInterceptor())
.build();
}
public static HttpLoggingInterceptor getLogInterceptor() {
//设置log拦截器拦截内容
HttpLoggingInterceptor.Level level = HttpLoggingInterceptor.Level.BODY;
//新建log拦截器
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
@Override
public void log(String message) {
Log.e("<--网络请求-->", message);
}
});
loggingInterceptor.setLevel(level);
return loggingInterceptor;
}
}
... ...
package com.hh.xuetubao.Utils;
public class IntentConfig {
public static final int INTENT_ZERO=0;
public static final int INTENT_ONE=1;
public static final int INTENT_TWO=2;
public static final int INTENT_THREE=3;
public static final int INTENT_FOUR=4;
public static final int INTENT_FIVE=5;
public static final int INTENT_SIX=6;
public static final int INTENT_SEVER=7;
}
... ...
package com.hh.xuetubao.Utils;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ListView;
public class ListViewNesting extends ListView {
public ListViewNesting(Context context) {
super(context);
}
public ListViewNesting(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ListViewNesting(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
}
... ...
package com.hh.xuetubao.Utils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.ListView;
public class ListviewUtils {
public static void setListViewHeightBasedOnChildren(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null) {
return;
}
int totalHeight = 0;
for (int i = 0; i < listAdapter.getCount(); i++) {
View listItem = listAdapter.getView(i, null, listView);
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
listView.setLayoutParams(params);
}
}
... ...
package com.hh.xuetubao.Utils;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
public class MyViewPager extends ViewPager {
/*
更改scrollble的值可设置是否可滑动,默认true为可滑动
*/
private boolean scrollble = false;
private int startX;
private int startY;
public MyViewPager(Context context) {
super(context);
}
public MyViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (!scrollble) {
return true;
}
return super.onTouchEvent(ev);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
startX = (int) ev.getX();
startY = (int) ev.getY();
break;
case MotionEvent.ACTION_MOVE:
// int dX = (int) (ev.getX() - startX);
int dY = (int) (ev.getY() - startX);
if (Math.abs(dY) > 0) // 说明上下方向滑动了
{
return false;
} else {
return true;
}
case MotionEvent.ACTION_UP:
break;
}
return super.onInterceptTouchEvent(ev);
}
public boolean isScrollble() {
return scrollble;
}
public void setScrollble(boolean scrollble) {
this.scrollble = scrollble;
}
}
... ...
package com.hh.xuetubao.Utils;
public class NetConfig {
public static String learnUrl="http://www.prepro.pq1959.com/LearningService/";
public static String shuaTiUrl="http://www.prepro.pq1959.com/DoExerciseService/";
public static String accountUrl="http://www.prepro.pq1959.com/AccountService/";
public static String personUrl="http://www.prepro.robotart.com/PersonalCenterService/";
public static String zhaopinUrl="http://www.prepro.robotart.com/ZhaopinService/";
}
... ...
package com.hh.xuetubao.Utils;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
public class RecyclerViewNesting extends RecyclerView {
public RecyclerViewNesting(Context context) {
super(context);
}
public RecyclerViewNesting(Context context, AttributeSet attrs) {
super(context, attrs);
}
public RecyclerViewNesting(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
}
... ...
package com.hh.xuetubao.Utils;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import java.util.HashMap;
public class RecyclerViewSpacesItemDecoration extends RecyclerView.ItemDecoration {
private HashMap<String, Integer> mSpaceValueMap;
public static final String TOP_DECORATION = "top_decoration";
public static final String BOTTOM_DECORATION = "bottom_decoration";
public static final String LEFT_DECORATION = "left_decoration";
public static final String RIGHT_DECORATION = "right_decoration";
public RecyclerViewSpacesItemDecoration(HashMap<String, Integer> mSpaceValueMap) {
this.mSpaceValueMap = mSpaceValueMap;
}
@Override
public void getItemOffsets(Rect outRect, View view,
RecyclerView parent, RecyclerView.State state) {
if (mSpaceValueMap.get(TOP_DECORATION) != null)
outRect.top = mSpaceValueMap.get(TOP_DECORATION);
if (mSpaceValueMap.get(LEFT_DECORATION) != null)
outRect.left = mSpaceValueMap.get(LEFT_DECORATION);
if (mSpaceValueMap.get(RIGHT_DECORATION) != null)
outRect.right = mSpaceValueMap.get(RIGHT_DECORATION);
if (mSpaceValueMap.get(BOTTOM_DECORATION) != null)
outRect.bottom = mSpaceValueMap.get(BOTTOM_DECORATION);
}
/* HashMap<String, Integer> stringIntegerHashMap = new HashMap<>();
stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.RIGHT_DECORATION,10);//右间距
recyclerView.addItemDecoration(new RecyclerViewSpacesItemDecoration(stringIntegerHashMap));*/
}
\ No newline at end of file
... ...
package com.hh.xuetubao.Utils;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.graphics.Point;
import android.graphics.RectF;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import com.hh.xuetubao.R;
import java.util.ArrayList;
import java.util.List;
public class RingView extends View {
private Context mContext;
private Paint mPaint;
private int mPaintWidth = 0; // 画笔的宽
private int topMargin = 30; // 上边距
private int leftMargin = 80; // 左边距
private Resources mRes;
private DisplayMetrics dm;
private int showRateSize = 10; // 展示文字的大小
private int circleCenterX = 96; // 圆心点X 要与外圆半径相等
private int circleCenterY = 96; // 圆心点Y 要与外圆半径相等
private int ringOuterRidus = 96; // 外圆的半径
private int ringInnerRidus = 33; // 内圆的半径
private int ringPointRidus = 80; // 点所在圆的半径
private float rate = 0.4f; //点的外延距离 与 点所在圆半径的长度比率
private float extendLineWidth = 20; //点外延后 折的横线的长度
private RectF rectF; // 外圆所在的矩形
private RectF rectFPoint; // 点所在的矩形
private List<Integer> colorList;
private List<Float> rateList;
private boolean isRing;
private boolean isShowCenterPoint;
private boolean isShowRate;
public RingView(Context context) {
super(context, null);
}
public RingView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
this.mContext = context;
initView();
}
public void setShow(List<Integer> colorList, List<Float> rateList) {
setShow(colorList, rateList, false);
}
public void setShow(List<Integer> colorList, List<Float> rateList, boolean isRing) {
setShow(colorList, rateList, isRing, false);
}
public void setShow(List<Integer> colorList, List<Float> rateList, boolean isRing, boolean isShowRate) {
setShow(colorList, rateList, isRing, isShowRate, false);
}
public void setShow(List<Integer> colorList, List<Float> rateList, boolean isRing, boolean isShowRate, boolean isShowCenterPoint) {
this.colorList = colorList;
this.rateList = rateList;
this.isRing = isRing;
this.isShowRate = isShowRate;
this.isShowCenterPoint = isShowCenterPoint;
}
private void initView() {
this.mRes = mContext.getResources();
this.mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
dm = new DisplayMetrics();
WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
wm.getDefaultDisplay().getMetrics(dm);
int screenWidth = wm.getDefaultDisplay().getWidth();
// int height = wm.getDefaultDisplay().getHeight();
leftMargin = (px2dip(screenWidth) - (2 * circleCenterX)) / 2;
mPaint.setColor(getResources().getColor(R.color.colorPrimary));
mPaint.setStrokeWidth(dip2px(mPaintWidth));
mPaint.setStyle(Paint.Style.FILL);
mPaint.setAntiAlias(true);
rectF = new RectF(dip2px(mPaintWidth + leftMargin),
dip2px(mPaintWidth + topMargin),
dip2px(circleCenterX + ringOuterRidus + mPaintWidth * 2 + leftMargin),
dip2px(circleCenterY + ringOuterRidus + mPaintWidth * 2 + topMargin));
rectFPoint = new RectF(dip2px(mPaintWidth + leftMargin + (ringOuterRidus - ringPointRidus)),
dip2px(mPaintWidth + topMargin + (ringOuterRidus - ringPointRidus)),
dip2px(circleCenterX + ringPointRidus + mPaintWidth * 2 + leftMargin),
dip2px(circleCenterY + ringPointRidus + mPaintWidth * 2 + topMargin));
Log.e("矩形点:", dip2px(circleCenterX + ringOuterRidus + mPaintWidth * 2) + " --- " + dip2px(circleCenterY + ringOuterRidus + mPaintWidth * 2));
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
pointList.clear();
if (colorList != null) {
for (int i = 0; i < colorList.size(); i++) {
mPaint.setColor(mRes.getColor(colorList.get(i)));
mPaint.setStyle(Paint.Style.FILL);
drawOuter(canvas, i);
}
}
mPaint.setStyle(Paint.Style.FILL);
if (isRing) {
drawInner(canvas);
}
if (isShowCenterPoint) {
drawCenterPoint(canvas);
}
}
private void drawCenterPoint(Canvas canvas) {
mPaint.setColor(mRes.getColor(R.color.colorPrimary));
// Log.e("中心点:", dip2px(circleCenterX + mPaintWidth * 2 + leftMargin) + " --- " + dip2px(circleCenterY + mPaintWidth * 2 + topMargin));
canvas.drawCircle(dip2px(circleCenterX + mPaintWidth * 2 + leftMargin), dip2px(circleCenterY + mPaintWidth * 2 + topMargin), dip2px(1), mPaint);
}
private void drawInner(Canvas canvas) {
mPaint.setColor(mRes.getColor(R.color.colorAccent));
// Log.e("内部圆点:", dip2px(circleCenterX + mPaintWidth * 2 + leftMargin) + " --- " + dip2px(circleCenterY + mPaintWidth * 2 + topMargin));
canvas.drawCircle(dip2px(circleCenterX + mPaintWidth * 2 + leftMargin), dip2px(circleCenterY + mPaintWidth * 2 + topMargin), dip2px(ringInnerRidus), mPaint);
}
private float preRate;
private void drawArcCenterPoint(Canvas canvas, int position) {
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setColor(mRes.getColor(R.color.colorPrimaryDark));
mPaint.setStrokeWidth(dip2px(1));
canvas.drawArc(rectFPoint, preAngle, (endAngle) / 2, true, mPaint);
dealPoint(rectFPoint, preAngle, (endAngle) / 2, pointArcCenterList);
Point point = pointArcCenterList.get(position);
mPaint.setColor(mRes.getColor(R.color.colorAccent));
canvas.drawCircle(point.x, point.y, dip2px(2), mPaint);
if (preRate / 2 + rateList.get(position) / 2 < 5) {
extendLineWidth += 20;
rate -= 0.05f;
} else {
extendLineWidth = 20;
rate = 0.4f;
}
// 外延画折线
float lineXPoint1 = (point.x - dip2px(leftMargin + ringOuterRidus)) * (1 + rate);
float lineYPoint1 = (point.y - dip2px(topMargin + ringOuterRidus)) * (1 + rate);
float[] floats = new float[8];
floats[0] = point.x;
floats[1] = point.y;
floats[2] = dip2px(leftMargin + ringOuterRidus) + lineXPoint1;
floats[3] = dip2px(topMargin + ringOuterRidus) + lineYPoint1;
floats[4] = dip2px(leftMargin + ringOuterRidus) + lineXPoint1;
floats[5] = dip2px(topMargin + ringOuterRidus) + lineYPoint1;
if (point.x >= dip2px(leftMargin + ringOuterRidus)) {
mPaint.setTextAlign(Paint.Align.LEFT);
floats[6] = dip2px(leftMargin + ringOuterRidus) + lineXPoint1 + dip2px(extendLineWidth);
} else {
mPaint.setTextAlign(Paint.Align.RIGHT);
floats[6] = dip2px(leftMargin + ringOuterRidus) + lineXPoint1 - dip2px(extendLineWidth);
}
floats[7] = dip2px(topMargin + ringOuterRidus) + lineYPoint1;
mPaint.setColor(mRes.getColor(colorList.get(position)));
canvas.drawLines(floats, mPaint);
mPaint.setTextSize(dip2px(showRateSize));
mPaint.setStyle(Paint.Style.STROKE);
canvas.drawText(rateList.get(position) + "%", floats[6], floats[7] + dip2px(showRateSize) / 3, mPaint);
preRate = rateList.get(position);
}
List<Point> pointList = new ArrayList<>();
List<Point> pointArcCenterList = new ArrayList<>();
private void dealPoint(RectF rectF, float startAngle, float endAngle, List<Point> pointList) {
Path orbit = new Path();
//通过Path类画一个90度(180—270)的内切圆弧路径
orbit.addArc(rectF, startAngle, endAngle);
PathMeasure measure = new PathMeasure(orbit, false);
Log.e("路径的测量长度:", "" + measure.getLength());
float[] coords = new float[]{0f, 0f};
//利用PathMeasure分别测量出各个点的坐标值coords
int divisor = 1;
measure.getPosTan(measure.getLength() / divisor, coords, null);
Log.e("coords:", "x轴:" + coords[0] + " -- y轴:" + coords[1]);
float x = coords[0];
float y = coords[1];
Point point = new Point(Math.round(x), Math.round(y));
pointList.add(point);
}
private void drawOuter(Canvas canvas, int position) {
// canvas.drawCircle(circleCenterX, circleCenterY, ringInnerRidus, mPaint);
if (rateList != null) {
endAngle = getAngle(rateList.get(position));
}
// Log.e("preAngle:", "" + preAngle + " endAngle:" + endAngle);
canvas.drawArc(rectF, preAngle, endAngle, true, mPaint);
// dealPoint(rectF, preAngle, endAngle, pointList);
if (isShowRate) {
drawArcCenterPoint(canvas, position);
}
preAngle = preAngle + endAngle;
}
private float preAngle = -90;
private float endAngle = -90;
/**
* @param percent 百分比
* @return
*/
private float getAngle(float percent) {
float a = 360f / 100f * percent;
return a;
}
/**
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
*/
public int dip2px(float dpValue) {
return (int) (dpValue * dm.density + 0.5f);
}
/**
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
*/
public int px2dip(float pxValue) {
return (int) (pxValue / dm.density + 0.5f);
}
}
... ...
package com.hh.xuetubao.Utils;
import android.content.Context;
import android.os.Build;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import com.hh.xuetubao.mvp.BaseActivity;
/**
* 屏幕管理
*/
public class ScreenManager {
private static ScreenManager instance;
private ScreenManager() {
}
public synchronized static ScreenManager getInstance() {
if (instance == null) {
instance = new ScreenManager();
}
return instance;
}
/**
* 窗口全屏
*/
public void setFullScreen(boolean isChange, BaseActivity mActivity) {
if (!isChange) {
return;
}
mActivity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
mActivity.requestWindowFeature(Window.FEATURE_NO_TITLE);
}
/**
* [沉浸状态栏]
*/
public void setStatusBar(boolean isChange, BaseActivity mActivity) {
if (!isChange) {
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// 透明状态栏
mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// 透明导航栏
mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
}
/**
* [沉浸状态栏]
*/
public void setStatusBar2(BaseActivity mActivity) {
Window window = mActivity.getWindow();
//默认API 最低19
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) {
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
ViewGroup contentView = (ViewGroup) window.getDecorView().findViewById(Window.ID_ANDROID_CONTENT);
contentView.getChildAt(0).setFitsSystemWindows(false);
}
}
}
... ...
package com.hh.xuetubao.Utils;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Base64;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* Created by Administrator on 2016/6/13.
*/
public class SharedPrefrenceUtils {
private static SharedPreferences sp;
public static void saveBoolean(Context context, String key, boolean value) {
if (sp == null) {
sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
}
sp.edit().putBoolean(key, value).commit();
}
public static boolean getBoolean(Context context, String key, boolean defValue) {
if (sp == null) {
sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
}
return sp.getBoolean(key, defValue);
}
public static boolean getBoolean(Context context, String key) {
if (sp == null) {
sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
}
return sp.getBoolean(key, false);
}
public static void saveString(Context context, String key, String value) {
if (sp == null) {
sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
}
sp.edit().putString(key, value).commit();
}
public static String getString(Context context, String key, String defValue) {
if (sp == null) {
sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
}
return sp.getString(key, defValue);
}
public static String getString(Context context, String key) {
if (sp == null) {
sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
}
return sp.getString(key, "");
}
/**
* 保存对象
*
* @param context 上下文
* @param key 键
* @param obj 要保存的对象(Serializable的子类)
* @param <T> 泛型定义
*/
public static <T extends Serializable> void putObject(Context context, String key, T obj) {
try {
put(context, key, obj);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 获取对象
*
* @param context 上下文
* @param key 键
* @param <T> 指定泛型
* @return 泛型对象
*/
public static <T extends Serializable> T getObject(Context context, String key) {
try {
return (T) get(context, key);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static void setFloat(Context context, final String key,
final float value) {
final SharedPreferences settings = PreferenceManager
.getDefaultSharedPreferences(context);
settings.edit().putFloat(key, value).apply();
}
public static float getFloat(Context context, final String key,
final float defaultValue) {
final SharedPreferences settings = PreferenceManager
.getDefaultSharedPreferences(context);
return settings.getFloat(key, defaultValue);
}
public static void setLong(Context context, final String key,
final long value) {
final SharedPreferences settings = PreferenceManager
.getDefaultSharedPreferences(context);
settings.edit().putLong(key, value).apply();
}
public static long getLong(Context context, final String key,
final long defaultValue) {
final SharedPreferences settings = PreferenceManager
.getDefaultSharedPreferences(context);
return settings.getLong(key, defaultValue);
}
public static void putStringList(Context context, String key, List<String> list) {
try {
put(context, key, list);
} catch (Exception e) {
e.printStackTrace();
}
}
public static List<String> getStringList(Context context, String key) {
try {
return (List<String>) get(context, key);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 存储List集合
*
* @param context 上下文
* @param key 存储的键
* @param list 存储的集合
*/
public static void putSerializableList(Context context, String key, List<? extends Serializable> list) {
try {
put(context, key, list);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 获取List集合
*
* @param context 上下文
* @param key 键
* @param <E> 指定泛型
* @return List集合
*/
public static <E extends Serializable> List<E> getSerializableList(Context context, String key) {
try {
return (List<E>) get(context, key);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 存储Map集合
*
* @param context 上下文
* @param key 键
* @param map 存储的集合
* @param <K> 指定Map的键
* @param <V> 指定Map的值
*/
public static <K extends Serializable, V extends Serializable> void putMap(Context context,
String key, Map<K, V> map) {
try {
put(context, key, map);
} catch (Exception e) {
e.printStackTrace();
}
}
public static <K extends Serializable, V extends Serializable> Map<K, V> getMap(Context context, String key) {
try {
return (Map<K, V>) get(context, key);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 存储对象
*/
private static void put(Context context, String key, Object obj)
throws IOException {
if (obj == null) {//判断对象是否为空
return;
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = null;
oos = new ObjectOutputStream(baos);
oos.writeObject(obj);
// 将对象放到OutputStream中
// 将对象转换成byte数组,并将其进行base64编码
String objectStr = new String(Base64.encode(baos.toByteArray(), Base64.DEFAULT));
baos.close();
oos.close();
saveString(context, key, objectStr);
}
/**
* 获取对象
*/
private static Object get(Context context, String key)
throws IOException, ClassNotFoundException {
String wordBase64 = getString(context, key);
// 将base64格式字符串还原成byte数组
if (TextUtils.isEmpty(wordBase64)) { //不可少,否则在下面会报java.io.StreamCorruptedException
return null;
}
byte[] objBytes = Base64.decode(wordBase64.getBytes(), Base64.DEFAULT);
ByteArrayInputStream bais = new ByteArrayInputStream(objBytes);
ObjectInputStream ois = new ObjectInputStream(bais);
// 将byte数组转换成product对象
Object obj = ois.readObject();
bais.close();
ois.close();
return obj;
}
}
... ...
package com.hh.xuetubao.Utils;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.Rect;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.animation.LinearInterpolator;
import com.hh.xuetubao.R;
public class WaveView extends View {
//View的宽高
private int width;
private int height;
//View的画笔
private Paint wavePaint;
private Paint textPaint;
private Paint circlePaint;
//波浪的路径
private Path path;
//sin曲线的长度:一个周期的长度
private int cycle = 160;
//每次平移的长度,为四分之一个周期
private int translateX = cycle / 4;
//sin曲线振幅的高度
private int waveHeight = 80;
//sin曲线的起点坐标
private Point startPoint;
//当前波浪的进度
private int progress = 0;
//当前波浪的速度
private int waveSpeech = 150;
//是否启用了自动增长进度
public boolean isAutoIncrease = false;
public WaveView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
initPaint(context);
}
public WaveView(Context context) {
super(context);
initPaint(context);
}
private void initPaint(Context context) {
path = new Path();
wavePaint = new Paint();
wavePaint.setAntiAlias(true);
wavePaint.setStyle(Paint.Style.FILL);
wavePaint.setColor(getResources().getColor(R.color.color_ff5400));//Color.parseColor("#1998FA")
circlePaint = new Paint();
circlePaint.setStrokeWidth(5);
circlePaint.setStyle(Paint.Style.STROKE);
circlePaint.setAntiAlias(true);
circlePaint.setColor(getResources().getColor(R.color.color_ff5400)); // "#1998FA"
textPaint = new Paint();
textPaint.setAntiAlias(true);
textPaint.setTextSize(50);
textPaint.setColor(Color.parseColor("#ffffff"));
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//设置内间距
setPadding(20, 20, 20, 20);
//裁剪画布为圆形
clipCicle(canvas);
//绘制圆形边框
drawCicleBorder(canvas);
//绘制波浪区域
drawWavePath(canvas);
//绘制进度文字
drawProcessText(canvas);
//自动增长进度
if (isAutoIncrease) {
if (progress >= 100) {
progress = 0;
} else {
progress++;
}
}
//更新UI
// postInvalidateDelayed(waveSpeech);
}
/**
* 绘制进度文字
*
* @param canvas
*/
private void drawProcessText(Canvas canvas) {
//画布的大小
Rect targetRect = new Rect(0, 0, width, height);
Paint.FontMetricsInt fontMetrics = textPaint.getFontMetricsInt();
int baseline = (targetRect.bottom + targetRect.top - fontMetrics.bottom - fontMetrics.top) / 2;
// 下面这行是实现水平居中,drawText对应改为传入targetRect.centerX()
textPaint.setTextAlign(Paint.Align.CENTER);
canvas.drawText(progress + "分", targetRect.centerX(), baseline, textPaint);
}
/**
* 绘制波浪区域
*
* @param canvas
*/
private void drawWavePath(Canvas canvas) {
//根据进度改变起点坐标的y值
startPoint.y = (int) ((1 - (progress / 100.0)) * (height / 2 + width / 2));
Log.e("TAG", "startPoint.y:" + startPoint.y);
//移动区域起点
path.moveTo(startPoint.x, startPoint.y);
int j = 1;
//循环绘制正弦曲线区域,循环两个周期
for (int i = 1; i <= 8; i++) {
if (i % 2 == 0) {
//波峰
path.quadTo(startPoint.x + (cycle * j), startPoint.y + waveHeight,
startPoint.x + (cycle * 2) * i, startPoint.y);
} else {
//波谷
path.quadTo(startPoint.x + (cycle * j), startPoint.y - waveHeight,
startPoint.x + (cycle * 2) * i, startPoint.y);
}
j += 2;
}
//绘制封闭的区域
path.lineTo(width, height);//右下角
path.lineTo(startPoint.x, height);//左下角
path.lineTo(startPoint.x, startPoint.y);//起点
path.close();
//绘制区域
canvas.drawPath(path, wavePaint);
path.reset();
//一开始的起点是在-160,160 = 40 + 40 + 40 + 40,走完一个周期则回到原点
if (startPoint.x + translateX >= 0) {
startPoint.x = -cycle * 4;
} else {
startPoint.x += translateX;
}
}
/**
* 绘制圆形边框
*
* @param canvas
*/
private void drawCicleBorder(Canvas canvas) {
canvas.drawPaint(circlePaint);
canvas.drawCircle(width / 2, height / 2, width / 2, circlePaint);
}
/**
* 裁剪画布为圆形
*
* @param canvas
*/
private void clipCicle(Canvas canvas) {
Path circlePath = new Path();
circlePath.addCircle(width / 2, height / 2, width / 2, Path.Direction.CW);
canvas.clipPath(circlePath);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
//由于是一个圆形,所以取的值是宽高的最小值
width = measureSize(400, widthMeasureSpec);
height = measureSize(400, heightMeasureSpec);
width = Math.min(width, height);
height = Math.min(width, height);
setMeasuredDimension(width, height);
//初始化起点,为屏幕外的一个周期
startPoint = new Point(-cycle * 4, 0);
}
/**
* 测量宽高
*
* @param defaultSize
* @param measureSpec
* @return
*/
private int measureSize(int defaultSize, int measureSpec) {
int result = defaultSize;
int mode = MeasureSpec.getMode(measureSpec);
int size = MeasureSpec.getSize(measureSpec);
switch (mode) {
case MeasureSpec.UNSPECIFIED: //如果没有指定大小,就设置为默认大小
result = defaultSize;
break;
case MeasureSpec.AT_MOST:
case MeasureSpec.EXACTLY:
result = size;
break;
}
return result;
}
/**
* 开启自动增长
*/
public void startIncrease() {
isAutoIncrease = true;
invalidate();
}
/**
* 设置当前进度
*
* @param progress 进度
*/
public void setProgress(int progress) {
if (progress > 100 || progress < 0)
throw new RuntimeException(getClass().getName() + "请设置[0,100]之间的值");
this.progress = progress;
invalidate();
}
/**
* 通过动画设置当前进度
*
* @param targetProcess 进度 <=100
* @param duration 动画时长
*/
public void setProgress(final int targetProcess, int duration) {
if (progress > 100 || progress < 0)
throw new RuntimeException(getClass().getName() + "请设置[0,100]之间的值");
ValueAnimator progressAnimator = ValueAnimator.ofInt(progress, targetProcess);
progressAnimator.setDuration(duration);
progressAnimator.setTarget(progress);
progressAnimator.setInterpolator(new LinearInterpolator());
progressAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
setProgress((Integer) animation.getAnimatedValue());
}
});
progressAnimator.start();
}
/**
* 获取当前进度
*
* @return
*/
public int getProgress() {
return progress;
}
}
... ...
package com.hh.xuetubao.Utils;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
public class XCRoundImageView extends android.support.v7.widget.AppCompatImageView {
private Paint paint;
public XCRoundImageView(Context context) {
this(context, null);
}
public XCRoundImageView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public XCRoundImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
paint = new Paint();
}
/**
* 绘制圆形图片
*
* @author caizhiming
*/
@Override
protected void onDraw(Canvas canvas) {
Drawable drawable = getDrawable();
if (null != drawable) {
// Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();//此方法报错
Bitmap bitmap = drawableToBitmap(drawable);//使用此方法将drawable转换成bitmap
Bitmap b = getCircleBitmap(bitmap, 14);
final Rect rectSrc = new Rect(0, 0, b.getWidth(), b.getHeight());
final Rect rectDest = new Rect(0, 0, getWidth(), getHeight());
paint.reset();
canvas.drawBitmap(b, rectSrc, rectDest, paint);
} else {
super.onDraw(canvas);
}
}
/**
* 将Drawable转换成bitmap
*
* @param drawable
* @return
*/
public static Bitmap drawableToBitmap(Drawable drawable) {
int w = drawable.getIntrinsicWidth();
int h = drawable.getIntrinsicHeight();
Bitmap.Config config =
drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
: Bitmap.Config.RGB_565;
Bitmap bitmap = Bitmap.createBitmap(w, h, config);
//注意,下面三行代码要用到,否则在View或者SurfaceView里的canvas.drawBitmap会看不到图
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, w, h);
drawable.draw(canvas);
return bitmap;
}
/**
* 获取圆形图片方法
*
* @param bitmap
* @param pixels
* @return Bitmap
* @author caizhiming
*/
private Bitmap getCircleBitmap(Bitmap bitmap, int pixels) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
int x = bitmap.getWidth();
canvas.drawCircle(x / 2, x / 2, x / 2, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
}
\ No newline at end of file
... ...
package com.hh.xuetubao.activity.login;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.hh.xuetubao.MainActivity;
import com.hh.xuetubao.R;
import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
import com.hh.xuetubao.bean.UserBean;
import com.hh.xuetubao.model.AccountModel;
import com.hh.xuetubao.mvp.BaseMvpActivity;
import com.hh.xuetubao.mvp.CommonPresenter;
import com.hh.xuetubao.mvp.ICommonView;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* 登录界面
*/
public class LoginActivity extends BaseMvpActivity<CommonPresenter, AccountModel> implements ICommonView, View.OnClickListener {
@BindView(R.id.login)
TextView login;
@BindView(R.id.ed_phone)
EditText edPhone;
@BindView(R.id.tv_yanzheng)
TextView tvYanzheng;
@BindView(R.id.ed_code)
EditText edCode;
@BindView(R.id.img_wechat)
ImageView imgWechat;
@BindView(R.id.img_jigou)
ImageView imgJigou;
private int time = 60;
private CountDownTimer timer;
@Override
public void initView() {
login.setOnClickListener(this);
tvYanzheng.setOnClickListener(this);
imgWechat.setOnClickListener(this);
imgJigou.setOnClickListener(this);
}
@Override
public int initLayout() {
return R.layout.activity_login;
}
@Override
public void initData() {
}
@Override
public CommonPresenter getPresenter() {
return new CommonPresenter();
}
@Override
public AccountModel getModel() {
return new AccountModel();
}
@Override
public void getData(Object o, int api, int intent) {
if (api == 1 && intent == 1) {
UserBean bean = (UserBean) o;
if (bean.getSuccess()) {
Toast.makeText(this, "验证码发送成功", Toast.LENGTH_LONG).show();
timer = new CountDownTimer(60000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
time--;
try {
tvYanzheng.setText(String.valueOf(time) + "s");
tvYanzheng.setFocusable(false);
} catch (Exception e) {
Log.e("zhangtao", e.toString());
}
}
@Override
public void onFinish() {
tvYanzheng.setText("获取验证码");
tvYanzheng.setFocusable(true);
time = 60;
}
}.start();
} else {
Toast.makeText(this, "验证码发送失败", Toast.LENGTH_LONG).show();
}
}
if (api == 1 && intent == 2) {
UserBean bean = (UserBean) o;
if (bean.getSuccess()) {
// AccountOid
timer.cancel();
SharedPrefrenceUtils.saveString(this, "AccountOid", bean.getAccountOid());
startActivity(new Intent(this, MainActivity.class));
this.finish();
} else {
Toast.makeText(this, "登录失败", Toast.LENGTH_LONG).show();
}
}
}
@Override
public void onComplete(int api) {
}
@Override
public void onError(Throwable e, int api) {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.login:
mPresenter.getPresenter(1, 2, edPhone.getText().toString(), edCode.getText().toString());
break;
case R.id.tv_yanzheng:
if (isCellphone(edPhone.getText().toString()))
mPresenter.getPresenter(1, 1, edPhone.getText().toString(), String.valueOf(0));
else
Toast.makeText(this, "请输入正确的手机号码", Toast.LENGTH_LONG).show();
break;
case R.id.img_wechat:
break;
case R.id.img_jigou:
break;
}
}
public static boolean isCellphone(String str) {
Pattern pattern = Pattern.compile("^((13[0-9])|(14[5,7,9])|(15[^4])|(18[0-9])|(17[0,1,3,5,6,7,8]))\\d{8}$");
Matcher matcher = pattern.matcher(str);
return matcher.matches();
}
}
... ...
package com.hh.xuetubao.activity.personal;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.hh.xuetubao.R;
import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
import com.hh.xuetubao.activity.work.OfficeDetailActivity;
import com.hh.xuetubao.adapter.DeliveryXrecAdapter;
import com.hh.xuetubao.bean.ResumedJobListBean;
import com.hh.xuetubao.model.ZhaopinModel;
import com.hh.xuetubao.mvp.BaseMvpActivity;
import com.hh.xuetubao.mvp.CommonPresenter;
import com.hh.xuetubao.mvp.ICommonView;
import com.jcodecraeer.xrecyclerview.XRecyclerView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* 投递记录
*/
public class DeliveryActivity extends BaseMvpActivity<CommonPresenter, ZhaopinModel> implements ICommonView, XRecyclerView.LoadingListener, View.OnClickListener, DeliveryXrecAdapter.TurnTo {
@BindView(R.id.xrecyclerview)
XRecyclerView xrecyclerview;
@BindView(R.id.img_user)
ImageView imgUser;
@BindView(R.id.tv_user)
TextView tvUser;
@BindView(R.id.lin_back)
LinearLayout linBack;
@BindView(R.id.tv_none)
TextView tvNone;
private int pageIndex = 1;
private int pageSize = 10;
private boolean isRefresh = false;
private List<ResumedJobListBean.JobListBean> list = new ArrayList<>();
private DeliveryXrecAdapter adapter;
private String resumeOid;
@Override
public void initView() {
resumeOid = SharedPrefrenceUtils.getString(this, "AccountOid");
String reallHeader = SharedPrefrenceUtils.getString(this, "ReallHeader");
String headPic = SharedPrefrenceUtils.getString(this, "HeadPic");
String userName = SharedPrefrenceUtils.getString(this, "UserName");
if (reallHeader != null && reallHeader != "") {
Glide.with(this).load(reallHeader).into(imgUser);
} else {
if (headPic != null)
Glide.with(this).load(headPic).into(imgUser);
}
if (userName != null) {
tvUser.setText(userName);
}
xrecyclerview.setLayoutManager(new LinearLayoutManager(this));
adapter = new DeliveryXrecAdapter(list, this);
xrecyclerview.setAdapter(adapter);
xrecyclerview.setLoadingListener(this);
adapter.setTurnTo(this);
linBack.setOnClickListener(this);
}
@Override
public int initLayout() {
return R.layout.activity_delivery;
}
@Override
public void initData() {
mPresenter.getPresenter(1, 1, String.valueOf(pageIndex), String.valueOf(pageSize), resumeOid);
}
@Override
public CommonPresenter getPresenter() {
return new CommonPresenter();
}
@Override
public ZhaopinModel getModel() {
return new ZhaopinModel();
}
@Override
public void getData(Object o, int api, int intent) {
if (api == 1 && intent == 1) {
ResumedJobListBean bean = (ResumedJobListBean) o;
List<ResumedJobListBean.JobListBean> jobList = bean.getJobList();
if (jobList == null) {
tvNone.setVisibility(View.VISIBLE);
} else {
tvNone.setVisibility(View.GONE);
}
if (isRefresh) {
list.clear();
isRefresh = false;
}
list.addAll(jobList);
adapter.notifyDataSetChanged();
xrecyclerview.loadMoreComplete();
xrecyclerview.refreshComplete();
}
}
@Override
public void onComplete(int api) {
}
@Override
public void onError(Throwable e, int api) {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
@Override
public void onRefresh() {
pageIndex = 1;
isRefresh = true;
mPresenter.getPresenter(1, 1, String.valueOf(pageIndex), String.valueOf(pageSize), resumeOid);
}
@Override
public void onLoadMore() {
pageIndex++;
mPresenter.getPresenter(1, 1, String.valueOf(pageIndex), String.valueOf(pageSize), resumeOid);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.lin_back:
this.finish();
break;
}
}
@Override
public void turnToActicity(String jobId) {
Intent intent = new Intent(this, OfficeDetailActivity.class);
intent.putExtra("JobOid", jobId);
startActivity(intent);
}
}
... ...
package com.hh.xuetubao.activity.personal;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.amap.api.maps.MapView;
import com.hh.xuetubao.R;
import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
import com.hh.xuetubao.bean.UserBean;
import com.hh.xuetubao.model.PersonalModel;
import com.hh.xuetubao.mvp.BaseMvpActivity;
import com.hh.xuetubao.mvp.CommonPresenter;
import com.hh.xuetubao.mvp.ICommonView;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* 基本信息
*/
public class InfromationActivity extends BaseMvpActivity<CommonPresenter, PersonalModel> implements ICommonView, View.OnClickListener {
@BindView(R.id.tv_name)
EditText tvName;
@BindView(R.id.tv_sex)
EditText tvSex;
@BindView(R.id.tv_company)
EditText tvCompany;
@BindView(R.id.tv_web)
EditText tvWeb;
@BindView(R.id.progress)
ProgressBar progress;
@BindView(R.id.tv_jindu)
TextView tvJindu;
@BindView(R.id.tv_user)
TextView tvUser;
@BindView(R.id.lin_back)
LinearLayout linBack;
private int level = 0;
private String resumeOid;
@Override
public void initView() {
resumeOid = SharedPrefrenceUtils.getString(this, "AccountOid");
tvName.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
mPresenter.getPresenter(4, 1, resumeOid, "UserName", tvName.getText().toString());
}
});
tvSex.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
String value = "";
if (tvSex.getText().toString().equals("男")) {
value = "0";
} else if (tvSex.getText().toString().equals("女")) {
value = "1";
} else {
tvSex.getText().clear();
Toast.makeText(InfromationActivity.this, "请正确输入性别", Toast.LENGTH_SHORT).show();
}
mPresenter.getPresenter(4, 2, resumeOid, "Sex", value);
}
});
tvCompany.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
mPresenter.getPresenter(4, 3, resumeOid, "Company", tvCompany.getText().toString());
}
});
tvWeb.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
mPresenter.getPresenter(4, 4, resumeOid, "WebSite", tvWeb.getText().toString());
}
});
linBack.setOnClickListener(this);
}
@Override
public int initLayout() {
return R.layout.activity_infromation;
}
@Override
public void initData() {
mPresenter.getPresenter(3, 1, resumeOid);
}
@Override
public CommonPresenter getPresenter() {
return new CommonPresenter();
}
@Override
public PersonalModel getModel() {
return new PersonalModel();
}
@Override
public void getData(Object o, int api, int intent) {
if (api == 3 && intent == 1) {
UserBean bean = (UserBean) o;
if (bean.getUserName() != null)
level += 1;
tvName.setText(bean.getUserName());
tvUser.setText(bean.getUserName());
if (bean.getCompany() != null)
level += 1;
tvCompany.setText(bean.getCompany());
if (bean.getWebSite() != null && bean.getWebSite() != "")
level += 1;
tvWeb.setText(bean.getWebSite());
if (bean.getSex() == 0) {
tvSex.setText("男");
level += 1;
} else if (bean.getSex() == 1) {
tvSex.setText("女");
level += 1;
}
progress.setProgress(level);
tvJindu.setText(level + "/" + 4);
}
}
@Override
public void onComplete(int api) {
}
@Override
public void onError(Throwable e, int api) {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.lin_back:
this.finish();
break;
}
}
}
... ...
package com.hh.xuetubao.activity.personal;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.hh.xuetubao.R;
import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
import com.hh.xuetubao.adapter.MessageXrecAdapter;
import com.hh.xuetubao.bean.MsgListBean;
import com.hh.xuetubao.bean.UserBean;
import com.hh.xuetubao.model.PersonalModel;
import com.hh.xuetubao.mvp.BaseMvpActivity;
import com.hh.xuetubao.mvp.CommonPresenter;
import com.hh.xuetubao.mvp.ICommonView;
import com.jcodecraeer.xrecyclerview.XRecyclerView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* 我的消息
*/
public class MessageActivity extends BaseMvpActivity<CommonPresenter, PersonalModel> implements ICommonView, View.OnClickListener, XRecyclerView.LoadingListener, MessageXrecAdapter.TurnToDetail {
@BindView(R.id.img_user)
ImageView imgUser;
@BindView(R.id.tv_user)
TextView tvUser;
@BindView(R.id.tv_name)
TextView tvName;
@BindView(R.id.tv_system)
TextView tvSystem;
@BindView(R.id.tv_hudong)
TextView tvHudong;
@BindView(R.id.xrecyclerview)
XRecyclerView xrecyclerview;
@BindView(R.id.lin_back)
LinearLayout linBack;
private int pageIndex = 1;
private int pageSize = 10;
private int type = 1;
private boolean isRefresh = false;
private List<MsgListBean.MsgBean> list = new ArrayList<>();
private MessageXrecAdapter adapter;
private String resumeOid;
@Override
public void initView() {
resumeOid = SharedPrefrenceUtils.getString(this, "AccountOid");
xrecyclerview.setLayoutManager(new LinearLayoutManager(this));
adapter = new MessageXrecAdapter(list, this);
xrecyclerview.setAdapter(adapter);
xrecyclerview.setLoadingListener(this);
adapter.setTurnToDetail(this);
tvSystem.setOnClickListener(this);
tvHudong.setOnClickListener(this);
linBack.setOnClickListener(this);
}
@Override
public int initLayout() {
return R.layout.activity_message;
}
@Override
public void initData() {
mPresenter.getPresenter(2, 1, resumeOid);
mPresenter.getPresenter(5, 1, resumeOid, "System", String.valueOf(pageIndex), String.valueOf(pageSize));
}
@Override
public CommonPresenter getPresenter() {
return new CommonPresenter();
}
@Override
public PersonalModel getModel() {
return new PersonalModel();
}
@Override
public void getData(Object o, int api, int intent) {
if (api == 2 && intent == 1) {
UserBean bean = (UserBean) o;
if (bean.getUserName() != null)
tvName.setText(bean.getUserName());
if (bean.getLoginName() != null)
tvUser.setText(bean.getLoginName());
if (bean.getHeadPic() != null) {
Glide.with(this).load(bean.getHeadPic()).into(imgUser);
} else {
String headPic = SharedPrefrenceUtils.getString(this, "HeadPic");
if (headPic != null)
Glide.with(this).load(headPic).into(imgUser);
}
}
if (api == 5 && intent == 1) {
MsgListBean bean = (MsgListBean) o;
List<MsgListBean.MsgBean> msgList = bean.getMsgList();
if (isRefresh) {
list.clear();
isRefresh = false;
}
list.addAll(msgList);
adapter.notifyDataSetChanged();
xrecyclerview.refreshComplete();
xrecyclerview.loadMoreComplete();
}
if (api == 5 && intent == 2) {
MsgListBean bean = (MsgListBean) o;
List<MsgListBean.MsgBean> msgList = bean.getMsgList();
if (isRefresh) {
list.clear();
isRefresh = false;
}
list.addAll(msgList);
adapter.notifyDataSetChanged();
xrecyclerview.refreshComplete();
xrecyclerview.loadMoreComplete();
}
}
@Override
public void onComplete(int api) {
}
@Override
public void onError(Throwable e, int api) {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.tv_system:
type = 1;
tvSystem.setTextColor(getResources().getColor(R.color.color_ffffff));
tvHudong.setTextColor(getResources().getColor(R.color.color_349dfe));
tvSystem.setBackgroundResource(R.drawable.circle_coners_left_blue);
tvHudong.setBackgroundResource(R.drawable.circle_coners_right);
list.clear();
pageIndex = 1;
mPresenter.getPresenter(5, 1, resumeOid, "System", String.valueOf(pageIndex), String.valueOf(pageSize));
break;
case R.id.tv_hudong:
type = 2;
tvSystem.setTextColor(getResources().getColor(R.color.color_349dfe));
tvHudong.setTextColor(getResources().getColor(R.color.color_ffffff));
tvSystem.setBackgroundResource(R.drawable.circle_coners_left);
tvHudong.setBackgroundResource(R.drawable.circle_coners_right_blue);
list.clear();
pageIndex = 1;
mPresenter.getPresenter(5, 2, resumeOid, "Interaction", String.valueOf(pageIndex), String.valueOf(pageSize));
break;
case R.id.lin_back:
this.finish();
break;
}
}
@Override
public void onRefresh() {
pageIndex = 1;
isRefresh = true;
if (type == 1)
mPresenter.getPresenter(5, 1, resumeOid, "System", String.valueOf(pageIndex), String.valueOf(pageSize));
else if (type == 2)
mPresenter.getPresenter(5, 2, resumeOid, "Interaction", String.valueOf(pageIndex), String.valueOf(pageSize));
}
@Override
public void onLoadMore() {
pageIndex++;
if (type == 1)
mPresenter.getPresenter(5, 1, resumeOid, "System", String.valueOf(pageIndex), String.valueOf(pageSize));
else if (type == 2)
mPresenter.getPresenter(5, 2, resumeOid, "Interaction", String.valueOf(pageIndex), String.valueOf(pageSize));
}
@Override
public void Turn(int Status, String MsgOid) {
Intent intent = new Intent(this, MessageDetailActivity.class);
intent.putExtra("Status", Status);
intent.putExtra("MsgOid", MsgOid);
startActivity(intent);
}
}
... ...
package com.hh.xuetubao.activity.personal;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import com.hh.xuetubao.R;
import com.hh.xuetubao.bean.UserBean;
import com.hh.xuetubao.model.PersonalModel;
import com.hh.xuetubao.mvp.BaseMvpActivity;
import com.hh.xuetubao.mvp.CommonPresenter;
import com.hh.xuetubao.mvp.ICommonView;
import butterknife.BindView;
import butterknife.ButterKnife;
public class MessageDetailActivity extends BaseMvpActivity<CommonPresenter, PersonalModel> implements ICommonView {
@BindView(R.id.tv_content)
TextView tvContent;
private String msgOid;
private int status;
@Override
public void initView() {
Intent intent = getIntent();
msgOid = intent.getStringExtra("MsgOid");
status = intent.getIntExtra("Status", 0);
}
@Override
public int initLayout() {
return R.layout.activity_message_detail;
}
@Override
public void initData() {
if (status == 0) {
mPresenter.getPresenter(10, 1, msgOid);
}
mPresenter.getPresenter(10, 2, msgOid);
}
@Override
public CommonPresenter getPresenter() {
return new CommonPresenter();
}
@Override
public PersonalModel getModel() {
return new PersonalModel();
}
@Override
public void getData(Object o, int api, int intent) {
if (api == 10 && intent == 2) {
UserBean bean = (UserBean) o;
if (bean.getMsgContent() != null)
tvContent.setText(bean.getMsgContent());
}
}
@Override
public void onComplete(int api) {
}
@Override
public void onError(Throwable e, int api) {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
}
... ...
package com.hh.xuetubao.activity.personal;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.hh.xuetubao.R;
import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
import com.hh.xuetubao.bean.UserBean;
import com.hh.xuetubao.model.PersonalModel;
import com.hh.xuetubao.mvp.BaseMvpActivity;
import com.hh.xuetubao.mvp.CommonPresenter;
import com.hh.xuetubao.mvp.ICommonView;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* PQ币
*/
public class MoneyActivity extends BaseMvpActivity<CommonPresenter, PersonalModel> implements ICommonView, View.OnClickListener {
@BindView(R.id.tv_mingxi)
TextView tvMingxi;
@BindView(R.id.tv_count)
TextView tvCount;
@BindView(R.id.img_user)
ImageView imgUser;
@BindView(R.id.tv_user)
TextView tvUser;
@BindView(R.id.lin_back)
LinearLayout linBack;
private String resumeOid;
@Override
public void initView() {
resumeOid = SharedPrefrenceUtils.getString(this, "AccountOid");
String reallHeader = SharedPrefrenceUtils.getString(this, "ReallHeader");
String headPic = SharedPrefrenceUtils.getString(this, "HeadPic");
String userName = SharedPrefrenceUtils.getString(this, "UserName");
if (reallHeader != null) {
Glide.with(this).load(reallHeader).into(imgUser);
} else {
if (headPic != null)
Glide.with(this).load(headPic).into(imgUser);
}
if (userName != null) {
tvUser.setText(userName);
}
tvMingxi.setOnClickListener(this);
linBack.setOnClickListener(this);
}
@Override
public int initLayout() {
return R.layout.activity_money;
}
@Override
public void initData() {
mPresenter.getPresenter(6, 1, resumeOid);
}
@Override
public CommonPresenter getPresenter() {
return new CommonPresenter();
}
@Override
public PersonalModel getModel() {
return new PersonalModel();
}
@Override
public void getData(Object o, int api, int intent) {
if (api == 6 && intent == 1) {
UserBean bean = (UserBean) o;
tvCount.setText(String.valueOf(bean.getPQCoinCount()));
}
}
@Override
public void onComplete(int api) {
}
@Override
public void onError(Throwable e, int api) {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.tv_mingxi:
startActivity(new Intent(this, MoneyHistoryActivity.class));
break;
case R.id.lin_back:
this.finish();
break;
}
}
}
... ...
package com.hh.xuetubao.activity.personal;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.TextView;
import com.hh.xuetubao.R;
import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
import com.hh.xuetubao.adapter.PqAdapter;
import com.hh.xuetubao.bean.PQbean;
import com.hh.xuetubao.model.PersonalModel;
import com.hh.xuetubao.mvp.BaseMvpActivity;
import com.hh.xuetubao.mvp.CommonPresenter;
import com.hh.xuetubao.mvp.ICommonView;
import com.jcodecraeer.xrecyclerview.XRecyclerView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* PQ币历史
*/
public class MoneyHistoryActivity extends BaseMvpActivity<CommonPresenter, PersonalModel> implements ICommonView, View.OnClickListener, XRecyclerView.LoadingListener {
@BindView(R.id.tv_all)
TextView tvAll;
@BindView(R.id.tv_in)
TextView tvIn;
@BindView(R.id.tv_out)
TextView tvOut;
@BindView(R.id.xrecyclerview)
XRecyclerView xrecyclerview;
private String searchType = null;
private int pageIndex = 1;
private int pageSize = 10;
private List<PQbean.RecordListBean> pqlist = new ArrayList<>();
private PqAdapter pqAdapter;
private boolean isRefresh = false;
private String resumeOid;
@Override
public void initView() {
resumeOid = SharedPrefrenceUtils.getString(this, "AccountOid");
xrecyclerview.setLayoutManager(new LinearLayoutManager(this));
pqAdapter = new PqAdapter(pqlist, this);
xrecyclerview.setAdapter(pqAdapter);
xrecyclerview.setLoadingListener(this);
tvAll.setOnClickListener(this);
tvIn.setOnClickListener(this);
tvOut.setOnClickListener(this);
}
@Override
public int initLayout() {
return R.layout.activity_money_history;
}
@Override
public void initData() {
mPresenter.getPresenter(9, 1, resumeOid, searchType, String.valueOf(pageIndex), String.valueOf(pageSize));
}
@Override
public CommonPresenter getPresenter() {
return new CommonPresenter();
}
@Override
public PersonalModel getModel() {
return new PersonalModel();
}
@Override
public void getData(Object o, int api, int intent) {
if (api == 9 && intent == 1) {
PQbean qbean = (PQbean) o;
List<PQbean.RecordListBean> listBeans = qbean.getRecordList();
if (isRefresh) {
pqlist.clear();
isRefresh = false;
}
pqlist.addAll(listBeans);
pqAdapter.notifyDataSetChanged();
xrecyclerview.loadMoreComplete();
xrecyclerview.refreshComplete();
}
}
@Override
public void onComplete(int api) {
}
@Override
public void onError(Throwable e, int api) {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.tv_all:
selectPress(tvAll);
searchType = null;
isRefresh = true;
mPresenter.getPresenter(9, 1, resumeOid, searchType, String.valueOf(1), String.valueOf(pageSize));
break;
case R.id.tv_in:
selectPress(tvIn);
searchType = "Incoming";
isRefresh = true;
mPresenter.getPresenter(9, 1, resumeOid, searchType, String.valueOf(1), String.valueOf(pageSize));
break;
case R.id.tv_out:
selectPress(tvOut);
searchType = "Payout";
isRefresh = true;
mPresenter.getPresenter(9, 1, resumeOid, searchType, String.valueOf(1), String.valueOf(pageSize));
break;
}
}
public void selectPress(TextView view) {
if (view == tvAll) {
tvAll.setBackground(this.getResources().getDrawable(R.drawable.stoke_1dp_orange));
tvAll.setTextColor(this.getResources().getColor(R.color.color_ffffff));
tvIn.setBackground(this.getResources().getDrawable(R.drawable.stoke_1dp));
tvIn.setTextColor(this.getResources().getColor(R.color.color_464646));
tvOut.setBackground(this.getResources().getDrawable(R.drawable.stoke_1dp));
tvOut.setTextColor(this.getResources().getColor(R.color.color_464646));
}
if (view == tvIn) {
tvIn.setBackground(this.getResources().getDrawable(R.drawable.stoke_1dp_orange));
tvIn.setTextColor(this.getResources().getColor(R.color.color_ffffff));
tvAll.setBackground(this.getResources().getDrawable(R.drawable.stoke_1dp));
tvAll.setTextColor(this.getResources().getColor(R.color.color_464646));
tvOut.setBackground(this.getResources().getDrawable(R.drawable.stoke_1dp));
tvOut.setTextColor(this.getResources().getColor(R.color.color_464646));
}
if (view == tvOut) {
tvOut.setBackground(this.getResources().getDrawable(R.drawable.stoke_1dp_orange));
tvOut.setTextColor(this.getResources().getColor(R.color.color_ffffff));
tvAll.setBackground(this.getResources().getDrawable(R.drawable.stoke_1dp));
tvAll.setTextColor(this.getResources().getColor(R.color.color_464646));
tvIn.setBackground(this.getResources().getDrawable(R.drawable.stoke_1dp));
tvIn.setTextColor(this.getResources().getColor(R.color.color_464646));
}
}
@Override
public void onRefresh() {
isRefresh = true;
pageIndex = 1;
mPresenter.getPresenter(9, 1, resumeOid, searchType, String.valueOf(pageIndex), String.valueOf(pageSize));
}
@Override
public void onLoadMore() {
pageIndex++;
mPresenter.getPresenter(9, 1, resumeOid, searchType, String.valueOf(pageIndex), String.valueOf(pageSize));
}
}
... ...
package com.hh.xuetubao.activity.personal;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.hh.xuetubao.R;
import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
import com.hh.xuetubao.adapter.ResumeCertAdapter;
import com.hh.xuetubao.adapter.ResumeEduAdapter;
import com.hh.xuetubao.adapter.ResumeExpAdapter;
import com.hh.xuetubao.adapter.ResumeTrainAdapter;
import com.hh.xuetubao.bean.ResumeDetailBean;
import com.hh.xuetubao.model.PersonalModel;
import com.hh.xuetubao.mvp.BaseMvpActivity;
import com.hh.xuetubao.mvp.CommonPresenter;
import com.hh.xuetubao.mvp.ICommonView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* 我的简历
*/
public class ResumeActivity extends BaseMvpActivity<CommonPresenter, PersonalModel> implements ICommonView, View.OnClickListener {
@BindView(R.id.tv_name)
TextView tvName;
@BindView(R.id.img_user)
ImageView imgUser;
@BindView(R.id.tv_phone)
TextView tvPhone;
@BindView(R.id.pingjia_content)
TextView pingjiaContent;
@BindView(R.id.tv_techang_show)
TextView tvTechangShow;
@BindView(R.id.tv_experience)
TextView tvExperience;
@BindView(R.id.tv_age)
TextView tvAge;
@BindView(R.id.tv_education)
TextView tvEducation;
@BindView(R.id.tv_email)
TextView tvEmail;
@BindView(R.id.list_xueli)
ListView listXueli;
@BindView(R.id.list_exp)
ListView listExp;
@BindView(R.id.list_edu)
ListView listEdu;
@BindView(R.id.list_train)
ListView listTrain;
@BindView(R.id.tv_zhineng)
TextView tvZhineng;
@BindView(R.id.tv_hangye)
TextView tvHangye;
@BindView(R.id.tv_xinzi)
TextView tvXinzi;
@BindView(R.id.tv_leixing)
TextView tvLeixing;
@BindView(R.id.tv_daogang)
TextView tvDaogang;
@BindView(R.id.tv_address)
TextView tvAddress;
@BindView(R.id.lin_back)
LinearLayout linBack;
private List<ResumeDetailBean.CertListBean> certList = new ArrayList<>();
private List<ResumeDetailBean.ExpListBean> expList = new ArrayList<>();
private List<ResumeDetailBean.EduListBean> eduList = new ArrayList<>();
private List<ResumeDetailBean.TrainListBean> trainList = new ArrayList<>();
private ResumeCertAdapter certAdapter;
private ResumeExpAdapter expAdapter;
private ResumeEduAdapter eduAdapter;
private ResumeTrainAdapter trainAdapter;
private String resumeOid;
@Override
public void initView() {
resumeOid = SharedPrefrenceUtils.getString(this, "AccountOid");
tvName.setFocusable(true);
tvName.setFocusableInTouchMode(true);
tvName.requestFocus();
certAdapter = new ResumeCertAdapter(certList, this);
listXueli.setAdapter(certAdapter);
expAdapter = new ResumeExpAdapter(expList, this);
listExp.setAdapter(expAdapter);
eduAdapter = new ResumeEduAdapter(eduList, this);
listEdu.setAdapter(eduAdapter);
trainAdapter = new ResumeTrainAdapter(trainList, this);
listTrain.setAdapter(trainAdapter);
linBack.setOnClickListener(this);
}
@Override
public int initLayout() {
return R.layout.activity_resume;
}
@Override
public void initData() {
mPresenter.getPresenter(7, 1, resumeOid);
}
@Override
public CommonPresenter getPresenter() {
return new CommonPresenter();
}
@Override
public PersonalModel getModel() {
return new PersonalModel();
}
@Override
public void getData(Object o, int api, int intent) {
if (api == 7 && intent == 1) {
ResumeDetailBean bean = (ResumeDetailBean) o;
if (bean.getHeadPicUrl() != null) {
Glide.with(this).load(bean.getHeadPicUrl()).into(imgUser);
} else {
String headPic = SharedPrefrenceUtils.getString(this, "HeadPic");
if (headPic != null)
Glide.with(this).load(headPic).into(imgUser);
}
if (bean.getName() != null)
tvName.setText(bean.getName());
if (bean.getExprience() != null)
tvExperience.setText(bean.getExprience());
if (bean.getAge() != null)
tvAge.setText(bean.getAge());
if (bean.getEducation() != null)
tvEducation.setText(bean.getEducation());
if (bean.getPhone() != null)
tvPhone.setText(bean.getPhone());
if (bean.getEmail() != null)
tvEmail.setText(bean.getEmail());
if (bean.getIntroduce() != null)
pingjiaContent.setText(bean.getIntroduce());
if (bean.getArrivalTime() != null)
tvDaogang.setText(bean.getArrivalTime());
if (bean.getJobNature() != null)
tvLeixing.setText(bean.getJobNature());
if (bean.getAddress() != null)
tvAddress.setText(bean.getAddress());
if (bean.getJobFunction() != null)
tvZhineng.setText(bean.getJobFunction());
if (bean.getIndustry() != null)
tvHangye.setText(bean.getIndustry());
if (bean.getSalary() != null)
tvXinzi.setText(bean.getSalary());
if (bean.getCustomSkill() != null)
tvTechangShow.setText(bean.getCustomSkill());
if (bean.getResumeOid() != null)
SharedPrefrenceUtils.saveString(this, "ResumeOid", bean.getResumeOid());
List<ResumeDetailBean.CertListBean> listBeans = bean.getCertList();
certList.addAll(listBeans);
certAdapter.notifyDataSetChanged();
List<ResumeDetailBean.ExpListBean> beanExpList = bean.getExpList();
expList.addAll(beanExpList);
expAdapter.notifyDataSetChanged();
List<ResumeDetailBean.EduListBean> beanEduList = bean.getEduList();
eduList.addAll(beanEduList);
eduAdapter.notifyDataSetChanged();
List<ResumeDetailBean.TrainListBean> trainListBeans = bean.getTrainList();
trainList.addAll(trainListBeans);
trainAdapter.notifyDataSetChanged();
}
}
@Override
public void onComplete(int api) {
}
@Override
public void onError(Throwable e, int api) {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.lin_back:
this.finish();
break;
}
}
}
... ...
package com.hh.xuetubao.activity.pratice;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.hh.xuetubao.R;
import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
import com.hh.xuetubao.adapter.AnswerSheetGridAdapter;
import com.hh.xuetubao.adapter.ListAnswerAdapter;
import com.hh.xuetubao.bean.AnswerBean;
import com.hh.xuetubao.model.ExerciseModel;
import com.hh.xuetubao.mvp.BaseMvpActivity;
import com.hh.xuetubao.mvp.CommonPresenter;
import com.hh.xuetubao.mvp.ICommonView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* 模拟考试答题界面
*/
public class AnswerActivity extends BaseMvpActivity<CommonPresenter, ExerciseModel> implements ICommonView, View.OnClickListener {
@BindView(R.id.list_answer)
ListView listAnswer;
@BindView(R.id.tv_radio)
TextView tvRadio;
@BindView(R.id.tv_max)
TextView tvMax;
@BindView(R.id.tv_current)
TextView tvCurrent;
@BindView(R.id.tv_title)
TextView tvTitle;
@BindView(R.id.tv_topic)
TextView tvTopic;
@BindView(R.id.rl_last)
RelativeLayout rlLast;
@BindView(R.id.rl_next)
RelativeLayout rlNext;
@BindView(R.id.commit)
LinearLayout commit;
@BindView(R.id.index)
TextView index;
@BindView(R.id.all)
TextView all;
@BindView(R.id.tv_right_num)
TextView tvRightNum;
@BindView(R.id.tv_wrong_num)
TextView tvWrongNum;
@BindView(R.id.lin_tab)
LinearLayout linTab;
@BindView(R.id.rl_card)
RelativeLayout rlCard;
private ListAnswerAdapter optionsAdapter;
private List<AnswerBean.QuestionLstBean> questionList = new ArrayList<>();
private List<Integer> sheetCard = new ArrayList<>();
private String catalogOid;
private PopupWindow popupWindow;
private int maxTopic=0; //题目总数量
private int unDone; //未完成题目数量
private double danxuan; //单选题分数 单个
private double duoxuan; //多选题分数 单个
private double panduan; //判断题分数 单个
private int danxuanCount;//单选题数量
private int duoxuanCount;//多选题数量
private int panduanCount;//判断题数量
private int currentIndex = 0; //当前题目下标
private String selectAnswer; //选择答案
private String rightAnswer; //正确答案
private double totalScore = 0; //获得分数
private String markType; //当前题目类型
private boolean isClickOnce = false;//是否是单选题 只能点击一次
private int rightCount;//答对题的数量
private int wrongCount;//答错题的数量
private int danxuanWrong;//单选做错的数量
private int duoxuanWrong;//多选做错的数量
private int panduanWrong;//判断做错的数量
private AnswerSheetGridAdapter sheetGridAdapter;
private String resumeOid;
// R.layout.pop_answer
@Override
public void initView() {
resumeOid = SharedPrefrenceUtils.getString(this, "AccountOid");
catalogOid = getIntent().getStringExtra("catalogOid");
rlLast.setOnClickListener(this);
rlNext.setOnClickListener(this);
commit.setOnClickListener(this);
linTab.setOnClickListener(this);
rlCard.setOnClickListener(this);
listAnswer.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ImageView wrong = (ImageView) view.findViewById(R.id.img_wrong);
ImageView right = (ImageView) view.findViewById(R.id.img_right);
TextView option = (TextView) view.findViewById(R.id.option);
if (markType.contains("单选") || markType.contains("判断")) {
if (isClickOnce) {
isClickOnce = false;
try {
//选择答案
if (position == 0)
selectAnswer = "A";
if (position == 1)
selectAnswer = "B";
if (position == 2)
selectAnswer = "C";
if (position == 3)
selectAnswer = "D";
if (position == 4)
selectAnswer = "E";
if (position == 5)
selectAnswer = "F";
} catch (Exception e) {
Log.e("Exception:", e.toString());
}
} else {
return;
}
} else if (markType.contains("多选")) {
try {
//选择答案
if (position == 0)
selectAnswer += "A";
if (position == 1)
selectAnswer += "B";
if (position == 2)
selectAnswer += "C";
if (position == 3)
selectAnswer += "D";
if (position == 4)
selectAnswer += "E";
if (position == 5)
selectAnswer += "F";
} catch (Exception e) {
Log.e("Exception:", e.toString());
}
}
Log.e("zhangtao:rightAnswer", rightAnswer + "");
Log.e("zhangtao:selectAnswer", selectAnswer + "");
if (rightAnswer.contains(selectAnswer)) {
right.setVisibility(View.VISIBLE);
wrong.setVisibility(View.GONE);
option.setVisibility(View.GONE);
//答题成功 加分
if (markType.contains("单选")) {
totalScore += danxuan;
} else if (markType.contains("多选")) {
totalScore += duoxuan;
} else if (markType.contains("判断")) {
totalScore += panduan;
}
rightCount++;
tvRightNum.setText(String.valueOf(rightCount));
sheetCard.set(currentIndex, 1);
sheetGridAdapter.notifyDataSetChanged();
} else {
if (markType.contains("单选")) {
danxuanWrong++;
} else if (markType.contains("多选")) {
duoxuanWrong++;
} else if (markType.contains("判断")) {
panduanWrong++;
}
//答题失败
right.setVisibility(View.GONE);
wrong.setVisibility(View.VISIBLE);
option.setVisibility(View.GONE);
String questionOid = questionList.get(position).getQuestionOid();
mPresenter.getPresenter(4, 2, resumeOid, questionOid, String.valueOf(1));
wrongCount++;
tvWrongNum.setText(String.valueOf(wrongCount));
sheetCard.set(currentIndex, 2);
sheetGridAdapter.notifyDataSetChanged();
}
}
});
}
private void doRefresh() {
rightAnswer = questionList.get(currentIndex).getAnswer();
tvCurrent.setText(String.valueOf(currentIndex + 1));
tvRadio.setText(questionList.get(currentIndex).getQuestionTypeName());
markType = questionList.get(currentIndex).getQuestionTypeName();
if (markType.contains("单选") || markType.contains("判断")) {
isClickOnce = true;
} else {
isClickOnce = false;
}
tvTopic.setText(questionList.get(currentIndex).getQuestionTitle());
optionsAdapter = new ListAnswerAdapter(questionList.get(currentIndex).getOptionsLst(), this);
listAnswer.setAdapter(optionsAdapter);
optionsAdapter.notifyDataSetChanged();
}
@Override
public int initLayout() {
return R.layout.activity_answer;
}
@Override
public void initData() {
// mPresenter.getPresenter(4, 1, catalogOid, "3E0E2A6B-6616-4CEE-B498-1F06A6F8D482");
mPresenter.getPresenter(4, 1, catalogOid,resumeOid);
}
@Override
public CommonPresenter getPresenter() {
return new CommonPresenter();
}
@Override
public ExerciseModel getModel() {
return new ExerciseModel();
}
@Override
public void getData(Object o, int api, int intent) {
if (api == 4 && intent == 1) {
AnswerBean bean = (AnswerBean) o;
maxTopic = bean.getRadioCount() + bean.getMultipleCount() + bean.getJudgeCount();
danxuanCount = bean.getRadioCount();
duoxuanCount = bean.getMultipleCount();
panduanCount = bean.getJudgeCount();
all.setText(String.valueOf(maxTopic));
for (int i = 0; i < maxTopic; i++) {
sheetCard.add(0);
}
sheetGridAdapter = new AnswerSheetGridAdapter(sheetCard, this);
questionList.addAll(bean.getQuestionLst());
danxuan = bean.getRadioScore();
duoxuan = bean.getMultipleScore();
panduan = bean.getJudgeScore();
rightAnswer = bean.getQuestionLst().get(0).getAnswer();
if (bean.getExamType() != null) {
tvTitle.setText(bean.getExamType());
}
optionsAdapter = new ListAnswerAdapter(questionList.get(0).getOptionsLst(), this);
listAnswer.setAdapter(optionsAdapter);
tvCurrent.setText(String.valueOf(currentIndex + 1));
tvMax.setText(String.valueOf(maxTopic));
if (questionList.get(currentIndex).getQuestionTypeName() != null)
tvRadio.setText(questionList.get(currentIndex).getQuestionTypeName());
markType = questionList.get(currentIndex).getQuestionTypeName();
if (markType.contains("单选") || markType.contains("判断")) {
isClickOnce = true;
} else {
isClickOnce = false;
}
if (questionList.get(currentIndex).getQuestionTitle() != null)
tvTopic.setText(questionList.get(currentIndex).getQuestionTitle());
}
}
@Override
public void onComplete(int api) {
}
@Override
public void onError(Throwable e, int api) {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.rl_last:
if (currentIndex > 0) {
selectAnswer = "";
currentIndex--;
index.setText(String.valueOf(currentIndex + 1));
doRefresh();
} else {
Toast.makeText(this, "当前已是第一题", Toast.LENGTH_SHORT).show();
}
break;
case R.id.rl_next:
if (currentIndex < maxTopic - 1) {
if (selectAnswer == "" || selectAnswer == null) {
sheetCard.set(currentIndex, 0);
sheetGridAdapter.notifyDataSetChanged();
unDone++;
if (markType.contains("单选")) {
danxuanWrong++;
} else if (markType.contains("多选")) {
duoxuanWrong++;
} else if (markType.contains("判断")) {
panduanWrong++;
}
String questionOid = questionList.get(currentIndex).getQuestionOid();
mPresenter.getPresenter(4, 2, resumeOid, questionOid, String.valueOf(1));
}
currentIndex++;
index.setText(String.valueOf(currentIndex + 1));
doRefresh();
selectAnswer = "";
} else {
/* Intent intent = new Intent(this, AnswerMarkActivity.class);
intent.putExtra("catalogOid", catalogOid);
startActivity(intent);
Log.e("zhangtao:totalScore", totalScore + "");*/
Toast.makeText(this, "当前已是最后一题", Toast.LENGTH_SHORT).show();
}
break;
case R.id.commit:
showCommitCard(this, maxTopic - currentIndex - 1);
chageAlpha(0.5f);
break;
case R.id.lin_tab:
this.finish();
break;
case R.id.rl_card:
showAnswerCard(sheetCard, rightCount, wrongCount, currentIndex, maxTopic);
break;
}
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void showCommitCard(final Context context, int laveCount) {
View contentView = LayoutInflater.from(this).inflate(R.layout.pop_answer_commit, null);
View view = LayoutInflater.from(this).inflate(R.layout.activity_answer, null);
TextView count = (TextView) contentView.findViewById(R.id.tv_count);
TextView goOn = (TextView) contentView.findViewById(R.id.tv_continue);
TextView commit = (TextView) contentView.findViewById(R.id.tv_commit);
count.setText(String.valueOf(laveCount));
popupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
popupWindow.setOutsideTouchable(false);
popupWindow.setTouchable(true);
popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0);
goOn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popupWindow.dismiss();
}
});
commit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popupWindow.dismiss();
Intent intent = new Intent(context, TestScoreActivity.class);
intent.putExtra("catalogOid", catalogOid);
intent.putExtra("danxuanCount", danxuanCount);
intent.putExtra("duoxuanCount", duoxuanCount);
intent.putExtra("panduanCount", panduanCount);
intent.putExtra("danxuanWrong", danxuanWrong);
intent.putExtra("panduanWrong", panduanWrong);
intent.putExtra("duoxuanWrong", duoxuanWrong);
intent.putExtra("totalScore", totalScore);
Log.e("zhangtao",totalScore+"分");
startActivity(intent);
}
});
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
chageAlpha(1f);
}
});
}
private void showAnswerCard(List<Integer> sheetCard, int rightCount, int wrongCount, int currentIndex, int maxTopic) {
View contentView = LayoutInflater.from(this).inflate(R.layout.pop_answer_sheet, null);
View view = LayoutInflater.from(this).inflate(R.layout.activity_answer, null);
TextView tv_card = (TextView) contentView.findViewById(R.id.tv_card);
GridView gridView = (GridView) contentView.findViewById(R.id.grid_dati);
TextView index = (TextView) contentView.findViewById(R.id.index);
TextView total = (TextView) contentView.findViewById(R.id.total);
TextView right = (TextView) contentView.findViewById(R.id.tv_right_num);
TextView wrong = (TextView) contentView.findViewById(R.id.tv_wrong_num);
right.setText(String.valueOf(rightCount));
wrong.setText(String.valueOf(wrongCount));
index.setText(String.valueOf(currentIndex+1));
total.setText(String.valueOf(maxTopic));
// sheetGridAdapter = new AnswerSheetGridAdapter(sheetCard, this);
gridView.setAdapter(sheetGridAdapter);
popupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
popupWindow.setOutsideTouchable(false);
popupWindow.setTouchable(true);
popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
tv_card.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (popupWindow != null) {
popupWindow.dismiss();
}
}
});
}
private void chageAlpha(float color) {
WindowManager.LayoutParams lp = this.getWindow().getAttributes();
lp.alpha = color;
this.getWindow().setAttributes(lp);
}
}
... ...
package com.hh.xuetubao.activity.pratice;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import com.hh.xuetubao.R;
import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
import com.hh.xuetubao.adapter.ListAnswerMarkAdapter;
import com.hh.xuetubao.bean.TranscriptBean;
import com.hh.xuetubao.model.ExerciseModel;
import com.hh.xuetubao.mvp.BaseMvpActivity;
import com.hh.xuetubao.mvp.CommonPresenter;
import com.hh.xuetubao.mvp.ICommonView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* 成绩单页面
*/
public class AnswerMarkActivity extends BaseMvpActivity<CommonPresenter, ExerciseModel> implements ICommonView, View.OnClickListener {
@BindView(R.id.tv_title)
TextView tvTitle;
@BindView(R.id.count_test)
TextView countTest;
@BindView(R.id.count_pass)
TextView countPass;
@BindView(R.id.count_answer)
TextView countAnswer;
@BindView(R.id.list_history)
ListView listHistory;
@BindView(R.id.lin_back)
LinearLayout linBack;
private String catalogOid;
private List<TranscriptBean.RecordLstBean> recordLst = new ArrayList<>();
private ListAnswerMarkAdapter markAdapter;
private String resumeOid;
@Override
public void initView() {
resumeOid = SharedPrefrenceUtils.getString(this, "AccountOid");
catalogOid = getIntent().getStringExtra("catalogOid");
markAdapter = new ListAnswerMarkAdapter(recordLst, this);
listHistory.setAdapter(markAdapter);
linBack.setOnClickListener(this);
}
@Override
public int initLayout() {
return R.layout.activity_answer_mark;
}
@Override
public void initData() {
// mPresenter.getPresenter(5,1,catalogOid,"3E0E2A6B-6616-4CEE-B498-1F06A6F8D482");
mPresenter.getPresenter(5, 1, catalogOid, resumeOid);
}
@Override
public CommonPresenter getPresenter() {
return new CommonPresenter();
}
@Override
public ExerciseModel getModel() {
return new ExerciseModel();
}
@Override
public void getData(Object o, int api, int intent) {
if (api == 5 && intent == 1) {
TranscriptBean bean = (TranscriptBean) o;
List<TranscriptBean.RecordLstBean> beanRecordLst = bean.getRecordLst();
if (beanRecordLst != null)
recordLst.addAll(beanRecordLst);
markAdapter.notifyDataSetChanged();
}
}
@Override
public void onComplete(int api) {
}
@Override
public void onError(Throwable e, int api) {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.lin_back:
this.finish();
break;
}
}
}
... ...