价格设置页

chengzhenyu 8 年之前
父节点
当前提交
25c4c82329

+ 1 - 1
app/build.gradle

@@ -49,7 +49,7 @@ android {
49 49
             zipAlignEnabled false
50 50
             minifyEnabled false
51 51
             shrinkResources false
52
-            buildConfigField "boolean", "isTestMode", "false"
52
+            buildConfigField "boolean", "isTestMode", "true"
53 53
             signingConfig signingConfigs.releaseConfig
54 54
         }
55 55
     }

+ 38 - 2
app/src/main/java/ai/pai/lensman/activities/PriceSettingActivity.java

@@ -11,8 +11,11 @@ import android.widget.TextView;
11 11
 import android.widget.Toast;
12 12
 
13 13
 import com.android.common.executors.ThreadExecutor;
14
+import com.android.common.utils.LogHelper;
14 15
 import com.android.common.utils.NetworkUtil;
15 16
 
17
+import org.json.JSONObject;
18
+
16 19
 import java.util.HashMap;
17 20
 
18 21
 import ai.pai.lensman.R;
@@ -33,9 +36,12 @@ public class PriceSettingActivity extends BaseActivity implements View.OnClickLi
33 36
         super.onCreate(savedInstanceState);
34 37
         setContentView(R.layout.activity_price_setting);
35 38
         SystemUtils.setImmerseLayout(this,findViewById(R.id.title_layout));
39
+        int nomark = getIntent().getIntExtra("nomark",0);
40
+        int origin = getIntent().getIntExtra("origin",0);
36 41
         TextView title = (TextView)findViewById(R.id.title_bar_middle_txt);
37 42
         title.setText(R.string.price_manage);
38 43
         originPriceET = (EditText)findViewById(R.id.et_price_origin);
44
+        originPriceET.setText(String.valueOf(origin));
39 45
         originPriceET.addTextChangedListener(new TextWatcher() {
40 46
             @Override
41 47
             public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@@ -54,6 +60,7 @@ public class PriceSettingActivity extends BaseActivity implements View.OnClickLi
54 60
         });
55 61
 
56 62
         noPrintPriceET = (EditText)findViewById(R.id.et_price_no_waterprint);
63
+        noPrintPriceET.setText(String.valueOf(nomark));
57 64
         noPrintPriceET.addTextChangedListener(new TextWatcher() {
58 65
             @Override
59 66
             public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@@ -109,10 +116,39 @@ public class PriceSettingActivity extends BaseActivity implements View.OnClickLi
109 116
         if(userId.length()==0){
110 117
             return;
111 118
         }
119
+        sendBtn.setEnabled(false);
112 120
         params.put("user_id",userId);
113 121
         params.put("nomark",noMarkPrice);
114 122
         params.put("origin",originPrice);
115
-        new HttpPostTask(params).executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), UrlContainer.PRICE_FIX_URL);
116
-        finish();
123
+        new HttpPostTask(params){
124
+            @Override
125
+            protected boolean parseResponse(String response) {
126
+                LogHelper.d(TAG,"PriceSettingActivity get response string = "+response);
127
+                try{
128
+                    JSONObject json = new JSONObject(response);
129
+                    int status = json.getInt("status");
130
+                    if(status == 200){
131
+                        return true;
132
+                    }
133
+                }catch (Exception e){
134
+                    e.printStackTrace();
135
+                }
136
+                return false;
137
+            }
138
+
139
+            @Override
140
+            protected void onPostSuccess() {
141
+                super.onPostSuccess();
142
+                sendBtn.setEnabled(true);
143
+                Toast.makeText(PriceSettingActivity.this,R.string.set_price_success,Toast.LENGTH_SHORT).show();
144
+            }
145
+
146
+            @Override
147
+            protected void onPostFail() {
148
+                super.onPostFail();
149
+                sendBtn.setEnabled(true);
150
+                Toast.makeText(PriceSettingActivity.this,R.string.set_price_fail,Toast.LENGTH_SHORT).show();
151
+            }
152
+        }.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), UrlContainer.PRICE_FIX_URL);
117 153
     }
118 154
 }

+ 9 - 5
app/src/main/java/ai/pai/lensman/briefs/BriefsActivity.java

@@ -12,7 +12,6 @@ import android.widget.TextView;
12 12
 import android.widget.ViewSwitcher;
13 13
 
14 14
 import ai.pai.lensman.R;
15
-import ai.pai.lensman.activities.PriceSettingActivity;
16 15
 import ai.pai.lensman.activities.WebViewActivity;
17 16
 import ai.pai.lensman.base.BaseActivity;
18 17
 import ai.pai.lensman.bean.BriefsBean;
