调整ad
This commit is contained in:
parent
b0a180eaab
commit
577a1acf4a
|
@ -40,6 +40,7 @@ android {
|
|||
buildConfigField "String", "MAIN_HOST", '"http://xiaoshuofenxiang.com/api/"'
|
||||
buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/g.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"'
|
||||
buildConfigField "String","AD_TOUTIAO_APP_ID",'"5019267"'
|
||||
buildConfigField "String","AD_SLOT_TOUTIAO_FEEDAD_ID",'"919267464"'
|
||||
buildConfigField "String","AD_SLOT_TOUTIAO_SPLASH_ID",'"819267134"'
|
||||
buildConfigField "String","AD_SLOT_TOUTIAO_BANNER_ID",'"919267016"'
|
||||
buildConfigField "String","AD_SLOT_TOUTIAO_BANNER_NATIVE_ID",'"919267816"'
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.util.Log;
|
|||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bytedance.sdk.openadsdk.AdSlot;
|
||||
import com.bytedance.sdk.openadsdk.TTAdNative;
|
||||
|
@ -19,6 +20,9 @@ import com.novelbook.android.Main2Activity;
|
|||
import com.novelbook.android.R;
|
||||
import com.novelbook.android.utils.Constants;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
|
||||
/**
|
||||
* 开屏广告Activity示例
|
||||
|
@ -38,12 +42,15 @@ public class SplashActivity extends Activity implements WeakHandler.IHandler {
|
|||
private static final int MSG_GO_MAIN = 1;
|
||||
//开屏广告是否已经加载
|
||||
private boolean mHasLoaded;
|
||||
@BindView(R.id.textTile)
|
||||
TextView tvTitle;
|
||||
|
||||
@SuppressWarnings("RedundantCast")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.ad_toutiao_activity_splash);
|
||||
ButterKnife.bind(this);
|
||||
mSplashContainer = (FrameLayout) findViewById(R.id.splash_container);
|
||||
//step2:创建TTAdNative对象
|
||||
mTTAdNative = TTAdManagerHolder.get().createAdNative(this);
|
||||
|
@ -61,7 +68,7 @@ public class SplashActivity extends Activity implements WeakHandler.IHandler {
|
|||
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
||||
// | View.SYSTEM_UI_FLAG_IMMERSIVE
|
||||
);
|
||||
|
||||
tvTitle.setText(R.string.app_name);
|
||||
//加载开屏广告
|
||||
loadSplashAd();
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class Activity_Search extends Activity_base {
|
|||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
|
||||
loadNativeBannerAd(mBannerContainer,BuildConfig.AD_SLOT_TOUTIAO_BANNER_NATIVE_ID);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,13 +4,11 @@ import android.app.Activity;
|
|||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
@ -33,24 +31,24 @@ import com.bytedance.sdk.openadsdk.TTAdDislike;
|
|||
import com.bytedance.sdk.openadsdk.TTAdNative;
|
||||
import com.bytedance.sdk.openadsdk.TTAppDownloadListener;
|
||||
import com.bytedance.sdk.openadsdk.TTBannerAd;
|
||||
|
||||
import com.bytedance.sdk.openadsdk.TTImage;
|
||||
import com.bytedance.sdk.openadsdk.TTNativeAd;
|
||||
import com.google.gson.Gson;
|
||||
import com.novelbook.android.AD.toutiao.TTAdManagerHolder;
|
||||
import com.novelbook.android.AD.toutiao.TToast;
|
||||
|
||||
import com.novelbook.android.db.Novel;
|
||||
import com.novelbook.android.netsubscribe.MovieSubscribe;
|
||||
|
||||
import com.novelbook.android.netutils.NetUtil;
|
||||
import com.novelbook.android.netutils.OnSuccessAndFaultListener;
|
||||
import com.novelbook.android.netutils.OnSuccessAndFaultSub;
|
||||
|
||||
import com.novelbook.android.upgrade.UpdateManager;
|
||||
import com.novelbook.android.utils.CommonUtil;
|
||||
import com.novelbook.android.utils.Constants;
|
||||
|
||||
import com.novelbook.android.utils.ImageUtil;
|
||||
import com.novelbook.android.utils.MyImageLoader;
|
||||
|
||||
import com.novelbook.android.utils.OnItemClickListener;
|
||||
import com.novelbook.android.adapter.BookListAdapter;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -70,6 +68,12 @@ public abstract class Activity_base extends AppCompatActivity {
|
|||
@Nullable
|
||||
@BindView(R.id.banner_container)
|
||||
FrameLayout mBannerContainer;
|
||||
/* @Nullable
|
||||
@BindView(R.id.banner_native_container)
|
||||
FrameLayout mNativeBannerContainer;*/
|
||||
|
||||
|
||||
|
||||
@Nullable
|
||||
@BindView(R.id.recycleViewBookList)
|
||||
RecyclerView rvshudan;
|
||||
|
@ -347,7 +351,7 @@ public abstract class Activity_base extends AppCompatActivity {
|
|||
}else if(height >150){
|
||||
width =(int)(height*1.78);
|
||||
}*/
|
||||
// width =990;
|
||||
width =690;
|
||||
//height=150;
|
||||
height=height > 500 ? 500: height;
|
||||
Log.d(TAG, String.format("loadBannerAd:finial width %s, height %s ",width,height));
|
||||
|
@ -661,4 +665,8 @@ public abstract class Activity_base extends AppCompatActivity {
|
|||
}
|
||||
};
|
||||
|
||||
public TTAdNative getAdNative(){
|
||||
return mTTAdNative;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import com.bytedance.sdk.openadsdk.TTAdDislike;
|
|||
import com.bytedance.sdk.openadsdk.TTAdNative;
|
||||
import com.bytedance.sdk.openadsdk.TTAppDownloadListener;
|
||||
import com.bytedance.sdk.openadsdk.TTBannerAd;
|
||||
import com.bytedance.sdk.openadsdk.TTFeedAd;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
|
@ -461,5 +462,40 @@ void initTabs(){
|
|||
mBannerContainer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载 toutiao feed广告
|
||||
*/
|
||||
void loadListAd( BookListAdapter adapter, int adCnt, boolean addFooter) {
|
||||
//feed广告请求类型参数
|
||||
AdSlot adSlot = new AdSlot.Builder()
|
||||
.setCodeId(BuildConfig.AD_SLOT_TOUTIAO_FEEDAD_ID)
|
||||
.setSupportDeepLink(true)
|
||||
.setImageAcceptedSize(228, 150)
|
||||
.setAdCount(adCnt)
|
||||
.build();
|
||||
//调用feed广告异步请求接口
|
||||
((Activity_base)getActivity()).getAdNative().loadFeedAd(adSlot, new TTAdNative.FeedAdListener() {
|
||||
@Override
|
||||
public void onError(int code, String message) {
|
||||
|
||||
Log.e(TAG, String.format("loadListAd onError: code %s,msg %s",code,message) );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFeedAdLoad(List<TTFeedAd> ads) {
|
||||
// myAdapter.changeMoreStatus(2);
|
||||
if (ads == null || ads.isEmpty()) {
|
||||
Log.e(TAG, "on FeedAdLoaded: ad is null!" );
|
||||
return;
|
||||
}
|
||||
if(addFooter) {
|
||||
adapter.AddFooterItem(ads);
|
||||
}else{
|
||||
adapter.AddHeaderItem(ads);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,17 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.bytedance.sdk.openadsdk.AdSlot;
|
||||
import com.bytedance.sdk.openadsdk.TTAdNative;
|
||||
import com.bytedance.sdk.openadsdk.TTFeedAd;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.novelbook.android.AD.toutiao.TToast;
|
||||
import com.novelbook.android.Activity_Search;
|
||||
import com.novelbook.android.Activity_base;
|
||||
import com.novelbook.android.BuildConfig;
|
||||
import com.novelbook.android.Main2Activity;
|
||||
import com.novelbook.android.R;
|
||||
import com.novelbook.android.activity_cates;
|
||||
|
@ -54,8 +60,8 @@ public class Fragment_booklist extends BasicFragment {
|
|||
private static final String EXTR_CID ="cid" ;
|
||||
private BookListAdapter mAdapter;
|
||||
// private BookListAdapter mAdapter;
|
||||
private List<Novel> mData;;
|
||||
private List<Novel> mMoreData;
|
||||
private List mData;;
|
||||
private List mMoreData;
|
||||
private String cate;
|
||||
private int progress,cid;
|
||||
private String keyWord ,fn,bangdan,history;
|
||||
|
@ -182,6 +188,7 @@ public class Fragment_booklist extends BasicFragment {
|
|||
if (mData != null) { //下拉刷新
|
||||
mData = new ArrayList<Novel>();
|
||||
mAdapter.setData(mData);
|
||||
// loadListAd(mAdapter,1,false);
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -190,7 +197,8 @@ public class Fragment_booklist extends BasicFragment {
|
|||
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
showBookDetail(mData.get(position));
|
||||
if(mData.get(position) instanceof Novel)
|
||||
showBookDetail((Novel)mData.get(position));
|
||||
// openBook(mData.get(position),mAdapter);
|
||||
}
|
||||
|
||||
|
@ -226,7 +234,9 @@ public class Fragment_booklist extends BasicFragment {
|
|||
pageCount = jsonObject.getInt("pageCount");
|
||||
|
||||
mMoreData = GsonUtil. parserJsonArray(jsonObject,Constants.BLOCK_TITLE_NOVELS);
|
||||
|
||||
if(mMoreData.size()>0){
|
||||
loadListAd(mAdapter,1,mData.size()>0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(); Log.e(TAG, "onSuccess: 解析失败",e );
|
||||
}
|
||||
|
@ -259,7 +269,9 @@ public class Fragment_booklist extends BasicFragment {
|
|||
pageCount = jsonObject.getJSONObject("rank").getInt("pageCount");
|
||||
mMoreData = GsonUtil. parserJsonArray(resultstr,Constants.BLOCK_TITLE_NOVELS);
|
||||
Log.d(TAG, "排行榜详细 onSuccess: pageCount " + pageCount);
|
||||
|
||||
if(mMoreData.size()>0){
|
||||
loadListAd(mAdapter,1,mData.size()>0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "onSuccess: 解析失败",e );
|
||||
|
@ -388,4 +400,9 @@ public class Fragment_booklist extends BasicFragment {
|
|||
super.onPause();
|
||||
MobclickAgent.onPageEnd(TAG);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -287,7 +287,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
|
|||
|
||||
|
||||
@OnClick({R.id.buttonMore1, R.id.buttonMore2, R.id.buttonMoreTuijian, R.id.buttonMore3
|
||||
, R.id.buttonCatePingfen, R.id.buttonCateRegeng, R.id.buttonCateTuijian, R.id.buttonCateShoucang, R.id.buttonCateWanjie
|
||||
/* , R.id.buttonCatePingfen, R.id.buttonCateRegeng, R.id.buttonCateTuijian, R.id.buttonCateShoucang, R.id.buttonCateWanjie*/
|
||||
})
|
||||
void bubmitButton(View view) {
|
||||
|
||||
|
@ -307,7 +307,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
|
|||
case R.id.buttonMore4:
|
||||
showPaihangbang(btnMore4.getTag());
|
||||
break;
|
||||
case R.id.buttonCatePingfen:
|
||||
/* case R.id.buttonCatePingfen:
|
||||
showPaihangbang("评分");
|
||||
break;
|
||||
case R.id.buttonCateRegeng:
|
||||
|
@ -321,7 +321,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
|
|||
break;
|
||||
case R.id.buttonCateTuijian:
|
||||
showPaihangbang("推荐");
|
||||
break;
|
||||
break;*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -195,7 +195,9 @@ public static final String TAG = Fragment_paihang.class.getSimpleName();
|
|||
pageCount = jsonObject.getInt("pageCount");
|
||||
|
||||
mMoreData = GsonUtil. parserJsonArray(jsonObject,Constants.BLOCK_TITLE_NOVELS);
|
||||
|
||||
if(mMoreData.size()>0){
|
||||
loadListAd(mAdapter,1,mData.size()>0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -995,7 +995,7 @@ public class ReadActivity extends Activity_base implements AdInterface {
|
|||
|
||||
|
||||
|
||||
final int contentAdHight=100;
|
||||
final int contentAdHight=80;
|
||||
|
||||
@Override
|
||||
public void showAd(boolean showAd ,int adHeight,int adY) {
|
||||
|
@ -1005,6 +1005,8 @@ public class ReadActivity extends Activity_base implements AdInterface {
|
|||
if(!Constants.SHOWAD){
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, String.format("loadBannerAd:width %s, height %s ,adY %s,showAd %s",Constants.SCREEN_WIDTH_PIX-50,adHeight,adY, showAd));
|
||||
|
||||
if(!showAd){
|
||||
return;
|
||||
}
|
||||
|
@ -1013,14 +1015,15 @@ public class ReadActivity extends Activity_base implements AdInterface {
|
|||
|
||||
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mBannerContainer.getLayoutParams();
|
||||
|
||||
Log.d(TAG, String.format("loadBannerAd:width %s, height %s ",Constants.SCREEN_WIDTH_PIX-50,adHeight));
|
||||
// Log.d(TAG, String.format("loadBannerAd:width %s, height %s ,adY %s",Constants.SCREEN_WIDTH_PIX-50,adHeight,adY));
|
||||
|
||||
if(adHeight>620){
|
||||
if(adHeight>500 && adY <500){
|
||||
loadNativeBannerAd(mBannerContainer,BuildConfig.AD_SLOT_TOUTIAO_BANNER_NATIVE_ID);
|
||||
params.setMargins(20, adY-20, 20, 50);
|
||||
}else{
|
||||
params.setMargins(20, adY-30, 20, 50);
|
||||
}else
|
||||
{
|
||||
loadBannerAd(mBannerContainer,BuildConfig.AD_SLOT_TOUTIAO_BANNER_ID, Constants.SCREEN_WIDTH_PIX-50,adHeight);
|
||||
params.setMargins(20, adY, 20, 10);
|
||||
params.setMargins(20, adY-10, 20, 15);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,16 +1,33 @@
|
|||
package com.novelbook.android.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.StaggeredGridLayoutManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.androidquery.callback.AQuery2;
|
||||
import com.androidquery.callback.ImageOptions;
|
||||
import com.bytedance.sdk.openadsdk.DownloadStatusController;
|
||||
import com.bytedance.sdk.openadsdk.TTAdConstant;
|
||||
import com.bytedance.sdk.openadsdk.TTAppDownloadListener;
|
||||
import com.bytedance.sdk.openadsdk.TTFeedAd;
|
||||
import com.bytedance.sdk.openadsdk.TTImage;
|
||||
import com.bytedance.sdk.openadsdk.TTNativeAd;
|
||||
import com.novelbook.android.AD.toutiao.TToast;
|
||||
import com.novelbook.android.BookActivity;
|
||||
import com.novelbook.android.R;
|
||||
import com.novelbook.android.db.Novel;
|
||||
|
@ -23,6 +40,8 @@ import com.novelbook.android.utils.OnItemClickListener;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
@ -31,15 +50,22 @@ import okhttp3.internal.Util;
|
|||
import static com.novelbook.android.utils.ImageUtil.loader;
|
||||
|
||||
public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHolder> {
|
||||
private final static String TAG= BookListAdapter.class.getSimpleName();
|
||||
private final int EMPTY_VIEW = 1;
|
||||
private final int PROGRESS_VIEW = 2;
|
||||
private final int IMAGE_VIEW = 3;
|
||||
private static final int TYPE_ITEM = 4;
|
||||
private static final int TYPE_FOOTER = 5;
|
||||
private static final int NO_FOOTER = 6;
|
||||
|
||||
private static final int TYPE_ITEM = 2;
|
||||
private static final int TYPE_FOOTER = 3;
|
||||
private static final int NO_FOOTER = 4;
|
||||
private static final int ITEM_VIEW_TYPE_GROUP_PIC_AD =5;
|
||||
private static final int ITEM_VIEW_TYPE_SMALL_PIC_AD = 6;
|
||||
private static final int ITEM_VIEW_TYPE_LARGE_PIC_AD = 7;
|
||||
private static final int ITEM_VIEW_TYPE_VIDEO = 8;
|
||||
|
||||
|
||||
|
||||
// private MyImageLoader loader = new MyImageLoader();
|
||||
private Context context;
|
||||
private List<Novel> mDatas ;
|
||||
private Context mContext;
|
||||
private List mDatas ;
|
||||
|
||||
private OnItemClickListener mOnItemClickListener;
|
||||
private int listItemID;
|
||||
|
@ -79,32 +105,34 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol
|
|||
this.percent = percent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private AQuery2 mAQuery;
|
||||
private Map<AdViewHolder, TTAppDownloadListener> mTTAppDownloadListenerMap = new WeakHashMap<>();
|
||||
public void setShowFootView(boolean showFootView) {
|
||||
this.showFootView = showFootView;
|
||||
}
|
||||
|
||||
public BookListAdapter(Context context, List<Novel> datas) {
|
||||
context = context;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mContext = context;
|
||||
mInflater = LayoutInflater.from(mContext);
|
||||
mDatas = datas;
|
||||
this.mAQuery = new AQuery2(context);
|
||||
}
|
||||
|
||||
public BookListAdapter(Context context, List<Novel> mBooks, int listItemID, OnItemClickListener clickLitener) {
|
||||
this.context = context;
|
||||
this.mContext =context;
|
||||
this.mDatas = mBooks;
|
||||
this.mOnItemClickListener = clickLitener;
|
||||
this.listItemID = listItemID;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mInflater = LayoutInflater.from(mContext);
|
||||
this.mAQuery = new AQuery2(context);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public BookListAdapter(Context context, OnItemClickListener clickLitener) {
|
||||
this.context = context;
|
||||
this.mContext = context;
|
||||
this.mOnItemClickListener = clickLitener;
|
||||
|
||||
this.mAQuery = new AQuery2(context);
|
||||
}
|
||||
|
||||
public void setListener(OnItemClickListener clickLitener){
|
||||
|
@ -119,8 +147,24 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol
|
|||
return EMPTY_VIEW;
|
||||
}else if ( position < mDatas.size()) {
|
||||
//最后一个item设置为footerView
|
||||
if (mDatas.get(position) instanceof Novel) {
|
||||
return TYPE_ITEM;
|
||||
} else if ( position == mDatas.size()) {
|
||||
} else if (mDatas.get(position) instanceof TTFeedAd) {
|
||||
TTFeedAd ad = (TTFeedAd) mDatas.get(position);
|
||||
Log.d(TAG, "getItemViewType: ad.getImageMode()= " +ad.getImageMode());
|
||||
if (ad.getImageMode() == TTAdConstant.IMAGE_MODE_SMALL_IMG) {
|
||||
return ITEM_VIEW_TYPE_SMALL_PIC_AD;
|
||||
} else if (ad.getImageMode() == TTAdConstant.IMAGE_MODE_LARGE_IMG) {
|
||||
return ITEM_VIEW_TYPE_LARGE_PIC_AD;
|
||||
} else if (ad.getImageMode() == TTAdConstant.IMAGE_MODE_GROUP_IMG) {
|
||||
return ITEM_VIEW_TYPE_GROUP_PIC_AD;
|
||||
} else if (ad.getImageMode() == TTAdConstant.IMAGE_MODE_VIDEO) {
|
||||
return ITEM_VIEW_TYPE_VIDEO;
|
||||
}
|
||||
return ITEM_VIEW_TYPE_SMALL_PIC_AD;
|
||||
}
|
||||
|
||||
}else if ( position == mDatas.size()) {
|
||||
//最后一个item设置为footerView
|
||||
if(!showFootView){
|
||||
return NO_FOOTER;
|
||||
|
@ -130,7 +174,7 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol
|
|||
return TYPE_ITEM;
|
||||
}
|
||||
|
||||
|
||||
return EMPTY_VIEW;
|
||||
|
||||
// return super.getItemViewType(position);
|
||||
|
||||
|
@ -141,20 +185,25 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol
|
|||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == TYPE_FOOTER) {
|
||||
View itemView = mInflater.inflate(R.layout.load_more_footview_layout, parent, false);
|
||||
|
||||
return new FooterViewHolder(itemView);
|
||||
}else if(viewType == EMPTY_VIEW){
|
||||
EmptyViewHolder holder = new EmptyViewHolder (LayoutInflater.from(context).inflate(R.layout.recycle_list_empty_item, parent, false));
|
||||
return holder;
|
||||
}else if(viewType == NO_FOOTER){
|
||||
return new NoShowViewHolder (LayoutInflater.from(context).inflate(R.layout.recycle_list_noshow_item, parent, false));
|
||||
switch (viewType) {
|
||||
case TYPE_FOOTER:
|
||||
return new FooterViewHolder(mInflater.inflate(R.layout.load_more_footview_layout, parent, false));
|
||||
case EMPTY_VIEW:
|
||||
return new EmptyViewHolder (mInflater.inflate(R.layout.recycle_list_empty_item, parent, false));
|
||||
case NO_FOOTER:
|
||||
return new NoShowViewHolder (mInflater.inflate(R.layout.recycle_list_noshow_item, parent, false));
|
||||
case ITEM_VIEW_TYPE_SMALL_PIC_AD:
|
||||
return new SmallAdViewHolder(mInflater.inflate(R.layout.listitem_ad_small_pic, parent, false));
|
||||
case ITEM_VIEW_TYPE_LARGE_PIC_AD:
|
||||
return new LargeAdViewHolder(mInflater.inflate(R.layout.listitem_ad_large_pic, parent, false));
|
||||
case ITEM_VIEW_TYPE_GROUP_PIC_AD:
|
||||
return new GroupAdViewHolder(mInflater.inflate(R.layout.listitem_ad_group_pic, parent, false));
|
||||
case ITEM_VIEW_TYPE_VIDEO:
|
||||
return new VideoAdViewHolder(mInflater.inflate(R.layout.listitem_ad_large_video, parent, false));
|
||||
default:
|
||||
return new MyViewHolder( mInflater.inflate(listItemID, parent, false));
|
||||
}
|
||||
|
||||
View itemView = mInflater.inflate(listItemID, parent, false);
|
||||
|
||||
return new MyViewHolder(itemView);
|
||||
}
|
||||
|
||||
|
||||
|
@ -175,7 +224,7 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol
|
|||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder hd, int position) {
|
||||
|
||||
|
||||
TTFeedAd ttFeedAd;
|
||||
if (hd instanceof FooterViewHolder) {
|
||||
|
||||
|
||||
|
@ -208,27 +257,28 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol
|
|||
}
|
||||
|
||||
|
||||
else if (hd instanceof MyViewHolder) {
|
||||
else if (hd instanceof MyViewHolder && mDatas.get(position) instanceof Novel) {
|
||||
|
||||
Novel novel =(Novel) mDatas.get(position);
|
||||
MyViewHolder holder = (MyViewHolder)hd;
|
||||
holder.tvTitle.setText(mDatas.get(position).getName());
|
||||
if (holder.tvAuthor != null) holder.tvAuthor.setText(mDatas.get(position).getAuthor());
|
||||
if (holder.tvCate != null) holder.tvCate.setText(mDatas.get(position).getNovelType());
|
||||
if (holder.tvDesc != null) holder.tvDesc.setText(mDatas.get(position).getDesc());
|
||||
holder.tvTitle.setText(novel.getName());
|
||||
if (holder.tvAuthor != null) holder.tvAuthor.setText(novel.getAuthor());
|
||||
if (holder.tvCate != null) holder.tvCate.setText(novel.getNovelType());
|
||||
if (holder.tvDesc != null) holder.tvDesc.setText(novel.getDesc());
|
||||
|
||||
if (holder.tvLastRead != null) holder.tvLastRead.setText(CommonUtil.getDateString( mDatas.get(position).getLastVisit() ));
|
||||
if (holder.tvLastRead != null) holder.tvLastRead.setText(CommonUtil.getDateString( novel.getLastVisit() ));
|
||||
// if (holder.tvProgress != null) holder.tvProgress.setText( String.format("上次看到第 %s 章,共%s章",mDatas.get(position).getLastReadChapt(),mDatas.get(position).getChaptCnt()) );
|
||||
if (holder.tvProgress != null) holder.tvProgress.setText( String.format("上次看到第 %s 章",mDatas.get(position).getLastReadChapt(),mDatas.get(position).getChaptCnt()) );
|
||||
if (holder.tvReadtime != null) holder.tvReadtime.setText( "总计阅读了 "+CommonUtil.getTimeCnt4Read( mDatas.get(position).getReadtime() ,true) );
|
||||
if (holder.tvProgress != null) holder.tvProgress.setText( String.format("上次看到第 %s 章",novel.getLastReadChapt(),novel.getChaptCnt()) );
|
||||
if (holder.tvReadtime != null) holder.tvReadtime.setText( "总计阅读了 "+CommonUtil.getTimeCnt4Read( novel.getReadtime() ,true) );
|
||||
|
||||
|
||||
if (holder.tvStatus != null) holder.tvStatus.setText(mDatas.get(position).getProgress());
|
||||
if (holder.tvStatus != null) holder.tvStatus.setText(novel.getProgress());
|
||||
if (holder.imageView != null/* && !TextUtils.isEmpty(mDatas.get(position).getCover())*/) {
|
||||
// ImageUtil.loadImage(context, mDatas.get(position).getCover(), holder.imageView);
|
||||
loader.displayImage(context, NetUtil.getCoverUrl(mDatas.get(position).getCover()) ,holder.imageView);
|
||||
// ImageUtil.loadImage(mContext, mDatas.get(position).getCover(), holder.imageView);
|
||||
loader.displayImage(mContext, NetUtil.getCoverUrl(novel.getCover()) ,holder.imageView);
|
||||
}
|
||||
if (holder.imageTop != null) {
|
||||
if( mDatas.get(position).isTop()){
|
||||
if( novel.isTop()){
|
||||
holder.imageTop.setVisibility(View.VISIBLE);
|
||||
}else{
|
||||
holder.imageTop.setVisibility(View.GONE);
|
||||
|
@ -260,7 +310,7 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol
|
|||
}
|
||||
|
||||
if (holder.imageUpdate != null) {
|
||||
if( mDatas.get(position).isUpdated()){
|
||||
if( novel.isUpdated()){
|
||||
holder.imageUpdate.setVisibility(View.VISIBLE);
|
||||
}else{
|
||||
holder.imageUpdate.setVisibility(View.GONE);
|
||||
|
@ -287,6 +337,87 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol
|
|||
}
|
||||
});
|
||||
}
|
||||
}else if (hd instanceof SmallAdViewHolder) {
|
||||
ttFeedAd =(TTFeedAd) mDatas.get(position);
|
||||
SmallAdViewHolder smallAdViewHolder = (SmallAdViewHolder) hd;
|
||||
bindData(smallAdViewHolder, ttFeedAd);
|
||||
if (ttFeedAd.getImageList() != null && !ttFeedAd.getImageList().isEmpty()) {
|
||||
TTImage image = ttFeedAd.getImageList().get(0);
|
||||
if (image != null && image.isValid()) {
|
||||
mAQuery.id(smallAdViewHolder.mSmallImage).image(image.getImageUrl());
|
||||
}
|
||||
}
|
||||
|
||||
} else if (hd instanceof LargeAdViewHolder) {
|
||||
ttFeedAd =(TTFeedAd) mDatas.get(position);
|
||||
LargeAdViewHolder largeAdViewHolder = (LargeAdViewHolder) hd;
|
||||
bindData(largeAdViewHolder, ttFeedAd);
|
||||
if (ttFeedAd.getImageList() != null && !ttFeedAd.getImageList().isEmpty()) {
|
||||
TTImage image = ttFeedAd.getImageList().get(0);
|
||||
if (image != null && image.isValid()) {
|
||||
mAQuery.id(largeAdViewHolder.mLargeImage).image(image.getImageUrl());
|
||||
}
|
||||
}
|
||||
|
||||
} else if (hd instanceof GroupAdViewHolder) {
|
||||
ttFeedAd =(TTFeedAd) mDatas.get(position);
|
||||
GroupAdViewHolder groupAdViewHolder = (GroupAdViewHolder) hd;
|
||||
bindData(groupAdViewHolder, ttFeedAd);
|
||||
if (ttFeedAd.getImageList() != null && ttFeedAd.getImageList().size() >= 3) {
|
||||
TTImage image1 = ttFeedAd.getImageList().get(0);
|
||||
TTImage image2 = ttFeedAd.getImageList().get(1);
|
||||
TTImage image3 = ttFeedAd.getImageList().get(2);
|
||||
if (image1 != null && image1.isValid()) {
|
||||
mAQuery.id(groupAdViewHolder.mGroupImage1).image(image1.getImageUrl());
|
||||
}
|
||||
if (image2 != null && image2.isValid()) {
|
||||
mAQuery.id(groupAdViewHolder.mGroupImage2).image(image2.getImageUrl());
|
||||
}
|
||||
if (image3 != null && image3.isValid()) {
|
||||
mAQuery.id(groupAdViewHolder.mGroupImage3).image(image3.getImageUrl());
|
||||
}
|
||||
}
|
||||
|
||||
} else if (hd instanceof VideoAdViewHolder) {
|
||||
ttFeedAd = (TTFeedAd)mDatas.get(position);
|
||||
VideoAdViewHolder videoAdViewHolder = (VideoAdViewHolder) hd;
|
||||
bindData(videoAdViewHolder, ttFeedAd);
|
||||
ttFeedAd.setVideoAdListener(new TTFeedAd.VideoAdListener() {
|
||||
@Override
|
||||
public void onVideoLoad(TTFeedAd ad) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVideoError(int errorCode, int extraCode) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVideoAdStartPlay(TTFeedAd ad) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVideoAdPaused(TTFeedAd ad) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVideoAdContinuePlay(TTFeedAd ad) {
|
||||
|
||||
}
|
||||
});
|
||||
if (videoAdViewHolder.videoView != null) {
|
||||
View video = ttFeedAd.getAdView();
|
||||
if (video != null) {
|
||||
if (video.getParent() == null) {
|
||||
videoAdViewHolder.videoView.removeAllViews();
|
||||
videoAdViewHolder.videoView.addView(video);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -338,8 +469,9 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol
|
|||
|
||||
}
|
||||
}
|
||||
public void AddHeaderItem(List<Novel> items) {
|
||||
mDatas.addAll(0, items);
|
||||
public void AddHeaderItem(List items) {
|
||||
int p = mDatas.size()>3?3:0;
|
||||
mDatas.addAll(p, items);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
public void setData(List<Novel> items) {
|
||||
|
@ -347,7 +479,7 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol
|
|||
mDatas = items;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
public void AddFooterItem(List<Novel> items) {
|
||||
public void AddFooterItem(List items) {
|
||||
mDatas.addAll(items);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
@ -360,6 +492,309 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol
|
|||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||
super.onAttachedToRecyclerView(recyclerView);
|
||||
|
||||
RecyclerView.LayoutManager layout = recyclerView.getLayoutManager();
|
||||
if (layout != null && layout instanceof GridLayoutManager) {
|
||||
final GridLayoutManager manager = (GridLayoutManager) layout;
|
||||
manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
||||
@Override
|
||||
public int getSpanSize(int position) {
|
||||
int type = getItemViewType(position);
|
||||
if (/*type == ITEM_VIEW_TYPE_LOAD_MORE ||*/ type == ITEM_VIEW_TYPE_VIDEO) {
|
||||
return manager.getSpanCount();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewAttachedToWindow(@NonNull RecyclerView.ViewHolder holder) {
|
||||
//noinspection unchecked
|
||||
super.onViewAttachedToWindow(holder);
|
||||
ViewGroup.LayoutParams lp = holder.itemView.getLayoutParams();
|
||||
if (lp != null && lp instanceof StaggeredGridLayoutManager.LayoutParams) {
|
||||
int position = holder.getLayoutPosition();
|
||||
int type = getItemViewType(position);
|
||||
if (/*type == ITEM_VIEW_TYPE_LOAD_MORE || */type == ITEM_VIEW_TYPE_VIDEO) {
|
||||
StaggeredGridLayoutManager.LayoutParams p = (StaggeredGridLayoutManager.LayoutParams) lp;
|
||||
p.setFullSpan(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
private static class VideoAdViewHolder extends AdViewHolder {
|
||||
@SuppressWarnings("CanBeFinal")
|
||||
FrameLayout videoView;
|
||||
|
||||
@SuppressWarnings("RedundantCast")
|
||||
public VideoAdViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
mTitle = (TextView) itemView.findViewById(R.id.tv_listitem_ad_title);
|
||||
mDescription = (TextView) itemView.findViewById(R.id.tv_listitem_ad_desc);
|
||||
mSource = (TextView) itemView.findViewById(R.id.tv_listitem_ad_source);
|
||||
videoView = (FrameLayout) itemView.findViewById(R.id.iv_listitem_video);
|
||||
mIcon = (ImageView) itemView.findViewById(R.id.iv_listitem_icon);
|
||||
mCreativeButton = (Button) itemView.findViewById(R.id.btn_listitem_creative);
|
||||
// mStopButton = (Button) itemView.findViewById(R.id.btn_listitem_stop);
|
||||
// mRemoveButton = (Button) itemView.findViewById(R.id.btn_listitem_remove);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static class LargeAdViewHolder extends AdViewHolder {
|
||||
ImageView mLargeImage;
|
||||
|
||||
@SuppressWarnings("RedundantCast")
|
||||
public LargeAdViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
mTitle = (TextView) itemView.findViewById(R.id.tv_listitem_ad_title);
|
||||
mDescription = (TextView) itemView.findViewById(R.id.tv_listitem_ad_desc);
|
||||
mSource = (TextView) itemView.findViewById(R.id.tv_listitem_ad_source);
|
||||
mLargeImage = (ImageView) itemView.findViewById(R.id.iv_listitem_image);
|
||||
mIcon = (ImageView) itemView.findViewById(R.id.iv_listitem_icon);
|
||||
mCreativeButton = (Button) itemView.findViewById(R.id.btn_listitem_creative);
|
||||
// mStopButton = (Button) itemView.findViewById(R.id.btn_listitem_stop);
|
||||
// mRemoveButton = (Button) itemView.findViewById(R.id.btn_listitem_remove);
|
||||
}
|
||||
}
|
||||
|
||||
private static class SmallAdViewHolder extends AdViewHolder {
|
||||
ImageView mSmallImage;
|
||||
|
||||
@SuppressWarnings("RedundantCast")
|
||||
public SmallAdViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
mTitle = (TextView) itemView.findViewById(R.id.tv_listitem_ad_title);
|
||||
mSource = (TextView) itemView.findViewById(R.id.tv_listitem_ad_source);
|
||||
mDescription = (TextView) itemView.findViewById(R.id.tv_listitem_ad_desc);
|
||||
mSmallImage = (ImageView) itemView.findViewById(R.id.iv_listitem_image);
|
||||
mIcon = (ImageView) itemView.findViewById(R.id.iv_listitem_icon);
|
||||
mCreativeButton = (Button) itemView.findViewById(R.id.btn_listitem_creative);
|
||||
// mStopButton = (Button) itemView.findViewById(R.id.btn_listitem_stop);
|
||||
// mRemoveButton = (Button) itemView.findViewById(R.id.btn_listitem_remove);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("CanBeFinal")
|
||||
private static class GroupAdViewHolder extends AdViewHolder {
|
||||
ImageView mGroupImage1;
|
||||
ImageView mGroupImage2;
|
||||
ImageView mGroupImage3;
|
||||
|
||||
@SuppressWarnings("RedundantCast")
|
||||
public GroupAdViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
mTitle = (TextView) itemView.findViewById(R.id.tv_listitem_ad_title);
|
||||
mSource = (TextView) itemView.findViewById(R.id.tv_listitem_ad_source);
|
||||
mDescription = (TextView) itemView.findViewById(R.id.tv_listitem_ad_desc);
|
||||
mGroupImage1 = (ImageView) itemView.findViewById(R.id.iv_listitem_image1);
|
||||
mGroupImage2 = (ImageView) itemView.findViewById(R.id.iv_listitem_image2);
|
||||
mGroupImage3 = (ImageView) itemView.findViewById(R.id.iv_listitem_image3);
|
||||
mIcon = (ImageView) itemView.findViewById(R.id.iv_listitem_icon);
|
||||
mCreativeButton = (Button) itemView.findViewById(R.id.btn_listitem_creative);
|
||||
// mStopButton = (Button) itemView.findViewById(R.id.btn_listitem_stop);
|
||||
// mRemoveButton = (Button) itemView.findViewById(R.id.btn_listitem_remove);
|
||||
}
|
||||
}
|
||||
|
||||
private static class AdViewHolder extends RecyclerView.ViewHolder {
|
||||
ImageView mIcon;
|
||||
Button mCreativeButton;
|
||||
TextView mTitle;
|
||||
TextView mDescription;
|
||||
TextView mSource;
|
||||
// Button mStopButton;
|
||||
// Button mRemoveButton;
|
||||
|
||||
public AdViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
}
|
||||
private void bindData(final AdViewHolder adViewHolder, TTFeedAd ad) {
|
||||
//可以被点击的view, 也可以把convertView放进来意味item可被点击
|
||||
List<View> clickViewList = new ArrayList<>();
|
||||
clickViewList.add(adViewHolder.itemView);
|
||||
//触发创意广告的view(点击下载或拨打电话)
|
||||
List<View> creativeViewList = new ArrayList<>();
|
||||
creativeViewList.add(adViewHolder.mCreativeButton);
|
||||
//如果需要点击图文区域也能进行下载或者拨打电话动作,请将图文区域的view传入
|
||||
// creativeViewList.add(convertView);
|
||||
//重要! 这个涉及到广告计费,必须正确调用。convertView必须使用ViewGroup。
|
||||
ad.registerViewForInteraction((ViewGroup) adViewHolder.itemView, clickViewList, creativeViewList, new TTNativeAd.AdInteractionListener() {
|
||||
@Override
|
||||
public void onAdClicked(View view, TTNativeAd ad) {
|
||||
if (ad != null) {
|
||||
// TToast.show(mContext, "广告" + ad.getTitle() + "被点击");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdCreativeClick(View view, TTNativeAd ad) {
|
||||
if (ad != null) {
|
||||
// TToast.show(mContext, "广告" + ad.getTitle() + "被创意按钮被点击");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdShow(TTNativeAd ad) {
|
||||
if (ad != null) {
|
||||
// TToast.show(mContext, "广告" + ad.getTitle() + "展示");
|
||||
}
|
||||
}
|
||||
});
|
||||
adViewHolder.mTitle.setText(ad.getTitle());
|
||||
adViewHolder.mDescription.setText(ad.getDescription());
|
||||
adViewHolder.mSource.setText(ad.getSource() == null ? "广告来源" : ad.getSource());
|
||||
TTImage icon = ad.getIcon();
|
||||
if (icon != null && icon.isValid()) {
|
||||
ImageOptions options = new ImageOptions();
|
||||
mAQuery.id(adViewHolder.mIcon).image(icon.getImageUrl(), options);
|
||||
}
|
||||
Button adCreativeButton = adViewHolder.mCreativeButton;
|
||||
switch (ad.getInteractionType()) {
|
||||
case TTAdConstant.INTERACTION_TYPE_DOWNLOAD:
|
||||
//如果初始化ttAdManager.createAdNative(getApplicationContext())没有传入activity 则需要在此传activity,否则影响使用Dislike逻辑
|
||||
if (mContext instanceof Activity) {
|
||||
ad.setActivityForDownloadApp((Activity) mContext);
|
||||
}
|
||||
adCreativeButton.setVisibility(View.VISIBLE);
|
||||
// adViewHolder.mStopButton.setVisibility(View.VISIBLE);
|
||||
// adViewHolder.mRemoveButton.setVisibility(View.VISIBLE);
|
||||
bindDownloadListener(adCreativeButton, adViewHolder, ad);
|
||||
//绑定下载状态控制器
|
||||
bindDownLoadStatusController(adViewHolder, ad);
|
||||
break;
|
||||
case TTAdConstant.INTERACTION_TYPE_DIAL:
|
||||
adCreativeButton.setVisibility(View.VISIBLE);
|
||||
adCreativeButton.setText("立即拨打");
|
||||
// adViewHolder.mStopButton.setVisibility(View.GONE);
|
||||
// adViewHolder.mRemoveButton.setVisibility(View.GONE);
|
||||
break;
|
||||
case TTAdConstant.INTERACTION_TYPE_LANDING_PAGE:
|
||||
case TTAdConstant.INTERACTION_TYPE_BROWSER:
|
||||
// adCreativeButton.setVisibility(View.GONE);
|
||||
adCreativeButton.setVisibility(View.VISIBLE);
|
||||
adCreativeButton.setText("查看详情");
|
||||
// adViewHolder.mStopButton.setVisibility(View.GONE);
|
||||
// adViewHolder.mRemoveButton.setVisibility(View.GONE);
|
||||
break;
|
||||
default:
|
||||
adCreativeButton.setVisibility(View.GONE);
|
||||
// adViewHolder.mStopButton.setVisibility(View.GONE);
|
||||
// adViewHolder.mRemoveButton.setVisibility(View.GONE);
|
||||
// TToast.show(mContext, "交互类型异常");
|
||||
}
|
||||
}
|
||||
|
||||
private void bindDownLoadStatusController(AdViewHolder adViewHolder, final TTFeedAd ad) {
|
||||
final DownloadStatusController controller = ad.getDownloadStatusController();
|
||||
/* adViewHolder.mStopButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (controller != null) {
|
||||
controller.changeDownloadStatus();
|
||||
// TToast.show(mContext, "改变下载状态");
|
||||
Log.d(TAG, "改变下载状态");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
adViewHolder.mRemoveButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (controller != null) {
|
||||
controller.cancelDownload();
|
||||
// TToast.show(mContext, "取消下载");
|
||||
Log.d(TAG, "取消下载");
|
||||
}
|
||||
}
|
||||
});*/
|
||||
}
|
||||
|
||||
private void bindDownloadListener(final Button adCreativeButton, final AdViewHolder adViewHolder, TTFeedAd ad) {
|
||||
TTAppDownloadListener downloadListener = new TTAppDownloadListener() {
|
||||
@Override
|
||||
public void onIdle() {
|
||||
if (!isValid()) {
|
||||
return;
|
||||
}
|
||||
adCreativeButton.setText("开始下载");
|
||||
// adViewHolder.mStopButton.setText("开始下载");
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onDownloadActive(long totalBytes, long currBytes, String fileName, String appName) {
|
||||
if (!isValid()) {
|
||||
return;
|
||||
}
|
||||
if (totalBytes <= 0L) {
|
||||
adCreativeButton.setText("下载中 percent: 0");
|
||||
} else {
|
||||
adCreativeButton.setText("下载中 percent: " + (currBytes * 100 / totalBytes));
|
||||
}
|
||||
// adViewHolder.mStopButton.setText("下载中");
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onDownloadPaused(long totalBytes, long currBytes, String fileName, String appName) {
|
||||
if (!isValid()) {
|
||||
return;
|
||||
}
|
||||
if (totalBytes <= 0L) {
|
||||
adCreativeButton.setText("下载中 percent: 0");
|
||||
} else {
|
||||
adCreativeButton.setText("下载暂停 percent: " + (currBytes * 100 / totalBytes));
|
||||
}
|
||||
// adViewHolder.mStopButton.setText("下载暂停");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadFailed(long totalBytes, long currBytes, String fileName, String appName) {
|
||||
if (!isValid()) {
|
||||
return;
|
||||
}
|
||||
adCreativeButton.setText("重新下载");
|
||||
// adViewHolder.mStopButton.setText("重新下载");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInstalled(String fileName, String appName) {
|
||||
if (!isValid()) {
|
||||
return;
|
||||
}
|
||||
adCreativeButton.setText("点击打开");
|
||||
// adViewHolder.mStopButton.setText("点击打开");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadFinished(long totalBytes, String fileName, String appName) {
|
||||
if (!isValid()) {
|
||||
return;
|
||||
}
|
||||
adCreativeButton.setText("点击安装");
|
||||
// adViewHolder.mStopButton.setText("点击安装");
|
||||
}
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
private boolean isValid() {
|
||||
return mTTAppDownloadListenerMap.get(adViewHolder) == this;
|
||||
}
|
||||
};
|
||||
//一个ViewHolder对应一个downloadListener, isValid判断当前ViewHolder绑定的listener是不是自己
|
||||
ad.setDownloadListener(downloadListener); // 注册下载监听器
|
||||
mTTAppDownloadListenerMap.put(adViewHolder, downloadListener);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1601,6 +1601,9 @@ int muluRetryCount =0;
|
|||
|
||||
return error.toCharArray();
|
||||
}
|
||||
if( Constants.AD_PRE_LOAD_CHAPT) {
|
||||
|
||||
|
||||
if (mChapters.size() > index && NetUtil.isNetworkConnected()) {
|
||||
|
||||
if (!chaptDownStatus.containsKey(index + 1) || chaptDownStatus.get(index + 1).equals(DownloadStatus.failure)) {
|
||||
|
@ -1628,6 +1631,7 @@ int muluRetryCount =0;
|
|||
|
||||
}
|
||||
}
|
||||
}
|
||||
// mChangeChapId =0;
|
||||
int size = (int) file.length();
|
||||
if (size < 0) {
|
||||
|
|
|
@ -14,6 +14,7 @@ public class Constants {
|
|||
public static final int MAXAGE_MULU = 60*60*24*7*2; //2周;;
|
||||
public static final String VERSION_ADDRESS ="version.xml";
|
||||
public static final boolean SHOWAD =true ;
|
||||
public static boolean AD_PRE_LOAD_CHAPT = false;
|
||||
public static long AD_SPLASH_INVTERVAL = 5*60*1000;//间隔5分钟
|
||||
public static int AD_SPLASH_PAGES = 15;
|
||||
public static int SCREEN_HEIGHT_PIX =1920 ;
|
||||
|
|
|
@ -35,6 +35,9 @@ public class HistoryCache {
|
|||
Gson gson = new Gson();
|
||||
List<String> retList = (List)gson.fromJson(history, (new TypeToken<List<String>>() {
|
||||
}).getType());
|
||||
if(retList.size()>9){
|
||||
return retList.subList(0,9);
|
||||
}
|
||||
return retList;
|
||||
}
|
||||
|
||||
|
|
|
@ -337,7 +337,7 @@ public class PageFactory implements ChangeSource{
|
|||
public void run() {
|
||||
int slepttime =0;
|
||||
File file = new File(getChapterFileName(chid));
|
||||
while( !file.exists() && slepttime <60 && mBookUtil.muluRetryCount<Constants.retryCnt){
|
||||
while( !file.exists() && slepttime <60 && mBookUtil.muluRetryCount<Constants.retryCnt ||showingStatusAd &&(new Date().getTime() - showStatusAdTime <2200) ){
|
||||
try {
|
||||
sleep(50);
|
||||
slepttime++;
|
||||
|
@ -391,6 +391,10 @@ public class PageFactory implements ChangeSource{
|
|||
}
|
||||
|
||||
void preReadChaptCache(final int chaptId){
|
||||
|
||||
if(!Constants.AD_PRE_LOAD_CHAPT){
|
||||
return;
|
||||
}
|
||||
if(chaptMap==null) {
|
||||
chaptMap = new ConcurrentHashMap<Integer, List<TRPage>>();
|
||||
}
|
||||
|
@ -712,6 +716,8 @@ private void hideSysUI(){
|
|||
}
|
||||
private String loadingTxt ="";
|
||||
private String statusChangeSource ="正在换源...";
|
||||
private boolean showingStatusAd =false;
|
||||
private long showStatusAdTime =0;
|
||||
private void drawStatus(Bitmap bitmap){
|
||||
hideSysUI();
|
||||
mAd.showRefresh(View.VISIBLE);
|
||||
|
@ -769,7 +775,7 @@ private void hideSysUI(){
|
|||
// c.drawRect(targetRect, waitPaint);
|
||||
Paint.FontMetricsInt fontMetrics = waitPaint.getFontMetricsInt();
|
||||
// 转载请注明出处:http://blog.csdn.net/hursing
|
||||
int baseline = (targetRect.bottom + targetRect.top - fontMetrics.bottom - fontMetrics.top) / 2;
|
||||
int baseline = (targetRect.bottom + targetRect.top - fontMetrics.bottom - fontMetrics.top) *4/5;
|
||||
// 下面这行是实现水平居中,drawText对应改为传入targetRect.centerX()
|
||||
waitPaint.setTextAlign(Paint.Align.CENTER);
|
||||
c.drawText(status, targetRect.centerX(), baseline, waitPaint);
|
||||
|
@ -783,11 +789,28 @@ private void hideSysUI(){
|
|||
|
||||
mBookPageWidget.postInvalidate();
|
||||
// hideSysUI();
|
||||
/* float adHeight = mHeight - baseline -marginHeight-statusMarginBottom-30;
|
||||
float adY =targetRect.top +10;*/
|
||||
|
||||
float adHeight = baseline -100;
|
||||
float adY =targetRect.top +250;
|
||||
|
||||
while(!showingStatusAd || new Date().getTime() - showStatusAdTime > 2000) {
|
||||
showingStatusAd =true;
|
||||
showStatusAdTime = new Date().getTime();
|
||||
showAd((int) adHeight, (int) adY);
|
||||
Log.d(TAG, "loadBannerAd: AD is requested");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//上次翻书时间
|
||||
private long lastPageTime;
|
||||
public void onDraw(Bitmap bitmap,List<String> m_lines,Boolean updateChapter) {
|
||||
|
||||
public void onDraw(Bitmap bitmap,List<String> m_lines,Boolean updateChapter,Boolean showAd) {
|
||||
hideSysUI();
|
||||
// mAd.showRefresh(View.GONE);
|
||||
if(m_lines.size()==0){
|
||||
|
@ -801,14 +824,14 @@ private void hideSysUI(){
|
|||
// Log.d(TAG, String.format(" prepare book onDraw chapter after getCurrentChapter(),currentChapter %s ",currentChapter ) );
|
||||
}
|
||||
// Log.d(TAG, String.format(" prepare book onDraw chapter _____________ %s ",currentChapter ) );
|
||||
//更新数据库进度
|
||||
|
||||
showingStatusAd =false;
|
||||
if(mAd!=null){
|
||||
|
||||
handler.sendEmptyMessage(MSG_HIDEPROGRESS);
|
||||
}
|
||||
|
||||
|
||||
//更新数据库进度
|
||||
if ( mStatus ==Status.FINISH && currentPage != null && getNovel() != null) {
|
||||
new Thread() {
|
||||
@Override
|
||||
|
@ -898,7 +921,10 @@ private void hideSysUI(){
|
|||
|
||||
float adHeight = mHeight -y - space -marginHeight-statusMarginBottom;
|
||||
float adY =y +space;
|
||||
showAd((int)adHeight,(int)adY);
|
||||
if(showAd) {
|
||||
showAd((int) adHeight, (int) adY);
|
||||
Log.d(TAG, "loadBannerAd: AD is requested");
|
||||
}
|
||||
// Log.d(TAG,String.format("ad + statusMarginBottom %s ",200+ statusMarginBottom));
|
||||
// Log.d(TAG,String.format("adHeight %s, adY %s",adHeight,adY));
|
||||
}
|
||||
|
@ -988,9 +1014,9 @@ private void hideSysUI(){
|
|||
|
||||
private void showAd(int adHeight,int adY) {
|
||||
|
||||
boolean showAd = getCurrentPage().getPageNo() > 1
|
||||
&&NetWorkUtil.isNetworkConnected(mContext);
|
||||
boolean showAd = showingStatusAd || getCurrentPage()==null || getCurrentPage().getPageNo() > 1;
|
||||
|
||||
// boolean showAd =true;
|
||||
if (mAd != null) {
|
||||
mAd.showAd(showAd,adHeight, adY);
|
||||
}
|
||||
|
@ -1022,12 +1048,14 @@ private void hideSysUI(){
|
|||
if(mBookPageWidget==null){
|
||||
return;
|
||||
}
|
||||
onDraw(mBookPageWidget.getCurPage(),currentPage.getLines(),true);
|
||||
Log.d(TAG, " prePage() onDraw: mBookPageWidget.getCurPage() ");
|
||||
onDraw(mBookPageWidget.getCurPage(),currentPage.getLines(),true,false);
|
||||
currentPage = getPrePage();
|
||||
if(mBookPageWidget==null){
|
||||
return;
|
||||
}
|
||||
onDraw(mBookPageWidget.getNextPage(),currentPage.getLines(),true);
|
||||
Log.d(TAG, " prePage() onDraw: mBookPageWidget.getNextPage() ");
|
||||
onDraw(mBookPageWidget.getNextPage(),currentPage.getLines(),true,true);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1098,14 +1126,16 @@ private void hideSysUI(){
|
|||
if(mBookPageWidget==null){
|
||||
return;
|
||||
}
|
||||
onDraw(mBookPageWidget.getCurPage(),currentPage.getLines(),true);
|
||||
Log.d(TAG, "nextPage() onDraw: mBookPageWidget.getCurPage() ");
|
||||
onDraw(mBookPageWidget.getCurPage(),currentPage.getLines(),true,false);
|
||||
prePage = currentPage;
|
||||
currentPage = getNextPage();
|
||||
// currentPage = currentChaptPages.get(currentPage.getPageNo()-1);
|
||||
if(mBookPageWidget==null){
|
||||
return;
|
||||
}
|
||||
onDraw(mBookPageWidget.getNextPage(),currentPage.getLines(),true);
|
||||
Log.d(TAG, "nextPage() onDraw: mBookPageWidget.getNextPage() ");
|
||||
onDraw(mBookPageWidget.getNextPage(),currentPage.getLines(),true,true);
|
||||
Log.d("nextPage","nextPagenext");
|
||||
|
||||
HashMap<String,String> map = new HashMap<String,String>();
|
||||
|
@ -1588,8 +1618,10 @@ private void hideSysUI(){
|
|||
if(mBookPageWidget==null){
|
||||
return;
|
||||
}
|
||||
onDraw(mBookPageWidget.getCurPage(),currentPage.getLines(),updateChapter);
|
||||
onDraw(mBookPageWidget.getNextPage(),currentPage.getLines(),updateChapter);
|
||||
Log.d(TAG, "currentPage onDraw: mBookPageWidget.getCurPage() ");
|
||||
onDraw(mBookPageWidget.getCurPage(),currentPage.getLines(),updateChapter,false);
|
||||
Log.d(TAG, "currentPage onDraw: mBookPageWidget.getNextPage() ");
|
||||
onDraw(mBookPageWidget.getNextPage(),currentPage.getLines(),updateChapter,true);
|
||||
}
|
||||
|
||||
//更新电量
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -1,10 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Activity_shudan">
|
||||
android:orientation="vertical"
|
||||
>
|
||||
|
||||
|
||||
|
||||
|
@ -17,6 +19,13 @@
|
|||
app:search_baground="@drawable/search_baground_shap"
|
||||
/>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_weight="0"
|
||||
android:gravity="bottom"
|
||||
style="@style/frmBannerContainer"
|
||||
android:layout_height="400dp"
|
||||
android:id="@+id/banner_container"/>
|
||||
<LinearLayout style="@style/llGraySplit" />
|
||||
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
</LinearLayout>
|
|
@ -5,14 +5,24 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="#000000"
|
||||
|
||||
tools:context=".AD.toutiao.SplashActivity">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/splash_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#000000"
|
||||
>
|
||||
</FrameLayout>
|
||||
<TextView android:id="@+id/textTile"
|
||||
android:layout_weight="0"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
android:text="" />
|
||||
</LinearLayout>
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
|
||||
<Button
|
||||
android:id="@+id/btn_native_creative"
|
||||
style="@style/buttonCates"
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
|
|
|
@ -209,7 +209,7 @@
|
|||
</LinearLayout>
|
||||
<FrameLayout
|
||||
style="@style/frmBannerContainer"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="200dp"
|
||||
android:id="@+id/banner_container"/>
|
||||
<LinearLayout style="@style/llGraySplit" />
|
||||
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
style="@style/llOutside.vertical"
|
||||
tools:context=".Fragments.Fragment_jingxuan">
|
||||
<FrameLayout
|
||||
android:id="@+id/banner_container"
|
||||
style="@style/frmBannerContainer"/>
|
||||
|
||||
<android.support.v4.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipeLayout"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -33,7 +31,10 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="150dp" />
|
||||
|
||||
<include layout="@layout/fragment_jingxuan_cates" />
|
||||
<FrameLayout
|
||||
android:id="@+id/banner_container"
|
||||
style="@style/frmBannerContainer"/>
|
||||
<!-- <include layout="@layout/fragment_jingxuan_cates" />-->
|
||||
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -0,0 +1,137 @@
|
|||
<?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="wrap_content"
|
||||
tools:ignore="HardcodedText">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_listitem_ad_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:singleLine="false"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_image_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/tv_listitem_ad_title"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_listitem_image1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_weight="1"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_listitem_image2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_weight="1"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_listitem_image3"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_weight="1"
|
||||
android:scaleType="centerCrop" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_listitem_icon"
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_below="@id/layout_image_group"
|
||||
android:layout_marginStart="3dp"
|
||||
android:layout_marginLeft="3dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/tv_source_desc_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/layout_image_group"
|
||||
android:layout_toEndOf="@id/iv_listitem_icon"
|
||||
android:layout_toRightOf="@id/iv_listitem_icon"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_listitem_ad_desc"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_listitem_ad_source"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textSize="10sp" />
|
||||
|
||||
<!--==== 测试下载状态控制功能 begin ========-->
|
||||
<!-- <LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_listitem_stop"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="暂停"
|
||||
android:visibility="gone" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_listitem_remove"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="删除"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>-->
|
||||
<!--==== 测试下载状态控制功能 end ========-->
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_listitem_creative"
|
||||
style="@style/buttonCates"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_alignTop="@+id/tv_source_desc_layout"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginEnd="14dp"
|
||||
android:layout_marginRight="14dp"
|
||||
android:textSize="10sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_listitem_dislike"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:clickable="true"
|
||||
android:src="@drawable/dislike_icon" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,109 @@
|
|||
<?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="wrap_content"
|
||||
tools:ignore="HardcodedText">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_listitem_ad_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:singleLine="false"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_listitem_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
android:layout_below="@id/tv_listitem_ad_title"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_listitem_icon"
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_below="@id/iv_listitem_image"
|
||||
android:layout_marginStart="3dp"
|
||||
android:layout_marginLeft="3dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/tv_source_desc_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/iv_listitem_image"
|
||||
android:layout_toEndOf="@id/iv_listitem_icon"
|
||||
android:layout_toRightOf="@id/iv_listitem_icon"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_listitem_ad_desc"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_listitem_ad_source"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textSize="10sp" />
|
||||
|
||||
<!--==== 测试下载状态控制功能 begin ========-->
|
||||
<!-- <LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_listitem_stop"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="暂停"
|
||||
android:visibility="gone" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_listitem_remove"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="删除"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>-->
|
||||
<!--==== 测试下载状态控制功能 end ========-->
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_listitem_creative"
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignTop="@+id/tv_source_desc_layout"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginEnd="14dp"
|
||||
android:layout_marginRight="14dp"
|
||||
android:textSize="10sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_listitem_dislike"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:clickable="true"
|
||||
android:src="@drawable/dislike_icon" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,109 @@
|
|||
<?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="wrap_content"
|
||||
tools:ignore="HardcodedText">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_listitem_ad_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:singleLine="false"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/iv_listitem_video"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
android:layout_below="@id/tv_listitem_ad_title"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_listitem_icon"
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_below="@id/iv_listitem_video"
|
||||
android:layout_marginStart="3dp"
|
||||
android:layout_marginLeft="3dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/tv_source_desc_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/iv_listitem_video"
|
||||
android:layout_toEndOf="@id/iv_listitem_icon"
|
||||
android:layout_toRightOf="@id/iv_listitem_icon"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_listitem_ad_desc"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_listitem_ad_source"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textSize="10sp" />
|
||||
|
||||
<!--==== 测试下载状态控制功能 begin ========-->
|
||||
<!-- <LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_listitem_stop"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="暂停"
|
||||
android:visibility="gone" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_listitem_remove"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="删除"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>-->
|
||||
<!--==== 测试下载状态控制功能 end ========-->
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_listitem_creative"
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignTop="@+id/tv_source_desc_layout"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginEnd="14dp"
|
||||
android:layout_marginRight="14dp"
|
||||
android:textSize="10sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_listitem_dislike"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:clickable="true"
|
||||
android:src="@drawable/dislike_icon" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,125 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="HardcodedText">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_listitem_image"
|
||||
style="@style/NovelImage.horizon"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_weight="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_toStartOf="@+id/iv_listitem_image"
|
||||
android:layout_toLeftOf="@+id/iv_listitem_image"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_listitem_ad_title"
|
||||
style="@style/TextViewNovelTitle.horizon"
|
||||
/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_listitem_icon"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginLeft="10dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/tv_source_desc_layout"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/layout_image_group"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_toEndOf="@id/iv_listitem_icon"
|
||||
android:layout_toRightOf="@id/iv_listitem_icon"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_listitem_ad_desc"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="20dp"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textSize="10sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_listitem_ad_source"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textSize="8sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<!--==== 测试下载状态控制功能 begin ========-->
|
||||
<!-- <LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_listitem_stop"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="暂停"
|
||||
android:visibility="gone" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_listitem_remove"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="删除"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>-->
|
||||
<!--==== 测试下载状态控制功能 end ========-->
|
||||
<Button
|
||||
android:id="@+id/btn_listitem_creative"
|
||||
style="@style/buttonCates"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
|
||||
android:textSize="9sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_listitem_dislike"
|
||||
android:layout_weight="0"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:clickable="true"
|
||||
android:src="@drawable/dislike_icon" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
@ -49,9 +49,9 @@
|
|||
android:layout_height="35dp"
|
||||
android:src="@mipmap/loading"
|
||||
android:scaleType="centerCrop"
|
||||
android:layout_gravity="center"
|
||||
android:layout_gravity="center_horizontal|bottom"
|
||||
android:visibility="gone"
|
||||
android:layout_marginBottom="60dp"
|
||||
android:layout_marginBottom="160dp"
|
||||
android:contentDescription="TODO" />
|
||||
|
||||
<Button
|
||||
|
@ -59,8 +59,8 @@
|
|||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/buttonRound"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="80dp"
|
||||
android:layout_gravity="center_horizontal|bottom"
|
||||
android:layout_marginBottom="160dp"
|
||||
android:text="@string/refresh"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
@ -74,6 +74,8 @@
|
|||
|
||||
|
||||
</LinearLayout>-->
|
||||
|
||||
|
||||
<FrameLayout
|
||||
style="@style/frmBannerContainer"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -175,6 +175,11 @@
|
|||
<item name="android:scaleType">fitStart</item>
|
||||
<item name="android:paddingTop">2dp</item>
|
||||
</style>
|
||||
<style name="NovelImage.grid">
|
||||
<item name="android:layout_width">100dp</item>
|
||||
<item name="android:layout_height">120dp</item>
|
||||
|
||||
</style>
|
||||
<style name="NovelImage.horizon">
|
||||
<item name="android:layout_weight">0</item>
|
||||
<!--item name="android:gravity">left|center_vertical</item -->
|
||||
|
@ -449,7 +454,7 @@
|
|||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">50dp</item>
|
||||
<item name="android:layout_centerInParent">true</item>
|
||||
<item name="android:background">@color/transparent</item>
|
||||
<item name="android:background">@color/mintcream</item>
|
||||
</style>
|
||||
|
||||
|
||||
|
|
|
@ -104,7 +104,6 @@
|
|||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javac" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/legacy_multidex_aapt_derived_proguard_rules" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/legacy_multidex_main_dex_list" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifest-checker" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_manifests" />
|
||||
|
|
Loading…
Reference in New Issue