初始化

This commit is contained in:
2022-08-24 09:32:54 +08:00
parent 0d349c559c
commit 8e4d517c40
800 changed files with 74927 additions and 20 deletions
@@ -0,0 +1,111 @@
package com.arpa.hndahesudintocctmsdriver.util.view;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import com.arpa.hndahesudintocctmsdriver.R;
import com.arpa.hndahesudintocctmsdriver.util.http.RequsetCodeConstants;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
public abstract class BaseActivity extends Activity {
public Context con;
public Activity act;
public static String dataName,dataName2,dataName3="";
public View root;
private String title_text="空白标题";
public Handler hd=new Handler(msg -> {
msgMethod(msg);
return false;
});
public SmartRefreshLayout refreshLayout;
public void msgMethod(Message m){
switch (m.what){
case RequsetCodeConstants.ERROR:
Toast.makeText(con,RequsetCodeConstants.FEEDBACK_TEXT,Toast.LENGTH_SHORT).show();
if(refreshLayout!=null){
refreshLayout.finishRefresh();
}
break;
case RequsetCodeConstants.UNKONWN:
Toast.makeText(con,RequsetCodeConstants.UNKONWN_TEXT,Toast.LENGTH_SHORT).show();
if(refreshLayout!=null){
refreshLayout.finishRefresh();
}
break;
case RequsetCodeConstants.SERVER_ERROR:
Toast.makeText(con,RequsetCodeConstants.SERVER_ERROR_TEXT,Toast.LENGTH_SHORT).show();
if(refreshLayout!=null){
refreshLayout.finishRefresh();
}
break;
case RequsetCodeConstants.GATEWAY_ERROR:
Toast.makeText(con,RequsetCodeConstants.GATEWAY_ERROR_TEXT,Toast.LENGTH_SHORT).show();
if(refreshLayout!=null){
refreshLayout.finishRefresh();
}
break;
}
}
public void initView(Object obj){
//ViewGroup vg=findViewById(layout);
//vg.findViewById(R)
if(findViewById(R.id.return_btn)!=null){
findViewById(R.id.return_btn).setOnClickListener(v -> {
finish();
});
}
if(findViewById(R.id.title_view)!=null){
TextView title_view=findViewById(R.id.title_view);
title_view.setText(title_text);
}
//GetObjectName.ZIModel(vg,obj,con);
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
MyReceiver receiver;
private void registerBroadcast() {
// 注册广播接收者
receiver = new MyReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction("exit_app");
if(receiver!=null){
Log.e("广播概况",receiver.toString()+"_"+this.toString());
registerReceiver(receiver,filter);
}
}
class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
context.unregisterReceiver(this);
if(intent.getAction().equals("exit_app")){
finish();
}
}
}
public void setTitle(String title){
this.title_text=title;
}
}
@@ -0,0 +1,95 @@
package com.arpa.hndahesudintocctmsdriver.util.view;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.arpa.hndahesudintocctmsdriver.R;
import com.arpa.hndahesudintocctmsdriver.util.http.RequsetCodeConstants;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
public class BaseAppCompatActivity extends AppCompatActivity {
public Context con;
public Activity act;
public static String dataName,dataName2,dataName3="";
public View root;
public Handler hd=new Handler(msg -> {
msgMethod(msg);
return false;
});
public SmartRefreshLayout refreshLayout;
public void msgMethod(Message m){
switch (m.what){
case RequsetCodeConstants.ERROR:
Toast.makeText(con,RequsetCodeConstants.FEEDBACK_TEXT,Toast.LENGTH_SHORT).show();
if(refreshLayout!=null){
refreshLayout.finishRefresh();
}
break;
case RequsetCodeConstants.UNKONWN:
Toast.makeText(con,RequsetCodeConstants.UNKONWN_TEXT,Toast.LENGTH_SHORT).show();
if(refreshLayout!=null){
refreshLayout.finishRefresh();
}
break;
case RequsetCodeConstants.SERVER_ERROR:
Toast.makeText(con,RequsetCodeConstants.SERVER_ERROR_TEXT,Toast.LENGTH_SHORT).show();
if(refreshLayout!=null){
refreshLayout.finishRefresh();
}
break;
case RequsetCodeConstants.GATEWAY_ERROR:
Toast.makeText(con,RequsetCodeConstants.GATEWAY_ERROR_TEXT,Toast.LENGTH_SHORT).show();
if(refreshLayout!=null){
refreshLayout.finishRefresh();
}
break;
}
}
public void initView(Object obj){
if(findViewById(R.id.return_btn)!=null){
findViewById(R.id.return_btn).setOnClickListener(v -> {
finish();
});
}
//ViewGroup vg=root.findViewById(root.getId());
//GetObjectName.ZIModel(vg,obj,con);
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
MyReceiver receiver;
private void registerBroadcast() {
// 注册广播接收者
receiver = new MyReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction("exit_app");
registerReceiver(receiver,filter);
}
class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
context.unregisterReceiver(this);
if(intent.getAction().equals("exit_app")){
finish();
}
}
}
}
@@ -0,0 +1,49 @@
package com.arpa.hndahesudintocctmsdriver.util.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import androidx.lifecycle.Lifecycle;
import com.arpa.hndahesudintocctmsdriver.R;
import com.arpa.hndahesudintocctmsdriver.ui.wallet.BannerApdate;
import com.zhpan.bannerview.BannerViewPager;
import com.zhpan.bannerview.constants.PageStyle;
import java.util.List;
/**
* @author hlh
* @version 1.0.0
* @date 2021/10/11 14:11
* @description:
*/
public class BaseBannerView extends BannerViewPager {
public BaseBannerView(Context context) {
super(context);
}
public BaseBannerView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public BaseBannerView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public BannerApdate init(Context con, Lifecycle li, List<Object> list,int layout){
this.setPageStyle(PageStyle.MULTI_PAGE_SCALE);
BannerApdate ba=new BannerApdate(con,layout);
this.setLifecycleRegistry(li)
.setPageMargin(getResources().getDimensionPixelOffset(R.dimen.dp_20))
.setRevealWidth(getResources().getDimensionPixelOffset(R.dimen.dp_20))
.setAdapter(ba)
.create();
this.refreshData(list);
this.setIndicatorVisibility(View.GONE);
return ba;
}
}
@@ -0,0 +1,108 @@
package com.arpa.hndahesudintocctmsdriver.util.view;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.arpa.hndahesudintocctmsdriver.R;
import com.arpa.hndahesudintocctmsdriver.util.http.RequsetCodeConstants;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import org.jetbrains.annotations.NotNull;
public class BaseFragment extends Fragment {
public SmartRefreshLayout refreshLayout;
public Context con=getContext();
public Activity act=getActivity();
public static String dataName,dataName2,dataName3="";
public View root;
public Handler hd=new Handler(msg -> {
msgMethod(msg);
return false;
});
public void msgMethod(Message m){
switch (m.what){
case RequsetCodeConstants.ERROR:
Toast.makeText(con,RequsetCodeConstants.FEEDBACK_TEXT,Toast.LENGTH_SHORT).show();
if(refreshLayout!=null){
refreshLayout.finishRefresh();
}
break;
case RequsetCodeConstants.UNKONWN:
Toast.makeText(con,RequsetCodeConstants.UNKONWN_TEXT,Toast.LENGTH_SHORT).show();
if(refreshLayout!=null){
refreshLayout.finishRefresh();
}
break;
case RequsetCodeConstants.SERVER_ERROR:
Toast.makeText(con,RequsetCodeConstants.SERVER_ERROR_TEXT,Toast.LENGTH_SHORT).show();
if(refreshLayout!=null){
refreshLayout.finishRefresh();
}
break;
case RequsetCodeConstants.GATEWAY_ERROR:
Toast.makeText(con,RequsetCodeConstants.GATEWAY_ERROR_TEXT,Toast.LENGTH_SHORT).show();
if(refreshLayout!=null){
refreshLayout.finishRefresh();
}
break;
}
}
public void initView(Object obj){
// if(root.getId()!=-1){
// ViewGroup vg=root.findViewById(root.getId());
// GetObjectName.ZIModel(vg,obj,con);
// }
if(root.findViewById(R.id.return_btn)!=null){
root.findViewById(R.id.return_btn).setOnClickListener(v -> {
getActivity().finish();
});
}
}
@Nullable
@org.jetbrains.annotations.Nullable
@Override
public View onCreateView(@NonNull @NotNull LayoutInflater inflater, @Nullable @org.jetbrains.annotations.Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
//registerBroadcast();
return super.onCreateView(inflater, container, savedInstanceState);
}
MyReceiver receiver;
private void registerBroadcast() {
// 注册广播接收者
receiver = new MyReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction("exit_app");
getActivity().registerReceiver(receiver,filter);
}
class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
context.unregisterReceiver(this);
if(intent.getAction().equals("exit_app")){
getActivity().finish();
}
}
}
}
@@ -0,0 +1,137 @@
package com.arpa.hndahesudintocctmsdriver.util.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.TouchDelegate;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.arpa.hndahesudintocctmsdriver.util.adapter.AdapterAll;
import com.arpa.hndahesudintocctmsdriver.util.adapter.AdapterAlls;
import com.arpa.hndahesudintocctmsdriver.util.adapter.ManyBean;
import java.util.List;
public class BaseRecyclerView extends RecyclerView {
@Override
public TouchDelegate getTouchDelegate() {
return super.getTouchDelegate();
}
public BaseRecyclerView(@NonNull Context context) {
super(context);
}
public BaseRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public BaseRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
private AdapterAlls ra;
private AdapterAll aa;
public AdapterAll createV(Context con,List list, int layout){
LinearLayoutManager layoutManager = new LinearLayoutManager(con);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
this.setLayoutManager(layoutManager);
aa=new AdapterAll(con,list,layout);
this.setAdapter(aa);
return aa;
}
public AdapterAll createH(Context con, List<Object> list,int layout){
LinearLayoutManager layoutManager = new LinearLayoutManager(con);
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
this.setLayoutManager(layoutManager);
aa=new AdapterAll(con,list,layout);
this.setAdapter(aa);
return aa;
}
public AdapterAll createG(int ral,Context con, List<Object> list,int layout){
GridLayoutManager gm=new GridLayoutManager(con,ral){
@Override
public boolean canScrollVertically() {
return false;
}
};
this.setLayoutManager(gm);
aa=new AdapterAll(con,list,layout);
this.setAdapter(aa);
return aa;
}
public AdapterAlls createGs(int ral,Context con, List<ManyBean> list){
this.setLayoutManager(new GridLayoutManager(con,ral));
AdapterAlls ra=new AdapterAlls(con,list);
this.setAdapter(ra);
return ra;
}
//多任务布局
public AdapterAlls creates(Context con, List<ManyBean> list){
LinearLayoutManager layoutManager = new LinearLayoutManager(con);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
this.setLayoutManager(layoutManager);
ra=new AdapterAlls(con,list);
this.setAdapter(ra);
return ra;
}
public void removeAll(){
aa.removeAll();
}
public void updateItemV(int position,Object o){
aa.updateItem(position,o);
}
public void addItemV(Object o){
aa.addItemV(o);
}
public void delItemV(int p){
aa.delItemV(p);
}
public void removeItemV(int index){
aa.removeItemV(index);
}
public void addV(List<ManyBean> list){
}
public void addItem(ManyBean mb){
ra.addItem(mb);
}
public void adds(List<ManyBean> list){
ra.add(list);
}
public AdapterAlls createsH(Context con, List<ManyBean> list){
LinearLayoutManager layoutManager = new LinearLayoutManager(con);
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
this.setLayoutManager(layoutManager);
AdapterAlls ra=new AdapterAlls(con,list);
this.setAdapter(ra);
return ra;
}
//下拉刷新
public void insDropDown(){
}
//上拉加载更多
public void pullUpLoading(){
}
//加载中状态
public void Loading(){
}
//加载无数据状态
public void loadFeedback(){
}
}
@@ -0,0 +1,54 @@
package com.arpa.hndahesudintocctmsdriver.util.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.SlidingDrawer;
public class BaseSlidingDrawer extends SlidingDrawer {
private boolean mVertical;
private int mTopOffset;
public BaseSlidingDrawer(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
int orientation = attrs.getAttributeIntValue("android", "orientation", ORIENTATION_VERTICAL);
mTopOffset = attrs.getAttributeIntValue("android", "topOffset", 0);
mVertical = (orientation == SlidingDrawer.ORIENTATION_VERTICAL);
}
public BaseSlidingDrawer(Context context, AttributeSet attrs) {
super(context, attrs);
int orientation = attrs.getAttributeIntValue("android", "orientation", ORIENTATION_VERTICAL);
mTopOffset = attrs.getAttributeIntValue("android", "topOffset", 0);
mVertical = (orientation == SlidingDrawer.ORIENTATION_VERTICAL);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);
int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);
int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec);
final View handle = getHandle();
final View content = getContent();
measureChild(handle, widthMeasureSpec, heightMeasureSpec);
if (mVertical) {
int height = heightSpecSize - handle.getMeasuredHeight() - mTopOffset;
content.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(height, heightSpecMode));
heightSpecSize = handle.getMeasuredHeight() + mTopOffset + content.getMeasuredHeight();
widthSpecSize = content.getMeasuredWidth();
if (handle.getMeasuredWidth() > widthSpecSize) widthSpecSize = handle.getMeasuredWidth();
}
else {
int width = widthSpecSize - handle.getMeasuredWidth() - mTopOffset;
getContent().measure(MeasureSpec.makeMeasureSpec(width, widthSpecMode), heightMeasureSpec);
widthSpecSize = handle.getMeasuredWidth() + mTopOffset + content.getMeasuredWidth();
heightSpecSize = content.getMeasuredHeight();
if (handle.getMeasuredHeight() > heightSpecSize) heightSpecSize = handle.getMeasuredHeight();
}
setMeasuredDimension(widthSpecSize, heightSpecSize);
}
}
@@ -0,0 +1,198 @@
package com.arpa.hndahesudintocctmsdriver.util.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
public class BaseTableView extends LinearLayout {
private List<TextView> TextViewlist=new ArrayList<>();
private List<Integer> hang=new ArrayList<>();
private int rol=0;
private int height=0;
public List<TextView> getTextViewlist() {
return TextViewlist;
}
public void setTextViewlist(List<TextView> textViewlist) {
TextViewlist = textViewlist;
}
public BaseTableView(Context context) {
super(context);
}
public BaseTableView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public BaseTableView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public void initView(List<List<Table>> lists){
rol=lists.size();
// LinearLayout.LayoutParams vlp = new LinearLayout.LayoutParams(
// LinearLayout.LayoutParams.MATCH_PARENT,
// LinearLayout.LayoutParams.WRAP_CONTENT);
this.setOrientation(LinearLayout.VERTICAL);
//this.setLayoutParams(vlp);
for(int i=0;i<rol;i++){
this.addView(addHangView(lists.get(i)));
}
}
public LinearLayout addHangView(List<Table> list){
LinearLayout li=new LinearLayout(getContext());
LayoutParams vlp = new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT);
li.setLayoutParams(vlp);
li.setOrientation(LinearLayout.HORIZONTAL);
for(int i=0;i<list.size();i++){
li.addView(addView(list.get(i).getBody(),list.get(i).getWeight()));
}
if (hang.size()==0) {
hang.add(list.size());
}else{
hang.add(hang.get(hang.size()-1)+list.size());
}
return li;
}
public TextView addView(String text,int q){
TextView t=new TextView(getContext());
LayoutParams vlp = new LayoutParams(
0,
20,1.0f*q);
t.setLayoutParams(vlp);
t.setGravity(Gravity.CENTER);
t.setText(text);
TextViewlist.add(t);
return t;
}
public void setCellBack(int dr){
for (TextView textView : TextViewlist) {
textView.setBackgroundResource(dr);
}
}
public void setCellSize(int size){
for (TextView textView : TextViewlist) {
textView.setTextSize(size);
}
}
public void setCellHight(int h){
for (TextView textView : TextViewlist) {
LayoutParams lp = (LayoutParams) textView.getLayoutParams();
lp.height=h;
textView.setLayoutParams(lp);
}
}
public void setCellBg(int c){
for (TextView textView : TextViewlist) {
textView.setBackgroundColor(c);
}
}
public void setCellMargin(int l,int t,int r,int b){
for (TextView textView : TextViewlist) {
LayoutParams lp = (LayoutParams) textView.getLayoutParams();
lp.setMargins(l,t,r,b);
textView.setLayoutParams(lp);
}
}
public void setCellColor(int c){
for (TextView textView : TextViewlist) {
textView.setTextColor(c);
}
}
//
public void setHangSize(int hsum,int size){
if(hsum==0){
for(int i=0;i<hang.get(hsum);i++){
TextViewlist.get(i).setTextSize(size);
}
}else{
for(int i=hang.get(hsum-1);i<hang.get(hsum);i++){
TextViewlist.get(i).setTextSize(size);
}
}
}
public void setHangHight(int hsum,int h){
if(hsum==0){
for(int i=0;i<hang.get(hsum);i++){
LayoutParams lp = (LayoutParams) TextViewlist.get(i).getLayoutParams();
lp.height=h;
TextViewlist.get(i).setLayoutParams(lp);
}
}else{
for(int i=hang.get(hsum-1);i<hang.get(hsum);i++){
LayoutParams lp = (LayoutParams) TextViewlist.get(i).getLayoutParams();
lp.height=h;
TextViewlist.get(i).setLayoutParams(lp);
}
}
}
public void setHangBg(int hsum,int c){
if(hsum==0){
for(int i=0;i<hang.get(hsum);i++){
TextViewlist.get(i).setBackgroundColor(c);
}
}else{
for(int i=hang.get(hsum-1);i<hang.get(hsum);i++){
TextViewlist.get(i).setBackgroundColor(c);
}
}
}
public void setHangMargin(int hsum,int l,int t,int r,int b){
if(hsum==0){
for(int i=0;i<hang.get(hsum);i++){
LayoutParams lp = (LayoutParams) TextViewlist.get(i).getLayoutParams();
lp.setMargins(l,t,r,b);
TextViewlist.get(i).setLayoutParams(lp);
}
}else{
for(int i=hang.get(hsum-1);i<hang.get(hsum);i++){
LayoutParams lp = (LayoutParams) TextViewlist.get(i).getLayoutParams();
lp.setMargins(l,t,r,b);
TextViewlist.get(i).setLayoutParams(lp);
}
}
}
public void setHangColor(int hsum,int c){
if(hsum==0){
for(int i=0;i<hang.get(hsum);i++){
TextViewlist.get(i).setTextColor(c);
}
}else{
for(int i=hang.get(hsum-1);i<hang.get(hsum);i++){
TextViewlist.get(i).setTextColor(c);
}
}
}
public void setMargin(int index,int l,int t,int r,int b){
LayoutParams lp = (LayoutParams) TextViewlist.get(index).getLayoutParams();
lp.setMargins(l,t,r,b);
TextViewlist.get(index).setLayoutParams(lp);
}
public void setHeight(int index,int h){
LayoutParams lp = (LayoutParams) TextViewlist.get(index).getLayoutParams();
lp.height=h;
TextViewlist.get(index).setLayoutParams(lp);
}
public void setSize(int index,int size){
TextViewlist.get(index).setTextSize(size);
}
}
@@ -0,0 +1,38 @@
package com.arpa.hndahesudintocctmsdriver.util.view;
import android.content.Context;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.lxj.xpopup.core.HorizontalAttachPopupView;
import com.arpa.hndahesudintocctmsdriver.R;
/**
* @author hlh
* @version 1.0.0
* @date 2021/8/19 16:15
* @description:
*/
public class BaseTextAlertPopup extends HorizontalAttachPopupView {
private String body;
public BaseTextAlertPopup(@NonNull Context context,String body) {
super(context);
this.body=body;
}
@Override
protected int getImplLayoutId() {
return 0;
}
@Override
protected void onCreate() {
String a="使用我们产品前";
super.onCreate();
TextView text=findViewById(R.id.text);
text.setText(body);
}
}
@@ -0,0 +1,50 @@
package com.arpa.hndahesudintocctmsdriver.util.view;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;
import com.lxj.xpopup.XPopup;
import org.jetbrains.annotations.NotNull;
/**
* @author hlh
* @version 1.0.0
* @date 2021/8/19 15:49
* @description:
*/
public class BaseTextView extends AppCompatTextView{
public BaseTextView(@NonNull @NotNull Context context) {
super(context);
openShow();
}
public BaseTextView(@NonNull @NotNull Context context, @Nullable @org.jetbrains.annotations.Nullable AttributeSet attrs) {
super(context, attrs);
}
public BaseTextView(@NonNull @NotNull Context context, @Nullable @org.jetbrains.annotations.Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public void openShow(){
this.setOnClickListener(v -> {
Log.e("點擊了","123456");
new XPopup.Builder(getContext())
.isDestroyOnDismiss(true) //对于只使用一次的弹窗,推荐设置这个
//.offsetX(50) //偏移10
// .offsetY(10) //往下偏移10
// .popupPosition(PopupPosition.Right) //手动指定位置,有可能被遮盖
.hasShadowBg(false) // 去掉半透明背景
.atView(v)
.asCustom(new BaseTextAlertPopup(getContext(),this.getText()+""))
.show();
});
}
}
@@ -0,0 +1,48 @@
package com.arpa.hndahesudintocctmsdriver.util.view;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
public class BottomTabUtil {
private AppCompatActivity act;
private int layout;
private FragmentManager fm;
private Fragment[] fs;
private int index=0;
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public BottomTabUtil(AppCompatActivity act, int layout, Fragment[] fs) {
this.act = act;
this.layout = layout;
this.fs = fs;
}
public void selectItem(Fragment f){
fm = act.getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
//ft.replace(R.id.body,f);
ft.add(layout,f,"").commit();
}
public void setDefaultFragment(Fragment f) {
fm =act.getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.hide(fs[index]);
ft.show(f);
ft.commit();
}
public void hide(Fragment f) {
fm =act.getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.hide(f);
ft.commit();
}
}
@@ -0,0 +1,204 @@
package com.arpa.hndahesudintocctmsdriver.util.view;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.OvershootInterpolator;
import androidx.annotation.ColorRes;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import com.arpa.hndahesudintocctmsdriver.R;
public class CircularProgressView extends View {
private Paint mBackPaint, mProgPaint; // 绘制画笔
private RectF mRectF; // 绘制区域
private int[] mColorArray; // 圆环渐变色
private int mProgress; // 圆环进度(0-100)
public CircularProgressView(Context context) {
this(context, null);
}
public CircularProgressView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public CircularProgressView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
@SuppressLint("Recycle")
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CircularProgressView);
// 初始化背景圆环画笔
mBackPaint = new Paint();
mBackPaint.setStyle(Paint.Style.STROKE); // 只描边,不填充
mBackPaint.setStrokeCap(Paint.Cap.ROUND); // 设置圆角
mBackPaint.setAntiAlias(true); // 设置抗锯齿
mBackPaint.setDither(true); // 设置抖动
mBackPaint.setStrokeWidth(typedArray.getDimension(R.styleable.CircularProgressView_backWidth, 5));
mBackPaint.setColor(typedArray.getColor(R.styleable.CircularProgressView_backColor, Color.LTGRAY));
// 初始化进度圆环画笔
mProgPaint = new Paint();
mProgPaint.setStyle(Paint.Style.STROKE); // 只描边,不填充
mProgPaint.setStrokeCap(Paint.Cap.ROUND); // 设置圆角
mProgPaint.setAntiAlias(true); // 设置抗锯齿
mProgPaint.setDither(true); // 设置抖动
mProgPaint.setStrokeWidth(typedArray.getDimension(R.styleable.CircularProgressView_progWidth, 10));
mProgPaint.setColor(typedArray.getColor(R.styleable.CircularProgressView_progColor, Color.BLUE));
// 初始化进度圆环渐变色
int startColor = typedArray.getColor(R.styleable.CircularProgressView_progStartColor, -1);
int firstColor = typedArray.getColor(R.styleable.CircularProgressView_progFirstColor, -1);
if (startColor != -1 && firstColor != -1) mColorArray = new int[]{startColor, firstColor};
else mColorArray = null;
// 初始化进度
mProgress = typedArray.getInteger(R.styleable.CircularProgressView_progress, 0);
typedArray.recycle();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int viewWide = getMeasuredWidth() - getPaddingLeft() - getPaddingRight();
int viewHigh = getMeasuredHeight() - getPaddingTop() - getPaddingBottom();
int mRectLength = (int) ((viewWide > viewHigh ? viewHigh : viewWide) - (mBackPaint.getStrokeWidth() > mProgPaint.getStrokeWidth() ? mBackPaint.getStrokeWidth() : mProgPaint.getStrokeWidth()));
int mRectL = getPaddingLeft() + (viewWide - mRectLength) / 2;
int mRectT = getPaddingTop() + (viewHigh - mRectLength) / 2;
mRectF = new RectF(mRectL, mRectT, mRectL + mRectLength, mRectT + mRectLength);
// 设置进度圆环渐变色
if (mColorArray != null && mColorArray.length > 1)
mProgPaint.setShader(new LinearGradient(0, 0, 0, getMeasuredWidth(), mColorArray, null, Shader.TileMode.MIRROR));
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawArc(mRectF, 0, 360, false, mBackPaint);
canvas.drawArc(mRectF, 275, 360 * mProgress / 100, false, mProgPaint);
}
// ---------------------------------------------------------------------------------------------
/**
* 获取当前进度
*
* @return 当前进度(0-100
*/
public int getProgress() {
return mProgress;
}
/**
* 设置当前进度
*
* @param progress 当前进度(0-100
*/
public void setProgress(int progress) {
this.mProgress = progress;
invalidate();
}
/**
* 设置当前进度,并展示进度动画。如果动画时间小于等于0,则不展示动画
*
* @param progress 当前进度(0-100
* @param animTime 动画时间(毫秒)
*/
public void setProgress(int progress, long animTime) {
if (animTime <= 0) setProgress(progress);
else {
ValueAnimator animator = ValueAnimator.ofInt(mProgress, progress);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mProgress = (int) animation.getAnimatedValue();
invalidate();
}
});
animator.setInterpolator(new OvershootInterpolator());
animator.setDuration(animTime);
animator.start();
}
}
/**
* 设置背景圆环宽度
*
* @param width 背景圆环宽度
*/
public void setBackWidth(int width) {
mBackPaint.setStrokeWidth(width);
invalidate();
}
/**
* 设置背景圆环颜色
*
* @param color 背景圆环颜色
*/
public void setBackColor(@ColorRes int color) {
mBackPaint.setColor(ContextCompat.getColor(getContext(), color));
invalidate();
}
/**
* 设置进度圆环宽度
*
* @param width 进度圆环宽度
*/
public void setProgWidth(int width) {
mProgPaint.setStrokeWidth(width);
invalidate();
}
/**
* 设置进度圆环颜色
*
* @param color 景圆环颜色
*/
public void setProgColor(@ColorRes int color) {
mProgPaint.setColor(ContextCompat.getColor(getContext(), color));
mProgPaint.setShader(null);
invalidate();
}
/**
* 设置进度圆环颜色(支持渐变色)
*
* @param startColor 进度圆环开始颜色
* @param firstColor 进度圆环结束颜色
*/
public void setProgColor(@ColorRes int startColor, @ColorRes int firstColor) {
mColorArray = new int[]{ContextCompat.getColor(getContext(), startColor), ContextCompat.getColor(getContext(), firstColor)};
mProgPaint.setShader(new LinearGradient(0, 0, 0, getMeasuredWidth(), mColorArray, null, Shader.TileMode.MIRROR));
invalidate();
}
/**
* 设置进度圆环颜色(支持渐变色)
*
* @param colorArray 渐变色集合
*/
public void setProgColor(@ColorRes int[] colorArray) {
if (colorArray == null || colorArray.length < 2) return;
mColorArray = new int[colorArray.length];
for (int index = 0; index < colorArray.length; index++)
mColorArray[index] = ContextCompat.getColor(getContext(), colorArray[index]);
mProgPaint.setShader(new LinearGradient(0, 0, 0, getMeasuredWidth(), mColorArray, null, Shader.TileMode.MIRROR));
invalidate();
}
}
@@ -0,0 +1,22 @@
package com.arpa.hndahesudintocctmsdriver.util.view;
import android.content.Context;
public class DensityUtil {
/**
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
*/
public static int dip2px(Context context, float dpValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
/**
* 根据手机的分辨率从 px(像素) 的单位 转成为 dp
*/
public static int px2dip(Context context, float pxValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}
}
@@ -0,0 +1,11 @@
package com.arpa.hndahesudintocctmsdriver.util.view;
import android.content.Context;
import android.util.TypedValue;
public class PX_DP {
public static int getDp(int body,Context con){
return ((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, body,con.getResources().getDisplayMetrics()));
}
}
@@ -0,0 +1,23 @@
package com.arpa.hndahesudintocctmsdriver.util.view;
import android.content.Context;
import com.arpa.hndahesudintocctmsdriver.ui.login.LoginActivity;
import com.arpa.hndahesudintocctmsdriver.util.sp.SPUtil;
/**
* @author hlh
* @version 1.0.0
* @date 2021/8/2 10:33
* @description:判断事件的工具
*/
public class PanDuanUtil {
public static boolean isLogin(Context con){
String token=SPUtil.getSP(con, LoginActivity.USER,LoginActivity.USER_TOKEN);
if(token.equals("")){
return false;
}
return true;
}
}
@@ -0,0 +1,120 @@
package com.arpa.hndahesudintocctmsdriver.util.view;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import com.arpa.hndahesudintocctmsdriver.R;
/**
* @author hlh
* @version 1.0.0
* @date 2021/8/7 15:46
* @description:评分view
*/
public class ScoreView extends LinearLayout {
private ImageButton[] xings=new ImageButton[5];
private int score=0;
private boolean upKey=true;
public ScoreView(Context context) {
super(context);
}
public ScoreView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public ScoreView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public ScoreView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
public void initView(){
this.setOrientation(LinearLayout.HORIZONTAL);
View v=inflate(getContext(),R.layout.item_view_score,null);
xings[0]=v.findViewById(R.id.xing1);
xings[1]=v.findViewById(R.id.xing2);
xings[2]=v.findViewById(R.id.xing3);
xings[3]=v.findViewById(R.id.xing4);
xings[4]=v.findViewById(R.id.xing5);
xings[0].setOnClickListener(v1 -> {
switchClick(0);
});
xings[1].setOnClickListener(v1 -> {
switchClick(1);
});
xings[2].setOnClickListener(v1 -> {
switchClick(2);
});
xings[3].setOnClickListener(v1 -> {
switchClick(3);
});
xings[4].setOnClickListener(v1 -> {
switchClick(4);
});
this.addView(v);
}
public void switchClick(int i){
if (upKey) {
for(int j=0;j<xings.length;j++){
Log.e("-j-",j+"");
xings[j].setImageResource(R.mipmap.xingxing0);
}
switch (i){
case 4:
xings[4].setImageResource(R.mipmap.xingxing);
xings[3].setImageResource(R.mipmap.xingxing);
xings[2].setImageResource(R.mipmap.xingxing);
xings[1].setImageResource(R.mipmap.xingxing);
xings[0].setImageResource(R.mipmap.xingxing);
score=5;
break;
case 3:
xings[3].setImageResource(R.mipmap.xingxing);
xings[2].setImageResource(R.mipmap.xingxing);
xings[1].setImageResource(R.mipmap.xingxing);
xings[0].setImageResource(R.mipmap.xingxing);
score=4;
break;
case 2:
xings[2].setImageResource(R.mipmap.xingxing);
xings[1].setImageResource(R.mipmap.xingxing);
xings[0].setImageResource(R.mipmap.xingxing);
score=3;
break;
case 1:
xings[1].setImageResource(R.mipmap.xingxing);
xings[0].setImageResource(R.mipmap.xingxing);
score=2;
break;
case 0:
xings[0].setImageResource(R.mipmap.xingxing);
score=1;
break;
default:break;
}
}
}
public int getScore() {
return score;
}
public void setScore(int s){
switchClick(s-1);
}
public void setUpKey(boolean upKey) {
this.upKey = upKey;
}
}
@@ -0,0 +1,35 @@
package com.arpa.hndahesudintocctmsdriver.util.view;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import java.util.List;
public class TabUtil extends FragmentPagerAdapter {
private List<Fragment> fs;
private List<String> titles;
public TabUtil(FragmentManager fm, List<Fragment> fs, List<String> titles){
super(fm);
this.fs=fs;
this.titles=titles;
}
@NonNull
@Override
public Fragment getItem(int position) {
return fs.get(position);
}
@Override
public int getCount() {
return fs.size();
}
@Override
public CharSequence getPageTitle(int position) {
return titles.get(position);
}
}
@@ -0,0 +1,31 @@
package com.arpa.hndahesudintocctmsdriver.util.view;
public class Table {
private String body;
private int weight;
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public Table(String body, int weight) {
this.body = body;
this.weight = weight;
}
public Table() {
}
}