@@ -27,7 +26,7 @@ public class BriefsActivity extends BaseActivity implements BriefsContract.View{
27 26
     @BindView(R.id.tv_today_upload_num)     TextView todayUploadNumText;
28 27
     @BindView(R.id.tv_today_point_amount)   TextView todayPointAmountText;
29 28
     @BindView(R.id.tv_week_origin_sold_num) TextView weekOriginSoldNumText;
30
-    @BindView(R.id.tv_week_point_amount)    TextView weekPotinAmountText;
29
+    @BindView(R.id.tv_week_point_amount)    TextView weekPointAmountText;
31 30
     @BindView(R.id.switcher_order_msg)      TextSwitcher orderMsgSwitch;
32 31
     @BindView(R.id.switcher_system_msg)     TextSwitcher systemMsgSwitch;
33 32
     @BindView(R.id.tv_box_num)              TextView boxNumText;
@@ -55,7 +54,6 @@ public class BriefsActivity extends BaseActivity implements BriefsContract.View{
55 54
         orderMsgSwitch.setFactory(factory);
56 55
         systemMsgSwitch.setFactory(factory);
57 56
         presenter = new BriefsPresenter(this,this);
58
-        presenter.start();
59 57
     }
60 58
 
61 59
     @OnClick(R.id.switcher_order_msg)
@@ -80,7 +78,7 @@ public class BriefsActivity extends BaseActivity implements BriefsContract.View{
80 78
 
81 79
     @OnClick(R.id.layout_price_setting)
82 80
     void goToSetPrice(){
83
-        startActivity(new Intent(this, PriceSettingActivity.class));
81
+        presenter.clickSettingPrice();
84 82
     }
85 83
 
86 84
     @OnClick(R.id.layout_price_introduction)
@@ -92,6 +90,12 @@ public class BriefsActivity extends BaseActivity implements BriefsContract.View{
92 90
     }
93 91
 
94 92
     @Override
93
+    protected void onResume() {
94
+        super.onResume();
95
+        presenter.start();
96
+    }
97
+
98
+    @Override
95 99
     protected void onDestroy() {
96 100
         super.onDestroy();
97 101
         presenter.stop();
@@ -100,7 +104,7 @@ public class BriefsActivity extends BaseActivity implements BriefsContract.View{
100 104
     @Override
101 105
     public void updateUserInfo(BriefsBean bean) {
102 106
         todayUploadNumText.setText(String.valueOf(bean.todayUpload));
103
-        weekPotinAmountText.setText(String.valueOf(bean.weekIncome));
107
+        weekPointAmountText.setText(String.valueOf(bean.weekIncome));
104 108
         todayPointAmountText.setText(String.valueOf(bean.todayIncome));
105 109
         weekOriginSoldNumText.setText(String.valueOf(bean.weekSold));
106 110
     }

+ 1 - 0
app/src/main/java/ai/pai/lensman/briefs/BriefsContract.java

@@ -19,6 +19,7 @@ public class BriefsContract {
19 19
     public interface Presenter extends BasePresenter{
20 20
         void clickCurrentOrderMsg();
21 21
         void clickCurrentSysMsg();
22
+        void clickSettingPrice();
22 23
     }
23 24
 
24 25
 

+ 9 - 0
app/src/main/java/ai/pai/lensman/briefs/BriefsPresenter.java

@@ -11,6 +11,7 @@ import java.util.TimerTask;
11 11
 
12 12
 import ai.pai.lensman.App;
13 13
 import ai.pai.lensman.R;
14
+import ai.pai.lensman.activities.PriceSettingActivity;
14 15
 import ai.pai.lensman.activities.WebViewActivity;
15 16
 import ai.pai.lensman.base.BaseInteractor;
16 17
 import ai.pai.lensman.bean.BriefsBean;
@@ -129,4 +130,12 @@ public class BriefsPresenter implements BriefsContract.Presenter,BaseInteractor.
129 130
         intent.putExtra("title",currentSystemMsg.title);
130 131
         context.startActivity(intent);
131 132
     }
133
+
134
+    @Override
135
+    public void clickSettingPrice() {
136
+        Intent intent = new Intent(context, PriceSettingActivity.class);
137
+        intent.putExtra("origin",briefsBean.originPrice);
138
+        intent.putExtra("nomark",briefsBean.noMarkPrice);
139
+        context.startActivity(intent);
140
+    }
132 141
 }

+ 1 - 1
app/src/main/java/ai/pai/lensman/utils/UrlContainer.java

@@ -65,7 +65,7 @@ public class UrlContainer {
65 65
      */
66 66
     public static final String PRICE_FIX_URL = HOST_URL+"l/price_fix";
67 67
 
68
-    public static final String PLATFORM_PRICE_RULES_PAGE_URL = "http://www.baidu.com";
68
+    public static final String PLATFORM_PRICE_RULES_PAGE_URL = "http://pai.ai/page/price";
69 69
 
70 70
 
71 71
 }

+ 63 - 23
app/src/main/res/layout/activity_price_setting.xml

@@ -10,44 +10,84 @@
10 10
         android:layout_width="match_parent"
11 11
         android:layout_height="wrap_content"
12 12
         android:background="@color/colorPrimaryDark">
13
+
13 14
         <include layout="@layout/title_bar_with_back_and_option" />
14 15
     </RelativeLayout>
15 16
 
16
-    <EditText
17
-        android:id="@+id/et_price_origin"
17
+    <LinearLayout
18 18
         android:layout_width="match_parent"
19
-        android:textSize="14sp"
20
-        android:textColorHint="@color/grey"
21
-        android:background="@color/white"
22
-        android:textColor="@color/dark_grey"
23
-        android:hint="@string/input_origin_price"
24
-        android:paddingLeft="12dp"
19
+        android:layout_height="44dp"
25 20
         android:gravity="center_vertical"
26
-        android:layout_height="44dp" />
21
+        android:background="@color/white"
22
+        android:orientation="horizontal">
23
+
24
+        <TextView
25
+            android:layout_width="0dp"
26
+            android:layout_height="match_parent"
27
+            android:layout_weight="1"
28
+            android:gravity="center_vertical"
29
+            android:paddingLeft="12dp"
30
+            android:text="@string/input_origin_price"
31
+            android:textColor="@color/grey"
32
+            android:textSize="14sp" />
33
+
34
+        <EditText
35
+            android:id="@+id/et_price_origin"
36
+            android:layout_width="80dp"
37
+            android:layout_height="38dp"
38
+            android:gravity="center"
39
+            android:inputType="number"
40
+            android:background="@color/background_light_grey_color"
41
+            android:layout_marginLeft="12dp"
42
+            android:layout_marginRight="24dp"
43
+            android:textColor="@color/dark_grey"
44
+            android:textSize="14sp" />
27 45
 
28
-    <EditText
29
-        android:id="@+id/et_price_no_waterprint"
46
+    </LinearLayout>
47
+
48
+
49
+    <LinearLayout
30 50
         android:layout_width="match_parent"
31
-        android:textSize="14sp"
32
-        android:textColorHint="@color/grey"
33
-        android:background="@color/white"
34
-        android:textColor="@color/dark_grey"
35
-        android:hint="@string/input_no_water_print_price"
36
-        android:layout_marginTop="8dp"
37
-        android:paddingLeft="12dp"
51
+        android:layout_height="44dp"
38 52
         android:gravity="center_vertical"
39
-        android:layout_height="44dp" />
53
+        android:background="@color/white"
54
+        android:orientation="horizontal">
55
+
56
+        <TextView
57
+            android:layout_width="0dp"
58
+            android:layout_height="match_parent"
59
+            android:layout_weight="1"
60
+            android:gravity="center_vertical"
61
+            android:paddingLeft="12dp"
62
+            android:text="@string/input_no_water_print_price"
63
+            android:textColor="@color/grey"
64
+            android:textSize="14sp" />
65
+
66
+        <EditText
67
+            android:id="@+id/et_price_no_waterprint"
68
+            android:layout_width="80dp"
69
+            android:layout_height="38dp"
70
+            android:gravity="center"
71
+            android:inputType="number"
72
+            android:background="@color/background_light_grey_color"
73
+            android:layout_marginLeft="12dp"
74
+            android:layout_marginRight="24dp"
75
+            android:textColor="@color/dark_grey"
76
+            android:textSize="14sp"/>
77
+
78
+    </LinearLayout>
79
+
40 80
 
41 81
     <Button
42 82
         android:id="@+id/btn_price_setting"
43 83
         android:layout_width="match_parent"
44 84
         android:layout_height="48dp"
45 85
         android:layout_marginTop="30dp"
46
-        android:textColor="@color/white"
47
-        android:textSize="20sp"
48
-        android:enabled="false"
49 86
         android:background="@drawable/send_btn_bg_selector"
50
-        android:text="@string/ok"/>
87
+        android:enabled="false"
88
+        android:text="@string/ok"
89
+        android:textColor="@color/white"
90
+        android:textSize="20sp" />
51 91
 
52 92
 
53 93
 </LinearLayout>

+ 4 - 0
app/src/main/res/values/strings.xml

@@ -153,4 +153,8 @@
153 153
     <string name="new_order_and_check_box">您后台有新的订单,请检查box是否连接</string>
154 154
 
155 155
     <string name="fixed_price">高清图 ¥ %1$s 去水印 ¥ %2$s</string>
156
+
157
+    <string name="set_price_success">价格设置成功</string>
158
+
159
+    <string name="set_price_fail">价格设置失败,请重试</string>
156 160
 </resources>