d
1
.idea/modules.xml
generated
@@ -5,6 +5,7 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/July.iml" filepath="$PROJECT_DIR$/July.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/baselibs/baselibs.iml" filepath="$PROJECT_DIR$/baselibs/baselibs.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/citypicker/citypicker.iml" filepath="$PROJECT_DIR$/citypicker/citypicker.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@@ -26,6 +26,7 @@ dependencies {
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.0.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
|
||||
@@ -60,4 +61,7 @@ dependencies {
|
||||
// implementation 'com.contrarywind:Android-PickerView:3.2.6'
|
||||
implementation 'com.contrarywind:Android-PickerView:4.1.9'
|
||||
implementation files('libs/fastjson-1.1.43.android.jar')
|
||||
implementation 'org.jsoup:jsoup:1.10.1'
|
||||
api 'com.amap.api:location:latest.integration'
|
||||
implementation project(':citypicker')
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.administrator.seven">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" /> <!-- 获取运营商信息,用于支持提供运营商信息相关的接口 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 这个权限用于获取wifi的获取权限,wifi信息会用来进行网络定位 -->
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
|
||||
<application
|
||||
android:name=".BaseApplication"
|
||||
android:allowBackup="true"
|
||||
@@ -14,25 +16,27 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name="com.example.administrator.seven.main.kehu.activity.JsonDataActivity">
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="android.intent.action.MAIN" />-->
|
||||
<activity android:name=".main.find.ConversationActivity"></activity>
|
||||
<activity android:name=".main.find.CommentActivity" />
|
||||
<activity android:name=".main.kehu.activity.JsonDataActivity">
|
||||
|
||||
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- <intent-filter> -->
|
||||
<!-- <action android:name="android.intent.action.MAIN" /> -->
|
||||
|
||||
|
||||
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
|
||||
<!-- </intent-filter> -->
|
||||
</activity>
|
||||
|
||||
|
||||
<activity android:name=".main.kehu.activity.CustomerDetailActivity"></activity>
|
||||
<activity android:name=".main.kehu.activity.CustomerDetailActivity" />
|
||||
<activity android:name=".main.activity.Main2Activity" /> <!-- 开启页 -->
|
||||
<activity
|
||||
android:name=".main.activity.SplashActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/SplashTheme">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity> <!-- 登录 -->
|
||||
<activity
|
||||
@@ -47,11 +51,13 @@
|
||||
<activity
|
||||
android:name=".main.activity.MainActivity"
|
||||
android:screenOrientation="portrait">
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="android.intent.action.MAIN" />-->
|
||||
|
||||
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- <intent-filter> -->
|
||||
<!-- <action android:name="android.intent.action.MAIN" /> -->
|
||||
|
||||
|
||||
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
|
||||
<!-- </intent-filter> -->
|
||||
</activity>
|
||||
<activity android:name=".view.webview.XfiveWebActivity" />
|
||||
<activity
|
||||
@@ -69,17 +75,25 @@
|
||||
<activity
|
||||
android:name=".main.kehu.activity.SearchActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".main.kehu.activity.DesignActivity"
|
||||
android:screenOrientation="portrait" >
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="android.intent.action.MAIN" />-->
|
||||
android:screenOrientation="portrait">
|
||||
|
||||
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- <intent-filter> -->
|
||||
<!-- <action android:name="android.intent.action.MAIN" /> -->
|
||||
|
||||
|
||||
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
|
||||
<!-- </intent-filter> -->
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.example.administrator.seven.main.find.CloundSolutionActivity"
|
||||
android:theme="@style/DefaultCityPickerTheme"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.example.administrator.seven.main.find.MainActivitytwot"
|
||||
android:theme="@style/DefaultCityPickerTheme"
|
||||
android:screenOrientation="portrait" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
||||
@@ -1,93 +1,167 @@
|
||||
package com.example.administrator.seven.base;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextPaint;
|
||||
import android.util.TypedValue;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.dialog.LoadingDialog;
|
||||
import com.example.administrator.seven.dialog.PersonnelDialogHelptwo;
|
||||
import com.example.administrator.seven.utils.StatusBarUtils;
|
||||
import com.example.administrator.seven.utils.NetUtils;
|
||||
import com.example.administrator.seven.utils.StatusBarUtil;
|
||||
import com.example.administrator.seven.utils.ToastUtils;
|
||||
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import androidx.annotation.ColorRes;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
|
||||
/**
|
||||
* 日期:2017.01.03
|
||||
* <p>
|
||||
* 作者:xudiwei
|
||||
* <p>
|
||||
* 描述:Baseactivity添加相关的方法
|
||||
*
|
||||
*
|
||||
* @author: qndroid
|
||||
* @function: 所有Activity的基类,用来处理一些公共事件,如:数据统计
|
||||
* @date: 16/3/10
|
||||
*/
|
||||
public class BaseActivity extends AppCompatActivity {
|
||||
public abstract class BaseActivity extends FragmentActivity {
|
||||
|
||||
private ProgressDialog mProgressDialog;
|
||||
private LoadingDialog mProgressDialog;
|
||||
public static final int REQUEST_CALL_PERMISSION = 10111; //拨号请求码
|
||||
protected final String TAG = this.getClass().getSimpleName();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
reverseStatusColor();
|
||||
StatusBarUtil.transparencyBar(this); //设置状态栏全透明
|
||||
StatusBarUtil.StatusBarLightMode(this); //设置白底黑字
|
||||
initFontScale();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 拨打电话(直接拨打)
|
||||
*
|
||||
* @param telPhone 电话
|
||||
*/
|
||||
public void call(String telPhone) {
|
||||
if (checkReadPermission(Manifest.permission.CALL_PHONE, REQUEST_CALL_PERMISSION)) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_CALL);
|
||||
Uri phoneNum = Uri.parse("tel:" + telPhone);
|
||||
intent.setData(phoneNum);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有某项权限
|
||||
*
|
||||
* @param string_permission 权限
|
||||
* @param request_code 请求码
|
||||
* @return
|
||||
*/
|
||||
public boolean checkReadPermission(String string_permission, int request_code) {
|
||||
boolean flag = false;
|
||||
if (ContextCompat.checkSelfPermission(this, string_permission) == PackageManager.PERMISSION_GRANTED) {//已有权限
|
||||
flag = true;
|
||||
} else {//申请权限
|
||||
ActivityCompat.requestPermissions(this, new String[]{string_permission}, request_code);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
private void initFontScale() {
|
||||
Configuration configuration = getResources().getConfiguration();
|
||||
configuration.fontScale = (float) 1;
|
||||
//0.85 小, 1 标准大小, 1.15 大,1.3 超大 ,1.45 特大
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||
metrics.scaledDensity = configuration.fontScale * metrics.density;
|
||||
getBaseContext().getResources().updateConfiguration(configuration, metrics);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
initStyle();
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化状态栏
|
||||
* 申请指定的权限.
|
||||
*/
|
||||
public void initStyle() {
|
||||
StatusBarUtils.setStateBaeColor(this, Color.parseColor("#131313"));
|
||||
}
|
||||
/**
|
||||
* 字体加粗
|
||||
*/
|
||||
protected void Thickening(TextView mLayTopTitle) {
|
||||
TextPaint tp = mLayTopTitle.getPaint();
|
||||
tp.setFakeBoldText(true);
|
||||
}
|
||||
public void requestPermission(int code, String... permissions) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void toast(String msg) {
|
||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public void toast(@StringRes int ids) {
|
||||
this.toast(getString(ids));
|
||||
ActivityCompat.requestPermissions(this, permissions, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 线程安全的toast
|
||||
*
|
||||
* @param msg
|
||||
* 初始化进度对话框
|
||||
*/
|
||||
public void toastThreadSafe(final String msg) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
toast(msg);
|
||||
|
||||
public void showProgressDialog(String dialogMessage,Context mContext) {
|
||||
mProgressDialog = new LoadingDialog(mContext);
|
||||
mProgressDialog.setCanceledOnTouchOutside(false);
|
||||
// mProgressDialog.setMessage(dialogMessage);
|
||||
mProgressDialog.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭进度对话框
|
||||
*/
|
||||
|
||||
public void dismissProgressDialog() {
|
||||
if (null != mProgressDialog && mProgressDialog.isShowing()) {
|
||||
mProgressDialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有指定的权限
|
||||
*/
|
||||
public boolean hasPermission(String... permissions) {
|
||||
|
||||
for (String permisson : permissions) {
|
||||
if (ContextCompat.checkSelfPermission(this, permisson)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理整个应用用中的SDCard业务
|
||||
*/
|
||||
public void doSDCardPermission() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏状态栏
|
||||
*/
|
||||
public void hiddenStatusBar() {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
/**
|
||||
* 开启一个Activity
|
||||
*
|
||||
@@ -96,88 +170,68 @@ public class BaseActivity extends AppCompatActivity {
|
||||
public void startActivity(Class<? extends Activity> clz) {
|
||||
startActivity(new Intent(this, clz));
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启一个Activity并关闭当前Activity
|
||||
* 改变状态栏颜色
|
||||
*
|
||||
* @param clz
|
||||
* @param color
|
||||
*/
|
||||
public void startActivityAndFinishSelf(Class<? extends Activity> clz) {
|
||||
startActivity(clz);
|
||||
finish();
|
||||
public void changeStatusBarColor(@ColorRes int color) {
|
||||
// StatusBarUtil.setStatusBarColor(this, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化进度对话框
|
||||
* 调整状态栏为亮模式,这样状态栏的文字颜色就为深模式了。
|
||||
*/
|
||||
public void showProgressDialog(String dialogMessage) {
|
||||
mProgressDialog = new ProgressDialog(this);
|
||||
mProgressDialog.setCanceledOnTouchOutside(false);
|
||||
mProgressDialog.setMessage(dialogMessage);
|
||||
mProgressDialog.show();
|
||||
private void reverseStatusColor() {
|
||||
// StatusBarUtil.statusBarLightMode(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 关闭进度对话框
|
||||
* 弹出提示对话框
|
||||
*/
|
||||
public void dismissProgressDialog() {
|
||||
if (null != mProgressDialog && mProgressDialog.isShowing()) {
|
||||
mProgressDialog.dismiss();
|
||||
|
||||
public void alertmessage(Context context,String msg) {
|
||||
|
||||
new PersonnelDialogHelptwo().showDownloadDialog(BaseActivity.this, msg,"确定", new PersonnelDialogHelptwo.ClickListener() {
|
||||
@Override
|
||||
public void confirm() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
public void messageDialog(String str) {
|
||||
new PersonnelDialogHelptwo().showDownloadDialog(BaseActivity.this, str,"确定", new PersonnelDialogHelptwo.ClickListener() {
|
||||
@Override
|
||||
public void confirm() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void toast(String msg) {
|
||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
/**
|
||||
* 字体加粗
|
||||
*/
|
||||
protected void Thickening(TextView mLayTopTitle) {
|
||||
TextPaint tp = mLayTopTitle.getPaint();
|
||||
tp.setFakeBoldText(true);
|
||||
}
|
||||
protected void Thickeningtwo(TextView mLayTopTitle) {
|
||||
TextPaint tp = mLayTopTitle.getPaint();
|
||||
tp.setFakeBoldText(false);
|
||||
}
|
||||
|
||||
|
||||
public boolean ConnectNetwork(Context context,String str) {
|
||||
if (!NetUtils.isConnected(context)) {
|
||||
ToastUtils.showToast(context, str);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化刷新控件的参数
|
||||
*
|
||||
* @param ids 刷新控件的id
|
||||
*/
|
||||
protected SwipeRefreshLayout setSwipeRefreshLayout(@IdRes int ids) {
|
||||
SwipeRefreshLayout mRefreshLayout = (SwipeRefreshLayout) findViewById(ids);
|
||||
mRefreshLayout.setProgressViewOffset(false, 0,
|
||||
(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, getResources().getDisplayMetrics()));
|
||||
mRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
|
||||
return mRefreshLayout;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 显示或隐藏软键盘,如果当时是显示则隐藏,如果当前是隐藏则显示
|
||||
*/
|
||||
public void showOrHide() {
|
||||
InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
// 得到InputMethodManager的实例
|
||||
if (imm.isActive()) {
|
||||
// 如果开启
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,
|
||||
InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 隐藏软键盘
|
||||
*/
|
||||
public void hintKb() {
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
/**点击空白处隐藏键盘*/
|
||||
if (getCurrentFocus() != null && getCurrentFocus().getWindowToken() != null) {
|
||||
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示软键盘
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public void showKb(View view) {
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.showSoftInput(view, InputMethodManager.RESULT_SHOWN);
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化一般返回按钮事件
|
||||
*/
|
||||
@@ -194,13 +248,4 @@ public class BaseActivity extends AppCompatActivity {
|
||||
});
|
||||
}
|
||||
}
|
||||
public void messageDialog(String str) {
|
||||
new PersonnelDialogHelptwo().showDownloadDialog(BaseActivity.this, str,"确定", new PersonnelDialogHelptwo.ClickListener() {
|
||||
@Override
|
||||
public void confirm() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,257 @@
|
||||
package com.example.administrator.seven.base;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.example.administrator.seven.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import static com.example.administrator.seven.common.Constants.LIMIT;
|
||||
|
||||
|
||||
/**
|
||||
* BaseRecycleAdapter
|
||||
* (๑• . •๑)
|
||||
* 类描述:普通RecycleView的普通BaseAdapter
|
||||
* 支持多类型item,支持加载更多,通过{{@link #canLoadMore}开启}
|
||||
* 支持Empty布局
|
||||
* simple{@link ProjectAdapter}
|
||||
* Created by LeiXiaoXing on 2017/3/17 14:26
|
||||
*/
|
||||
|
||||
public abstract class BaseRecycleAdapter<E, VH extends BaseViewHolder<E>> extends RecyclerView.Adapter<BaseViewHolder<E>> {
|
||||
|
||||
/**
|
||||
* Item类型: 加载更多
|
||||
*/
|
||||
private static final int ITEM_TYPE_LOAD_MORE = -1;
|
||||
/**
|
||||
* Item类型: Empty
|
||||
*/
|
||||
private static final int ITEM_TYPE_EMPTY = -2;
|
||||
public List<E> mEList;
|
||||
protected Context mContext;
|
||||
private OnItemClickListener<E> mListener;
|
||||
/**
|
||||
* 是否支付加载更多,默认不开启
|
||||
*/
|
||||
private boolean canLoadMore;
|
||||
/**
|
||||
* 是否加载完全部,默认可以加载更多
|
||||
*/
|
||||
private boolean isLoadAll;
|
||||
|
||||
/**
|
||||
* 构造Adapter
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param eList 数据集合
|
||||
* @param canLoadMore 是否支持加载更多
|
||||
*/
|
||||
protected BaseRecycleAdapter(Context context, List<E> eList, boolean canLoadMore) {
|
||||
mEList = eList;
|
||||
mContext = context;
|
||||
this.canLoadMore = canLoadMore;
|
||||
}
|
||||
|
||||
public List<E> getEList() {
|
||||
return mEList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseViewHolder<E> onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == ITEM_TYPE_LOAD_MORE) {
|
||||
//返回加载更多类型 ViewHolder
|
||||
View view = LayoutInflater.from(mContext).inflate(R.layout.item_rcv_load_and_all, parent, false);
|
||||
return new LoadMoreViewHolder(view);
|
||||
} else if (viewType == ITEM_TYPE_EMPTY) {
|
||||
//返回空布局类型 ViewHolder
|
||||
View view = LayoutInflater.from(mContext).inflate(R.layout.item_rcv_empty, parent, false);
|
||||
return new EmptyViewHolder(view);
|
||||
} else {
|
||||
View view = LayoutInflater.from(mContext).inflate(getItemLayout(viewType), parent, false);
|
||||
return createViewHolder(view, viewType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final BaseViewHolder<E> holder, final int position) {
|
||||
holder.bindView(mEList.get(position), position);
|
||||
if (!canLoadMore || position <= LIMIT
|
||||
|| position != mEList.size() - 1
|
||||
&& mEList.get(0) != null) {
|
||||
//在没有开启加载更多时,开启加更多但未满一页数据时,大于一页数据但不是加载更多的item时,并且为空内容时
|
||||
//点击事件生效
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mListener != null) {
|
||||
if (mEList.get(position) == null) {
|
||||
return;
|
||||
}
|
||||
mListener.onItemClick(mEList.get(position),position);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (canLoadMore && position > LIMIT - 1 && position == mEList.size() - 1) {
|
||||
//如果开启加载更多,显示加载中
|
||||
return ITEM_TYPE_LOAD_MORE;
|
||||
} else if (mEList.get(0) == null) {
|
||||
//如果无内容,显示空布局
|
||||
return ITEM_TYPE_EMPTY;
|
||||
}
|
||||
return getCustomItemViewType(position);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建自定义的item Type
|
||||
*
|
||||
* @param position item下标
|
||||
* @return 自定义item Type
|
||||
*/
|
||||
protected int getCustomItemViewType(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建ViewHolder
|
||||
*
|
||||
* @param view item
|
||||
* @param viewType item视图类型
|
||||
* @return ViewHolder
|
||||
*/
|
||||
protected abstract VH createViewHolder(View view, int viewType);
|
||||
|
||||
/**
|
||||
* 获取子项布局文件id
|
||||
*
|
||||
* @return 子项布局文件id
|
||||
*/
|
||||
protected abstract int getItemLayout(int viewType);
|
||||
|
||||
/**
|
||||
* 刷新列表数据
|
||||
*
|
||||
* @param entitys 新的数据集合
|
||||
*/
|
||||
public void upDate(List<E> entitys) {
|
||||
this.mEList = entitys;
|
||||
isLoadAll = false;//刷新列表,取消已加载完全部状态
|
||||
if (entitys != null && entitys.size() != 0) {
|
||||
//有内容,移除EmptyView
|
||||
mEList.remove(null);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* 追加数据并更新
|
||||
*
|
||||
* @param entitys 新的数据集合
|
||||
*/
|
||||
public void upDateAdd(List<E> entitys) {
|
||||
|
||||
if (this.mEList == null) {
|
||||
mEList = entitys;
|
||||
} else if (entitys != null) {
|
||||
if (canLoadMore) {
|
||||
//k
|
||||
isLoadAll = entitys.size() == 0;
|
||||
if (entitys.size() != 0) {
|
||||
//移除加载更多
|
||||
isLoadAll = false;
|
||||
mEList.remove(null);
|
||||
}
|
||||
|
||||
}
|
||||
mEList.addAll(entitys);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (canLoadMore && mEList != null && mEList.size() >= LIMIT) {
|
||||
//数据条数大于每页条数时显示加载更多
|
||||
//添加加载更多到尾部
|
||||
if (!mEList.contains(null)) {
|
||||
mEList.add(null);
|
||||
}
|
||||
} else if (mEList == null || mEList.size() == 0) {
|
||||
//无内容,添加EmptyView
|
||||
mEList = new ArrayList<>();
|
||||
mEList.add(null);
|
||||
}
|
||||
return mEList.size();
|
||||
}
|
||||
|
||||
public boolean isLoadAll() {
|
||||
return isLoadAll;
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<E> listener) {
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
|
||||
public interface OnItemClickListener<E> {
|
||||
void onItemClick(E entity, int position);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载更多item以及加载完全部 ViewHolder
|
||||
*/
|
||||
private class LoadMoreViewHolder extends BaseViewHolder<E> {
|
||||
|
||||
private View viewLoadAll;
|
||||
private View viewLoading;
|
||||
|
||||
LoadMoreViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView(View itemView) {
|
||||
viewLoadAll = itemView.findViewById(R.id.view_load_all);
|
||||
viewLoading = itemView.findViewById(R.id.view_loading);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindView(E entity, int position) {
|
||||
viewLoadAll.setVisibility(isLoadAll ? View.VISIBLE : View.GONE);
|
||||
viewLoading.setVisibility(isLoadAll ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 空布局ViewHolder
|
||||
*/
|
||||
private class EmptyViewHolder extends BaseViewHolder<E> {
|
||||
|
||||
EmptyViewHolder(View view) {
|
||||
super(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView(View itemView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindView(E entity, int position) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import android.widget.Toast;
|
||||
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.dialog.LoadingDialogy;
|
||||
import com.example.administrator.seven.utils.StatusBarUtils;
|
||||
import com.hannesdorfmann.mosby3.mvp.MvpActivity;
|
||||
import com.hannesdorfmann.mosby3.mvp.MvpPresenter;
|
||||
import com.hannesdorfmann.mosby3.mvp.MvpView;
|
||||
@@ -41,7 +40,6 @@ public abstract class BaseTreeActivity<V extends MvpView, P extends MvpPresenter
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(getLayoutId());
|
||||
mContext = this;
|
||||
initStyle();
|
||||
initView();
|
||||
initData();
|
||||
initEvent();
|
||||
@@ -208,12 +206,4 @@ public abstract class BaseTreeActivity<V extends MvpView, P extends MvpPresenter
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化状态栏
|
||||
*/
|
||||
protected void initStyle() {
|
||||
StatusBarUtils.setStateBaeColor(this, Color.parseColor("#131313"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.example.administrator.seven.base;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/**
|
||||
* BaseViewHolder
|
||||
* (๑• . •๑)
|
||||
* 类描述:普通的BaseViewHolder
|
||||
* Created by LeiXiaoXing on 2017/3/17 14:12
|
||||
*/
|
||||
|
||||
public abstract class BaseViewHolder<E> extends RecyclerView.ViewHolder {
|
||||
|
||||
protected BaseViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
initView(itemView);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*
|
||||
* @param itemView 子视图
|
||||
*/
|
||||
protected abstract void initView(View itemView);
|
||||
|
||||
/**
|
||||
* 绑定数据
|
||||
*
|
||||
* @param entity 实体对象
|
||||
*/
|
||||
protected abstract void bindView(E entity,int position);
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
package com.example.administrator.seven.base;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.dialog.LoadingDialog;
|
||||
import com.example.administrator.seven.widget.TitleBar;
|
||||
import com.hannesdorfmann.mosby3.mvp.MvpFragment;
|
||||
import com.hannesdorfmann.mosby3.mvp.MvpPresenter;
|
||||
import com.hannesdorfmann.mosby3.mvp.MvpView;
|
||||
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
/**
|
||||
* BaseTreeFragment
|
||||
* (๑• . •๑)
|
||||
* 类描述: Fragment基类,使用第三方MVP
|
||||
* Created by LeiXiaoXing on 2017/3/14 09:57
|
||||
*/
|
||||
|
||||
public abstract class BasetwoFragment<V extends MvpView, P extends MvpPresenter<V>> extends MvpFragment<V, P> {
|
||||
|
||||
protected final String TAG = getClass().getSimpleName();
|
||||
protected Context mContext;
|
||||
protected Activity mActivity;
|
||||
private LoadingDialog mProgressDialog;
|
||||
/**
|
||||
* 视图是否已经初初始化
|
||||
*/
|
||||
protected boolean isInit = false;
|
||||
protected boolean isLoad = false;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
||||
return inflater.inflate(getFragmentLayoutId(), container, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
initView(view);
|
||||
initData();
|
||||
initEvent(view);
|
||||
isInit = true;
|
||||
isCanLoadData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Fragment布局文件id
|
||||
*
|
||||
* @return Fragment布局文件id
|
||||
*/
|
||||
protected abstract int getFragmentLayoutId();
|
||||
|
||||
/**
|
||||
* 初始化视图状态
|
||||
*/
|
||||
protected abstract void initView(View view);
|
||||
|
||||
/**
|
||||
* 初始化数据参数
|
||||
*/
|
||||
protected abstract void initData();
|
||||
|
||||
/**
|
||||
* 初始化操作事件
|
||||
*/
|
||||
protected abstract void initEvent(View view);
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
mContext = context;
|
||||
mActivity = getActivity();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 视图是否已经对用户可见,系统的方法,setUserVisibleHint在onCreate之前调用
|
||||
* 1.第一次创建Fragment时,加载数据会报空指针异常,所以要加个判断是否已经初始化
|
||||
* 2.当Fragment已经初始化,再次可见时会直接调用此方法,此时可以直接加载数据
|
||||
* 所以要在两个地方调用加载数据
|
||||
*/
|
||||
@Override
|
||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
isCanLoadData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可以加载数据
|
||||
* 可以加载数据的条件:
|
||||
* 1.视图已经初始化
|
||||
* 2.视图对用户可见
|
||||
*/
|
||||
private void isCanLoadData() {
|
||||
if (!isInit) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getUserVisibleHint()) {
|
||||
setUpView();
|
||||
isLoad = true;
|
||||
} else {
|
||||
if (isLoad) {
|
||||
stopLoad();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当视图初始化并且对用户可见的时候去真正的加载数据
|
||||
*/
|
||||
protected void setUpView() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 当视图已经对用户不可见并且加载过数据,如果需要在切换到其他页面时停止加载数据,可以调用此方法
|
||||
*/
|
||||
protected void stopLoad() {
|
||||
}
|
||||
|
||||
/**
|
||||
* toast
|
||||
*
|
||||
* @param msg 吐丝的内容
|
||||
*/
|
||||
public void toast(String msg) {
|
||||
Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
/**
|
||||
* toast
|
||||
*
|
||||
* @param ids 吐丝的内容的字符串ids
|
||||
*/
|
||||
public void toast(@StringRes int ids) {
|
||||
toast(getString(ids));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 线程安全的toast
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
public void toastThreadSafe(final String msg) {
|
||||
if (null != mActivity) {
|
||||
mActivity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
toast(msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 线程安全的toast
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
public void toastThreadSafe(@StringRes final int ids) {
|
||||
if (null != mActivity) {
|
||||
mActivity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
toast(ids);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启一个Activity
|
||||
*
|
||||
* @param clz 需要开启的Activity
|
||||
*/
|
||||
public void startActivity(Class<? extends Activity> clz) {
|
||||
if (null != mContext) {
|
||||
startActivity(new Intent(mContext, clz));
|
||||
// getActivity().overridePendingTransition(R.anim.trans_next_in,R.anim.trans_next_out);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启一个Activity,并finish掉当前的Activity
|
||||
*
|
||||
* @param clz
|
||||
*/
|
||||
public void startActivityAndFinishSelf(Class<? extends Activity> clz) {
|
||||
if (null != mActivity) {
|
||||
startActivity(clz);
|
||||
mActivity.finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化进度对话框
|
||||
*/
|
||||
|
||||
public void showProgressDialog(String dialogMessage) {
|
||||
mProgressDialog = new LoadingDialog(mContext);
|
||||
mProgressDialog.setCanceledOnTouchOutside(false);
|
||||
// mProgressDialog.setMessage(dialogMessage);
|
||||
mProgressDialog.show();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onHiddenChanged(boolean hidden) {
|
||||
super.onHiddenChanged(hidden);
|
||||
Log.d(TAG, "onHiddenChanged");
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭进度对话框
|
||||
*/
|
||||
|
||||
public void dismissProgressDialog() {
|
||||
if (null != mProgressDialog && mProgressDialog.isShowing()) {
|
||||
mProgressDialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化刷新控件的参数
|
||||
*
|
||||
* @param ids 刷新控件的id
|
||||
*/
|
||||
protected SwipeRefreshLayout setSwipeRefreshLayout(@IdRes int ids) {
|
||||
SwipeRefreshLayout mRefreshLayout = (SwipeRefreshLayout) getView().findViewById(ids);
|
||||
mRefreshLayout.setProgressViewOffset(false, 0,
|
||||
(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, getResources().getDisplayMetrics()));
|
||||
mRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
|
||||
return mRefreshLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置标题栏参数
|
||||
*
|
||||
* @param titleIds 标题栏的id
|
||||
* @param title 标题
|
||||
* @param goneLeftBtn 左边按钮是否显示
|
||||
* @param goneRightBtn 右边按钮是否显示
|
||||
* @param titleBarClickListener 左右边的按钮点击事件回调接口
|
||||
* @return 返回设置好的titlebar
|
||||
*/
|
||||
public TitleBar setTitleBar(@IdRes int titleIds, String title
|
||||
, boolean goneLeftBtn, boolean goneRightBtn, TitleBar.OnTitleBarClickListener titleBarClickListener) {
|
||||
TitleBar titleBar = (TitleBar) getView().findViewById(titleIds);
|
||||
titleBar.setTitle(title);
|
||||
titleBar.visibleIvLeftBtn(goneLeftBtn);
|
||||
titleBar.visibleIvRightBtn(goneRightBtn);
|
||||
titleBar.setOnTitleBarClickListener(titleBarClickListener);
|
||||
return titleBar;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.example.administrator.seven.common;
|
||||
|
||||
/**
|
||||
* Created by Administrator on 2016/1/10.
|
||||
* 作者:xudiwei
|
||||
* <p>
|
||||
* 描述:常量类
|
||||
*/
|
||||
|
||||
public class Constants {
|
||||
/**
|
||||
* 模拟网络请求成功
|
||||
*/
|
||||
public static final int SUCCESS = 1;
|
||||
/**
|
||||
* 模拟网络请求失败
|
||||
*/
|
||||
public static final int FAILE = 0;
|
||||
|
||||
/**
|
||||
* 模拟数据网络耗时
|
||||
*/
|
||||
public static final int LOADING_TIME = 1500;
|
||||
|
||||
/**
|
||||
* 模拟数据每页长度
|
||||
*/
|
||||
public static final int LIMIT = 20;
|
||||
|
||||
/**
|
||||
* 讯飞语音appid
|
||||
*/
|
||||
public static final String IFLYTEK_APPID = "58a176c2";
|
||||
/**
|
||||
* 当前App创建在Sd卡里的根目录,其它的目录都要创建在App_root_dir里面。
|
||||
*/
|
||||
public static final String APP_ROOT_DIR = "LifeTree";
|
||||
/**
|
||||
* 存图片的dir
|
||||
*/
|
||||
public static final String IMG_DIR = APP_ROOT_DIR + "/img";
|
||||
/**
|
||||
* 图片预览里保存图片的目录
|
||||
*/
|
||||
public static final String SAVE_IMG_DIR = APP_ROOT_DIR + "/save";
|
||||
/**
|
||||
* apk下载存放目录
|
||||
*/
|
||||
public static final String APK_DIR = APP_ROOT_DIR + "/apk";
|
||||
/**
|
||||
* 缓存目录
|
||||
*/
|
||||
public static final String CACHE_DIR = APP_ROOT_DIR + "/cache";
|
||||
/**
|
||||
* SharedPreferences 文件名
|
||||
*/
|
||||
public static final String SP_CONFIG_FILE_NAME = "config";
|
||||
private static final String TAG = "Constants";
|
||||
/**
|
||||
* 当前用户的user_id(token)
|
||||
*/
|
||||
private static String userId = "";
|
||||
/**
|
||||
* 当前用户的角色 1=普通用户 2=老师 3=义工
|
||||
*/
|
||||
// private static int role = -1;
|
||||
/**
|
||||
* 当前用户所在的班级
|
||||
*/
|
||||
private static String classId = "";
|
||||
/**
|
||||
* 当前用户的IMidentify
|
||||
*/
|
||||
private static String identify = "";
|
||||
|
||||
|
||||
/**
|
||||
* 消息内存中的用户相关的信息。
|
||||
*/
|
||||
public static void clearAccountInfo() {
|
||||
userId = "";
|
||||
//role = -1;
|
||||
classId = "";
|
||||
identify = "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -7,10 +7,11 @@ import android.widget.TextView;
|
||||
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.base.BaseActivity;
|
||||
import com.example.administrator.seven.main.find.FindFragment;
|
||||
import com.example.administrator.seven.main.kehu.TraceFragment;
|
||||
import com.example.administrator.seven.main.my.MyFragment;
|
||||
import com.example.administrator.seven.main.task.HomeFragment;
|
||||
import com.example.administrator.seven.main.zhibo.SendFragment;
|
||||
import com.example.administrator.seven.main.zhibo.LivebroFragment;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
@@ -23,6 +24,7 @@ public class MainActivity extends BaseActivity implements View.OnClickListener{
|
||||
*/
|
||||
private TextView mTvHome;
|
||||
private TextView mTvHomeImg;
|
||||
|
||||
private RelativeLayout mRlHome;
|
||||
/**
|
||||
* 地图
|
||||
@@ -30,6 +32,10 @@ public class MainActivity extends BaseActivity implements View.OnClickListener{
|
||||
private TextView mTvMap;
|
||||
private RelativeLayout mRlMap;
|
||||
private TextView mTvMapImg;
|
||||
/**
|
||||
* 发现
|
||||
*/
|
||||
private TextView img_toggle_cms;
|
||||
/**
|
||||
* 配送
|
||||
*/
|
||||
@@ -46,10 +52,13 @@ public class MainActivity extends BaseActivity implements View.OnClickListener{
|
||||
private FragmentManager fm;
|
||||
|
||||
private HomeFragment mHomeFragment;
|
||||
private SendFragment mSendFragment;
|
||||
private LivebroFragment mSendFragment;
|
||||
private TraceFragment traceFragment;
|
||||
private FindFragment mapFragment;
|
||||
private MyFragment mMineFragment;
|
||||
private Fragment mCurrent;
|
||||
private RelativeLayout rl_faxian;
|
||||
private TextView tv_find;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -62,8 +71,14 @@ public class MainActivity extends BaseActivity implements View.OnClickListener{
|
||||
private void initView() {
|
||||
mTvHomeImg = (TextView) findViewById(R.id.tv_home_img);
|
||||
mTvHome = (TextView) findViewById(R.id.tv_home);
|
||||
|
||||
|
||||
mRlHome = (RelativeLayout) findViewById(R.id.rl_home);
|
||||
mRlHome.setOnClickListener(this);
|
||||
rl_faxian = (RelativeLayout) findViewById(R.id.rl_faxian);
|
||||
rl_faxian.setOnClickListener(this);
|
||||
tv_find = (TextView) findViewById(R.id.tv_find);
|
||||
|
||||
mTvMapImg = (TextView) findViewById(R.id.tv_map_img);
|
||||
mTvMap = (TextView) findViewById(R.id.tv_map);
|
||||
mRlMap = (RelativeLayout) findViewById(R.id.rl_map);
|
||||
@@ -102,12 +117,14 @@ public class MainActivity extends BaseActivity implements View.OnClickListener{
|
||||
|
||||
mTvHome.setTextColor(getResources().getColor(R.color.colortheme));
|
||||
mTvSend.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
tv_find.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
mTvMap.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
mTvMy.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
|
||||
|
||||
hideFragment(mSendFragment, fragmentTransaction);
|
||||
hideFragment(traceFragment, fragmentTransaction);
|
||||
hideFragment(mapFragment, fragmentTransaction);
|
||||
hideFragment(mMineFragment, fragmentTransaction);
|
||||
if (mHomeFragment == null) {
|
||||
fragmentTransaction.add(R.id.content_layout, mHomeFragment);
|
||||
@@ -124,21 +141,48 @@ public class MainActivity extends BaseActivity implements View.OnClickListener{
|
||||
|
||||
mTvHome.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
mTvSend.setTextColor(getResources().getColor(R.color.colortheme));
|
||||
tv_find.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
mTvMap.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
mTvMy.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
|
||||
|
||||
hideFragment(mHomeFragment, fragmentTransaction);
|
||||
hideFragment(traceFragment, fragmentTransaction);
|
||||
hideFragment(mapFragment, fragmentTransaction);
|
||||
hideFragment(mMineFragment, fragmentTransaction);
|
||||
if (mSendFragment == null) {
|
||||
mSendFragment = new SendFragment();
|
||||
mSendFragment = new LivebroFragment();
|
||||
fragmentTransaction.add(R.id.content_layout, mSendFragment);
|
||||
} else {
|
||||
mCurrent = mSendFragment;
|
||||
fragmentTransaction.show(mSendFragment);
|
||||
}
|
||||
break;
|
||||
case R.id.rl_faxian:
|
||||
mTvHomeImg.setBackgroundResource(R.mipmap.icon_task_hui);
|
||||
mTvSendImg.setBackgroundResource(R.mipmap.icon_zhibohui);
|
||||
mTvMapImg.setBackgroundResource(R.mipmap.icon_kehuhui);
|
||||
mTvMineImg.setBackgroundResource(R.mipmap.icon_wodehui);
|
||||
|
||||
mTvHome.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
mTvSend.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
tv_find.setTextColor(getResources().getColor(R.color.colortheme));
|
||||
mTvMap.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
mTvMy.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
|
||||
|
||||
hideFragment(mHomeFragment, fragmentTransaction);
|
||||
hideFragment(mSendFragment, fragmentTransaction);
|
||||
hideFragment(traceFragment, fragmentTransaction);
|
||||
hideFragment(mMineFragment, fragmentTransaction);
|
||||
if (mapFragment == null) {
|
||||
mapFragment = new FindFragment();
|
||||
fragmentTransaction.add(R.id.content_layout, mapFragment);
|
||||
} else {
|
||||
mCurrent = mapFragment;
|
||||
fragmentTransaction.show(mapFragment);
|
||||
}
|
||||
break;
|
||||
case R.id.rl_map:
|
||||
mTvHomeImg.setBackgroundResource(R.mipmap.icon_task_hui);
|
||||
mTvSendImg.setBackgroundResource(R.mipmap.icon_zhibohui);
|
||||
@@ -147,12 +191,14 @@ public class MainActivity extends BaseActivity implements View.OnClickListener{
|
||||
|
||||
mTvHome.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
mTvSend.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
tv_find.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
mTvMap.setTextColor(getResources().getColor(R.color.colortheme));
|
||||
mTvMy.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
|
||||
|
||||
hideFragment(mHomeFragment, fragmentTransaction);
|
||||
hideFragment(mSendFragment, fragmentTransaction);
|
||||
hideFragment(mapFragment, fragmentTransaction);
|
||||
hideFragment(mMineFragment, fragmentTransaction);
|
||||
if (traceFragment == null) {
|
||||
traceFragment = new TraceFragment();
|
||||
@@ -170,12 +216,14 @@ public class MainActivity extends BaseActivity implements View.OnClickListener{
|
||||
|
||||
mTvHome.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
mTvSend.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
tv_find.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
mTvMap.setTextColor(getResources().getColor(R.color.colorhui));
|
||||
mTvMy.setTextColor(getResources().getColor(R.color.colortheme));
|
||||
|
||||
|
||||
hideFragment(mHomeFragment, fragmentTransaction);
|
||||
hideFragment(mSendFragment, fragmentTransaction);
|
||||
hideFragment(mapFragment, fragmentTransaction);
|
||||
hideFragment(traceFragment, fragmentTransaction);
|
||||
if (mMineFragment == null) {
|
||||
mMineFragment = new MyFragment();
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
package com.example.administrator.seven.main.find;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.amap.api.location.AMapLocation;
|
||||
import com.amap.api.location.AMapLocationClient;
|
||||
import com.amap.api.location.AMapLocationClientOption;
|
||||
import com.amap.api.location.AMapLocationListener;
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.base.BaseActivity;
|
||||
import com.zaaach.citypicker.CityPicker;
|
||||
import com.zaaach.citypicker.adapter.OnPickListener;
|
||||
import com.zaaach.citypicker.model.City;
|
||||
import com.zaaach.citypicker.model.HotCity;
|
||||
import com.zaaach.citypicker.model.LocateState;
|
||||
import com.zaaach.citypicker.model.LocatedCity;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class CloundSolutionActivity extends BaseActivity implements View.OnClickListener, AMapLocationListener {
|
||||
|
||||
private List<HotCity> hotCities;
|
||||
private int anim;
|
||||
private boolean enable;
|
||||
|
||||
|
||||
private TextView titleTv;
|
||||
private ImageView backIv;
|
||||
|
||||
/**
|
||||
* 西安
|
||||
*/
|
||||
private TextView mChengshi;
|
||||
|
||||
//声明AMapLocationClient类对象,定位发起端
|
||||
private AMapLocationClient mLocationClient = null;
|
||||
//声明mLocationOption对象,定位参数
|
||||
public AMapLocationClientOption mLocationOption = null;
|
||||
//标识,用于判断是否只显示一次定位信息和用户重新定位
|
||||
private boolean isFirstLoc = true;
|
||||
private String city;
|
||||
private String province;
|
||||
private String cityCode;
|
||||
private String adCode;
|
||||
private View view;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_clound_solution);
|
||||
initView();
|
||||
// HotCity();
|
||||
//开始定位
|
||||
// location();
|
||||
}
|
||||
|
||||
private void HotCity() {
|
||||
hotCities = new ArrayList<>();
|
||||
hotCities.add(new HotCity("北京", "北京", "101010100"));
|
||||
hotCities.add(new HotCity("上海", "上海", "101020100"));
|
||||
hotCities.add(new HotCity("广州", "广东", "101280101"));
|
||||
hotCities.add(new HotCity("深圳", "广东", "101280601"));
|
||||
hotCities.add(new HotCity("杭州", "浙江", "101210101"));
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
mChengshi = (TextView) findViewById(R.id.chengshi);
|
||||
mChengshi.setOnClickListener(this);
|
||||
view = (View) findViewById(R.id.view);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.leftIv:
|
||||
finish();
|
||||
break;
|
||||
case R.id.chengshi:
|
||||
CityPicker.from(CloundSolutionActivity.this)
|
||||
.enableAnimation(enable)
|
||||
.setAnimationStyle(anim)
|
||||
.setLocatedCity(null)
|
||||
.setHotCities(hotCities)
|
||||
.setOnPickListener(new OnPickListener() {
|
||||
@Override
|
||||
public void onPick(int position, City data) {
|
||||
// mDangqianchengshi.setText(String.format("当前城市:%s,%s", data.getName(), data.getCode()));
|
||||
mChengshi.setText(String.format(data.getName()));
|
||||
Toast.makeText(
|
||||
getApplicationContext(),
|
||||
String.format("点击的数据:%s,%s", data.getName(), data.getCode()),
|
||||
Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
Toast.makeText(getApplicationContext(), "取消选择", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocate() {
|
||||
//开始定位,这里模拟一下定位
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CityPicker.from(CloundSolutionActivity.this).locateComplete(new LocatedCity(city, province, adCode), LocateState.SUCCESS);
|
||||
}
|
||||
}, 3000);
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
.show();
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void location() {
|
||||
//初始化定位
|
||||
mLocationClient = new AMapLocationClient(getApplicationContext());
|
||||
//设置定位回调监听
|
||||
mLocationClient.setLocationListener(this);
|
||||
//初始化定位参数
|
||||
mLocationOption = new AMapLocationClientOption();
|
||||
//设置定位模式为Hight_Accuracy高精度模式,Battery_Saving为低功耗模式,Device_Sensors是仅设备模式
|
||||
mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
|
||||
//设置是否返回地址信息(默认返回地址信息)
|
||||
mLocationOption.setNeedAddress(true);
|
||||
//设置是否只定位一次,默认为false
|
||||
mLocationOption.setOnceLocation(false);
|
||||
//设置是否强制刷新WIFI,默认为强制刷新
|
||||
mLocationOption.setWifiActiveScan(true);
|
||||
//设置是否允许模拟位置,默认为false,不允许模拟位置
|
||||
mLocationOption.setMockEnable(false);
|
||||
//设置定位间隔,单位毫秒,默认为2000ms
|
||||
mLocationOption.setInterval(2000);
|
||||
//给定位客户端对象设置定位参数
|
||||
mLocationClient.setLocationOption(mLocationOption);
|
||||
//启动定位
|
||||
mLocationClient.startLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(AMapLocation aMapLocation) {
|
||||
if (aMapLocation != null) {
|
||||
if (aMapLocation.getErrorCode() == 0) {
|
||||
//定位成功回调信息,设置相关消息
|
||||
aMapLocation.getLocationType();//获取当前定位结果来源,如网络定位结果,详见官方定位类型表
|
||||
aMapLocation.getLatitude();//获取纬度
|
||||
aMapLocation.getLongitude();//获取经度
|
||||
aMapLocation.getAccuracy();//获取精度信息
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date date = new Date(aMapLocation.getTime());
|
||||
df.format(date);//定位时间
|
||||
aMapLocation.getAddress();//地址,如果option中设置isNeedAddress为false,则没有此结果,网络定位结果中会有地址信息,GPS定位不返回地址信息。
|
||||
aMapLocation.getCountry();//国家信息
|
||||
aMapLocation.getProvince();//省信息
|
||||
aMapLocation.getCity();//城市信息
|
||||
aMapLocation.getDistrict();//城区信息
|
||||
aMapLocation.getStreet();//街道信息
|
||||
aMapLocation.getStreetNum();//街道门牌号信息
|
||||
aMapLocation.getCityCode();//城市编码
|
||||
aMapLocation.getAdCode();//地区编码
|
||||
|
||||
// 如果不设置标志位,此时再拖动地图时,它会不断将地图移动到当前的位置
|
||||
if (isFirstLoc) {
|
||||
//获取定位信息
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(aMapLocation.getCountry() + ""
|
||||
+ aMapLocation.getProvince() + ""
|
||||
+ aMapLocation.getCity() + ""
|
||||
+ aMapLocation.getProvince() + ""
|
||||
+ aMapLocation.getDistrict() + ""
|
||||
+ aMapLocation.getStreet() + ""
|
||||
+ aMapLocation.getStreetNum());
|
||||
Toast.makeText(getApplicationContext(), buffer.toString(), Toast.LENGTH_LONG).show();
|
||||
|
||||
city = aMapLocation.getCity();
|
||||
mChengshi.setText(city);
|
||||
province = aMapLocation.getProvince();
|
||||
cityCode = aMapLocation.getCityCode();
|
||||
adCode = aMapLocation.getAdCode();
|
||||
isFirstLoc = false;
|
||||
mLocationClient.stopLocation();
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
//显示错误信息ErrCode是错误码,errInfo是错误信息,详见错误码表。
|
||||
Log.e("AmapError", "location Error, ErrCode:"
|
||||
+ aMapLocation.getErrorCode() + ", errInfo:"
|
||||
+ aMapLocation.getErrorInfo());
|
||||
Toast.makeText(getApplicationContext(), "定位失败", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.example.administrator.seven.main.find;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.base.BaseActivity;
|
||||
import com.example.administrator.seven.main.find.ui.CommentFragment;
|
||||
import com.example.administrator.seven.widget.TitleBar;
|
||||
|
||||
/**
|
||||
* 评论
|
||||
*/
|
||||
public class CommentActivity extends BaseActivity {
|
||||
|
||||
private TitleBar mTitleBar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_comment);
|
||||
mTitleBar = findViewById(R.id.title_bar);
|
||||
initNormalBack();
|
||||
String num = getIntent().getStringExtra("num");
|
||||
mTitleBar.setTitle("新评论"+"("+num+")");
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.container,new CommentFragment()).commit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.example.administrator.seven.main.find;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.base.BaseActivity;
|
||||
import com.example.administrator.seven.main.find.ui.CommentFragment;
|
||||
import com.example.administrator.seven.widget.TitleBar;
|
||||
|
||||
/**
|
||||
* 会话
|
||||
*/
|
||||
public class ConversationActivity extends BaseActivity {
|
||||
private TitleBar mTitleBar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_conversation);
|
||||
mTitleBar = findViewById(R.id.title_bar);
|
||||
initNormalBack();
|
||||
String num = getIntent().getStringExtra("num");
|
||||
mTitleBar.setTitle("抖音昵称"+"**");
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.container,new QuestionsFragment()).commit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.example.administrator.seven.main.find;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.main.find.ui.FindFragmenttwo;
|
||||
import com.example.administrator.seven.main.kehu.activity.ShowAty;
|
||||
import com.example.administrator.seven.test.BaseFragment;
|
||||
import com.zaaach.citypicker.CityPicker;
|
||||
import com.zaaach.citypicker.adapter.OnPickListener;
|
||||
import com.zaaach.citypicker.model.City;
|
||||
import com.zaaach.citypicker.model.HotCity;
|
||||
import com.zaaach.citypicker.model.LocateState;
|
||||
import com.zaaach.citypicker.model.LocatedCity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 发现
|
||||
*/
|
||||
public class FindFragment extends BaseFragment {
|
||||
private int anim;
|
||||
private boolean enable;
|
||||
private List<HotCity> hotCities;
|
||||
private String city;
|
||||
private String province;
|
||||
private String adCode;
|
||||
Context mContext;
|
||||
View view;
|
||||
private RelativeLayout rl_privateletter;
|
||||
private String pagetype="0";//0是家居 1是私信
|
||||
private RelativeLayout dianpubuju;
|
||||
private LinearLayout dianyuanbuju;
|
||||
private TextView marking_fragment;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mContext = getActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
if (view != null) {
|
||||
ViewGroup parent = (ViewGroup) view.getParent();
|
||||
if (parent != null) {
|
||||
parent.removeView(view);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
view = inflater.inflate(R.layout.criclefragment, container, false);
|
||||
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.container,new FindFragmenttwo()).commit();
|
||||
initView(view);
|
||||
HotCity();
|
||||
return view;
|
||||
}
|
||||
private void HotCity() {
|
||||
hotCities = new ArrayList<>();
|
||||
hotCities.add(new HotCity("北京", "北京", "101010100"));
|
||||
hotCities.add(new HotCity("上海", "上海", "101020100"));
|
||||
hotCities.add(new HotCity("广州", "广东", "101280101"));
|
||||
hotCities.add(new HotCity("深圳", "广东", "101280601"));
|
||||
hotCities.add(new HotCity("杭州", "浙江", "101210101"));
|
||||
}
|
||||
|
||||
private void initView(View mContentView) {
|
||||
marking_fragment = (TextView)view.findViewById(R.id.marking_fragment);
|
||||
dianpubuju = (RelativeLayout)view.findViewById(R.id.dianpubuju);
|
||||
dianyuanbuju = (LinearLayout)view.findViewById(R.id.dianyuanbuju);
|
||||
rl_privateletter = (RelativeLayout)view.findViewById(R.id.rl_privateletter);
|
||||
rl_privateletter.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(pagetype.equals("0")){
|
||||
pagetype="1";
|
||||
dianpubuju.setVisibility(View.GONE);
|
||||
dianyuanbuju.setVisibility(View.VISIBLE);
|
||||
|
||||
}else {
|
||||
pagetype="0";
|
||||
dianpubuju.setVisibility(View.VISIBLE);
|
||||
dianyuanbuju.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
PriLetFragment priLetFragment = (PriLetFragment) getChildFragmentManager().findFragmentById(R.id.news_title_fragment);
|
||||
priLetFragment.cutover(new PriLetFragment.ClickCallback() {
|
||||
@Override
|
||||
public void onsuccess() {
|
||||
pagetype="0";
|
||||
dianpubuju.setVisibility(View.VISIBLE);
|
||||
dianyuanbuju.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
marking_fragment.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// ShowAty.CloundSolutionActivity(getActivity());
|
||||
ShowAty.MainActivitytwot(getActivity());
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.example.administrator.seven.main.find;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.administrator.seven.R;
|
||||
import com.zaaach.citypicker.CityPicker;
|
||||
import com.zaaach.citypicker.adapter.OnPickListener;
|
||||
import com.zaaach.citypicker.model.City;
|
||||
import com.zaaach.citypicker.model.HotCity;
|
||||
import com.zaaach.citypicker.model.LocateState;
|
||||
import com.zaaach.citypicker.model.LocatedCity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class MainActivitytwot extends AppCompatActivity implements CompoundButton.OnCheckedChangeListener {
|
||||
private TextView currentTV;
|
||||
private CheckBox hotCB;
|
||||
private CheckBox animCB;
|
||||
private CheckBox enableCB;
|
||||
private Button themeBtn;
|
||||
|
||||
private static final String KEY = "current_theme";
|
||||
|
||||
private List<HotCity> hotCities;
|
||||
private int anim;
|
||||
private int theme;
|
||||
private boolean enable;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
theme = savedInstanceState.getInt(KEY);
|
||||
setTheme(theme > 0 ? theme : R.style.DefaultCityPickerTheme);
|
||||
}
|
||||
|
||||
setContentView(R.layout.activity_mainsss);
|
||||
|
||||
currentTV = findViewById(R.id.tv_current);
|
||||
hotCB = findViewById(R.id.cb_hot);
|
||||
animCB = findViewById(R.id.cb_anim);
|
||||
enableCB = findViewById(R.id.cb_enable_anim);
|
||||
themeBtn = findViewById(R.id.btn_style);
|
||||
|
||||
if (theme == R.style.DefaultCityPickerTheme){
|
||||
themeBtn.setText("默认主题");
|
||||
}
|
||||
hotCB.setOnCheckedChangeListener(this);
|
||||
animCB.setOnCheckedChangeListener(this);
|
||||
enableCB.setOnCheckedChangeListener(this);
|
||||
|
||||
themeBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (themeBtn.getText().toString().startsWith("自定义")){
|
||||
themeBtn.setText("默认主题");
|
||||
theme = R.style.DefaultCityPickerTheme;
|
||||
}
|
||||
recreate();
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.btn_pick).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
CityPicker.from(MainActivitytwot.this)
|
||||
.enableAnimation(enable)
|
||||
.setAnimationStyle(anim)
|
||||
.setLocatedCity(null)
|
||||
.setHotCities(hotCities)
|
||||
.setOnPickListener(new OnPickListener() {
|
||||
@Override
|
||||
public void onPick(int position, City data) {
|
||||
currentTV.setText(String.format("当前城市:%s,%s", data.getName(), data.getCode()));
|
||||
Toast.makeText(
|
||||
getApplicationContext(),
|
||||
String.format("点击的数据:%s,%s", data.getName(), data.getCode()),
|
||||
Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
Toast.makeText(getApplicationContext(), "取消选择", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocate() {
|
||||
//开始定位,这里模拟一下定位
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CityPicker.from(MainActivitytwot.this).locateComplete(new LocatedCity("深圳", "广东", "101280601"), LocateState.SUCCESS);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
switch (buttonView.getId()){
|
||||
case R.id.cb_hot:
|
||||
if (isChecked){
|
||||
hotCities = new ArrayList<>();
|
||||
hotCities.add(new HotCity("北京", "北京", "101010100"));
|
||||
hotCities.add(new HotCity("上海", "上海", "101020100"));
|
||||
hotCities.add(new HotCity("广州", "广东", "101280101"));
|
||||
hotCities.add(new HotCity("深圳", "广东", "101280601"));
|
||||
hotCities.add(new HotCity("杭州", "浙江", "101210101"));
|
||||
}else {
|
||||
hotCities = null;
|
||||
}
|
||||
break;
|
||||
case R.id.cb_anim:
|
||||
|
||||
break;
|
||||
case R.id.cb_enable_anim:
|
||||
enable = isChecked;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putInt(KEY, theme);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package com.example.administrator.seven.main.find;
|
||||
|
||||
import com.example.administrator.seven.base.BaseFragment;
|
||||
|
||||
public class MapFragment extends BaseFragment {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.example.administrator.seven.main.find;
|
||||
|
||||
/**
|
||||
* Created by ${hu} on 2017/5/27.
|
||||
*/
|
||||
|
||||
public interface OnSatisfactionListener {
|
||||
void onClick();
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.example.administrator.seven.main.find;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.main.find.ui.PrivateletterFragment;
|
||||
import com.example.administrator.seven.test.BaseFragment;
|
||||
|
||||
/**
|
||||
* 私信
|
||||
*/
|
||||
public class PriLetFragment extends BaseFragment {
|
||||
|
||||
Context mContext;
|
||||
View view;
|
||||
private RelativeLayout rl_live;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mContext = getActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
if (view != null) {
|
||||
ViewGroup parent = (ViewGroup) view.getParent();
|
||||
if (parent != null) {
|
||||
parent.removeView(view);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
view = inflater.inflate(R.layout.findfragment, container, false);
|
||||
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.containerr,new PrivateletterFragment()).commit();
|
||||
initView(view);
|
||||
return view;
|
||||
}
|
||||
|
||||
private void initView(View mContentView) {
|
||||
rl_live = (RelativeLayout)view.findViewById(R.id.rl_live);
|
||||
|
||||
}
|
||||
|
||||
interface ClickCallback {
|
||||
void onsuccess();
|
||||
}
|
||||
|
||||
public void cutover(final ClickCallback callback) {
|
||||
rl_live.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
callback.onsuccess();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.example.administrator.seven.main.find;
|
||||
|
||||
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.base.BaseTreeFragment;
|
||||
import com.example.administrator.seven.main.find.adapter.QuestionsAdapter;
|
||||
import com.example.administrator.seven.main.find.entity.QuestionsEntity;
|
||||
import com.example.administrator.seven.main.find.mvp.contract.QuestionsContract;
|
||||
import com.example.administrator.seven.main.find.mvp.presenter.QuestionsPresenterImpl;
|
||||
import com.example.administrator.seven.widget.PastEditText;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
|
||||
/**
|
||||
* 日期:2017.01.03
|
||||
* <p>
|
||||
* 作者:
|
||||
* <p>
|
||||
* 描述:答疑Fragment
|
||||
*/
|
||||
public class QuestionsFragment extends BaseTreeFragment<QuestionsContract.View, QuestionsPresenterImpl> implements QuestionsContract.View {
|
||||
|
||||
|
||||
private Button btnSend;
|
||||
private PastEditText pastEditText;
|
||||
private RecyclerView mRecyclerView;
|
||||
private QuestionsAdapter mAdapter;
|
||||
private LinearLayoutManager mLayoutManager;
|
||||
|
||||
@Override
|
||||
protected int getFragmentLayoutId() {
|
||||
return R.layout.fragment_questions;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView(View view) {
|
||||
btnSend = (Button) view.findViewById(R.id.btn_send);
|
||||
pastEditText = (PastEditText) view.findViewById(R.id.et_msg);
|
||||
mRecyclerView = (RecyclerView) view.findViewById(R.id.rcv);
|
||||
mLayoutManager = new LinearLayoutManager(mContext);
|
||||
mRecyclerView.setLayoutManager(mLayoutManager);
|
||||
mAdapter = new QuestionsAdapter(mContext, null, false);
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
||||
|
||||
//初始化
|
||||
List<QuestionsEntity> question = new ArrayList<>();
|
||||
QuestionsEntity questionsEntity = new QuestionsEntity();
|
||||
questionsEntity.setIs_self(0);//表明是自己发送的
|
||||
questionsEntity.setMsg("您好,很高兴为您服务。");//设置问题内容
|
||||
question.add(questionsEntity);
|
||||
mAdapter.upDate(question);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initEvent(View view) {
|
||||
pastEditText.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) {
|
||||
btnSend.setEnabled(!TextUtils.isEmpty(s));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
btnSend.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//发送消息
|
||||
getPresenter().sendMsg();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public QuestionsPresenterImpl createPresenter() {
|
||||
return new QuestionsPresenterImpl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInput() {
|
||||
String msg = pastEditText.getText().toString();
|
||||
pastEditText.setText("");
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upDataAdd(List<QuestionsEntity> list) {
|
||||
mAdapter.upDateAdd(list);
|
||||
mLayoutManager.scrollToPosition(mAdapter.getEList().size() - 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.example.administrator.seven.main.find.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.main.kehu.Bean.CustomerListBean;
|
||||
import com.example.administrator.seven.utils.WidgetTools;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class FindListAdapter extends BaseQuickAdapter<CustomerListBean.ResultBean.DataBean, BaseViewHolder> {
|
||||
Context mcontext;
|
||||
OnViewClickListener onViewClickListener;
|
||||
|
||||
public FindListAdapter(Context context, List list) {
|
||||
super(R.layout.cuslist_item, list);
|
||||
this.mcontext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(final BaseViewHolder helper, final CustomerListBean.ResultBean.DataBean item) {
|
||||
WidgetTools.setTextfive((TextView) helper.getView(R.id.tv_dea_name), "", item.getName());
|
||||
WidgetTools.setTextfive((TextView) helper.getView(R.id.tv_dea_phone), "", item.getPhone());
|
||||
WidgetTools.setTextfive((TextView) helper.getView(R.id.tv_dea_watch), "", item.getWechat());
|
||||
TextView tv_cuslist_caozuo = (TextView)helper.getView(R.id.tv_cuslist_caozuo);
|
||||
tv_cuslist_caozuo.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
onViewClickListener.operation(item);
|
||||
}
|
||||
});
|
||||
RelativeLayout yichengjhiao_rv = (RelativeLayout)helper.getView(R.id.yichengjhiao_rv);
|
||||
yichengjhiao_rv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
onViewClickListener.enterCusDetail(item);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void operationListenner(OnViewClickListener onViewClickListener){
|
||||
this.onViewClickListener = onViewClickListener;
|
||||
}
|
||||
|
||||
public interface OnViewClickListener{
|
||||
|
||||
void operation(CustomerListBean.ResultBean.DataBean item);
|
||||
|
||||
|
||||
void enterCusDetail(CustomerListBean.ResultBean.DataBean item);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.example.administrator.seven.main.find.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.main.kehu.Bean.CustomerListBean;
|
||||
import com.example.administrator.seven.utils.WidgetTools;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PrivateletAdapter extends BaseQuickAdapter<CustomerListBean.ResultBean.DataBean, BaseViewHolder> {
|
||||
Context mcontext;
|
||||
OnViewClickListener onViewClickListener;
|
||||
|
||||
public PrivateletAdapter(Context context, List list) {
|
||||
super(R.layout.private_let_item, list);
|
||||
this.mcontext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(final BaseViewHolder helper, final CustomerListBean.ResultBean.DataBean item) {
|
||||
WidgetTools.setTextfive((TextView) helper.getView(R.id.tv_dea_name), "", item.getName());
|
||||
WidgetTools.setTextfive((TextView) helper.getView(R.id.tv_dea_phone), "", item.getPhone());
|
||||
WidgetTools.setTextfive((TextView) helper.getView(R.id.tv_dea_watch), "", item.getWechat());
|
||||
TextView tv_cuslist_caozuo = (TextView)helper.getView(R.id.tv_cuslist_caozuo);
|
||||
tv_cuslist_caozuo.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
onViewClickListener.operation(item);
|
||||
}
|
||||
});
|
||||
RelativeLayout yichengjhiao_rv = (RelativeLayout)helper.getView(R.id.yichengjhiao_rv);
|
||||
yichengjhiao_rv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
onViewClickListener.enterCusDetail(item);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void operationListenner(OnViewClickListener onViewClickListener){
|
||||
this.onViewClickListener = onViewClickListener;
|
||||
}
|
||||
|
||||
public interface OnViewClickListener{
|
||||
|
||||
void operation(CustomerListBean.ResultBean.DataBean item);
|
||||
|
||||
|
||||
void enterCusDetail(CustomerListBean.ResultBean.DataBean item);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
package com.example.administrator.seven.main.find.adapter;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.base.BaseRecycleAdapter;
|
||||
import com.example.administrator.seven.base.BaseViewHolder;
|
||||
import com.example.administrator.seven.main.find.entity.QuestionsEntity;
|
||||
import com.example.administrator.seven.utils.GlideTools;
|
||||
import com.example.administrator.seven.widget.CircleImageView;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
/**
|
||||
* QuestionsAdapter
|
||||
* (๑• . •๑)
|
||||
* 类描述: 答疑记录适配器
|
||||
* Created by LeiXiaoXing on 2017/5/22 19:53
|
||||
*/
|
||||
|
||||
public class QuestionsAdapter extends BaseRecycleAdapter<QuestionsEntity, QuestionsAdapter.ViewHolder> {
|
||||
|
||||
|
||||
private final int ITEM_TYPE_LEFT = 1;
|
||||
private final int ITEM_TYPE_RIGHT = 2;
|
||||
private Context mContext;
|
||||
|
||||
/**
|
||||
* 构造Adapter
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param questionEntities 数据集合
|
||||
* @param canLoadMore 是否支持加载更多
|
||||
*/
|
||||
public QuestionsAdapter(Context context, List<QuestionsEntity> questionEntities, boolean canLoadMore) {
|
||||
super(context, questionEntities, canLoadMore);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ViewHolder createViewHolder(View view, int viewType) {
|
||||
if (viewType == ITEM_TYPE_LEFT) {
|
||||
return new ViewHolder(view);
|
||||
} else if (viewType == ITEM_TYPE_RIGHT) {
|
||||
return new QuestionViewHolder(view);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getCustomItemViewType(int position) {
|
||||
return 1 == mEList.get(position).getIs_self() ? ITEM_TYPE_RIGHT : ITEM_TYPE_LEFT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getItemLayout(int viewType) {
|
||||
if (viewType == ITEM_TYPE_LEFT) {
|
||||
return R.layout.item_question_left;
|
||||
} else if (viewType == ITEM_TYPE_RIGHT) {
|
||||
return R.layout.item_question_right;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建绿色健康文本
|
||||
*
|
||||
* @param msg 文本内容
|
||||
* @return
|
||||
*/
|
||||
private TextView createTextView(String msg) {
|
||||
TextView textView = new TextView(mContext);
|
||||
textView.setPadding(0, 10, 0, 10);
|
||||
textView.setTextColor(ContextCompat.getColor(mContext, R.color.colorAccent));
|
||||
textView.setText(msg);
|
||||
textView.setTextSize(16);
|
||||
return textView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建绿色健康文本
|
||||
*
|
||||
* @param msg 文本内容
|
||||
* @return
|
||||
*/
|
||||
private WebView createWebView(String msg) {
|
||||
WebView webView = new WebView(mContext);
|
||||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
|
||||
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
|
||||
webView.setLayoutParams(layoutParams);
|
||||
// webView.getSettings().setLoadWithOverviewMode(true);// 缩放至屏幕的大小
|
||||
|
||||
webView.loadDataWithBaseURL(null, getNewContent(msg), "text/html", "utf-8", null);
|
||||
return webView;
|
||||
}
|
||||
|
||||
|
||||
class ViewHolder extends BaseViewHolder<QuestionsEntity> {
|
||||
|
||||
TextView tvContent;
|
||||
private FrameLayout view_content_fl;
|
||||
private LinearLayout view_content_ll;
|
||||
|
||||
protected ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView(View itemView) {
|
||||
tvContent = (TextView) itemView.findViewById(R.id.tv_content);
|
||||
view_content_fl = (FrameLayout) itemView.findViewById(R.id.view_content_fl);
|
||||
view_content_ll = (LinearLayout) itemView.findViewById(R.id.view_content_ll);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
@Override
|
||||
protected void bindView(final QuestionsEntity entity, int position) {
|
||||
Log.e("entity.getMsg()", "bindView: " + entity.getMsg());
|
||||
tvContent.setText(entity.getMsg());
|
||||
//0 = 解答内容回复 , 1 = 回答满意/不满意 ,2 = 点击提交问题
|
||||
if (entity.getReply_type() == 1) {
|
||||
view_content_fl.setVisibility(View.GONE);//隐藏帧布局,使用线性布局
|
||||
view_content_ll.setVisibility(View.VISIBLE);
|
||||
view_content_ll.removeAllViews();
|
||||
view_content_ll.setOrientation(LinearLayout.HORIZONTAL);
|
||||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
layoutParams.setMarginEnd(100);
|
||||
TextView tvUnsatisfy = createTextView("不满意");
|
||||
TextView tvSatisfy = createTextView("满意");
|
||||
tvUnsatisfy.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// mContext.startActivity(new Intent(mContext, QuestionsAddedActivity.class));
|
||||
}
|
||||
});
|
||||
tvSatisfy.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// Toast.makeText(mContext, "满意", Toast.LENGTH_SHORT).show();
|
||||
// mListener.onClick();
|
||||
}
|
||||
});
|
||||
view_content_ll.addView(tvUnsatisfy, layoutParams);
|
||||
view_content_ll.addView(tvSatisfy);
|
||||
} else if (entity.getReply_type() == 2) {
|
||||
view_content_ll.setVisibility(View.VISIBLE);
|
||||
view_content_fl.setVisibility(View.GONE);//隐藏帧布局,使用线性布局
|
||||
view_content_ll.removeAllViews();
|
||||
TextView textView = createTextView("点击提交问题和关键字 >");
|
||||
textView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// Intent intent=new Intent(mContext, QuestionsAddedActivity.class);
|
||||
// intent.putExtra("question",entity.getQuestion());//把问题传到提交问题界面
|
||||
// mContext.startActivity(intent);
|
||||
//mContext.startActivity(new Intent(mContext, QuestionsAddedActivity.class));
|
||||
}
|
||||
});
|
||||
view_content_ll.addView(textView);
|
||||
} else {
|
||||
view_content_fl.setVisibility(View.VISIBLE);
|
||||
view_content_ll.setVisibility(View.GONE);
|
||||
List<QuestionsEntity.DataEntity> data = entity.getData();
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
// view_content.setOrientation(LinearLayout.VERTICAL);
|
||||
view_content_fl.removeAllViews();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
//i + 1 + "." + data.get(i).getContent()
|
||||
view_content_fl.addView(createWebView(data.get(i).getContent()));
|
||||
// view_content.addView(createTextView(data.get(i).getContent()));
|
||||
Log.d("log","content:"+data.get(i).getContent());
|
||||
}
|
||||
Log.d("log",data.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getNewContent(String htmlText) {
|
||||
Document doc = Jsoup.parse(htmlText);
|
||||
Elements elements = doc.getElementsByTag("img");
|
||||
for (Element element : elements) {
|
||||
element.attr("width", "auto").attr("height", "auto");
|
||||
}
|
||||
return doc.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户提问方的ViewHolder
|
||||
*/
|
||||
private class QuestionViewHolder extends ViewHolder {
|
||||
|
||||
private CircleImageView ivAvatar;
|
||||
|
||||
private QuestionViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView(View itemView) {
|
||||
super.initView(itemView);
|
||||
ivAvatar = (CircleImageView) itemView.findViewById(R.id.iv_icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindView(QuestionsEntity entity, int position) {
|
||||
tvContent.setText(entity.getMsg());
|
||||
GlideTools.init(mContext).displaypic(ivAvatar, "", R.mipmap.icon_default_head);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.example.administrator.seven.main.find.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* QuestionsEntity
|
||||
* (๑• . •๑)
|
||||
* 类描述:
|
||||
* Created by LeiXiaoXing on 2017/5/22 19:46
|
||||
*/
|
||||
|
||||
public class QuestionsEntity {
|
||||
|
||||
/**
|
||||
* msg : 关键字"为什么"的解答如下
|
||||
* is_self : 0
|
||||
* data : [{"id":"69","content":"每年农历冬至这天,不论贫富,饺子是必不可少的节日饭。这种习俗,据说是为了纪念\u201c医圣\u201d张仲景。"},{"id":"70","content":"为了纪念这位\u201c医圣\u201d也为了冬天不冻耳朵,人们学着\u201c娇耳\u201d的样子,包成食物,也叫\u201c饺子\u201d或\u201c扁食\u201d。"},{"id":"71","content":"金字塔是古代埃及劳动人民智慧的结晶,是世界古代文明史上的奇迹。"},{"id":"72","content":"在《圣经》中,记载着这么一个故事:耶稣和他的十二个门徒逾越节聚会。在晚餐时,耶稣说:\u201c你们中有一个人要出卖我。 \u201d果然,门徒中的犹大向统治者告发了耶稣,耶稣被钉死在十字架上。当时晚餐桌上正好是十三个人,人们就认为是这个\u201c13\u201d带来了不幸。"}]
|
||||
* reply_type : 0
|
||||
*/
|
||||
|
||||
private String msg;
|
||||
private int is_self;
|
||||
private int reply_type;
|
||||
private List<DataEntity> data;
|
||||
private String question;
|
||||
|
||||
public String getQuestion() {
|
||||
return question;
|
||||
}
|
||||
|
||||
public void setQuestion(String question) {
|
||||
this.question = question;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getIs_self() {
|
||||
return is_self;
|
||||
}
|
||||
|
||||
public void setIs_self(int is_self) {
|
||||
this.is_self = is_self;
|
||||
}
|
||||
|
||||
public int getReply_type() {
|
||||
return reply_type;
|
||||
}
|
||||
|
||||
public void setReply_type(int reply_type) {
|
||||
this.reply_type = reply_type;
|
||||
}
|
||||
|
||||
public List<DataEntity> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(List<DataEntity> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static class DataEntity {
|
||||
/**
|
||||
* id : 69
|
||||
* content : 每年农历冬至这天,不论贫富,饺子是必不可少的节日饭。这种习俗,据说是为了纪念“医圣”张仲景。
|
||||
*/
|
||||
|
||||
private String id;
|
||||
private String content;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.example.administrator.seven.main.find.mvp.contract;
|
||||
|
||||
import com.example.administrator.seven.base.BaseTreeView;
|
||||
import com.example.administrator.seven.main.find.entity.QuestionsEntity;
|
||||
import com.example.administrator.seven.network.ApiCallBack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* QuestionsContract
|
||||
* (๑• . •๑)
|
||||
* 类描述:
|
||||
* Created by LeiXiaoXing on 2017/5/22 19:43
|
||||
*/
|
||||
|
||||
public class QuestionsContract {
|
||||
|
||||
public interface View extends BaseTreeView {
|
||||
|
||||
/**
|
||||
* 获取输入内容
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getInput();
|
||||
|
||||
/**
|
||||
* 叠加数据
|
||||
*
|
||||
* @param list
|
||||
*/
|
||||
void upDataAdd(List<QuestionsEntity> list);
|
||||
}
|
||||
|
||||
public interface Presenter {
|
||||
void sendMsg();
|
||||
}
|
||||
|
||||
public interface Model {
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param qu_key 关键字
|
||||
* @param callBack 回调
|
||||
*/
|
||||
void sendMsg(String qu_key, ApiCallBack<List<QuestionsEntity>> callBack);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.example.administrator.seven.main.find.mvp.model;
|
||||
|
||||
import com.example.administrator.seven.main.find.entity.QuestionsEntity;
|
||||
import com.example.administrator.seven.main.find.mvp.contract.QuestionsContract;
|
||||
import com.example.administrator.seven.network.ApiCallBack;
|
||||
import com.example.administrator.seven.network.ApiUtils;
|
||||
import com.example.administrator.seven.network.http.ResponseBean;
|
||||
import com.example.administrator.seven.utils.checkVersionsUtils.ProfileSpUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Created by 雷小星🍀 on 2017/05/22
|
||||
*/
|
||||
|
||||
public class QuestionsModelImpl implements QuestionsContract.Model {
|
||||
|
||||
@Override
|
||||
public void sendMsg(String qu_key, final ApiCallBack<List<QuestionsEntity>> callBack) {
|
||||
ApiUtils.getApi()
|
||||
.ask(ProfileSpUtils.getInstance().getUserProfie().getData().getUuid()
|
||||
, qu_key)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(new Consumer<ResponseBean<List<QuestionsEntity>>>() {
|
||||
@Override
|
||||
public void accept(@NonNull ResponseBean<List<QuestionsEntity>> listResponseBean) throws Exception {
|
||||
callBack.onResponse(listResponseBean);
|
||||
}
|
||||
}, new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(@NonNull Throwable throwable) throws Exception {
|
||||
callBack.onFailure(throwable);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.example.administrator.seven.main.find.mvp.presenter;
|
||||
|
||||
import com.example.administrator.seven.main.find.entity.QuestionsEntity;
|
||||
import com.example.administrator.seven.main.find.mvp.contract.QuestionsContract;
|
||||
import com.example.administrator.seven.main.find.mvp.model.QuestionsModelImpl;
|
||||
import com.example.administrator.seven.network.ApiCallBack;
|
||||
import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by 雷小星🍀 on 2017/05/22
|
||||
*/
|
||||
|
||||
public class QuestionsPresenterImpl extends MvpBasePresenter<QuestionsContract.View> implements QuestionsContract.Presenter {
|
||||
|
||||
private QuestionsModelImpl mModel;
|
||||
|
||||
public QuestionsPresenterImpl() {
|
||||
mModel = new QuestionsModelImpl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMsg() {
|
||||
if (getView() == null) {
|
||||
return;
|
||||
}
|
||||
//获取输入
|
||||
String input = getView().getInput();
|
||||
List<QuestionsEntity> question = new ArrayList<>();
|
||||
QuestionsEntity questionsEntity = new QuestionsEntity();
|
||||
questionsEntity.setIs_self(1);//表明是自己发送的
|
||||
questionsEntity.setMsg(input);//设置问题内容
|
||||
question.add(questionsEntity);
|
||||
getView().upDataAdd(question);
|
||||
//用户提问,获取服务器回答
|
||||
mModel.sendMsg(input, new ApiCallBack<List<QuestionsEntity>>() {
|
||||
@Override
|
||||
protected void onSuccess(List<QuestionsEntity> responseData, String message) {
|
||||
if (getView() == null) {
|
||||
return;
|
||||
}
|
||||
getView().upDataAdd(responseData);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFailure(String error) {
|
||||
if (getView() == null) {
|
||||
return;
|
||||
}
|
||||
getView().toast(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.example.administrator.seven.main.find.ui;
|
||||
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.administrator.seven.JsonUtils;
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.dialog.BaseTipsDialog;
|
||||
import com.example.administrator.seven.main.kehu.Bean.CustomerListBean;
|
||||
import com.example.administrator.seven.main.kehu.Dialog.CusOperationDialog;
|
||||
import com.example.administrator.seven.main.kehu.MobanFragment;
|
||||
import com.example.administrator.seven.main.kehu.activity.ShowAty;
|
||||
import com.example.administrator.seven.main.kehu.adapter.CusListAdapter;
|
||||
import com.example.administrator.seven.okgonet.NetApi;
|
||||
import com.example.administrator.seven.okgonet.Observer;
|
||||
import com.example.administrator.seven.utils.checkVersionsUtils.ProfileSpUtils;
|
||||
import com.lzy.okgo.model.Response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
|
||||
public class CommentFragment extends MobanFragment {
|
||||
|
||||
|
||||
public CommentFragment() {
|
||||
super();
|
||||
|
||||
}
|
||||
@Override
|
||||
public void initAdapter() {
|
||||
mMarkingFragmentRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
CusListAdapter markingtwoAdapter = new CusListAdapter(mContext, null);
|
||||
getAdpter(markingtwoAdapter);
|
||||
mMarkingFragmentRecyclerView.setAdapter(markingtwoAdapter);
|
||||
markingtwoAdapter.operationListenner(new CusListAdapter.OnViewClickListener() {
|
||||
@Override
|
||||
public void operation(final CustomerListBean.ResultBean.DataBean item) {
|
||||
new CusOperationDialog(getActivity(), R.style.dialog, new CusOperationDialog.OnCloseListener() {
|
||||
@Override
|
||||
public void phoneClick() {//拨打电话
|
||||
if (item.getPhone() != null) {
|
||||
call(item.getPhone());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kaidanonClick() {//删除客户
|
||||
new BaseTipsDialog().showDownloadDialog(getActivity(), "确认删除该客户吗?", "确定", new BaseTipsDialog.ClickListener() {
|
||||
@Override
|
||||
public void confirm() {
|
||||
Toast.makeText(getActivity(), "还没调接口", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancle() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//信息完善
|
||||
@Override
|
||||
public void uploadAvatar() {
|
||||
|
||||
}
|
||||
|
||||
}).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterCusDetail(CustomerListBean.ResultBean.DataBean item) {
|
||||
//进入查看评论
|
||||
ShowAty.CustomerDetailActivity(getActivity(),item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestData() {
|
||||
new NetApi().customerList(ProfileSpUtils.getInstance().getUserProfie().getData().getUuid(),"").subscribe(new Observer<Response>() {
|
||||
@Override
|
||||
public void onNext(Response response) {
|
||||
String body = (String) response.body();
|
||||
CustomerListBean.ResultBean result = JsonUtils.fromJson(body, CustomerListBean.class).getResult();
|
||||
mSwl.setRefreshing(false);
|
||||
if (result != null && String.valueOf(result.getSuccess()).equals("0")) {
|
||||
|
||||
List<CustomerListBean.ResultBean.DataBean> data = result.getData();
|
||||
if (data.size() == 0) {
|
||||
markingtwoAdapter.setEmptyView(notDataView);
|
||||
return;
|
||||
}
|
||||
if (mNextRequestPage == 1) {
|
||||
setData(true, data);
|
||||
} else {
|
||||
setData(false, data);
|
||||
}
|
||||
} else {
|
||||
setData(true, null);
|
||||
markingtwoAdapter.setEmptyView(notDataView);
|
||||
mSwl.setRefreshing(false);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
e.printStackTrace();
|
||||
markingtwoAdapter.setEmptyView(errorView);
|
||||
mSwl.setRefreshing(false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.example.administrator.seven.main.find.ui;
|
||||
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.administrator.seven.JsonUtils;
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.dialog.BaseTipsDialog;
|
||||
import com.example.administrator.seven.main.kehu.Bean.CustomerListBean;
|
||||
import com.example.administrator.seven.main.kehu.Dialog.CusOperationDialog;
|
||||
import com.example.administrator.seven.main.kehu.MobanFragment;
|
||||
import com.example.administrator.seven.main.kehu.activity.ShowAty;
|
||||
import com.example.administrator.seven.main.kehu.adapter.CusListAdapter;
|
||||
import com.example.administrator.seven.okgonet.NetApi;
|
||||
import com.example.administrator.seven.okgonet.Observer;
|
||||
import com.example.administrator.seven.utils.checkVersionsUtils.ProfileSpUtils;
|
||||
import com.lzy.okgo.model.Response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
|
||||
public class FindFragmenttwo extends MobanFragment {
|
||||
|
||||
|
||||
public FindFragmenttwo() {
|
||||
super();
|
||||
|
||||
}
|
||||
@Override
|
||||
public void initAdapter() {
|
||||
mMarkingFragmentRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
CusListAdapter markingtwoAdapter = new CusListAdapter(mContext, null);
|
||||
getAdpter(markingtwoAdapter);
|
||||
mMarkingFragmentRecyclerView.setAdapter(markingtwoAdapter);
|
||||
markingtwoAdapter.operationListenner(new CusListAdapter.OnViewClickListener() {
|
||||
@Override
|
||||
public void operation(final CustomerListBean.ResultBean.DataBean item) {
|
||||
new CusOperationDialog(getActivity(), R.style.dialog, new CusOperationDialog.OnCloseListener() {
|
||||
@Override
|
||||
public void phoneClick() {//拨打电话
|
||||
if (item.getPhone() != null) {
|
||||
call(item.getPhone());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kaidanonClick() {//删除客户
|
||||
new BaseTipsDialog().showDownloadDialog(getActivity(), "确认删除该客户吗?", "确定", new BaseTipsDialog.ClickListener() {
|
||||
@Override
|
||||
public void confirm() {
|
||||
Toast.makeText(getActivity(), "还没调接口", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancle() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//信息完善
|
||||
@Override
|
||||
public void uploadAvatar() {
|
||||
|
||||
}
|
||||
|
||||
}).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterCusDetail(CustomerListBean.ResultBean.DataBean item) {
|
||||
//进入查看评论
|
||||
ShowAty.CommentActivity(getActivity(),20);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestData() {
|
||||
new NetApi().customerList(ProfileSpUtils.getInstance().getUserProfie().getData().getUuid(),"").subscribe(new Observer<Response>() {
|
||||
@Override
|
||||
public void onNext(Response response) {
|
||||
String body = (String) response.body();
|
||||
CustomerListBean.ResultBean result = JsonUtils.fromJson(body, CustomerListBean.class).getResult();
|
||||
mSwl.setRefreshing(false);
|
||||
if (result != null && String.valueOf(result.getSuccess()).equals("0")) {
|
||||
|
||||
List<CustomerListBean.ResultBean.DataBean> data = result.getData();
|
||||
if (data.size() == 0) {
|
||||
markingtwoAdapter.setEmptyView(notDataView);
|
||||
return;
|
||||
}
|
||||
if (mNextRequestPage == 1) {
|
||||
setData(true, data);
|
||||
} else {
|
||||
setData(false, data);
|
||||
}
|
||||
} else {
|
||||
setData(true, null);
|
||||
markingtwoAdapter.setEmptyView(notDataView);
|
||||
mSwl.setRefreshing(false);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
e.printStackTrace();
|
||||
markingtwoAdapter.setEmptyView(errorView);
|
||||
mSwl.setRefreshing(false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.example.administrator.seven.main.find.ui;
|
||||
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.administrator.seven.JsonUtils;
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.dialog.BaseTipsDialog;
|
||||
import com.example.administrator.seven.main.find.adapter.PrivateletAdapter;
|
||||
import com.example.administrator.seven.main.kehu.Bean.CustomerListBean;
|
||||
import com.example.administrator.seven.main.kehu.Dialog.CusOperationDialog;
|
||||
import com.example.administrator.seven.main.kehu.MobanFragment;
|
||||
import com.example.administrator.seven.main.kehu.activity.ShowAty;
|
||||
import com.example.administrator.seven.main.kehu.adapter.CusListAdapter;
|
||||
import com.example.administrator.seven.okgonet.NetApi;
|
||||
import com.example.administrator.seven.okgonet.Observer;
|
||||
import com.example.administrator.seven.utils.checkVersionsUtils.ProfileSpUtils;
|
||||
import com.lzy.okgo.model.Response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
/**
|
||||
* 私信
|
||||
*/
|
||||
public class PrivateletterFragment extends MobanFragment {
|
||||
|
||||
|
||||
public PrivateletterFragment() {
|
||||
super();
|
||||
|
||||
}
|
||||
@Override
|
||||
public void initAdapter() {
|
||||
mMarkingFragmentRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
PrivateletAdapter markingtwoAdapter = new PrivateletAdapter(mContext, null);
|
||||
getAdpter(markingtwoAdapter);
|
||||
mMarkingFragmentRecyclerView.setAdapter(markingtwoAdapter);
|
||||
markingtwoAdapter.operationListenner(new PrivateletAdapter.OnViewClickListener() {
|
||||
@Override
|
||||
public void operation(final CustomerListBean.ResultBean.DataBean item) {
|
||||
new CusOperationDialog(getActivity(), R.style.dialog, new CusOperationDialog.OnCloseListener() {
|
||||
@Override
|
||||
public void phoneClick() {//拨打电话
|
||||
if (item.getPhone() != null) {
|
||||
call(item.getPhone());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kaidanonClick() {//删除客户
|
||||
new BaseTipsDialog().showDownloadDialog(getActivity(), "确认删除该客户吗?", "确定", new BaseTipsDialog.ClickListener() {
|
||||
@Override
|
||||
public void confirm() {
|
||||
Toast.makeText(getActivity(), "还没调接口", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancle() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//信息完善
|
||||
@Override
|
||||
public void uploadAvatar() {
|
||||
|
||||
}
|
||||
|
||||
}).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterCusDetail(CustomerListBean.ResultBean.DataBean item) {
|
||||
//进入回话页
|
||||
ShowAty.ConversationActivity(getActivity());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestData() {
|
||||
new NetApi().customerList(ProfileSpUtils.getInstance().getUserProfie().getData().getUuid(),"").subscribe(new Observer<Response>() {
|
||||
@Override
|
||||
public void onNext(Response response) {
|
||||
String body = (String) response.body();
|
||||
CustomerListBean.ResultBean result = JsonUtils.fromJson(body, CustomerListBean.class).getResult();
|
||||
mSwl.setRefreshing(false);
|
||||
if (result != null && String.valueOf(result.getSuccess()).equals("0")) {
|
||||
|
||||
List<CustomerListBean.ResultBean.DataBean> data = result.getData();
|
||||
if (data.size() == 0) {
|
||||
markingtwoAdapter.setEmptyView(notDataView);
|
||||
return;
|
||||
}
|
||||
if (mNextRequestPage == 1) {
|
||||
setData(true, data);
|
||||
} else {
|
||||
setData(false, data);
|
||||
}
|
||||
} else {
|
||||
setData(true, null);
|
||||
markingtwoAdapter.setEmptyView(notDataView);
|
||||
mSwl.setRefreshing(false);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
e.printStackTrace();
|
||||
markingtwoAdapter.setEmptyView(errorView);
|
||||
mSwl.setRefreshing(false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,10 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.example.administrator.seven.db.DbRecordBeanData;
|
||||
import com.example.administrator.seven.main.find.CloundSolutionActivity;
|
||||
import com.example.administrator.seven.main.find.CommentActivity;
|
||||
import com.example.administrator.seven.main.find.ConversationActivity;
|
||||
import com.example.administrator.seven.main.find.MainActivitytwot;
|
||||
import com.example.administrator.seven.main.kehu.Bean.CustomerListBean;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -50,5 +54,27 @@ public class ShowAty {
|
||||
i.putExtra("customer_id",item.getCustomer_id());
|
||||
ctx.startActivity(i);
|
||||
}
|
||||
public static void CommentActivity(Context ctx,int num) {
|
||||
Intent i = new Intent(ctx, CommentActivity.class);
|
||||
i.putExtra("num",num+"");
|
||||
ctx.startActivity(i);
|
||||
}
|
||||
|
||||
|
||||
public static void ConversationActivity(Context ctx) {
|
||||
Intent i = new Intent(ctx, ConversationActivity.class);
|
||||
ctx.startActivity(i);
|
||||
}
|
||||
|
||||
|
||||
public static void CloundSolutionActivity(Context ctx) {
|
||||
Intent i = new Intent(ctx, CloundSolutionActivity.class);
|
||||
ctx.startActivity(i);
|
||||
}
|
||||
public static void MainActivitytwot(Context ctx) {
|
||||
Intent i = new Intent(ctx, MainActivitytwot.class);
|
||||
ctx.startActivity(i);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.example.administrator.seven.main.Fragment.mvp.contract.MyContract;
|
||||
import com.example.administrator.seven.main.Fragment.mvp.presenter.MyPresenterImpl;
|
||||
import com.example.administrator.seven.main.activity.LoginPasswordActivity;
|
||||
import com.example.administrator.seven.main.activity.Main2Activity;
|
||||
import com.example.administrator.seven.utils.StatusBarUtil;
|
||||
import com.example.administrator.seven.utils.ToolsUtils;
|
||||
import com.example.administrator.seven.utils.checkVersionsUtils.ProfileSpUtils;
|
||||
import com.example.administrator.seven.view.webview.XfiveWebActivity;
|
||||
@@ -60,6 +61,7 @@ public class MyFragment
|
||||
|
||||
@Override
|
||||
protected void initView(View view) {
|
||||
|
||||
mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.SwipeRefreshLayout);
|
||||
mSwipeRefreshLayout.setColorSchemeColors(ContextCompat.getColor(mContext, R.color.colorAccent));
|
||||
//初始化用户资料控件
|
||||
|
||||
@@ -9,7 +9,10 @@ import android.widget.TextView;
|
||||
import com.example.administrator.seven.R;
|
||||
import com.example.administrator.seven.base.BaseFragment;
|
||||
|
||||
public class SendFragment extends BaseFragment {
|
||||
/**
|
||||
* 直播
|
||||
*/
|
||||
public class LivebroFragment extends BaseFragment {
|
||||
|
||||
private View mContentView;
|
||||
private TextView titleTv;
|
||||
@@ -3,9 +3,12 @@ package com.example.administrator.seven.network.http;
|
||||
|
||||
import com.example.administrator.seven.main.entity.LoginBean;
|
||||
import com.example.administrator.seven.main.entity.mine.TreeUserEntity;
|
||||
import com.example.administrator.seven.main.find.entity.QuestionsEntity;
|
||||
import com.example.administrator.seven.main.kehu.Bean.CommitDesignModel;
|
||||
import com.example.administrator.seven.main.kehu.Bean.industryBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
@@ -132,6 +135,19 @@ public class MyApi {
|
||||
, @Field("content") String content);
|
||||
|
||||
|
||||
/**
|
||||
* 答疑解惑
|
||||
* 提交问题
|
||||
*
|
||||
* @param user_id 用户token
|
||||
* @param qu_key 问题关键字
|
||||
* @return
|
||||
*/
|
||||
@POST("robotQA/ask")
|
||||
@FormUrlEncoded
|
||||
Observable<ResponseBean<List<QuestionsEntity>>> ask(@Field("user_id") String user_id
|
||||
, @Field("qu_key") String qu_key);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
package com.example.administrator.seven.utils;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.readystatesoftware.systembartint.SystemBarTintManager;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* Created by XiaoQiang on 2017/6/21.
|
||||
*/
|
||||
public class StatusBarUtil {
|
||||
|
||||
/**
|
||||
* 修改状态栏为全透明
|
||||
* @param activity
|
||||
*/
|
||||
@TargetApi(19)
|
||||
public static void transparencyBar(Activity activity){
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
Window window = activity.getWindow();
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
window.setStatusBarColor(Color.WHITE);
|
||||
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
Window window =activity.getWindow();
|
||||
window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
|
||||
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态栏颜色,支持4.4以上版本
|
||||
* @param activity
|
||||
* @param colorId
|
||||
*/
|
||||
public static void setStatusBarColor(Activity activity,int colorId) {
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
Window window = activity.getWindow();
|
||||
// window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
window.setStatusBarColor(activity.getResources().getColor(colorId));
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
//使用SystemBarTint库使4.4版本状态栏变色,需要先将状态栏设置为透明
|
||||
transparencyBar(activity);
|
||||
SystemBarTintManager tintManager = new SystemBarTintManager(activity);
|
||||
tintManager.setStatusBarTintEnabled(true);
|
||||
tintManager.setStatusBarTintResource(colorId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*状态栏亮色模式,设置状态栏黑色文字、图标,
|
||||
* 适配4.4以上版本MIUIV、Flyme和6.0以上版本其他Android
|
||||
* @param activity
|
||||
* @return 1:MIUUI 2:Flyme 3:android6.0
|
||||
*/
|
||||
public static int StatusBarLightMode(Activity activity){
|
||||
int result=0;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
if(MIUISetStatusBarLightMode(activity, true)){
|
||||
result=1;
|
||||
}else if(FlymeSetStatusBarLightMode(activity.getWindow(), true)){
|
||||
result=2;
|
||||
}else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
activity.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
result=3;
|
||||
}else{
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
Window window = activity.getWindow();
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
window.setStatusBarColor(Color.BLACK);
|
||||
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
Window window =activity.getWindow();
|
||||
window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
|
||||
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 已知系统类型时,设置状态栏黑色文字、图标。
|
||||
* 适配4.4以上版本MIUIV、Flyme和6.0以上版本其他Android
|
||||
* @param activity
|
||||
* @param type 1:MIUUI 2:Flyme 3:android6.0
|
||||
*/
|
||||
public static void StatusBarLightMode(Activity activity,int type){
|
||||
if(type==1){
|
||||
MIUISetStatusBarLightMode(activity, true);
|
||||
}else if(type==2){
|
||||
FlymeSetStatusBarLightMode(activity.getWindow(), true);
|
||||
}else if(type==3){
|
||||
activity.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态栏暗色模式,清除MIUI、flyme或6.0以上版本状态栏黑色文字、图标
|
||||
*/
|
||||
public static void StatusBarDarkMode(Activity activity,int type){
|
||||
if(type==1){
|
||||
MIUISetStatusBarLightMode(activity, false);
|
||||
}else if(type==2){
|
||||
FlymeSetStatusBarLightMode(activity.getWindow(), false);
|
||||
}else if(type==3){
|
||||
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置状态栏图标为深色和魅族特定的文字风格
|
||||
* 可以用来判断是否为Flyme用户
|
||||
* @param window 需要设置的窗口
|
||||
* @param dark 是否把状态栏文字及图标颜色设置为深色
|
||||
* @return boolean 成功执行返回true
|
||||
*
|
||||
*/
|
||||
public static boolean FlymeSetStatusBarLightMode(Window window, boolean dark) {
|
||||
boolean result = false;
|
||||
if (window != null) {
|
||||
try {
|
||||
WindowManager.LayoutParams lp = window.getAttributes();
|
||||
Field darkFlag = WindowManager.LayoutParams.class
|
||||
.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
|
||||
Field meizuFlags = WindowManager.LayoutParams.class
|
||||
.getDeclaredField("meizuFlags");
|
||||
darkFlag.setAccessible(true);
|
||||
meizuFlags.setAccessible(true);
|
||||
int bit = darkFlag.getInt(null);
|
||||
int value = meizuFlags.getInt(lp);
|
||||
if (dark) {
|
||||
value |= bit;
|
||||
} else {
|
||||
value &= ~bit;
|
||||
}
|
||||
meizuFlags.setInt(lp, value);
|
||||
window.setAttributes(lp);
|
||||
result = true;
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 需要MIUIV6以上
|
||||
* @param activity
|
||||
* @param dark 是否把状态栏文字及图标颜色设置为深色
|
||||
* @return boolean 成功执行返回true
|
||||
*
|
||||
*/
|
||||
public static boolean MIUISetStatusBarLightMode(Activity activity, boolean dark) {
|
||||
boolean result = false;
|
||||
Window window=activity.getWindow();
|
||||
if (window != null) {
|
||||
Class clazz = window.getClass();
|
||||
try {
|
||||
int darkModeFlag = 0;
|
||||
Class layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
|
||||
Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
|
||||
darkModeFlag = field.getInt(layoutParams);
|
||||
Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
|
||||
if(dark){
|
||||
extraFlagField.invoke(window,darkModeFlag,darkModeFlag);//状态栏透明且黑色字体
|
||||
}else{
|
||||
extraFlagField.invoke(window, 0, darkModeFlag);//清除黑色字体
|
||||
}
|
||||
result=true;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
//开发版 7.7.13 及以后版本采用了系统API,旧方法无效但不会报错,所以两个方式都要加上
|
||||
if(dark){
|
||||
activity.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN| View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
}else {
|
||||
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.example.administrator.seven.utils;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.os.Build;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.readystatesoftware.systembartint.SystemBarTintManager;
|
||||
|
||||
/**
|
||||
* Created by Administrator on 2016/12/26.
|
||||
* <p>
|
||||
* 作者:xudiwei
|
||||
* <p>
|
||||
* 描述:MIUI 与MEIZI的状态栏字体颜色工具类
|
||||
*/
|
||||
|
||||
public class StatusBarUtils {
|
||||
|
||||
|
||||
public static void setStateBaeColor(Activity ac , int color ){
|
||||
// 4.4及以上版本开启
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
setTranslucentStatus(true , ac);
|
||||
}
|
||||
|
||||
SystemBarTintManager tintManager = new SystemBarTintManager(ac);
|
||||
tintManager.setStatusBarTintEnabled(true);
|
||||
tintManager.setNavigationBarTintEnabled(true);
|
||||
|
||||
// 自定义颜色
|
||||
tintManager.setTintColor(color);
|
||||
}
|
||||
|
||||
|
||||
@TargetApi(19)
|
||||
private static void setTranslucentStatus(boolean on , Activity acc) {
|
||||
Window win = acc.getWindow();
|
||||
WindowManager.LayoutParams winParams = win.getAttributes();
|
||||
final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
|
||||
if (on) {
|
||||
winParams.flags |= bits;
|
||||
} else {
|
||||
winParams.flags &= ~bits;
|
||||
}
|
||||
win.setAttributes(winParams);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.example.administrator.seven.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.EditText;
|
||||
|
||||
/**
|
||||
* Created by: xudiwei
|
||||
* <p>
|
||||
* on: 2017/4/21.
|
||||
* <p>
|
||||
* 描述:
|
||||
*/
|
||||
|
||||
public class PastEditText extends EditText {
|
||||
|
||||
private static final String TAG = "PastEditText";
|
||||
|
||||
public PastEditText(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public PastEditText(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public PastEditText(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTextContextMenuItem(int id) {
|
||||
|
||||
// if (id == android.R.id.paste) {
|
||||
// ClipboardManager clipboardManager = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
// CharSequence text = clipboardManager.getText();
|
||||
// Log.d(TAG, "paste: " + text);
|
||||
// SpannableString spannableString = EmojUtils.stringTransSpannable(getContext(), text.toString());
|
||||
// this.append(spannableString);
|
||||
// return true;
|
||||
// }
|
||||
return super.onTextContextMenuItem(id);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@color/colorPressGreen">
|
||||
android:color="@color/colortheme">
|
||||
<item
|
||||
android:id="@android:id/mask">
|
||||
<shape
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/colorPressGreen"/>
|
||||
<solid android:color="@color/colortheme"/>
|
||||
<corners android:radius="5dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
@@ -15,7 +15,7 @@
|
||||
<item android:state_enabled="false">
|
||||
<shape
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/colorGreenLight"/>
|
||||
<solid android:color="@color/colortheme"/>
|
||||
<corners android:radius="5dp"/>
|
||||
|
||||
</shape>
|
||||
@@ -23,7 +23,7 @@
|
||||
<item android:state_enabled="true">
|
||||
<shape
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/colorGreen"/>
|
||||
<solid android:color="@color/colortheme"/>
|
||||
<corners android:radius="5dp"/>
|
||||
|
||||
</shape>
|
||||
|
||||
BIN
app/src/main/res/drawable-xhdpi/chat_left_bg.9.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable-xhdpi/chat_left_qp.9.png
Normal file
|
After Width: | Height: | Size: 488 B |
BIN
app/src/main/res/drawable-xhdpi/chat_right_bg.9.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable-xhdpi/chat_right_qp.9.png
Normal file
|
After Width: | Height: | Size: 567 B |
9
app/src/main/res/drawable/drawable_edit_normal.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<solid android:color="@color/colorWhite" />
|
||||
<stroke
|
||||
android:width="0.5dip"
|
||||
android:color="#dadada" />
|
||||
<corners android:radius="1dp"/>
|
||||
</shape>
|
||||
46
app/src/main/res/layout/activity_clound_solution.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="#fff5f5f5">
|
||||
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_location"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginTop="25dp"
|
||||
android:visibility="visible"
|
||||
android:layout_marginLeft="15dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@mipmap/fangan_location"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/chengshi"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="北京"
|
||||
android:textColor="#333333"
|
||||
android:textSize="16sp"
|
||||
android:layout_marginLeft="4dp"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:src="@mipmap/icon_down"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
19
app/src/main/res/layout/activity_comment.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.example.administrator.seven.widget.TitleBar
|
||||
android:id="@+id/title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/title_bar">
|
||||
|
||||
</FrameLayout>
|
||||
</RelativeLayout>
|
||||
19
app/src/main/res/layout/activity_conversation.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.example.administrator.seven.widget.TitleBar
|
||||
android:id="@+id/title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/title_bar">
|
||||
|
||||
</FrameLayout>
|
||||
</RelativeLayout>
|
||||
@@ -174,6 +174,7 @@
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_find"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
|
||||
58
app/src/main/res/layout/activity_mainsss.xml
Normal file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_current"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="72dp"
|
||||
android:gravity="center"
|
||||
android:text="当前城市:杭州"
|
||||
android:textSize="18sp"/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cb_hot"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:text="指定热门城市"
|
||||
android:textSize="16sp"/>
|
||||
<CheckBox
|
||||
android:id="@+id/cb_enable_anim"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:text="启用动画效果"
|
||||
android:textSize="16sp"/>
|
||||
<CheckBox
|
||||
android:id="@+id/cb_anim"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:text="自定义动画"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="点击更换:"/>
|
||||
<Button
|
||||
android:id="@+id/btn_style"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:paddingLeft="32dp"
|
||||
android:paddingRight="32dp"
|
||||
android:text="默认主题"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_pick"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:background="@color/colorPrimary"
|
||||
android:text="选择城市"
|
||||
android:textSize="16sp"
|
||||
android:textColor="@android:color/white"/>
|
||||
</LinearLayout>
|
||||
107
app/src/main/res/layout/criclefragment.xml
Normal file
@@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/dianpubuju"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/titlebar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:background="@color/colorWhite">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/marking_fragment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:drawableRight="@mipmap/marking_down_pic"
|
||||
android:drawablePadding="6dp"
|
||||
android:text="全国"
|
||||
android:textColor="#ff333333"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/marking_fragment_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:drawableRight="@mipmap/marking_down_pic"
|
||||
android:drawablePadding="6dp"
|
||||
android:text="家居"
|
||||
android:textColor="#ff333333"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_privateletter"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginRight="18dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/message_ivtwo"
|
||||
android:layout_width="21dp"
|
||||
android:layout_height="21dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:src="@mipmap/icon_watch_k" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/message_num_rltwo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="-5dp"
|
||||
android:layout_marginTop="13dp"
|
||||
android:layout_toRightOf="@id/message_ivtwo">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/left_tvtwo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:background="@mipmap/message_remind"
|
||||
android:gravity="center"
|
||||
android:text="0"
|
||||
android:textColor="@color/colorWhite"
|
||||
android:textSize="10sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/titlebar">
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dianyuanbuju"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/news_title_fragment"
|
||||
android:name="com.example.administrator.seven.main.find.PriLetFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
64
app/src/main/res/layout/findfragment.xml
Normal file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/titlebar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:background="@color/colorWhite">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/marking_fragment_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:drawablePadding="6dp"
|
||||
android:text="私信"
|
||||
android:textColor="#ff333333"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_live"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="18dp"
|
||||
android:layout_centerVertical="true">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/message_ivtwo"
|
||||
android:layout_width="21dp"
|
||||
android:layout_height="21dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:src="@mipmap/icon_live" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/message_num_rltwo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="-5dp"
|
||||
android:layout_marginTop="13dp"
|
||||
android:layout_toRightOf="@id/message_ivtwo">
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/containerr"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/titlebar">
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
120
app/src/main/res/layout/findlist_item.xml
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
|
||||
<RelativeLayout android:layout_width="match_parent"
|
||||
android:layout_height="99dp"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_cus_01"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="24dp">
|
||||
<TextView
|
||||
android:id="@+id/tv_cus_01"
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="12dp"
|
||||
android:layout_marginLeft="10.5dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="@mipmap/icon_cus_new"
|
||||
/>
|
||||
<TextView
|
||||
android:layout_toRightOf="@+id/tv_cus_01"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="17dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="多喜爱家纺磨毛小猪佩奇...(云拼团)"
|
||||
android:layout_centerVertical="true"
|
||||
android:textColor="#ffababab"
|
||||
android:textSize="13sp"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_below="@+id/rl_cus_01"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/yichengjhiao_rv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:background="@color/colorWhite">
|
||||
|
||||
|
||||
|
||||
<com.example.administrator.seven.widget.CircleImageView
|
||||
android:id="@+id/iv_dea_avatar"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:src="@mipmap/icon_default_head"
|
||||
app:border_color="#70ffffff" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_dea_name"
|
||||
android:layout_width="59dp"
|
||||
android:layout_height="21dp"
|
||||
android:layout_marginLeft="13.5dp"
|
||||
android:layout_marginTop="19.5dp"
|
||||
android:layout_toRightOf="@+id/iv_dea_avatar"
|
||||
android:text="欧阳子文"
|
||||
android:textColor="#ff333333"
|
||||
android:textSize="15sp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_dea_phone"
|
||||
android:layout_width="67dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_marginTop="19.5dp"
|
||||
android:layout_toRightOf="@+id/tv_dea_name"
|
||||
android:text="18971614151"
|
||||
android:textColor="#ff333333"
|
||||
android:textSize="12sp"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ima_dea_watch"
|
||||
android:layout_width="16.5dp"
|
||||
android:layout_toRightOf="@+id/iv_dea_avatar"
|
||||
android:layout_marginLeft="13.5dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_below="@+id/tv_dea_name"
|
||||
android:background="@mipmap/ic_launcher"
|
||||
android:layout_height="16.5dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_dea_watch"
|
||||
android:layout_width="67dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_toRightOf="@+id/ima_dea_watch"
|
||||
android:layout_marginLeft="13.5dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_below="@+id/tv_dea_name"
|
||||
android:textColor="#ff333333"
|
||||
android:textSize="12sp"
|
||||
android:text="--"
|
||||
/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_cuslist_caozuo"
|
||||
android:layout_width="43dp"
|
||||
android:layout_height="25dp"
|
||||
android:text="操作"
|
||||
android:gravity="center"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="22dp"
|
||||
android:textColor="#ff333333"
|
||||
android:background="@drawable/share_tv_cus"
|
||||
android:textSize="11sp"
|
||||
/>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dimen_2dp"
|
||||
android:background="#F5F5F5"
|
||||
/>
|
||||
</RelativeLayout>
|
||||
7
app/src/main/res/layout/findtwo_activity.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".FindtwoActivity" />
|
||||
20
app/src/main/res/layout/findtwo_fragment.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/findtwo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.findtwo.FindtwoFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/message"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="FindtwoFragment"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
54
app/src/main/res/layout/fragment_questions.xml
Normal file
@@ -0,0 +1,54 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context="com.example.administrator.seven.main.find.QuestionsFragment">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rcv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:background="@color/bg_gray"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="45dp"
|
||||
android:background="@color/colorWhile"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.example.administrator.seven.widget.PastEditText
|
||||
android:id="@+id/et_msg"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginLeft="13dp"
|
||||
android:layout_weight="1.0"
|
||||
android:background="@drawable/drawable_edit_normal"
|
||||
android:gravity="left|center"
|
||||
android:hint="请输入新消息"
|
||||
android:imeOptions="flagNoExtractUi"
|
||||
android:lineSpacingExtra="3dp"
|
||||
android:maxHeight="100dp"
|
||||
android:minHeight="40dp"
|
||||
android:padding="5dp"
|
||||
android:textColor="#1e1e1e"
|
||||
android:textColorHint="#b4b4b4"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_send"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="36dp"
|
||||
android:layout_margin="10dp"
|
||||
android:background="@drawable/selector_btn_green_bg"
|
||||
android:text="发 送"
|
||||
android:textColor="@color/colorWhile"
|
||||
android:textSize="13sp"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
48
app/src/main/res/layout/item_question_left.xml
Normal file
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="13dp">
|
||||
|
||||
<com.example.administrator.seven.widget.CircleImageView
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
android:src="@mipmap/icon_default_head"/>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/chat_left_bg"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingTop="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center|left"
|
||||
android:maxWidth="220dp"
|
||||
android:minHeight="40dp"
|
||||
android:textColor="@color/colorBlack"
|
||||
android:textSize="16sp"
|
||||
tools:text="我是一个什么的我是一个什么的我个什么么的我是一个什么的"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/view_content_fl"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/view_content_ll"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
34
app/src/main/res/layout/item_question_right.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right"
|
||||
android:orientation="horizontal"
|
||||
android:padding="13dp">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/tv_nickname"
|
||||
android:layout_toRightOf="@id/iv_avatar"
|
||||
android:background="@drawable/chat_right_bg"
|
||||
android:gravity="center|left"
|
||||
android:maxWidth="220dp"
|
||||
android:minHeight="40dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="15dp"
|
||||
android:paddingTop="10dp"
|
||||
android:textColor="@color/colorWhile"
|
||||
android:textSize="16sp"
|
||||
tools:text="我是一个什么的我是一个什么的我个什么么的我是一个什么的"/>
|
||||
|
||||
<com.example.administrator.seven.widget.CircleImageView
|
||||
android:id="@+id/iv_icon"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
android:src="@mipmap/icon_default_head"/>
|
||||
</LinearLayout>
|
||||
12
app/src/main/res/layout/item_rcv_empty.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:src="@mipmap/icon_nodata"/>
|
||||
</FrameLayout>
|
||||
56
app/src/main/res/layout/item_rcv_load_and_all.xml
Normal file
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/view_loading"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:background="@color/colorWhite"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ProgressBar
|
||||
style="@android:style/Widget.DeviceDefault.Light.ProgressBar.Small.Inverse"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="13dp"
|
||||
android:text="正在加载更多..."
|
||||
android:textColor="@color/colorText"
|
||||
android:textSize="14sp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/view_load_all"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:visibility="gone"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<View
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="0.1dp"
|
||||
android:background="@color/colorText"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="13dp"
|
||||
android:layout_marginRight="13dp"
|
||||
android:text="扯到我底线了"
|
||||
android:textColor="@color/colorText"
|
||||
android:textSize="14sp"/>
|
||||
|
||||
<View
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="0.1dp"
|
||||
android:background="@color/colorText"/>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
78
app/src/main/res/layout/priletfragment.xml
Normal file
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/titlebar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:background="@color/colorWhite">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/marking_fragment_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:drawablePadding="6dp"
|
||||
android:text="私信"
|
||||
android:textColor="#ff333333"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_live"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="18dp"
|
||||
android:layout_centerVertical="true">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/message_ivtwo"
|
||||
android:layout_width="21dp"
|
||||
android:layout_height="21dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:src="@mipmap/icon_watch_k" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/message_num_rltwo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="-5dp"
|
||||
android:layout_marginTop="13dp"
|
||||
android:layout_toRightOf="@id/message_ivtwo">
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/titlebar">
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dianyuanbuju"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/news_title_fragment"
|
||||
android:name="com.example.administrator.seven.main.find.PriLetFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
120
app/src/main/res/layout/private_let_item.xml
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
|
||||
<RelativeLayout android:layout_width="match_parent"
|
||||
android:layout_height="99dp"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_cus_01"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="24dp">
|
||||
<TextView
|
||||
android:id="@+id/tv_cus_01"
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="12dp"
|
||||
android:layout_marginLeft="10.5dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="@mipmap/icon_cus_new"
|
||||
/>
|
||||
<TextView
|
||||
android:layout_toRightOf="@+id/tv_cus_01"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="17dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="多喜爱家纺磨毛小猪佩奇...(云拼团)"
|
||||
android:layout_centerVertical="true"
|
||||
android:textColor="#ffababab"
|
||||
android:textSize="13sp"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_below="@+id/rl_cus_01"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/yichengjhiao_rv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:background="@color/colorWhite">
|
||||
|
||||
|
||||
|
||||
<com.example.administrator.seven.widget.CircleImageView
|
||||
android:id="@+id/iv_dea_avatar"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:src="@mipmap/icon_default_head"
|
||||
app:border_color="#70ffffff" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_dea_name"
|
||||
android:layout_width="59dp"
|
||||
android:layout_height="21dp"
|
||||
android:layout_marginLeft="13.5dp"
|
||||
android:layout_marginTop="19.5dp"
|
||||
android:layout_toRightOf="@+id/iv_dea_avatar"
|
||||
android:text="欧阳子文"
|
||||
android:textColor="#ff333333"
|
||||
android:textSize="15sp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_dea_phone"
|
||||
android:layout_width="67dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_marginTop="19.5dp"
|
||||
android:layout_toRightOf="@+id/tv_dea_name"
|
||||
android:text="18971614151"
|
||||
android:textColor="#ff333333"
|
||||
android:textSize="12sp"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ima_dea_watch"
|
||||
android:layout_width="16.5dp"
|
||||
android:layout_toRightOf="@+id/iv_dea_avatar"
|
||||
android:layout_marginLeft="13.5dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_below="@+id/tv_dea_name"
|
||||
android:background="@mipmap/ic_launcher"
|
||||
android:layout_height="16.5dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_dea_watch"
|
||||
android:layout_width="67dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_toRightOf="@+id/ima_dea_watch"
|
||||
android:layout_marginLeft="13.5dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_below="@+id/tv_dea_name"
|
||||
android:textColor="#ff333333"
|
||||
android:textSize="12sp"
|
||||
android:text="--"
|
||||
/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_cuslist_caozuo"
|
||||
android:layout_width="43dp"
|
||||
android:layout_height="25dp"
|
||||
android:text="操作"
|
||||
android:gravity="center"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="22dp"
|
||||
android:textColor="#ff333333"
|
||||
android:background="@drawable/share_tv_cus"
|
||||
android:textSize="11sp"
|
||||
/>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dimen_2dp"
|
||||
android:background="#F5F5F5"
|
||||
/>
|
||||
</RelativeLayout>
|
||||
BIN
app/src/main/res/mipmap-hdpi/icon_live.png
Normal file
|
After Width: | Height: | Size: 789 B |
BIN
app/src/main/res/mipmap-hdpi/icon_watch_k.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/main/res/mipmap-hdpi/marking_down_pic.png
Normal file
|
After Width: | Height: | Size: 305 B |
BIN
app/src/main/res/mipmap-mdpi/icon_live.png
Normal file
|
After Width: | Height: | Size: 574 B |
BIN
app/src/main/res/mipmap-mdpi/icon_watch_k.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/mipmap-mdpi/marking_down_pic.png
Normal file
|
After Width: | Height: | Size: 194 B |
BIN
app/src/main/res/mipmap-xhdpi/icon_live.png
Normal file
|
After Width: | Height: | Size: 778 B |
BIN
app/src/main/res/mipmap-xhdpi/icon_watch_k.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
app/src/main/res/mipmap-xhdpi/marking_down_pic.png
Normal file
|
After Width: | Height: | Size: 314 B |
BIN
app/src/main/res/mipmap-xxhdpi/fangan_location.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/icon_live.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/icon_watch_k.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/marking_down_pic.png
Normal file
|
After Width: | Height: | Size: 536 B |
BIN
app/src/main/res/mipmap-xxhdpi/message_remind.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/icon_live.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/icon_watch_k.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/marking_down_pic.png
Normal file
|
After Width: | Height: | Size: 626 B |
@@ -37,6 +37,8 @@
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
<!--<style name="SplashTheme" parent="Theme.AppCompat.Light.DarkActionBar">-->
|
||||
<!--<!– Customize your theme here. –>-->
|
||||
<!--<item name="android:windowIsTranslucent">true</item>-->
|
||||
|
||||
@@ -8,7 +8,7 @@ buildscript {
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
|
||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1
citypicker/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
34
citypicker/build.gradle
Normal file
@@ -0,0 +1,34 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.github.dcendents.android-maven'
|
||||
group='com.github.zaaach'
|
||||
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
buildToolsVersion "28.0.3"
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 27
|
||||
versionCode 7
|
||||
versionName "2.0.3"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
testImplementation 'junit:junit:4.12'
|
||||
compileOnly 'androidx.appcompat:appcompat:1.0.0'
|
||||
compileOnly 'androidx.recyclerview:recyclerview:1.0.0'
|
||||
api 'com.google.android.material:material:1.0.0'
|
||||
}
|
||||
17
citypicker/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in F:\Android\sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.zaaach.citypicker;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumentation test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() throws Exception {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
assertEquals("com.zaaach.citypicker.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
11
citypicker/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.zaaach.citypicker">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true">
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
BIN
citypicker/src/main/assets/china_cities_v2.db
Normal file
132
citypicker/src/main/java/com/zaaach/citypicker/CityPicker.java
Normal file
@@ -0,0 +1,132 @@
|
||||
package com.zaaach.citypicker;
|
||||
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.zaaach.citypicker.adapter.OnPickListener;
|
||||
import com.zaaach.citypicker.model.HotCity;
|
||||
import com.zaaach.citypicker.model.LocateState;
|
||||
import com.zaaach.citypicker.model.LocatedCity;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: Bro0cL
|
||||
* @Date: 2018/2/6 17:52
|
||||
*/
|
||||
public class CityPicker {
|
||||
private static final String TAG = "CityPicker";
|
||||
|
||||
private WeakReference<FragmentActivity> mContext;
|
||||
private WeakReference<Fragment> mFragment;
|
||||
private WeakReference<FragmentManager> mFragmentManager;
|
||||
|
||||
private boolean enableAnim;
|
||||
private int mAnimStyle;
|
||||
private LocatedCity mLocation;
|
||||
private List<HotCity> mHotCities;
|
||||
private OnPickListener mOnPickListener;
|
||||
|
||||
private CityPicker(){}
|
||||
|
||||
private CityPicker(Fragment fragment){
|
||||
this(fragment.getActivity(), fragment);
|
||||
mFragmentManager = new WeakReference<>(fragment.getChildFragmentManager());
|
||||
}
|
||||
|
||||
private CityPicker(FragmentActivity activity){
|
||||
this(activity, null);
|
||||
mFragmentManager = new WeakReference<>(activity.getSupportFragmentManager());
|
||||
}
|
||||
|
||||
private CityPicker(FragmentActivity activity, Fragment fragment){
|
||||
mContext = new WeakReference<>(activity);
|
||||
mFragment = new WeakReference<>(fragment);
|
||||
}
|
||||
|
||||
public static CityPicker from(Fragment fragment){
|
||||
return new CityPicker(fragment);
|
||||
}
|
||||
|
||||
public static CityPicker from(FragmentActivity activity){
|
||||
return new CityPicker(activity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置动画效果
|
||||
* @param animStyle
|
||||
* @return
|
||||
*/
|
||||
public CityPicker setAnimationStyle(@StyleRes int animStyle) {
|
||||
this.mAnimStyle = animStyle;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前已经定位的城市
|
||||
* @param location
|
||||
* @return
|
||||
*/
|
||||
public CityPicker setLocatedCity(LocatedCity location) {
|
||||
this.mLocation = location;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CityPicker setHotCities(List<HotCity> data){
|
||||
this.mHotCities = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用动画效果,默认为false
|
||||
* @param enable
|
||||
* @return
|
||||
*/
|
||||
public CityPicker enableAnimation(boolean enable){
|
||||
this.enableAnim = enable;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置选择结果的监听器
|
||||
* @param listener
|
||||
* @return
|
||||
*/
|
||||
public CityPicker setOnPickListener(OnPickListener listener){
|
||||
this.mOnPickListener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void show(){
|
||||
FragmentTransaction ft = mFragmentManager.get().beginTransaction();
|
||||
final Fragment prev = mFragmentManager.get().findFragmentByTag(TAG);
|
||||
if (prev != null){
|
||||
ft.remove(prev).commit();
|
||||
ft = mFragmentManager.get().beginTransaction();
|
||||
}
|
||||
ft.addToBackStack(null);
|
||||
final CityPickerDialogFragment cityPickerFragment =
|
||||
CityPickerDialogFragment.newInstance(enableAnim);
|
||||
cityPickerFragment.setLocatedCity(mLocation);
|
||||
cityPickerFragment.setHotCities(mHotCities);
|
||||
cityPickerFragment.setAnimationStyle(mAnimStyle);
|
||||
cityPickerFragment.setOnPickListener(mOnPickListener);
|
||||
cityPickerFragment.show(ft, TAG);
|
||||
}
|
||||
|
||||
/**
|
||||
* 定位完成
|
||||
* @param location
|
||||
* @param state
|
||||
*/
|
||||
public void locateComplete(LocatedCity location, @LocateState.State int state){
|
||||
CityPickerDialogFragment fragment = (CityPickerDialogFragment) mFragmentManager.get().findFragmentByTag(TAG);
|
||||
if (fragment != null){
|
||||
fragment.locationChanged(location, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
package com.zaaach.citypicker;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.zaaach.citypicker.adapter.CityListAdapter;
|
||||
import com.zaaach.citypicker.adapter.InnerListener;
|
||||
import com.zaaach.citypicker.adapter.OnPickListener;
|
||||
import com.zaaach.citypicker.adapter.decoration.DividerItemDecoration;
|
||||
import com.zaaach.citypicker.adapter.decoration.SectionItemDecoration;
|
||||
import com.zaaach.citypicker.db.DBManager;
|
||||
import com.zaaach.citypicker.model.City;
|
||||
import com.zaaach.citypicker.model.HotCity;
|
||||
import com.zaaach.citypicker.model.LocateState;
|
||||
import com.zaaach.citypicker.model.LocatedCity;
|
||||
import com.zaaach.citypicker.util.ScreenUtil;
|
||||
import com.zaaach.citypicker.view.SideIndexBar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: Bro0cL
|
||||
* @Date: 2018/2/6 20:50
|
||||
*/
|
||||
public class CityPickerDialogFragment extends DialogFragment implements TextWatcher,
|
||||
View.OnClickListener, SideIndexBar.OnIndexTouchedChangedListener, InnerListener {
|
||||
private View mContentView;
|
||||
private RecyclerView mRecyclerView;
|
||||
private View mEmptyView;
|
||||
private TextView mOverlayTextView;
|
||||
private SideIndexBar mIndexBar;
|
||||
private EditText mSearchBox;
|
||||
private TextView mCancelBtn;
|
||||
private ImageView mClearAllBtn;
|
||||
|
||||
private LinearLayoutManager mLayoutManager;
|
||||
private CityListAdapter mAdapter;
|
||||
private List<City> mAllCities;
|
||||
private List<HotCity> mHotCities;
|
||||
private List<City> mResults;
|
||||
|
||||
private DBManager dbManager;
|
||||
|
||||
private int height;
|
||||
private int width;
|
||||
|
||||
private boolean enableAnim = false;
|
||||
private int mAnimStyle = R.style.DefaultCityPickerAnimation;
|
||||
private LocatedCity mLocatedCity;
|
||||
private int locateState;
|
||||
private OnPickListener mOnPickListener;
|
||||
|
||||
/**
|
||||
* 获取实例
|
||||
* @param enable 是否启用动画效果
|
||||
* @return
|
||||
*/
|
||||
public static CityPickerDialogFragment newInstance(boolean enable){
|
||||
final CityPickerDialogFragment fragment = new CityPickerDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("cp_enable_anim", enable);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setStyle(STYLE_NORMAL, R.style.CityPickerStyle);
|
||||
}
|
||||
|
||||
public void setLocatedCity(LocatedCity location){
|
||||
mLocatedCity = location;
|
||||
}
|
||||
|
||||
public void setHotCities(List<HotCity> data){
|
||||
if (data != null && !data.isEmpty()){
|
||||
this.mHotCities = data;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("ResourceType")
|
||||
public void setAnimationStyle(@StyleRes int resId){
|
||||
this.mAnimStyle = resId <= 0 ? mAnimStyle : resId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
mContentView = inflater.inflate(R.layout.cp_dialog_city_picker, container, false);
|
||||
return mContentView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
initData();
|
||||
initViews();
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
mRecyclerView = mContentView.findViewById(R.id.cp_city_recyclerview);
|
||||
mLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
|
||||
mRecyclerView.setLayoutManager(mLayoutManager);
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.addItemDecoration(new SectionItemDecoration(getActivity(), mAllCities), 0);
|
||||
mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity()), 1);
|
||||
mAdapter = new CityListAdapter(getActivity(), mAllCities, mHotCities, locateState);
|
||||
mAdapter.autoLocate(true);
|
||||
mAdapter.setInnerListener(this);
|
||||
mAdapter.setLayoutManager(mLayoutManager);
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
||||
//确保定位城市能正常刷新
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE){
|
||||
mAdapter.refreshLocationItem();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||
}
|
||||
});
|
||||
|
||||
mEmptyView = mContentView.findViewById(R.id.cp_empty_view);
|
||||
mOverlayTextView = mContentView.findViewById(R.id.cp_overlay);
|
||||
|
||||
mIndexBar = mContentView.findViewById(R.id.cp_side_index_bar);
|
||||
mIndexBar.setNavigationBarHeight(ScreenUtil.getNavigationBarHeight(getActivity()));
|
||||
mIndexBar.setOverlayTextView(mOverlayTextView)
|
||||
.setOnIndexChangedListener(this);
|
||||
|
||||
mSearchBox = mContentView.findViewById(R.id.cp_search_box);
|
||||
mSearchBox.addTextChangedListener(this);
|
||||
|
||||
mCancelBtn = mContentView.findViewById(R.id.cp_cancel);
|
||||
mClearAllBtn = mContentView.findViewById(R.id.cp_clear_all);
|
||||
mCancelBtn.setOnClickListener(this);
|
||||
mClearAllBtn.setOnClickListener(this);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
Bundle args = getArguments();
|
||||
if (args != null) {
|
||||
enableAnim = args.getBoolean("cp_enable_anim");
|
||||
}
|
||||
//初始化热门城市
|
||||
if (mHotCities == null || mHotCities.isEmpty()) {
|
||||
mHotCities = new ArrayList<>();
|
||||
mHotCities.add(new HotCity("北京", "北京", "101010100"));
|
||||
mHotCities.add(new HotCity("上海", "上海", "101020100"));
|
||||
mHotCities.add(new HotCity("广州", "广东", "101280101"));
|
||||
mHotCities.add(new HotCity("深圳", "广东", "101280601"));
|
||||
mHotCities.add(new HotCity("天津", "天津", "101030100"));
|
||||
mHotCities.add(new HotCity("杭州", "浙江", "101210101"));
|
||||
mHotCities.add(new HotCity("南京", "江苏", "101190101"));
|
||||
mHotCities.add(new HotCity("成都", "四川", "101270101"));
|
||||
mHotCities.add(new HotCity("武汉", "湖北", "101200101"));
|
||||
}
|
||||
//初始化定位城市,默认为空时会自动回调定位
|
||||
if (mLocatedCity == null){
|
||||
mLocatedCity = new LocatedCity(getString(R.string.cp_locating), "未知", "0");
|
||||
locateState = LocateState.LOCATING;
|
||||
}else{
|
||||
locateState = LocateState.SUCCESS;
|
||||
}
|
||||
|
||||
dbManager = new DBManager(getActivity());
|
||||
mAllCities = dbManager.getAllCities();
|
||||
mAllCities.add(0, mLocatedCity);
|
||||
mAllCities.add(1, new HotCity("热门城市", "未知", "0"));
|
||||
mResults = mAllCities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Dialog dialog = getDialog();
|
||||
dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK){
|
||||
if (mOnPickListener != null){
|
||||
mOnPickListener.onCancel();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
measure();
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
window.setLayout(width, height - ScreenUtil.getStatusBarHeight(getActivity()));
|
||||
if (enableAnim) {
|
||||
window.setWindowAnimations(mAnimStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//测量宽高
|
||||
private void measure() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
getActivity().getWindowManager().getDefaultDisplay().getRealMetrics(dm);
|
||||
height = dm.heightPixels;
|
||||
width = dm.widthPixels;
|
||||
}else{
|
||||
DisplayMetrics dm = getResources().getDisplayMetrics();
|
||||
height = dm.heightPixels;
|
||||
width = dm.widthPixels;
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索框监听 */
|
||||
@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 keyword = s.toString();
|
||||
if (TextUtils.isEmpty(keyword)){
|
||||
mClearAllBtn.setVisibility(View.GONE);
|
||||
mEmptyView.setVisibility(View.GONE);
|
||||
mResults = mAllCities;
|
||||
((SectionItemDecoration)(mRecyclerView.getItemDecorationAt(0))).setData(mResults);
|
||||
mAdapter.updateData(mResults);
|
||||
}else {
|
||||
mClearAllBtn.setVisibility(View.VISIBLE);
|
||||
//开始数据库查找
|
||||
mResults = dbManager.searchCity(keyword);
|
||||
((SectionItemDecoration)(mRecyclerView.getItemDecorationAt(0))).setData(mResults);
|
||||
if (mResults == null || mResults.isEmpty()){
|
||||
mEmptyView.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
mEmptyView.setVisibility(View.GONE);
|
||||
mAdapter.updateData(mResults);
|
||||
}
|
||||
}
|
||||
mRecyclerView.scrollToPosition(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
if (id == R.id.cp_cancel) {
|
||||
dismiss();
|
||||
if (mOnPickListener != null){
|
||||
mOnPickListener.onCancel();
|
||||
}
|
||||
}else if(id == R.id.cp_clear_all){
|
||||
mSearchBox.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onIndexChanged(String index, int position) {
|
||||
//滚动RecyclerView到索引位置
|
||||
mAdapter.scrollToSection(index);
|
||||
}
|
||||
|
||||
public void locationChanged(LocatedCity location, int state){
|
||||
mAdapter.updateLocateState(location, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss(int position, City data) {
|
||||
dismiss();
|
||||
if (mOnPickListener != null){
|
||||
mOnPickListener.onPick(position, data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void locate(){
|
||||
if (mOnPickListener != null){
|
||||
mOnPickListener.onLocate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnPickListener(OnPickListener listener){
|
||||
this.mOnPickListener = listener;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
package com.zaaach.citypicker.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.zaaach.citypicker.R;
|
||||
import com.zaaach.citypicker.adapter.decoration.GridItemDecoration;
|
||||
import com.zaaach.citypicker.model.City;
|
||||
import com.zaaach.citypicker.model.HotCity;
|
||||
import com.zaaach.citypicker.model.LocateState;
|
||||
import com.zaaach.citypicker.model.LocatedCity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: Bro0cL
|
||||
* @Date: 2018/2/5 12:06
|
||||
*/
|
||||
public class CityListAdapter extends RecyclerView.Adapter<CityListAdapter.BaseViewHolder> {
|
||||
private static final int VIEW_TYPE_LOCATION = 10;
|
||||
private static final int VIEW_TYPE_HOT = 11;
|
||||
|
||||
private Context mContext;
|
||||
private List<City> mData;
|
||||
private List<HotCity> mHotData;
|
||||
private int locateState;
|
||||
private InnerListener mInnerListener;
|
||||
private LinearLayoutManager mLayoutManager;
|
||||
private boolean stateChanged;
|
||||
private boolean autoLocate;
|
||||
|
||||
public CityListAdapter(Context context, List<City> data, List<HotCity> hotData, int state) {
|
||||
this.mData = data;
|
||||
this.mContext = context;
|
||||
this.mHotData = hotData;
|
||||
this.locateState = state;
|
||||
}
|
||||
|
||||
public void autoLocate(boolean auto){
|
||||
autoLocate = auto;
|
||||
}
|
||||
|
||||
public void setLayoutManager(LinearLayoutManager manager){
|
||||
this.mLayoutManager = manager;
|
||||
}
|
||||
|
||||
public void updateData(List<City> data){
|
||||
this.mData = data;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void updateLocateState(LocatedCity location, int state){
|
||||
mData.remove(0);
|
||||
mData.add(0, location);
|
||||
stateChanged = !(locateState == state);
|
||||
locateState = state;
|
||||
refreshLocationItem();
|
||||
}
|
||||
|
||||
public void refreshLocationItem(){
|
||||
//如果定位城市的item可见则进行刷新
|
||||
if (stateChanged && mLayoutManager.findFirstVisibleItemPosition() == 0) {
|
||||
stateChanged = false;
|
||||
notifyItemChanged(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 滚动RecyclerView到索引位置
|
||||
* @param index
|
||||
*/
|
||||
public void scrollToSection(String index){
|
||||
if (mData == null || mData.isEmpty()) return;
|
||||
if (TextUtils.isEmpty(index)) return;
|
||||
int size = mData.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (TextUtils.equals(index.substring(0, 1), mData.get(i).getSection().substring(0, 1))){
|
||||
if (mLayoutManager != null){
|
||||
mLayoutManager.scrollToPositionWithOffset(i, 0);
|
||||
if (TextUtils.equals(index.substring(0, 1), "定")) {
|
||||
//防止滚动时进行刷新
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (stateChanged) notifyItemChanged(0);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public BaseViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view;
|
||||
switch (viewType){
|
||||
case VIEW_TYPE_LOCATION:
|
||||
view = LayoutInflater.from(mContext).inflate(R.layout.cp_list_item_location_layout, parent, false);
|
||||
return new LocationViewHolder(view);
|
||||
case VIEW_TYPE_HOT:
|
||||
view = LayoutInflater.from(mContext).inflate(R.layout.cp_list_item_hot_layout, parent, false);
|
||||
return new HotViewHolder(view);
|
||||
default:
|
||||
view = LayoutInflater.from(mContext).inflate(R.layout.cp_list_item_default_layout, parent, false);
|
||||
return new DefaultViewHolder(view);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull BaseViewHolder holder, int position) {
|
||||
if (holder instanceof DefaultViewHolder){
|
||||
final int pos = holder.getAdapterPosition();
|
||||
final City data = mData.get(pos);
|
||||
if (data == null) return;
|
||||
((DefaultViewHolder)holder).name.setText(data.getName());
|
||||
((DefaultViewHolder) holder).name.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mInnerListener != null){
|
||||
mInnerListener.dismiss(pos, data);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
//定位城市
|
||||
if (holder instanceof LocationViewHolder){
|
||||
final int pos = holder.getAdapterPosition();
|
||||
final City data = mData.get(pos);
|
||||
if (data == null) return;
|
||||
//设置宽高
|
||||
DisplayMetrics dm = mContext.getResources().getDisplayMetrics();
|
||||
int screenWidth = dm.widthPixels;
|
||||
TypedValue typedValue = new TypedValue();
|
||||
mContext.getTheme().resolveAttribute(R.attr.cpGridItemSpace, typedValue, true);
|
||||
int space = mContext.getResources().getDimensionPixelSize(R.dimen.cp_grid_item_space);
|
||||
int padding = mContext.getResources().getDimensionPixelSize(R.dimen.cp_default_padding);
|
||||
int indexBarWidth = mContext.getResources().getDimensionPixelSize(R.dimen.cp_index_bar_width);
|
||||
int itemWidth = (screenWidth - padding - space * (GridListAdapter.SPAN_COUNT - 1) - indexBarWidth) / GridListAdapter.SPAN_COUNT;
|
||||
ViewGroup.LayoutParams lp = ((LocationViewHolder) holder).container.getLayoutParams();
|
||||
lp.width = itemWidth;
|
||||
lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
((LocationViewHolder) holder).container.setLayoutParams(lp);
|
||||
|
||||
switch (locateState){
|
||||
case LocateState.LOCATING:
|
||||
((LocationViewHolder) holder).current.setText(R.string.cp_locating);
|
||||
break;
|
||||
case LocateState.SUCCESS:
|
||||
((LocationViewHolder) holder).current.setText(data.getName());
|
||||
break;
|
||||
case LocateState.FAILURE:
|
||||
((LocationViewHolder) holder).current.setText(R.string.cp_locate_failed);
|
||||
break;
|
||||
}
|
||||
((LocationViewHolder) holder).container.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (locateState == LocateState.SUCCESS) {
|
||||
if (mInnerListener != null) {
|
||||
mInnerListener.dismiss(pos, data);
|
||||
}
|
||||
} else if (locateState == LocateState.FAILURE){
|
||||
locateState = LocateState.LOCATING;
|
||||
notifyItemChanged(0);
|
||||
if (mInnerListener != null){
|
||||
mInnerListener.locate();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//第一次弹窗,如果未定位则自动定位
|
||||
if (autoLocate && locateState == LocateState.LOCATING && mInnerListener != null){
|
||||
mInnerListener.locate();
|
||||
autoLocate = false;
|
||||
}
|
||||
}
|
||||
//热门城市
|
||||
if (holder instanceof HotViewHolder){
|
||||
final int pos = holder.getAdapterPosition();
|
||||
final City data = mData.get(pos);
|
||||
if (data == null) return;
|
||||
GridListAdapter mAdapter = new GridListAdapter(mContext, mHotData);
|
||||
mAdapter.setInnerListener(mInnerListener);
|
||||
((HotViewHolder) holder).mRecyclerView.setAdapter(mAdapter);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mData == null ? 0 : mData.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == 0 && TextUtils.equals("定", mData.get(position).getSection().substring(0, 1)))
|
||||
return VIEW_TYPE_LOCATION;
|
||||
if (position == 1 && TextUtils.equals("热", mData.get(position).getSection().substring(0, 1)))
|
||||
return VIEW_TYPE_HOT;
|
||||
return super.getItemViewType(position);
|
||||
}
|
||||
|
||||
public void setInnerListener(InnerListener listener){
|
||||
this.mInnerListener = listener;
|
||||
}
|
||||
|
||||
static class BaseViewHolder extends RecyclerView.ViewHolder{
|
||||
BaseViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
}
|
||||
|
||||
public static class DefaultViewHolder extends BaseViewHolder{
|
||||
TextView name;
|
||||
|
||||
DefaultViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
name = itemView.findViewById(R.id.cp_list_item_name);
|
||||
}
|
||||
}
|
||||
|
||||
public static class HotViewHolder extends BaseViewHolder {
|
||||
RecyclerView mRecyclerView;
|
||||
|
||||
HotViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mRecyclerView = itemView.findViewById(R.id.cp_hot_list);
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new GridLayoutManager(itemView.getContext(),
|
||||
GridListAdapter.SPAN_COUNT, LinearLayoutManager.VERTICAL, false));
|
||||
int space = itemView.getContext().getResources().getDimensionPixelSize(R.dimen.cp_grid_item_space);
|
||||
mRecyclerView.addItemDecoration(new GridItemDecoration(GridListAdapter.SPAN_COUNT,
|
||||
space));
|
||||
}
|
||||
}
|
||||
|
||||
public static class LocationViewHolder extends BaseViewHolder {
|
||||
FrameLayout container;
|
||||
TextView current;
|
||||
|
||||
LocationViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
container = itemView.findViewById(R.id.cp_list_item_location_layout);
|
||||
current = itemView.findViewById(R.id.cp_list_item_location);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.zaaach.citypicker.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.zaaach.citypicker.R;
|
||||
import com.zaaach.citypicker.model.City;
|
||||
import com.zaaach.citypicker.model.HotCity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: Bro0cL
|
||||
* @Date: 2018/2/8 21:22
|
||||
*/
|
||||
public class GridListAdapter extends RecyclerView.Adapter<GridListAdapter.GridViewHolder>{
|
||||
public static final int SPAN_COUNT = 3;
|
||||
|
||||
private Context mContext;
|
||||
private List<HotCity> mData;
|
||||
private InnerListener mInnerListener;
|
||||
|
||||
public GridListAdapter(Context context, List<HotCity> data) {
|
||||
this.mContext = context;
|
||||
this.mData = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GridViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(mContext).inflate(R.layout.cp_grid_item_layout, parent, false);
|
||||
return new GridViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(GridViewHolder holder, int position) {
|
||||
final int pos = holder.getAdapterPosition();
|
||||
final City data = mData.get(pos);
|
||||
if (data == null) return;
|
||||
//设置item宽高
|
||||
DisplayMetrics dm = mContext.getResources().getDisplayMetrics();
|
||||
int screenWidth = dm.widthPixels;
|
||||
TypedValue typedValue = new TypedValue();
|
||||
mContext.getTheme().resolveAttribute(R.attr.cpGridItemSpace, typedValue, true);
|
||||
int space = mContext.getResources().getDimensionPixelSize(typedValue.resourceId);
|
||||
int padding = mContext.getResources().getDimensionPixelSize(R.dimen.cp_default_padding);
|
||||
int indexBarWidth = mContext.getResources().getDimensionPixelSize(R.dimen.cp_index_bar_width);
|
||||
int itemWidth = (screenWidth - padding - space * (SPAN_COUNT - 1) - indexBarWidth) / SPAN_COUNT;
|
||||
ViewGroup.LayoutParams lp = holder.container.getLayoutParams();
|
||||
lp.width = itemWidth;
|
||||
lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
holder.container.setLayoutParams(lp);
|
||||
|
||||
holder.name.setText(data.getName());
|
||||
holder.container.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mInnerListener != null){
|
||||
mInnerListener.dismiss(pos, data);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mData == null ? 0 : mData.size();
|
||||
}
|
||||
|
||||
public static class GridViewHolder extends RecyclerView.ViewHolder{
|
||||
FrameLayout container;
|
||||
TextView name;
|
||||
|
||||
public GridViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
container = itemView.findViewById(R.id.cp_grid_item_layout);
|
||||
name = itemView.findViewById(R.id.cp_gird_item_name);
|
||||
}
|
||||
}
|
||||
|
||||
public void setInnerListener(InnerListener listener){
|
||||
this.mInnerListener = listener;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.zaaach.citypicker.adapter;
|
||||
|
||||
import com.zaaach.citypicker.model.City;
|
||||
|
||||
public interface InnerListener {
|
||||
void dismiss(int position, City data);
|
||||
void locate();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.zaaach.citypicker.adapter;
|
||||
|
||||
import com.zaaach.citypicker.model.City;
|
||||
|
||||
public interface OnPickListener {
|
||||
void onPick(int position, City data);
|
||||
void onLocate();
|
||||
void onCancel();
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.zaaach.citypicker.adapter.decoration;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
|
||||
import com.zaaach.citypicker.R;
|
||||
|
||||
public class DividerItemDecoration extends RecyclerView.ItemDecoration {
|
||||
private float dividerHeight;
|
||||
private Paint mPaint;
|
||||
|
||||
public DividerItemDecoration(Context context) {
|
||||
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
|
||||
TypedValue typedValue = new TypedValue();
|
||||
context.getTheme().resolveAttribute(R.attr.cpSectionBackground, typedValue, true);
|
||||
mPaint.setColor(context.getResources().getColor(typedValue.resourceId));
|
||||
dividerHeight = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0.5f, context.getResources().getDisplayMetrics());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
||||
super.getItemOffsets(outRect, view, parent, state);
|
||||
outRect.bottom = (int) dividerHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
|
||||
int childCount = parent.getChildCount();
|
||||
int left = parent.getPaddingLeft();
|
||||
int right = parent.getWidth() - parent.getPaddingRight();
|
||||
|
||||
for (int i = 0; i < childCount - 1; i++) {
|
||||
View view = parent.getChildAt(i);
|
||||
float top = view.getBottom();
|
||||
float bottom = view.getBottom() + dividerHeight;
|
||||
c.drawRect(left, top, right, bottom, mPaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.zaaach.citypicker.adapter.decoration;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
|
||||
public class GridItemDecoration extends RecyclerView.ItemDecoration{
|
||||
private int mSpanCount;
|
||||
private int mSpace;
|
||||
|
||||
public GridItemDecoration(int spanCount, int space) {
|
||||
this.mSpanCount = spanCount;
|
||||
this.mSpace = space;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
||||
int position = parent.getChildAdapterPosition(view);
|
||||
int column = position % mSpanCount;
|
||||
|
||||
outRect.left = column * mSpace / mSpanCount;
|
||||
outRect.right = mSpace - (column + 1) * mSpace / mSpanCount;
|
||||
if (position >= mSpanCount) {
|
||||
outRect.top = mSpace;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package com.zaaach.citypicker.adapter.decoration;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.text.TextPaint;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
|
||||
import com.zaaach.citypicker.R;
|
||||
import com.zaaach.citypicker.model.City;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SectionItemDecoration extends RecyclerView.ItemDecoration {
|
||||
private List<City> mData;
|
||||
private Paint mBgPaint;
|
||||
private TextPaint mTextPaint;
|
||||
private Rect mBounds;
|
||||
|
||||
private int mSectionHeight;
|
||||
private int mBgColor;
|
||||
private int mTextColor;
|
||||
private int mTextSize;
|
||||
|
||||
public SectionItemDecoration(Context context, List<City> data) {
|
||||
this.mData = data;
|
||||
TypedValue typedValue = new TypedValue();
|
||||
|
||||
context.getTheme().resolveAttribute(R.attr.cpSectionBackground, typedValue, true);
|
||||
mBgColor = context.getResources().getColor(typedValue.resourceId);
|
||||
|
||||
context.getTheme().resolveAttribute(R.attr.cpSectionHeight, typedValue, true);
|
||||
mSectionHeight = context.getResources().getDimensionPixelSize(typedValue.resourceId);
|
||||
|
||||
context.getTheme().resolveAttribute(R.attr.cpSectionTextSize, typedValue, true);
|
||||
mTextSize = context.getResources().getDimensionPixelSize(typedValue.resourceId);
|
||||
|
||||
context.getTheme().resolveAttribute(R.attr.cpSectionTextColor, typedValue, true);
|
||||
mTextColor = context.getResources().getColor(typedValue.resourceId);
|
||||
|
||||
mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
mBgPaint.setColor(mBgColor);
|
||||
|
||||
mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
mTextPaint.setTextSize(mTextSize);
|
||||
mTextPaint.setColor(mTextColor);
|
||||
|
||||
mBounds = new Rect();
|
||||
}
|
||||
|
||||
public void setData(List<City> data) {
|
||||
this.mData = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
|
||||
super.onDraw(c, parent, state);
|
||||
final int left = parent.getPaddingLeft();
|
||||
final int right = parent.getWidth() - parent.getPaddingRight();
|
||||
final int childCount = parent.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
final View child = parent.getChildAt(i);
|
||||
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
|
||||
.getLayoutParams();
|
||||
int position = params.getViewLayoutPosition();
|
||||
if (mData != null && !mData.isEmpty() && position <= mData.size() - 1 && position > -1) {
|
||||
if (position == 0) {
|
||||
drawSection(c, left, right, child, params, position);
|
||||
} else {
|
||||
if (null != mData.get(position).getSection()
|
||||
&& !mData.get(position).getSection().equals(mData.get(position - 1).getSection())) {
|
||||
drawSection(c, left, right, child, params, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawSection(Canvas c, int left, int right, View child,
|
||||
RecyclerView.LayoutParams params, int position) {
|
||||
c.drawRect(left,
|
||||
child.getTop() - params.topMargin - mSectionHeight,
|
||||
right,
|
||||
child.getTop() - params.topMargin, mBgPaint);
|
||||
mTextPaint.getTextBounds(mData.get(position).getSection(),
|
||||
0,
|
||||
mData.get(position).getSection().length(),
|
||||
mBounds);
|
||||
c.drawText(mData.get(position).getSection(),
|
||||
child.getPaddingLeft(),
|
||||
child.getTop() - params.topMargin - (mSectionHeight / 2 - mBounds.height() / 2),
|
||||
mTextPaint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
|
||||
int pos = ((LinearLayoutManager) (parent.getLayoutManager())).findFirstVisibleItemPosition();
|
||||
if (pos < 0) return;
|
||||
if (mData == null || mData.isEmpty()) return;
|
||||
String section = mData.get(pos).getSection();
|
||||
View child = parent.findViewHolderForLayoutPosition(pos).itemView;
|
||||
|
||||
boolean flag = false;
|
||||
if ((pos + 1) < mData.size()) {
|
||||
if (null != section && !section.equals(mData.get(pos + 1).getSection())) {
|
||||
if (child.getHeight() + child.getTop() < mSectionHeight) {
|
||||
c.save();
|
||||
flag = true;
|
||||
c.translate(0, child.getHeight() + child.getTop() - mSectionHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
c.drawRect(parent.getPaddingLeft(),
|
||||
parent.getPaddingTop(),
|
||||
parent.getRight() - parent.getPaddingRight(),
|
||||
parent.getPaddingTop() + mSectionHeight, mBgPaint);
|
||||
mTextPaint.getTextBounds(section, 0, section.length(), mBounds);
|
||||
c.drawText(section,
|
||||
child.getPaddingLeft(),
|
||||
parent.getPaddingTop() + mSectionHeight - (mSectionHeight / 2 - mBounds.height() / 2),
|
||||
mTextPaint);
|
||||
if (flag)
|
||||
c.restore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
||||
super.getItemOffsets(outRect, view, parent, state);
|
||||
int position = ((RecyclerView.LayoutParams) view.getLayoutParams()).getViewLayoutPosition();
|
||||
if (mData != null && !mData.isEmpty() && position <= mData.size() - 1 && position > -1) {
|
||||
if (position == 0) {
|
||||
outRect.set(0, mSectionHeight, 0, 0);
|
||||
} else {
|
||||
if (null != mData.get(position).getSection()
|
||||
&& !mData.get(position).getSection().equals(mData.get(position - 1).getSection())) {
|
||||
outRect.set(0, mSectionHeight, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.zaaach.citypicker.db;
|
||||
|
||||
public class DBConfig {
|
||||
public static final String DB_NAME_V1 = "china_cities.db";
|
||||
public static final String DB_NAME_V2 = "china_cities_v2.db";
|
||||
public static final String LATEST_DB_NAME = DB_NAME_V2;
|
||||
|
||||
public static final String TABLE_NAME = "cities";
|
||||
|
||||
public static final String COLUMN_C_NAME = "c_name";
|
||||
public static final String COLUMN_C_PROVINCE = "c_province";
|
||||
public static final String COLUMN_C_PINYIN = "c_pinyin";
|
||||
public static final String COLUMN_C_CODE = "c_code";
|
||||
}
|
||||
130
citypicker/src/main/java/com/zaaach/citypicker/db/DBManager.java
Normal file
@@ -0,0 +1,130 @@
|
||||
package com.zaaach.citypicker.db;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Environment;
|
||||
|
||||
import com.zaaach.citypicker.model.City;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import static com.zaaach.citypicker.db.DBConfig.COLUMN_C_CODE;
|
||||
import static com.zaaach.citypicker.db.DBConfig.COLUMN_C_NAME;
|
||||
import static com.zaaach.citypicker.db.DBConfig.COLUMN_C_PINYIN;
|
||||
import static com.zaaach.citypicker.db.DBConfig.COLUMN_C_PROVINCE;
|
||||
import static com.zaaach.citypicker.db.DBConfig.LATEST_DB_NAME;
|
||||
import static com.zaaach.citypicker.db.DBConfig.DB_NAME_V1;
|
||||
import static com.zaaach.citypicker.db.DBConfig.TABLE_NAME;
|
||||
|
||||
/**
|
||||
* Author Bro0cL on 2016/1/26.
|
||||
*/
|
||||
public class DBManager {
|
||||
private static final int BUFFER_SIZE = 1024;
|
||||
|
||||
private String DB_PATH;
|
||||
private Context mContext;
|
||||
|
||||
public DBManager(Context context) {
|
||||
this.mContext = context;
|
||||
DB_PATH = File.separator + "data"
|
||||
+ Environment.getDataDirectory().getAbsolutePath() + File.separator
|
||||
+ context.getPackageName() + File.separator + "databases" + File.separator;
|
||||
copyDBFile();
|
||||
}
|
||||
|
||||
private void copyDBFile(){
|
||||
File dir = new File(DB_PATH);
|
||||
if (!dir.exists()){
|
||||
dir.mkdirs();
|
||||
}
|
||||
//如果旧版数据库存在,则删除
|
||||
File dbV1 = new File(DB_PATH + DB_NAME_V1);
|
||||
if (dbV1.exists()){
|
||||
dbV1.delete();
|
||||
}
|
||||
//创建新版本数据库
|
||||
File dbFile = new File(DB_PATH + LATEST_DB_NAME);
|
||||
if (!dbFile.exists()){
|
||||
InputStream is;
|
||||
OutputStream os;
|
||||
try {
|
||||
is = mContext.getResources().getAssets().open(LATEST_DB_NAME);
|
||||
os = new FileOutputStream(dbFile);
|
||||
byte[] buffer = new byte[BUFFER_SIZE];
|
||||
int length;
|
||||
while ((length = is.read(buffer, 0, buffer.length)) > 0){
|
||||
os.write(buffer, 0, length);
|
||||
}
|
||||
os.flush();
|
||||
os.close();
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<City> getAllCities(){
|
||||
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(DB_PATH + LATEST_DB_NAME, null);
|
||||
Cursor cursor = db.rawQuery("select * from " + TABLE_NAME, null);
|
||||
List<City> result = new ArrayList<>();
|
||||
City city;
|
||||
while (cursor.moveToNext()){
|
||||
String name = cursor.getString(cursor.getColumnIndex(COLUMN_C_NAME));
|
||||
String province = cursor.getString(cursor.getColumnIndex(COLUMN_C_PROVINCE));
|
||||
String pinyin = cursor.getString(cursor.getColumnIndex(COLUMN_C_PINYIN));
|
||||
String code = cursor.getString(cursor.getColumnIndex(COLUMN_C_CODE));
|
||||
city = new City(name, province, pinyin, code);
|
||||
result.add(city);
|
||||
}
|
||||
cursor.close();
|
||||
db.close();
|
||||
Collections.sort(result, new CityComparator());
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<City> searchCity(final String keyword){
|
||||
String sql = "select * from " + TABLE_NAME + " where "
|
||||
+ COLUMN_C_NAME + " like ? " + "or "
|
||||
+ COLUMN_C_PINYIN + " like ? ";
|
||||
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(DB_PATH + LATEST_DB_NAME, null);
|
||||
Cursor cursor = db.rawQuery(sql, new String[]{"%"+keyword+"%", keyword+"%"});
|
||||
|
||||
List<City> result = new ArrayList<>();
|
||||
while (cursor.moveToNext()){
|
||||
String name = cursor.getString(cursor.getColumnIndex(COLUMN_C_NAME));
|
||||
String province = cursor.getString(cursor.getColumnIndex(COLUMN_C_PROVINCE));
|
||||
String pinyin = cursor.getString(cursor.getColumnIndex(COLUMN_C_PINYIN));
|
||||
String code = cursor.getString(cursor.getColumnIndex(COLUMN_C_CODE));
|
||||
City city = new City(name, province, pinyin, code);
|
||||
result.add(city);
|
||||
}
|
||||
cursor.close();
|
||||
db.close();
|
||||
CityComparator comparator = new CityComparator();
|
||||
Collections.sort(result, comparator);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* sort by a-z
|
||||
*/
|
||||
private class CityComparator implements Comparator<City>{
|
||||
@Override
|
||||
public int compare(City lhs, City rhs) {
|
||||
String a = lhs.getPinyin().substring(0, 1);
|
||||
String b = rhs.getPinyin().substring(0, 1);
|
||||
return a.compareTo(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.zaaach.citypicker.model;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* author Bro0cL on 2016/1/26.
|
||||
*/
|
||||
public class City {
|
||||
private String name;
|
||||
private String province;
|
||||
private String pinyin;
|
||||
private String code;
|
||||
|
||||
public City(String name, String province, String pinyin, String code) {
|
||||
this.name = name;
|
||||
this.province = province;
|
||||
this.pinyin = pinyin;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取悬浮栏文本,(#、定位、热门 需要特殊处理)
|
||||
* @return
|
||||
*/
|
||||
public String getSection(){
|
||||
if (TextUtils.isEmpty(pinyin)) {
|
||||
return "#";
|
||||
} else {
|
||||
String c = pinyin.substring(0, 1);
|
||||
Pattern p = Pattern.compile("[a-zA-Z]");
|
||||
Matcher m = p.matcher(c);
|
||||
if (m.matches()) {
|
||||
return c.toUpperCase();
|
||||
}
|
||||
//在添加定位和热门数据时设置的section就是‘定’、’热‘开头
|
||||
else if (TextUtils.equals(c, "定") || TextUtils.equals(c, "热"))
|
||||
return pinyin;
|
||||
else
|
||||
return "#";
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPinyin() {
|
||||
return pinyin;
|
||||
}
|
||||
|
||||
public void setPinyin(String pinyin) {
|
||||
this.pinyin = pinyin;
|
||||
}
|
||||
|
||||
public String getProvince() {
|
||||
return province;
|
||||
}
|
||||
|
||||
public void setProvince(String province) {
|
||||
this.province = province;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.zaaach.citypicker.model;
|
||||
|
||||
public class HotCity extends City {
|
||||
|
||||
public HotCity(String name, String province, String code) {
|
||||
super(name, province, "热门城市", code);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zaaach.citypicker.model;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
public class LocateState {
|
||||
public static final int LOCATING = 123;
|
||||
public static final int SUCCESS = 132;
|
||||
public static final int FAILURE = 321;
|
||||
|
||||
@IntDef({SUCCESS, FAILURE})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface State{}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.zaaach.citypicker.model;
|
||||
|
||||
public class LocatedCity extends City {
|
||||
|
||||
public LocatedCity(String name, String province, String code) {
|
||||
super(name, province, "定位城市", code);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.zaaach.citypicker.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Display;
|
||||
import android.view.WindowManager;
|
||||
|
||||
/**
|
||||
* @Author: Bro0cL
|
||||
* @Date: 2018/12/4 11:35
|
||||
* @Discription:
|
||||
*/
|
||||
public class ScreenUtil {
|
||||
|
||||
private static int getInternalDimensionSize(Context context, String key) {
|
||||
int result = 0;
|
||||
try {
|
||||
int resourceId = context.getResources().getIdentifier(key, "dimen", "android");
|
||||
if (resourceId > 0) {
|
||||
result = Math.round(context.getResources().getDimensionPixelSize(resourceId) *
|
||||
Resources.getSystem().getDisplayMetrics().density /
|
||||
context.getResources().getDisplayMetrics().density);
|
||||
}
|
||||
} catch (Resources.NotFoundException ignored) {
|
||||
return 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static int getStatusBarHeight(Context context){
|
||||
return getInternalDimensionSize(context, "status_bar_height");
|
||||
}
|
||||
|
||||
public static int getNavigationBarHeight(Context context) {
|
||||
boolean mInPortrait = context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
|
||||
int result = 0;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
if (hasNavBar((Activity) context)) {
|
||||
String key;
|
||||
if (mInPortrait) {
|
||||
key = "navigation_bar_height";
|
||||
} else {
|
||||
key = "navigation_bar_height_landscape";
|
||||
}
|
||||
return getInternalDimensionSize(context, key);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean hasNavBar(Activity activity) {
|
||||
//判断小米手机是否开启了全面屏,开启了,直接返回false
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
if (Settings.Global.getInt(activity.getContentResolver(), "force_fsg_nav_bar", 0) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//其他手机根据屏幕真实高度与显示高度是否相同来判断
|
||||
WindowManager windowManager = activity.getWindowManager();
|
||||
Display d = windowManager.getDefaultDisplay();
|
||||
|
||||
DisplayMetrics realDisplayMetrics = new DisplayMetrics();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
d.getRealMetrics(realDisplayMetrics);
|
||||
}
|
||||
|
||||
int realHeight = realDisplayMetrics.heightPixels;
|
||||
int realWidth = realDisplayMetrics.widthPixels;
|
||||
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
d.getMetrics(displayMetrics);
|
||||
|
||||
int displayHeight = displayMetrics.heightPixels;
|
||||
int displayWidth = displayMetrics.widthPixels;
|
||||
|
||||
return (realWidth - displayWidth) > 0 || (realHeight - displayHeight) > 0;
|
||||
}
|
||||
}
|
||||