admin
2022-08-09 399ac289f80b7a40aa4210341db6b447cacdcf14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
package com.tejia.lijin.app.ui.recommend;
 
 
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
 
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.umeng.analytics.MobclickAgent;
import com.wpc.library.util.common.DimenUtils;
import com.tejia.lijin.app.BasicTextHttpResponseHandler;
import com.tejia.lijin.app.R;
import com.tejia.lijin.app.ShoppingApi;
import com.tejia.lijin.app.entity.share.SingleGoodsShareInfo;
import com.tejia.lijin.app.ui.BaseFragmentActivity;
import com.tejia.lijin.app.ui.invite.ShareBrowserActivity;
import com.tejia.lijin.app.ui.recommend.singleshare.FastShareFragment;
import com.tejia.lijin.app.ui.recommend.singleshare.SingleImageShareFragment;
import com.tejia.lijin.app.ui.subview.NoScrollViewPager;
import com.tejia.lijin.app.util.ToolUtil;
import com.tejia.lijin.app.util.TopStatusSettings;
 
import org.apache.http.Header;
import org.json.JSONObject;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * 商品详情创建分享
 */
public class ShareGoodsImageActivity31 extends BaseFragmentActivity implements View.OnClickListener {
 
    //导航栏
    private TextView tv_left, tv_middle, tv_right;
    private ImageView iv_right;
 
    //类型选择
    private TextView tv_single_img, tv_multiple_img, tv_fast_img;
    private FrameLayout fl_single_img, fl_multiple_img, fl_fast_img;
    private View v_single, v_multiple, v_fast;
 
    //小黄条
    private LinearLayout ll_notice;//小黄条
    private ImageView iv_close;
    private TextView tv_notice_content;
 
 
    private SingleGoodsShareInfo shareInfo;//分享信息
 
    private NoScrollViewPager vp_share_single;
 
 
    private DisplayImageOptions options;
    boolean isSingle = true;
 
 
 
    int isCheck = 0;
    private String TYPE = "shareSingle";// 小黄条type
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_share_goods_img);
        TopStatusSettings.setStatusViewAndDeepColor(this);
        initView();
        addListener();
