BaseActvity: 采用 装饰着模式进行解耦 各司其职
decorater都是 BaseActvity的父类
Pop_Zone(生命周期化):使用起来更简单
https://github.com/luhaoaimama1/ZoneStudio/blob/master/Android_Zone_Lib/src/and/base/Pop_Zone.java
使用方式
public class Pop_Bottom extends Pop_Zone implements OnClickListener{
private Button bt_how,bt_are,bt_you;
private Activity context;
public Pop_Bottom(Activity activity,int showAtLocationViewId) {
super(activity, showAtLocationViewId);
this.context=activity;
setPopContentView(R.layout.pop_bottom, Mode.Wrap, -1);
}
@Override
protected void findView(View mMenuView) {
bt_how=(Button) mMenuView.findViewById(R.id.bt_how);
bt_are=(Button) mMenuView.findViewById(R.id.bt_are);
bt_you=(Button) mMenuView.findViewById(R.id.bt_you);
}
@Override
protected void initData() {
}
@Override
protected void setListener() {
bt_how.setOnClickListener(this);
bt_are.setOnClickListener(this);
bt_you.setOnClickListener(this);
}
@Override
protected void setLocation(View view) {
this.showAsDropDown(view,0, 0);
}
@Override
public void onClick(View v) {
ToastUtils.showLong(context, "嘿嘿");
dismiss();
}
}
Fragment_Lazy懒加载:(viewpager与 hide show那种兼容)
FragmentSwitcher:fragment切换器
使用方式
public class FramentSwitchAcitiviy extends FragmentActivity implements OnClickListener{
private FragmentSwitcher fragmentSwitcher;
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
setContentView(R.layout.a_frament_switch_test);
fragmentSwitcher=new FragmentSwitcher(this, R.id.framelayout);
fragmentSwitcher.setPriDefaultAnimal(android.R.anim.fade_in,android.R.anim.fade_out);
// fragmentSwitcher.initFragment(Tab1.class, Tab2.class, Tab3.class);
Tab2 tab2 = new Tab2();
Bundle bundle = new Bundle();
bundle.putString("mode", "normal");
tab2.setArguments(bundle);
fragmentSwitcher.initFragment(new Tab1(),tab2, new Tab3());
fragmentSwitcher.switchToNull();
// fragmentSwitcher.switchPage(0);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.open1:
fragmentSwitcher.switchPage(0);
break;
case R.id.open2:
fragmentSwitcher.switchPage(1);
break;
case R.id.open3:
fragmentSwitcher.switchPage(2);
break;
case R.id.open4:
fragmentSwitcher.switchToNull();
break;
default:
break;
}
}
}
FeaturesDecorater :采用 订阅这模式进行解耦
主要解决了:onActivityResult的问题
使用方式
public class Photo_Shot_MainActivity extends BaseActvity implements OnClickListener{
private Feature_Pic feature_Pic;
@Override
public void setContentView() {
System.err.println("Photo_Shot_MainActivity setContentView");
setContentView(R.layout.a_photo_shot);
}
@Override
public void findIDs() {
}
@Override
public void initData() {
}
@Override
public void setListener() {
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.shot:
feature_Pic.openCamera();
break;
case R.id.photo:
feature_Pic.openPhotos();
break;
case R.id.clip:
startActivity(new Intent(this,ClipTest.class));
break;
default:
break;
}
}
@Override
protected void initFeature() {
feature_Pic = new Feature_Pic(this) {
@Override
protected void getReturnedPicPath(String path) {
System.out.println(path);
Intent intent = new Intent(Photo_Shot_MainActivity.this,ShowPicActivity.class);
Uri uri = Uri.parse(path);
intent.setData(uri);
startActivity(intent);
}
};
addFeature(feature_Pic);
}
}
ReflectCloneUtils:深克隆任何对象
- 暂时支持 object 类 ,基础类型, 基础类型的封装类, list, Map
- static 克隆不改变既不赋值
- TODO final 暂时不会管 异常再说
- 简单的枚举支持 太深层的表示没考虑过
MeasureUtils:
measure:在oncreate里测量控件的大小
measureImage:这个返回 既最后展现imageview show的宽高与位置(经过scaleType marix处理后的)
measure使用方式
MeasureUtils.measure(imageGroup_zone,
ListenerState.MEASURE_REMOVE, new OnMeasureListener() {
@Override
public void measureResult(View v, int viewWidth,
int viewHeight) {
imageGroup_zone.setBackgroundColor(Color.WHITE);
for (int i = 0; i < imageGroup_zone.getChildCount(); i++) {
imageGroup_zone.getChild_ChildPro(i).iv.setBackgroundColor(colorArray[i % 4]);
}
}
});
measureImage使用方式
MeasureUtils.measureImage(iv, new MeasureUtils.ImageListener() {
@Override
public void imageShowProperty(ImageView iv,float left, float top, int imageShowX, int imageShowY) {
System.out.println("scaleType :"+iv.getScaleType()+"\t left:"+left+" \ttop:"+top+" \timageShowX:"+imageShowX+"\timageShowY:"+imageShowY);
}
});
时间: 2024-10-25 19:18:32