| | |
| | | android:value="570f28a578d6e12cba6f7f200b8d1c83"></meta-data> |
| | | <meta-data |
| | | android:name="UMENG_CHANNEL" |
| | | android:value="qq"></meta-data> |
| | | android:value="vivo"></meta-data> |
| | | |
| | | |
| | | <provider |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <set xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | <scale |
| | | android:duration="200" |
| | | android:fromXScale="0.1" |
| | | android:fromYScale="0.1" |
| | | android:pivotX="50%" |
| | | android:pivotY="50%" |
| | | android:toXScale="1" |
| | | android:toYScale="1" /> |
| | | |
| | | </set> |
| | |
| | | android:layout_height="match_parent" |
| | | android:layout_gravity="left|center_vertical" |
| | | android:layout_marginLeft="5dp" |
| | | android:textSize="12sp" |
| | | android:textSize="15sp" |
| | | android:gravity="center_vertical" |
| | | android:textColor="#787878"></TextView> |
| | | </LinearLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | xmlns:tools="http://schemas.android.com/tools" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:orientation="vertical" |
| | | tools:ignore="MissingDefaultResource"> |
| | | |
| | | <com.lcjian.library.widget.ResizableImageView |
| | | android:id="@+id/iv_img" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_centerInParent="true" |
| | | android:layout_gravity="center_horizontal" |
| | | android:layout_marginLeft="20dp" |
| | | android:layout_marginTop="-20dp" |
| | | android:layout_marginRight="20dp" |
| | | android:scaleType="fitXY" /> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_close" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_below="@id/iv_img" |
| | | android:layout_centerHorizontal="true" |
| | | android:layout_marginTop="20dp" |
| | | android:src="@drawable/ic_close" /> |
| | | |
| | | </RelativeLayout> |
| | |
| | | asyncHttpClient.setURLEncodingEnabled(false); |
| | | syncHttpClient.setURLEncodingEnabled(false); |
| | | sortTimeAsyncHttpClient.setURLEncodingEnabled(false); |
| | | |
| | | } |
| | | |
| | | public static void getUid(Context context, String channel, String device, |
| | |
| | | */ |
| | | public static void getConfig(Context context, |
| | | ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<>(); |
| | | params.put("Method", "getConfig"); |
| | | if (!StringUtils.isBlank(BeibeiVideoApplication.deviceNumber)) { |
| | | params.put("DeviceName", BeibeiVideoApplication.deviceName); |
| | | params.put("DeviceNumber", BeibeiVideoApplication.deviceNumber); |
| | | } |
| | | commonPost(context, BASE_URL + "config", params, null, handler, true, true); |
| | | } |
| | | |
| | | |
| | | public static void getHomeConfig(Context context, |
| | | ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<>(); |
| | | params.put("Method", "getHomeConfig"); |
| | | commonPost(context, BASE_URL + "config", params, null, handler, true, true); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | public static void getBaiDuNewsTypeList(Context context, |
| | | ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<>(); |
| | | params.put("Method", "getNewsTypeList"); |
| | | commonPost(context, BASE_URL + "baidu", params, handler); |
| | | } |
| | | |
| | | public static void getBaiDuVideoTypeList(Context context, |
| | | ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<>(); |
| | | params.put("Method", "getVideoTypeList"); |
| | | commonPost(context, BASE_URL + "baidu", params, handler); |
| | | } |
| | | |
| | | |
| | | |
| | | public static LinkedHashMap<String, String> validateParams( |
| | | LinkedHashMap<String, String> params, Context context) { |
| | | params.put("System", "1"); |
New file |
| | |
| | | package com.weikou.beibeivideo.ui.baidu; |
| | | |
| | | import android.os.Bundle; |
| | | import android.support.annotation.Nullable; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.FragmentManager; |
| | | import android.support.v4.app.FragmentStatePagerAdapter; |
| | | import android.support.v4.view.ViewPager; |
| | | import android.view.View; |
| | | import android.widget.Toast; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.viewpagerindicator.FoundTabPageIndicator; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.BeibeiVideoApplication; |
| | | import com.weikou.beibeivideo.ui.MyRetainViewFragment; |
| | | import com.weikou.beibeivideo.util.cache.DiskLruCacheManager; |
| | | import com.weikou.beibeivideo.util.downutil.StringUtils; |
| | | import com.yeshi.ec.library_baiducpu.R; |
| | | import com.yeshi.ec.library_baiducpu.entity.BaiDuCPUType; |
| | | import com.yeshi.ec.library_baiducpu.fragment.BaiDuCPUContentFragment; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 百度资讯 |
| | | */ |
| | | public class BaiDuNewsFragment extends MyRetainViewFragment { |
| | | |
| | | private ViewPager viewPager; |
| | | private ContentAdapter contentAdapter; |
| | | private List<BaiDuCPUType> itemList = new ArrayList<>(); |
| | | private FoundTabPageIndicator indicator; |
| | | private AQuery mAQuery; |
| | | |
| | | |
| | | public static BaiDuNewsFragment newInstance() { |
| | | return new BaiDuNewsFragment("百度资讯"); |
| | | } |
| | | |
| | | |
| | | public BaiDuNewsFragment(String name) { |
| | | super(name); |
| | | } |
| | | |
| | | @Override |
| | | public int getContentResource() { |
| | | return R.layout.fragment_baidu_news_root; |
| | | } |
| | | |
| | | private void initView(View contentView) { |
| | | viewPager = contentView.findViewById(R.id.vp_news); |
| | | } |
| | | |
| | | |
| | | private String getCacheKey() { |
| | | return StringUtils.MD5("getBaiDuNewsTypeList"); |
| | | } |
| | | |
| | | private void initData(View contentView) { |
| | | mAQuery = new AQuery(contentView); |
| | | //获取缓存 |
| | | String value = DiskLruCacheManager.getInstance(BeibeiVideoApplication.application).getCache(getCacheKey()); |
| | | if (!StringUtils.isNullOrEmpty(value)) { |
| | | setData(value); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取类型列表 |
| | | */ |
| | | private void getTypeList() { |
| | | BeibeiVideoAPI.getBaiDuNewsTypeList(getContext(), new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | String data = jsonObject.optJSONArray("Data").toString(); |
| | | setData(data); |
| | | DiskLruCacheManager.getInstance(BeibeiVideoApplication.application).cache(getCacheKey(), data); |
| | | } else { |
| | | Toast.makeText(getContext(), jsonObject.optString("Msg"), Toast.LENGTH_SHORT).show(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) { |
| | | super.onFailure(statusCode, headers, responseString, throwable); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private synchronized void setData(String json) { |
| | | List<BaiDuCPUType> list = new Gson().fromJson(json, new TypeToken<List<BaiDuCPUType>>() { |
| | | }.getType()); |
| | | //数据一致就不必更新 |
| | | if (itemList != null) { |
| | | String data1 = new Gson().toJson(itemList); |
| | | String data2 = new Gson().toJson(list); |
| | | if (data1.equalsIgnoreCase(data2)) { |
| | | return; |
| | | } |
| | | } |
| | | itemList.clear(); |
| | | itemList.addAll(list); |
| | | setData(); |
| | | } |
| | | |
| | | |
| | | public void setData() { |
| | | contentAdapter = new ContentAdapter( |
| | | getChildFragmentManager(), itemList); |
| | | viewPager.setAdapter(contentAdapter); |
| | | ((FoundTabPageIndicator) mAQuery.id(R.id.indicator).getView()).setViewPager(viewPager); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | initView(contentView); |
| | | initData(contentView); |
| | | getTypeList(); |
| | | } |
| | | |
| | | class ContentAdapter extends FragmentStatePagerAdapter { |
| | | private FragmentManager fm; |
| | | |
| | | private List<BaiDuCPUType> mlist; |
| | | |
| | | public ContentAdapter(FragmentManager fm, List<BaiDuCPUType> list) { |
| | | super(fm); |
| | | this.fm = fm; |
| | | this.mlist = list; |
| | | } |
| | | |
| | | @Override |
| | | public Fragment getItem(int position) { |
| | | Fragment fragment = BaiDuCPUContentFragment.newInstance(mlist.get(position), BaiDuCPUContentFragment.VIEW_TYPE_NEWS); |
| | | return fragment; |
| | | } |
| | | |
| | | @Override |
| | | public int getCount() { |
| | | return mlist.size(); |
| | | } |
| | | |
| | | |
| | | @Nullable |
| | | @Override |
| | | public CharSequence getPageTitle(int position) { |
| | | return mlist.get(position).getName(); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.weikou.beibeivideo.ui.baidu; |
| | | |
| | | import android.os.Bundle; |
| | | import android.support.annotation.Nullable; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.FragmentManager; |
| | | import android.support.v4.app.FragmentStatePagerAdapter; |
| | | import android.support.v4.view.ViewPager; |
| | | import android.view.View; |
| | | import android.widget.Toast; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.lcjian.library.RetainViewFragment; |
| | | import com.viewpagerindicator.FoundTabPageIndicator; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.BeibeiVideoApplication; |
| | | import com.weikou.beibeivideo.ui.MyRetainViewFragment; |
| | | import com.weikou.beibeivideo.util.cache.DiskLruCacheManager; |
| | | import com.weikou.beibeivideo.util.downutil.StringUtils; |
| | | import com.yeshi.ec.library_baiducpu.R; |
| | | import com.yeshi.ec.library_baiducpu.entity.BaiDuCPUType; |
| | | import com.yeshi.ec.library_baiducpu.fragment.BaiDuCPUContentFragment; |
| | | import com.yeshi.ec.library_baiducpu.fragment.BaiDuShortVideosFragment; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 百度资讯 |
| | | */ |
| | | public class BaiDuVideosFragment extends MyRetainViewFragment { |
| | | |
| | | private ViewPager viewPager; |
| | | private ContentAdapter contentAdapter; |
| | | private List<BaiDuCPUType> itemList = new ArrayList<>(); |
| | | private FoundTabPageIndicator indicator; |
| | | private AQuery mAQuery; |
| | | |
| | | public static BaiDuVideosFragment newInstance() { |
| | | return new BaiDuVideosFragment("百度视频"); |
| | | } |
| | | |
| | | public BaiDuVideosFragment(String name) { |
| | | super(name); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int getContentResource() { |
| | | return R.layout.fragment_baidu_news_root; |
| | | } |
| | | |
| | | private void initView(View contentView) { |
| | | viewPager = contentView.findViewById(R.id.vp_news); |
| | | } |
| | | |
| | | private String getCacheKey() { |
| | | return StringUtils.MD5("getBaiDuNewsTypeList"); |
| | | } |
| | | |
| | | private void initData(View contentView) { |
| | | mAQuery = new AQuery(contentView); |
| | | //获取缓存 |
| | | String value = DiskLruCacheManager.getInstance(BeibeiVideoApplication.application).getCache(getCacheKey()); |
| | | if (!StringUtils.isNullOrEmpty(value)) { |
| | | setData(value); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | initView(contentView); |
| | | initData(contentView); |
| | | getTypeList(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取类型列表 |
| | | */ |
| | | private void getTypeList() { |
| | | BeibeiVideoAPI.getBaiDuVideoTypeList(getContext(), new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | String data = jsonObject.optJSONArray("Data").toString(); |
| | | setData(data); |
| | | DiskLruCacheManager.getInstance(BeibeiVideoApplication.application).cache(getCacheKey(), data); |
| | | } else { |
| | | Toast.makeText(getContext(), jsonObject.optString("Msg"), Toast.LENGTH_SHORT).show(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) { |
| | | super.onFailure(statusCode, headers, responseString, throwable); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private synchronized void setData(String data) { |
| | | List<BaiDuCPUType> list = new Gson().fromJson(data, new TypeToken<List<BaiDuCPUType>>() { |
| | | }.getType()); |
| | | //数据一致就不必更新 |
| | | if (itemList != null) { |
| | | String data1 = new Gson().toJson(itemList); |
| | | String data2 = new Gson().toJson(list); |
| | | if (data1.equalsIgnoreCase(data2)) { |
| | | return; |
| | | } |
| | | } |
| | | itemList.clear(); |
| | | itemList.addAll(list); |
| | | setData(); |
| | | } |
| | | |
| | | |
| | | public void setData() { |
| | | contentAdapter = new BaiDuVideosFragment.ContentAdapter( |
| | | getChildFragmentManager(), itemList); |
| | | viewPager.setAdapter(contentAdapter); |
| | | ((FoundTabPageIndicator) mAQuery.id(R.id.indicator).getView()).setViewPager(viewPager); |
| | | } |
| | | |
| | | class ContentAdapter extends FragmentStatePagerAdapter { |
| | | private FragmentManager fm; |
| | | |
| | | private List<BaiDuCPUType> mlist; |
| | | |
| | | public ContentAdapter(FragmentManager fm, List<BaiDuCPUType> list) { |
| | | super(fm); |
| | | this.fm = fm; |
| | | this.mlist = list; |
| | | } |
| | | |
| | | @Override |
| | | public Fragment getItem(int position) { |
| | | if (mlist.get(position).getId() == 1085) |
| | | return BaiDuShortVideosFragment.newInstance(mlist.get(position)); |
| | | else |
| | | return BaiDuCPUContentFragment.newInstance(mlist.get(position), mlist.get(position).getId() == 1085 ? BaiDuCPUContentFragment.VIEW_TYPE_SMALLVIDEO : BaiDuCPUContentFragment.VIEW_TYPE_VIDEO); |
| | | } |
| | | |
| | | @Override |
| | | public int getCount() { |
| | | return mlist.size(); |
| | | } |
| | | |
| | | |
| | | @Nullable |
| | | @Override |
| | | public CharSequence getPageTitle(int position) { |
| | | return mlist.get(position).getName(); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.weikou.beibeivideo.ui.dialog; |
| | | |
| | | import android.app.Activity; |
| | | import android.app.Dialog; |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.drawable.Drawable; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.WindowManager; |
| | | import android.widget.ImageView; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.bumptech.glide.GenericTransitionOptions; |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.request.RequestOptions; |
| | | import com.lcjian.library.util.SystemCommon; |
| | | import com.lcjian.library.util.common.TimeUtil; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.entity.JumpDetail; |
| | | import com.weikou.beibeivideo.util.JumpActivityUtil; |
| | | |
| | | /** |
| | | * 用户协议弹框 |
| | | */ |
| | | public class FloatADDialog extends Dialog { |
| | | |
| | | private static String TAG = FloatADDialog.class.getName(); |
| | | |
| | | public FloatADDialog(Context context) { |
| | | super(context); |
| | | this.setCancelable(false); |
| | | } |
| | | |
| | | public FloatADDialog(Context context, int theme) { |
| | | super(context, theme); |
| | | this.setCancelable(false); |
| | | } |
| | | |
| | | |
| | | public static class Builder { |
| | | |
| | | private String id; |
| | | |
| | | private Activity context; |
| | | |
| | | public Builder(Activity context) { |
| | | this.context = context; |
| | | } |
| | | |
| | | private Drawable drawable; |
| | | |
| | | private JumpDetail jumpDetail; |
| | | |
| | | private JSONObject params; |
| | | |
| | | |
| | | public Builder setImage(Drawable drawable) { |
| | | this.drawable = drawable; |
| | | return this; |
| | | } |
| | | |
| | | public Builder setJump(JumpDetail jumpDetail, JSONObject params) { |
| | | this.jumpDetail = jumpDetail; |
| | | this.params = params; |
| | | return this; |
| | | } |
| | | |
| | | public Builder setId(String id) { |
| | | this.id = id; |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * 是否可以显示 |
| | | * |
| | | * @param context |
| | | * @return |
| | | */ |
| | | public static boolean canShow(Context context, String id) { |
| | | final SharedPreferences share = context.getSharedPreferences("floatAD", Context.MODE_PRIVATE); |
| | | long time = share.getLong("showTime-" + id, 0L); |
| | | long now = System.currentTimeMillis(); |
| | | if (!TimeUtil.getGeneralTime(time, "yyyyMMdd").equalsIgnoreCase(TimeUtil.getGeneralTime(now, "yyyyMMdd"))) { |
| | | return true; |
| | | } else |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 设置显示 |
| | | * |
| | | * @param context |
| | | * @param id |
| | | */ |
| | | private static void setShow(Context context, String id) { |
| | | final SharedPreferences share = context.getSharedPreferences("floatAD", Context.MODE_PRIVATE); |
| | | SharedPreferences.Editor editor = share.edit(); |
| | | editor.putLong("showTime-" + id, System.currentTimeMillis()); |
| | | editor.commit(); |
| | | } |
| | | |
| | | |
| | | public FloatADDialog create() { |
| | | |
| | | LayoutInflater inflater = (LayoutInflater) context |
| | | .getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
| | | final FloatADDialog dialog = new FloatADDialog(context, R.style.Dialog); |
| | | dialog.setCanceledOnTouchOutside(true); |
| | | final View layout = inflater.inflate(R.layout.dialog_float_ad, null); |
| | | ImageView imageView = layout.findViewById(R.id.iv_img); |
| | | Glide.with(context).load(drawable).transition(GenericTransitionOptions.with(R.anim.anim_float_ad_show)).apply(new RequestOptions().centerInside()).into(imageView); |
| | | ImageView close = layout.findViewById(R.id.iv_close); |
| | | close.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | setShow(context, id); |
| | | if (dialog.isShowing()) |
| | | dialog.dismiss(); |
| | | } |
| | | }); |
| | | |
| | | imageView.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | setShow(context, id); |
| | | JumpActivityUtil.jumpPage(context, jumpDetail, params); |
| | | if (dialog.isShowing()) |
| | | dialog.dismiss(); |
| | | } |
| | | }); |
| | | |
| | | |
| | | dialog.setContentView(layout); |
| | | |
| | | android.view.WindowManager.LayoutParams params = dialog.getWindow() |
| | | .getAttributes(); |
| | | params.width = WindowManager.LayoutParams.MATCH_PARENT; |
| | | params.height = WindowManager.LayoutParams.MATCH_PARENT; |
| | | dialog.getWindow().setAttributes(params); |
| | | return dialog; |
| | | } |
| | | } |
| | | |
| | | public interface MeasureCallBack { |
| | | public void onMeasure(int height); |
| | | } |
| | | } |
| | |
| | | import android.content.SharedPreferences; |
| | | import android.content.pm.PackageInfo; |
| | | import android.content.pm.PackageManager; |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.drawable.Drawable; |
| | | import android.os.Bundle; |
| | | import android.support.annotation.NonNull; |
| | | import android.support.annotation.Nullable; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.FragmentManager; |
| | |
| | | import android.view.View; |
| | | import android.widget.FrameLayout; |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.request.target.SimpleTarget; |
| | | import com.bumptech.glide.request.transition.Transition; |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.lcjian.library.util.cache.DiskLruCache; |
| | | import com.lcjian.library.util.common.StorageUtils; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; |
| | | import com.viewpagerindicator.IconPagerAdapter; |
| | | import com.viewpagerindicator.MainTabPageIndicator; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.BeibeiVideoApplication; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.entity.JumpDetail; |
| | | import com.weikou.beibeivideo.entity.VideoType; |
| | | import com.weikou.beibeivideo.entity.recommend.HomeClass; |
| | | import com.weikou.beibeivideo.ui.MyRetainViewFragment; |
| | | import com.weikou.beibeivideo.ui.dialog.FloatADDialog; |
| | | import com.weikou.beibeivideo.ui.dialog.UserProtocolDialog; |
| | | import com.weikou.beibeivideo.ui.recommend.NovelJNZFragment; |
| | | import com.weikou.beibeivideo.ui.recommend.RecommendFragment; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.util.cache.DiskLruCacheManager; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | |
| | | FrameLayout fl_indicator; |
| | | |
| | | private DiskLruCache cache; |
| | | |
| | | public HomeFragment() { |
| | | super(HomeFragment.class.getClass().getName()); |
| | |
| | | @Override |
| | | public void onCreate(@Nullable Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | try { |
| | | cache = DiskLruCache.open( |
| | | new File(StorageUtils.getCacheDirectory(getContext()) |
| | | .toString(), "http"), getVersionNum(getContext()), |
| | | 1, 1024 * 1024); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (!BeibeiConstant.IS_TEST) |
| | | showProtocol(); |
| | | } |
| | |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | dialog.dismiss(); |
| | | UserUtil.agreeUserProtocol(getContext()); |
| | | showFloatImgAd(); |
| | | } |
| | | }).setData(data).create().show(); |
| | | } else { |
| | | showFloatImgAd(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 展示悬浮广告 |
| | | */ |
| | | private void showFloatImgAd() { |
| | | BeibeiVideoAPI.getHomeConfig(getContext(), new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | JSONObject data = jsonObject.optJSONObject("Data"); |
| | | if (data != null) { |
| | | |
| | | JSONObject ad = data.optJSONObject("floatAD"); |
| | | if (ad != null) { |
| | | String id = ad.optString("id"); |
| | | if (FloatADDialog.Builder.canShow(getContext(), id)) { |
| | | String picture = ad.optString("picture"); |
| | | Glide.with(getContext()).load(picture).into(new SimpleTarget<Drawable>() { |
| | | @Override |
| | | public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { |
| | | JSONObject jumpDetailJSON = ad.optJSONObject("jumpDetail"); |
| | | JSONObject params = ad.optJSONObject("params"); |
| | | JumpDetail jumpDetail = new Gson().fromJson(jumpDetailJSON.toString(), JumpDetail.class); |
| | | final FloatADDialog.Builder builder = new FloatADDialog.Builder(getActivity()) |
| | | .setId(id).setImage(resource); |
| | | if (params != null) { |
| | | builder.setJump(jumpDetail, com.alibaba.fastjson.JSONObject.parseObject(params.toString())); |
| | | } |
| | | |
| | | fl_indicator.postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | builder.create().show(); |
| | | } |
| | | }, 2000); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onLoadCleared(@Nullable Drawable placeholder) { |
| | | |
| | | } |
| | | |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | public static int getVersionNum(Context context) { |
| | | try { |
| | |
| | | if (fl_indicator.getChildCount() > 0) { |
| | | fl_indicator.removeAllViews(); |
| | | } |
| | | DiskLruCache.Snapshot snapshot = null; |
| | | try { |
| | | if (cache != null) { |
| | | snapshot = cache.get(getKey("getCategories")); |
| | | if (snapshot != null) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE).create(); |
| | | List<VideoType> list = gson.fromJson( |
| | | snapshot.getString(0), |
| | | new TypeToken<List<VideoType>>() { |
| | | }.getType()); |
| | | // categories.addAll(list); |
| | | } |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if (snapshot != null) { |
| | | snapshot.close(); |
| | | } |
| | | |
| | | String cacheValue = DiskLruCacheManager.getInstance(BeibeiVideoApplication.application).getCache(getKey("getCategories")); |
| | | if (!StringUtils.isBlank(cacheValue)) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE).create(); |
| | | List<HomeClass> list = gson.fromJson( |
| | | cacheValue, |
| | | new TypeToken<List<HomeClass>>() { |
| | | }.getType()); |
| | | categories.addAll(list); |
| | | } |
| | | |
| | | adapter = new HomePageAdapter( |
| | |
| | | |
| | | |
| | | count++; |
| | | try { |
| | | DiskLruCache.Editor editor = cache |
| | | .edit(getKey("getCategories")); |
| | | editor.set(0, gson.toJson(categories)); |
| | | editor.commit(); |
| | | } catch (IOException e) { |
| | | } |
| | | DiskLruCacheManager.getInstance(BeibeiVideoApplication.application).cache(getKey("getCategories"), gson.toJson(categories)); |
| | | } |
| | | } |
| | | |
| | |
| | | import android.widget.Toast; |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.load.DataSource; |
| | | import com.bumptech.glide.load.engine.GlideException; |
| | | import com.bumptech.glide.request.RequestListener; |
| | | import com.bumptech.glide.request.target.SimpleTarget; |
| | | import com.bumptech.glide.request.target.Target; |
| | | import com.bumptech.glide.request.transition.Transition; |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | |
| | | import com.mozillaonline.providers.downloads.DownloadService; |
| | | import com.qq.e.ads.cfg.VideoOption; |
| | | import com.tencent.android.tpush.XGPushTextMessage; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.umeng.socialize.ShareAction; |
| | | import com.umeng.socialize.UMShareAPI; |
| | | import com.umeng.socialize.UMShareListener; |
| | | import com.umeng.socialize.bean.SHARE_MEDIA; |
| | | import com.umeng.socialize.media.UMImage; |
| | | import com.umeng.socialize.media.UMWeb; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.db.MessageTable; |
| | | import com.weikou.beibeivideo.entity.NewComment; |
| | | import com.weikou.beibeivideo.ui.BaseActivity; |
| | | import com.weikou.beibeivideo.ui.common.FollowActivity; |
| | | import com.weikou.beibeivideo.ui.discover.ReleasePromptActivity; |
| | | import com.weikou.beibeivideo.ui.baidu.BaiDuNewsFragment; |
| | | import com.weikou.beibeivideo.ui.baidu.BaiDuVideosFragment; |
| | | import com.weikou.beibeivideo.ui.login.LoginActivity; |
| | | import com.weikou.beibeivideo.ui.login.PersonInfoActivity; |
| | | import com.weikou.beibeivideo.ui.mine.BrowserActivity; |
| | | import com.weikou.beibeivideo.ui.mine.DownloadActivity; |
| | | import com.weikou.beibeivideo.ui.mine.HelpAndTicklingActivity; |
| | | import com.weikou.beibeivideo.ui.mine.MyFavouriteActivity; |
| | | import com.weikou.beibeivideo.ui.mine.SettingsActivity; |
| | | import com.weikou.beibeivideo.ui.mine.SystemMessageActivity; |
| | | import com.weikou.beibeivideo.ui.mine.WatchHistoryActivity; |
| | | import com.weikou.beibeivideo.ui.recommend.SearchActivity; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.ExitDialog; |
| | | import com.weikou.beibeivideo.util.LoginFirstDialog; |
| | | import com.weikou.beibeivideo.util.ad.FullVideoAdManager; |
| | | import com.weikou.beibeivideo.util.ad.manager.SearchResultAdManager; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.yeshi.ec.library_baiducpu.fragment.BaiDuNewsFragment; |
| | | import com.yeshi.ec.library_baiducpu.fragment.BaiDuVideosFragment; |
| | | import com.ysh.wpc.appupdate.AppUpdate; |
| | | |
| | | import org.apache.http.Header; |
| | |
| | | mFragmentSwitchHelper = FragmentSwitchHelper.create( |
| | | R.id.fl_main_fragment_container, getSupportFragmentManager(), |
| | | new HomeFragment(), new CategoryFragment(), |
| | | new BaiDuNewsFragment(), new MineFragment(), new BaiDuVideosFragment()); |
| | | BaiDuNewsFragment.newInstance(), new MineFragment(), BaiDuVideosFragment.newInstance()); |
| | | rg_nav = findViewById(R.id.rg_nav); |
| | | rg_nav.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
| | | |
| | |
| | | if (!StringUtils.isBlank(topIcon)) { |
| | | fl_right_ad.setVisibility(View.VISIBLE); |
| | | try { |
| | | Glide.with(getApplicationContext()).load(topIcon).into(target); |
| | | Glide.with(getApplicationContext()).load(topIcon).into(iv_taobao); |
| | | long time = preferences.getLong("latestAdtime", 0); |
| | | if (!getDay(time).equalsIgnoreCase( |
| | | getDay(System.currentTimeMillis()))) { |
| | | iv_red_dot.setVisibility(View.VISIBLE); |
| | | } else { |
| | | iv_red_dot.setVisibility(View.GONE); |
| | | } |
| | | } catch (IllegalArgumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | Log.i(TAG, "onCreateView"); |
| | | EventBus.getDefault().register(this); |
| | | Bundle bundle = getArguments(); |
| | | mVideoInfo = (VideoInfo) bundle |
| | | .getSerializable("video_info"); |
| | |
| | | rv_episode.setVisibility(View.VISIBLE); |
| | | } else |
| | | rv_episode.setVisibility(View.GONE); |
| | | |
| | | EventBus.getDefault().register(this); |
| | | } |
| | | |
| | | |
| | | public void onEventMainThread(Playlocation playlocation) { |
| | | mPlayingPosition = playlocation.getPosition(); |
| | | loadEpisode(); |
| | | // loadEpisode(); |
| | | refresh(); |
| | | } |
| | | |
| | |
| | | import com.weikou.beibeivideo.util.ad.AdUtil; |
| | | import com.weikou.beibeivideo.util.ad.ExpressAdManager; |
| | | import com.weikou.beibeivideo.util.ui.DividerItemDecoration; |
| | | import com.yeshi.ec.library_baiducpu.fragment.BaiDuNewsFragment; |
| | | import com.yeshi.ec.library_baiducpu.fragment.BaiDuVideosFragment; |
| | | import com.ysh.wpc.appupdate.GoReview; |
| | | import com.ysh.wpc.appupdate.service.DownLoadFileService; |
| | | |
| | |
| | | vp_recommend = view.findViewById(R.id.vp_recommend); |
| | | ll_ad_containner = view.findViewById(R.id.ll_ad_containner); |
| | | rl_recommend_top = view.findViewById(R.id.rl_recommend_top); |
| | | if (position == 1) |
| | | if (position > 0) |
| | | rl_recommend_top.setRatio(0.56f); |
| | | indicator_recommend = view.findViewById(R.id.indicator_recommend); |
| | | mRecommendNewAdapter.setHeaderView(view); |
| | |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Intent; |
| | | import android.net.http.DelegatingSSLSession; |
| | | import android.support.annotation.NonNull; |
| | | import android.support.v7.widget.RecyclerView; |
| | | import android.view.LayoutInflater; |
| | |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.entity.VideoDetailInfo; |
| | | import com.weikou.beibeivideo.entity.VideoInfo; |
| | | import com.weikou.beibeivideo.entity.ad.ExpressAdContainer; |
| | | import com.weikou.beibeivideo.entity.video.VideoContent; |
| | | import com.weikou.beibeivideo.ui.media.VideoDetailActivity; |
| | | import com.weikou.beibeivideo.ui.media.VideoDetailActivity2; |
| | | import com.weikou.beibeivideo.util.ad.ExpressAdManager; |
| | | import com.weikou.beibeivideo.R; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | |
| | | private void myClick(VideoInfo info, final View v, int p) { |
| | | Intent intent = new Intent(v.getContext(), VideoDetailActivity2.class); |
| | | Intent intent = new Intent(v.getContext(), VideoDetailActivity.class); |
| | | intent.putExtra("video_info", info); |
| | | if (p > 0) |
| | | intent.putExtra("playing_position", p); |
| | |
| | | |
| | | public class BeibeiConstant { |
| | | |
| | | public final static boolean IS_TEST = true; |
| | | public final static boolean IS_TEST = false; |
| | | |
| | | //首页推荐第一个广告 |
| | | public final static boolean AD_SETTING_RECOMMEND_FIRST = true; |
| | |
| | | package com.weikou.beibeivideo.util; |
| | | |
| | | import android.app.Activity; |
| | | import android.app.ActivityManager; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | | import android.util.Log; |
| | | import android.webkit.WebChromeClient; |
| | | import android.webkit.WebViewClient; |
| | | |
New file |
| | |
| | | package com.weikou.beibeivideo.util.cache; |
| | | |
| | | import android.content.Context; |
| | | import android.content.pm.PackageInfo; |
| | | import android.content.pm.PackageManager; |
| | | |
| | | import com.lcjian.library.util.cache.DiskLruCache; |
| | | import com.lcjian.library.util.common.StorageUtils; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | |
| | | public class DiskLruCacheManager { |
| | | |
| | | private static DiskLruCacheManager instance; |
| | | private DiskLruCache cache; |
| | | |
| | | private static int getVersionNum(Context context) { |
| | | try { |
| | | PackageInfo pi = context.getPackageManager().getPackageInfo( |
| | | context.getPackageName(), 0); |
| | | return pi.versionCode; |
| | | } catch (PackageManager.NameNotFoundException e) { |
| | | e.printStackTrace(); |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | public DiskLruCacheManager(Context context) { |
| | | try { |
| | | cache = DiskLruCache.open( |
| | | new File(StorageUtils.getCacheDirectory(context) |
| | | .toString(), "http"), getVersionNum(context), |
| | | 1, 1024 * 1024); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | public static DiskLruCacheManager getInstance(Context context) { |
| | | if (instance == null) |
| | | instance = new DiskLruCacheManager(context); |
| | | return instance; |
| | | } |
| | | |
| | | |
| | | public void cache(String key, String value) { |
| | | if (cache == null) |
| | | return; |
| | | DiskLruCache.Editor editor = null; |
| | | try { |
| | | editor = cache |
| | | .edit(key); |
| | | editor.set(0, value); |
| | | editor.commit(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 取缓存 |
| | | * |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public String getCache(String key) { |
| | | if (cache == null) |
| | | return null; |
| | | DiskLruCache.Snapshot snapshot = null; |
| | | try { |
| | | if (cache != null) { |
| | | snapshot = cache.get(key); |
| | | if (snapshot != null) { |
| | | return snapshot.getString(0); |
| | | } |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if (snapshot != null) { |
| | | snapshot.close(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.ec.library_baiducpu.entity; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | public class BaiDuCPUType implements Serializable { |
| | | |
| | | private String name; |
| | | private int id; |
| | | |
| | | public BaiDuCPUType() { |
| | | } |
| | | |
| | | public BaiDuCPUType(String name, int id) { |
| | | this.name = name; |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public int getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(int id) { |
| | | this.id = id; |
| | | } |
| | | } |
| | |
| | | import com.ut.device.UTDevice; |
| | | import com.yeshi.ec.library_baiducpu.R; |
| | | import com.yeshi.ec.library_baiducpu.adapter.BaiduCPUContentAdapter; |
| | | import com.yeshi.ec.library_baiducpu.entity.SpinnerItem; |
| | | import com.yeshi.ec.library_baiducpu.entity.BaiDuCPUType; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | private int viewType; |
| | | |
| | | |
| | | public static BaiDuCPUContentFragment newInstance(SpinnerItem spinnerItem, int viewType) { |
| | | public static BaiDuCPUContentFragment newInstance(BaiDuCPUType spinnerItem, int viewType) { |
| | | BaiDuCPUContentFragment fragment = new BaiDuCPUContentFragment(); |
| | | Bundle bundle = new Bundle(); |
| | | bundle.putSerializable("item", spinnerItem); |
| | |
| | | |
| | | private void initData() { |
| | | Bundle bundle = getArguments(); |
| | | SpinnerItem item = (SpinnerItem) bundle.getSerializable("item"); |
| | | BaiDuCPUType item = (BaiDuCPUType) bundle.getSerializable("item"); |
| | | viewType = bundle.getInt("viewType"); |
| | | bundle.clear(); |
| | | mChannelId = item.getmId(); |
| | | mChannelId = item.getId(); |
| | | |
| | | mCpuManager = new NativeCPUManager(getContext(), YOUR_APP_ID, this); |
| | | /** |
| | |
| | | import android.os.Bundle; |
| | | import android.view.View; |
| | | import android.widget.RelativeLayout; |
| | | import android.widget.Toast; |
| | | |
| | | import com.baidu.mobads.CpuAdView; |
| | | import com.lcjian.library.RetainViewFragment; |
| | | import com.yeshi.ec.library_baiducpu.R; |
| | | import com.yeshi.ec.library_baiducpu.entity.SpinnerItem; |
| | | import com.yeshi.ec.library_baiducpu.entity.BaiDuCPUType; |
| | | |
| | | /** |
| | | * 百度小视频 |
| | | */ |
| | | public class BaiDuShortVideosFragment extends RetainViewFragment { |
| | | private static final String APP_ID = "be796ac7"; |
| | | private static int CHANNEL_ID = 1085; // 小视频频道 |
| | | private static int CHANNEL_ID = 1085; // 小视频频道 |
| | | private RelativeLayout mVideoContainer; |
| | | private CpuAdView mCpuView; |
| | | |
| | | public static BaiDuShortVideosFragment newInstance(SpinnerItem spinnerItem) { |
| | | public static BaiDuShortVideosFragment newInstance(BaiDuCPUType spinnerItem) { |
| | | BaiDuShortVideosFragment fragment = new BaiDuShortVideosFragment(); |
| | | Bundle bundle = new Bundle(); |
| | | bundle.putSerializable("item", spinnerItem); |
| | |
| | | |
| | | private void fetchCPUVideo() { |
| | | Bundle bundle = getArguments(); |
| | | SpinnerItem item = (SpinnerItem) bundle.getSerializable("item"); |
| | | BaiDuCPUType item = (BaiDuCPUType) bundle.getSerializable("item"); |
| | | bundle.clear(); |
| | | CHANNEL_ID = item.getmId(); |
| | | CHANNEL_ID = item.getId(); |
| | | |
| | | // 小视频频道的内容 |
| | | mCpuView = new CpuAdView(getContext(), APP_ID, CHANNEL_ID); |
| | |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_play" |
| | | android:layout_width="50dp" |
| | | android:layout_height="50dp" |
| | | android:layout_width="64dp" |
| | | android:layout_height="64dp" |
| | | android:layout_gravity="center" |
| | | android:src="@drawable/ic_baidu_play"> |
| | | android:src="@drawable/biz_video_list_play_icon_big"> |
| | | |
| | | </ImageView> |
| | | </FrameLayout> |
| | |
| | | tabView.setText(text); |
| | | tabView.setTextColor(R.color.black1); |
| | | tabView.setBackgroundResource(R.drawable.found__tab_indicator); |
| | | tabView.setPadding(0,0,0,DimenUtils.dip2px(getContext(), 6)); |
| | | tabView.setPadding(0, 0, 0, DimenUtils.dip2px(getContext(), 6)); |
| | | |
| | | if (iconResId != 0) { |
| | | tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0); |
| | |
| | | @Override |
| | | public void setCurrentItem(int item) { |
| | | if (mViewPager == null) { |
| | | throw new IllegalStateException("ViewPager has not been bound."); |
| | | return; |
| | | } |
| | | mSelectedTabIndex = item; |
| | | mViewPager.setCurrentItem(item); |