ソースを参照

Merge remote-tracking branch 'origin/master'

luanxuye 5 年 前
コミット
69fe41da76

+ 15 - 0
base_library/src/main/java/com/mgtech/base_library/custom/MyTitleView.java

@@ -12,6 +12,7 @@ import android.widget.ImageView;
 import android.widget.TextView;
 
 import androidx.constraintlayout.widget.ConstraintLayout;
+import androidx.constraintlayout.widget.ConstraintSet;
 
 import com.mgtech.base_library.R;
 import com.mgtech.base_library.util.DrawableUtil;
@@ -40,6 +41,7 @@ public class MyTitleView extends ConstraintLayout implements View.OnClickListene
     protected RightTextClickListener rightTextClickListener;
 
     private Context context;
+    private ConstraintSet constraintSet;
 
     public MyTitleView(Context context) {
         this(context,null);
@@ -80,11 +82,24 @@ public class MyTitleView extends ConstraintLayout implements View.OnClickListene
         rightImage.setImageResource(typedArray.getResourceId(R.styleable.MyTitleView_right_image, 0));
         titleText.setTextColor(typedArray.getColor(R.styleable.MyTitleView_title_text_color, Color.BLACK));
         centerImage.setBackground(typedArray.getDrawable(R.styleable.MyTitleView_center_image));
+        setConstraintSet(typedArray.getInt(R.styleable.MyTitleView_title_text_gravity,0));
         typedArray.recycle();
         leftImage.setOnClickListener(this);
         rightImage.setOnClickListener(this);
         rightText.setOnClickListener(this);
     }
+
+
+    private void setConstraintSet(int type){
+        if (type == 0)
+            return;
+        if (constraintSet == null)
+            constraintSet = new ConstraintSet();
+        constraintSet.clone(bgLayout);
+        constraintSet.connect(R.id.title_text,ConstraintSet.END,R.id.right_image,ConstraintSet.START);
+        constraintSet.applyTo(bgLayout);
+    }
+
     @Override
     public void onClick(View view) {
         int i = view.getId();

+ 1 - 1
base_library/src/main/java/com/mgtech/base_library/util/GoogleLocationUtil.java

@@ -45,7 +45,7 @@ public class GoogleLocationUtil {
 
     private final long MIN_TIME = 10 * 60 * 1000L;
     private final float MIN_DISTANCE = 200F;
-    private final int REQUEST_LOCATION = 999;
+    public final int REQUEST_LOCATION = 999;
     private MyLocationListener myLocationListener = new MyLocationListener();
     private LocationManager locationManager;
 

+ 4 - 0
base_library/src/main/res/values/attrs.xml

@@ -10,6 +10,10 @@
         <attr name="center_image" format="reference"/>
         <attr name="title_right_text_color" format="color"/>
         <attr name="title_right_text_size" format="dimension"/>
+        <attr name="title_text_gravity">
+            <flag name="left" value="0" />
+            <flag name="center" value="1" />
+        </attr>
     </declare-styleable>
 
     <declare-styleable name="SwitchView">