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();
|
}
|
|
|
}
|
|
}
|