//        getAppPageNotification();//小黄条
 
        init();
    }
 
    private void init() {
        setRecommend(false);
        vp_share_single.setAdapter(new MyPagerAdapter(getSupportFragmentManager(), shareInfo));
        vp_share_single.setOffscreenPageLimit(3);
        setShareMode(0);
    }
 
    /*************小黄条*******/
    private void getAppPageNotification() {
        ShoppingApi.getAppPageNotification(this, TYPE, new BasicTextHttpResponseHandler() {
            @Override
            public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                ToolUtil.setAppPageNotification(ll_notice, tv_notice_content, iv_close, jsonObject);
            }
        });
    }
 
    private void initView() {
        ll_notice = findViewById(R.id.ll_notice);
        tv_notice_content = findViewById(R.id.tv_notice_content);
        iv_close = findViewById(R.id.iv_close);
        tv_left = findViewById(R.id.tv_top_bar_left);
        tv_middle = findViewById(R.id.tv_top_bar_middle);
        iv_right = findViewById(R.id.iv_top_bar_right);
        iv_right.setVisibility(View.GONE);
 
        tv_fast_img = findViewById(R.id.tv_fast_img);
        fl_fast_img = findViewById(R.id.fl_fast_img);
        v_fast = findViewById(R.id.v_fast);
 
        tv_single_img = findViewById(R.id.tv_single_img);
        v_single = findViewById(R.id.v_single);
        fl_single_img = findViewById(R.id.fl_single_img);
 
        tv_multiple_img = findViewById(R.id.tv_multiple_img);
        fl_multiple_img = findViewById(R.id.fl_multiple_img);
        v_multiple = findViewById(R.id.v_multiple);
 
 
        vp_share_single = findViewById(R.id.vp_share_single);
 
        this.options = new DisplayImageOptions.Builder()
                .showImageForEmptyUri(R.drawable.ic_goods_default)
                .showImageOnFail(R.drawable.ic_goods_default)
                .showImageOnLoading(R.drawable.ic_goods_default)
                .resetViewBeforeLoading(false).cacheInMemory(true)
                .cacheOnDisk(true).imageScaleType(ImageScaleType.EXACTLY)
                .considerExifParams(true)
                .build();
        shareInfo = (SingleGoodsShareInfo) getIntent().getSerializableExtra("shareInfo");
        tv_middle.setText("创建分享");
    }
 
 
    private void addListener() {
        tv_left.setOnClickListener(this);
        iv_right.setOnClickListener(this);
        fl_single_img.setOnClickListener(this);
        fl_multiple_img.setOnClickListener(this);
        fl_fast_img.setOnClickListener(this);
    }
 
    @Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }
 
    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
    }
 
 
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_top_bar_left:
                finish();
                break;
            case R.id.iv_top_bar_right:
                Intent intent = new Intent(ShareGoodsImageActivity31.this, ShareBrowserActivity.class);
                intent.putExtra("url", shareInfo.getRule());
                startActivity(intent);
                break;
 
            case R.id.fl_fast_img:
                setShareMode(0);
                break;
 
            case R.id.fl_single_img:
                setShareMode(1);
                break;
            case R.id.fl_multiple_img:
                setShareMode(2);
                break;
            default:
                break;
        }
    }
 
    /**
     * 分享模式 展示与隐藏相关控件
     *
     * @param mode
     */
    private void setShareMode(int mode) {
        Drawable drawable0_0 = getResources().getDrawable(R.drawable.ic_fast_img_unselect);
        drawable0_0.setBounds(0, 0, DimenUtils.dip2px(getApplicationContext(), 19), DimenUtils.dip2px(getApplicationContext(), 17));
 
        Drawable drawable1_0 = getResources().getDrawable(R.drawable.ic_single_img_unselect);
        drawable1_0.setBounds(0, 0, DimenUtils.dip2px(getApplicationContext(), 19), DimenUtils.dip2px(getApplicationContext(), 17));
 
        Drawable drawable2_0 = getResources().getDrawable(R.drawable.ic_multiple_img_unselect);
        drawable2_0.setBounds(0, 0, DimenUtils.dip2px(getApplicationContext(), 19), DimenUtils.dip2px(getApplicationContext(), 17));
 
        //初始化
        tv_fast_img.setTextColor(getResources().getColor(R.color.text_black_2));
        tv_fast_img.setCompoundDrawables(
                drawable0_0, null, null, null);
        v_fast.setVisibility(View.GONE);
 
        tv_single_img.setTextColor(getResources().getColor(R.color.text_black_2));
        tv_single_img.setCompoundDrawables(
                drawable1_0, null, null, null);
        v_single.setVisibility(View.GONE);
 
        tv_multiple_img.setTextColor(getResources().getColor(R.color.text_black_2));
        tv_multiple_img.setCompoundDrawables(
                drawable2_0, null, null, null);
        v_multiple.setVisibility(View.GONE);
 
 
        switch (mode) {
            case 0:
                Drawable drawable0 = getResources().getDrawable(R.drawable.ic_fast_img_selected);
                drawable0.setBounds(0, 0, DimenUtils.dip2px(getApplicationContext(), 19), DimenUtils.dip2px(getApplicationContext(), 17));
                tv_fast_img.setTextColor(getResources().getColor(R.color.theme));
                tv_fast_img.setCompoundDrawables(drawable0, null, null, null);
                v_fast.setVisibility(View.VISIBLE);
                break;
            case 1:
                Drawable drawable1 = getResources().getDrawable(R.drawable.ic_single_img_selected);
                drawable1.setBounds(0, 0, DimenUtils.dip2px(getApplicationContext(), 19), DimenUtils.dip2px(getApplicationContext(), 17));
                tv_single_img.setTextColor(getResources().getColor(R.color.theme));
                tv_single_img.setCompoundDrawables(drawable1, null, null, null);
                v_single.setVisibility(View.VISIBLE);
                break;
            case 2:
                Drawable drawable2 = getResources().getDrawable(R.drawable.ic_multiple_img_selected);
                drawable2.setBounds(0, 0, DimenUtils.dip2px(getApplicationContext(), 19), DimenUtils.dip2px(getApplicationContext(), 17));
                tv_multiple_img.setTextColor(getResources().getColor(R.color.theme));
                tv_multiple_img.setCompoundDrawables(drawable2, null, null, null);
                v_multiple.setVisibility(View.VISIBLE);
                break;
        }
        vp_share_single.setCurrentItem(mode);
    }
 
 
    @Override
    protected void onPause() {
        super.onPause();
    }
 
    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
 
 
    class MyPagerAdapter extends FragmentPagerAdapter {
        List<Fragment> mList = new ArrayList<>();
 
        public MyPagerAdapter(FragmentManager fm, SingleGoodsShareInfo info) {
            super(fm);
            mList.add(new FastShareFragment());
            mList.add(new SingleImageShareFragment());
//            mList.add(new MultiImageShareFragment());
            for (Fragment fragment : mList) {
                Bundle bundle = new Bundle();
                bundle.putSerializable("shareInfo", info);
                fragment.setArguments(bundle);
            }
        }
 
        @Override
        public Fragment getItem(int position) {
            return mList.get(position);
        }
 
        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            return super.instantiateItem(container, position);
        }
 
        @Override
        public int getCount() {
            return mList.size();
        }
 
 
    }
 
}