320个文件已添加
166个文件已修改
54个文件已删除
| | |
| | | dependencies { |
| | | api fileTree(include: '*.jar', dir: 'libs') |
| | | api files('libs/android-async-http-1.4.8.jar') |
| | | implementation 'com.android.support:support-v4:27.1.1' |
| | | implementation 'androidx.legacy:legacy-support-v4:1.0.0' |
| | | implementation project(path: ':library-common') |
| | | } |
| | | |
| | | android { |
| | | |
| | | useLibrary 'org.apache.http.legacy' |
| | | compileSdkVersion 26 |
| | | compileSdkVersion 28 |
| | | |
| | | buildToolsVersion '28.0.3' |
| | | defaultConfig { |
| | | minSdkVersion 17 |
| | | targetSdkVersion 26 |
| | | targetSdkVersion 28 |
| | | } |
| | | compileOptions { |
| | | sourceCompatibility JavaVersion.VERSION_1_7 |
| | |
| | | |
| | | dependencies { |
| | | api fileTree(include: '*.jar', dir: 'libs') |
| | | implementation 'com.android.support:support-v4:27.1.1' |
| | | implementation 'androidx.legacy:legacy-support-v4:1.0.0' |
| | | } |
| | | |
| | | android { |
| | |
| | | import android.annotation.TargetApi; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.Fragment; |
| | | import androidx.fragment.app.Fragment; |
| | | |
| | | /** |
| | | * Factory to allow injecting a more complex exception mapping; typically you would subclass one of {@link Honeycomb} or |
| | |
| | | import android.content.DialogInterface.OnClickListener; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.DialogFragment; |
| | | import androidx.fragment.app.DialogFragment; |
| | | import de.greenrobot.event.EventBus; |
| | | |
| | | public class ErrorDialogFragments { |
| | |
| | | import android.app.Application; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.DialogFragment; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.FragmentActivity; |
| | | import android.support.v4.app.FragmentManager; |
| | | import androidx.fragment.app.DialogFragment; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentActivity; |
| | | import androidx.fragment.app.FragmentManager; |
| | | import android.util.Log; |
| | | import de.greenrobot.event.EventBus; |
| | | |
| | |
| | | existingFragment.dismiss(); |
| | | } |
| | | |
| | | android.support.v4.app.DialogFragment errorFragment = (android.support.v4.app.DialogFragment) factory |
| | | DialogFragment errorFragment = (DialogFragment) factory |
| | | .prepareErrorFragment(event, finishAfterDialog, argumentsForErrorDialog); |
| | | if (errorFragment != null) { |
| | | errorFragment.show(fm, TAG_ERROR_DIALOG); |
| | |
| | | |
| | | dependencies { |
| | | api fileTree(include: '*.jar', dir: 'libs') |
| | | api files('libs/GDTSDK.unionNormal.4.176.1046.aar') |
| | | } |
| | | |
| | | android { |
| | |
| | | <permission android:name="android.permission.WRITE_MEDIA_STORAGE"></permission> |
| | | |
| | | <uses-permission android:name="android.permission.INTERNET" /> |
| | | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
| | | <uses-permission android:name="android.permission.WAKE_LOCK" /> |
| | | <uses-permission android:name="android.permission.VIBRATE" /> |
| | | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
| | |
| | | <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> |
| | | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
| | | |
| | | <application |
| | | <application xmlns:tools="http://schemas.android.com/tools" |
| | | android:name=".MGVideoApplication" |
| | | android:allowBackup="true" |
| | | android:icon="${app_icon}" |
| | | android:label="@string/app_name" |
| | | android:largeHeap="true" |
| | | android:networkSecurityConfig="@xml/network_security_config" |
| | | android:screenOrientation="portrait" |
| | | android:theme="@style/AppTheme" |
| | | android:usesCleartextTraffic="true" |
| | | tools:replace="android:allowBackup"> |
| | | tools:replace="android:screenOrientation,android:allowBackup,android:theme"> |
| | | |
| | | <uses-library |
| | | android:name="org.apache.http.legacy" |
| | | android:required="false" /> |
| | | <!-- 单元测试 --> |
| | | <uses-library android:name="android.test.runner" /> |
| | | |
| | | <activity |
| | | android:name=".ui.SplashActivity" |
| | | android:label="@string/app_name"> |
| | | <intent-filter> |
| | | <action android:name="android.intent.action.MAIN" /> |
| | | |
| | | <category android:name="android.intent.category.LAUNCHER" /> |
| | | </intent-filter> |
| | | </activity> |
| | |
| | | android:name=".ui.recommend.SearchActivity" |
| | | android:label="@string/app_name" |
| | | android:windowSoftInputMode="stateHidden"></activity> |
| | | <activity |
| | | android:name=".ui.recommend.SearchResultActivity" |
| | | android:label="@string/app_name" |
| | | android:windowSoftInputMode="stateHidden"></activity> |
| | | <activity |
| | | android:name=".ui.media.VideoDetailActivity" |
| | | android:configChanges="orientation|screenSize|keyboardHidden" |
| | | android:label="@string/app_name" |
| | | android:theme="@style/AppTabTheme2" |
| | | android:windowSoftInputMode="stateHidden"></activity> |
| | | |
| | | |
| | | <activity |
| | | android:name=".ui.mine.SystemMessageActivity" |
| | | android:label="@string/app_name"></activity> |
| | |
| | | android:name=".ui.category.StarDetailActivity" |
| | | android:label="@string/app_name"></activity> |
| | | |
| | | <activity |
| | | android:name=".ui.VideoPlayerBrowserActivity" |
| | | android:configChanges="screenSize|keyboardHidden|orientation" |
| | | android:hardwareAccelerated="true" |
| | | android:label="@string/app_name"></activity> |
| | | |
| | | |
| | | |
| | | <service android:name=".service.DownLoadFileService" /> |
| | | |
| | | <service android:name=".service.HelpService"></service> |
| | | |
| | | <uses-library |
| | | android:name="org.apache.http.legacy" |
| | | android:required="false" /> |
| | | <!-- 广点通--> |
| | | <service |
| | | android:name="com.qq.e.comm.DownloadService" |
| | | android:exported="false"></service> |
| | | |
| | | <!--广点通广告--> |
| | | <!-- targetSDKVersion >= 24时才需要添加这个provider。provider的authorities属性的值为${applicationId}.fileprovider,请开发者根据自己的${applicationId}来设置这个值,例如本例中applicationId为"com.qq.e.union.demo"。 --> |
| | | <provider |
| | | android:name="android.support.v4.content.FileProvider" |
| | | android:authorities="${applicationId}.fileprovider" |
| | | android:name="androidx.core.content.FileProvider" |
| | | android:authorities="com.doudou.ysvideo.fileprovider" |
| | | android:exported="false" |
| | | android:grantUriPermissions="true"> |
| | | <meta-data |
| | | android:name="android.support.FILE_PROVIDER_PATHS" |
| | | android:resource="@xml/gdt_file_path" /> |
| | | </provider> <!-- 声明SDK所需要的组件 --> |
| | | </provider> |
| | | |
| | | |
| | | <!-- 声明SDK所需要的组件 --> |
| | | <service |
| | | android:name="com.qq.e.comm.DownloadService" |
| | | android:exported="false" /> <!-- 请开发者注意字母的大小写,ADActivity,而不是AdActivity --> |
| | | <activity |
| | | android:name="com.qq.e.ads.ADActivity" |
| | | android:configChanges="keyboard|keyboardHidden|orientation|screenSize" /> |
| | | android:exported="false" /> |
| | | |
| | | <activity |
| | | android:name="com.qq.e.ads.PortraitADActivity" |
| | | android:configChanges="keyboard|keyboardHidden|orientation|screenSize" |
| | | android:screenOrientation="portrait" /> |
| | | |
| | | <!-- 请开发者注意字母的大小写,ADActivity,而不是AdActivity --> |
| | | <activity |
| | | android:name="com.qq.e.ads.ADActivity" |
| | | android:configChanges="keyboard|keyboardHidden|orientation|screenSize" /> |
| | | |
| | | <activity |
| | | android:name="com.qq.e.ads.RewardvideoLandscapeADActivity" |
| | | android:theme="@android:style/Theme.Translucent" |
| | | tools:replace="android:theme"></activity> |
| | | |
| | | <activity |
| | | android:name="com.qq.e.ads.LandscapeADActivity" |
| | | android:configChanges="keyboard|keyboardHidden|orientation|screenSize" |
| | | android:screenOrientation="landscape" /> <!-- 声明该Demo中的组件 --> |
| | | android:screenOrientation="landscape" |
| | | tools:replace="android:screenOrientation"></activity> |
| | | |
| | | <activity |
| | | android:name="com.qq.e.ads.RewardvideoPortraitADActivity" |
| | | android:theme="@android:style/Theme.Translucent" |
| | | tools:replace="android:theme"></activity> |
| | | |
| | | |
| | | <meta-data |
| | | android:name="android.max_aspect" |
| | |
| | | api files('lib/jg_filter_sdk_1.1.jar') |
| | | api files('lib/fastjson-1.2.9.jar') |
| | | api files('lib/open_ad_sdk.aar') |
| | | api files('lib/tbs_sdk_thirdapp_v3.5.0.1004_43500_sharewithdownload_withoutGame_obfs_20170801_113025.jar') |
| | | implementation 'com.android.support:support-v4:27.1.1' |
| | | //阿里百川 |
| | | //登陆 |
| | | implementation 'com.ali.auth.sdk:alibabauth_core:2.0.0.6@aar' |
| | | implementation 'com.ali.auth.sdk:alibabauth_ui:2.0.0.6@aar' |
| | | implementation 'com.ali.auth.sdk:alibabauth_ext:2.0.0.6@aar' |
| | | //安全组件 |
| | | implementation 'com.taobao.android:securityguardaar3:5.4.171@aar' |
| | | implementation 'com.taobao.android:securitybodyaar3:5.4.99@aar' |
| | | implementation 'com.taobao.android:avmpaar3:5.4.36@aar' |
| | | implementation 'com.taobao.android:sgmiddletieraar3:5.4.9@aar' |
| | | //Mtop |
| | | implementation 'com.taobao.android:mtopsdk_allinone_open:3.1.2.5@jar' |
| | | //applink |
| | | implementation 'com.alibaba.sdk.android:alibc_link_partner:4.1.15@aar' |
| | | //ut |
| | | |
| | | implementation 'com.alibaba.mtl:app-monitor-sdk:2.6.4.5_for_bc' |
| | | // 电商基础组件 |
| | | implementation 'com.alibaba.sdk.android:AlibcTradeCommon:4.0.0.15@aar' |
| | | implementation 'com.alibaba.sdk.android:AlibcTradeBiz:4.0.0.15@aar' |
| | | implementation 'com.alibaba.sdk.android:nb_trade:4.0.0.15@aar' |
| | | implementation 'com.android.support:cardview-v7:27.1.1' |
| | | implementation 'androidx.legacy:legacy-support-v4:1.0.0' |
| | | //阿里百川 |
| | | |
| | | |
| | | implementation 'androidx.cardview:cardview:1.0.0' |
| | | |
| | | //微信SDK |
| | | api 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+' |
| | |
| | | implementation project(path: ':library-BaiduCPU') |
| | | |
| | | |
| | | implementation files('lib/FunshionAD-1.3.16.aar') |
| | | implementation files('lib/FunshionBase-2.0.0.0.aar') |
| | | implementation files('lib/FunshionPlaySDK-2.0.0.2-buwanysdq.aar') |
| | | implementation files('lib/library-VideoPlayer.aar') |
| | | |
| | | //加载动画库 |
| | | implementation 'com.github.ybq:Android-SpinKit:1.4.0' |
| | | implementation project(path: ':library-base') |
| | | implementation project(path: ':library-search') |
| | | implementation project(path: ':library-video') |
| | | |
| | | |
| | | } |
| | |
| | | defaultConfig { |
| | | minSdkVersion 17 |
| | | targetSdkVersion 28 |
| | | javaCompileOptions { |
| | | annotationProcessorOptions { |
| | | arguments = [AROUTER_MODULE_NAME: project.getName()] |
| | | } |
| | | } |
| | | } |
| | | aaptOptions { |
| | | cruncherEnabled = false |
| | |
| | | resValue "string", "agreement", "http://111.231.250.166/mugua/userAgreenment.html" |
| | | resValue "string", "privacy", "http://111.231.250.166/mugua/privacyPolicy.html" |
| | | resValue "string", "about_us_url", "http://111.231.250.166/mugua/aboutUs.html" |
| | | manifestPlaceholders = [app_icon: "@drawable/ic_launcher",splashLayout:"activity_splash"] |
| | | manifestPlaceholders = [app_icon: "@drawable/ic_launcher", splashLayout: "activity_splash"] |
| | | } |
| | | |
| | | // productFlavors { |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | <solid android:color="@color/black"></solid> |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | <corners android:radius="5dp" /> |
| | | |
| | | <solid android:color="@color/item_more_bg_color" /> |
| | | |
| | | <corners android:radius="15dp" /> |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | <corners |
| | | android:bottomLeftRadius="6dp" |
| | | android:bottomRightRadius="6dp" |
| | | android:topLeftRadius="6dp" |
| | | android:topRightRadius="6dp" /> |
| | | |
| | | <solid android:color="#ff333333" /> |
| | | |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:shape="rectangle"> |
| | | |
| | | <solid android:color="#0051F5" /> |
| | | <corners android:radius="5dp" /> |
| | | |
| | | |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:shape="rectangle"> |
| | | <solid android:color="@color/video_episode_bg_color" /> |
| | | <corners android:radius="5dp" /> |
| | | |
| | | |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | <gradient |
| | | android:angle="0" |
| | | android:endColor="#E9CE93" |
| | | android:startColor="#F7EDD7" /> |
| | | |
| | | <corners android:radius="20dp" /> |
| | | |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | <solid android:color="#B2000000" /> |
| | | <corners android:radius="20dp" /> |
| | | |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | <gradient |
| | | android:angle="90" |
| | | android:endColor="#80000000" |
| | | android:startColor="#80000000" |
| | | android:type="linear" |
| | | android:useLevel="true" /> |
| | | |
| | | |
| | | </shape> |
| | |
| | | android:layout_height="match_parent" |
| | | android:orientation="vertical" > |
| | | |
| | | <android.support.v4.view.ViewPager |
| | | <androidx.viewpager.widget.ViewPager |
| | | android:id="@+id/vp_recommend" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" /> |
| | |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | <android.support.v4.view.ViewPager |
| | | <androidx.viewpager.widget.ViewPager |
| | | android:id="@+id/vp_discover" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" /> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | xmlns:app="http://schemas.android.com/apk/res-auto" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | android:gravity="center" |
| | | android:orientation="vertical"> |
| | | |
| | | <com.github.ybq.android.spinkit.SpinKitView |
| | | android:id="@+id/spin_kit" |
| | | style="@style/SpinKitView.Large.Circle" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | app:SpinKit_Color="@color/colorLoading" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_msg" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="5dp" |
| | | android:textColor="@color/colorLoading"></TextView> |
| | | |
| | | |
| | | </LinearLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:background="@color/transparent"> |
| | | |
| | | <androidx.recyclerview.widget.RecyclerView |
| | | android:id="@+id/rv_suggest" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="18dp" |
| | | android:layout_marginTop="2dp" |
| | | android:layout_marginRight="18dp" |
| | | android:layout_marginBottom="18dp" |
| | | android:background="#DFDFDF"></androidx.recyclerview.widget.RecyclerView> |
| | | |
| | | |
| | | </FrameLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | xmlns:app="http://schemas.android.com/apk/res-auto" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:orientation="horizontal"> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:orientation="vertical"> |
| | | |
| | | <com.lcjian.library.widget.RatioLayout |
| | | android:id="@+id/rl_container" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | app:ratio="0.5625"> |
| | | |
| | | <FrameLayout |
| | | android:id="@+id/fl_container" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | |
| | | </FrameLayout> |
| | | </com.lcjian.library.widget.RatioLayout> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_movie_title" |
| | | style="@style/TextBlackSmall" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:ellipsize="end" |
| | | android:lines="2" |
| | | android:textSize="@dimen/video_list_title" |
| | | android:paddingRight="8dp" |
| | | android:textColor="@color/video_list_title_text_color" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginBottom="3dp" |
| | | android:visibility="gone"> |
| | | |
| | | <FrameLayout |
| | | android:layout_width="0dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | android:layout_weight="1"> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_movie_play_num" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical|left" |
| | | android:drawableLeft="@drawable/ic_play_num" |
| | | android:drawablePadding="8dp" |
| | | android:ellipsize="end" |
| | | android:gravity="center_vertical|left" |
| | | android:paddingLeft="8dp" |
| | | android:paddingRight="8dp" |
| | | android:singleLine="true" |
| | | android:textColor="@color/gray" |
| | | android:textSize="12sp" /> |
| | | </FrameLayout> |
| | | |
| | | <FrameLayout |
| | | android:layout_width="0dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_weight="1" |
| | | android:visibility="invisible"> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_movie_comment_num" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:drawableLeft="@drawable/ic_comment_num" |
| | | android:drawablePadding="8dp" |
| | | android:ellipsize="end" |
| | | android:paddingLeft="8dp" |
| | | android:paddingRight="8dp" |
| | | android:singleLine="true" |
| | | android:textColor="@color/gray" |
| | | android:textSize="12sp" /> |
| | | </FrameLayout> |
| | | </LinearLayout> |
| | | |
| | | </LinearLayout> |
| | | </LinearLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | xmlns:app="http://schemas.android.com/apk/res-auto" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:orientation="horizontal"> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:orientation="vertical"> |
| | | |
| | | <com.qq.e.ads.nativ.widget.NativeAdContainer |
| | | android:id="@+id/native_ad_container" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | <FrameLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | <ImageView |
| | | android:scaleType="centerCrop" |
| | | android:id="@+id/iv_picture" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"></ImageView> |
| | | |
| | | </FrameLayout> |
| | | |
| | | </com.qq.e.ads.nativ.widget.NativeAdContainer> |
| | | </LinearLayout> |
| | | </LinearLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | xmlns:app="http://schemas.android.com/apk/res-auto" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:orientation="horizontal"> |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/ll_video_show" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:orientation="vertical"> |
| | | |
| | | <com.lcjian.library.widget.RatioLayout |
| | | android:id="@+id/rl_ratio" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | app:ratio="0.625"> |
| | | |
| | | <FrameLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_movie_cover" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:scaleType="fitXY" /> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_vip" |
| | | android:layout_width="29.5dp" |
| | | android:layout_height="17.5dp" |
| | | android:layout_gravity="top|right" |
| | | android:src="@drawable/icon_video_vip" /> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_high" |
| | | android:layout_width="29dp" |
| | | android:layout_height="17dp" |
| | | android:layout_gravity="top|left" |
| | | android:src="@drawable/icon_high" |
| | | android:visibility="gone" /> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_spread" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="top|right" |
| | | android:src="@drawable/spread" |
| | | android:visibility="gone" /> |
| | | |
| | | |
| | | <LinearLayout |
| | | android:paddingBottom="5dp" |
| | | android:paddingTop="5dp" |
| | | android:paddingLeft="5dp" |
| | | android:paddingRight="5dp" |
| | | android:id="@+id/ll_tag_container" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="bottom" |
| | | android:background="@drawable/shape_video_small_tag_bg" |
| | | android:gravity="bottom" |
| | | android:orientation="horizontal"> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_tag" |
| | | style="@style/TextWhiteSmall" |
| | | android:layout_width="0dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_weight="1" |
| | | android:ellipsize="end" |
| | | android:singleLine="true" |
| | | android:textColor="@color/video_list_tag_text_color" |
| | | android:textSize="@dimen/video_list_tag" /> |
| | | |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_score" |
| | | style="@style/TextWhiteSmall" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:ellipsize="end" |
| | | android:singleLine="true" |
| | | android:textColor="@color/video_list_score_text_color" |
| | | android:textSize="@dimen/video_list_tag" /> |
| | | |
| | | </LinearLayout> |
| | | |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_ad_logo" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="bottom|right" |
| | | android:src="@drawable/tsa_ad_logo" |
| | | android:visibility="gone" /> |
| | | </FrameLayout> |
| | | </com.lcjian.library.widget.RatioLayout> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_movie_title" |
| | | style="@style/TextBlackSmall" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="3dp" |
| | | android:ellipsize="end" |
| | | android:lines="1" |
| | | android:paddingRight="8dp" |
| | | android:textColor="@color/video_list_title_text_color" |
| | | android:textSize="@dimen/video_list_title" /> |
| | | |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_subtitle" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:ellipsize="end" |
| | | android:lines="1" |
| | | android:paddingRight="8dp" |
| | | android:singleLine="true" |
| | | android:textColor="@color/video_list_subtitle_text_color" |
| | | android:textSize="12sp" /> |
| | | |
| | | |
| | | </LinearLayout> |
| | | </LinearLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:gravity="center"> |
| | | |
| | | <TextView |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:gravity="center" |
| | | android:text="^到底了^" |
| | | android:textColor="#FF0000" |
| | | android:textSize="15sp"></TextView> |
| | | |
| | | </LinearLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | xmlns:app="http://schemas.android.com/apk/res-auto" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:background="@color/transparent" |
| | | android:orientation="vertical" |
| | | android:paddingLeft="8dp" |
| | | android:paddingRight="8dp" |
| | | android:paddingBottom="6dp"> |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/fl_content" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:orientation="vertical"> |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/ll_title_item" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="4dp" |
| | | android:gravity="center_vertical" |
| | | android:paddingTop="8dp" |
| | | android:paddingBottom="8dp"> |
| | | |
| | | <TextView |
| | | android:textStyle="bold" |
| | | android:id="@+id/tv_category_name" |
| | | android:layout_width="0dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_weight="1" |
| | | android:text="什么鬼" |
| | | android:textColor="@color/item_title_text_color" |
| | | android:textSize="16sp" /> |
| | | |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_tag_refresh" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:background="@drawable/shape_item_tag_bg" |
| | | android:drawableLeft="@drawable/icon_item_refresh" |
| | | android:drawablePadding="6.5dp" |
| | | android:paddingLeft="12dp" |
| | | android:paddingTop="5dp" |
| | | android:paddingRight="12dp" |
| | | android:paddingBottom="5dp" |
| | | android:text="换一批" |
| | | android:textColor="@color/item_tag_text_color" |
| | | android:textSize="10sp" |
| | | android:visibility="visible" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_more" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:background="@drawable/shape_item_tag_bg" |
| | | android:drawableRight="@drawable/ic_home_type_more" |
| | | android:drawablePadding="6.5dp" |
| | | android:paddingLeft="12dp" |
| | | android:paddingTop="5dp" |
| | | android:paddingRight="8dp" |
| | | android:paddingBottom="5dp" |
| | | android:text="更多免费热剧" |
| | | android:textColor="@color/item_tag_text_color" |
| | | android:textSize="10sp" /> |
| | | </LinearLayout> |
| | | |
| | | |
| | | <androidx.recyclerview.widget.RecyclerView |
| | | android:id="@+id/rv_content" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content"></androidx.recyclerview.widget.RecyclerView> |
| | | |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_refresh" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_alignParentEnd="true" |
| | | android:layout_alignParentRight="true" |
| | | android:layout_centerVertical="true" |
| | | android:layout_gravity="center_horizontal" |
| | | android:background="@drawable/shape_item_tag_bg" |
| | | android:drawableLeft="@drawable/icon_item_refresh" |
| | | android:drawablePadding="6.5dp" |
| | | android:paddingLeft="12dp" |
| | | android:paddingTop="5dp" |
| | | android:paddingRight="12dp" |
| | | android:paddingBottom="5dp" |
| | | android:text="换一批" |
| | | android:textColor="@color/item_tag_text_color" |
| | | android:textSize="10sp" |
| | | android:visibility="gone" /> |
| | | |
| | | </LinearLayout> |
| | | |
| | | |
| | | <FrameLayout |
| | | android:id="@+id/fl_ad" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:orientation="vertical" |
| | | android:paddingTop="3dp" |
| | | android:visibility="gone"> |
| | | |
| | | <com.lcjian.library.widget.RatioLayout |
| | | android:id="@+id/rl_ad" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | app:ratio="0.4375"> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_ad" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:scaleType="centerCrop" /> |
| | | </com.lcjian.library.widget.RatioLayout> |
| | | |
| | | </FrameLayout> |
| | | |
| | | |
| | | </LinearLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | xmlns:app="http://schemas.android.com/apk/res-auto" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:orientation="vertical"> |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/ll_container" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:orientation="vertical" |
| | | android:paddingLeft="6dp" |
| | | android:paddingRight="6dp" |
| | | android:paddingBottom="6dp"> |
| | | |
| | | <RelativeLayout |
| | | android:id="@+id/rl_title_item" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="8dp" |
| | | android:layout_marginRight="8dp" |
| | | android:padding="8dp" |
| | | android:visibility="gone"> |
| | | |
| | | |
| | | <ImageView |
| | | android:id="@+id/tv_category_icon" |
| | | android:layout_width="20dp" |
| | | android:layout_height="20dp" |
| | | android:layout_alignParentStart="true" |
| | | android:layout_alignParentLeft="true" |
| | | android:layout_centerVertical="true" |
| | | android:layout_marginRight="5dp" |
| | | android:src="@drawable/ic_title_spread" |
| | | android:visibility="gone" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_category_name" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_centerVertical="true" |
| | | android:layout_toRightOf="@id/tv_category_icon" |
| | | android:text="推广" |
| | | android:textColor="#DDDDDD" |
| | | android:textSize="@dimen/video_album_title" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_category_name2" |
| | | style="@style/TextBuleSmall" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_centerVertical="true" |
| | | android:layout_marginLeft="10dp" |
| | | android:layout_toRightOf="@id/tv_category_name" |
| | | android:drawableLeft="@drawable/recommend_left" |
| | | android:visibility="gone" /> |
| | | |
| | | </RelativeLayout> |
| | | |
| | | <FrameLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content"> |
| | | |
| | | <FrameLayout |
| | | android:id="@+id/fl_ad" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:background="@color/page_content_bg_color" |
| | | android:paddingLeft="1dp" |
| | | android:paddingRight="1dp"></FrameLayout> |
| | | <!--挡住广告黑边 --> |
| | | <View |
| | | android:layout_width="2dp" |
| | | android:layout_height="match_parent" |
| | | android:background="@color/white"></View> |
| | | |
| | | </FrameLayout> |
| | | |
| | | |
| | | </LinearLayout> |
| | | |
| | | </LinearLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="54dp" |
| | | android:orientation="horizontal"> |
| | | |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_content" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="54dp" |
| | | android:background="@color/page_content_bg_color" |
| | | android:drawableLeft="@drawable/icon_suggest_search" |
| | | android:drawableRight="@drawable/icon_suggest_search_input" |
| | | android:drawablePadding="17dp" |
| | | android:ellipsize="end" |
| | | android:gravity="center_vertical|left" |
| | | android:lines="1" |
| | | android:textColor="@color/search_input_text_color" |
| | | android:textSize="15sp"></TextView> |
| | | |
| | | |
| | | </LinearLayout> |
| | |
| | | android:layout_height="wrap_content" > |
| | | </FrameLayout> |
| | | |
| | | <android.support.v4.view.ViewPager |
| | | <androidx.viewpager.widget.ViewPager |
| | | android:id="@+id/pager" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="0dp" |
| | |
| | | android:layout_height="1px" |
| | | android:background="#DADADA" /> |
| | | |
| | | <android.support.v4.view.ViewPager |
| | | <androidx.viewpager.widget.ViewPager |
| | | android:id="@+id/category_vp" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" /> |
| | |
| | | |
| | | <include layout="@layout/no_network" /> |
| | | |
| | | <android.support.v4.widget.SwipeRefreshLayout |
| | | <androidx.swiperefreshlayout.widget.SwipeRefreshLayout |
| | | android:id="@+id/ptsv_container" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="0dp" |
| | |
| | | android:numColumns="2" |
| | | android:paddingBottom="10dp" |
| | | android:verticalSpacing="15dp" /> |
| | | </android.support.v4.widget.SwipeRefreshLayout> |
| | | </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> |
| | | |
| | | </LinearLayout> |
| | |
| | | <?xml version="1.0" encoding="utf-8"?>
|
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
| | | android:layout_width="match_parent"
|
| | | android:layout_height="match_parent"
|
| | | android:background="@color/register_gray"
|
| | | android:orientation="vertical" >
|
| | |
|
| | | <RelativeLayout
|
| | | android:layout_width="match_parent"
|
| | | android:layout_height="48dp"
|
| | | android:background="#ff222222"
|
| | | android:padding="8dp" >
|
| | |
|
| | | <ImageView
|
| | | android:id="@+id/logo"
|
| | | android:layout_width="wrap_content"
|
| | | android:layout_height="wrap_content"
|
| | | android:layout_alignParentLeft="true"
|
| | | android:layout_alignParentStart="true"
|
| | | android:layout_centerVertical="true"
|
| | | android:contentDescription="@string/app_name"
|
| | | android:src="@drawable/logo" />
|
| | |
|
| | | <TextView
|
| | | android:id="@+id/tv_go_search"
|
| | | android:layout_width="wrap_content"
|
| | | android:layout_height="wrap_content"
|
| | | android:layout_alignParentEnd="true"
|
| | | android:layout_alignParentRight="true"
|
| | | android:layout_centerVertical="true"
|
| | | android:background="@drawable/search_input_bg"
|
| | | android:drawableEnd="@drawable/ic_search"
|
| | | android:drawableRight="@drawable/ic_search"
|
| | | android:ellipsize="end"
|
| | | android:gravity="center_vertical"
|
| | | android:maxEms="7"
|
| | | android:paddingLeft="8dp"
|
| | | android:paddingRight="8dp"
|
| | | android:singleLine="true"
|
| | | android:textAppearance="?android:attr/textAppearance"
|
| | | android:textColor="@color/white" />
|
| | |
|
| | | <FrameLayout
|
| | | android:layout_width="wrap_content"
|
| | | android:layout_height="wrap_content"
|
| | | android:layout_centerVertical="true"
|
| | | android:layout_marginRight="10dp"
|
| | | android:layout_toLeftOf="@id/tv_go_search" >
|
| | |
|
| | | <ImageView
|
| | | android:id="@+id/nat"
|
| | | android:layout_width="30dp"
|
| | | android:layout_height="30dp"
|
| | | android:layout_gravity="center"
|
| | | android:layout_margin="2dp" >
|
| | | </ImageView>
|
| | |
|
| | | <ImageView
|
| | | android:id="@+id/iv_red_dot"
|
| | | android:layout_width="wrap_content"
|
| | | android:layout_height="wrap_content"
|
| | | android:layout_gravity="top|right"
|
| | | android:src="@drawable/ic_red_point" >
|
| | | </ImageView>
|
| | | </FrameLayout>
|
| | | </RelativeLayout>
|
| | |
|
| | |
|
| | | <include layout="@layout/no_network" />
|
| | |
|
| | | <include
|
| | | android:id="@+id/include_notice"
|
| | | layout="@layout/notice" />
|
| | |
|
| | | <LinearLayout
|
| | | android:id="@+id/ll_container"
|
| | | android:layout_width="match_parent"
|
| | | android:layout_height="wrap_content"
|
| | | android:gravity="center"
|
| | | android:orientation="vertical" >
|
| | | </LinearLayout>
|
| | |
|
| | | <android.support.v4.widget.SwipeRefreshLayout
|
| | | android:id="@+id/rl_recommend"
|
| | | android:layout_width="match_parent"
|
| | | android:layout_height="0dp"
|
| | | android:layout_weight="1" >
|
| | |
|
| | | <ListView
|
| | | android:id="@+id/lv_recommend"
|
| | | android:layout_width="match_parent"
|
| | | android:layout_height="match_parent"
|
| | | android:divider="@null"
|
| | | android:dividerHeight="0dp"
|
| | | android:listSelector="@android:color/transparent" >
|
| | | </ListView>
|
| | | </android.support.v4.widget.SwipeRefreshLayout>
|
| | |
|
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:background="@color/register_gray" |
| | | android:orientation="vertical"> |
| | | |
| | | <RelativeLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="48dp" |
| | | android:background="#ff222222" |
| | | android:padding="8dp"> |
| | | |
| | | <ImageView |
| | | android:id="@+id/logo" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_alignParentStart="true" |
| | | android:layout_alignParentLeft="true" |
| | | android:layout_centerVertical="true" |
| | | android:contentDescription="@string/app_name" |
| | | android:src="@drawable/logo" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_go_search" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_alignParentEnd="true" |
| | | android:layout_alignParentRight="true" |
| | | android:layout_centerVertical="true" |
| | | android:background="@drawable/search_input_bg" |
| | | android:drawableEnd="@drawable/ic_search" |
| | | android:drawableRight="@drawable/ic_search" |
| | | android:ellipsize="end" |
| | | android:gravity="center_vertical" |
| | | android:maxEms="7" |
| | | android:paddingLeft="8dp" |
| | | android:paddingRight="8dp" |
| | | android:singleLine="true" |
| | | android:textAppearance="?android:attr/textAppearance" |
| | | android:textColor="@color/white" /> |
| | | |
| | | <FrameLayout |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_centerVertical="true" |
| | | android:layout_marginRight="10dp" |
| | | android:layout_toLeftOf="@id/tv_go_search"> |
| | | |
| | | <ImageView |
| | | android:id="@+id/nat" |
| | | android:layout_width="30dp" |
| | | android:layout_height="30dp" |
| | | android:layout_gravity="center" |
| | | android:layout_margin="2dp"></ImageView> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_red_dot" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="top|right" |
| | | android:src="@drawable/ic_red_point"></ImageView> |
| | | </FrameLayout> |
| | | </RelativeLayout> |
| | | |
| | | |
| | | <include layout="@layout/no_network" /> |
| | | |
| | | <include |
| | | android:id="@+id/include_notice" |
| | | layout="@layout/notice" /> |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/ll_container" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:gravity="center" |
| | | android:orientation="vertical"></LinearLayout> |
| | | |
| | | <FrameLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="0dp" |
| | | android:layout_weight="1"> |
| | | |
| | | <androidx.swiperefreshlayout.widget.SwipeRefreshLayout |
| | | android:id="@+id/rl_recommend" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | |
| | | <androidx.recyclerview.widget.RecyclerView |
| | | android:id="@+id/rv_recommend" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | </androidx.recyclerview.widget.RecyclerView> |
| | | |
| | | |
| | | </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> |
| | | |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/ll_right_ad" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical|right" |
| | | android:layout_marginTop="100dp" |
| | | android:gravity="center_horizontal" |
| | | android:orientation="vertical" |
| | | android:visibility="gone"> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_right_ad" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="80dp" /> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_right_ad_close" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="3dp" |
| | | android:src="@drawable/icon_right_ad_close"></ImageView> |
| | | |
| | | </LinearLayout> |
| | | |
| | | |
| | | </FrameLayout> |
| | | |
| | | |
| | | </LinearLayout> |
| | |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content"></LinearLayout> |
| | | |
| | | <com.lcjian.library.widget.RatioLayout xmlns:app="http://schemas.android.com/apk/res-auto" |
| | | <com.lcjian.library.widget.RatioLayout |
| | | android:id="@+id/rl_recommend_top" |
| | | xmlns:app="http://schemas.android.com/apk/res-auto" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | app:ratio="0.4375"> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | <corners android:radius="20dp" /> |
| | | |
| | | <solid android:color="@color/search_input_bg_color" /> |
| | | |
| | | </shape> |
| | |
| | | android:background="@color/white" |
| | | android:orientation="vertical"> |
| | | |
| | | <android.support.v4.widget.SwipeRefreshLayout |
| | | <androidx.swiperefreshlayout.widget.SwipeRefreshLayout |
| | | android:id="@+id/rl_specific_detail" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | |
| | | android:divider="@null" |
| | | android:dividerHeight="0dp" |
| | | android:listSelector="@android:color/transparent"></ListView> |
| | | </android.support.v4.widget.SwipeRefreshLayout> |
| | | </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> |
| | | |
| | | |
| | | </LinearLayout> |
| | |
| | | |
| | | <color name="transparent_gray">#99666666</color> |
| | | |
| | | <color name="transparent">#00000000</color> |
| | | |
| | | <color name="colorLoading">#159FFF</color> |
| | | <!--主题颜色设置 --> |
| | | <color name="page_bg_color">#F3F3F3</color> |
| | | <color name="page_status_bar_color">#FFFFFF</color> |
| | | <color name="page_header_bg_color">#FFFFFF</color> |
| | | <color name="page_title_text_color">#000000</color> |
| | | <color name="page_content_bg_color">#FFFFFF</color> |
| | | |
| | | <!-- 别表项目的颜色 --> |
| | | <color name="item_title_text_color">#000000</color> |
| | | <color name="item_subtitle_text_color">#777777</color> |
| | | <color name="item_tag_text_color">#666666</color> |
| | | <color name="item_more_bg_color">#E9F0FF</color> |
| | | |
| | | <!-- 页面下拉刷新的颜色 --> |
| | | <color name="page_refresh_color">#159FFF</color> |
| | | |
| | | <!-- 列表为空的提示 --> |
| | | <color name="list_empty_default_text_color">#666666</color> |
| | | |
| | | |
| | | <!--搜索框颜色 --> |
| | | <color name="search_input_bg_color">#EBEBEB</color> |
| | | <color name="search_input_text_color">#000000</color> |
| | | <color name="search_input_hint_text_color">#787878</color> |
| | | |
| | | <color name="home_page_bg_color">#FFFFFF</color> |
| | | |
| | | |
| | | |
| | | |
| | | </resources> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <resources> |
| | | |
| | | |
| | | <dimen name="page_title_height">50dp</dimen> |
| | | <dimen name="album_item_width_short">200dp</dimen> |
| | | <dimen name="shadow_width">15dp</dimen> |
| | | <dimen name="slidingmenu_offset">80dp</dimen> |
| | | <dimen name="checkmark_area">40dip</dimen> |
| | | <dimen name="video_list_title">14sp</dimen> |
| | | <dimen name="video_list_tag">11sp</dimen> |
| | | <dimen name="mine_item_name">12sp</dimen> |
| | | <!--专辑标题 --> |
| | | <dimen name="video_album_title">16sp</dimen> |
| | | |
| | | <dimen name="banner_radius">6dp</dimen> |
| | | |
| | | |
| | | </resources> |
| | |
| | | <item name="android:textAppearance">?android:attr/textAppearanceSmall</item> |
| | | </style> |
| | | |
| | | <style name="PopupAnimation"> |
| | | <item name="android:windowEnterAnimation">@anim/pop_show</item> |
| | | <item name="android:windowExitAnimation">@anim/pop_dismiss</item> |
| | | </style> |
| | | |
| | | |
| | | <style name="Dialog" parent="android:style/Theme.Dialog"> |
| | | <item name="android:background">#00000000</item> |
| | |
| | | import android.content.Context; |
| | | |
| | | import com.nostra13.universalimageloader.core.download.BaseImageDownloader; |
| | | import com.mugua.mgvideo.util.BeibeiConstant; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | |
| | | public class BeibeiImageDownloader extends BaseImageDownloader { |
| | | |
| | |
| | | import com.loopj.android.http.RequestParams; |
| | | import com.loopj.android.http.ResponseHandlerInterface; |
| | | import com.loopj.android.http.SyncHttpClient; |
| | | import com.mugua.mgvideo.util.BeibeiConstant; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | import com.yeshi.base.utils.http.API; |
| | | |
| | | public class MGVideoAPI { |
| | | |
| | |
| | | |
| | | public static String ERROR_NOTICE = ""; |
| | | |
| | | public static String BASE_URL = BeibeiConstant.HOST + "/new_video/api/v2/"; |
| | | public static String BASE_URL = API.HOST + "/BuWan/api/v2/"; |
| | | |
| | | private static AsyncHttpClient asyncHttpClient = new AsyncHttpClient(); |
| | | |
| | |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<>(); |
| | | params.put("Method", "getUid"); |
| | | params.put("Device", device); |
| | | params.put("Imei", imei); |
| | | params.put("Mac", mac); |
| | | params.put("Lat", lat); |
| | | params.put("Lng", lng); |
| | | if (imei != null) |
| | | params.put("Imei", imei); |
| | | if (mac != null) |
| | | params.put("Mac", mac); |
| | | if (lat != null) |
| | | params.put("Lat", lat); |
| | | if (lng != null) |
| | | params.put("Lng", lng); |
| | | params.put("Channel", channel); |
| | | if (!StringUtils.isBlank(MGVideoApplication.deviceNumber)) { |
| | | params.put("DeviceName", MGVideoApplication.deviceName); |
| | |
| | | public static void search(Context context, String uid, String key, |
| | | String videoType, String page, ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("Method", "search"); |
| | | params.put("Method", "searchNew"); |
| | | params.put("Uid", uid); |
| | | params.put("Key", key); |
| | | params.put("Type", "1"); |
| | |
| | | * @param context |
| | | * @param handler |
| | | */ |
| | | public static void getAdId(Context context, String channel, String device, |
| | | String imei, String mac, String lat, String lng, |
| | | ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("Method", "getAndroidAdList"); |
| | | params.put("device", device); |
| | | params.put("imei", imei); |
| | | params.put("mac", mac); |
| | | params.put("lat", lat); |
| | | params.put("lng", lng); |
| | | params.put("channel", channel); |
| | | if (!StringUtils.isBlank(MGVideoApplication.deviceNumber)) { |
| | | params.put("deviceName", MGVideoApplication.deviceName); |
| | | params.put("deviceNumber", MGVideoApplication.deviceNumber); |
| | | } |
| | | commonPost(context, BASE_URL + "ad", params, handler); |
| | | public static void getConfig(Context context, |
| | | ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<>(); |
| | | params.put("Method", "getConfig"); |
| | | commonPost(context, BASE_URL + "config", params, handler); |
| | | } |
| | | |
| | | public static void getCollectedVideo(Context context, String uid, |
| | |
| | | commonPost(context, BASE_URL + "user", params, handler); |
| | | } |
| | | |
| | | public static void getHomeAd(Context context, String uid, |
| | | public static void getHomeAd(Context context, String uid, String vtid, String dataKey, |
| | | ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("Method", "getHomeAd"); |
| | | params.put("Uid", uid); |
| | | if (vtid != null) { |
| | | params.put("Vtid", vtid); |
| | | } |
| | | if (dataKey != null) { |
| | | params.put("DataKey", dataKey); |
| | | } |
| | | commonPost(context, BASE_URL + "recommend", params, handler); |
| | | } |
| | | |
| | | public static void getHomeType(Context context, String uid, |
| | | public static void getHomeType(Context context, String uid, String vtid, String dataKey, int page, int pageSize, |
| | | ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("Method", "getHomeType"); |
| | | params.put("Method", "getHomeTypeNew"); |
| | | params.put("Uid", uid); |
| | | params.put("Vtid", vtid); |
| | | params.put("Page", page + ""); |
| | | params.put("PageSize", pageSize + ""); |
| | | if (dataKey != null) { |
| | | params.put("DataKey", dataKey); |
| | | } |
| | | commonPost(context, BASE_URL + "recommend", params, handler); |
| | | } |
| | | |
| | | public static void getHomeVideoList(Context context, String id, int page, |
| | | ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("Method", "getHomeVideoList"); |
| | | params.put("Id", id); |
| | | params.put("Page", page + ""); |
| | | commonPost(context, BASE_URL + "recommend", params, handler); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 视频评论列表 |
| | | * |
| | | * @param context |
| | | * @param uid |
| | | * @param videoId |
| | |
| | | LinkedHashMap<String, String> params, |
| | | ResponseHandlerInterface handler, boolean asyn) { |
| | | params.put("Package", context.getPackageName()); |
| | | LinkedHashMap<String, String> map = validateParams(params,context); |
| | | LinkedHashMap<String, String> map = validateParams(params, context); |
| | | |
| | | RequestParams requestParams = new RequestParams(map); |
| | | if (BuildConfig.DEBUG) { |
| | |
| | | int version = PackageUtils2.getVersionCode(context); |
| | | params.put("Version", version + ""); |
| | | |
| | | LinkedHashMap<String, String> map = validateParams(params,context); |
| | | LinkedHashMap<String, String> map = validateParams(params, context); |
| | | RequestParams requestParams = new RequestParams(map); |
| | | if (BuildConfig.DEBUG) { |
| | | Log.i(TAG, "post url: " + url + "?" + requestParams.toString()); |
| | |
| | | import android.content.pm.PackageManager.NameNotFoundException; |
| | | import android.graphics.Bitmap.Config; |
| | | import android.util.Log; |
| | | import android.widget.Toast; |
| | | |
| | | import com.alibaba.android.arouter.launcher.ARouter; |
| | | import com.alibaba.baichuan.android.trade.AlibcTradeSDK; |
| | | import com.alibaba.baichuan.android.trade.callback.AlibcTradeInitCallback; |
| | | import com.baidu.mobads.AppActivity; |
| | |
| | | import com.funshion.playsdk.callback.FunshionPlayInitCallback; |
| | | import com.funshion.playsdk.register.IAuthCodeGetter; |
| | | import com.lcjian.library.util.ManifestDataUtil; |
| | | import com.mugua.mgvideo.util.CrashHandler; |
| | | import com.mugua.mgvideo.util.FunshionConstant; |
| | | import com.mugua.mgvideo.util.downutil.StringUtils; |
| | | import com.mugua.mgvideo.util.UserUtil; |
| | | import com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator; |
| | | import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; |
| | | import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache; |
| | |
| | | import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; |
| | | import com.nostra13.universalimageloader.core.assist.ImageScaleType; |
| | | import com.nostra13.universalimageloader.core.assist.QueueProcessingType; |
| | | import com.qq.e.comm.managers.GDTADManager; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.umeng.commonsdk.UMConfigure; |
| | | import com.umeng.socialize.PlatformConfig; |
| | | import com.mugua.mgvideo.util.BeibeiConstant; |
| | | import com.mugua.mgvideo.util.CrashHandler; |
| | | import com.mugua.mgvideo.util.ad.TTAdManagerHolder; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | import com.yeshi.base.utils.ad.GDTConstant; |
| | | import com.yeshi.base.utils.ad.TTAdManagerHolder; |
| | | import com.yeshi.base.utils.downutil.StringUtils; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | public static String KKNumber; |
| | | public static String MMNumber; |
| | | public static boolean showAd = true; |
| | | private String TAG="MGVideoApplication"; |
| | | private static String TAG = "MGVideoApplication"; |
| | | |
| | | @Override |
| | | public void onCreate() { |
| | |
| | | // .detectAll().penaltyDeath().build()); |
| | | // } |
| | | super.onCreate(); |
| | | //同意用户协议 |
| | | if (UserUtil.isAgreeUserProtocol(this)) { |
| | | init(this); |
| | | } |
| | | } |
| | | |
| | | initImageLoader(getApplicationContext()); |
| | | public static void init(Application application) { |
| | | |
| | | initImageLoader(application); |
| | | //友盟初始化 |
| | | UMConfigure.setLogEnabled(true); |
| | | String description = ManifestDataUtil.getAppMetaData(this, "UMENG_CHANNEL"); |
| | | UMConfigure.init(this, getResources().getString(R.string.umeng_key), description, UMConfigure.DEVICE_TYPE_PHONE, null); |
| | | String description = ManifestDataUtil.getAppMetaData(application, "UMENG_CHANNEL"); |
| | | UMConfigure.init(application, application.getResources().getString(R.string.umeng_key), description, UMConfigure.DEVICE_TYPE_PHONE, null); |
| | | // 选用AUTO页面采集模式 |
| | | MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO); |
| | | |
| | | //电商SDK初始化 |
| | | AlibcTradeSDK.asyncInit(this, new AlibcTradeInitCallback() { |
| | | AlibcTradeSDK.asyncInit(application, new AlibcTradeInitCallback() { |
| | | @Override |
| | | public void onSuccess() { |
| | | } |
| | |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | |
| | | initCSJAd(); |
| | | initFunshion(); |
| | | initAd(application); |
| | | initFunshion(application); |
| | | ARouter.init(application); |
| | | } |
| | | |
| | | private void initFunshion(){ |
| | | private static void initFunshion(Application application) { |
| | | try { |
| | | //初始化播放插件 |
| | | FSPlayer.init(this, FunshionConstant.APP_ID, new IAuthCodeGetter() { |
| | | FSPlayer.init(application, FunshionConstant.APP_ID, new IAuthCodeGetter() { |
| | | @Override |
| | | public void getAuthCode(final AuthCodeCallBack authCodeCallBack) { |
| | | MGVideoAPI.getFuntvAuthCode(application, new BasicTextHttpResponseHandler() { |
| | |
| | | /** |
| | | * 穿山甲广告初始化 |
| | | */ |
| | | private void initCSJAd() { |
| | | TTAdManagerHolder.init(this); |
| | | private static void initAd(Application application) { |
| | | TTAdManagerHolder.init(application); |
| | | GDTADManager.getInstance().initWith(application, GDTConstant.GDT_APP_ID); |
| | | } |
| | | |
| | | |
| | |
| | | import android.database.sqlite.SQLiteDatabase; |
| | | import android.database.sqlite.SQLiteQueryBuilder; |
| | | import android.net.Uri; |
| | | import android.support.v4.database.DatabaseUtilsCompat; |
| | | import androidx.core.database.DatabaseUtilsCompat; |
| | | |
| | | public class DownloadProvider extends ContentProvider { |
| | | |
| | |
| | | import android.database.sqlite.SQLiteDatabase; |
| | | import android.database.sqlite.SQLiteQueryBuilder; |
| | | import android.net.Uri; |
| | | import android.support.v4.database.DatabaseUtilsCompat; |
| | | import androidx.core.database.DatabaseUtilsCompat; |
| | | |
| | | public class MessageProvider extends ContentProvider { |
| | | |
| | |
| | | import android.database.sqlite.SQLiteDatabase; |
| | | import android.database.sqlite.SQLiteQueryBuilder; |
| | | import android.net.Uri; |
| | | import android.support.v4.database.DatabaseUtilsCompat; |
| | | import androidx.core.database.DatabaseUtilsCompat; |
| | | import android.util.Log; |
| | | |
| | | public class WatchHistoryProvider extends ContentProvider { |
| | |
| | | import java.util.List; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | |
| | | /** |
| | | * ���� |
| | |
| | | package com.mugua.mgvideo.entity; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | |
| | | /** |
| | | * ��ҳ��� |
| | |
| | | package com.mugua.mgvideo.entity; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | import com.mugua.mgvideo.ui.category.bean.HotStar; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * ��ҳ�ķ��� |
| | | * |
| | | * @author Administrator |
| | | */ |
| | | public class HomeType implements Serializable { |
| | | |
| | | public HomeType() { |
| | | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | */ |
| | |
| | | private String params; |
| | | @Expose |
| | | private String hasMore; |
| | | |
| | | |
| | | @Expose |
| | | private List<HomeVideo> homeVideoList; |
| | | @Expose |
| | | private List<HomeTypeItem> itemTypeList; |
| | | @Expose |
| | | private String icon; |
| | | @Expose |
| | | private boolean needAd; |
| | | |
| | | //刷新的位置 0-无刷新 1-右上角 2-下方 |
| | | @Expose |
| | | private int refreshPosition; |
| | | @Expose |
| | | private String moreTag; |
| | | @Expose |
| | | private int count; |
| | | @Expose |
| | | private int number; |
| | | |
| | | //当前页码(0-开始) |
| | | private int currentPage; |
| | | |
| | | |
| | | //广告 |
| | | @Expose |
| | | private HomeTypeAd ad; |
| | | |
| | | public String getMoreTag() { |
| | | return moreTag; |
| | | } |
| | | |
| | | public void setMoreTag(String moreTag) { |
| | | this.moreTag = moreTag; |
| | | } |
| | | |
| | | public HomeTypeAd getAd() { |
| | | return ad; |
| | | } |
| | | |
| | | public void setAd(HomeTypeAd ad) { |
| | | this.ad = ad; |
| | | } |
| | | |
| | | public boolean isNeedAd() { |
| | | return needAd; |
| | | } |
| | | |
| | | public void setNeedAd(boolean needAd) { |
| | | this.needAd = needAd; |
| | | } |
| | | |
| | | private List<VideoInfo> videoInfoList; |
| | | |
| | | public List<VideoInfo> getVideoInfoList() { |
| | | return videoInfoList; |
| | | } |
| | | |
| | | public void setVideoInfoList(List<VideoInfo> videoInfoList) { |
| | | this.videoInfoList = videoInfoList; |
| | | } |
| | | |
| | | private List<HotStar> hotStars; |
| | | |
| | |
| | | this.admin = admin; |
| | | } |
| | | |
| | | public int getRefreshPosition() { |
| | | return refreshPosition; |
| | | } |
| | | |
| | | public void setRefreshPosition(int refreshPosition) { |
| | | this.refreshPosition = refreshPosition; |
| | | } |
| | | |
| | | public int getCount() { |
| | | return count; |
| | | } |
| | | |
| | | public void setCount(int count) { |
| | | this.count = count; |
| | | } |
| | | |
| | | public int getNumber() { |
| | | return number; |
| | | } |
| | | |
| | | public void setNumber(int number) { |
| | | this.number = number; |
| | | } |
| | | |
| | | public int getCurrentPage() { |
| | | return currentPage; |
| | | } |
| | | |
| | | public void setCurrentPage(int currentPage) { |
| | | this.currentPage = currentPage; |
| | | } |
| | | |
| | | public static class HomeTypeAd { |
| | | @Expose |
| | | private String picture; |
| | | @Expose |
| | | private BigDecimal pictureRate; |
| | | @Expose |
| | | private JumpDetail jumpDetail; |
| | | @Expose |
| | | private String params; |
| | | |
| | | public String getPicture() { |
| | | return picture; |
| | | } |
| | | |
| | | public void setPicture(String picture) { |
| | | this.picture = picture; |
| | | } |
| | | |
| | | public BigDecimal getPictureRate() { |
| | | return pictureRate; |
| | | } |
| | | |
| | | public void setPictureRate(BigDecimal pictureRate) { |
| | | this.pictureRate = pictureRate; |
| | | } |
| | | |
| | | public JumpDetail getJumpDetail() { |
| | | return jumpDetail; |
| | | } |
| | | |
| | | public void setJumpDetail(JumpDetail jumpDetail) { |
| | | this.jumpDetail = jumpDetail; |
| | | } |
| | | |
| | | public String getParams() { |
| | | return params; |
| | | } |
| | | |
| | | public void setParams(String params) { |
| | | this.params = params; |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import java.io.Serializable; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | |
| | | public class HomeVideo implements Serializable { |
| | | |
| | | public HomeVideo(){ |
| | | |
| | | } |
| | | /** |
| | | * |
| | | * |
| | | */ |
| | | private static final long serialVersionUID = 1L; |
| | | @Expose |
| | |
| | | @Expose |
| | | private String picture; |
| | | |
| | | // private IMvNativeAd ad;// 广告 |
| | | @Expose |
| | | //是否为大图 |
| | | private boolean bigPicture; |
| | | |
| | | public boolean isBigPicture() { |
| | | return bigPicture; |
| | | } |
| | | |
| | | public void setBigPicture(boolean bigPicture) { |
| | | this.bigPicture = bigPicture; |
| | | } |
| | | |
| | | |
| | | // private IMvNativeAd ad;// 广告 |
| | | |
| | | public String getId() { |
| | | return id; |
| | |
| | | public void setPicture(String picture) { |
| | | this.picture = picture; |
| | | } |
| | | |
| | | // public IMvNativeAd getAd() { |
| | | // return ad; |
| | | // } |
| | | // |
| | | // public void setAd(IMvNativeAd ad) { |
| | | // this.ad = ad; |
| | | // } |
| | | } |
| | |
| | | package com.mugua.mgvideo.entity; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | import com.yeshi.base.entity.video.VideoType; |
| | | |
| | | public class HotVideoType { |
| | | public HotVideoType(String id) { |
| | |
| | | package com.mugua.mgvideo.entity; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | import com.qq.e.ads.nativ.NativeADDataRef; |
| | | |
| | | /** |
| | | * 直播频道具体信息 |
| | |
| | | private String title;// 广告标题 |
| | | private String desc;// 广告描述 |
| | | private String appScore;// 广告评分 |
| | | private NativeADDataRef adInfo;//广告信息 |
| | | |
| | | public String getIconUrl() { |
| | | return iconUrl; |
| | |
| | | |
| | | public void setPoster_path_1280(String poster_path_1280) { |
| | | this.poster_path_1280 = poster_path_1280; |
| | | } |
| | | |
| | | public NativeADDataRef getAdInfo() { |
| | | return adInfo; |
| | | } |
| | | |
| | | public void setAdInfo(NativeADDataRef adInfo) { |
| | | this.adInfo = adInfo; |
| | | } |
| | | |
| | | |
| | |
| | | package com.mugua.mgvideo.entity; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | import com.qq.e.ads.nativ.NativeADDataRef; |
| | | |
| | | /** |
| | | * 么么直播实体类 |
| | |
| | | private String title;// 广告标题 |
| | | private String desc;// 广告描述 |
| | | private String appScore;// 广告评分 |
| | | private NativeADDataRef adInfo;// 广告信息 |
| | | |
| | | public String getIconUrl() { |
| | | return iconUrl; |
| | |
| | | |
| | | public void setContent_url(String content_url) { |
| | | this.content_url = content_url; |
| | | } |
| | | |
| | | public NativeADDataRef getAdInfo() { |
| | | return adInfo; |
| | | } |
| | | |
| | | public void setAdInfo(NativeADDataRef adInfo) { |
| | | this.adInfo = adInfo; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.mugua.mgvideo.entity.recommend; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | import com.yeshi.base.entity.video.VideoType; |
| | | |
| | | public class HomeClass extends VideoType { |
| | | |
| | | @Expose |
| | | private String dataType;//数据类型 "recommend"-推荐 "class"-分类 "novel"-小说 "common"-常见 |
| | | |
| | | //数据Key |
| | | @Expose |
| | | private String dataKey; |
| | | |
| | | //字体颜色 |
| | | @Expose |
| | | private String color; |
| | | |
| | | public String getDataType() { |
| | | return dataType; |
| | | } |
| | | |
| | | public void setDataType(String dataType) { |
| | | this.dataType = dataType; |
| | | } |
| | | |
| | | public String getDataKey() { |
| | | return dataKey; |
| | | } |
| | | |
| | | public void setDataKey(String dataKey) { |
| | | this.dataKey = dataKey; |
| | | } |
| | | |
| | | public String getColor() { |
| | | return color; |
| | | } |
| | | |
| | | public void setColor(String color) { |
| | | this.color = color; |
| | | } |
| | | } |
New file |
| | |
| | | package com.mugua.mgvideo.entity.recommend; |
| | | |
| | | import com.mugua.mgvideo.entity.HomeAd; |
| | | import com.mugua.mgvideo.entity.HomeType; |
| | | import com.yeshi.base.entity.ad.ExpressAdContainer; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 推荐内容 |
| | | */ |
| | | public class RecommendContent { |
| | | public final static int TYPE_BANNER = 1; |
| | | public final static int TYPE_AD = 2; |
| | | public final static int TYPE_HOMETYPE = 3; |
| | | |
| | | private int type; |
| | | private List<HomeAd> homeBannerList; |
| | | private HomeType homeType; |
| | | private ExpressAdContainer ad; |
| | | |
| | | public RecommendContent(int type, List<HomeAd> homeBannerList) { |
| | | this.type = type; |
| | | this.homeBannerList = homeBannerList; |
| | | } |
| | | |
| | | public RecommendContent(int type, HomeType homeType) { |
| | | this.type = type; |
| | | this.homeType = homeType; |
| | | } |
| | | |
| | | public RecommendContent(int type, ExpressAdContainer ad) { |
| | | this.type = type; |
| | | this.ad = ad; |
| | | } |
| | | |
| | | public static RecommendContent createBanner(List<HomeAd> homeBannerList) { |
| | | return new RecommendContent(RecommendContent.TYPE_BANNER, homeBannerList); |
| | | } |
| | | |
| | | public static RecommendContent createHomeType(HomeType homeType) { |
| | | return new RecommendContent(RecommendContent.TYPE_HOMETYPE, homeType); |
| | | } |
| | | |
| | | public static RecommendContent createAd(ExpressAdContainer ad) { |
| | | return new RecommendContent(RecommendContent.TYPE_AD, ad); |
| | | } |
| | | |
| | | public int getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(int type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public List<HomeAd> getHomeBannerList() { |
| | | return homeBannerList; |
| | | } |
| | | |
| | | public void setHomeBannerList(List<HomeAd> homeBannerList) { |
| | | this.homeBannerList = homeBannerList; |
| | | } |
| | | |
| | | public ExpressAdContainer getAd() { |
| | | return ad; |
| | | } |
| | | |
| | | public void setAd(ExpressAdContainer ad) { |
| | | this.ad = ad; |
| | | } |
| | | |
| | | public HomeType getHomeType() { |
| | | return homeType; |
| | | } |
| | | |
| | | public void setHomeType(HomeType homeType) { |
| | | this.homeType = homeType; |
| | | } |
| | | } |
New file |
| | |
| | | package com.mugua.mgvideo.entity.recommend.holder; |
| | | |
| | | import android.view.View; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.lcjian.library.widget.RatioLayout; |
| | | import com.mugua.mgvideo.R; |
| | | |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | |
| | | public class RecommendVideoAdHolder extends RecyclerView.ViewHolder { |
| | | public View view; |
| | | public FrameLayout fl_container; |
| | | public TextView tv_movie_title; |
| | | public TextView tv_movie_play_num; |
| | | public RatioLayout rl_container; |
| | | |
| | | public RecommendVideoAdHolder(View view) { |
| | | super(view); |
| | | this.view = view; |
| | | rl_container = view.findViewById(R.id.rl_container); |
| | | fl_container = view.findViewById(R.id.fl_container); |
| | | tv_movie_title = view.findViewById(R.id.tv_movie_title); |
| | | tv_movie_play_num = view.findViewById(R.id.tv_movie_play_num); |
| | | } |
| | | } |
New file |
| | |
| | | package com.mugua.mgvideo.entity.video; |
| | | |
| | | import com.yeshi.base.entity.ad.ExpressAdContainer; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | |
| | | public class VideoContent { |
| | | public final static int TYPE_AD = 1; |
| | | public final static int TYPE_VIDEO = 2; |
| | | |
| | | private int type; |
| | | |
| | | private ExpressAdContainer ad; |
| | | private VideoInfo video; |
| | | |
| | | |
| | | public static VideoContent createVideoContent(VideoInfo video) { |
| | | VideoContent vc = new VideoContent(); |
| | | vc.setType(TYPE_VIDEO); |
| | | vc.setVideo(video); |
| | | return vc; |
| | | } |
| | | |
| | | |
| | | public static VideoContent createAdContent(ExpressAdContainer ad) { |
| | | VideoContent vc = new VideoContent(); |
| | | vc.setType(TYPE_AD); |
| | | vc.setAd(ad); |
| | | return vc; |
| | | } |
| | | |
| | | public int getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(int type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public ExpressAdContainer getAd() { |
| | | return ad; |
| | | } |
| | | |
| | | public void setAd(ExpressAdContainer ad) { |
| | | this.ad = ad; |
| | | } |
| | | |
| | | public VideoInfo getVideo() { |
| | | return video; |
| | | } |
| | | |
| | | public void setVideo(VideoInfo video) { |
| | | this.video = video; |
| | | } |
| | | } |
New file |
| | |
| | | package com.mugua.mgvideo.entity.video.holder; |
| | | |
| | | import android.view.View; |
| | | |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | |
| | | public class FooterViewHolder extends RecyclerView.ViewHolder { |
| | | public FooterViewHolder(View view) { |
| | | super(view); |
| | | } |
| | | } |
New file |
| | |
| | | package com.mugua.mgvideo.entity.video.holder; |
| | | |
| | | import android.view.View; |
| | | |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | |
| | | public class HeaderViewHolder extends RecyclerView.ViewHolder { |
| | | public HeaderViewHolder(View view) { |
| | | super(view); |
| | | } |
| | | } |
New file |
| | |
| | | package com.mugua.mgvideo.entity.video.holder; |
| | | |
| | | import android.view.View; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.lcjian.library.widget.RatioLayout; |
| | | import com.mugua.mgvideo.R; |
| | | |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | |
| | | public class VideoHolder extends RecyclerView.ViewHolder { |
| | | |
| | | public RatioLayout rl_ratio; |
| | | public LinearLayout ll_video_show; |
| | | public ImageView iv_movie_cover; |
| | | public ImageView iv_spread; |
| | | public ImageView iv_vip; |
| | | public TextView tv_score; |
| | | public ImageView iv_ad_logo; |
| | | public ImageView iv_high; |
| | | public TextView tv_tag; |
| | | public TextView tv_movie_title; |
| | | public TextView tv_movie_sub_title; |
| | | public LinearLayout ll_tag_container; |
| | | public View view; |
| | | |
| | | public VideoHolder(View view) { |
| | | super(view); |
| | | this.view = view; |
| | | rl_ratio = view.findViewById(R.id.rl_ratio); |
| | | ll_video_show = view.findViewById(R.id.ll_video_show); |
| | | iv_movie_cover = view.findViewById(R.id.iv_movie_cover); |
| | | iv_spread = view.findViewById(R.id.iv_spread); |
| | | tv_score = view.findViewById(R.id.tv_score); |
| | | tv_tag = view.findViewById(R.id.tv_tag); |
| | | iv_high = view.findViewById(R.id.iv_high); |
| | | iv_ad_logo = view.findViewById(R.id.iv_ad_logo); |
| | | tv_movie_title = view.findViewById(R.id.tv_movie_title); |
| | | tv_movie_sub_title = view.findViewById(R.id.tv_subtitle); |
| | | iv_vip = view.findViewById(R.id.iv_vip); |
| | | ll_tag_container = view.findViewById(R.id.ll_tag_container); |
| | | } |
| | | } |
New file |
| | |
| | | package com.mugua.mgvideo.entity.vo; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | public class UserInfoVO implements Serializable { |
| | | private String id; |
| | | private String nickName; |
| | | private String portrait; |
| | | private String sex; |
| | | private String birthday; |
| | | private String sign; |
| | | |
| | | private String pptvCode; |
| | | //绑定的电话号码 |
| | | |
| | | private String qqOpenId; |
| | | private String qqNickName; |
| | | private String wxUnionId; |
| | | private String wxName; |
| | | private String phone; |
| | | private String email; |
| | | |
| | | //VIP到期时间 |
| | | private Long vipExpireTime; |
| | | |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getNickName() { |
| | | return nickName; |
| | | } |
| | | |
| | | public void setNickName(String nickName) { |
| | | this.nickName = nickName; |
| | | } |
| | | |
| | | public String getPortrait() { |
| | | return portrait; |
| | | } |
| | | |
| | | public void setPortrait(String portrait) { |
| | | this.portrait = portrait; |
| | | } |
| | | |
| | | public String getSex() { |
| | | return sex; |
| | | } |
| | | |
| | | public void setSex(String sex) { |
| | | this.sex = sex; |
| | | } |
| | | |
| | | public String getBirthday() { |
| | | return birthday; |
| | | } |
| | | |
| | | public void setBirthday(String birthday) { |
| | | this.birthday = birthday; |
| | | } |
| | | |
| | | public String getSign() { |
| | | return sign; |
| | | } |
| | | |
| | | public void setSign(String sign) { |
| | | this.sign = sign; |
| | | } |
| | | |
| | | public String getPptvCode() { |
| | | return pptvCode; |
| | | } |
| | | |
| | | public void setPptvCode(String pptvCode) { |
| | | this.pptvCode = pptvCode; |
| | | } |
| | | |
| | | public String getQqOpenId() { |
| | | return qqOpenId; |
| | | } |
| | | |
| | | public void setQqOpenId(String qqOpenId) { |
| | | this.qqOpenId = qqOpenId; |
| | | } |
| | | |
| | | public String getQqNickName() { |
| | | return qqNickName; |
| | | } |
| | | |
| | | public void setQqNickName(String qqNickName) { |
| | | this.qqNickName = qqNickName; |
| | | } |
| | | |
| | | public String getWxUnionId() { |
| | | return wxUnionId; |
| | | } |
| | | |
| | | public void setWxUnionId(String wxUnionId) { |
| | | this.wxUnionId = wxUnionId; |
| | | } |
| | | |
| | | public String getWxName() { |
| | | return wxName; |
| | | } |
| | | |
| | | public void setWxName(String wxName) { |
| | | this.wxName = wxName; |
| | | } |
| | | |
| | | public String getPhone() { |
| | | return phone; |
| | | } |
| | | |
| | | public void setPhone(String phone) { |
| | | this.phone = phone; |
| | | } |
| | | |
| | | public String getEmail() { |
| | | return email; |
| | | } |
| | | |
| | | public void setEmail(String email) { |
| | | this.email = email; |
| | | } |
| | | |
| | | public Long getVipExpireTime() { |
| | | return vipExpireTime; |
| | | } |
| | | |
| | | public void setVipExpireTime(Long vipExpireTime) { |
| | | this.vipExpireTime = vipExpireTime; |
| | | } |
| | | } |
| | |
| | | import android.widget.Toast; |
| | | |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.util.downutil.DownLoadApks; |
| | | import com.mugua.mgvideo.util.downutil.DownLoadApks.IProgress; |
| | | import com.yeshi.base.utils.downutil.DownLoadApks; |
| | | |
| | | public class DownLoadFileService extends Service { |
| | | private NotificationManager manager; |
| | |
| | | } else { |
| | | apkType = ""; |
| | | } |
| | | new DownLoadApks(this, new IProgress() { |
| | | new DownLoadApks(this, new DownLoadApks.IProgress() { |
| | | |
| | | @Override |
| | | public void getProgress(int p) { |
| | |
| | | import com.loopj.android.http.RequestParams; |
| | | import com.loopj.android.http.SyncHttpClient; |
| | | import com.loopj.android.http.TextHttpResponseHandler; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | |
| | | import android.app.Service; |
| | | import android.content.Context; |
| | |
| | | package com.mugua.mgvideo.test; |
| | | |
| | | import android.content.Context; |
| | | import android.support.v4.view.PagerAdapter; |
| | | import android.support.v4.view.ViewPager; |
| | | import androidx.viewpager.widget.PagerAdapter; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | import android.util.AttributeSet; |
| | | import android.view.MotionEvent; |
| | | import android.view.View; |
| | |
| | | import android.content.res.Configuration; |
| | | import android.content.res.Resources; |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.FragmentActivity; |
| | | import androidx.fragment.app.FragmentActivity; |
| | | |
| | | import com.umeng.analytics.MobclickAgent; |
| | | |
| | |
| | | import android.content.SharedPreferences; |
| | | import android.content.SharedPreferences.Editor; |
| | | import android.os.Bundle; |
| | | import android.support.v4.view.ViewPager; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | |
| | | import com.lcjian.library.util.common.DimenUtils; |
| | | import com.mugua.mgvideo.R; |
| | |
| | | |
| | | import android.Manifest; |
| | | import android.annotation.TargetApi; |
| | | import android.content.ContentResolver; |
| | | import android.content.Context; |
| | | import android.content.DialogInterface; |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | | import android.content.SharedPreferences.Editor; |
| | | import android.content.pm.ActivityInfo; |
| | | import android.content.pm.PackageManager; |
| | | import android.content.pm.PackageManager.NameNotFoundException; |
| | | import android.database.Cursor; |
| | | import android.net.Uri; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.provider.ContactsContract.CommonDataKinds.Phone; |
| | | import android.provider.Settings; |
| | | import android.support.v4.app.ActivityCompat; |
| | | import android.telephony.TelephonyManager; |
| | | import android.text.TextUtils; |
| | | import android.util.Base64; |
| | | import android.view.KeyEvent; |
| | | import android.view.ViewGroup; |
| | | import android.view.animation.AlphaAnimation; |
| | | import android.view.animation.Animation; |
| | | import android.widget.ImageView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.lcjian.library.DeviceUuidFactory; |
| | | import com.lcjian.library.util.ManifestDataUtil; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.ui.dialog.UserProtocolDialog; |
| | | import com.mugua.mgvideo.util.UserUtil; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.MGVideoApplication; |
| | | import com.mugua.mgvideo.entity.Contacts; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.ui.dialog.UserProtocolDialog; |
| | | import com.mugua.mgvideo.ui.main.MainActivity; |
| | | import com.mugua.mgvideo.util.BeibeiConstant; |
| | | import com.mugua.mgvideo.util.ConfigUtil; |
| | | import com.mugua.mgvideo.util.SDCardUtil; |
| | | import com.mugua.mgvideo.util.ad.AdTypeEnum; |
| | | import com.mugua.mgvideo.util.ad.CSJConstant; |
| | | import com.mugua.mgvideo.util.UserUtil; |
| | | import com.mugua.mgvideo.util.ad.SplashAdUtil; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.yeshi.base.entity.ad.AdPositionEnum; |
| | | import com.yeshi.base.utils.ad.AdTypeEnum; |
| | | import com.yeshi.base.utils.ad.AdUtil; |
| | | import com.yeshi.base.utils.ad.CSJConstant; |
| | | import com.yeshi.base.utils.ad.GDTConstant; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import androidx.core.app.ActivityCompat; |
| | | |
| | | import static android.content.pm.PackageManager.PERMISSION_GRANTED; |
| | | |
| | | public class SplashActivity extends BaseActivity { |
| | | |
| | |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | dialog.dismiss(); |
| | | UserUtil.agreeUserProtocol(getApplicationContext()); |
| | | MGVideoApplication.init(MGVideoApplication.application); |
| | | //进行下一步 |
| | | if (Build.VERSION.SDK_INT >= 23) { |
| | | checkAndRequestPermission(); |
| | | } else { |
| | | getAdId(); |
| | | next(); |
| | | } |
| | | } |
| | | }).setData(data).create().show(); |
| | |
| | | if (Build.VERSION.SDK_INT >= 23) { |
| | | checkAndRequestPermission(); |
| | | } else { |
| | | getAdId(); |
| | | next(); |
| | | } |
| | | } |
| | | } |
| | |
| | | return "360"; |
| | | } |
| | | |
| | | private void getAdId() { |
| | | |
| | | private void getUid() { |
| | | final SharedPreferences preferences = getSharedPreferences("user", |
| | | Context.MODE_PRIVATE); |
| | | String channel = ""; |
| | | try { |
| | | channel = getChannel(); |
| | | } catch (NameNotFoundException e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | MGVideoAPI.getAdId(this, channel, new DeviceUuidFactory(this) |
| | | .getDeviceUuid().toString(), preferences.getString("imei", ""), |
| | | preferences.getString("mac", ""), "", "", |
| | | MGVideoAPI.getUid(this, "", MGVideoAPI.getDeviceId(this), null, |
| | | null, "", "", |
| | | new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | if (Boolean.parseBoolean(jsonObject.optJSONObject( |
| | | "Data").optString("showAd"))) { |
| | | BeibeiConstant.ADSHOW = true; |
| | | requestAd(); |
| | | } else { |
| | | BeibeiConstant.ADSHOW = false; |
| | | toMainActivity(); |
| | | } |
| | | } else { |
| | | requestAd(); |
| | | JSONObject data = jsonObject.getJSONObject("Data"); |
| | | preferences.edit() |
| | | .putString( |
| | | "uid", data |
| | | |
| | | .optString("Uid")) |
| | | .putString("COMMENT_ALERT", data |
| | | .optString("COMMENT_ALERT")) |
| | | .putInt("ShowAd", Integer.parseInt(data |
| | | .optString("ShowAd"))) |
| | | .putString( |
| | | "share_url", |
| | | data |
| | | .optString("ShareUrl")) |
| | | .putString( |
| | | "shopurl", |
| | | data |
| | | .optString("shopurl")) |
| | | .putString( |
| | | "share_content", |
| | | data |
| | | .optString("ShareContent")) |
| | | .putString( |
| | | "share_url_wechat", |
| | | data |
| | | .optString("WXShareUrl")) |
| | | .putString( |
| | | "share_content_wechat", |
| | | data |
| | | .optString("WXShareContent")) |
| | | .putString( |
| | | "show_more_app", |
| | | data |
| | | .optString("ShowMoreApp")) |
| | | .putString( |
| | | "evalueate", |
| | | data |
| | | .optString("evalueate")) |
| | | .putString( |
| | | "share_image_wechat", |
| | | data |
| | | .optString("WXShareIcon")) |
| | | .putString( |
| | | "tuiguang_add", |
| | | data |
| | | .optString("TuiGuang")) |
| | | .putString( |
| | | "top_icon", |
| | | data |
| | | .optString("TopIcon")) |
| | | .commit(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, |
| | | String responseString, Throwable throwable) { |
| | | super.onFailure(statusCode, headers, responseString, |
| | | throwable); |
| | | requestAd(); |
| | | public void onStart() { |
| | | super.onStart(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | }); |
| | | } |
| | | |
| | | private void next() { |
| | | getUid(); |
| | | fl_ad.postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | MGVideoAPI.getConfig(getApplicationContext(), |
| | | new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject != null) { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | JSONObject data = jsonObject.getJSONObject("Data"); |
| | | JSONObject ad = data.optJSONObject("adNew"); |
| | | String vipLink = data.optString("vipLink"); |
| | | int pptvNoAdRewardHour = data.optInt("pptvNoAdRewardHour", 3); |
| | | |
| | | //网页加速域名 |
| | | String webSpeedUpHost = data.optString("webSpeedUpHost"); |
| | | ConfigUtil.saveWebSpeedUpHost(getApplicationContext(), webSpeedUpHost); |
| | | |
| | | ConfigUtil.savePlayerJumpOutProtocolPrefix(getApplicationContext(), data.optString("jumpAppProtocolPrefix")); |
| | | |
| | | //保存购买记录 |
| | | ConfigUtil.saveBuyRecordUrl(getApplicationContext(), data.optString("buyRecordUrl")); |
| | | |
| | | AdUtil.saveAdConfig(getApplicationContext(), ad); |
| | | AdTypeEnum splash = AdUtil.getAdType(getApplicationContext(), AdPositionEnum.splash); |
| | | String pid = AdUtil.getAdPid(getApplicationContext(), AdPositionEnum.splash); |
| | | if (StringUtils.isBlank(pid)) { |
| | | if (splash != null) { |
| | | if (splash == AdTypeEnum.csj) { |
| | | pid = CSJConstant.SPLASH_AD; |
| | | } else if (splash == AdTypeEnum.gdt) { |
| | | pid = GDTConstant.PID_SPLASH_HOT; |
| | | } |
| | | } |
| | | } |
| | | ConfigUtil.saveVipLink(getApplicationContext(), vipLink); |
| | | loadSplashAd(splash, pid); |
| | | } |
| | | } else { |
| | | loadSplashAd(AdTypeEnum.csj, CSJConstant.SPLASH_AD); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, |
| | | String responseString, Throwable throwable) { |
| | | super.onFailure(statusCode, headers, responseString, |
| | | throwable); |
| | | requestAd(); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | } |
| | | }); |
| | | } |
| | | }, 1000); |
| | | |
| | | |
| | | } |
| | | |
| | | private void requestAd() { |
| | | fl_ad.postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | loadSplashAd(AdTypeEnum.csj, CSJConstant.CODE_SPLASH); |
| | | loadSplashAd(AdTypeEnum.csj, CSJConstant.SPLASH_AD); |
| | | } |
| | | }, 500); |
| | | } |
| | |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | toMainActivity(); |
| | | fl_ad.postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | toMainActivity(); |
| | | } |
| | | },2000); |
| | | |
| | | } |
| | | }); |
| | | } |
| | |
| | | public void onResume() { |
| | | super.onResume(); |
| | | MobclickAgent.onPageStart("欢迎页"); |
| | | // new WebView(this); |
| | | mList = new ArrayList<Contacts>(); |
| | | // if (!getSharedPreferences("user", MODE_PRIVATE).getBoolean( |
| | | // "updateMobile", false)) { |
| | | // getPhoneContacts(); |
| | | // } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | MobclickAgent.onPageEnd("欢迎页"); |
| | | } |
| | | |
| | | /** |
| | | * 获取库Phon表字段 |
| | | **/ |
| | | private static final String[] PHONES_PROJECTION = new String[]{ |
| | | Phone.DISPLAY_NAME, Phone.NUMBER}; |
| | | /** |
| | | * 联系人显示名称 |
| | | **/ |
| | | private static final int PHONES_DISPLAY_NAME_INDEX = 0; |
| | | |
| | | /** |
| | | * 电话号码 |
| | | **/ |
| | | private static final int PHONES_NUMBER_INDEX = 1; |
| | | private List<Contacts> mList; |
| | | |
| | | /** |
| | | * 得到手机通讯录联系人信息 |
| | | **/ |
| | | private void getPhoneContacts() { |
| | | ContentResolver resolver = getContentResolver(); |
| | | |
| | | // 获取手机联系人 |
| | | Cursor phoneCursor = resolver.query(Phone.CONTENT_URI, |
| | | PHONES_PROJECTION, null, null, null); |
| | | |
| | | if (phoneCursor != null) { |
| | | while (phoneCursor.moveToNext()) { |
| | | |
| | | // 得到手机号码 |
| | | String contactNumber = phoneCursor.getString( |
| | | PHONES_NUMBER_INDEX).replace(" ", ""); |
| | | // 当手机号码为空的或者为空字段 跳过当前循环 |
| | | if (TextUtils.isEmpty(contactNumber)) |
| | | continue; |
| | | |
| | | // 得到联系人名称 |
| | | String contactName = phoneCursor |
| | | .getString(PHONES_DISPLAY_NAME_INDEX); |
| | | if (StringUtils.isMobileNumber(contactNumber)) { |
| | | Contacts info = new Contacts(); |
| | | info.setName(contactName); |
| | | info.setMobile(contactNumber); |
| | | mList.add(info); |
| | | } |
| | | |
| | | } |
| | | phoneCursor.close(); |
| | | } |
| | | getSIMContacts(); |
| | | } |
| | | |
| | | /** |
| | | * 得到手机SIM卡联系人人信息 |
| | | **/ |
| | | private void getSIMContacts() { |
| | | ContentResolver resolver = getContentResolver(); |
| | | // 获取Sims卡联系人 |
| | | Uri uri = Uri.parse("content://icc/adn"); |
| | | Cursor phoneCursor = resolver.query(uri, PHONES_PROJECTION, null, null, |
| | | null); |
| | | |
| | | if (phoneCursor != null) { |
| | | while (phoneCursor.moveToNext()) { |
| | | |
| | | // 得到手机号码 |
| | | String contactNumber = phoneCursor.getString( |
| | | PHONES_NUMBER_INDEX).replace(" ", ""); |
| | | // 当手机号码为空的或者为空字段 跳过当前循环 |
| | | if (TextUtils.isEmpty(contactNumber)) |
| | | continue; |
| | | // 得到联系人名称 |
| | | String contactName = phoneCursor |
| | | .getString(PHONES_DISPLAY_NAME_INDEX); |
| | | |
| | | if (StringUtils.isMobileNumber(contactNumber)) { |
| | | Contacts info = new Contacts(); |
| | | info.setName(contactName); |
| | | info.setMobile(contactNumber); |
| | | mList.add(info); |
| | | } |
| | | } |
| | | } |
| | | updateContact(); |
| | | |
| | | } |
| | | |
| | | private void updateContact() { |
| | | SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE); |
| | | String uid = sp.getString("uid", ""); |
| | | Gson gson = new GsonBuilder().setPrettyPrinting() |
| | | .setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | String str = Base64.encodeToString(gson.toJson(mList).getBytes(), |
| | | Base64.DEFAULT); |
| | | MGVideoAPI.updateContact(this, uid, str, |
| | | new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | SharedPreferences sp = getSharedPreferences("user", |
| | | MODE_PRIVATE); |
| | | Editor editor = sp.edit(); |
| | | editor.putBoolean("updateMobile", true); |
| | | editor.commit(); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, |
| | | String responseString, Throwable throwable) { |
| | | super.onFailure(statusCode, headers, responseString, |
| | | throwable); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private String getDay(long time) { |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String date = format.format(new Date(time)); |
| | | return date; |
| | | } |
| | | |
| | | @Override |
| | |
| | | lackedPermission.toArray(requestPermissions); |
| | | requestPermissions(requestPermissions, 1024); |
| | | } else { |
| | | getAdId(); |
| | | next(); |
| | | } |
| | | } |
| | | |
| | |
| | | public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { |
| | | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
| | | if (requestCode == 1024) { |
| | | if (!hasAllPermissionsGranted(grantResults)) { |
| | | Toast.makeText(this, "应用缺少必要的权限!请点击\"权限\",打开所需要的权限。", Toast.LENGTH_LONG).show(); |
| | | // 如果用户没有授权,那么应该说明意图,引导用户去设置里面授权。 |
| | | Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); |
| | | intent.setData(Uri.parse("package:" + getPackageName())); |
| | | startActivity(intent); |
| | | } else { |
| | | getAdId(); |
| | | for (int i = 0; i < permissions.length; i++) { |
| | | if (grantResults[i] == PERMISSION_GRANTED) {//选择了“始终允许” |
| | | checkAndRequestPermission(); |
| | | } else { |
| | | next(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.nostra13.universalimageloader.core.ImageLoader; |
| | | import com.nostra13.universalimageloader.core.assist.ImageScaleType; |
| | | import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; |
| | | import com.mugua.mgvideo.entity.VideoType; |
| | | import com.mugua.mgvideo.ui.common.VideosLiveActivity; |
| | | import com.yeshi.base.entity.video.VideoType; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | |
| | | import com.bumptech.glide.Glide; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.mugua.mgvideo.ui.media.VideoDetailActivity; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.util.List; |
| | |
| | | import com.nostra13.universalimageloader.core.ImageLoader; |
| | | import com.nostra13.universalimageloader.core.assist.ImageScaleType; |
| | | import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; |
| | | import com.mugua.mgvideo.entity.VideoType; |
| | | import com.yeshi.base.entity.video.VideoType; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | |
| | | import com.nostra13.universalimageloader.core.ImageLoader; |
| | | import com.nostra13.universalimageloader.core.assist.ImageScaleType; |
| | | import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; |
| | | import com.mugua.mgvideo.entity.VideoType; |
| | | import com.mugua.mgvideo.ui.common.VideosLiveActivity; |
| | | import com.yeshi.base.entity.video.VideoType; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | |
| | | package com.mugua.mgvideo.ui.category; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.content.pm.ActivityInfo; |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.FragmentActivity; |
| | | import android.support.v4.app.FragmentManager; |
| | | import android.support.v4.app.FragmentPagerAdapter; |
| | | import android.support.v4.view.ViewPager; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.widget.FrameLayout; |
| | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.mugua.mgvideo.R; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.viewpagerindicator.MTabPageIndicator; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.entity.VideoType; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.ui.common.VideosFragment; |
| | | import com.mugua.mgvideo.util.VideoTypeUtil; |
| | | import com.viewpagerindicator.MTabPageIndicator; |
| | | import com.yeshi.base.entity.video.VideoType; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentActivity; |
| | | import androidx.fragment.app.FragmentManager; |
| | | import androidx.fragment.app.FragmentPagerAdapter; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | |
| | | public class MVideosActivity extends FragmentActivity implements |
| | | OnClickListener { |
| | |
| | | package com.mugua.mgvideo.ui.category; |
| | | |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.FragmentManager; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentManager; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.widget.TextView; |
| | | |
| | | import com.mugua.mgvideo.R; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.mugua.mgvideo.ui.BaseActivity; |
| | | |
| | | /** |
| | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.os.Bundle; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | |
| | | import com.lcjian.library.RetainViewFragment; |
| | | import com.mugua.mgvideo.R; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.mugua.mgvideo.ui.discover.StarWorksAdapter; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | |
| | | import com.nostra13.universalimageloader.core.ImageLoader; |
| | | import com.nostra13.universalimageloader.core.assist.ImageScaleType; |
| | | import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.mugua.mgvideo.ui.media.VideoDetailActivity; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | |
| | | package com.mugua.mgvideo.ui.category; |
| | | |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.FragmentManager; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentManager; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.widget.TextView; |
| | | |
| | | import com.mugua.mgvideo.R; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.mugua.mgvideo.ui.BaseActivity; |
| | | |
| | | /** |
| | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.os.Bundle; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.widget.ImageView; |
| | |
| | | import com.mugua.mgvideo.R; |
| | | import com.nostra13.universalimageloader.core.DisplayImageOptions; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.mugua.mgvideo.ui.discover.StarWorksAdapter; |
| | | import com.mugua.mgvideo.util.GlideCircleTransform; |
| | | |
| | |
| | | package com.mugua.mgvideo.ui.category; |
| | | |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.FragmentManager; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentManager; |
| | | import android.view.View; |
| | | import android.widget.TextView; |
| | | |
| | |
| | | import com.mugua.mgvideo.R; |
| | | import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.entity.VideoType; |
| | | import com.mugua.mgvideo.ui.category.ChannelAdapter; |
| | | import com.mugua.mgvideo.ui.category.ChannelAdapterHot; |
| | | import com.yeshi.base.entity.video.VideoType; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.os.Bundle; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import android.view.View; |
| | | import android.widget.ListView; |
| | | import android.widget.ProgressBar; |
| | |
| | | import com.lcjian.library.util.RefreshLayout; |
| | | import com.mugua.mgvideo.R; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.ui.category.NewStarAdapter; |
| | | import com.mugua.mgvideo.ui.category.bean.HotStar; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.os.Bundle; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import android.view.View; |
| | | import android.widget.ListView; |
| | | import android.widget.ProgressBar; |
| | |
| | | import com.lcjian.library.util.RefreshLayout; |
| | | import com.mugua.mgvideo.R; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.ui.category.UniqueAdapter; |
| | | import com.mugua.mgvideo.ui.category.bean.UniqueBean; |
| | |
| | | import com.nostra13.universalimageloader.core.ImageLoader; |
| | | import com.nostra13.universalimageloader.core.assist.ImageScaleType; |
| | | import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.mugua.mgvideo.ui.media.VideoDetailActivity; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | import com.mugua.mgvideo.util.AdPromptDialog; |
| | | import com.mugua.mgvideo.util.BeibeiConstant; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | | public class CategoryGridVideoAdapter extends BaseAdapter { |
| | | |
| | | private ImageLoader imageLoader = ImageLoader.getInstance(); |
| | | private ImageLoader imageLoader = ImageLoader.getInstance(); |
| | | |
| | | private DisplayImageOptions options; |
| | | private DisplayImageOptions options; |
| | | |
| | | private List<VideoInfo> mVideoInfos; |
| | | private List<VideoInfo> mVideoInfos; |
| | | |
| | | public CategoryGridVideoAdapter(List<VideoInfo> videoInfos, boolean layout2) { |
| | | super(); |
| | | this.mVideoInfos = videoInfos; |
| | | this.options = new DisplayImageOptions.Builder() |
| | | .showImageForEmptyUri(R.drawable.ic_default_cover) |
| | | .showImageOnFail(R.drawable.ic_default_cover) |
| | | .showImageOnLoading(R.drawable.ic_default_cover) |
| | | .resetViewBeforeLoading(true).cacheInMemory(true) |
| | | .cacheOnDisk(true).imageScaleType(ImageScaleType.EXACTLY) |
| | | .considerExifParams(true) |
| | | // default |
| | | .displayer(new FadeInBitmapDisplayer(300)).build(); |
| | | } |
| | | public CategoryGridVideoAdapter(List<VideoInfo> videoInfos, boolean layout2) { |
| | | super(); |
| | | this.mVideoInfos = videoInfos; |
| | | this.options = new DisplayImageOptions.Builder() |
| | | .showImageForEmptyUri(R.drawable.ic_default_cover) |
| | | .showImageOnFail(R.drawable.ic_default_cover) |
| | | .showImageOnLoading(R.drawable.ic_default_cover) |
| | | .resetViewBeforeLoading(true).cacheInMemory(true) |
| | | .cacheOnDisk(true).imageScaleType(ImageScaleType.EXACTLY) |
| | | .considerExifParams(true) |
| | | // default |
| | | .displayer(new FadeInBitmapDisplayer(300)).build(); |
| | | } |
| | | |
| | | @Override |
| | | public int getCount() { |
| | | if (mVideoInfos.size() % 3 == 0) { |
| | | return mVideoInfos == null ? 0 : (mVideoInfos.size() / 3); |
| | | } else { |
| | | return mVideoInfos == null ? 0 : (mVideoInfos.size() / 3 + 1); |
| | | } |
| | | } |
| | | @Override |
| | | public int getCount() { |
| | | if (mVideoInfos.size() % 3 == 0) { |
| | | return mVideoInfos == null ? 0 : (mVideoInfos.size() / 3); |
| | | } else { |
| | | return mVideoInfos == null ? 0 : (mVideoInfos.size() / 3 + 1); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Object getItem(int position) { |
| | | return mVideoInfos.get(position); |
| | | } |
| | | @Override |
| | | public Object getItem(int position) { |
| | | return mVideoInfos.get(position); |
| | | } |
| | | |
| | | @Override |
| | | public long getItemId(int position) { |
| | | return position; |
| | | } |
| | | @Override |
| | | public long getItemId(int position) { |
| | | return position; |
| | | } |
| | | |
| | | private VideoInfo mInfo; |
| | | private VideoInfo mInfo; |
| | | |
| | | @Override |
| | | public View getView(int position, View convertView, ViewGroup parent) { |
| | | ViewHolder viewHolder; |
| | | VideoInfo info = null; |
| | | VideoInfo info1 = null; |
| | | VideoInfo info2 = null; |
| | | int startP = position * 3; |
| | | info = mVideoInfos.get(startP); |
| | | if (startP + 1 < mVideoInfos.size()) |
| | | info1 = mVideoInfos.get(startP + 1); |
| | | if (startP + 2 < mVideoInfos.size()) |
| | | info2 = mVideoInfos.get(startP + 2); |
| | | @Override |
| | | public View getView(int position, View convertView, ViewGroup parent) { |
| | | ViewHolder viewHolder; |
| | | VideoInfo info = null; |
| | | VideoInfo info1 = null; |
| | | VideoInfo info2 = null; |
| | | int startP = position * 3; |
| | | info = mVideoInfos.get(startP); |
| | | if (startP + 1 < mVideoInfos.size()) |
| | | info1 = mVideoInfos.get(startP + 1); |
| | | if (startP + 2 < mVideoInfos.size()) |
| | | info2 = mVideoInfos.get(startP + 2); |
| | | |
| | | if (convertView == null) { |
| | | viewHolder = new ViewHolder(); |
| | | convertView = LayoutInflater.from(parent.getContext()).inflate( |
| | | R.layout.category_movie_item, parent, false); |
| | | viewHolder.ll_moive_item = (LinearLayout) convertView |
| | | .findViewById(R.id.ll_moive_item); |
| | | viewHolder.ll_moive_item1 = (LinearLayout) convertView |
| | | .findViewById(R.id.ll_moive_item1); |
| | | viewHolder.ll_moive_item2 = (LinearLayout) convertView |
| | | .findViewById(R.id.ll_moive_item2); |
| | | if (convertView == null) { |
| | | viewHolder = new ViewHolder(); |
| | | convertView = LayoutInflater.from(parent.getContext()).inflate( |
| | | R.layout.category_movie_item, parent, false); |
| | | viewHolder.ll_moive_item = (LinearLayout) convertView |
| | | .findViewById(R.id.ll_moive_item); |
| | | viewHolder.ll_moive_item1 = (LinearLayout) convertView |
| | | .findViewById(R.id.ll_moive_item1); |
| | | viewHolder.ll_moive_item2 = (LinearLayout) convertView |
| | | .findViewById(R.id.ll_moive_item2); |
| | | |
| | | viewHolder.iv_movie_cover = (ImageView) convertView |
| | | .findViewById(R.id.iv_movie_cover); |
| | | viewHolder.tv_movie_title = (TextView) convertView |
| | | .findViewById(R.id.tv_movie_title); |
| | | viewHolder.tv_movie_rating = (TextView) convertView |
| | | .findViewById(R.id.tv_movie_rating); |
| | | viewHolder.iv_movie_cover = (ImageView) convertView |
| | | .findViewById(R.id.iv_movie_cover); |
| | | viewHolder.tv_movie_title = (TextView) convertView |
| | | .findViewById(R.id.tv_movie_title); |
| | | viewHolder.tv_movie_rating = (TextView) convertView |
| | | .findViewById(R.id.tv_movie_rating); |
| | | |
| | | viewHolder.iv_movie_cover1 = (ImageView) convertView |
| | | .findViewById(R.id.iv_movie_cover1); |
| | | viewHolder.tv_movie_title1 = (TextView) convertView |
| | | .findViewById(R.id.tv_movie_title1); |
| | | viewHolder.tv_movie_rating1 = (TextView) convertView |
| | | .findViewById(R.id.tv_movie_rating1); |
| | | viewHolder.iv_movie_cover1 = (ImageView) convertView |
| | | .findViewById(R.id.iv_movie_cover1); |
| | | viewHolder.tv_movie_title1 = (TextView) convertView |
| | | .findViewById(R.id.tv_movie_title1); |
| | | viewHolder.tv_movie_rating1 = (TextView) convertView |
| | | .findViewById(R.id.tv_movie_rating1); |
| | | |
| | | viewHolder.iv_movie_cover2 = (ImageView) convertView |
| | | .findViewById(R.id.iv_movie_cover2); |
| | | viewHolder.tv_movie_title2 = (TextView) convertView |
| | | .findViewById(R.id.tv_movie_title2); |
| | | viewHolder.tv_movie_rating2 = (TextView) convertView |
| | | .findViewById(R.id.tv_movie_rating2); |
| | | convertView.setTag(viewHolder); |
| | | viewHolder.iv_movie_cover2 = (ImageView) convertView |
| | | .findViewById(R.id.iv_movie_cover2); |
| | | viewHolder.tv_movie_title2 = (TextView) convertView |
| | | .findViewById(R.id.tv_movie_title2); |
| | | viewHolder.tv_movie_rating2 = (TextView) convertView |
| | | .findViewById(R.id.tv_movie_rating2); |
| | | convertView.setTag(viewHolder); |
| | | |
| | | viewHolder.iv_gdt_nativead_logo = (ImageView) convertView |
| | | .findViewById(R.id.gdt_nativead_logo); |
| | | viewHolder.iv_gdt_nativead_poster = (ImageView) convertView |
| | | .findViewById(R.id.gdt_nativead_poster); |
| | | viewHolder.tv_gdt_nativead_text_desc = (TextView) convertView |
| | | .findViewById(R.id.gdt_nativead_text_desc); |
| | | viewHolder.tv_gdt_nativead_text_name = (TextView) convertView |
| | | .findViewById(R.id.gdt_nativead_text_name); |
| | | viewHolder.tv_gdt_nativead_text_status = (TextView) convertView |
| | | .findViewById(R.id.gdt_nativead_text_status); |
| | | viewHolder.tv_download = (TextView) convertView |
| | | .findViewById(R.id.tv_download); |
| | | } else { |
| | | viewHolder = (ViewHolder) convertView.getTag(); |
| | | } |
| | | // glide定义 |
| | | RequestManager glide = Glide.with(convertView.getContext()); |
| | | if (info == null) { |
| | | convertView.setVisibility(View.GONE); |
| | | return convertView; |
| | | } |
| | | if (info1 == null) { |
| | | viewHolder.ll_moive_item1.setVisibility(View.INVISIBLE); |
| | | convertView.findViewById(R.id.fl_gdtnative_ad).setVisibility( |
| | | View.GONE); |
| | | viewHolder.ll_moive_item2.setVisibility(View.INVISIBLE); |
| | | // return convertView; |
| | | } |
| | | if (info2 == null) { |
| | | viewHolder.ll_moive_item2.setVisibility(View.INVISIBLE); |
| | | convertView.findViewById(R.id.fl_gdtnative_ad).setVisibility( |
| | | View.GONE); |
| | | // return convertView; |
| | | } |
| | | // VideoInfo videoInfo = (VideoInfo) getItem(position); |
| | | // imageLoader.displayImage(videoInfo.getPicture(), |
| | | // viewHolder.iv_movie_cover, options);// GridVideoAdapter |
| | | // viewHolder.tv_movie_title.setText(videoInfo.getName()); |
| | | // viewHolder.tv_movie_rating.setText(StringUtils.isBlank(videoInfo |
| | | // .getTag()) ? "" : videoInfo.getTag()); |
| | | viewHolder.iv_gdt_nativead_logo = (ImageView) convertView |
| | | .findViewById(R.id.gdt_nativead_logo); |
| | | viewHolder.iv_gdt_nativead_poster = (ImageView) convertView |
| | | .findViewById(R.id.gdt_nativead_poster); |
| | | viewHolder.tv_gdt_nativead_text_desc = (TextView) convertView |
| | | .findViewById(R.id.gdt_nativead_text_desc); |
| | | viewHolder.tv_gdt_nativead_text_name = (TextView) convertView |
| | | .findViewById(R.id.gdt_nativead_text_name); |
| | | viewHolder.tv_gdt_nativead_text_status = (TextView) convertView |
| | | .findViewById(R.id.gdt_nativead_text_status); |
| | | viewHolder.tv_download = (TextView) convertView |
| | | .findViewById(R.id.tv_download); |
| | | } else { |
| | | viewHolder = (ViewHolder) convertView.getTag(); |
| | | } |
| | | // glide定义 |
| | | RequestManager glide = Glide.with(convertView.getContext()); |
| | | if (info == null) { |
| | | convertView.setVisibility(View.GONE); |
| | | return convertView; |
| | | } |
| | | if (info1 == null) { |
| | | viewHolder.ll_moive_item1.setVisibility(View.INVISIBLE); |
| | | convertView.findViewById(R.id.fl_gdtnative_ad).setVisibility( |
| | | View.GONE); |
| | | viewHolder.ll_moive_item2.setVisibility(View.INVISIBLE); |
| | | // return convertView; |
| | | } |
| | | if (info2 == null) { |
| | | viewHolder.ll_moive_item2.setVisibility(View.INVISIBLE); |
| | | convertView.findViewById(R.id.fl_gdtnative_ad).setVisibility( |
| | | View.GONE); |
| | | // return convertView; |
| | | } |
| | | |
| | | if (info != null) { |
| | | if (info != null) { |
| | | |
| | | viewHolder.ll_moive_item.setVisibility(View.VISIBLE); |
| | | // imageLoader.displayImage(info.getPicture(), |
| | | // viewHolder.iv_movie_cover, options);// GridVideoAdapter |
| | | glide.load(info.getPicture()) |
| | | .placeholder(R.drawable.ic_default_cover) |
| | | .error(R.drawable.ic_default_cover).transition(withCrossFade()) |
| | | .into(viewHolder.iv_movie_cover); |
| | | viewHolder.tv_movie_title.setText(info.getName()); |
| | | viewHolder.tv_movie_rating.setText(StringUtils.isBlank(info |
| | | .getTag()) ? "" : info.getTag()); |
| | | final VideoInfo cInfo = info; |
| | | if (info.getAdInfo() != null) { |
| | | convertView.findViewById(R.id.ll_all_moive_item).setVisibility( |
| | | View.GONE); |
| | | convertView.findViewById(R.id.fl_gdtnative_ad).setVisibility( |
| | | View.VISIBLE); |
| | | // imageLoader.displayImage( |
| | | // info.getAdInfo().getContent() |
| | | // .get(XfvideoNativeKey.IMAGE_URL) |
| | | // + "", viewHolder.iv_gdt_nativead_poster); |
| | | glide.load(info.getAdInfo().getImgUrl() + "").transition(withCrossFade()) |
| | | .into(viewHolder.iv_gdt_nativead_poster); |
| | | // imageLoader.displayImage( |
| | | // info.getAdInfo().getContent() |
| | | // .get(XfvideoNativeKey.ICON_URL) |
| | | // + "", viewHolder.iv_gdt_nativead_logo); |
| | | glide.load(info.getAdInfo().getIconUrl() + "").transition(withCrossFade()) |
| | | .into(viewHolder.iv_gdt_nativead_logo); |
| | | viewHolder.tv_gdt_nativead_text_desc.setText(info.getAdInfo() |
| | | .getDesc() + ""); |
| | | viewHolder.tv_gdt_nativead_text_name.setText(info.getAdInfo() |
| | | .getTitle() + ""); |
| | | mInfo = info; |
| | | viewHolder.tv_download.setText("下载"); |
| | | mInfo.getAdInfo().onExposured( |
| | | (ViewGroup) convertView |
| | | .findViewById(R.id.fl_gdtnative_ad)); |
| | | viewHolder.tv_download |
| | | .setOnClickListener(new OnClickListener() { |
| | | viewHolder.ll_moive_item.setVisibility(View.VISIBLE); |
| | | // imageLoader.displayImage(info.getPicture(), |
| | | // viewHolder.iv_movie_cover, options);// GridVideoAdapter |
| | | glide.load(info.getPicture()) |
| | | .placeholder(R.drawable.ic_default_cover) |
| | | .error(R.drawable.ic_default_cover).transition(withCrossFade()) |
| | | .into(viewHolder.iv_movie_cover); |
| | | viewHolder.tv_movie_title.setText(info.getName()); |
| | | viewHolder.tv_movie_rating.setText(StringUtils.isBlank(info |
| | | .getTag()) ? "" : info.getTag()); |
| | | final VideoInfo cInfo = info; |
| | | { |
| | | convertView.findViewById(R.id.ll_all_moive_item).setVisibility( |
| | | View.VISIBLE); |
| | | convertView.findViewById(R.id.fl_gdtnative_ad).setVisibility( |
| | | View.GONE); |
| | | viewHolder.ll_moive_item |
| | | .setOnClickListener(new OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(final View v) { |
| | | if (mInfo.getAdInfo() == null) { |
| | | myClick(mInfo, v); |
| | | } else { |
| | | if (BeibeiConstant.ISHUAWEI) { |
| | | DialogInterface.OnClickListener dialogOnclicListener = new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | myClick(cInfo, v); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | if (info1 != null) { |
| | | viewHolder.ll_moive_item1.setVisibility(View.VISIBLE); |
| | | // imageLoader.displayImage(info1.getPicture(), |
| | | // viewHolder.iv_movie_cover1, options);// GridVideoAdapter |
| | | glide.load(info1.getPicture()) |
| | | .placeholder(R.drawable.ic_default_cover) |
| | | .error(R.drawable.ic_default_cover).transition(withCrossFade()) |
| | | .into(viewHolder.iv_movie_cover1); |
| | | viewHolder.tv_movie_title1.setText(info1.getName()); |
| | | viewHolder.tv_movie_rating1.setText(StringUtils.isBlank(info1 |
| | | .getTag()) ? "" : info1.getTag()); |
| | | final VideoInfo cInfo = info1; |
| | | viewHolder.ll_moive_item1.setOnClickListener(new OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(DialogInterface dialog, |
| | | int which) { |
| | | switch (which) { |
| | | case Dialog.BUTTON_POSITIVE: |
| | | mInfo.getAdInfo().onClicked(v); |
| | | dialog.dismiss(); |
| | | break; |
| | | case Dialog.BUTTON_NEGATIVE: |
| | | dialog.dismiss(); |
| | | break; |
| | | } |
| | | } |
| | | }; |
| | | AdPromptDialog.Builder builder = new AdPromptDialog.Builder( |
| | | v.getContext()); // 先得到构造器 |
| | | builder.setPositiveButton("确认", dialogOnclicListener); |
| | | builder.setNegativeButton("取消", dialogOnclicListener); |
| | | builder.create().show(); |
| | | } else { |
| | | mInfo.getAdInfo().onClicked(v); |
| | | } |
| | | } |
| | | Toast.makeText(v.getContext(), "正在下载中,请等待...", |
| | | Toast.LENGTH_LONG).show(); |
| | | } |
| | | }); |
| | | } else { |
| | | convertView.findViewById(R.id.ll_all_moive_item).setVisibility( |
| | | View.VISIBLE); |
| | | convertView.findViewById(R.id.fl_gdtnative_ad).setVisibility( |
| | | View.GONE); |
| | | viewHolder.ll_moive_item |
| | | .setOnClickListener(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | myClick(cInfo, v); |
| | | } |
| | | }); |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | myClick(cInfo, v); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | if (info1 != null) { |
| | | viewHolder.ll_moive_item1.setVisibility(View.VISIBLE); |
| | | // imageLoader.displayImage(info1.getPicture(), |
| | | // viewHolder.iv_movie_cover1, options);// GridVideoAdapter |
| | | glide.load(info1.getPicture()) |
| | | .placeholder(R.drawable.ic_default_cover) |
| | | .error(R.drawable.ic_default_cover).transition(withCrossFade()) |
| | | .into(viewHolder.iv_movie_cover1); |
| | | viewHolder.tv_movie_title1.setText(info1.getName()); |
| | | viewHolder.tv_movie_rating1.setText(StringUtils.isBlank(info1 |
| | | .getTag()) ? "" : info1.getTag()); |
| | | final VideoInfo cInfo = info1; |
| | | viewHolder.ll_moive_item1.setOnClickListener(new OnClickListener() { |
| | | } else { |
| | | viewHolder.ll_moive_item1.setVisibility(View.INVISIBLE); |
| | | return convertView; |
| | | } |
| | | if (info2 != null) { |
| | | viewHolder.ll_moive_item2.setVisibility(View.VISIBLE); |
| | | // imageLoader.displayImage(info2.getPicture(), |
| | | // viewHolder.iv_movie_cover2, options);// GridVideoAdapter |
| | | glide.load(info2.getPicture()) |
| | | .placeholder(R.drawable.ic_default_cover) |
| | | .error(R.drawable.ic_default_cover).transition(withCrossFade()) |
| | | .into(viewHolder.iv_movie_cover2); |
| | | viewHolder.tv_movie_title2.setText(info2.getName()); |
| | | viewHolder.tv_movie_rating2.setText(StringUtils.isBlank(info2 |
| | | .getTag()) ? "" : info2.getTag()); |
| | | final VideoInfo cInfo = info2; |
| | | viewHolder.ll_moive_item2.setOnClickListener(new OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | myClick(cInfo, v); |
| | | } |
| | | }); |
| | | @Override |
| | | public void onClick(View v) { |
| | | myClick(cInfo, v); |
| | | } |
| | | }); |
| | | } else { |
| | | viewHolder.ll_moive_item2.setVisibility(View.INVISIBLE); |
| | | return convertView; |
| | | } |
| | | |
| | | } else { |
| | | viewHolder.ll_moive_item1.setVisibility(View.INVISIBLE); |
| | | return convertView; |
| | | } |
| | | if (info2 != null) { |
| | | viewHolder.ll_moive_item2.setVisibility(View.VISIBLE); |
| | | // imageLoader.displayImage(info2.getPicture(), |
| | | // viewHolder.iv_movie_cover2, options);// GridVideoAdapter |
| | | glide.load(info2.getPicture()) |
| | | .placeholder(R.drawable.ic_default_cover) |
| | | .error(R.drawable.ic_default_cover).transition(withCrossFade()) |
| | | .into(viewHolder.iv_movie_cover2); |
| | | viewHolder.tv_movie_title2.setText(info2.getName()); |
| | | viewHolder.tv_movie_rating2.setText(StringUtils.isBlank(info2 |
| | | .getTag()) ? "" : info2.getTag()); |
| | | final VideoInfo cInfo = info2; |
| | | viewHolder.ll_moive_item2.setOnClickListener(new OnClickListener() { |
| | | return convertView; |
| | | } |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | myClick(cInfo, v); |
| | | } |
| | | }); |
| | | } else { |
| | | viewHolder.ll_moive_item2.setVisibility(View.INVISIBLE); |
| | | return convertView; |
| | | } |
| | | private static class ViewHolder { |
| | | LinearLayout ll_moive_item; |
| | | LinearLayout ll_moive_item1; |
| | | LinearLayout ll_moive_item2; |
| | | ImageView iv_movie_cover; |
| | | TextView tv_movie_title; |
| | | TextView tv_movie_rating; |
| | | ImageView iv_movie_cover1; |
| | | TextView tv_movie_title1; |
| | | TextView tv_movie_rating1; |
| | | ImageView iv_movie_cover2; |
| | | TextView tv_movie_title2; |
| | | TextView tv_movie_rating2; |
| | | |
| | | return convertView; |
| | | } |
| | | /* |
| | | * 广点通原生广告样式 |
| | | */ |
| | | ImageView iv_gdt_nativead_logo; |
| | | TextView tv_gdt_nativead_text_name; |
| | | TextView tv_gdt_nativead_text_desc; |
| | | TextView tv_gdt_nativead_text_status; |
| | | TextView tv_download; |
| | | ImageView iv_gdt_nativead_poster; |
| | | } |
| | | |
| | | private static class ViewHolder { |
| | | LinearLayout ll_moive_item; |
| | | LinearLayout ll_moive_item1; |
| | | LinearLayout ll_moive_item2; |
| | | ImageView iv_movie_cover; |
| | | TextView tv_movie_title; |
| | | TextView tv_movie_rating; |
| | | ImageView iv_movie_cover1; |
| | | TextView tv_movie_title1; |
| | | TextView tv_movie_rating1; |
| | | ImageView iv_movie_cover2; |
| | | TextView tv_movie_title2; |
| | | TextView tv_movie_rating2; |
| | | |
| | | /* |
| | | * 广点通原生广告样式 |
| | | */ |
| | | ImageView iv_gdt_nativead_logo; |
| | | TextView tv_gdt_nativead_text_name; |
| | | TextView tv_gdt_nativead_text_desc; |
| | | TextView tv_gdt_nativead_text_status; |
| | | TextView tv_download; |
| | | ImageView iv_gdt_nativead_poster; |
| | | } |
| | | |
| | | /** |
| | | * App类广告安装、下载状态的更新(普链广告没有此状态,其值为-1) 返回的AppStatus含义如下: 0:未下载 1:已安装 2:已安装旧版本 |
| | | * 4:下载中(可获取下载进度“0-100”) 8:下载完成 16:下载失败 |
| | | */ |
| | | // private String getADText() { |
| | | // if (mInfo.getAdInfo() == null) { |
| | | // return "……"; |
| | | // } |
| | | // switch (Integer.parseInt(mInfo.getAdInfo().getContent() |
| | | // .get(XfvideoNativeKey.LATYPE) |
| | | // + "")) { |
| | | // case 2: |
| | | // return "点击下载"; |
| | | // case 3: |
| | | // return "打开网页"; |
| | | // default: |
| | | // return "查看详情"; |
| | | // } |
| | | // } |
| | | |
| | | private void myClick(VideoInfo videoInfo, View v) { |
| | | Intent intent = new Intent(v.getContext(), VideoDetailActivity.class); |
| | | intent.putExtra("video_info", videoInfo); |
| | | v.getContext().startActivity(intent); |
| | | } |
| | | /** |
| | | * App类广告安装、下载状态的更新(普链广告没有此状态,其值为-1) 返回的AppStatus含义如下: 0:未下载 1:已安装 2:已安装旧版本 |
| | | * 4:下载中(可获取下载进度“0-100”) 8:下载完成 16:下载失败 |
| | | */ |
| | | // private String getADText() { |
| | | // if (mInfo.getAdInfo() == null) { |
| | | // return "……"; |
| | | // } |
| | | // switch (Integer.parseInt(mInfo.getAdInfo().getContent() |
| | | // .get(XfvideoNativeKey.LATYPE) |
| | | // + "")) { |
| | | // case 2: |
| | | // return "点击下载"; |
| | | // case 3: |
| | | // return "打开网页"; |
| | | // default: |
| | | // return "查看详情"; |
| | | // } |
| | | // } |
| | | private void myClick(VideoInfo videoInfo, View v) { |
| | | Intent intent = new Intent(v.getContext(), VideoDetailActivity.class); |
| | | intent.putExtra("video_info", videoInfo); |
| | | v.getContext().startActivity(intent); |
| | | } |
| | | } |
| | |
| | | import com.bumptech.glide.RequestManager; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.mugua.mgvideo.ui.media.VideoDetailActivity; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | import com.bumptech.glide.RequestManager; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | import com.nostra13.universalimageloader.core.ImageLoader; |
| | | import com.nostra13.universalimageloader.core.assist.ImageScaleType; |
| | | import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.mugua.mgvideo.ui.media.VideoDetailActivity; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | |
| | | import com.mugua.mgvideo.entity.LiveVideoInfo; |
| | | import com.mugua.mgvideo.service.DownLoadFileService; |
| | | import com.mugua.mgvideo.util.AdPromptDialog; |
| | | import com.mugua.mgvideo.util.BeibeiConstant; |
| | | import com.mugua.mgvideo.util.downutil.ApkUtil; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | import com.yeshi.base.utils.downutil.ApkUtil; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | |
| | | viewHolder.tv_gdt_nativead_text_name.setText(info.getTitle()); |
| | | mInfo = info; |
| | | viewHolder.tv_download.setText("点击下载"); |
| | | mInfo.getAdInfo().onExposured( |
| | | (ViewGroup) convertView |
| | | .findViewById(R.id.fl_gdtnative_ad)); |
| | | viewHolder.tv_download |
| | | .setOnClickListener(new OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(final View v) { |
| | | if (BeibeiConstant.ISHUAWEI) { |
| | | DialogInterface.OnClickListener dialogOnclicListener = new DialogInterface.OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(DialogInterface dialog, |
| | | int which) { |
| | | switch (which) { |
| | | case Dialog.BUTTON_POSITIVE: |
| | | mInfo.getAdInfo().onClicked(v); |
| | | dialog.dismiss(); |
| | | break; |
| | | case Dialog.BUTTON_NEGATIVE: |
| | | dialog.dismiss(); |
| | | break; |
| | | } |
| | | } |
| | | }; |
| | | AdPromptDialog.Builder builder = new AdPromptDialog.Builder( |
| | | v.getContext()); // 先得到构造器 |
| | | builder.setPositiveButton("确认", dialogOnclicListener); |
| | | builder.setNegativeButton("取消", dialogOnclicListener); |
| | | builder.create().show(); |
| | | } else { |
| | | mInfo.getAdInfo().onClicked(v); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } else { |
| | | convertView.findViewById(R.id.fl_gdtnative_ad).setVisibility( |
| | | View.GONE); |
| | |
| | | import android.content.pm.ActivityInfo; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.widget.AdapterView; |
| | |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mugua.mgvideo.R; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.mugua.mgvideo.ui.BaseActivity; |
| | | import com.mugua.mgvideo.ui.media.VideoDetailActivity; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.RequestManager; |
| | | import com.mugua.mgvideo.MGVideoApplication; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.entity.MemeLiveInfo; |
| | | import com.mugua.mgvideo.service.DownLoadFileService; |
| | | import com.nostra13.universalimageloader.core.DisplayImageOptions; |
| | | import com.nostra13.universalimageloader.core.ImageLoader; |
| | | import com.nostra13.universalimageloader.core.assist.ImageScaleType; |
| | | import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; |
| | | import com.mugua.mgvideo.MGVideoApplication; |
| | | import com.mugua.mgvideo.entity.MemeLiveInfo; |
| | | import com.mugua.mgvideo.service.DownLoadFileService; |
| | | import com.mugua.mgvideo.util.downutil.ApkUtil; |
| | | import com.yeshi.base.utils.downutil.ApkUtil; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | import com.nostra13.universalimageloader.core.ImageLoader; |
| | | import com.nostra13.universalimageloader.core.assist.ImageScaleType; |
| | | import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import android.view.Gravity; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.lcjian.library.util.RefreshLayout; |
| | | import com.lcjian.library.util.common.DimenUtils; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.ui.category.CategoryListAdapter; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | import com.qq.e.ads.cfg.VideoOption; |
| | | import com.qq.e.ads.nativ.ADSize; |
| | | import com.qq.e.ads.nativ.NativeExpressAD; |
| | | import com.qq.e.ads.nativ.NativeExpressADView; |
| | | import com.qq.e.comm.util.AdError; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.mugua.mgvideo.entity.VideoType; |
| | | import com.mugua.mgvideo.ui.category.CategoryListAdapter; |
| | | import com.mugua.mgvideo.util.BeibeiConstant; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.yeshi.base.entity.video.VideoType; |
| | | import com.yeshi.base.utils.ad.GDTConstant; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | |
| | | public class VideosFragment extends Fragment implements |
| | | OnCheckedChangeListener, OnClickListener { |
| | |
| | | |
| | | private void loadAD() { |
| | | NativeExpressAD nativeExpressAD = new NativeExpressAD(getContext(), new ADSize(ADSize.FULL_WIDTH, ADSize.AUTO_HEIGHT), |
| | | BeibeiConstant.GDT_APP_ID, BeibeiConstant.GDT_TEMPLATE_SEARCH_RESULT, new NativeExpressAD.NativeExpressADListener() { |
| | | GDTConstant.GDT_APP_ID, GDTConstant.GDT_TEMPLATE_SEARCH_RESULT, new NativeExpressAD.NativeExpressADListener() { |
| | | @Override |
| | | public void onADLoaded(final List<NativeExpressADView> list) { |
| | | if (list != null && list.size() > 0) { |
| | |
| | | import android.app.ActivityManager; |
| | | import android.content.ComponentName; |
| | | import android.os.Bundle; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import android.view.KeyEvent; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | |
| | | import com.lcjian.library.util.common.DimenUtils; |
| | | import com.mugua.mgvideo.R; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.entity.MemeLiveInfo; |
| | | import com.mugua.mgvideo.ui.BaseActivity; |
New file |
| | |
| | | package com.mugua.mgvideo.ui.dialog; |
| | | |
| | | import android.app.Dialog; |
| | | import android.content.Context; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.widget.TextView; |
| | | |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mugua.mgvideo.R; |
| | | |
| | | /** |
| | | * 用户协议弹框 |
| | | */ |
| | | public class LoadingDialogUtil { |
| | | |
| | | private static Dialog pd; |
| | | |
| | | public static void show(Context context) { |
| | | show(context, "", false); |
| | | } |
| | | |
| | | public static void show(Context context, String msg, boolean cancelable) { |
| | | try { |
| | | dismiss(); |
| | | //拿到dialog |
| | | pd = getLoadingDialog(context, msg); |
| | | //设置点击外围是否消失 |
| | | pd.setCancelable(cancelable); |
| | | pd.show(); |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | |
| | | //这里的加载效果自己随意定义 |
| | | public static Dialog getLoadingDialog(Context context, String msg) { |
| | | Dialog loading_dialog = new Dialog(context, R.style.Dialog); |
| | | View view = LayoutInflater.from(context).inflate(R.layout.dialog_loading, null); |
| | | TextView tv_msg = view.findViewById(R.id.tv_msg); |
| | | if (StringUtils.isEmpty(msg)) { |
| | | tv_msg.setVisibility(View.GONE); |
| | | } else { |
| | | tv_msg.setText(msg); |
| | | tv_msg.setVisibility(View.VISIBLE); |
| | | } |
| | | loading_dialog.setContentView(view); |
| | | loading_dialog.getWindow().setBackgroundDrawableResource(R.color.transparent); |
| | | loading_dialog.setCancelable(false); |
| | | return loading_dialog; |
| | | } |
| | | |
| | | |
| | | //在这里直接做了判断,大胆的放心的使用,保证不会出现空指针 |
| | | public static void dismiss() { |
| | | try { |
| | | if (pd != null && pd.isShowing()) { |
| | | pd.dismiss(); |
| | | } |
| | | pd = null; |
| | | } catch (Exception e) { |
| | | // TODO: handle exception |
| | | } finally { |
| | | pd = null; |
| | | } |
| | | } |
| | | |
| | | |
| | | public static boolean isShowing() { |
| | | try { |
| | | if (pd != null) { |
| | | return pd.isShowing(); |
| | | } |
| | | } catch (Exception e) { |
| | | // TODO: handle exception |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 设置dialog点击外部是否可以消失 |
| | | */ |
| | | public static void setCanceledOnTouchOutside(boolean b) { |
| | | try { |
| | | if (pd != null && pd.isShowing()) { |
| | | pd.setCanceledOnTouchOutside(b); |
| | | } |
| | | } catch (Exception e) { |
| | | // TODO: handle exception |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | | import android.os.Bundle; |
| | | import android.support.v4.view.PagerAdapter; |
| | | import androidx.viewpager.widget.PagerAdapter; |
| | | import android.util.TypedValue; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | |
| | | import com.nostra13.universalimageloader.core.ImageLoader; |
| | | import com.nostra13.universalimageloader.core.assist.ImageScaleType; |
| | | import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.entity.GoodsInfo; |
| | | import com.mugua.mgvideo.util.GlideCircleTransform; |
| | |
| | | import com.nostra13.universalimageloader.core.ImageLoader; |
| | | import com.nostra13.universalimageloader.core.assist.ImageScaleType; |
| | | import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.entity.GoodsComments; |
| | | import com.mugua.mgvideo.entity.Ware; |
| | | import com.mugua.mgvideo.ui.BaseActivity; |
| | | import com.mugua.mgvideo.util.AlibcTradeUtil; |
| | | import com.mugua.mgvideo.util.BeibeiConstant; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | import com.mugua.mgvideo.util.GlideCircleTransform; |
| | | |
| | | import org.apache.http.Header; |
| | |
| | | import android.content.SharedPreferences; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.Window; |
| | |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.lcjian.library.util.RefreshLayout; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.entity.GoodsComments; |
| | | import com.mugua.mgvideo.ui.BaseActivity; |
| | |
| | | |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.entity.GoodsComments; |
| | | import com.mugua.mgvideo.entity.UserInfo; |
| | |
| | | |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.FragmentManager; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentManager; |
| | | import android.view.View; |
| | | import android.view.Window; |
| | | import android.view.WindowManager; |
| | |
| | | package com.mugua.mgvideo.ui.discover; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.util.List; |
| | | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.view.LayoutInflater; |
| | |
| | | import com.bumptech.glide.Glide; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.mugua.mgvideo.ui.media.VideoDetailActivity; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.util.List; |
| | | |
| | | public class StarWorksAdapter extends BaseAdapter { |
| | | private Context mContext; |
| | |
| | | import com.lcjian.library.util.SingleToast; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.ui.BaseActivity; |
| | | import com.mugua.mgvideo.util.IsEmail; |
| | |
| | | import com.umeng.socialize.UMAuthListener; |
| | | import com.umeng.socialize.UMShareAPI; |
| | | import com.umeng.socialize.bean.SHARE_MEDIA; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.ui.BaseActivity; |
| | | import com.mugua.mgvideo.ui.mine.BrowserActivity; |
| | | import com.mugua.mgvideo.util.BeibeiConstant; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | import com.mugua.mgvideo.util.XGPush; |
| | | |
| | | public class LoginActivity extends BaseActivity implements OnClickListener { |
| | |
| | | import com.lcjian.library.util.SingleToast; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.ui.BaseActivity; |
| | | import com.mugua.mgvideo.util.BeibeiConstant; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | import com.mugua.mgvideo.util.GlideCircleTransform; |
| | | import com.mugua.mgvideo.util.SelectPicUtil; |
| | | |
| | |
| | | import com.lcjian.library.util.SingleToast; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.ui.BaseActivity; |
| | | import com.mugua.mgvideo.ui.mine.BrowserActivity; |
| | | import com.mugua.mgvideo.util.BeibeiConstant; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | import com.mugua.mgvideo.util.IsEmail; |
| | | |
| | | /** |
| | |
| | | package com.mugua.mgvideo.ui.main; |
| | | |
| | | 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 androidx.annotation.Nullable; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentManager; |
| | | import androidx.fragment.app.FragmentStatePagerAdapter; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | import android.view.View; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.lcjian.library.RetainViewFragment; |
| | | import com.viewpagerindicator.FoundTabPageIndicator; |
| | | import com.mugua.mgvideo.util.downutil.StringUtils; |
| | | import com.yeshi.base.utils.downutil.StringUtils; |
| | | 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 android.graphics.drawable.Drawable; |
| | | import android.os.Bundle; |
| | | import android.provider.Settings; |
| | | import android.support.v4.view.PagerAdapter; |
| | | import android.support.v4.view.ViewPager; |
| | | |
| | | import androidx.viewpager.widget.PagerAdapter; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | |
| | | import android.view.MotionEvent; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | |
| | | import android.widget.ScrollView; |
| | | import android.widget.TextView; |
| | | |
| | | import com.alibaba.android.arouter.launcher.ARouter; |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | |
| | | import com.mugua.mgvideo.R; |
| | | import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; |
| | | import com.viewpagerindicator.CirclePageIndicator; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.entity.HotVideoType; |
| | | import com.mugua.mgvideo.entity.Special; |
| | | import com.mugua.mgvideo.entity.VideoType; |
| | | import com.yeshi.base.entity.video.VideoType; |
| | | import com.mugua.mgvideo.ui.category.CategoryAdapter; |
| | | import com.mugua.mgvideo.ui.category.MVideosActivity; |
| | | import com.mugua.mgvideo.ui.category.StarAdapter; |
| | | import com.mugua.mgvideo.ui.discover.DiscoverTopAdapter; |
| | | import com.mugua.mgvideo.ui.discover.SpecificListActivity; |
| | | import com.mugua.mgvideo.ui.recommend.SearchActivity; |
| | | import com.mugua.mgvideo.ui.recommend.SearchResultActivity; |
| | | import com.yeshi.base.utils.RouteConstant; |
| | | |
| | | public class CategoryFragment extends RetainViewFragment implements |
| | | OnClickListener { |
| | | OnClickListener { |
| | | |
| | | private TextView tv_go_search; |
| | | private TextView tv_go_search; |
| | | |
| | | private TextView tv_no_network; |
| | | private TextView tv_no_network; |
| | | |
| | | private PullToRefreshScrollView ptsv_container; |
| | | private PullToRefreshScrollView ptsv_container; |
| | | |
| | | private GridView gv_video_category; |
| | | private GridView gv_video_category; |
| | | |
| | | private GridView gv_hot_stars; |
| | | private GridView gv_hot_stars; |
| | | |
| | | private DiskLruCache cache; |
| | | private DiskLruCache cache; |
| | | |
| | | private ConnectivityChangeHelper mChangeHelper; |
| | | private ConnectivityChangeHelper mChangeHelper; |
| | | |
| | | private List<String> hotSearchs = null; |
| | | private List<String> hotSearchs = null; |
| | | |
| | | private ViewPager vp_theme; |
| | | private ViewPager vp_theme; |
| | | |
| | | private CirclePageIndicator indicator_theme; |
| | | private CirclePageIndicator indicator_theme; |
| | | |
| | | @Override |
| | | public void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | try { |
| | | cache = DiskLruCache.open( |
| | | new File(StorageUtils.getCacheDirectory(getActivity()) |
| | | .toString(), "http"), getVersionNum(getActivity()), |
| | | 1, 1024 * 1024); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | @Override |
| | | public void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | try { |
| | | cache = DiskLruCache.open( |
| | | new File(StorageUtils.getCacheDirectory(getActivity()) |
| | | .toString(), "http"), getVersionNum(getActivity()), |
| | | 1, 1024 * 1024); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int getContentResource() { |
| | | return R.layout.category_fragment; |
| | | } |
| | | @Override |
| | | public int getContentResource() { |
| | | return R.layout.category_fragment; |
| | | } |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | |
| | | tv_no_network = (TextView) contentView.findViewById(R.id.tv_no_network); |
| | | tv_no_network.setOnClickListener(this); |
| | | vp_theme = (ViewPager) contentView.findViewById(R.id.vp_discover); |
| | | vp_theme.setAdapter(new DiscoverTopAdapter(null, getActivity() |
| | | .getApplicationContext())); |
| | | indicator_theme = (CirclePageIndicator) contentView |
| | | .findViewById(R.id.indicator_discover); |
| | | indicator_theme.setViewPager(vp_theme); |
| | | contentView.findViewById(R.id.tv_collection_more).setOnClickListener( |
| | | this); |
| | | mChangeHelper = new ConnectivityChangeHelper(getActivity(), |
| | | new OnConnectivityChangeListener() { |
| | | tv_no_network = (TextView) contentView.findViewById(R.id.tv_no_network); |
| | | tv_no_network.setOnClickListener(this); |
| | | vp_theme = (ViewPager) contentView.findViewById(R.id.vp_discover); |
| | | vp_theme.setAdapter(new DiscoverTopAdapter(null, getActivity() |
| | | .getApplicationContext())); |
| | | indicator_theme = (CirclePageIndicator) contentView |
| | | .findViewById(R.id.indicator_discover); |
| | | indicator_theme.setViewPager(vp_theme); |
| | | contentView.findViewById(R.id.tv_collection_more).setOnClickListener( |
| | | this); |
| | | mChangeHelper = new ConnectivityChangeHelper(getActivity(), |
| | | new OnConnectivityChangeListener() { |
| | | |
| | | @Override |
| | | public void onNetworkUnAvailable() { |
| | | tv_no_network.setVisibility(View.VISIBLE); |
| | | } |
| | | @Override |
| | | public void onNetworkUnAvailable() { |
| | | tv_no_network.setVisibility(View.VISIBLE); |
| | | } |
| | | |
| | | @Override |
| | | public void onWiFiAvailable() { |
| | | tv_no_network.setVisibility(View.GONE); |
| | | } |
| | | @Override |
| | | public void onWiFiAvailable() { |
| | | tv_no_network.setVisibility(View.GONE); |
| | | } |
| | | |
| | | @Override |
| | | public void onMobileAvailable() { |
| | | tv_no_network.setVisibility(View.GONE); |
| | | } |
| | | }); |
| | | @Override |
| | | public void onMobileAvailable() { |
| | | tv_no_network.setVisibility(View.GONE); |
| | | } |
| | | }); |
| | | |
| | | tv_go_search = (TextView) contentView.findViewById(R.id.tv_go_search); |
| | | tv_go_search = (TextView) contentView.findViewById(R.id.tv_go_search); |
| | | |
| | | ptsv_container = (PullToRefreshScrollView) contentView |
| | | .findViewById(R.id.ptsv_container); |
| | | gv_video_category = (GridView) contentView |
| | | .findViewById(R.id.gv_video_category); |
| | | gv_hot_stars = (GridView) contentView.findViewById(R.id.gv_hot_stars); |
| | | tv_go_search.setOnClickListener(this); |
| | | tv_go_search.setOnTouchListener(new OnTouchListener() { |
| | | ptsv_container = (PullToRefreshScrollView) contentView |
| | | .findViewById(R.id.ptsv_container); |
| | | gv_video_category = (GridView) contentView |
| | | .findViewById(R.id.gv_video_category); |
| | | gv_hot_stars = (GridView) contentView.findViewById(R.id.gv_hot_stars); |
| | | tv_go_search.setOnClickListener(this); |
| | | tv_go_search.setOnTouchListener(new OnTouchListener() { |
| | | |
| | | @Override |
| | | public boolean onTouch(View v, MotionEvent event) { |
| | | // getCompoundDrawables() 可以获取一个长度为4的数组, |
| | | // 存放drawableLeft,Right,Top,Bottom四个图片资源对象 |
| | | // index=2 表示的是 drawableRight 图片资源对象 |
| | | Drawable drawable = tv_go_search.getCompoundDrawables()[2]; |
| | | if (drawable == null) |
| | | return false; |
| | | @Override |
| | | public boolean onTouch(View v, MotionEvent event) { |
| | | // getCompoundDrawables() 可以获取一个长度为4的数组, |
| | | // 存放drawableLeft,Right,Top,Bottom四个图片资源对象 |
| | | // index=2 表示的是 drawableRight 图片资源对象 |
| | | Drawable drawable = tv_go_search.getCompoundDrawables()[2]; |
| | | if (drawable == null) |
| | | return false; |
| | | |
| | | if (event.getAction() != MotionEvent.ACTION_UP) |
| | | return false; |
| | | if (event.getAction() != MotionEvent.ACTION_UP) |
| | | return false; |
| | | |
| | | // drawable.getIntrinsicWidth() 获取drawable资源图片呈现的宽度 |
| | | if (event.getX() > tv_go_search.getWidth() |
| | | - tv_go_search.getPaddingRight() |
| | | - drawable.getIntrinsicWidth()) { |
| | | if (!StringUtils.isEmpty(tv_go_search.getText().toString())) { |
| | | Intent intent = new Intent(getActivity(), |
| | | SearchResultActivity.class); |
| | | intent.putExtra("key", tv_go_search.getText() |
| | | .toString()); |
| | | startActivity(intent); |
| | | } else { |
| | | Intent intent = new Intent(getActivity(), |
| | | SearchActivity.class); |
| | | intent.putExtra("value", tv_go_search.getText() |
| | | .toString()); |
| | | startActivity(intent); |
| | | } |
| | | // drawable.getIntrinsicWidth() 获取drawable资源图片呈现的宽度 |
| | | if (event.getX() > tv_go_search.getWidth() |
| | | - tv_go_search.getPaddingRight() |
| | | - drawable.getIntrinsicWidth()) { |
| | | if (!StringUtils.isEmpty(tv_go_search.getText().toString())) { |
| | | ARouter.getInstance().build(RouteConstant.PATH_VIDEO_SEARCH_RESULT).withString("key", tv_go_search.getText() + "").navigation(); |
| | | } else { |
| | | Intent intent = new Intent(getActivity(), |
| | | SearchActivity.class); |
| | | intent.putExtra("value", tv_go_search.getText() |
| | | .toString()); |
| | | startActivity(intent); |
| | | } |
| | | |
| | | } else { |
| | | Intent intent = new Intent(getActivity(), |
| | | SearchActivity.class); |
| | | intent.putExtra("value", tv_go_search.getText().toString()); |
| | | startActivity(intent); |
| | | } |
| | | return true; |
| | | } |
| | | } else { |
| | | Intent intent = new Intent(getActivity(), |
| | | SearchActivity.class); |
| | | intent.putExtra("value", tv_go_search.getText().toString()); |
| | | startActivity(intent); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | }); |
| | | }); |
| | | |
| | | // gv_video_category.setOnItemClickListener(new OnItemClickListener() { |
| | | // |
| | | // @Override |
| | | // public void onItemClick(AdapterView<?> parent, View view, |
| | | // int position, long id) { |
| | | // if (parent.getItemAtPosition(position) != null) { |
| | | // VideoType videoType = (VideoType) parent |
| | | // .getItemAtPosition(position); |
| | | // if (videoType.getId().contains("1111")) { |
| | | // Intent intent = new Intent(parent.getContext(), |
| | | // VideosLiveActivity.class); |
| | | // intent.putExtra("video_type", videoType.getId()); |
| | | // intent.putExtra("title", videoType.getName()); |
| | | // startActivity(intent); |
| | | // } else { |
| | | // Intent intent = new Intent(parent.getContext(), |
| | | // VideosActivity.class); |
| | | // intent.putExtra("video_type", videoType.getId()); |
| | | // intent.putExtra("title", videoType.getName()); |
| | | // startActivity(intent); |
| | | // } |
| | | // } |
| | | // } |
| | | // }); |
| | | gv_hot_stars.setOnItemClickListener(new OnItemClickListener() { |
| | | // gv_video_category.setOnItemClickListener(new OnItemClickListener() { |
| | | // |
| | | // @Override |
| | | // public void onItemClick(AdapterView<?> parent, View view, |
| | | // int position, long id) { |
| | | // if (parent.getItemAtPosition(position) != null) { |
| | | // VideoType videoType = (VideoType) parent |
| | | // .getItemAtPosition(position); |
| | | // if (videoType.getId().contains("1111")) { |
| | | // Intent intent = new Intent(parent.getContext(), |
| | | // VideosLiveActivity.class); |
| | | // intent.putExtra("video_type", videoType.getId()); |
| | | // intent.putExtra("title", videoType.getName()); |
| | | // startActivity(intent); |
| | | // } else { |
| | | // Intent intent = new Intent(parent.getContext(), |
| | | // VideosActivity.class); |
| | | // intent.putExtra("video_type", videoType.getId()); |
| | | // intent.putExtra("title", videoType.getName()); |
| | | // startActivity(intent); |
| | | // } |
| | | // } |
| | | // } |
| | | // }); |
| | | gv_hot_stars.setOnItemClickListener(new OnItemClickListener() { |
| | | |
| | | @Override |
| | | public void onItemClick(AdapterView<?> parent, View view, |
| | | int position, long id) { |
| | | HotVideoType hotStar = (HotVideoType) parent |
| | | .getItemAtPosition(position); |
| | | Intent intent = new Intent(parent.getContext(), |
| | | MVideosActivity.class); |
| | | intent.putExtra("video_type", hotStar.getType()); |
| | | startActivity(intent); |
| | | } |
| | | }); |
| | | @Override |
| | | public void onItemClick(AdapterView<?> parent, View view, |
| | | int position, long id) { |
| | | HotVideoType hotStar = (HotVideoType) parent |
| | | .getItemAtPosition(position); |
| | | Intent intent = new Intent(parent.getContext(), |
| | | MVideosActivity.class); |
| | | intent.putExtra("video_type", hotStar.getType()); |
| | | startActivity(intent); |
| | | } |
| | | }); |
| | | |
| | | ptsv_container |
| | | .setOnRefreshListener(new OnRefreshListener<ScrollView>() { |
| | | ptsv_container |
| | | .setOnRefreshListener(new OnRefreshListener<ScrollView>() { |
| | | |
| | | @Override |
| | | public void onRefresh( |
| | | PullToRefreshBase<ScrollView> refreshView) { |
| | | vp_theme.setCurrentItem(0, true); |
| | | getCategories(); |
| | | getHotStars(); |
| | | getHomeAd(); |
| | | } |
| | | }); |
| | | @Override |
| | | public void onRefresh( |
| | | PullToRefreshBase<ScrollView> refreshView) { |
| | | vp_theme.setCurrentItem(0, true); |
| | | getCategories(); |
| | | getHotStars(); |
| | | getHomeAd(); |
| | | } |
| | | }); |
| | | |
| | | ptsv_container.post(new Runnable() { |
| | | ptsv_container.post(new Runnable() { |
| | | |
| | | @Override |
| | | public void run() { |
| | | if (cache != null) { |
| | | { |
| | | DiskLruCache.Snapshot snapshot = null; |
| | | try { |
| | | snapshot = cache.get(getKey("getCategories")); |
| | | if (snapshot != null) { |
| | | Gson gson = new GsonBuilder() |
| | | .setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoType> categories = gson.fromJson( |
| | | snapshot.getString(0), |
| | | new TypeToken<List<VideoType>>() { |
| | | }.getType()); |
| | | gv_video_category |
| | | .setAdapter(new CategoryAdapter( |
| | | categories, getActivity())); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if (snapshot != null) { |
| | | snapshot.close(); |
| | | } |
| | | } |
| | | } |
| | | { |
| | | DiskLruCache.Snapshot snapshot = null; |
| | | try { |
| | | snapshot = cache.get(getKey("getHotStars")); |
| | | if (snapshot != null) { |
| | | Gson gson = new GsonBuilder() |
| | | .setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<HotVideoType> hotStars = gson.fromJson( |
| | | snapshot.getString(0), |
| | | new TypeToken<List<HotVideoType>>() { |
| | | }.getType()); |
| | | gv_hot_stars.setAdapter(new StarAdapter( |
| | | hotStars)); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if (snapshot != null) { |
| | | snapshot.close(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | // if (BeibeiVideoApplication.showAd) { |
| | | // initAdvertisement(); |
| | | // } |
| | | ptsv_container.postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (cache != null) { |
| | | { |
| | | DiskLruCache.Snapshot snapshot = null; |
| | | try { |
| | | snapshot = cache.get(getKey("getCategories")); |
| | | if (snapshot != null) { |
| | | Gson gson = new GsonBuilder() |
| | | .setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoType> categories = gson.fromJson( |
| | | snapshot.getString(0), |
| | | new TypeToken<List<VideoType>>() { |
| | | }.getType()); |
| | | gv_video_category |
| | | .setAdapter(new CategoryAdapter( |
| | | categories, getActivity())); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if (snapshot != null) { |
| | | snapshot.close(); |
| | | } |
| | | } |
| | | } |
| | | { |
| | | DiskLruCache.Snapshot snapshot = null; |
| | | try { |
| | | snapshot = cache.get(getKey("getHotStars")); |
| | | if (snapshot != null) { |
| | | Gson gson = new GsonBuilder() |
| | | .setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<HotVideoType> hotStars = gson.fromJson( |
| | | snapshot.getString(0), |
| | | new TypeToken<List<HotVideoType>>() { |
| | | }.getType()); |
| | | gv_hot_stars.setAdapter(new StarAdapter( |
| | | hotStars)); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if (snapshot != null) { |
| | | snapshot.close(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | // if (BeibeiVideoApplication.showAd) { |
| | | // initAdvertisement(); |
| | | // } |
| | | ptsv_container.postDelayed(new Runnable() { |
| | | |
| | | @Override |
| | | public void run() { |
| | | ptsv_container.setRefreshing(); |
| | | } |
| | | }, 200); |
| | | @Override |
| | | public void run() { |
| | | ptsv_container.setRefreshing(); |
| | | } |
| | | }, 200); |
| | | |
| | | getHotSearch(); |
| | | getHomeAd(); |
| | | } |
| | | getHotSearch(); |
| | | getHomeAd(); |
| | | } |
| | | |
| | | private Runnable mAutoScroller = new Runnable() { |
| | | private Runnable mAutoScroller = new Runnable() { |
| | | |
| | | @Override |
| | | public void run() { |
| | | PagerAdapter adapter = vp_theme.getAdapter(); |
| | | if (adapter != null && adapter.getCount() != 0) { |
| | | vp_theme.setCurrentItem((vp_theme.getCurrentItem() + 1) |
| | | % adapter.getCount(), true); |
| | | } |
| | | vp_theme.postDelayed(this, 5000); |
| | | } |
| | | }; |
| | | @Override |
| | | public void run() { |
| | | PagerAdapter adapter = vp_theme.getAdapter(); |
| | | if (adapter != null && adapter.getCount() != 0) { |
| | | vp_theme.setCurrentItem((vp_theme.getCurrentItem() + 1) |
| | | % adapter.getCount(), true); |
| | | } |
| | | vp_theme.postDelayed(this, 5000); |
| | | } |
| | | }; |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | indicator_theme.setViewPager(vp_theme); |
| | | vp_theme.postDelayed(mAutoScroller, 2000); |
| | | mChangeHelper.registerReceiver(); |
| | | initHotSearch(); |
| | | } |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | indicator_theme.setViewPager(vp_theme); |
| | | vp_theme.postDelayed(mAutoScroller, 2000); |
| | | mChangeHelper.registerReceiver(); |
| | | initHotSearch(); |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | vp_theme.removeCallbacks(mAutoScroller); |
| | | mChangeHelper.unregisterReceiver(); |
| | | } |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | vp_theme.removeCallbacks(mAutoScroller); |
| | | mChangeHelper.unregisterReceiver(); |
| | | } |
| | | |
| | | @Override |
| | | public void onDestroy() { |
| | | super.onDestroy(); |
| | | } |
| | | @Override |
| | | public void onDestroy() { |
| | | super.onDestroy(); |
| | | } |
| | | |
| | | private String getKey(String method) { |
| | | return new Md5FileNameGenerator().generate(method); |
| | | } |
| | | private String getKey(String method) { |
| | | return new Md5FileNameGenerator().generate(method); |
| | | } |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | switch (v.getId()) { |
| | | case R.id.tv_go_search: { |
| | | Intent intent = new Intent(getActivity(), SearchActivity.class); |
| | | startActivity(intent); |
| | | } |
| | | break; |
| | | case R.id.tv_no_network: { |
| | | Intent intent = new Intent(Settings.ACTION_SETTINGS); |
| | | startActivity(intent); |
| | | } |
| | | break; |
| | | case R.id.tv_collection_more: |
| | | startActivity(new Intent(tv_no_network.getContext(), |
| | | SpecificListActivity.class)); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | @Override |
| | | public void onClick(View v) { |
| | | switch (v.getId()) { |
| | | case R.id.tv_go_search: { |
| | | Intent intent = new Intent(getActivity(), SearchActivity.class); |
| | | startActivity(intent); |
| | | } |
| | | break; |
| | | case R.id.tv_no_network: { |
| | | Intent intent = new Intent(Settings.ACTION_SETTINGS); |
| | | startActivity(intent); |
| | | } |
| | | break; |
| | | case R.id.tv_collection_more: |
| | | startActivity(new Intent(tv_no_network.getContext(), |
| | | SpecificListActivity.class)); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | private void initHotSearch() { |
| | | if (hotSearchs != null && hotSearchs.size() > 0) { |
| | | int count = (int) (hotSearchs.size() * Math.random()); |
| | | if (count > hotSearchs.size() - 1) { |
| | | count = hotSearchs.size() - 1; |
| | | } |
| | | tv_go_search.setText(hotSearchs.get(count)); |
| | | } |
| | | } |
| | | private void initHotSearch() { |
| | | if (hotSearchs != null && hotSearchs.size() > 0) { |
| | | int count = (int) (hotSearchs.size() * Math.random()); |
| | | if (count > hotSearchs.size() - 1) { |
| | | count = hotSearchs.size() - 1; |
| | | } |
| | | tv_go_search.setText(hotSearchs.get(count)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取热门搜索 |
| | | */ |
| | | private void getHotSearch() { |
| | | if (getActivity() == null) |
| | | return; |
| | | SharedPreferences preferences = getActivity().getSharedPreferences( |
| | | "user", Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | MGVideoAPI.getHotSearch(getActivity(), uid, |
| | | new BasicTextHttpResponseHandler() { |
| | | /** |
| | | * 获取热门搜索 |
| | | */ |
| | | private void getHotSearch() { |
| | | if (getActivity() == null) |
| | | return; |
| | | SharedPreferences preferences = getActivity().getSharedPreferences( |
| | | "user", Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | MGVideoAPI.getHotSearch(getActivity(), uid, |
| | | new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | hotSearchs = gson.fromJson(jsonObject |
| | | .getJSONObject("Data").getJSONArray("data") |
| | | .toString(), new TypeToken<List<String>>() { |
| | | }.getType()); |
| | | initHotSearch(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | hotSearchs = gson.fromJson(jsonObject |
| | | .getJSONObject("Data").getJSONArray("data") |
| | | .toString(), new TypeToken<List<String>>() { |
| | | }.getType()); |
| | | initHotSearch(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void getCategories() { |
| | | if (getActivity() == null) |
| | | return; |
| | | SharedPreferences preferences = getActivity().getSharedPreferences( |
| | | "user", Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | MGVideoAPI.getClass(getActivity(), uid, |
| | | new BasicTextHttpResponseHandler() { |
| | | private void getCategories() { |
| | | if (getActivity() == null) |
| | | return; |
| | | SharedPreferences preferences = getActivity().getSharedPreferences( |
| | | "user", Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | MGVideoAPI.getClass(getActivity(), uid, |
| | | new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoType> categories = gson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoType>>() { |
| | | }.getType()); |
| | | gv_video_category.setAdapter(new CategoryAdapter( |
| | | categories, getActivity())); |
| | | // cache.remove(getKey("getCategories")); |
| | | DiskLruCache.Editor editor = cache |
| | | .edit(getKey("getCategories")); |
| | | editor.set(0, jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString()); |
| | | editor.commit(); |
| | | } |
| | | } |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoType> categories = gson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoType>>() { |
| | | }.getType()); |
| | | gv_video_category.setAdapter(new CategoryAdapter( |
| | | categories, getActivity())); |
| | | // cache.remove(getKey("getCategories")); |
| | | DiskLruCache.Editor editor = cache |
| | | .edit(getKey("getCategories")); |
| | | editor.set(0, jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString()); |
| | | editor.commit(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | ptsv_container.onRefreshComplete(); |
| | | } |
| | | }); |
| | | } |
| | | @Override |
| | | public void onFinish() { |
| | | ptsv_container.onRefreshComplete(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | public static int getVersionNum(Context context) { |
| | | try { |
| | | PackageInfo pi = context.getPackageManager().getPackageInfo( |
| | | context.getPackageName(), 0); |
| | | return pi.versionCode; |
| | | } catch (NameNotFoundException e) { |
| | | e.printStackTrace(); |
| | | return 1; |
| | | } |
| | | } |
| | | public static int getVersionNum(Context context) { |
| | | try { |
| | | PackageInfo pi = context.getPackageManager().getPackageInfo( |
| | | context.getPackageName(), 0); |
| | | return pi.versionCode; |
| | | } catch (NameNotFoundException e) { |
| | | e.printStackTrace(); |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | private void getHotStars() { |
| | | if (getActivity() == null) |
| | | return; |
| | | SharedPreferences preferences = getActivity().getSharedPreferences( |
| | | "user", Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | MGVideoAPI.getHotStars(getActivity(), uid, |
| | | new BasicTextHttpResponseHandler() { |
| | | private void getHotStars() { |
| | | if (getActivity() == null) |
| | | return; |
| | | SharedPreferences preferences = getActivity().getSharedPreferences( |
| | | "user", Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | MGVideoAPI.getHotStars(getActivity(), uid, |
| | | new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<HotVideoType> hotStars = gson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<HotVideoType>>() { |
| | | }.getType()); |
| | | gv_hot_stars.setAdapter(new StarAdapter(hotStars)); |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<HotVideoType> hotStars = gson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<HotVideoType>>() { |
| | | }.getType()); |
| | | gv_hot_stars.setAdapter(new StarAdapter(hotStars)); |
| | | |
| | | DiskLruCache.Editor editor = cache |
| | | .edit(getKey("getHotStars")); |
| | | editor.set(0, jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString()); |
| | | editor.commit(); |
| | | } |
| | | } |
| | | DiskLruCache.Editor editor = cache |
| | | .edit(getKey("getHotStars")); |
| | | editor.set(0, jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString()); |
| | | editor.commit(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | ptsv_container.onRefreshComplete(); |
| | | } |
| | | }); |
| | | } |
| | | @Override |
| | | public void onFinish() { |
| | | ptsv_container.onRefreshComplete(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取顶部可滑动Banner中的数据 |
| | | */ |
| | | private void getHomeAd() { |
| | | SharedPreferences preferences = tv_no_network.getContext() |
| | | .getSharedPreferences("user", Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | MGVideoAPI.getDiscpverAd(tv_no_network.getContext(), uid, |
| | | new BasicTextHttpResponseHandler() { |
| | | /** |
| | | * 获取顶部可滑动Banner中的数据 |
| | | */ |
| | | private void getHomeAd() { |
| | | SharedPreferences preferences = tv_no_network.getContext() |
| | | .getSharedPreferences("user", Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | MGVideoAPI.getDiscpverAd(tv_no_network.getContext(), uid, |
| | | new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder() |
| | | .setPrettyPrinting() |
| | | .setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<Special> homeAds = gson.fromJson(jsonObject |
| | | .getJSONObject("Data").getJSONArray("data") |
| | | .toString(), |
| | | new TypeToken<List<Special>>() { |
| | | }.getType()); |
| | | vp_theme.setAdapter(new DiscoverTopAdapter(homeAds, |
| | | getActivity().getApplicationContext())); |
| | | } |
| | | } |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder() |
| | | .setPrettyPrinting() |
| | | .setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<Special> homeAds = gson.fromJson(jsonObject |
| | | .getJSONObject("Data").getJSONArray("data") |
| | | .toString(), |
| | | new TypeToken<List<Special>>() { |
| | | }.getType()); |
| | | vp_theme.setAdapter(new DiscoverTopAdapter(homeAds, |
| | | getActivity().getApplicationContext())); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | ptsv_container.onRefreshComplete(); |
| | | } |
| | | }); |
| | | } |
| | | @Override |
| | | public void onFinish() { |
| | | ptsv_container.onRefreshComplete(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | |
| | | import android.net.wifi.WifiManager; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.LoaderManager; |
| | | import android.support.v4.content.CursorLoader; |
| | | import android.support.v4.content.Loader; |
| | | |
| | | import androidx.loader.app.LoaderManager; |
| | | import androidx.loader.content.CursorLoader; |
| | | import androidx.loader.content.Loader; |
| | | |
| | | import android.telephony.TelephonyManager; |
| | | import android.view.KeyEvent; |
| | | import android.widget.RadioButton; |
| | |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mozillaonline.providers.downloads.DownloadService; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.entity.recommend.HomeClass; |
| | | import com.umeng.socialize.UMShareAPI; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.MGVideoApplication; |
| | | import com.mugua.mgvideo.db.MessageTable; |
| | |
| | | import com.mugua.mgvideo.entity.NewComment; |
| | | import com.mugua.mgvideo.service.HelpService; |
| | | import com.mugua.mgvideo.ui.BaseActivity; |
| | | import com.mugua.mgvideo.util.BeibeiConstant; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | import com.mugua.mgvideo.util.ExitDialog; |
| | | import com.mugua.mgvideo.util.LoginFirstDialog; |
| | | import com.mugua.mgvideo.widget.BadgeView; |
| | |
| | | pd = new ProgressDialog(this); |
| | | pd.setMessage("正在请求网络..."); |
| | | pd.setCanceledOnTouchOutside(false); |
| | | |
| | | HomeClass homeClass = new HomeClass(); |
| | | homeClass.setDataKey("recommend"); |
| | | homeClass.setId("1626144258979"); |
| | | homeClass.setDataType("recommend"); |
| | | mFragmentSwitchHelper = FragmentSwitchHelper.create( |
| | | R.id.fl_main_fragment_container, getSupportFragmentManager(), |
| | | new RecommendFragment(), BaiDuVideosFragment.newInstance(), new CategoryFragment(), |
| | | RecommendNewFragment.newInstance(homeClass, 0), BaiDuVideosFragment.newInstance(), new CategoryFragment(), |
| | | new ShopFragment(), new MineFragment()); |
| | | rg_nav = findViewById(R.id.rg_nav); |
| | | rg_nav.setOnCheckedChangeListener(new OnCheckedChangeListener() { |
| | |
| | | switch (checkedId) { |
| | | case R.id.rb_nav_recommend: { |
| | | mFragmentSwitchHelper |
| | | .changeFragment(RecommendFragment.class); |
| | | .changeFragment(RecommendNewFragment.class); |
| | | } |
| | | break; |
| | | case R.id.rb_nav_short_video: |
| | |
| | | "evalueate", |
| | | jsonObject.getJSONObject("Data") |
| | | .optString("evalueate")) |
| | | .putString( |
| | | "share_image_wechat", |
| | | jsonObject.getJSONObject("Data") |
| | | .getString("WXShareIcon")) |
| | | .putString( |
| | | "show_ad", |
| | | jsonObject.optJSONObject("Data") |
| | |
| | | import android.net.Uri; |
| | | import android.os.Bundle; |
| | | import android.provider.Settings; |
| | | import android.support.v4.app.LoaderManager; |
| | | import android.support.v4.content.CursorLoader; |
| | | import android.support.v4.content.Loader; |
| | | |
| | | import androidx.loader.app.LoaderManager; |
| | | import androidx.loader.content.CursorLoader; |
| | | import androidx.loader.content.Loader; |
| | | |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.widget.ImageView; |
| | |
| | | import android.widget.Toast; |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.request.RequestOptions; |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | |
| | | import com.umeng.socialize.UMShareListener; |
| | | import com.umeng.socialize.bean.SHARE_MEDIA; |
| | | import com.umeng.socialize.media.UMWeb; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.ui.PersonInfoActivity; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.db.MessageTable; |
| | | import com.mugua.mgvideo.entity.Banner; |
| | |
| | | import com.mugua.mgvideo.ui.mine.MyFavouriteActivity; |
| | | import com.mugua.mgvideo.ui.mine.SettingsActivity; |
| | | import com.mugua.mgvideo.ui.mine.WatchHistoryActivity; |
| | | import com.mugua.mgvideo.util.BeibeiConstant; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | import com.mugua.mgvideo.util.GlideCircleTransform; |
| | | import com.mugua.mgvideo.widget.BadgeView; |
| | | |
| | |
| | | } |
| | | break; |
| | | case R.id.rl_privacy: |
| | | startActivity(new Intent(getActivity(), BrowserActivity.class).putExtra("url", getString(R.string.privacy))); |
| | | startActivity(new Intent(getActivity(), BrowserActivity.class).putExtra("url", getString(R.string.privacy))); |
| | | break; |
| | | |
| | | case R.id.rl_accumulate: { |
| | |
| | | } |
| | | break; |
| | | case R.id.mine_rl_head: {// 点击头像事件,跳转到登录界面 |
| | | Intent intent = new Intent(); |
| | | if (isLogin) {// 登录后 逻辑 |
| | | // intent.setClass(getActivity(), UserInfoActivity.class); |
| | | // intent.setClass(getActivity(), PersonInfoActivity.class); |
| | | } else {// 登陆前 |
| | | Intent intent = new Intent(); |
| | | intent.setClass(getActivity(), LoginActivity.class); |
| | | startActivity(intent); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | case R.id.rl_rate: { |
| | |
| | | String name = sp_user.getString("name", "");// 用户名称 |
| | | // ImageLoader.getInstance().displayImage(qqFigureurl, |
| | | // iv_user_logo); |
| | | Glide.with(getActivity()).load(portrait) |
| | | Glide.with(getActivity()).load(portrait).apply(new RequestOptions().placeholder(R.drawable.ic_portrait_default).error(R.drawable.ic_portrait_default)) |
| | | .transform(new GlideCircleTransform(getActivity())) |
| | | .transition(withCrossFade()).into(iv_user_logo); |
| | | tv_userName.setText(name); |
| | |
| | | import android.content.pm.PackageManager.NameNotFoundException; |
| | | import android.os.Bundle; |
| | | import android.provider.Settings; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.widget.GridView; |
| | |
| | | import com.lcjian.library.util.common.StorageUtils; |
| | | import com.mugua.mgvideo.R; |
| | | import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.entity.NewsCategory; |
| | | import com.mugua.mgvideo.ui.news.NewsCategoryAdapter; |
| | |
| | | import android.content.Intent; |
| | | import android.os.Bundle; |
| | | import android.provider.Settings; |
| | | import android.support.v4.app.Fragment; |
| | | import androidx.fragment.app.Fragment; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.widget.Button; |
New file |
| | |
| | | package com.mugua.mgvideo.ui.main; |
| | | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | | import android.content.pm.PackageInfo; |
| | | import android.content.pm.PackageManager.NameNotFoundException; |
| | | import android.graphics.Color; |
| | | import android.graphics.drawable.Drawable; |
| | | import android.os.Bundle; |
| | | import android.provider.Settings; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.MotionEvent; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.view.ViewGroup; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.alibaba.android.arouter.launcher.ARouter; |
| | | 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.RetainViewFragment; |
| | | import com.lcjian.library.content.ConnectivityChangeHelper; |
| | | import com.lcjian.library.content.ConnectivityChangeHelper.OnConnectivityChangeListener; |
| | | import com.lcjian.library.util.ScreenUtils; |
| | | import com.lcjian.library.util.SystemCommon; |
| | | import com.lcjian.library.util.cache.DiskLruCache; |
| | | import com.lcjian.library.util.common.StorageUtils; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.lcjian.library.widget.RatioLayout; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.entity.HomeAd; |
| | | import com.mugua.mgvideo.entity.HomeType; |
| | | import com.mugua.mgvideo.entity.HomeTypeItem; |
| | | import com.mugua.mgvideo.entity.HomeVideo; |
| | | import com.mugua.mgvideo.entity.JumpDetail; |
| | | import com.mugua.mgvideo.entity.recommend.HomeClass; |
| | | import com.mugua.mgvideo.test.MyViewPager; |
| | | import com.mugua.mgvideo.ui.category.bean.HotStar; |
| | | import com.mugua.mgvideo.ui.recommend.RecommendNewAdapter; |
| | | import com.mugua.mgvideo.ui.recommend.RecommendTopAdapter; |
| | | import com.mugua.mgvideo.ui.recommend.SearchActivity; |
| | | import com.mugua.mgvideo.util.DimenUtils; |
| | | import com.mugua.mgvideo.util.JumpActivityUtil; |
| | | import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.viewpagerindicator.LinePageIndicator; |
| | | import com.yeshi.base.entity.ad.ExpressAdContainer; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.yeshi.base.utils.RouteConstant; |
| | | import com.yeshi.base.utils.ad.AdUtil; |
| | | import com.yeshi.base.utils.ad.CSJConstant; |
| | | import com.yeshi.base.utils.ad.ExpressAdManager; |
| | | import com.yeshi.base.utils.ad.GDTConstant; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.ui.DividerItemDecoration; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONArray; |
| | | import org.json.JSONException; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | |
| | | public class RecommendNewFragment extends RetainViewFragment implements |
| | | OnClickListener { |
| | | |
| | | private SwipeRefreshLayout rl_recommend; |
| | | |
| | | private RecyclerView rv_recommend; |
| | | |
| | | private RecommendNewAdapter mRecommendNewAdapter; |
| | | |
| | | private List mHomeTypes; |
| | | |
| | | private List<HomeAd> mHomeAds; |
| | | |
| | | private DiskLruCache cache; |
| | | |
| | | private ConnectivityChangeHelper mChangeHelper; |
| | | |
| | | private TextView tv_no_network; |
| | | |
| | | private TextView tv_notice; |
| | | |
| | | private HomeClass type; |
| | | |
| | | private int position; |
| | | |
| | | private ImageView iv_right_ad; |
| | | private ImageView iv_right_ad_close; |
| | | private LinearLayout ll_right_ad; |
| | | |
| | | private boolean isBottom = false; |
| | | |
| | | boolean isReview; |
| | | |
| | | private Context context; |
| | | |
| | | private TextView tv_go_search; |
| | | |
| | | public static Fragment newInstance(HomeClass homeClass, int position) { |
| | | RecommendNewFragment fragment = new RecommendNewFragment(); |
| | | Bundle bundle = new Bundle(); |
| | | bundle.putInt("position", position); |
| | | bundle.putSerializable("videotype", homeClass); |
| | | fragment.setArguments(bundle); |
| | | return fragment; |
| | | } |
| | | |
| | | @Override |
| | | public void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | context = getActivity().getApplicationContext(); |
| | | try { |
| | | cache = DiskLruCache.open( |
| | | new File(StorageUtils.getCacheDirectory(context) |
| | | .toString(), "http"), getVersionNum(context), |
| | | 1, 1024 * 1024); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onSaveInstanceState(Bundle outState) { |
| | | outState.putString("flash back", "show"); |
| | | super.onSaveInstanceState(outState); |
| | | } |
| | | |
| | | public static int getVersionNum(Context context) { |
| | | try { |
| | | PackageInfo pi = context.getPackageManager().getPackageInfo( |
| | | context.getPackageName(), 0); |
| | | return pi.versionCode; |
| | | } catch (NameNotFoundException e) { |
| | | e.printStackTrace(); |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int getContentResource() { |
| | | return R.layout.recommend_fragment; |
| | | } |
| | | |
| | | private String getDay(long time) { |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String date = format.format(new Date(time)); |
| | | return date; |
| | | } |
| | | |
| | | |
| | | //填充数据 |
| | | private void setAdContent() { |
| | | //没有广告,添加广告 |
| | | if (position != 0)//只有推荐才有广告 |
| | | return; |
| | | if (mRecommendNewAdapter.getAdCount() == 0) { |
| | | if (adList != null && adList.size() > 0) { |
| | | mRecommendNewAdapter.addAdToPosition(adList.get(0), 2); |
| | | } |
| | | mRecommendNewAdapter.notifyDataSetChanged(); |
| | | } |
| | | } |
| | | |
| | | private MyViewPager vp_recommend; |
| | | private LinePageIndicator indicator_recommend; |
| | | private LinearLayout ll_ad_containner; |
| | | private RatioLayout rl_recommend_top; |
| | | private boolean isLoad; |
| | | private View loading; |
| | | private View noMoreDataView; |
| | | |
| | | private void initHomeAd() { |
| | | View recommend_top = LayoutInflater.from(tv_no_network.getContext()) |
| | | .inflate(R.layout.recommend_top, null); |
| | | |
| | | rl_recommend_top = recommend_top |
| | | .findViewById(R.id.rl_recommend_top); |
| | | vp_recommend = recommend_top |
| | | .findViewById(R.id.vp_recommend); |
| | | vp_recommend.setOnTouchListener(new View.OnTouchListener() { |
| | | @Override |
| | | public boolean onTouch(View v, MotionEvent event) { |
| | | switch (event.getAction()) { |
| | | case MotionEvent.ACTION_MOVE: |
| | | rl_recommend.setEnabled(false); |
| | | break; |
| | | case MotionEvent.ACTION_UP: |
| | | case MotionEvent.ACTION_CANCEL: |
| | | rl_recommend.setEnabled(true); |
| | | break; |
| | | } |
| | | return false; |
| | | } |
| | | }); |
| | | indicator_recommend = recommend_top |
| | | .findViewById(R.id.indicator_recommend); |
| | | vp_recommend.setAdapter(new RecommendTopAdapter(null, getActivity() |
| | | .getApplicationContext())); |
| | | |
| | | indicator_recommend.setScreenWidth(DimenUtils.dip2px(getContext(), 200) - indicator_recommend.getPaddingLeft() - indicator_recommend.getPaddingRight()); |
| | | indicator_recommend.setSelectedColor(Color.parseColor("#2880BF")); |
| | | indicator_recommend.setGapWidth(DimenUtils.dip2px(getContext(), 10)); |
| | | indicator_recommend.setUnselectedColor(Color.WHITE); |
| | | mRecommendNewAdapter.setHeaderView(recommend_top); |
| | | } |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | tv_no_network = contentView.findViewById(R.id.tv_no_network); |
| | | tv_no_network.setOnClickListener(this); |
| | | // 公告 |
| | | tv_notice = contentView.findViewById(R.id.include_notice); |
| | | mChangeHelper = new ConnectivityChangeHelper(context, |
| | | new OnConnectivityChangeListener() { |
| | | @Override |
| | | public void onNetworkUnAvailable() { |
| | | if (!StringUtils.isBlank(content)) { |
| | | tv_notice.setVisibility(View.VISIBLE); |
| | | } else { |
| | | tv_notice.setVisibility(View.GONE); |
| | | } |
| | | tv_no_network.setVisibility(View.VISIBLE); |
| | | } |
| | | |
| | | @Override |
| | | public void onWiFiAvailable() { |
| | | if (!StringUtils.isBlank(content)) { |
| | | tv_notice.setVisibility(View.VISIBLE); |
| | | } else { |
| | | tv_notice.setVisibility(View.GONE); |
| | | } |
| | | tv_no_network.setVisibility(View.GONE); |
| | | } |
| | | |
| | | @Override |
| | | public void onMobileAvailable() { |
| | | if (!StringUtils.isBlank(content)) { |
| | | tv_notice.setVisibility(View.VISIBLE); |
| | | } else { |
| | | tv_notice.setVisibility(View.GONE); |
| | | } |
| | | tv_no_network.setVisibility(View.GONE); |
| | | } |
| | | }); |
| | | |
| | | int width = (int) SystemCommon.getScreenWidth(context); |
| | | |
| | | rl_recommend = contentView.findViewById(R.id.rl_recommend); |
| | | rv_recommend = contentView |
| | | .findViewById(R.id.rv_recommend); |
| | | |
| | | rv_recommend.setLayoutManager(new LinearLayoutManager(context)); |
| | | DividerItemDecoration decoration = new DividerItemDecoration(); |
| | | decoration.setSize(DimenUtils.dip2px(rv_recommend.getContext(), 0)); |
| | | rv_recommend.addItemDecoration(decoration); |
| | | |
| | | loading = LayoutInflater.from(getContext()).inflate(R.layout.item_loading, null); |
| | | loading.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); |
| | | loading.setVisibility(View.GONE); |
| | | |
| | | noMoreDataView = LayoutInflater.from(getContext()).inflate(R.layout.item_no_more_data_view, null); |
| | | noMoreDataView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); |
| | | |
| | | tv_go_search = contentView.findViewById(R.id.tv_go_search); |
| | | tv_go_search.setOnClickListener(this); |
| | | tv_go_search.setOnTouchListener(new View.OnTouchListener() { |
| | | |
| | | @Override |
| | | public boolean onTouch(View v, MotionEvent event) { |
| | | // getCompoundDrawables() 可以获取一个长度为4的数组, |
| | | // 存放drawableLeft,Right,Top,Bottom四个图片资源对象 |
| | | // index=2 表示的是 drawableRight 图片资源对象 |
| | | Drawable drawable = tv_go_search.getCompoundDrawables()[2]; |
| | | if (drawable == null) |
| | | return false; |
| | | |
| | | if (event.getAction() != MotionEvent.ACTION_UP) |
| | | return false; |
| | | |
| | | // drawable.getIntrinsicWidth() 获取drawable资源图片呈现的宽度 |
| | | if (event.getX() > tv_go_search.getWidth() |
| | | - tv_go_search.getPaddingRight() |
| | | - drawable.getIntrinsicWidth()) { |
| | | if (!StringUtils.isEmpty(tv_go_search.getText().toString())) { |
| | | ARouter.getInstance().build(RouteConstant.PATH_VIDEO_SEARCH_RESULT).withString("key", tv_go_search.getText() + "").navigation(); |
| | | } else { |
| | | Intent intent = new Intent(getActivity(), |
| | | SearchActivity.class); |
| | | intent.putExtra("value", tv_go_search.getText() |
| | | .toString()); |
| | | startActivity(intent); |
| | | } |
| | | |
| | | } else { |
| | | Intent intent = new Intent(getActivity(), |
| | | SearchActivity.class); |
| | | intent.putExtra("value", tv_go_search.getText().toString()); |
| | | startActivity(intent); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | }); |
| | | |
| | | |
| | | rv_recommend.addOnScrollListener(new RecyclerView.OnScrollListener() { |
| | | @Override |
| | | public void onScrollStateChanged(RecyclerView recyclerView, int newState) { |
| | | super.onScrollStateChanged(recyclerView, newState); |
| | | LinearLayoutManager manager = (LinearLayoutManager) recyclerView.getLayoutManager(); |
| | | int first = manager.findFirstVisibleItemPosition(); |
| | | int last = manager.findLastVisibleItemPosition(); |
| | | int total = manager.getItemCount(); |
| | | if (newState == RecyclerView.SCROLL_STATE_IDLE) { |
| | | |
| | | |
| | | if ((!isLoad) && last == total - 1) { |
| | | int nowHomeTypeCount = 0; |
| | | if (mHomeTypes != null) |
| | | for (Object object : mHomeTypes) { |
| | | if (object instanceof HomeType) { |
| | | nowHomeTypeCount++; |
| | | } |
| | | } |
| | | if (nowHomeTypeCount < homeTypeCount) { |
| | | if (mHomeTypes != null && mHomeTypes.size() > 0 && !rl_recommend.isRefreshing()) {//列表中有数据才能加载更多 |
| | | homeTypePage++; |
| | | isLoad = true; |
| | | loading.setVisibility(View.VISIBLE); |
| | | getHomeType(homeTypePage); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onScrolled(RecyclerView recyclerView, int dx, final int dy) { |
| | | super.onScrolled(recyclerView, dx, dy); |
| | | } |
| | | }); |
| | | |
| | | |
| | | rl_recommend.setClickable(false); |
| | | |
| | | iv_right_ad = contentView.findViewById(R.id.iv_right_ad); |
| | | iv_right_ad_close = contentView.findViewById(R.id.iv_right_ad_close); |
| | | ll_right_ad = contentView.findViewById(R.id.ll_right_ad); |
| | | |
| | | type = (HomeClass) getArguments().getSerializable("videotype"); |
| | | position = (Integer) getArguments().get("position"); |
| | | |
| | | mHomeTypes = new ArrayList<HomeType>(); |
| | | mHomeAds = new ArrayList<>(); |
| | | |
| | | iv_right_ad_close.setOnClickListener(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (ll_right_ad != null) { |
| | | ll_right_ad.setVisibility(View.GONE); |
| | | // MainActivity.showRecommendRightAd = false; |
| | | } |
| | | } |
| | | }); |
| | | |
| | | rl_recommend.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { |
| | | @Override |
| | | public void onRefresh() { |
| | | |
| | | //加载广告 |
| | | loadAd(); |
| | | getHomeAd(); |
| | | Log.i("mResult", "onCreate---setOnRefreshListener---loadAD1"); |
| | | } |
| | | }); |
| | | |
| | | if (mHomeTypes == null) |
| | | mHomeTypes = new ArrayList(); |
| | | mRecommendNewAdapter = new RecommendNewAdapter(getActivity(), mHomeTypes, ScreenUtils.getScreenWidth(getContext())); |
| | | rv_recommend.setAdapter(mRecommendNewAdapter); |
| | | |
| | | mRecommendNewAdapter.setFooterView(loading); |
| | | setAdContent(); |
| | | initHomeAd(); |
| | | //加载缓存数据 |
| | | // loadCacheData(); |
| | | rv_recommend.postDelayed(new Runnable() { |
| | | |
| | | @Override |
| | | public void run() { |
| | | if (getActivity() != null) { |
| | | rl_recommend.setRefreshing(true); |
| | | getHomeAd(); |
| | | Log.i("mResult", "onCreate---postDelayed---loadAD1"); |
| | | } |
| | | } |
| | | }, 500); |
| | | |
| | | //加载广告 |
| | | loadAd(); |
| | | |
| | | getNotice(); |
| | | if (position == 0) { |
| | | // getAdRecommendRight(); |
| | | } |
| | | loadCacheData(); |
| | | } |
| | | |
| | | private List<ExpressAdContainer> adList; |
| | | |
| | | private void loadAd() { |
| | | try { |
| | | ExpressAdManager recommendAdManager = new ExpressAdManager(AdUtil.AD_TYPE.csj, context); |
| | | //加载大图 |
| | | int deviceWidth = DimenUtils.getScreenWidth(getContext()); |
| | | deviceWidth = DimenUtils.px2dip(getContext(), deviceWidth); |
| | | int width = deviceWidth - 9 * 2; |
| | | int height = (int) (width * 0.8); |
| | | String pid = null; |
| | | if (recommendAdManager.getSourceType() == AdUtil.AD_TYPE.csj) { |
| | | pid = CSJConstant.RECOMMEND_BIG_IMG_AD; |
| | | height = (int) (width * 0.78); |
| | | } else if (recommendAdManager.getSourceType() == AdUtil.AD_TYPE.gdt2) { |
| | | pid = GDTConstant.PID_HOME_RECOMMEND_BIG_IMG; |
| | | } |
| | | |
| | | recommendAdManager.loadAd(width, height, pid, 1, new ExpressAdManager.IAdLoadListener() { |
| | | @Override |
| | | public void onSuccess(final List<ExpressAdContainer> adList) { |
| | | RecommendNewFragment.this.adList = new ArrayList<>(); |
| | | for (ExpressAdContainer ad : adList) { |
| | | ExpressAdManager.renderAd(getActivity(), ad, new ExpressAdManager.IAdRenderListener() { |
| | | @Override |
| | | public void onRenderSuccess(List<ExpressAdContainer> adList1) { |
| | | RecommendNewFragment.this.adList.add(adList1.get(0)); |
| | | if (RecommendNewFragment.this.adList.size() == adList.size()) { |
| | | if (mRecommendNewAdapter.getAdCount() == 0 && mHomeTypes.size() > 0) {//没有填充广告 |
| | | setAdContent(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderFail(List<ExpressAdContainer> adList) { |
| | | |
| | | } |
| | | }, new ExpressAdManager.IAdEventListener() { |
| | | @Override |
| | | public void closeAd(ExpressAdContainer ad) { |
| | | mRecommendNewAdapter.removeAd(ad); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | private void setHomeAdsData(float ratio) { |
| | | vp_recommend.setAdapter(new RecommendTopAdapter( |
| | | mHomeAds, getActivity() |
| | | .getApplicationContext())); |
| | | indicator_recommend.invalidate(); |
| | | } |
| | | |
| | | |
| | | private void loadCacheData() { |
| | | if (cache != null && position == 0) { |
| | | { |
| | | DiskLruCache.Snapshot snapshot = null; |
| | | try { |
| | | snapshot = cache.get(getKey("getHomeAdNew") + type.getId()); |
| | | if (snapshot != null) { |
| | | List<HomeAd> adList = new ArrayList<>(); |
| | | String str = snapshot.getString(0); |
| | | try { |
| | | JSONObject jsonObject = new JSONObject(str); |
| | | String bannerRate = jsonObject.optString("bannerSizeRate"); |
| | | JSONArray array = jsonObject.optJSONArray("data"); |
| | | HomeAd ad; |
| | | for (int i = 0; i < array.length(); i++) { |
| | | ad = new HomeAd(); |
| | | ad.setId(array.optJSONObject(i).optString("Id")); |
| | | ad.setPicture(array.optJSONObject(i).optString( |
| | | "Picture")); |
| | | ad.setTitle(array.optJSONObject(i).optString( |
| | | "Title")); |
| | | ad.setClazz(array.optJSONObject(i).optString( |
| | | "Clazz")); |
| | | ad.setParams(array.optJSONObject(i).optString( |
| | | "Params")); |
| | | ad.setLinkType(Integer |
| | | .parseInt(array.optJSONObject(i) |
| | | .optString("LinkType"))); |
| | | VideoInfo videoInfo = new VideoInfo(); |
| | | videoInfo |
| | | .setId(array.optJSONObject(i) |
| | | .optJSONObject("Video") |
| | | .optString("Id")); |
| | | videoInfo.setShare(array.optJSONObject(i) |
| | | .optJSONObject("Video") |
| | | .optString("Share")); |
| | | videoInfo.setThirdType(array.optJSONObject(i) |
| | | .optJSONObject("Video") |
| | | .optString("ThirdType")); |
| | | ad.setVideo(videoInfo); |
| | | adList.add(ad); |
| | | |
| | | } |
| | | if (adList != null && adList.size() > 0) { |
| | | mHomeAds.clear(); |
| | | mHomeAds.addAll(adList); |
| | | setHomeAdsData(StringUtils.isBlank(bannerRate) ? 0.4375f : new BigDecimal(bannerRate).floatValue()); |
| | | } |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if (snapshot != null) { |
| | | snapshot.close(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | DiskLruCache.Snapshot snapshot = null; |
| | | try { |
| | | snapshot = cache.get(getKey("getHomeType") + type.getId()); |
| | | if (snapshot != null) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE).create(); |
| | | List<HomeType> homeTypes = gson.fromJson( |
| | | snapshot.getString(0), |
| | | new TypeToken<List<HomeType>>() { |
| | | }.getType()); |
| | | mHomeTypes.clear(); |
| | | if (homeTypes != null) { |
| | | mHomeTypes.addAll(homeTypes); |
| | | // mRecommendNewAdapter.notifyDataSetChanged(); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if (snapshot != null) { |
| | | snapshot.close(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | // private void getAdRecommendRight() { |
| | | // MGVideoAPI.getAdRecommendRight(context, new BasicTextHttpResponseHandler() { |
| | | // @Override |
| | | // public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | // if (jsonObject.getBoolean("IsPost")) { |
| | | // if (position == 0) { |
| | | // String img = jsonObject.optJSONObject("Data").optString("img"); |
| | | // String mstatus = jsonObject.optJSONObject("Data").optString("mstatus"); |
| | | // final String linkType = jsonObject.optJSONObject("Data").optString("linkType"); |
| | | // final String webLink = jsonObject.optJSONObject("Data").optString("webLink"); |
| | | // final String downloadLink = jsonObject.optJSONObject("Data").optString("downloadLink"); |
| | | // Glide.with(context).load(img).into(iv_right_ad); |
| | | // if (mstatus.equalsIgnoreCase("0")) { |
| | | // ll_right_ad.setVisibility(View.GONE); |
| | | // } else { |
| | | // if (MainActivity.showRecommendRightAd) |
| | | // ll_right_ad.setVisibility(View.VISIBLE); |
| | | // } |
| | | // |
| | | // |
| | | // iv_right_ad.setOnClickListener(new OnClickListener() { |
| | | // @Override |
| | | // public void onClick(View v) { |
| | | // if (linkType.equalsIgnoreCase("0")) { |
| | | // Intent intent = new Intent(context, BrowserActivity.class); |
| | | // intent.putExtra("url", webLink); |
| | | // startActivity(intent); |
| | | // } else { |
| | | // try { |
| | | // Intent intent = new Intent(context, |
| | | // DownLoadFileService.class); |
| | | // context.stopService(intent); |
| | | // } catch (Exception e) { |
| | | // } |
| | | // try { |
| | | // Bundle bundle = new Bundle(); |
| | | // bundle.putString("downloadurl", |
| | | // downloadLink); |
| | | // Intent intent = new Intent(context, |
| | | // DownLoadFileService.class); |
| | | // intent.putExtras(bundle); |
| | | // context.startService(intent); |
| | | // } catch (Exception e) { |
| | | // } |
| | | // } |
| | | // } |
| | | // }); |
| | | // } else { |
| | | // ll_right_ad.setVisibility(View.GONE); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onFailure(int statusCode, Header[] headers, String responseString, Throwable |
| | | // throwable) { |
| | | // super.onFailure(statusCode, headers, responseString, throwable); |
| | | // } |
| | | // }); |
| | | // } |
| | | |
| | | private String getKey(String method) { |
| | | return new Md5FileNameGenerator().generate(method); |
| | | } |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | indicator_recommend.setViewPager(vp_recommend); |
| | | mChangeHelper.registerReceiver(); |
| | | MobclickAgent.onPageStart("主页面—推荐"); |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | mChangeHelper.unregisterReceiver(); |
| | | MobclickAgent.onPageEnd("主页面—推荐"); |
| | | } |
| | | |
| | | private String content; |
| | | |
| | | private void getNotice() { |
| | | SharedPreferences preferences = context.getSharedPreferences( |
| | | "user", Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | MGVideoAPI.getNotice(context, uid, |
| | | new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | JSONObject obj = jsonObject.optJSONObject("Data"); |
| | | content = obj.optString("Content"); |
| | | JSONObject jumpDetailJson = obj.optJSONObject("jumpDetail"); |
| | | JumpDetail jumpDetail = null; |
| | | if (jumpDetailJson != null) { |
| | | jumpDetail = new Gson().fromJson(jumpDetailJson.toString(), JumpDetail.class); |
| | | } |
| | | JSONObject paramsJson = obj.optJSONObject("Params"); |
| | | com.alibaba.fastjson.JSONObject params = null; |
| | | if (paramsJson != null) |
| | | params = com.alibaba.fastjson.JSONObject.parseObject(paramsJson.toString()); |
| | | |
| | | |
| | | final JumpDetail fJumpDetail = jumpDetail; |
| | | final com.alibaba.fastjson.JSONObject fParams = params; |
| | | |
| | | // 0-不显示 |
| | | // 1-显示 |
| | | final String url = obj.optString("Url"); |
| | | if (position > 0)//只有第一页才显示通知 |
| | | content = null; |
| | | if (!StringUtils.isBlank(content)) { |
| | | tv_notice.setVisibility(View.VISIBLE); |
| | | tv_notice.setText(content); |
| | | if (!StringUtils.isBlank(url)) { |
| | | tv_notice |
| | | .setOnClickListener(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | JumpActivityUtil.jumpPage(getActivity(), fJumpDetail, fParams); |
| | | } |
| | | }); |
| | | } |
| | | } else { |
| | | tv_notice.setVisibility(View.GONE); |
| | | } |
| | | |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void getHomeAd() { |
| | | SharedPreferences preferences = context.getSharedPreferences( |
| | | "user", Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | MGVideoAPI.getHomeAd(context, uid, type.getId(), type.getDataKey(), |
| | | new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder() |
| | | .setPrettyPrinting() |
| | | .setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | JSONObject data = jsonObject |
| | | .getJSONObject("Data"); |
| | | List<HomeAd> homeAds = gson.fromJson(data.getJSONArray("data") |
| | | .toString(), new TypeToken<List<HomeAd>>() { |
| | | }.getType()); |
| | | //获取banner比例 |
| | | String bannerSizeRate = data.optString("bannerSizeRate"); |
| | | if (!StringUtils.isEmpty(bannerSizeRate)) { |
| | | rl_recommend_top.setRatio(new BigDecimal(bannerSizeRate).floatValue()); |
| | | } |
| | | if (homeAds != null) { |
| | | mHomeAds.clear(); |
| | | mHomeAds.addAll(homeAds); |
| | | } |
| | | |
| | | setHomeAdsData(new BigDecimal(bannerSizeRate).floatValue()); |
| | | |
| | | |
| | | if (position == 0) { |
| | | DiskLruCache.Editor editor = cache |
| | | .edit(getKey("getHomeAdNew") + type.getId()); |
| | | editor.set(0, jsonObject.getJSONObject("Data").toString()); |
| | | editor.commit(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | homeTypePage = 1; |
| | | getHomeType(homeTypePage); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取影片整体信息 |
| | | */ |
| | | |
| | | private int homeTypePage; |
| | | private int homeTypeCount; |
| | | |
| | | private void getHomeType(int page) { |
| | | SharedPreferences preferences = context.getSharedPreferences( |
| | | "user", Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | MGVideoAPI.getHomeType(context, uid, type.getId(), type.getDataKey(), page, 4, |
| | | new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setVersion(1.0).setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<HomeType> homeTypes = new ArrayList<HomeType>(); |
| | | JSONArray array = jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data"); |
| | | homeTypeCount = jsonObject.getJSONObject("Data").optInt("count"); |
| | | for (int i = 0; i < array.length(); i++) { |
| | | HomeType type = new HomeType(); |
| | | JSONObject obj = array.optJSONObject(i); |
| | | type.setColumns(obj.optInt("Columns")); |
| | | type.setId(obj.optString("Id")); |
| | | type.setName(obj.optString("Name")); |
| | | type.setHasMore(obj.optString("HasMore")); |
| | | type.setActivity(obj.optString("Activity")); |
| | | type.setParams(obj.optString("Params")); |
| | | type.setIcon(obj.optString("Icon")); |
| | | type.setNeedAd(obj.optBoolean("NeedAd", false)); |
| | | type.setRefreshPosition(obj.optInt("RefreshPosition", 0)); |
| | | type.setMoreTag(obj.optString("MoreTag")); |
| | | type.setCount(obj.optInt("Count")); |
| | | type.setNumber(obj.optInt("Number")); |
| | | type.setCurrentPage(1); |
| | | |
| | | |
| | | if (obj.optJSONObject("Ad") != null) |
| | | type.setAd(gson.fromJson(obj.optJSONObject("Ad").toString(), HomeType.HomeTypeAd.class)); |
| | | |
| | | JSONArray homeArray = obj |
| | | .optJSONArray("HomeVideoList"); |
| | | List<HomeVideo> homeList = new ArrayList<HomeVideo>(); |
| | | if (homeArray != null && homeArray.length() > 0) { |
| | | for (int j = 0; j < homeArray.length(); j++) { |
| | | |
| | | homeList.add(gson.fromJson(homeArray |
| | | .optJSONObject(j).toString(), |
| | | HomeVideo.class)); |
| | | } |
| | | } |
| | | |
| | | |
| | | type.setHomeVideoList(homeList); |
| | | JSONArray itemArray = obj |
| | | .optJSONArray("ItemTypeList"); |
| | | List<HomeTypeItem> itemList = new ArrayList<HomeTypeItem>(); |
| | | if (itemArray != null && itemArray.length() > 0) { |
| | | for (int k = 0; k < itemArray.length(); k++) { |
| | | if (itemArray.optJSONObject(k) != null) { |
| | | itemList.add(gson.fromJson( |
| | | itemArray.optJSONObject(k) |
| | | .toString(), |
| | | HomeTypeItem.class)); |
| | | } |
| | | } |
| | | } |
| | | type.setItemTypeList(itemList); |
| | | if (!type.getName().equalsIgnoreCase("美女")) |
| | | homeTypes.add(type); |
| | | } |
| | | |
| | | //清除老数据 |
| | | if (page == 1) { |
| | | mHomeTypes.clear(); |
| | | mRecommendNewAdapter.removeAllAd(); |
| | | } |
| | | mHomeTypes.addAll(homeTypes); |
| | | //填充数据 |
| | | setAdContent(); |
| | | if (position == 0 && page == 1) { |
| | | DiskLruCache.Editor editor = cache |
| | | .edit(getKey("getHomeType") + type.getId()); |
| | | editor.set(0, jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString()); |
| | | editor.commit(); |
| | | } |
| | | //刷新 |
| | | if (page == 1) { |
| | | mRecommendNewAdapter.setFooterView(loading); |
| | | } |
| | | |
| | | if (mHomeTypes.size() >= homeTypeCount) { |
| | | mRecommendNewAdapter.removeFooterView(); |
| | | } |
| | | mRecommendNewAdapter.notifyDataSetChanged(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | isLoad = false; |
| | | rl_recommend.setRefreshing(false); |
| | | loading.setVisibility(View.GONE); |
| | | try { |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, |
| | | byte[] responseBytes, Throwable throwable) { |
| | | super.onFailure(statusCode, headers, responseBytes, |
| | | throwable); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | switch (v.getId()) { |
| | | case R.id.tv_no_network: { |
| | | Intent intent = new Intent(Settings.ACTION_SETTINGS); |
| | | startActivity(intent); |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onDestroy() { |
| | | super.onDestroy(); |
| | | } |
| | | |
| | | private List<HomeVideo> adList1 = new ArrayList<>(); |
| | | |
| | | |
| | | List<HotStar> hotStars = new ArrayList<>(); |
| | | |
| | | private void getHotStars() { |
| | | SharedPreferences preferences = context.getSharedPreferences( |
| | | "user", Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | MGVideoAPI.getRecommendStars(context, uid, |
| | | new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | hotStars.clear(); |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<HotStar> hotStarList = gson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<HotStar>>() { |
| | | }.getType()); |
| | | hotStars.addAll(hotStarList); |
| | | |
| | | //插入明星列表 |
| | | if (hotStars != null && hotStars.size() > 0) { |
| | | HomeType homeType = new HomeType(); |
| | | homeType.setName("明星合辑"); |
| | | homeType.setColumns(4); |
| | | homeType.setHotStars(hotStars); |
| | | homeType.setActivity(""); |
| | | homeType.setBeizhu(""); |
| | | homeType.setParams(""); |
| | | homeType.setHasMore("true"); |
| | | homeType.setId("9998"); |
| | | mHomeTypes.add(homeType); |
| | | mRecommendNewAdapter.notifyDataSetChanged(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, |
| | | byte[] responseBytes, Throwable throwable) { |
| | | super.onFailure(statusCode, headers, responseBytes, throwable); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | |
| | | import android.content.pm.PackageManager.NameNotFoundException; |
| | | import android.os.Bundle; |
| | | import android.provider.Settings; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | |
| | | import com.lcjian.library.util.cache.DiskLruCache; |
| | | import com.lcjian.library.util.common.StorageUtils; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.entity.GoodsInfo; |
| | | import com.mugua.mgvideo.ui.discover.GoodsAdapter; |
| | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.ListFragment; |
| | | import androidx.fragment.app.ListFragment; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.widget.TextView; |
| | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.entity.AccumulateRule; |
| | |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.entity.AccumulateUseRule; |
| | |
| | | import com.tencent.smtt.sdk.WebViewClient; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.mugua.mgvideo.ui.BaseActivity; |
| | | import com.mugua.mgvideo.ui.media.VideoDetailActivity; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | import com.mugua.mgvideo.util.browser.MGJavaInterface; |
| | | import com.mugua.mgvideo.util.x5.X5WebView; |
| | | |
| | |
| | | import com.lcjian.library.util.common.DateUtils; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.entity.CommentReply; |
| | | import com.mugua.mgvideo.ui.media.VideoDetailActivity; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | import com.mugua.mgvideo.util.GlideCircleTransform; |
| | | |
| | | import de.greenrobot.event.EventBus; |
| | |
| | | import com.lcjian.library.DeviceUuidFactory; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.ui.BaseActivity; |
| | | |
| | |
| | | |
| | | import com.mugua.mgvideo.R; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.mugua.mgvideo.util.BeibeiConstant; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | |
| | | public class HelpAndTicklingActivity extends Activity implements |
| | | OnClickListener { |
| | |
| | | |
| | | import android.content.Context; |
| | | import android.database.Cursor; |
| | | import android.support.v4.widget.CursorAdapter; |
| | | import androidx.cursoradapter.widget.CursorAdapter; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.os.Bundle; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.widget.Button; |
| | |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mugua.mgvideo.R; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.entity.GoodsFavourite; |
| | | import com.mugua.mgvideo.entity.GoodsInfo; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.mugua.mgvideo.ui.BaseActivity; |
| | | import com.mugua.mgvideo.ui.common.ListVideoAdapter; |
| | | import com.mugua.mgvideo.ui.discover.GoodsFavouriteAdapter; |
| | |
| | | import com.mugua.mgvideo.entity.SDCardEntity; |
| | | import com.mugua.mgvideo.ui.BaseActivity; |
| | | import com.mugua.mgvideo.ui.main.MineFragment; |
| | | import com.mugua.mgvideo.util.BeibeiConstant; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | import com.mugua.mgvideo.util.SDCardUtil; |
| | | import com.mugua.mgvideo.widget.BadgeView; |
| | | import com.ysh.wpc.appupdate.AppUpdate; |
| | |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.ui.BaseActivity; |
| | |
| | | import android.content.SharedPreferences; |
| | | import android.database.Cursor; |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.LoaderManager; |
| | | import android.support.v4.content.CursorLoader; |
| | | import android.support.v4.content.Loader; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import androidx.loader.app.LoaderManager; |
| | | import androidx.loader.content.CursorLoader; |
| | | import androidx.loader.content.Loader; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import android.util.Log; |
| | | import android.view.Gravity; |
| | | import android.view.View; |
| | |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mugua.mgvideo.R; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.db.MessageTable; |
| | | import com.mugua.mgvideo.entity.CommentReply; |
| | |
| | | import android.content.Intent; |
| | | import android.os.Bundle; |
| | | import android.provider.Settings; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.FragmentActivity; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentActivity; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.widget.Button; |
| | |
| | | import android.content.SharedPreferences; |
| | | import android.content.pm.ActivityInfo; |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.FragmentActivity; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import androidx.fragment.app.FragmentActivity; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.widget.ListView; |
| | |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.lcjian.library.util.RefreshLayout; |
| | | import com.mugua.mgvideo.R; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.entity.News; |
| | | |
| | |
| | | import android.net.Uri; |
| | | import android.os.Bundle; |
| | | import android.os.Environment; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.ListFragment; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.ListFragment; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.widget.Button; |
| | |
| | | import com.mugua.mgvideo.R; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.mugua.mgvideo.db.DownloadTable; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.mugua.mgvideo.ui.BaseActivity; |
| | | import com.mugua.mgvideo.ui.media.VideoEpisodeFragment3; |
| | | import com.mugua.mgvideo.ui.recent.DownLoadAdapter.IGetDeleteCallback; |
| | | import com.mugua.mgvideo.ui.recent.DownLoadAdapter.IGetSelectStatus; |
| | | import com.yeshi.video.ui.VideoEpisodeFragment3; |
| | | |
| | | public class DownLoadActivity extends BaseActivity implements OnClickListener, |
| | | IGetDeleteCallback, IGetSelectStatus { |
| | |
| | | import android.content.Intent; |
| | | import android.content.res.Resources; |
| | | import android.database.Cursor; |
| | | import android.support.v4.widget.CursorAdapter; |
| | | import androidx.cursoradapter.widget.CursorAdapter; |
| | | import android.text.TextUtils; |
| | | import android.text.format.Formatter; |
| | | import android.view.LayoutInflater; |
| | |
| | | import com.nostra13.universalimageloader.core.assist.ImageScaleType; |
| | | import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer; |
| | | import com.mugua.mgvideo.db.DownloadTable; |
| | | import com.mugua.mgvideo.entity.VideoDetailInfo; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.mugua.mgvideo.ui.media.VideoDetailActivity; |
| | | import com.yeshi.base.entity.video.VideoDetailInfo; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | import com.mugua.mgvideo.util.DownloadUtils; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | |
| | | import com.nostra13.universalimageloader.core.assist.ImageScaleType; |
| | | import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer; |
| | | import com.mugua.mgvideo.db.DownloadTable; |
| | | import com.mugua.mgvideo.entity.VideoDetailInfo; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.mugua.mgvideo.ui.media.VideoDetailActivity; |
| | | import com.yeshi.base.entity.video.VideoDetailInfo; |
| | | import com.yeshi.base.entity.video.VideoDetailInfo; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | import com.mugua.mgvideo.util.DownloadUtils; |
| | | |
| | | import java.text.DateFormat; |
| | |
| | | |
| | | import android.content.Context; |
| | | import android.database.Cursor; |
| | | import android.support.v4.content.AsyncTaskLoader; |
| | | import androidx.loader.content.AsyncTaskLoader; |
| | | |
| | | import com.mozillaonline.providers.DownloadManager; |
| | | import com.mozillaonline.providers.downloads.Downloads; |
| | |
| | | import android.net.Uri; |
| | | import android.os.Bundle; |
| | | import android.os.Environment; |
| | | import android.support.v4.app.Fragment; |
| | | import androidx.fragment.app.Fragment; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | |
| | | import com.mozillaonline.providers.DownloadManager; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.db.DownloadTable; |
| | | import com.mugua.mgvideo.entity.VideoDetailInfo; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.mugua.mgvideo.ui.media.VideoDetailActivity; |
| | | import com.yeshi.base.entity.video.VideoDetailInfo; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | |
| | | public class MOfflineCacheFragment extends Fragment implements |
| | | OnItemClickListener { |
| | |
| | | import android.net.Uri; |
| | | import android.os.Bundle; |
| | | import android.os.Environment; |
| | | import android.support.v4.app.ListFragment; |
| | | import androidx.fragment.app.ListFragment; |
| | | import android.view.View; |
| | | import android.widget.ListView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.mozillaonline.providers.DownloadManager; |
| | | import com.mugua.mgvideo.db.DownloadTable; |
| | | import com.mugua.mgvideo.entity.VideoDetailInfo; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.mugua.mgvideo.ui.media.VideoDetailActivity; |
| | | import com.yeshi.base.entity.video.VideoDetailInfo; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | |
| | | public class OfflineCacheFragment extends ListFragment { |
| | | |
| | |
| | | import android.database.Cursor; |
| | | import android.net.Uri; |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.LoaderManager; |
| | | import android.support.v4.content.Loader; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.loader.app.LoaderManager; |
| | | import androidx.loader.content.Loader; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.database.Cursor; |
| | | import android.support.v4.widget.CursorAdapter; |
| | | import android.text.TextUtils; |
| | | import android.text.TextUtils.TruncateAt; |
| | | import android.view.LayoutInflater; |
| | |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.db.DownloadTable; |
| | | import com.mugua.mgvideo.db.WatchHistoryTable; |
| | | import com.mugua.mgvideo.entity.VideoDetailInfo; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.mugua.mgvideo.ui.media.VideoDetailActivity; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | import com.yeshi.base.entity.video.VideoDetailInfo; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Formatter; |
| | |
| | | import java.util.Locale; |
| | | import java.util.Map; |
| | | |
| | | import androidx.cursoradapter.widget.CursorAdapter; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | | public class WatchHistoryAdapter extends CursorAdapter { |
| | |
| | | import android.content.Intent; |
| | | import android.database.Cursor; |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.LoaderManager; |
| | | import android.support.v4.content.CursorLoader; |
| | | import android.support.v4.content.Loader; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.loader.app.LoaderManager; |
| | | import androidx.loader.content.CursorLoader; |
| | | import androidx.loader.content.Loader; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | |
| | | import com.mugua.mgvideo.MGVideoApplication; |
| | | import com.mugua.mgvideo.entity.HomeType; |
| | | import com.mugua.mgvideo.entity.HomeVideo; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.mugua.mgvideo.entity.VideoType; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.yeshi.base.entity.video.VideoType; |
| | | import com.mugua.mgvideo.service.DownLoadFileService; |
| | | import com.mugua.mgvideo.ui.category.StarDetailActivity; |
| | | import com.mugua.mgvideo.ui.category.StarsActivity; |
| | | import com.mugua.mgvideo.ui.category.bean.HotStar; |
| | | import com.mugua.mgvideo.ui.common.VideosLiveActivity; |
| | | import com.mugua.mgvideo.ui.media.VideoDetailActivity; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | import com.mugua.mgvideo.util.AdPromptDialog; |
| | | import com.mugua.mgvideo.util.BeibeiConstant; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | import com.mugua.mgvideo.util.GlideCircleTransform; |
| | | import com.mugua.mgvideo.util.downutil.ApkUtil; |
| | | import com.yeshi.base.utils.downutil.ApkUtil; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | |
| | | |
| | | private void setView_star(View view, List<HotStar> list, final HomeType type) |
| | | throws IndexOutOfBoundsException { |
| | | if(list==null||list.size()==0) |
| | | return; |
| | | LinearLayout ll_star = (LinearLayout) view.findViewById(R.id.ll_star); |
| | | ImageView iv_pic = (ImageView) view.findViewById(R.id.item_star_iv); |
| | | TextView tv_name = (TextView) view.findViewById(R.id.item_star_tv); |
| | |
| | | } |
| | | if (info != null) { |
| | | final VideoInfo myInfo = info.getVideo(); |
| | | ll_video_show1.setOnClickListener(new OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(final View v) { |
| | | if (myInfo.getAdInfo() == null) { |
| | | myClick(myInfo, type, v); |
| | | } else { |
| | | if (BeibeiConstant.ISHUAWEI) { |
| | | DialogInterface.OnClickListener dialogOnclicListener = new DialogInterface.OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(DialogInterface dialog, |
| | | int which) { |
| | | switch (which) { |
| | | case Dialog.BUTTON_POSITIVE: |
| | | myInfo.getAdInfo().onClicked(v); |
| | | dialog.dismiss(); |
| | | break; |
| | | case Dialog.BUTTON_NEGATIVE: |
| | | dialog.dismiss(); |
| | | break; |
| | | } |
| | | } |
| | | }; |
| | | AdPromptDialog.Builder builder = new AdPromptDialog.Builder( |
| | | v.getContext()); // 先得到构造器 |
| | | builder.setPositiveButton("确认", dialogOnclicListener); |
| | | builder.setNegativeButton("取消", dialogOnclicListener); |
| | | builder.create().show(); |
| | | } else { |
| | | myInfo.getAdInfo().onClicked(v); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | if (info1 != null) { |
| | | final VideoInfo myInfo1 = info1.getVideo(); |
New file |
| | |
| | | package com.mugua.mgvideo.ui.recommend; |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Intent; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.view.ViewGroup; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.RelativeLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.request.RequestOptions; |
| | | import com.bumptech.glide.request.target.DrawableImageViewTarget; |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.lcjian.library.util.common.DimenUtils; |
| | | import com.lcjian.library.widget.RatioLayout; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.entity.HomeType; |
| | | import com.mugua.mgvideo.entity.HomeVideo; |
| | | import com.mugua.mgvideo.entity.recommend.RecommendContent; |
| | | import com.mugua.mgvideo.entity.video.holder.FooterViewHolder; |
| | | import com.mugua.mgvideo.entity.video.holder.HeaderViewHolder; |
| | | import com.mugua.mgvideo.ui.category.StarsActivity; |
| | | import com.mugua.mgvideo.ui.common.VideosLiveActivity; |
| | | import com.mugua.mgvideo.ui.video.VideoRecommendAdapter; |
| | | import com.mugua.mgvideo.util.JumpActivityUtil; |
| | | import com.yeshi.base.entity.ad.ExpressAdContainer; |
| | | import com.yeshi.base.entity.video.VideoType; |
| | | import com.yeshi.base.utils.ad.ExpressAdManager; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.ysh.wpc.appupdate.util.StringUtils; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONArray; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.TreeSet; |
| | | |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | | public class RecommendNewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
| | | |
| | | private final static String TAG = "RecommendNewAdapter"; |
| | | |
| | | private Activity mContext; |
| | | List<Object> contentList; |
| | | private LayoutInflater inflater; |
| | | private TreeSet mADSet = new TreeSet(); |
| | | |
| | | public final int TYPE_HEADER = 10001; |
| | | public final int TYPE_FOOTER = 10002; |
| | | |
| | | private Gson gson = new GsonBuilder().setVersion(1.0).setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | |
| | | private View headerView; |
| | | private View footerView; |
| | | |
| | | public void setHeaderView(View view) { |
| | | this.headerView = view; |
| | | } |
| | | |
| | | public void setFooterView(View view) { |
| | | this.footerView = view; |
| | | if (contentList != null) { |
| | | notifyItemChanged(contentList.size() + (headerView != null ? 1 : 0)); |
| | | } |
| | | } |
| | | |
| | | public void removeFooterView() { |
| | | if (footerView != null) { |
| | | notifyItemRemoved(contentList.size() + (headerView != null ? 1 : 0)); |
| | | this.footerView = null; |
| | | } |
| | | } |
| | | |
| | | |
| | | public RecommendNewAdapter(Activity context, List contentList, int recyclerViewWidth) { |
| | | this.mContext = context; |
| | | this.contentList = contentList; |
| | | this.recyclerViewWidth = recyclerViewWidth; |
| | | inflater = LayoutInflater.from(mContext); |
| | | } |
| | | |
| | | /** |
| | | * 添加数据项 |
| | | * |
| | | * @param item |
| | | */ |
| | | public void addNormalItem(HomeType item) { |
| | | contentList.add(item); |
| | | } |
| | | |
| | | /** |
| | | * 获取广告数量 |
| | | * |
| | | * @return |
| | | */ |
| | | public int getAdCount() { |
| | | return mADSet.size(); |
| | | } |
| | | |
| | | /** |
| | | * 添加广告到指定位置 |
| | | * |
| | | * @param ad |
| | | * @param position |
| | | */ |
| | | public void addAdToPosition(ExpressAdContainer ad, int position) { |
| | | if (position >= 0 && position < contentList.size()) { |
| | | contentList.add(position, ad); |
| | | mADSet.add(position); |
| | | } |
| | | Log.i(TAG, "addAdToPosition"); |
| | | } |
| | | |
| | | public void addAd(ExpressAdContainer ad) { |
| | | contentList.add(ad); |
| | | Log.i(TAG, "addAd"); |
| | | } |
| | | |
| | | public void removeAd(ExpressAdContainer ad) { |
| | | if (mADSet != null) |
| | | for (Iterator<Integer> its = mADSet.iterator(); its.hasNext(); ) { |
| | | int p = its.next(); |
| | | if (p < contentList.size() && contentList.get(p) == ad) { |
| | | mADSet.remove(p); |
| | | contentList.remove(p); |
| | | notifyDataSetChanged(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | public void removeAllAd() { |
| | | if (contentList != null) |
| | | for (int i = 0; i < contentList.size(); i++) { |
| | | if (contentList.get(i) instanceof ExpressAdContainer) { |
| | | contentList.remove(i); |
| | | i--; |
| | | } |
| | | } |
| | | mADSet.clear(); |
| | | } |
| | | |
| | | @Override |
| | | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
| | | switch (viewType) { |
| | | case TYPE_HEADER: |
| | | return new HeaderViewHolder(headerView); |
| | | case TYPE_FOOTER: |
| | | return new FooterViewHolder(footerView); |
| | | case RecommendContent.TYPE_HOMETYPE: |
| | | return new HomeTypeHolder(inflater.inflate(R.layout.item_recommend_home_type, null, false), new RecyclerView.RecycledViewPool()); |
| | | case RecommendContent.TYPE_AD: |
| | | return new AdHolder(inflater.inflate(R.layout.item_recommend_home_type_ad, parent, false)); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | private int recyclerViewWidth = -1; |
| | | |
| | | @Override |
| | | public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) { |
| | | if (viewHolder instanceof HeaderViewHolder) |
| | | return; |
| | | if (viewHolder instanceof FooterViewHolder) |
| | | return; |
| | | int p = i; |
| | | if (headerView != null) |
| | | p--; |
| | | |
| | | |
| | | if (viewHolder instanceof HomeTypeHolder) { |
| | | final HomeType homeType = (HomeType) contentList.get(p); |
| | | |
| | | |
| | | final HomeTypeHolder holder = (HomeTypeHolder) viewHolder; |
| | | |
| | | if (homeType == null) { |
| | | holder.view.setVisibility(View.GONE); |
| | | return; |
| | | } |
| | | if (homeType.getVideoInfoList() == null) { |
| | | homeType.setVideoInfoList(new ArrayList<>()); |
| | | } |
| | | |
| | | |
| | | ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); |
| | | holder.view.setLayoutParams(params); |
| | | //是否为广告 |
| | | if (homeType.getAd() != null) { |
| | | holder.fl_ad.setVisibility(View.VISIBLE); |
| | | holder.fl_content.setVisibility(View.GONE); |
| | | holder.rl_ad.setRatio(homeType.getAd().getPictureRate().floatValue()); |
| | | try { |
| | | Glide.with(mContext).load(homeType.getAd().getPicture()).transition(withCrossFade()) |
| | | .apply(new RequestOptions().placeholder(R.drawable.shape_default_cover).error(R.drawable.shape_default_cover)) |
| | | .into(new DrawableImageViewTarget(holder.iv_ad, true)); |
| | | } catch (IllegalArgumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | holder.view.setOnClickListener(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | |
| | | JumpActivityUtil.jumpPage(mContext, homeType.getAd().getJumpDetail(), homeType.getAd().getParams() != null ? JSONObject.parseObject(homeType.getAd().getParams().replace( |
| | | "\\" + "\"", "\"")) : null); |
| | | } |
| | | }); |
| | | |
| | | return; |
| | | } |
| | | |
| | | holder.fl_ad.setVisibility(View.GONE); |
| | | holder.fl_content.setVisibility(View.VISIBLE); |
| | | |
| | | |
| | | homeType.getVideoInfoList().clear(); |
| | | int bigPictureIndex = -1; |
| | | if (homeType.getHomeVideoList() != null) |
| | | for (int j = 0; j < homeType.getHomeVideoList().size(); j++) { |
| | | if (homeType.getHomeVideoList().get(j).isBigPicture()) |
| | | bigPictureIndex = j; |
| | | homeType.getVideoInfoList().add(homeType.getHomeVideoList().get(j).getVideo()); |
| | | } |
| | | |
| | | //隐藏 |
| | | if (homeType.getVideoInfoList() != null && homeType.getVideoInfoList().size() > 0) |
| | | holder.view.setVisibility(View.VISIBLE); |
| | | else |
| | | holder.view.setVisibility(View.GONE); |
| | | |
| | | VideoRecommendAdapter adapter = null; |
| | | |
| | | holder.rv_content.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); |
| | | |
| | | |
| | | int contentWidth = recyclerViewWidth - DimenUtils.dip2px(mContext, 16); |
| | | if (homeType.getColumns() > 3) {//第一排为小视频 |
| | | adapter = new VideoRecommendAdapter(mContext, mContext, homeType.getVideoInfoList(), homeType.isNeedAd(), Integer.MAX_VALUE, "recommend", homeType.getName(), null, new ExpressAdManager.IAdShowListener() { |
| | | @Override |
| | | public void show() { |
| | | holder.rv_content.scrollToPosition(0); |
| | | } |
| | | }); |
| | | adapter.initRecyclerViewDisplayWidthRow1(holder.rv_content, contentWidth); |
| | | } else { |
| | | adapter = new VideoRecommendAdapter(mContext, mContext, homeType.getVideoInfoList(), homeType.isNeedAd(), homeType.getColumns(), "recommend", homeType.getName(), null); |
| | | if (homeType.getColumns() == 2) |
| | | adapter.initRecyclerViewDisplayWidthColumn2(holder.rv_content, contentWidth, bigPictureIndex); |
| | | else if (homeType.getColumns() == 3) |
| | | adapter.initRecyclerViewDisplayWidthColumn3(holder.rv_content, contentWidth); |
| | | else |
| | | adapter.initRecyclerViewDisplayWidthRow1(holder.rv_content, contentWidth); |
| | | } |
| | | |
| | | |
| | | if (homeType.getVideoInfoList() != null && homeType.getVideoInfoList().size() > 0) { |
| | | holder.rv_content.setAdapter(adapter); |
| | | } |
| | | |
| | | |
| | | holder.tv_category_name.setText(homeType.getName()); |
| | | |
| | | |
| | | //更多 |
| | | if (Boolean.parseBoolean(homeType.getHasMore())) { |
| | | holder.tv_more.setVisibility(View.VISIBLE); |
| | | if (!StringUtils.isNullOrEmpty(homeType.getMoreTag())) { |
| | | holder.tv_more.setText(homeType.getMoreTag()); |
| | | } else { |
| | | holder.tv_more.setText("更多" + homeType.getName()); |
| | | } |
| | | } else { |
| | | holder.tv_more.setVisibility(View.GONE); |
| | | } |
| | | |
| | | int refreshP = homeType.getRefreshPosition(); |
| | | //右上角且有更多选项 |
| | | if (refreshP == 1 && Boolean.parseBoolean(homeType.getHasMore())) { |
| | | refreshP = 2;//移动至下方 |
| | | } |
| | | |
| | | //不足一页不显示刷新 |
| | | if (homeType.getCount() <= homeType.getNumber()) { |
| | | refreshP = 0; |
| | | } |
| | | |
| | | |
| | | switch (refreshP) { |
| | | case 0: |
| | | holder.tv_refresh.setVisibility(View.GONE); |
| | | holder.tv_tag_refresh.setVisibility(View.GONE); |
| | | break; |
| | | |
| | | case 1: |
| | | holder.tv_refresh.setVisibility(View.GONE); |
| | | holder.tv_tag_refresh.setVisibility(View.VISIBLE); |
| | | break; |
| | | |
| | | case 2: |
| | | holder.tv_refresh.setVisibility(View.VISIBLE); |
| | | holder.tv_tag_refresh.setVisibility(View.GONE); |
| | | break; |
| | | } |
| | | //刷新的动作 |
| | | OnClickListener refreshListener = new OnClickListener() { |
| | | |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | MGVideoAPI.getHomeVideoList(mContext, homeType.getId(), homeType.getCurrentPage() + 1, new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, org.json.JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | org.json.JSONObject data = jsonObject.optJSONObject("Data"); |
| | | int page = data.optInt("page"); |
| | | homeType.setCurrentPage(page); |
| | | //解析数据 |
| | | homeType.getHomeVideoList().clear(); |
| | | //解析HomeVideo数据 |
| | | int count = data.optInt("count"); |
| | | homeType.setCount(count); |
| | | |
| | | JSONArray homeArray = data |
| | | .optJSONArray("list"); |
| | | List<HomeVideo> homeList = new ArrayList<>(); |
| | | if (homeArray != null && homeArray.length() > 0) { |
| | | for (int j = 0; j < homeArray.length(); j++) { |
| | | homeList.add(gson.fromJson(homeArray |
| | | .optJSONObject(j).toString(), |
| | | HomeVideo.class)); |
| | | } |
| | | } |
| | | |
| | | homeType.getHomeVideoList().clear(); |
| | | homeType.getHomeVideoList().addAll(homeList); |
| | | //改变当前选项 |
| | | notifyItemChanged(i); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | }; |
| | | holder.tv_refresh.setOnClickListener(refreshListener); |
| | | holder.tv_tag_refresh.setOnClickListener(refreshListener); |
| | | |
| | | |
| | | holder.tv_more |
| | | .setOnClickListener(new OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | Intent intent = null; |
| | | if (homeType.getId().equalsIgnoreCase("1111")) { |
| | | intent = new Intent(v.getContext(), |
| | | VideosLiveActivity.class); |
| | | intent.putExtra("home_type", homeType.getId()); |
| | | intent.putExtra("title", homeType.getName()); |
| | | v.getContext().startActivity(intent); |
| | | } else if (homeType.getId().equalsIgnoreCase("9998")) { |
| | | intent = new Intent(v.getContext(), StarsActivity.class); |
| | | v.getContext().startActivity(intent); |
| | | } else { |
| | | Gson gson = new GsonBuilder() |
| | | .setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | VideoType type = gson.fromJson(homeType.getParams().replace( |
| | | "\\" + "\"", "\""), VideoType.class); |
| | | try { |
| | | intent = new Intent(v.getContext(), Class.forName(homeType.getActivity())); |
| | | intent.putExtra("video_type", type); |
| | | intent.putExtra("type_name", type.getName()); |
| | | intent.putExtra("isPush", false); |
| | | v.getContext().startActivity(intent); |
| | | } catch (ClassNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | |
| | | |
| | | } else if (viewHolder instanceof AdHolder) { |
| | | final AdHolder holder = (AdHolder) viewHolder; |
| | | holder.fl_ad.removeAllViews(); |
| | | final ExpressAdContainer ad = (ExpressAdContainer) contentList.get(p); |
| | | if (ad != null) { |
| | | holder.ll_container.setVisibility(View.VISIBLE); |
| | | ExpressAdManager.fillAd(ad, holder.fl_ad); |
| | | } else { |
| | | holder.ll_container.setVisibility(View.GONE); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int getItemCount() { |
| | | int count = this.contentList.size(); |
| | | if (headerView != null) |
| | | count++; |
| | | if (footerView != null) |
| | | count++; |
| | | return count; |
| | | } |
| | | |
| | | /** |
| | | * banner第一栏,视频内容第二栏,广告第三栏和最后一栏 |
| | | * |
| | | * @param position |
| | | * @return |
| | | */ |
| | | //获取类型 |
| | | @Override |
| | | public int getItemViewType(int position) { |
| | | if (position == 0) { |
| | | if (headerView != null) |
| | | return TYPE_HEADER; |
| | | } |
| | | |
| | | if (headerView != null) |
| | | position--; |
| | | |
| | | if (position >= contentList.size()) |
| | | return TYPE_FOOTER; |
| | | |
| | | if (contentList.get(position) instanceof HomeType) |
| | | return RecommendContent.TYPE_HOMETYPE; |
| | | else |
| | | return RecommendContent.TYPE_AD; |
| | | |
| | | } |
| | | |
| | | class HomeTypeHolder extends RecyclerView.ViewHolder { |
| | | LinearLayout fl_content; |
| | | FrameLayout fl_ad; |
| | | RatioLayout rl_ad; |
| | | TextView tv_category_name; |
| | | ImageView iv_ad; |
| | | TextView tv_more; |
| | | RecyclerView rv_content; |
| | | RelativeLayout rl_title_item; |
| | | TextView tv_refresh; |
| | | TextView tv_tag_refresh; |
| | | View view; |
| | | |
| | | public HomeTypeHolder(View convertView, RecyclerView.RecycledViewPool recycledViewPool) { |
| | | super(convertView); |
| | | this.view = convertView; |
| | | rl_title_item = convertView |
| | | .findViewById(R.id.rl_title_item); |
| | | |
| | | fl_content = convertView |
| | | .findViewById(R.id.fl_content); |
| | | |
| | | fl_ad = convertView |
| | | .findViewById(R.id.fl_ad); |
| | | |
| | | iv_ad = convertView |
| | | .findViewById(R.id.iv_ad); |
| | | |
| | | rl_ad = convertView |
| | | .findViewById(R.id.rl_ad); |
| | | |
| | | |
| | | tv_category_name = convertView |
| | | .findViewById(R.id.tv_category_name); |
| | | tv_more = convertView |
| | | .findViewById(R.id.tv_more); |
| | | rv_content = convertView |
| | | .findViewById(R.id.rv_content); |
| | | |
| | | tv_refresh = convertView |
| | | .findViewById(R.id.tv_refresh); |
| | | |
| | | tv_tag_refresh = convertView |
| | | .findViewById(R.id.tv_tag_refresh); |
| | | |
| | | |
| | | if (recycledViewPool != null) |
| | | rv_content.setRecycledViewPool(recycledViewPool); |
| | | } |
| | | } |
| | | |
| | | class AdHolder extends RecyclerView.ViewHolder { |
| | | |
| | | FrameLayout fl_ad; |
| | | RelativeLayout rl_title_item; |
| | | LinearLayout ll_container; |
| | | |
| | | |
| | | public AdHolder(View view) { |
| | | super(view); |
| | | ll_container = view.findViewById(R.id.ll_container); |
| | | fl_ad = view.findViewById(R.id.fl_ad); |
| | | rl_title_item = view.findViewById(R.id.rl_title_item); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.support.v4.view.PagerAdapter; |
| | | import androidx.viewpager.widget.PagerAdapter; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.view.ViewGroup; |
| | |
| | | import android.widget.ImageView.ScaleType; |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.mugua.mgvideo.MGVideoApplication; |
| | | import com.nostra13.universalimageloader.core.DisplayImageOptions; |
| | | import com.nostra13.universalimageloader.core.ImageLoader; |
| | | import com.nostra13.universalimageloader.core.assist.ImageScaleType; |
| | | import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; |
| | | import com.mugua.mgvideo.entity.HomeAd; |
| | | import com.mugua.mgvideo.ui.media.VideoDetailActivity; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | v.getContext().startActivity(intent); |
| | | MGVideoApplication.application.startActivity(intent); |
| | | } |
| | | }); |
| | | Glide.with(context).load(mHomeAds.get(position).getPicture()) |
| | |
| | | import android.widget.GridView; |
| | | import android.widget.TextView; |
| | | |
| | | import com.alibaba.android.arouter.facade.Postcard; |
| | | import com.alibaba.android.arouter.launcher.ARouter; |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | |
| | | import com.qq.e.ads.nativ.NativeExpressADView; |
| | | import com.qq.e.comm.util.AdError; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.ad.GDTConstant; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.mugua.mgvideo.ui.BaseActivity; |
| | | import com.mugua.mgvideo.ui.common.GridVideoAdapter1; |
| | | import com.mugua.mgvideo.ui.media.VideoDetailActivity; |
| | | import com.mugua.mgvideo.util.BeibeiConstant; |
| | | import com.yeshi.ec.search.ui.SearchResultActivity; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | import com.yeshi.base.utils.RouteConstant; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | @Override |
| | | public void onItemClick(AdapterView<?> parent, View view, |
| | | int position, long id) { |
| | | Intent intent = new Intent(SearchActivity.this, |
| | | SearchResultActivity.class); |
| | | intent.putExtra("key", parent.getItemAtPosition(position) |
| | | .toString()); |
| | | startActivity(intent); |
| | | |
| | | startActivity(new Intent(getApplicationContext(), SearchResultActivity.class).putExtra("key", parent.getItemAtPosition(position) |
| | | .toString())); |
| | | |
| | | } |
| | | }); |
| | | |
| | |
| | | @Override |
| | | public void onItemClick(AdapterView<?> parent, View view, |
| | | int position, long id) { |
| | | Intent intent = new Intent(SearchActivity.this, |
| | | SearchResultActivity.class); |
| | | intent.putExtra("key", |
| | | (String) parent.getItemAtPosition(position)); |
| | | startActivity(intent); |
| | | startActivity(new Intent(getApplicationContext(), SearchResultActivity.class).putExtra("key", (String) parent.getItemAtPosition(position))); |
| | | } |
| | | }); |
| | | gv_history_search.setOnItemClickListener(new OnItemClickListener() { |
| | |
| | | @Override |
| | | public void onItemClick(AdapterView<?> parent, View view, |
| | | int position, long id) { |
| | | Intent intent = new Intent(SearchActivity.this, |
| | | SearchResultActivity.class); |
| | | intent.putExtra("key", |
| | | (String) parent.getItemAtPosition(position)); |
| | | startActivity(intent); |
| | | startActivity(new Intent(getApplicationContext(), SearchResultActivity.class).putExtra("key", (String) parent.getItemAtPosition(position))); |
| | | } |
| | | }); |
| | | gv_video_guess_like.setOnItemClickListener(new OnItemClickListener() { |
| | |
| | | case R.id.tv_search_cancel: { |
| | | if (tv_search_cancel.getText().toString() |
| | | .equals(getResources().getString(R.string.search))) { |
| | | Intent intent = new Intent(this, SearchResultActivity.class); |
| | | Intent intent = new Intent(getApplicationContext(), SearchResultActivity.class); |
| | | if (StringUtils.isEmpty(et_search_key.getEditableText() |
| | | .toString())) { |
| | | intent.putExtra("key", value); |
| | |
| | | private void loadAD() { |
| | | // |
| | | NativeExpressAD nativeExpressAD = new NativeExpressAD(this, new ADSize(ADSize.FULL_WIDTH, ADSize.AUTO_HEIGHT), |
| | | BeibeiConstant.GDT_APP_ID, BeibeiConstant.GDT_HOME_AND_PLAY_BIG_PICTURE, new NativeExpressAD.NativeExpressADListener() { |
| | | GDTConstant.GDT_APP_ID, GDTConstant.GDT_HOME_AND_PLAY_BIG_PICTURE, new NativeExpressAD.NativeExpressADListener() { |
| | | @Override |
| | | public void onADLoaded(final List<NativeExpressADView> list) { |
| | | tv_back.post(new Runnable() { |
| | |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Intent; |
| | | import android.support.v4.view.PagerAdapter; |
| | | import androidx.viewpager.widget.PagerAdapter; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
New file |
| | |
| | | package com.mugua.mgvideo.ui.video; |
| | | |
| | | |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | |
| | | public interface IVideoClickListener { |
| | | |
| | | public void onClick(VideoInfo video); |
| | | } |
New file |
| | |
| | | package com.mugua.mgvideo.ui.video; |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.graphics.Canvas; |
| | | import android.graphics.Rect; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.ImageView; |
| | | |
| | | import com.lcjian.library.util.common.DimenUtils; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.entity.recommend.holder.RecommendVideoAdHolder; |
| | | import com.mugua.mgvideo.entity.video.VideoContent; |
| | | import com.mugua.mgvideo.entity.video.holder.FooterViewHolder; |
| | | import com.mugua.mgvideo.entity.video.holder.HeaderViewHolder; |
| | | import com.mugua.mgvideo.entity.video.holder.VideoHolder; |
| | | import com.mugua.mgvideo.util.video.VideoUIUtil; |
| | | import com.qq.e.ads.nativ.NativeUnifiedADData; |
| | | import com.qq.e.ads.nativ.widget.NativeAdContainer; |
| | | import com.yeshi.base.entity.ad.ExpressAdContainer; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.yeshi.base.utils.ad.ExpressAdManager; |
| | | import com.yeshi.base.utils.ad.GDTConstant; |
| | | import com.yeshi.base.utils.ad.GDTNativeADUnifiedManager; |
| | | import com.yeshi.video.ui.VideoDetailActivity; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import androidx.recyclerview.widget.GridLayoutManager; |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | |
| | | public class VideoRecommendAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
| | | private Context mContext; |
| | | private List<VideoContent> contentList; |
| | | private LayoutInflater inflater; |
| | | private IVideoClickListener itemClickListener; |
| | | private ExpressAdManager.IAdShowListener showListener; |
| | | private Activity activity; |
| | | private int columns; |
| | | |
| | | String TAG = "VideoColumn2Adapter"; |
| | | |
| | | private View headerView; |
| | | |
| | | private View footerView; |
| | | |
| | | //如果是横向的才设置宽度 |
| | | private Integer itemWidth;//条目宽度 |
| | | |
| | | private final static int TYPE_HEADER = 10001; |
| | | private final static int TYPE_FOOTER = 10002; |
| | | |
| | | private String from; |
| | | private String tag; |
| | | |
| | | //大图所在位置 |
| | | private int firstBigPosition = -1; |
| | | |
| | | //内容区的宽度 |
| | | private int contentWidth; |
| | | |
| | | |
| | | public void setHeaderView(View headerView) { |
| | | this.headerView = headerView; |
| | | } |
| | | |
| | | public void setFooterView(View footerView) { |
| | | this.footerView = footerView; |
| | | } |
| | | |
| | | RecyclerView.ItemDecoration itemDecorationRow = new RecyclerView.ItemDecoration() { |
| | | @Override |
| | | public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { |
| | | super.onDraw(c, parent, state); |
| | | } |
| | | |
| | | @Override |
| | | public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { |
| | | super.onDrawOver(c, parent, state); |
| | | } |
| | | |
| | | @Override |
| | | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { |
| | | super.getItemOffsets(outRect, view, parent, state); |
| | | int index = parent.getChildAdapterPosition(view); |
| | | int total = parent.getAdapter().getItemCount(); |
| | | int minWidth = DimenUtils.dipToPixels(3, view.getContext()); |
| | | if (index == 0) { |
| | | outRect.left = 0; //第一列左边贴边 |
| | | outRect.right = minWidth; |
| | | } else if (index == total - 1) { |
| | | outRect.right = minWidth; |
| | | outRect.left = minWidth; |
| | | } else { |
| | | outRect.right = minWidth * 2; //第一列左边贴边 |
| | | outRect.left = minWidth; |
| | | } |
| | | } |
| | | }; |
| | | RecyclerView.ItemDecoration itemDecoration2 = new RecyclerView.ItemDecoration() { |
| | | @Override |
| | | public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { |
| | | super.onDraw(c, parent, state); |
| | | } |
| | | |
| | | @Override |
| | | public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { |
| | | super.onDrawOver(c, parent, state); |
| | | } |
| | | |
| | | @Override |
| | | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { |
| | | super.getItemOffsets(outRect, view, parent, state); |
| | | int index = parent.getChildAdapterPosition(view); |
| | | int total = parent.getAdapter().getItemCount(); |
| | | int minWidth = DimenUtils.dipToPixels(3, view.getContext()); |
| | | |
| | | GridLayoutManager.SpanSizeLookup lookup = ((GridLayoutManager) parent.getLayoutManager()).getSpanSizeLookup(); |
| | | int size = lookup.getSpanSize(index); |
| | | if (size == 6) { |
| | | outRect.left = 0; |
| | | outRect.right = 0; |
| | | } else { |
| | | //计算距离上一个大图的距离 |
| | | int lastBigIndex = 0; |
| | | for (int i = index - 1; i >= 0; i--) { |
| | | if (lookup.getSpanSize(i) == 6) { |
| | | lastBigIndex = i + 1; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | if ((index - lastBigIndex) % 2 == 0) { |
| | | outRect.left = 0; //第一列左边贴边 |
| | | outRect.right = minWidth; |
| | | } else { |
| | | outRect.right = 0; //第一列左边贴边 |
| | | outRect.left = minWidth; |
| | | } |
| | | } |
| | | |
| | | int totalSize = 0; |
| | | for (int i = 0; i < index; i++) { |
| | | totalSize += lookup.getSpanSize(i); |
| | | } |
| | | |
| | | if (totalSize >= 6) { |
| | | outRect.top = DimenUtils.dipToPixels(8, view.getContext()); |
| | | } else |
| | | outRect.top = 0; |
| | | |
| | | //是否是最后一行 |
| | | boolean lastRow = false; |
| | | //最后一个 |
| | | if (index == total - 1) { |
| | | lastRow = true; |
| | | } else { |
| | | if (index == total - 2) { |
| | | totalSize += lookup.getSpanSize(index); |
| | | if (totalSize % 6 != 0) { |
| | | lastRow = true; |
| | | } |
| | | } |
| | | } |
| | | if (lastRow) |
| | | outRect.bottom = DimenUtils.dipToPixels(8, view.getContext()); |
| | | else |
| | | outRect.bottom = 0; |
| | | |
| | | Log.i(TAG, String.format(" %s: left:%s right:%s top:%s bottom:%s", tag, outRect.left, outRect.right, outRect.top, outRect.bottom)); |
| | | } |
| | | }; |
| | | |
| | | |
| | | RecyclerView.ItemDecoration itemDecoration3 = new RecyclerView.ItemDecoration() { |
| | | @Override |
| | | public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { |
| | | super.onDraw(c, parent, state); |
| | | } |
| | | |
| | | @Override |
| | | public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { |
| | | super.onDrawOver(c, parent, state); |
| | | } |
| | | |
| | | @Override |
| | | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { |
| | | super.getItemOffsets(outRect, view, parent, state); |
| | | int index = parent.getChildAdapterPosition(view); |
| | | int total = parent.getAdapter().getItemCount(); |
| | | int minWidth = DimenUtils.dipToPixels(2, view.getContext()); |
| | | if (index % 3 == 0) { |
| | | outRect.left = 0; //第一列左边贴边 |
| | | outRect.right = minWidth * 2; |
| | | } else if (index % 3 == 1) { |
| | | outRect.right = minWidth * 1; |
| | | outRect.left = minWidth * 1; |
| | | } else { |
| | | outRect.right = 0; //第一列左边贴边 |
| | | outRect.left = minWidth * 2; |
| | | } |
| | | |
| | | if (index - 2 > 0) { |
| | | outRect.top = DimenUtils.dipToPixels(8, view.getContext()); |
| | | } else |
| | | outRect.top = 0; |
| | | |
| | | if (total > 3) { |
| | | if (index < ((total - 1) / 3) * 3) |
| | | outRect.bottom = DimenUtils.dipToPixels(0, view.getContext()); |
| | | else |
| | | outRect.bottom = 0; |
| | | } else |
| | | outRect.bottom = 0; |
| | | } |
| | | }; |
| | | |
| | | |
| | | /** |
| | | * 计算每行宽度 |
| | | * |
| | | * @param position |
| | | * @return |
| | | */ |
| | | public int getItemWidth(int position, String typeName) { |
| | | if (columns > 3) |
| | | return (int) (contentWidth / 2.5); |
| | | //计算间隔 |
| | | int spanSize = getItemSpanSize(position); |
| | | |
| | | |
| | | int width = 0; |
| | | switch (spanSize) { |
| | | case 6: |
| | | width = contentWidth; |
| | | break; |
| | | case 2: {//一行3列 |
| | | int padding = DimenUtils.dipToPixels(2 * 3, mContext); |
| | | width = (contentWidth - padding * 2) / 3; |
| | | break; |
| | | } |
| | | case 3: {//一行2列 |
| | | int padding = DimenUtils.dipToPixels(3 * 2, mContext); |
| | | width = (contentWidth - padding) / 2; |
| | | break; |
| | | } |
| | | } |
| | | if (contentWidth < 0) |
| | | Log.i(TAG, String.format("%s column:%s position:%s spansize:%s width:%s", typeName, columns + "", position + "", spanSize, width)); |
| | | return width; |
| | | } |
| | | |
| | | |
| | | private int getItemSpanSize(int position) { |
| | | int type = getItemViewType(position); |
| | | if (type == TYPE_FOOTER || type == TYPE_HEADER) { |
| | | return 6; |
| | | } else { |
| | | if (getContentPosition(position) == firstBigPosition) { |
| | | return 6; |
| | | } else |
| | | return 6 / columns; |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 初始化内容区宽度 |
| | | * |
| | | * @param rv |
| | | */ |
| | | private void initContentWidth(RecyclerView rv, int viewWidth) { |
| | | |
| | | int padding = 0; |
| | | padding += rv.getPaddingLeft(); |
| | | padding += rv.getPaddingRight(); |
| | | contentWidth = viewWidth - padding; |
| | | } |
| | | |
| | | /** |
| | | * 设置列表的显示样式(一行2列) |
| | | * |
| | | * @param rv |
| | | * @param firstBigPosition 第一个数据是否以大图显示 |
| | | */ |
| | | public void initRecyclerViewDisplayWidthColumn2(RecyclerView rv, int viewWidth, int firstBigPosition) { |
| | | initContentWidth(rv, viewWidth); |
| | | this.firstBigPosition = firstBigPosition; |
| | | if (rv.getLayoutManager() == null || !(rv.getLayoutManager() instanceof GridLayoutManager)) { |
| | | RecyclerView.LayoutManager layoutManager = new GridLayoutManager(rv.getContext(), 6); |
| | | rv.setLayoutManager(layoutManager); |
| | | } |
| | | //统一分为2列 |
| | | ((GridLayoutManager) rv.getLayoutManager()).setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { |
| | | @Override |
| | | public int getSpanSize(int position) { |
| | | return getItemSpanSize(position); |
| | | } |
| | | }); |
| | | for (int i = 0; i < rv.getItemDecorationCount(); i++) { |
| | | rv.removeItemDecoration(rv.getItemDecorationAt(i)); |
| | | i--; |
| | | } |
| | | |
| | | int count = rv.getItemDecorationCount(); |
| | | for (int i = 0; i < count; i++) { |
| | | rv.removeItemDecorationAt(i); |
| | | } |
| | | rv.addItemDecoration(itemDecoration2); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置列表的显示样式(一行2列) |
| | | * |
| | | * @param rv |
| | | */ |
| | | public void initRecyclerViewDisplayWidthColumn2(RecyclerView rv, int viewWidth) { |
| | | initRecyclerViewDisplayWidthColumn2(rv, viewWidth, -1); |
| | | } |
| | | |
| | | |
| | | public void initRecyclerViewDisplayWidthRow1(RecyclerView rv, int viewWidth) { |
| | | initContentWidth(rv, viewWidth); |
| | | // if (rv.getLayoutManager() == null || !(rv.getLayoutManager() instanceof LinearLayoutManager)) { |
| | | LinearLayoutManager layoutManager = new LinearLayoutManager(rv.getContext()); |
| | | layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); |
| | | rv.setLayoutManager(layoutManager); |
| | | // } else { |
| | | // ((LinearLayoutManager) rv.getLayoutManager()).setOrientation(LinearLayoutManager.HORIZONTAL); |
| | | // } |
| | | for (int i = 0; i < rv.getItemDecorationCount(); i++) { |
| | | rv.removeItemDecoration(rv.getItemDecorationAt(i)); |
| | | i--; |
| | | } |
| | | int padding = 0; |
| | | padding += rv.getPaddingLeft(); |
| | | padding += rv.getPaddingRight(); |
| | | itemWidth = contentWidth; |
| | | rv.addItemDecoration(itemDecorationRow); |
| | | } |
| | | |
| | | /** |
| | | * 设置列表的显示样式(一行3列) |
| | | * |
| | | * @param rv |
| | | */ |
| | | public void initRecyclerViewDisplayWidthColumn3(RecyclerView rv, int viewWidth) { |
| | | initContentWidth(rv, viewWidth); |
| | | if (rv.getLayoutManager() == null || !(rv.getLayoutManager() instanceof GridLayoutManager)) { |
| | | RecyclerView.LayoutManager layoutManager = new GridLayoutManager(rv.getContext(), 6); |
| | | rv.setLayoutManager(layoutManager); |
| | | } |
| | | //统一分为2列 |
| | | ((GridLayoutManager) rv.getLayoutManager()).setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { |
| | | @Override |
| | | public int getSpanSize(int position) { |
| | | return getItemSpanSize(position); |
| | | } |
| | | }); |
| | | for (int i = 0; i < rv.getItemDecorationCount(); i++) { |
| | | rv.removeItemDecoration(rv.getItemDecorationAt(i)); |
| | | i--; |
| | | } |
| | | rv.addItemDecoration(itemDecoration3); |
| | | } |
| | | |
| | | public VideoRecommendAdapter() { |
| | | |
| | | } |
| | | |
| | | public void refreshAd() { |
| | | if (contentList == null || contentList.size() == 0) |
| | | return; |
| | | |
| | | GDTNativeADUnifiedManager.loadAD(columns == 3 ? GDTConstant.PID_2_VIDEO_LIST_SMALL_AD_COLUMN3 : GDTConstant.PID_2_VIDEO_LIST_SMALL_AD_COLUMN2, 1, mContext, new GDTNativeADUnifiedManager.IAdLoadListener() { |
| | | @Override |
| | | public void onSuccess(List<NativeUnifiedADData> adList) { |
| | | if (adList != null && adList.size() > 0) |
| | | VideoRecommendAdapter.this.addAdToPosition(0, new ExpressAdContainer(adList.get(0))); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | public void setVideoList(List<VideoInfo> videoList) { |
| | | if (contentList == null) |
| | | contentList = new ArrayList<>(); |
| | | contentList.clear(); |
| | | for (VideoInfo video : videoList) { |
| | | contentList.add(VideoContent.createVideoContent(video)); |
| | | } |
| | | } |
| | | |
| | | public void setColumns(int columns) { |
| | | this.columns = columns; |
| | | } |
| | | |
| | | public VideoRecommendAdapter(final Activity activity, Context context, List<VideoInfo> videoList, boolean needAd, int columns, String from, String tag, IVideoClickListener itemClickListener) { |
| | | this(activity, context, videoList, needAd, columns, from, tag, itemClickListener, null); |
| | | } |
| | | |
| | | |
| | | public VideoRecommendAdapter(final Activity activity, Context context, List<VideoInfo> videoList, boolean needAd, int columns, String from, String tag, IVideoClickListener itemClickListener, ExpressAdManager.IAdShowListener showListener) { |
| | | if (activity == null || context == null) |
| | | return; |
| | | this.mContext = context; |
| | | this.activity = activity; |
| | | this.contentList = new ArrayList<>(); |
| | | inflater = LayoutInflater.from(context); |
| | | this.itemClickListener = itemClickListener; |
| | | this.columns = columns; |
| | | this.showListener = showListener; |
| | | this.from = from; |
| | | this.tag = tag; |
| | | |
| | | for (VideoInfo video : videoList) { |
| | | contentList.add(VideoContent.createVideoContent(video)); |
| | | } |
| | | |
| | | if (needAd) { |
| | | refreshAd(); |
| | | } |
| | | } |
| | | |
| | | // 把返回的 广告 添加到数据集里面去 |
| | | void addAdToPosition(int position, ExpressAdContainer ad) { |
| | | if (position >= 0 && position < contentList.size() && ad != null) { |
| | | contentList.add(position, VideoContent.createAdContent(ad)); |
| | | notifyDataSetChanged(); |
| | | // notifyItemInserted(position); |
| | | // notifyItemRangeChanged(0, contentList.size()); |
| | | if (showListener != null) |
| | | showListener.show(); |
| | | |
| | | Log.d(TAG, "addAdToPosition:" + VideoRecommendAdapter.this.toString()); |
| | | } |
| | | } |
| | | |
| | | // 移除 广告 的时候是一条一条移除的 |
| | | void removeADView(int position, ExpressAdContainer ad) { |
| | | if (contentList.get(position).getAd() == null) |
| | | return; |
| | | contentList.remove(position); |
| | | notifyItemRemoved(position); |
| | | notifyItemRangeChanged(0, contentList.size() - 1); |
| | | } |
| | | |
| | | @Override |
| | | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int type) { |
| | | |
| | | switch (type) { |
| | | case TYPE_HEADER: |
| | | return new HeaderViewHolder(headerView); |
| | | case TYPE_FOOTER: |
| | | return new FooterViewHolder(footerView); |
| | | case VideoContent.TYPE_AD: |
| | | return new RecommendVideoAdHolder(inflater.inflate(R.layout.item_ad_list_small, parent, false)); |
| | | case VideoContent.TYPE_VIDEO: |
| | | return new VideoHolder(inflater.inflate(R.layout.item_movie, parent, false)); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int p) { |
| | | if ((viewHolder instanceof HeaderViewHolder) || (viewHolder instanceof FooterViewHolder)) { |
| | | return; |
| | | } |
| | | |
| | | if (headerView != null) |
| | | p = p - 1; |
| | | |
| | | final VideoContent content = contentList.get(p); |
| | | |
| | | ViewGroup.LayoutParams params = viewHolder.itemView.getLayoutParams(); |
| | | // if (columns > 3) { |
| | | // if (itemWidth != null) { |
| | | // params.width = itemWidth; |
| | | // } |
| | | // } else { |
| | | params.width = getItemWidth(p,""); |
| | | // } |
| | | |
| | | if (viewHolder instanceof VideoHolder) { |
| | | VideoHolder holder = (VideoHolder) viewHolder; |
| | | final VideoInfo info = content.getVideo(); |
| | | |
| | | VideoUIUtil.setVideoListItem(mContext, holder, new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(final View v) { |
| | | //跳转到商品视频播放页 |
| | | if (itemClickListener == null) |
| | | myClick(info, v); |
| | | else |
| | | itemClickListener.onClick(info); |
| | | } |
| | | }, info, columns, getItemWidth(p, info.getName())); |
| | | } else if (viewHolder instanceof RecommendVideoAdHolder) {//广告 |
| | | final RecommendVideoAdHolder holder = (RecommendVideoAdHolder) viewHolder; |
| | | if (columns == 2) { |
| | | holder.rl_container.setRatio(0.562f); |
| | | } else if (columns == 3) { |
| | | holder.rl_container.setRatio(1.39f); |
| | | } |
| | | ExpressAdContainer ad = content.getAd(); |
| | | View v = inflater.inflate(R.layout.item_ad_list_small_gdt2, null); |
| | | ImageView iv_picture = v.findViewById(R.id.iv_picture); |
| | | NativeAdContainer nv = v.findViewById(R.id.native_ad_container); |
| | | GDTNativeADUnifiedManager.renderSinglePicture(iv_picture, holder.tv_movie_title, nv, ad.getGdt2Unfied()); |
| | | holder.fl_container.removeAllViews(); |
| | | holder.fl_container.addView(v); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int getItemCount() { |
| | | int count = 0; |
| | | if (contentList != null) |
| | | count = contentList.size(); |
| | | // if (columns < 4) |
| | | // count = count ;//% columns == 0 ? count : ((count / columns) * columns); |
| | | if (headerView != null) |
| | | count++; |
| | | if (footerView != null) |
| | | count++; |
| | | return count; |
| | | } |
| | | |
| | | @Override |
| | | public int getItemViewType(int position) { |
| | | if (columns == 0) |
| | | return -1; |
| | | |
| | | int count = contentList == null ? 0 : contentList.size(); |
| | | int contentCount = count; |
| | | |
| | | // if (columns < 4) |
| | | // contentCount = count % columns == 0 ? count : ((count / columns) * columns); |
| | | |
| | | if (position == 0) { |
| | | if (headerView != null) |
| | | return TYPE_HEADER; |
| | | else if (this.contentList.size() > 0) |
| | | return this.contentList.get(position).getType(); |
| | | else if (footerView != null) |
| | | return TYPE_FOOTER; |
| | | else |
| | | return -1; |
| | | } else if (position < (contentCount + (headerView == null ? 0 : 1))) { |
| | | if (headerView != null) |
| | | position--; |
| | | this.contentList.get(position).getType(); |
| | | } else if (footerView != null) |
| | | return TYPE_FOOTER; |
| | | else |
| | | return -1; |
| | | return this.contentList.get(position).getType(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取内容的position |
| | | * |
| | | * @param position |
| | | * @return |
| | | */ |
| | | public int getContentPosition(int position) { |
| | | if (headerView != null) |
| | | return position - 1; |
| | | else |
| | | return position; |
| | | } |
| | | |
| | | |
| | | private void myClick(VideoInfo info, final View v) { |
| | | Intent intent = new Intent(v.getContext(), VideoDetailActivity.class); |
| | | intent.putExtra("video_info", info); |
| | | intent.putExtra("from", from); |
| | | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | v.getContext().startActivity(intent); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.alibaba.baichuan.trade.biz.context.AlibcTradeResult; |
| | | import com.alibaba.baichuan.trade.biz.core.taoke.AlibcTaokeParams; |
| | | import com.mugua.mgvideo.ui.mine.BrowserActivity; |
| | | import com.mugua.mgvideo.util.downutil.ApkUtil; |
| | | import com.yeshi.base.utils.downutil.ApkUtil; |
| | | |
| | | import java.util.HashMap; |
| | | |
New file |
| | |
| | | package com.mugua.mgvideo.util; |
| | | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | |
| | | import org.json.JSONObject; |
| | | |
| | | import java.lang.reflect.Type; |
| | | import java.util.Arrays; |
| | | import java.util.HashSet; |
| | | import java.util.Set; |
| | | |
| | | public class ConfigUtil { |
| | | |
| | | public static void saveVipLink(Context context, String link) { |
| | | saveConfig("vipLink", link, context); |
| | | } |
| | | |
| | | public static String getVipLink(Context context) { |
| | | return getConfig("vipLink", context); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 网页加速域名 |
| | | * |
| | | * @param context |
| | | * @param hosts |
| | | */ |
| | | public static void saveWebSpeedUpHost(Context context, String hosts) { |
| | | saveConfig("webSpeedUpHost", hosts, context); |
| | | } |
| | | |
| | | public static Set<String> getWebSpeedUpHost(Context context) { |
| | | Set<String> set = new HashSet<>(); |
| | | String value = getConfig("webSpeedUpHost", context); |
| | | if (!StringUtils.isEmpty(value)) { |
| | | set.addAll(Arrays.asList(value.split(","))); |
| | | } |
| | | return set; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 我的页面banner |
| | | * |
| | | * @param context |
| | | * @param content |
| | | */ |
| | | public static void saveMinePageBanner(Context context, String content) { |
| | | saveConfig("minePageBanner", content, context); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 保存播放器外跳协议 |
| | | * |
| | | * @param context |
| | | * @param content |
| | | */ |
| | | public static void savePlayerJumpOutProtocolPrefix(Context context, String content) { |
| | | saveConfig("jumpAppProtocolPrefix", content, context); |
| | | } |
| | | |
| | | public static Set<String> getPlayerJumpOutProtocolPrefix(Context context) { |
| | | try { |
| | | String config = getConfig("jumpAppProtocolPrefix", context); |
| | | if (!StringUtils.isEmpty(config)) { |
| | | Type type = new TypeToken<Set<String>>() { |
| | | }.getType(); |
| | | return new Gson().fromJson(config, type); |
| | | } |
| | | } catch (Exception e) { |
| | | e.getMessage(); |
| | | } |
| | | return new HashSet<>(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存购买记录 |
| | | * |
| | | * @param context |
| | | * @param content |
| | | */ |
| | | public static void saveBuyRecordUrl(Context context, String content) { |
| | | saveConfig("buyRecordUrl", content, context); |
| | | } |
| | | |
| | | |
| | | public static String getBuyRecordUrl(Context context) { |
| | | return getConfig("buyRecordUrl", context); |
| | | } |
| | | |
| | | |
| | | private static void saveConfig(String key, String value, Context context) { |
| | | SharedPreferences.Editor editor = context.getSharedPreferences("config", Context.MODE_PRIVATE).edit(); |
| | | editor.putString(key, value); |
| | | editor.commit(); |
| | | } |
| | | |
| | | |
| | | private static String getConfig(String key, Context context) { |
| | | if (context == null) |
| | | return null; |
| | | SharedPreferences share = context.getSharedPreferences("config", Context.MODE_PRIVATE); |
| | | return share.getString(key, ""); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.mugua.mgvideo.R; |
| | | import com.qq.e.ads.cfg.VideoOption; |
| | | import com.qq.e.ads.nativ.ADSize; |
| | | import com.qq.e.ads.nativ.NativeADDataRef; |
| | | import com.qq.e.ads.nativ.NativeExpressAD; |
| | | import com.qq.e.ads.nativ.NativeExpressADView; |
| | | import com.qq.e.comm.util.AdError; |
| | | import com.yeshi.base.utils.ad.GDTConstant; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | return dialog; |
| | | } |
| | | |
| | | NativeADDataRef adDataRef; |
| | | |
| | | // 1.加载广告,先设置加载上下文环境和条件 |
| | | private void nativeAd() { |
| | | NativeExpressAD nativeExpressAD = new NativeExpressAD(context, new ADSize(ADSize.FULL_WIDTH, ADSize.AUTO_HEIGHT), |
| | | BeibeiConstant.GDT_APP_ID, BeibeiConstant.GDT_EXIT_DIALOG, new NativeExpressAD.NativeExpressADListener() { |
| | | GDTConstant.GDT_APP_ID, GDTConstant.GDT_EXIT_DIALOG, new NativeExpressAD.NativeExpressADListener() { |
| | | @Override |
| | | public void onADLoaded(final List<NativeExpressADView> list) { |
| | | fl_advertisement.post(new Runnable() { |
| | |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.loopj.android.http.SyncHttpClient; |
| | | import com.loopj.android.http.TextHttpResponseHandler; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | |
| | | public class GetDownLoadTask extends AsyncTask<String, Long, String[]> { |
| | |
| | | import com.loopj.android.http.JsonHttpResponseHandler; |
| | | import com.loopj.android.http.SyncHttpClient; |
| | | import com.loopj.android.http.TextHttpResponseHandler; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | |
| | | public class GetRealPathTask extends AsyncTask<String, Long, String[]> { |
| | |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.loopj.android.http.SyncHttpClient; |
| | | import com.loopj.android.http.TextHttpResponseHandler; |
| | | import com.mugua.mgvideo.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.mugua.mgvideo.MGVideoAPI; |
| | | |
| | | public class GetRealPathTask2 extends AsyncTask<String, Long, String[]> { |
| | |
| | | import android.graphics.BitmapShader; |
| | | import android.graphics.Canvas; |
| | | import android.graphics.Paint; |
| | | import android.support.annotation.NonNull; |
| | | import androidx.annotation.NonNull; |
| | | |
| | | import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; |
| | | import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; |
| | |
| | | import android.graphics.Canvas; |
| | | import android.graphics.Paint; |
| | | import android.graphics.RectF; |
| | | import android.support.annotation.NonNull; |
| | | import androidx.annotation.NonNull; |
| | | |
| | | import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; |
| | | import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; |
| | |
| | | import com.alibaba.baichuan.trade.biz.core.taoke.AlibcTaokeParams; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.mugua.mgvideo.entity.JumpDetail; |
| | | import com.mugua.mgvideo.util.downutil.StringUtils; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | import com.yeshi.base.utils.downutil.StringUtils; |
| | | |
| | | import org.json.JSONException; |
| | | |
| | |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.mugua.mgvideo.util.downutil.StringUtils; |
| | | import com.yeshi.base.utils.downutil.StringUtils; |
| | | |
| | | import static android.content.Context.MODE_PRIVATE; |
| | | |
| | |
| | | |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mugua.mgvideo.db.WatchHistoryTable; |
| | | import com.mugua.mgvideo.entity.VideoDetailInfo; |
| | | import com.mugua.mgvideo.entity.VideoInfo; |
| | | import com.mugua.mgvideo.entity.VideoUrl; |
| | | import com.yeshi.base.entity.video.VideoDetailInfo; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.yeshi.base.entity.video.VideoUrl; |
| | | |
| | | public class VideoPlayUrlUtil { |
| | | public static VideoUrl getVideoUrl1(VideoDetailInfo info) { |
| | |
| | | package com.mugua.mgvideo.util; |
| | | |
| | | import com.yeshi.base.entity.video.VideoType; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import com.mugua.mgvideo.entity.VideoType; |
| | | |
| | | public class VideoTypeUtil { |
| | | public static String getVideoTypeName(VideoType type) { |
| | |
| | | import com.bytedance.sdk.openadsdk.TTAdNative; |
| | | import com.bytedance.sdk.openadsdk.TTFullScreenVideoAd; |
| | | import com.mugua.mgvideo.util.DimenUtils; |
| | | import com.yeshi.base.utils.ad.CSJConstant; |
| | | import com.yeshi.base.utils.ad.TTAdManagerHolder; |
| | | |
| | | public class FullVideoAdManager { |
| | | |
| | |
| | | package com.mugua.mgvideo.util.ad; |
| | | |
| | | import android.app.Activity; |
| | | import android.support.annotation.NonNull; |
| | | import android.support.annotation.Nullable; |
| | | import androidx.annotation.NonNull; |
| | | import androidx.annotation.Nullable; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.TextView; |
| | |
| | | import com.qq.e.ads.splash.SplashAD; |
| | | import com.qq.e.ads.splash.SplashADListener; |
| | | import com.qq.e.comm.util.AdError; |
| | | import com.mugua.mgvideo.util.BeibeiConstant; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | import com.mugua.mgvideo.util.DimenUtils; |
| | | import com.mugua.mgvideo.util.downutil.StringUtils; |
| | | import com.yeshi.base.utils.ad.AdTypeEnum; |
| | | import com.yeshi.base.utils.ad.CSJConstant; |
| | | import com.yeshi.base.utils.ad.GDTConstant; |
| | | import com.yeshi.base.utils.ad.TTAdManagerHolder; |
| | | import com.yeshi.base.utils.downutil.StringUtils; |
| | | |
| | | public class SplashAdUtil { |
| | | |
| | |
| | | |
| | | String channel = ManifestDataUtil.getAppMetaData(context, "UMENG_CHANNEL"); |
| | | if (StringUtils.isNullOrEmpty(code)) |
| | | code = BeibeiConstant.GDT_SPLASH_AD_ID; |
| | | new SplashAD(context, BeibeiConstant.GDT_APP_ID, code, new SplashADListener() { |
| | | code = GDTConstant.GDT_SPLASH_AD_ID; |
| | | new SplashAD(context, GDTConstant.GDT_APP_ID, code, new SplashADListener() { |
| | | @Override |
| | | public void onADDismissed() { |
| | | splashAdListener.close(); |
| | |
| | | height = 1080; |
| | | String channel = ManifestDataUtil.getAppMetaData(context, "UMENG_CHANNEL"); |
| | | if (StringUtils.isNullOrEmpty(code)) |
| | | code = CSJConstant.CODE_SPLASH; |
| | | code = CSJConstant.SPLASH_AD; |
| | | |
| | | AdSlot adSlot = new AdSlot.Builder() |
| | | .setCodeId(code) |
| | |
| | | import android.app.Activity; |
| | | import android.content.Intent; |
| | | import android.content.pm.PackageManager; |
| | | import android.support.v4.content.ContextCompat; |
| | | import androidx.core.content.ContextCompat; |
| | | import android.webkit.JavascriptInterface; |
| | | import android.widget.ImageView; |
| | | import android.widget.TextView; |
New file |
| | |
| | | package com.mugua.mgvideo.util.browser; |
| | | |
| | | import android.content.Context; |
| | | import android.webkit.JavascriptInterface; |
| | | |
| | | import com.mugua.mgvideo.entity.vo.UserInfoVO; |
| | | import com.mugua.mgvideo.util.UserUtil; |
| | | |
| | | import org.json.JSONObject; |
| | | |
| | | public class PPJavaInterface { |
| | | private static final String TAG = "PPJavaInterface"; |
| | | private Context mContext; |
| | | private IEventListener eventListener; |
| | | |
| | | public PPJavaInterface(Context context, IEventListener eventListener) { |
| | | mContext = context; |
| | | this.eventListener = eventListener; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 跳转登录页 |
| | | */ |
| | | @JavascriptInterface |
| | | public void login() { |
| | | eventListener.onLogin(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 返回用户信息(JSON格式)。 |
| | | * code为0标识用户未登录,data的值为空; |
| | | * code为1表示用户已经登录,data为用户信息 |
| | | * 如: {"code":1,"data":{"code":"123","nickname":"昵称","isSVip":false,"isCoupon":false}} |
| | | * |
| | | * @return |
| | | */ |
| | | @JavascriptInterface |
| | | public String getUserInfo() { |
| | | try { |
| | | JSONObject root = new JSONObject(); |
| | | UserInfoVO user = null;//UserUtil.getLoginUserInfoDetail(mContext); |
| | | if (user == null) { |
| | | root.put("code", 0); |
| | | } else { |
| | | root.put("code", 1); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("code", user.getPptvCode()); |
| | | data.put("nickname", user.getNickName()); |
| | | data.put("isSVip", "false"); |
| | | data.put("isCoupon", false); |
| | | root.put("data", data); |
| | | } |
| | | return root.toString(); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 试看结束 |
| | | */ |
| | | @JavascriptInterface |
| | | public void tryPlayFinish() { |
| | | eventListener.onTryPlayFinish(); |
| | | } |
| | | |
| | | /** |
| | | * 视频播放完成 |
| | | */ |
| | | @JavascriptInterface |
| | | public void playFinish() { |
| | | eventListener.onPlayFinish(); |
| | | } |
| | | |
| | | /** |
| | | * 视频信息回调 |
| | | * |
| | | * @param name 视频名称 |
| | | * @param cid |
| | | * @param vid |
| | | */ |
| | | @JavascriptInterface |
| | | public void videoInfo(String name, String cid, String vid) { |
| | | |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public void stopPlay(String cid, String vid, int currentTime) { |
| | | |
| | | } |
| | | |
| | | |
| | | public interface IEventListener { |
| | | public void onLogin(); |
| | | |
| | | public void onTryPlayFinish(); |
| | | |
| | | public void onPlayFinish(); |
| | | |
| | | |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.mugua.mgvideo.util.ui; |
| | | |
| | | |
| | | import android.app.Activity; |
| | | import android.graphics.Color; |
| | | import android.os.Build; |
| | | import android.view.View; |
| | | import android.view.Window; |
| | | import android.view.WindowManager; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.RelativeLayout; |
| | | |
| | | import com.mugua.mgvideo.R; |
| | | |
| | | import java.lang.reflect.Field; |
| | | |
| | | public class TopStatusSettings { |
| | | /* |
| | | * 计算状态栏高度并设置 |
| | | */ |
| | | public static void setStatusView(Activity mActivity, View v_status_bar) { |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { |
| | | Window window = mActivity.getWindow(); |
| | | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
| | | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| | | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); |
| | | window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, |
| | | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) |
| | | window.setStatusBarColor(Color.WHITE); |
| | | //设置状态栏文字颜色及图标为深色 |
| | | mActivity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); |
| | | int result = 0; |
| | | int resourceId = mActivity.getResources().getIdentifier("status_bar_height", |
| | | "dimen", "android"); |
| | | if (resourceId > 0) { |
| | | result = mActivity.getResources().getDimensionPixelSize(resourceId); |
| | | } |
| | | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, |
| | | result); |
| | | v_status_bar.setLayoutParams(params); |
| | | |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| | | try { |
| | | Class decorViewClazz = Class.forName("com.android.internal.policy.DecorView"); |
| | | Field field = decorViewClazz.getDeclaredField("mSemiTransparentStatusBarColor"); |
| | | field.setAccessible(true); |
| | | field.setInt(window.getDecorView(), Color.TRANSPARENT); //改为透明 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } else { |
| | | v_status_bar.setVisibility(View.GONE); |
| | | } |
| | | } |
| | | |
| | | /* |
| | | * 计算状态栏高度并设置 |
| | | */ |
| | | public static void setStatusViewAndDeepColor(Activity mActivity) { |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
| | | Window window = mActivity.getWindow(); |
| | | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
| | | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| | | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); |
| | | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); |
| | | window.setStatusBarColor(Color.WHITE); |
| | | //设置状态栏文字颜色及图标为深色 |
| | | mActivity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); |
| | | |
| | | int result = 0; |
| | | int resourceId = mActivity.getResources().getIdentifier("status_bar_height", |
| | | "dimen", "android"); |
| | | if (resourceId > 0) { |
| | | result = mActivity.getResources().getDimensionPixelSize(resourceId); |
| | | } |
| | | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, |
| | | result); |
| | | mActivity.findViewById(R.id.v_status_bar).setLayoutParams(params); |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| | | try { |
| | | Class decorViewClazz = Class.forName("com.android.internal.policy.DecorView"); |
| | | Field field = decorViewClazz.getDeclaredField("mSemiTransparentStatusBarColor"); |
| | | field.setAccessible(true); |
| | | field.setInt(window.getDecorView(), Color.TRANSPARENT); //改为透明 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } else { |
| | | mActivity.findViewById(R.id.v_status_bar).setVisibility(View.GONE); |
| | | } |
| | | } |
| | | |
| | | |
| | | public static void setStatusViewAndDeepColor(Activity mActivity, View stateBar, View stateBar1) { |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
| | | Window window = mActivity.getWindow(); |
| | | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
| | | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| | | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); |
| | | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); |
| | | window.setStatusBarColor(Color.WHITE); |
| | | //设置状态栏文字颜色及图标为深色 |
| | | mActivity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); |
| | | |
| | | int result = 0; |
| | | int resourceId = mActivity.getResources().getIdentifier("status_bar_height", |
| | | "dimen", "android"); |
| | | if (resourceId > 0) { |
| | | result = mActivity.getResources().getDimensionPixelSize(resourceId); |
| | | } |
| | | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, |
| | | result); |
| | | stateBar.setLayoutParams(params); |
| | | if (stateBar1 != null) { |
| | | stateBar1.setLayoutParams(params); |
| | | } |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| | | try { |
| | | Class decorViewClazz = Class.forName("com.android.internal.policy.DecorView"); |
| | | Field field = decorViewClazz.getDeclaredField("mSemiTransparentStatusBarColor"); |
| | | field.setAccessible(true); |
| | | field.setInt(window.getDecorView(), Color.TRANSPARENT); //改为透明 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } else { |
| | | stateBar.setVisibility(View.GONE); |
| | | if (stateBar1 != null) { |
| | | stateBar1.setVisibility(View.GONE); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /* |
| | | * 计算状态栏高度并设置 |
| | | */ |
| | | public static void setStatusViewAndDeepColor2(Activity mActivity) { |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
| | | Window window = mActivity.getWindow(); |
| | | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
| | | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| | | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); |
| | | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); |
| | | window.setStatusBarColor(Color.TRANSPARENT); |
| | | int result = 0; |
| | | int resourceId = mActivity.getResources().getIdentifier("status_bar_height", |
| | | "dimen", "android"); |
| | | if (resourceId > 0) { |
| | | result = mActivity.getResources().getDimensionPixelSize(resourceId); |
| | | } |
| | | //设置状态栏文字颜色及图标为深色 |
| | | mActivity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); |
| | | RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, result); |
| | | mActivity.findViewById(R.id.v_status_bar).setLayoutParams(params); |
| | | try { |
| | | Class decorViewClazz = Class.forName("com.android.internal.policy.DecorView"); |
| | | Field field = decorViewClazz.getDeclaredField("mSemiTransparentStatusBarColor"); |
| | | field.setAccessible(true); |
| | | field.setInt(mActivity.getWindow().getDecorView(), Color.TRANSPARENT); //改为透明 |
| | | } catch (Exception e) { |
| | | } |
| | | } else { |
| | | mActivity.findViewById(R.id.v_status_bar).setVisibility(View.GONE); |
| | | } |
| | | } |
| | | |
| | | /* |
| | | * 计算状态栏高度并设置 |
| | | */ |
| | | public static void setStatusViewAndDeepColorNoView(Activity mActivity) { |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
| | | Window window = mActivity.getWindow(); |
| | | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
| | | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| | | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); |
| | | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); |
| | | window.setStatusBarColor(Color.WHITE); |
| | | //设置状态栏文字颜色及图标为深色 |
| | | mActivity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); |
| | | |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| | | try { |
| | | Class decorViewClazz = Class.forName("com.android.internal.policy.DecorView"); |
| | | Field field = decorViewClazz.getDeclaredField("mSemiTransparentStatusBarColor"); |
| | | field.setAccessible(true); |
| | | field.setInt(window.getDecorView(), Color.TRANSPARENT); //改为透明 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.mugua.mgvideo.util.video; |
| | | |
| | | import android.content.Context; |
| | | |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | |
| | | public class PlayerFullScreenUtil { |
| | | |
| | | |
| | | private static String getJSContent(Context context, String name) { |
| | | try { |
| | | InputStream inputStream = context.getAssets().open(name); |
| | | return StringUtils.convertStreamToString(inputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 风行全屏JS代码 |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getFunShionFullScreenJS(Context context) { |
| | | return getJSContent(context, "player_funshion.js"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取Acfun全屏代码 |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getAcfunFullScreenJS(Context context) { |
| | | return getJSContent(context, "player_acfun.js"); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mugua.mgvideo.util.video; |
| | | |
| | | import android.content.Context; |
| | | import android.graphics.Typeface; |
| | | import android.text.SpannableString; |
| | | import android.text.Spanned; |
| | | import android.text.style.AbsoluteSizeSpan; |
| | | import android.text.style.StyleSpan; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.load.engine.DiskCacheStrategy; |
| | | import com.bumptech.glide.request.RequestOptions; |
| | | import com.lcjian.library.util.common.DimenUtils; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.lcjian.library.util.glide.GlideRoundTransform; |
| | | import com.mugua.mgvideo.R; |
| | | import com.mugua.mgvideo.entity.HomeVideo; |
| | | import com.mugua.mgvideo.entity.video.holder.VideoHolder; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | | public class VideoUIUtil { |
| | | |
| | | private static final String TAG = "VideoUIUtil"; |
| | | |
| | | public static void setVideoListItem(Context mContext, VideoHolder viewHolder, View.OnClickListener itemOnClickListener, final VideoInfo info, int columns, int itemWidth) { |
| | | viewHolder.ll_video_show.setVisibility(View.VISIBLE); |
| | | float ratio = 0; |
| | | if (columns == 2) { |
| | | ratio = 0.562f; |
| | | } else if (columns == 3) { |
| | | ratio = 1.39f; |
| | | } else { |
| | | ratio = 0.562f; |
| | | } |
| | | viewHolder.rl_ratio.setRatio(ratio); |
| | | |
| | | String picture = ""; |
| | | if (columns == 2) { |
| | | picture = info.getHpicture(); |
| | | } else if (columns == 3) { |
| | | picture = info.getVpicture(); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(picture)) { |
| | | picture = info.getPicture(); |
| | | } |
| | | |
| | | viewHolder.rl_ratio.setTag(picture); |
| | | if (itemWidth > 0) { |
| | | ViewGroup.LayoutParams params = viewHolder.iv_movie_cover.getLayoutParams(); |
| | | ViewGroup.LayoutParams params1 = viewHolder.view.getLayoutParams(); |
| | | params.width = itemWidth; |
| | | params.height = (int) (itemWidth * ratio); |
| | | params1.width = itemWidth; |
| | | try { |
| | | Glide.with(mContext).load(picture).apply(new RequestOptions().centerCrop()).transition(withCrossFade()).placeholder(R.drawable.shape_video_list_cover_placeholder).diskCacheStrategy(DiskCacheStrategy.ALL).into(viewHolder.iv_movie_cover); |
| | | } catch (IllegalArgumentException e) { |
| | | Log.i(TAG, e.getMessage()); |
| | | } |
| | | } else { |
| | | viewHolder.rl_ratio.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | Glide.with(mContext).load(viewHolder.rl_ratio.getTag() + "").apply(new RequestOptions().centerCrop()).transition(withCrossFade()).placeholder(R.drawable.shape_video_list_cover_placeholder).diskCacheStrategy(DiskCacheStrategy.ALL).into(viewHolder.iv_movie_cover); |
| | | } catch (IllegalArgumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | if (info.getTag() != null && info.getTag().contains("评分")) { |
| | | info.setTag(""); |
| | | } |
| | | |
| | | |
| | | viewHolder.tv_movie_title.setText(info.getName() + ""); |
| | | viewHolder.tv_tag.setText(StringUtils.isEmpty(info.getTag()) ? "" : info.getTag()); |
| | | |
| | | viewHolder.view.setOnClickListener(itemOnClickListener); |
| | | |
| | | viewHolder.tv_tag.setText(info.getTag()); |
| | | if (StringUtils.isBlank(info.getTag())) { |
| | | viewHolder.tv_tag.setVisibility(View.INVISIBLE); |
| | | } else { |
| | | viewHolder.tv_tag.setVisibility(View.VISIBLE); |
| | | } |
| | | |
| | | |
| | | if (!StringUtils.isEmpty(info.getScore())) { |
| | | viewHolder.tv_score.setVisibility(View.VISIBLE); |
| | | //改变 |
| | | SpannableString spannableString = new SpannableString(info.getScore() + "分"); |
| | | spannableString.setSpan(new AbsoluteSizeSpan(DimenUtils.spToPixels(13, mContext)), 0, 1, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); |
| | | spannableString.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), 0, info.getScore().length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); |
| | | viewHolder.tv_score.setText(spannableString); |
| | | } else { |
| | | viewHolder.tv_score.setVisibility(View.INVISIBLE); |
| | | } |
| | | |
| | | if (viewHolder.tv_tag.getVisibility() == View.INVISIBLE && viewHolder.tv_score.getVisibility() == View.INVISIBLE) { |
| | | viewHolder.ll_tag_container.setVisibility(View.GONE); |
| | | } else { |
| | | viewHolder.ll_tag_container.setVisibility(View.VISIBLE); |
| | | } |
| | | |
| | | |
| | | //vip标识 |
| | | if (info != null && info.getFree() == 1) { |
| | | viewHolder.iv_vip.setVisibility(View.VISIBLE); |
| | | } else { |
| | | viewHolder.iv_vip.setVisibility(View.GONE); |
| | | } |
| | | |
| | | if (info != null && info.getDefinition() == 1) { |
| | | viewHolder.iv_high.setVisibility(View.VISIBLE); |
| | | } else { |
| | | viewHolder.iv_high.setVisibility(View.GONE); |
| | | } |
| | | |
| | | |
| | | |
| | | if (StringUtils.isEmpty(info.getSubTitle())) { |
| | | viewHolder.tv_movie_sub_title.setVisibility(View.GONE); |
| | | viewHolder.tv_movie_title.setLines(2); |
| | | } else { |
| | | viewHolder.tv_movie_sub_title.setVisibility(View.VISIBLE); |
| | | viewHolder.tv_movie_title.setLines(1); |
| | | } |
| | | |
| | | |
| | | viewHolder.tv_movie_sub_title.setText(info.getSubTitle() == null ? "" : info.getSubTitle()); |
| | | } |
| | | |
| | | public static void setHomeVideoListItem(Context mContext, VideoHolder holder, View.OnClickListener itemOnClickListener, HomeVideo info, boolean big) { |
| | | //设置内容 |
| | | holder.ll_video_show.setVisibility(View.VISIBLE); |
| | | if (StringUtils.isEmpty(info.getPicture())) { |
| | | Glide.with(mContext).load(info.getVideo().getPicture()) |
| | | .apply(new RequestOptions().centerCrop().transform(new GlideRoundTransform(mContext, big ? 8 : 6)).placeholder(R.drawable.ic_default_cover).error(R.drawable.ic_default_cover)) |
| | | .into(holder.iv_movie_cover); |
| | | } else { |
| | | try { |
| | | Glide.with(mContext).load(info.getPicture()) |
| | | .apply(new RequestOptions().centerCrop().transform(new GlideRoundTransform(mContext, big ? 8 : 6)).placeholder(R.drawable.ic_default_cover).error(R.drawable.ic_default_cover)) |
| | | .into(holder.iv_movie_cover); |
| | | } catch (IllegalArgumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | holder.tv_movie_title.setText(info.getVideo().getName()); |
| | | |
| | | |
| | | String tag = StringUtils.isBlank(info |
| | | .getVideo().getTag()) ? "" : info.getVideo() |
| | | .getTag(); |
| | | holder.tv_tag.setText(tag); |
| | | if (StringUtils.isBlank(tag)) { |
| | | holder.tv_tag.setVisibility(View.GONE); |
| | | } else { |
| | | holder.tv_tag.setVisibility(View.VISIBLE); |
| | | } |
| | | |
| | | if (!StringUtils.isEmpty(info.getVideo().getScore())) { |
| | | holder.tv_score.setVisibility(View.VISIBLE); |
| | | //改变 |
| | | SpannableString spannableString = new SpannableString(info.getVideo().getScore() + "分"); |
| | | spannableString.setSpan(new AbsoluteSizeSpan(DimenUtils.spToPixels(13, mContext)), 0, 1, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); |
| | | holder.tv_score.setText(spannableString); |
| | | } else { |
| | | holder.tv_score.setVisibility(View.GONE); |
| | | } |
| | | |
| | | if (holder.tv_tag.getVisibility() == View.GONE && holder.tv_score.getVisibility() == View.GONE) { |
| | | holder.ll_tag_container.setVisibility(View.GONE); |
| | | } else { |
| | | holder.ll_tag_container.setVisibility(View.VISIBLE); |
| | | } |
| | | |
| | | |
| | | //vip标识 |
| | | if (info.getVideo() != null && info.getVideo().getFree() == 1) { |
| | | holder.iv_vip.setVisibility(View.VISIBLE); |
| | | } else { |
| | | holder.iv_vip.setVisibility(View.GONE); |
| | | } |
| | | |
| | | if (info.getVideo() != null && info.getVideo().getDefinition() == 1) { |
| | | holder.iv_high.setVisibility(View.VISIBLE); |
| | | } else { |
| | | holder.iv_high.setVisibility(View.GONE); |
| | | } |
| | | holder.ll_video_show |
| | | .setOnClickListener(itemOnClickListener); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mugua.mgvideo.entity.VideoDetailInfo; |
| | | import com.yeshi.base.entity.video.VideoDetailInfo; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.util.ArrayList; |
| | |
| | | |
| | | import android.content.Context; |
| | | import android.database.DataSetObserver; |
| | | import android.support.v4.view.PagerAdapter; |
| | | import android.support.v4.view.ViewPager; |
| | | import androidx.viewpager.widget.PagerAdapter; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | import android.util.AttributeSet; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | |
| | | api fileTree(include: '*.jar', dir: 'libs') |
| | | api project(':APPUpdate') |
| | | api project(':library-ViewPagerIndicator') |
| | | implementation 'com.android.support:support-v4:27.1.1' |
| | | implementation 'androidx.legacy:legacy-support-v4:1.0.0' |
| | | implementation project(path: ':library-common') |
| | | } |
| | | |
| | |
| | | import android.app.Activity; |
| | | import android.content.Context; |
| | | import android.os.Build; |
| | | import android.support.v4.view.PagerAdapter; |
| | | import androidx.viewpager.widget.PagerAdapter; |
| | | import android.telephony.TelephonyManager; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | |
| | | import android.content.Intent; |
| | | import android.graphics.drawable.Drawable; |
| | | import android.os.Bundle; |
| | | import android.support.annotation.NonNull; |
| | | import android.support.annotation.Nullable; |
| | | import android.support.v4.view.PagerAdapter; |
| | | import androidx.annotation.NonNull; |
| | | import androidx.annotation.Nullable; |
| | | import androidx.viewpager.widget.PagerAdapter; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | |
| | | package com.weikou.wpc.superad.widget; |
| | | |
| | | import android.content.Context; |
| | | import android.support.v4.view.PagerAdapter; |
| | | import android.support.v4.view.ViewPager; |
| | | import androidx.viewpager.widget.PagerAdapter; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | import android.util.AttributeSet; |
| | | import android.view.MotionEvent; |
| | | import android.view.View; |
| | |
| | | // Top-level build file where you can add configuration options common to all sub-projects/modules. |
| | | buildscript { |
| | | repositories { |
| | | maven { |
| | | url "https://maven.aliyun.com/repository/public" |
| | | } |
| | | |
| | | maven { |
| | | url "https://maven.aliyun.com/repository/google" |
| | | } |
| | | |
| | | maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' } |
| | | |
| | | jcenter() |
| | | mavenCentral() |
| | | google() |
| | | jcenter() |
| | | maven { |
| | | url "http://repo.baichuan-android.taobao.com/content/groups/BaichuanRepositories/" |
| | | } |
| | | maven { url 'http://developer.huawei.com/repo/' } |
| | | } |
| | | |
| | | dependencies { |
| | | classpath 'com.android.tools.build:gradle:3.3.2' |
| | | classpath 'com.android.tools.build:gradle:4.1.1' |
| | | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'//Added line |
| | | } |
| | | } |
| | | |
| | | allprojects { |
| | | repositories { |
| | | google()//新增的 |
| | | maven { |
| | | url "https://maven.aliyun.com/repository/public" |
| | | } |
| | | |
| | | maven { |
| | | url "https://maven.aliyun.com/repository/google" |
| | | } |
| | | |
| | | maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' } |
| | | |
| | | jcenter() |
| | | maven { url "https://maven.google.com" } |
| | | maven { url "https://dl.bintray.com/thelasterstar/maven/" } |
| | | google() |
| | | maven { |
| | | url "http://repo.baichuan-android.taobao.com/content/groups/BaichuanRepositories/" |
| | | } |
| | | |
| | | |
| | | maven { url 'https://jitpack.io' } |
| | | maven { url 'https://dl.bintray.com/umsdk/release' } |
| | | maven { url "https://dl.bintray.com/thelasterstar/maven/" } |
| | | maven { url 'http://developer.huawei.com/repo/' } |
| | | } |
| | | } |
New file |
| | |
| | | android.enableJetifier=true |
| | | android.useAndroidX=true |
| | |
| | | #Fri Mar 27 16:08:13 CST 2020 |
| | | #Fri Jul 09 14:48:43 CST 2021 |
| | | distributionBase=GRADLE_USER_HOME |
| | | distributionPath=wrapper/dists |
| | | zipStoreBase=GRADLE_USER_HOME |
| | | zipStorePath=wrapper/dists |
| | | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip |
| | | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip |
| | |
| | | versionCode 1 |
| | | versionName "1.0" |
| | | |
| | | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" |
| | | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' |
| | | consumerProguardFiles "consumer-rules.pro" |
| | | } |
| | | |
| | |
| | | implementation project(path: ':library-common') |
| | | implementation project(path: ':library-ViewPagerIndicator') |
| | | testImplementation 'junit:junit:4.12' |
| | | androidTestImplementation 'com.android.support.test:runner:1.0.2' |
| | | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' |
| | | androidTestImplementation 'androidx.test.ext:junit:1.1.1' |
| | | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' |
| | | |
| | | } |
| | |
| | | package com.yeshi.ec.library_baiducpu; |
| | | |
| | | import android.content.Context; |
| | | import android.support.test.InstrumentationRegistry; |
| | | import android.support.test.runner.AndroidJUnit4; |
| | | import androidx.test.platform.app.InstrumentationRegistry; |
| | | import androidx.test.ext.junit.runners.AndroidJUnit4; |
| | | |
| | | import org.junit.Test; |
| | | import org.junit.runner.RunWith; |
| | |
| | | package com.yeshi.ec.library_baiducpu.adapter; |
| | | |
| | | import android.content.Context; |
| | | import android.support.annotation.NonNull; |
| | | import android.support.v7.widget.RecyclerView; |
| | | import androidx.annotation.NonNull; |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | |
| | | package com.yeshi.ec.library_baiducpu.fragment; |
| | | |
| | | import android.graphics.Canvas; |
| | | import android.graphics.Color; |
| | | import android.graphics.Rect; |
| | | import android.os.Bundle; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import android.support.v7.widget.GridLayoutManager; |
| | | import android.support.v7.widget.LinearLayoutManager; |
| | | import android.support.v7.widget.RecyclerView; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import androidx.recyclerview.widget.GridLayoutManager; |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | import android.util.Log; |
| | | import android.view.Gravity; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.ProgressBar; |
| | | import android.widget.TextView; |
| | | |
| | | import com.androidquery.util.Progress; |
| | | import com.baidu.mobad.feeds.RequestParameters; |
| | | import com.baidu.mobads.nativecpu.CPUAdRequest; |
| | | import com.baidu.mobads.nativecpu.CpuLpFontSize; |
| | |
| | | android:layout_height="match_parent" |
| | | android:orientation="vertical"> |
| | | |
| | | <android.support.v4.widget.SwipeRefreshLayout |
| | | <androidx.swiperefreshlayout.widget.SwipeRefreshLayout |
| | | android:id="@+id/srl_news" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | <android.support.v7.widget.RecyclerView |
| | | <androidx.recyclerview.widget.RecyclerView |
| | | android:id="@+id/rv_news" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | </android.support.v7.widget.RecyclerView> |
| | | </androidx.recyclerview.widget.RecyclerView> |
| | | |
| | | </android.support.v4.widget.SwipeRefreshLayout> |
| | | </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> |
| | | |
| | | |
| | | </LinearLayout> |
| | |
| | | android:layout_height="1px" |
| | | android:background="#616161" /> |
| | | |
| | | <android.support.v4.view.ViewPager |
| | | <androidx.viewpager.widget.ViewPager |
| | | android:id="@+id/vp_news" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="0dp" |
| | |
| | | |
| | | dependencies { |
| | | implementation fileTree(include: '*.jar', dir: 'libs') |
| | | implementation ('com.android.support:support-v4:27.1.1') |
| | | implementation ('androidx.legacy:legacy-support-v4:1.0.0') |
| | | implementation project(path: ':library-common') |
| | | } |
| | | |
| | |
| | | import android.graphics.drawable.Drawable; |
| | | import android.os.Parcel; |
| | | import android.os.Parcelable; |
| | | import android.support.v4.view.MotionEventCompat; |
| | | import android.support.v4.view.ViewConfigurationCompat; |
| | | import android.support.v4.view.ViewPager; |
| | | import androidx.core.view.MotionEventCompat; |
| | | import androidx.core.view.ViewConfigurationCompat; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | import android.util.AttributeSet; |
| | | import android.view.MotionEvent; |
| | | import android.view.View; |
| | |
| | | import android.annotation.SuppressLint; |
| | | import android.content.Context; |
| | | import android.graphics.Color; |
| | | import android.support.v4.view.PagerAdapter; |
| | | import android.support.v4.view.ViewPager; |
| | | import android.support.v4.view.ViewPager.OnPageChangeListener; |
| | | import androidx.viewpager.widget.PagerAdapter; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | import androidx.viewpager.widget.ViewPager.OnPageChangeListener; |
| | | import android.util.AttributeSet; |
| | | import android.util.TypedValue; |
| | | import android.view.View; |
| | |
| | | package com.viewpagerindicator; |
| | | |
| | | import android.content.Context; |
| | | import android.support.v4.view.PagerAdapter; |
| | | import android.support.v4.view.ViewPager; |
| | | import android.support.v4.view.ViewPager.OnPageChangeListener; |
| | | import androidx.viewpager.widget.PagerAdapter; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | import androidx.viewpager.widget.ViewPager.OnPageChangeListener; |
| | | import android.util.AttributeSet; |
| | | import android.view.Gravity; |
| | | import android.view.View; |
| | |
| | | import android.content.res.TypedArray; |
| | | import android.graphics.Canvas; |
| | | import android.graphics.Paint; |
| | | import android.graphics.RectF; |
| | | import android.graphics.drawable.Drawable; |
| | | import android.os.Parcel; |
| | | import android.os.Parcelable; |
| | | import android.support.v4.view.MotionEventCompat; |
| | | import android.support.v4.view.ViewConfigurationCompat; |
| | | import android.support.v4.view.ViewPager; |
| | | import androidx.core.view.MotionEventCompat; |
| | | import androidx.core.view.ViewConfigurationCompat; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | import android.util.AttributeSet; |
| | | import android.util.FloatMath; |
| | | import android.view.MotionEvent; |
| | | import android.view.View; |
| | | import android.view.ViewConfiguration; |
| | |
| | | import android.annotation.SuppressLint; |
| | | import android.content.Context; |
| | | import android.graphics.Color; |
| | | import android.support.v4.view.PagerAdapter; |
| | | import android.support.v4.view.ViewPager; |
| | | import android.support.v4.view.ViewPager.OnPageChangeListener; |
| | | import androidx.viewpager.widget.PagerAdapter; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | import androidx.viewpager.widget.ViewPager.OnPageChangeListener; |
| | | import android.text.SpannableStringBuilder; |
| | | import android.text.Spanned; |
| | | import android.text.style.ForegroundColorSpan; |
| | |
| | | import android.annotation.SuppressLint; |
| | | import android.content.Context; |
| | | import android.graphics.Color; |
| | | import android.support.v4.view.PagerAdapter; |
| | | import android.support.v4.view.ViewPager; |
| | | import android.support.v4.view.ViewPager.OnPageChangeListener; |
| | | import androidx.viewpager.widget.PagerAdapter; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | import androidx.viewpager.widget.ViewPager.OnPageChangeListener; |
| | | import android.util.AttributeSet; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | |
| | | import android.content.Context; |
| | | import android.content.res.Resources; |
| | | import android.graphics.Color; |
| | | import android.support.v4.view.PagerAdapter; |
| | | import android.support.v4.view.ViewPager; |
| | | import android.support.v4.view.ViewPager.OnPageChangeListener; |
| | | import androidx.viewpager.widget.PagerAdapter; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | import androidx.viewpager.widget.ViewPager.OnPageChangeListener; |
| | | import android.util.AttributeSet; |
| | | import android.util.TypedValue; |
| | | import android.view.View; |
| | |
| | | |
| | | package com.viewpagerindicator; |
| | | |
| | | import android.support.v4.view.ViewPager; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | |
| | | /** |
| | | * A PageIndicator is responsible to show an visual indicator on the total views |
| | |
| | | import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; |
| | | import android.content.Context; |
| | | import android.graphics.Color; |
| | | import android.support.v4.view.PagerAdapter; |
| | | import android.support.v4.view.ViewPager; |
| | | import android.support.v4.view.ViewPager.OnPageChangeListener; |
| | | import androidx.viewpager.widget.PagerAdapter; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | import androidx.viewpager.widget.ViewPager.OnPageChangeListener; |
| | | import android.util.AttributeSet; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | |
| | | import android.graphics.drawable.Drawable; |
| | | import android.os.Parcel; |
| | | import android.os.Parcelable; |
| | | import android.support.v4.view.MotionEventCompat; |
| | | import android.support.v4.view.ViewConfigurationCompat; |
| | | import android.support.v4.view.ViewPager; |
| | | import androidx.core.view.MotionEventCompat; |
| | | import androidx.core.view.ViewConfigurationCompat; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | import android.util.AttributeSet; |
| | | import android.view.MotionEvent; |
| | | import android.view.View; |
| | |
| | | import android.graphics.drawable.Drawable; |
| | | import android.os.Parcel; |
| | | import android.os.Parcelable; |
| | | import android.support.v4.view.MotionEventCompat; |
| | | import android.support.v4.view.ViewConfigurationCompat; |
| | | import android.support.v4.view.ViewPager; |
| | | import androidx.core.view.MotionEventCompat; |
| | | import androidx.core.view.ViewConfigurationCompat; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | import android.util.AttributeSet; |
| | | import android.view.MotionEvent; |
| | | import android.view.View; |
New file |
| | |
| | | plugins { |
| | | id 'com.android.library' |
| | | } |
| | | |
| | | android { |
| | | compileSdkVersion 28 |
| | | buildToolsVersion "30.0.2" |
| | | |
| | | defaultConfig { |
| | | minSdkVersion 17 |
| | | targetSdkVersion 28 |
| | | versionCode 1 |
| | | versionName "1.0" |
| | | |
| | | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| | | consumerProguardFiles "consumer-rules.pro" |
| | | |
| | | javaCompileOptions { |
| | | annotationProcessorOptions { |
| | | arguments = [AROUTER_MODULE_NAME: project.getName()] |
| | | } |
| | | } |
| | | } |
| | | |
| | | buildTypes { |
| | | release { |
| | | minifyEnabled false |
| | | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| | | } |
| | | } |
| | | compileOptions { |
| | | sourceCompatibility JavaVersion.VERSION_1_8 |
| | | targetCompatibility JavaVersion.VERSION_1_8 |
| | | } |
| | | } |
| | | |
| | | dependencies { |
| | | |
| | | implementation 'androidx.appcompat:appcompat:1.1.0' |
| | | implementation 'com.google.android.material:material:1.1.0' |
| | | implementation project(path: ':library-common') |
| | | api files('libs/android-async-http-1.4.8.jar') |
| | | testImplementation 'junit:junit:4.+' |
| | | androidTestImplementation 'androidx.test.ext:junit:1.1.1' |
| | | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' |
| | | api files("libs/open_ad_sdk.aar") |
| | | api 'com.qq.e.union:union:+' |
| | | api 'org.apache.httpcomponents:httpcore:4.4.2' |
| | | //加载动画库 |
| | | api 'com.github.ybq:Android-SpinKit:1.4.0' |
| | | |
| | | api project(':social_sdk_library_project') |
| | | |
| | | api files('libs/tbs_sdk_thirdapp_v3.5.0.1004_43500_sharewithdownload_withoutGame_obfs_20170801_113025.jar') |
| | | |
| | | |
| | | //安全组件 |
| | | api files('libs/avmpaar3-5.4.36.aar') |
| | | api files('libs/securitybodyaar3-5.4.99.aar') |
| | | api files('libs/securityguardaar3-5.4.171.aar') |
| | | api files('libs/sgmiddletieraar3-5.4.9.aar') |
| | | api files('libs/mtopsdk_allinone_open-3.1.2.5.jar') |
| | | api files('libs/alibc_link_partner-4.1.15.aar') |
| | | |
| | | //登陆 |
| | | api 'com.ali.auth.sdk:alibabauth_core:2.0.0.6@aar' |
| | | api 'com.ali.auth.sdk:alibabauth_ui:2.0.0.6@aar' |
| | | api 'com.ali.auth.sdk:alibabauth_ext:2.0.0.6@aar' |
| | | |
| | | |
| | | api 'com.alibaba.mtl:app-monitor-sdk:2.6.4.5_for_bc' |
| | | // 电商基础组件 |
| | | api 'com.alibaba.sdk.android:AlibcTradeCommon:4.0.0.15@aar' |
| | | api 'com.alibaba.sdk.android:AlibcTradeBiz:4.0.0.15@aar' |
| | | api 'com.alibaba.sdk.android:nb_trade:4.0.0.15@aar'\ |
| | | |
| | | |
| | | api files('libs/fastjson-1.2.9.jar') |
| | | |
| | | api project(path: ':MDownloadProvider') |
| | | |
| | | annotationProcessor'com.alibaba:arouter-compiler:1.2.2' |
| | | |
| | | } |
New file |
| | |
| | | # Add project specific ProGuard rules here. |
| | | # You can control the set of applied configuration files using the |
| | | # proguardFiles setting in build.gradle. |
| | | # |
| | | # For more details, see |
| | | # http://developer.android.com/guide/developing/tools/proguard.html |
| | | |
| | | # If your project uses WebView with JS, uncomment the following |
| | | # and specify the fully qualified class name to the JavaScript interface |
| | | # class: |
| | | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { |
| | | # public *; |
| | | #} |
| | | |
| | | # Uncomment this to preserve the line number information for |
| | | # debugging stack traces. |
| | | #-keepattributes SourceFile,LineNumberTable |
| | | |
| | | # If you keep the line number information, uncomment this to |
| | | # hide the original source file name. |
| | | #-renamesourcefileattribute SourceFile |
New file |
| | |
| | | package com.yeshi.ec.base; |
| | | |
| | | import android.content.Context; |
| | | |
| | | import androidx.test.platform.app.InstrumentationRegistry; |
| | | import androidx.test.ext.junit.runners.AndroidJUnit4; |
| | | |
| | | import org.junit.Test; |
| | | import org.junit.runner.RunWith; |
| | | |
| | | import static org.junit.Assert.*; |
| | | |
| | | /** |
| | | * Instrumented test, which will execute on an Android device. |
| | | * |
| | | * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> |
| | | */ |
| | | @RunWith(AndroidJUnit4.class) |
| | | public class ExampleInstrumentedTest { |
| | | @Test |
| | | public void useAppContext() { |
| | | // Context of the app under test. |
| | | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); |
| | | assertEquals("com.yeshi.ec.base.test", appContext.getPackageName()); |
| | | } |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| | | package="com.yeshi.ec.base"> |
| | | |
| | | </manifest> |
New file |
| | |
| | | package com.yeshi.base.entity; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | public class AccumulateRule implements Serializable { |
| | | |
| | | /** |
| | | * serialVersionUID |
| | | */ |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String name; |
| | | |
| | | private int score; |
| | | |
| | | private String description; |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public int getScore() { |
| | | return score; |
| | | } |
| | | |
| | | public void setScore(int score) { |
| | | this.score = score; |
| | | } |
| | | |
| | | public String getDescription() { |
| | | return description; |
| | | } |
| | | |
| | | public void setDescription(String description) { |
| | | this.description = description; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.entity; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * Created by weikou2015 on 2017/3/7. |
| | | */ |
| | | |
| | | public class JumpDetail implements Serializable { |
| | | @Expose |
| | | private String activity; |
| | | @Expose |
| | | private String id; |
| | | @Expose |
| | | private String name; |
| | | @Expose |
| | | private String type; |
| | | @Expose |
| | | private boolean needLogin; |
| | | @Expose |
| | | private String controller; |
| | | |
| | | public String getActivity() { |
| | | return activity; |
| | | } |
| | | |
| | | public void setActivity(String activity) { |
| | | this.activity = activity; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(String type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public String getController() { |
| | | return controller; |
| | | } |
| | | |
| | | public void setController(String controller) { |
| | | this.controller = controller; |
| | | } |
| | | |
| | | public boolean isNeedLogin() { |
| | | return needLogin; |
| | | } |
| | | |
| | | public void setNeedLogin(boolean needLogin) { |
| | | this.needLogin = needLogin; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.entity; |
| | | |
| | | public class SDCardEntity { |
| | | private String path; |
| | | private long totalSize; |
| | | private long availableSize; |
| | | |
| | | public String getPath() { |
| | | return path; |
| | | } |
| | | |
| | | public void setPath(String path) { |
| | | this.path = path; |
| | | } |
| | | |
| | | public long getTotalSize() { |
| | | return totalSize; |
| | | } |
| | | |
| | | public void setTotalSize(long totalSize) { |
| | | this.totalSize = totalSize; |
| | | } |
| | | |
| | | public long getAvailableSize() { |
| | | return availableSize; |
| | | } |
| | | |
| | | public void setAvailableSize(long availableSize) { |
| | | this.availableSize = availableSize; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.entity; |
| | | |
| | | /** |
| | | * ϵͳ��Ϣ�� |
| | | * |
| | | * @author Administrator |
| | | * |
| | | */ |
| | | public class SystemInfo { |
| | | private String id; |
| | | private String name; |
| | | private String createtime; |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getCreatetime() { |
| | | return createtime; |
| | | } |
| | | |
| | | public void setCreatetime(String createtime) { |
| | | this.createtime = createtime; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.entity; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | |
| | | /** |
| | | * �û���Ϣ |
| | | * |
| | | * @author Administrator |
| | | * |
| | | */ |
| | | public class UserInfo { |
| | | private String id; |
| | | private String score; |
| | | private String device; |
| | | private String createtime; |
| | | @Expose |
| | | private String Portrait;// 用户头像 |
| | | @Expose |
| | | private String Nickname;// 用户昵称 |
| | | |
| | | public String getPortrait() { |
| | | return Portrait; |
| | | } |
| | | |
| | | public void setPortrait(String portrait) { |
| | | Portrait = portrait; |
| | | } |
| | | |
| | | public String getNickname() { |
| | | return Nickname; |
| | | } |
| | | |
| | | public void setNickname(String nickname) { |
| | | Nickname = nickname; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getScore() { |
| | | return score; |
| | | } |
| | | |
| | | public void setScore(String score) { |
| | | this.score = score; |
| | | } |
| | | |
| | | public String getDevice() { |
| | | return device; |
| | | } |
| | | |
| | | public void setDevice(String device) { |
| | | this.device = device; |
| | | } |
| | | |
| | | public String getCreatetime() { |
| | | return createtime; |
| | | } |
| | | |
| | | public void setCreatetime(String createtime) { |
| | | this.createtime = createtime; |
| | | } |
| | | |
| | | public SystemInfo getSystem() { |
| | | return system; |
| | | } |
| | | |
| | | public void setSystem(SystemInfo system) { |
| | | this.system = system; |
| | | } |
| | | |
| | | private SystemInfo system; |
| | | } |
New file |
| | |
| | | package com.yeshi.base.entity.ad; |
| | | |
| | | public enum AdPositionEnum { |
| | | splash("splash"),//开屏 |
| | | splashHotStart("splashHotStart"),//热启动开屏 |
| | | videoPlayPre("videoPlayPre"),//视频播放前贴 |
| | | exitApp("exitApp"),//APP退出广告 |
| | | videoSearch("videoSearch"),//搜索页广告 |
| | | videoDetailFullVideo("videoDetailFullVideo"),//视频全屏广告 |
| | | pptvNoAdReward("pptvNoAdReward"),//PPTV无广告激励视频 |
| | | other("其他广告位"); |
| | | |
| | | private String positionName; |
| | | |
| | | public String getPositionName() { |
| | | return positionName; |
| | | } |
| | | |
| | | private AdPositionEnum(String positionName) { |
| | | this.positionName = positionName; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.entity.ad; |
| | | |
| | | import com.bytedance.sdk.openadsdk.TTNativeExpressAd; |
| | | import com.qq.e.ads.nativ.NativeExpressADView; |
| | | import com.qq.e.ads.nativ.NativeUnifiedADData; |
| | | import com.qq.e.ads.nativ.express2.NativeExpressADData2; |
| | | |
| | | //信息流原生广告容器 |
| | | public class ExpressAdContainer { |
| | | |
| | | TTNativeExpressAd csj; |
| | | NativeExpressADView gdt;//旧版广点通 |
| | | NativeExpressADData2 gdt2;//2.0版广点通 |
| | | NativeUnifiedADData gdt2Unfied;//2.0广点通自渲染 |
| | | |
| | | public NativeUnifiedADData getGdt2Unfied() { |
| | | return gdt2Unfied; |
| | | } |
| | | |
| | | public void setGdt2Unfied(NativeUnifiedADData gdt2Unfied) { |
| | | this.gdt2Unfied = gdt2Unfied; |
| | | } |
| | | |
| | | public ExpressAdContainer(TTNativeExpressAd csj) { |
| | | this.csj = csj; |
| | | } |
| | | |
| | | public ExpressAdContainer(NativeExpressADView gdt) { |
| | | this.gdt = gdt; |
| | | } |
| | | |
| | | public ExpressAdContainer(NativeExpressADData2 gdt2) { |
| | | this.gdt2 = gdt2; |
| | | } |
| | | |
| | | public ExpressAdContainer(NativeUnifiedADData gdt2Unfied) { |
| | | this.gdt2Unfied = gdt2Unfied; |
| | | } |
| | | |
| | | public TTNativeExpressAd getCsj() { |
| | | return csj; |
| | | } |
| | | |
| | | public void setCsj(TTNativeExpressAd csj) { |
| | | this.csj = csj; |
| | | } |
| | | |
| | | public NativeExpressADView getGdt() { |
| | | return gdt; |
| | | } |
| | | |
| | | public void setGdt(NativeExpressADView gdt) { |
| | | this.gdt = gdt; |
| | | } |
| | | |
| | | public NativeExpressADData2 getGdt2() { |
| | | return gdt2; |
| | | } |
| | | |
| | | public void setGdt2(NativeExpressADData2 gdt2) { |
| | | this.gdt2 = gdt2; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.entity.db; |
| | | |
| | | import android.database.sqlite.SQLiteDatabase; |
| | | import android.net.Uri; |
| | | import android.provider.BaseColumns; |
| | | |
| | | public class DownloadTable implements BaseColumns { |
| | | |
| | | public static final String AUTHORITY = "com.weikou.mgvideo.provider.download"; |
| | | |
| | | public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY |
| | | + "/" + "downloads"); |
| | | /** |
| | | * The MIME type of {@link #CONTENT_URI}. |
| | | */ |
| | | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.weikou.download"; |
| | | /** |
| | | * The MIME type of a {@link #CONTENT_URI} sub-directory of a single row. |
| | | */ |
| | | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.weikou.download"; |
| | | |
| | | public static final String TABLE_NAME = "DOWNLOAD"; |
| | | |
| | | public static final String TASK_ID = "_TASK_ID"; |
| | | |
| | | public static final String VIDEO_ID = "_VIDEO_ID"; |
| | | |
| | | public static final String VIDEO_DETAIL_ID = "_VIDEO_DETAIL_ID"; |
| | | |
| | | public static final String VIDEO_THIRD_TYPE = "_VIDEO_THIRD_TYPE"; |
| | | |
| | | public static final String VIDEO_DETAIL = "_VIDEO_DETAIL"; |
| | | |
| | | public static void createTables(SQLiteDatabase db) { |
| | | db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" |
| | | + DownloadTable._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," |
| | | + DownloadTable.TASK_ID + " INTEGER," + DownloadTable.VIDEO_ID |
| | | + " TEXT," + DownloadTable.VIDEO_DETAIL_ID + " TEXT," |
| | | + DownloadTable.VIDEO_THIRD_TYPE + " TEXT," |
| | | + DownloadTable.VIDEO_DETAIL + " TEXT)"); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.entity.db; |
| | | |
| | | import android.database.sqlite.SQLiteDatabase; |
| | | import android.net.Uri; |
| | | import android.provider.BaseColumns; |
| | | |
| | | public class WatchHistoryTable implements BaseColumns { |
| | | |
| | | public static final String AUTHORITY = "com.weikou.mgvideo.provider.watchhistory"; |
| | | |
| | | public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY |
| | | + "/" + "watchhistories"); |
| | | /** |
| | | * The MIME type of {@link #CONTENT_URI}. |
| | | */ |
| | | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.weikou.watchhistory"; |
| | | /** |
| | | * The MIME type of a {@link #CONTENT_URI} sub-directory of a single row. |
| | | */ |
| | | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.weikou.watchhistory"; |
| | | |
| | | public static final String TABLE_NAME = "WATCH_HISTORY"; |
| | | |
| | | public static final String VIDEO_ID = "_VIDEO_ID"; |
| | | |
| | | public static final String VIDEO_DETAIL_ID = "_VIDEO_DETAIL_ID"; |
| | | |
| | | public static final String VIDEO_THIRD_TYPE = "_VIDEO_THIRD_TYPE"; |
| | | |
| | | public static final String VIDEO_DETAIL = "_VIDEO_DETAIL"; |
| | | |
| | | public static final String VIDEO_RESOURCE = "_VIDEO_RESOURCE"; |
| | | |
| | | public static final String VIDEO_RESOURCE_ID = "_VIDEO_RESOURCE_ID"; |
| | | |
| | | public static final String WATCH_TIME = "_WATCH_TIME"; |
| | | |
| | | public static final String UPDATE_TIME = "_UPDATE_TIME"; |
| | | |
| | | public static final String CREATE_TIME = "_CREATE_TIME"; |
| | | |
| | | public static void createTables(SQLiteDatabase db) { |
| | | db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" |
| | | + WatchHistoryTable._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," |
| | | + WatchHistoryTable.VIDEO_ID + " TEXT," |
| | | + WatchHistoryTable.VIDEO_DETAIL_ID + " TEXT," |
| | | + WatchHistoryTable.VIDEO_THIRD_TYPE + " TEXT," |
| | | + WatchHistoryTable.VIDEO_DETAIL + " TEXT," |
| | | + WatchHistoryTable.WATCH_TIME + " INTEGER," |
| | | + WatchHistoryTable.UPDATE_TIME + " INTEGER," |
| | | + WatchHistoryTable.CREATE_TIME + " INTEGER," |
| | | + WatchHistoryTable.VIDEO_RESOURCE + " TEXT," |
| | | + WatchHistoryTable.VIDEO_RESOURCE_ID + " TEXT)"); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.entity.video; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * Created by weikou2015 on 2016/8/15. |
| | | * 关注相关实体 |
| | | */ |
| | | public class Follow implements Serializable { |
| | | private String movieName; |
| | | private String moviePicture; |
| | | private String updateInfo; |
| | | private boolean isAttention; |
| | | |
| | | public boolean isAttention() { |
| | | return isAttention; |
| | | } |
| | | |
| | | public void setAttention(boolean attention) { |
| | | isAttention = attention; |
| | | } |
| | | |
| | | public String getMovieName() { |
| | | return movieName; |
| | | } |
| | | |
| | | public void setMovieName(String movieName) { |
| | | this.movieName = movieName; |
| | | } |
| | | |
| | | public String getMoviePicture() { |
| | | return moviePicture; |
| | | } |
| | | |
| | | public void setMoviePicture(String moviePicture) { |
| | | this.moviePicture = moviePicture; |
| | | } |
| | | |
| | | public String getUpdateInfo() { |
| | | return updateInfo; |
| | | } |
| | | |
| | | public void setUpdateInfo(String updateInfo) { |
| | | this.updateInfo = updateInfo; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.entity.video; |
| | | |
| | | public class Play { |
| | | private PlayUrl playUrl; |
| | | |
| | | public PlayUrl getPlayUrl() { |
| | | return playUrl; |
| | | } |
| | | |
| | | public void setPlayUrl(PlayUrl playUrl) { |
| | | this.playUrl = playUrl; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.entity.video; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | public class PlayUrl implements Serializable { |
| | | /** |
| | | * |
| | | */ |
| | | private static final long serialVersionUID = 1L; |
| | | @Expose |
| | | private VideoResource resource; |
| | | @Expose |
| | | private String url; |
| | | @Expose |
| | | private int playType;// 0、不可播 1、站外-html 2、站内-播放器 |
| | | @Expose |
| | | private String params; |
| | | @Expose |
| | | private String code; |
| | | |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(String code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | public VideoResource getResource() { |
| | | return resource; |
| | | } |
| | | |
| | | public void setResource(VideoResource resource) { |
| | | this.resource = resource; |
| | | } |
| | | |
| | | public String getUrl() { |
| | | return url; |
| | | } |
| | | |
| | | public void setUrl(String url) { |
| | | this.url = url; |
| | | } |
| | | |
| | | public int getPlayType() { |
| | | return playType; |
| | | } |
| | | |
| | | public void setPlayType(int playType) { |
| | | this.playType = playType; |
| | | } |
| | | |
| | | public String getParams() { |
| | | return params; |
| | | } |
| | | |
| | | public void setParams(String params) { |
| | | this.params = params; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.entity.video; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | public class Playlocation implements Serializable { |
| | | |
| | | int position; |
| | | |
| | | public int getPosition() { |
| | | return position; |
| | | } |
| | | |
| | | public void setPosition(int position) { |
| | | this.position = position; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.entity.video; |
| | | |
| | | import com.yeshi.base.entity.ad.ExpressAdContainer; |
| | | |
| | | public class VideoContent { |
| | | public final static int TYPE_AD = 1; |
| | | public final static int TYPE_VIDEO = 2; |
| | | |
| | | private int type; |
| | | |
| | | private ExpressAdContainer ad; |
| | | private VideoInfo video; |
| | | |
| | | |
| | | public static VideoContent createVideoContent(VideoInfo video) { |
| | | VideoContent vc = new VideoContent(); |
| | | vc.setType(TYPE_VIDEO); |
| | | vc.setVideo(video); |
| | | return vc; |
| | | } |
| | | |
| | | |
| | | public static VideoContent createAdContent(ExpressAdContainer ad) { |
| | | VideoContent vc = new VideoContent(); |
| | | vc.setType(TYPE_AD); |
| | | vc.setAd(ad); |
| | | return vc; |
| | | } |
| | | |
| | | public int getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(int type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public ExpressAdContainer getAd() { |
| | | return ad; |
| | | } |
| | | |
| | | public void setAd(ExpressAdContainer ad) { |
| | | this.ad = ad; |
| | | } |
| | | |
| | | public VideoInfo getVideo() { |
| | | return video; |
| | | } |
| | | |
| | | public void setVideo(VideoInfo video) { |
| | | this.video = video; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.entity.video; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * ��Ƶ���� |
| | | * |
| | | * @author Administrator |
| | | */ |
| | | public class VideoDetailInfo implements Serializable { |
| | | |
| | | /** |
| | | * serialVersionUID |
| | | */ |
| | | private static final long serialVersionUID = 1L; |
| | | @Expose |
| | | private String id; |
| | | private VideoInfo video; |
| | | @Expose |
| | | private String name; |
| | | private String beizhu; |
| | | @Expose |
| | | private String createtime; |
| | | @Expose |
| | | private List<PlayUrl> urls; |
| | | @Expose |
| | | private String introduction; |
| | | @Expose |
| | | private String type; |
| | | @Expose |
| | | private String eId; |
| | | @Expose |
| | | private String picture; |
| | | private String comment; |
| | | |
| | | public String getPicture() { |
| | | return picture; |
| | | } |
| | | |
| | | public void setPicture(String picture) { |
| | | this.picture = picture; |
| | | } |
| | | |
| | | public String geteId() { |
| | | return eId; |
| | | } |
| | | |
| | | public void seteId(String eId) { |
| | | this.eId = eId; |
| | | } |
| | | |
| | | public String getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(String type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public static long getSerialversionuid() { |
| | | return serialVersionUID; |
| | | } |
| | | |
| | | public String getIntroduction() { |
| | | return introduction; |
| | | } |
| | | |
| | | public void setIntroduction(String introduction) { |
| | | this.introduction = introduction; |
| | | } |
| | | |
| | | public String getComment() { |
| | | return comment; |
| | | } |
| | | |
| | | public void setComment(String comment) { |
| | | this.comment = comment; |
| | | } |
| | | |
| | | public List<PlayUrl> getUrls() { |
| | | return urls; |
| | | } |
| | | |
| | | public void setUrls(List<PlayUrl> urls) { |
| | | this.urls = urls; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public VideoInfo getVideo() { |
| | | return video; |
| | | } |
| | | |
| | | public void setVideo(VideoInfo video) { |
| | | this.video = video; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getBeizhu() { |
| | | return beizhu; |
| | | } |
| | | |
| | | public void setBeizhu(String beizhu) { |
| | | this.beizhu = beizhu; |
| | | } |
| | | |
| | | public String getCreatetime() { |
| | | return createtime; |
| | | } |
| | | |
| | | public void setCreatetime(String createtime) { |
| | | this.createtime = createtime; |
| | | } |
| | | |
| | | public String getTag() { |
| | | return tag; |
| | | } |
| | | |
| | | public void setTag(String tag) { |
| | | this.tag = tag; |
| | | } |
| | | |
| | | private String tag; |
| | | } |
New file |
| | |
| | | package com.yeshi.base.entity.video; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | import com.qq.e.ads.nativ.NativeExpressADView; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | public class VideoInfo implements Serializable { |
| | | |
| | | /** |
| | | * serialVersionUID |
| | | */ |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Expose |
| | | private String id; |
| | | @Expose |
| | | private String picture; |
| | | @Expose |
| | | private String vpicture; |
| | | @Expose |
| | | private String hpicture; |
| | | @Expose |
| | | private String name; |
| | | @Expose |
| | | private String introduction; |
| | | @Expose |
| | | private String duration; |
| | | @Expose |
| | | private String mainActor; |
| | | @Expose |
| | | private String year; |
| | | @Expose |
| | | private String thirdType; |
| | | @Expose |
| | | private VideoType videoType; |
| | | @Expose |
| | | private String share; |
| | | private String beizhu; |
| | | @Expose |
| | | private String qulity; |
| | | @Expose |
| | | private String createtime; |
| | | @Expose |
| | | private String score; |
| | | @Expose |
| | | private String watchCount; |
| | | @Expose |
| | | private String tag; |
| | | @Expose |
| | | private String area; |
| | | @Expose |
| | | private String commentCount;// 评论数目 |
| | | @Expose |
| | | private List<VideoDetailInfo> videoDetailList; |
| | | @Expose |
| | | private boolean canSave;// true-可以 false-不行 |
| | | |
| | | private NativeExpressADView adView;// 原生广告信息 |
| | | @Expose |
| | | private List<VideoResource> resourceList; |
| | | @Expose |
| | | private int showType;// 1、单列 2、多列 |
| | | @Expose |
| | | private String playPicture; |
| | | @Expose |
| | | private String updatetime; |
| | | @Expose |
| | | private String evalueate; |
| | | |
| | | @Expose |
| | | private String subTitle; |
| | | |
| | | @Expose |
| | | private int free; |
| | | |
| | | //0-普清 1-高清 |
| | | @Expose |
| | | private int definition; |
| | | |
| | | //导演 |
| | | @Expose |
| | | private String director; |
| | | |
| | | @Expose |
| | | private VideoAlbumMoreInfo albumMoreInfo; |
| | | |
| | | //页大小 |
| | | @Expose |
| | | private int pageSize; |
| | | |
| | | |
| | | public int getPageSize() { |
| | | return pageSize; |
| | | } |
| | | |
| | | public void setPageSize(int pageSize) { |
| | | this.pageSize = pageSize; |
| | | } |
| | | |
| | | public VideoAlbumMoreInfo getAlbumMoreInfo() { |
| | | return albumMoreInfo; |
| | | } |
| | | |
| | | public void setAlbumMoreInfo(VideoAlbumMoreInfo albumMoreInfo) { |
| | | this.albumMoreInfo = albumMoreInfo; |
| | | } |
| | | |
| | | public int getDefinition() { |
| | | return definition; |
| | | } |
| | | |
| | | public void setDefinition(int definition) { |
| | | this.definition = definition; |
| | | } |
| | | |
| | | public int getFree() { |
| | | return free; |
| | | } |
| | | |
| | | public void setFree(int free) { |
| | | this.free = free; |
| | | } |
| | | |
| | | public String getVpicture() { |
| | | return vpicture; |
| | | } |
| | | |
| | | public void setVpicture(String vpicture) { |
| | | this.vpicture = vpicture; |
| | | } |
| | | |
| | | public String getHpicture() { |
| | | return hpicture; |
| | | } |
| | | |
| | | public void setHpicture(String hpicture) { |
| | | this.hpicture = hpicture; |
| | | } |
| | | |
| | | private Follow attention; |
| | | |
| | | public static long getSerialVersionUID() { |
| | | return serialVersionUID; |
| | | } |
| | | |
| | | public String getEvalueate() { |
| | | return evalueate; |
| | | } |
| | | |
| | | public void setEvalueate(String evalueate) { |
| | | this.evalueate = evalueate; |
| | | } |
| | | |
| | | public String getArea() { |
| | | return area; |
| | | } |
| | | |
| | | public void setArea(String area) { |
| | | this.area = area; |
| | | } |
| | | |
| | | public Follow getAttention() { |
| | | return attention; |
| | | } |
| | | |
| | | public void setAttention(Follow attention) { |
| | | this.attention = attention; |
| | | } |
| | | |
| | | public String getUpdatetime() { |
| | | return updatetime; |
| | | } |
| | | |
| | | public void setUpdatetime(String updatetime) { |
| | | this.updatetime = updatetime; |
| | | } |
| | | |
| | | public String getPlayPicture() { |
| | | return playPicture; |
| | | } |
| | | |
| | | public void setPlayPicture(String playPicture) { |
| | | this.playPicture = playPicture; |
| | | } |
| | | |
| | | public int getShowType() { |
| | | return showType; |
| | | } |
| | | |
| | | public void setShowType(int showType) { |
| | | this.showType = showType; |
| | | } |
| | | |
| | | public String getCommentCount() { |
| | | return commentCount; |
| | | } |
| | | |
| | | public void setCommentCount(String commentCount) { |
| | | this.commentCount = commentCount; |
| | | } |
| | | |
| | | public static long getSerialversionuid() { |
| | | return serialVersionUID; |
| | | } |
| | | |
| | | public boolean isCanSave() { |
| | | return canSave; |
| | | } |
| | | |
| | | public void setCanSave(boolean canSave) { |
| | | this.canSave = canSave; |
| | | } |
| | | |
| | | private String extraData;// 需要再次请求网络的播放url |
| | | |
| | | public String getExtraData() { |
| | | return extraData; |
| | | } |
| | | |
| | | public void setExtraData(String extraData) { |
| | | this.extraData = extraData; |
| | | } |
| | | |
| | | public String getTag() { |
| | | return tag; |
| | | } |
| | | |
| | | public void setTag(String tag) { |
| | | this.tag = tag; |
| | | } |
| | | |
| | | public String getShare() { |
| | | return share; |
| | | } |
| | | |
| | | public void setShare(String share) { |
| | | this.share = share; |
| | | } |
| | | |
| | | public String getMainActor() { |
| | | return mainActor; |
| | | } |
| | | |
| | | public void setMainActor(String mainActor) { |
| | | this.mainActor = mainActor; |
| | | } |
| | | |
| | | public String getThirdType() { |
| | | return thirdType; |
| | | } |
| | | |
| | | public void setThirdType(String thirdType) { |
| | | this.thirdType = thirdType; |
| | | } |
| | | |
| | | public VideoType getVideoType() { |
| | | return videoType; |
| | | } |
| | | |
| | | public void setVideoType(VideoType videoType) { |
| | | this.videoType = videoType; |
| | | } |
| | | |
| | | public String getWatchCount() { |
| | | return watchCount; |
| | | } |
| | | |
| | | public void setWatchCount(String watchCount) { |
| | | this.watchCount = watchCount; |
| | | } |
| | | |
| | | public List<VideoDetailInfo> getVideoDetailList() { |
| | | return videoDetailList; |
| | | } |
| | | |
| | | public void setVideoDetailList(List<VideoDetailInfo> videoDetalList) { |
| | | this.videoDetailList = videoDetalList; |
| | | } |
| | | |
| | | public String getScore() { |
| | | return score; |
| | | } |
| | | |
| | | public void setScore(String score) { |
| | | this.score = score; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getPicture() { |
| | | return picture; |
| | | } |
| | | |
| | | public void setPicture(String picture) { |
| | | this.picture = picture; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getIntroduction() { |
| | | return introduction; |
| | | } |
| | | |
| | | public void setIntroduction(String introduction) { |
| | | this.introduction = introduction; |
| | | } |
| | | |
| | | public String getDuration() { |
| | | return duration; |
| | | } |
| | | |
| | | public void setDuration(String duration) { |
| | | this.duration = duration; |
| | | } |
| | | |
| | | public String getMainactor() { |
| | | return mainActor; |
| | | } |
| | | |
| | | public void setMainactor(String mainactor) { |
| | | this.mainActor = mainactor; |
| | | } |
| | | |
| | | public String getYear() { |
| | | return year; |
| | | } |
| | | |
| | | public void setYear(String year) { |
| | | this.year = year; |
| | | } |
| | | |
| | | public String getBeizhu() { |
| | | return beizhu; |
| | | } |
| | | |
| | | public void setBeizhu(String beizhu) { |
| | | this.beizhu = beizhu; |
| | | } |
| | | |
| | | public String getQulity() { |
| | | return qulity; |
| | | } |
| | | |
| | | public void setQulity(String qulity) { |
| | | this.qulity = qulity; |
| | | } |
| | | |
| | | public String getCreatetime() { |
| | | return createtime; |
| | | } |
| | | |
| | | public void setCreatetime(String createtime) { |
| | | this.createtime = createtime; |
| | | } |
| | | |
| | | public List<VideoResource> getResourceList() { |
| | | return resourceList; |
| | | } |
| | | |
| | | public void setResourceList(List<VideoResource> resourceList) { |
| | | this.resourceList = resourceList; |
| | | } |
| | | |
| | | public NativeExpressADView getAdView() { |
| | | return adView; |
| | | } |
| | | |
| | | public void setAdView(NativeExpressADView adView) { |
| | | this.adView = adView; |
| | | } |
| | | |
| | | |
| | | public String getSubTitle() { |
| | | return subTitle; |
| | | } |
| | | |
| | | public void setSubTitle(String subTitle) { |
| | | this.subTitle = subTitle; |
| | | } |
| | | |
| | | public String getDirector() { |
| | | return director; |
| | | } |
| | | |
| | | public void setDirector(String director) { |
| | | this.director = director; |
| | | } |
| | | |
| | | public static class VideoAlbumMoreInfo implements Serializable{ |
| | | private String name; |
| | | private int jumpPosition; |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public int getJumpPosition() { |
| | | return jumpPosition; |
| | | } |
| | | |
| | | public void setJumpPosition(int jumpPosition) { |
| | | this.jumpPosition = jumpPosition; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.entity.video; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * ��Ƶ��Դ |
| | | * |
| | | * @author Administrator |
| | | * |
| | | */ |
| | | public class VideoResource implements Serializable { |
| | | |
| | | /** |
| | | * serialVersionUID |
| | | */ |
| | | private static final long serialVersionUID = 1L; |
| | | @Expose |
| | | private String id; |
| | | @Expose |
| | | private String name; |
| | | @Expose |
| | | private String createtime; |
| | | private String beizhu; |
| | | @Expose |
| | | private String picture; |
| | | @Expose |
| | | private boolean checked; |
| | | |
| | | public boolean isChecked() { |
| | | return checked; |
| | | } |
| | | |
| | | public void setChecked(boolean checked) { |
| | | this.checked = checked; |
| | | } |
| | | |
| | | public static long getSerialversionuid() { |
| | | return serialVersionUID; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getCreatetime() { |
| | | return createtime; |
| | | } |
| | | |
| | | public void setCreatetime(String createtime) { |
| | | this.createtime = createtime; |
| | | } |
| | | |
| | | public String getBeizhu() { |
| | | return beizhu; |
| | | } |
| | | |
| | | public void setBeizhu(String beizhu) { |
| | | this.beizhu = beizhu; |
| | | } |
| | | |
| | | public String getPicture() { |
| | | return picture; |
| | | } |
| | | |
| | | public void setPicture(String picture) { |
| | | this.picture = picture; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.entity.video; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * ��Ƶ���� |
| | | * |
| | | * @author Administrator |
| | | * |
| | | */ |
| | | public class VideoType implements Serializable { |
| | | |
| | | /** |
| | | * serialVersionUID |
| | | */ |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Expose |
| | | private String id; |
| | | @Expose |
| | | private String name; |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | @Expose |
| | | private String icon; |
| | | private String beizhu; |
| | | @Expose |
| | | private String createtime; |
| | | @Expose |
| | | private VideoType parent; |
| | | |
| | | @Expose |
| | | private String main;//1-主分类 0-热门 |
| | | |
| | | public String getMain() { |
| | | return main; |
| | | } |
| | | |
| | | public void setMain(String main) { |
| | | this.main = main; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getIcon() { |
| | | return icon; |
| | | } |
| | | |
| | | public void setIcon(String icon) { |
| | | this.icon = icon; |
| | | } |
| | | |
| | | public String getBeizhu() { |
| | | return beizhu; |
| | | } |
| | | |
| | | public void setBeizhu(String beizhu) { |
| | | this.beizhu = beizhu; |
| | | } |
| | | |
| | | public String getCreatetime() { |
| | | return createtime; |
| | | } |
| | | |
| | | public void setCreatetime(String createtime) { |
| | | this.createtime = createtime; |
| | | } |
| | | |
| | | public VideoType getParent() { |
| | | return parent; |
| | | } |
| | | |
| | | public void setParent(VideoType parent) { |
| | | this.parent = parent; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.entity.video; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * ��Ƶ��url���� |
| | | * |
| | | * @author Administrator |
| | | * |
| | | */ |
| | | public class VideoUrl implements Serializable { |
| | | |
| | | /** |
| | | * serialVersionUID |
| | | */ |
| | | private static final long serialVersionUID = 1L; |
| | | @Expose |
| | | private String id; |
| | | private VideoDetailInfo videoDetail; |
| | | @Expose |
| | | private VideoResource resource; |
| | | @Expose |
| | | private String url; |
| | | @Expose |
| | | private String createtime; |
| | | @Expose |
| | | private String invalid;// 0-有效 1-无效 |
| | | |
| | | private boolean selected = false;// 是否被选中 |
| | | |
| | | public boolean isSelected() { |
| | | return selected; |
| | | } |
| | | |
| | | public void setSelected(boolean selected) { |
| | | this.selected = selected; |
| | | } |
| | | |
| | | public String getInvalid() { |
| | | return invalid; |
| | | } |
| | | |
| | | public void setInvalid(String invalid) { |
| | | this.invalid = invalid; |
| | | } |
| | | |
| | | private String beizhu; |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public VideoDetailInfo getVideoDetail() { |
| | | return videoDetail; |
| | | } |
| | | |
| | | public void setVideoDetail(VideoDetailInfo videoDetail) { |
| | | this.videoDetail = videoDetail; |
| | | } |
| | | |
| | | public VideoResource getResource() { |
| | | return resource; |
| | | } |
| | | |
| | | public void setResource(VideoResource resource) { |
| | | this.resource = resource; |
| | | } |
| | | |
| | | public String getUrl() { |
| | | return url; |
| | | } |
| | | |
| | | public void setUrl(String url) { |
| | | this.url = url; |
| | | } |
| | | |
| | | public String getCreatetime() { |
| | | return createtime; |
| | | } |
| | | |
| | | public void setCreatetime(String createtime) { |
| | | this.createtime = createtime; |
| | | } |
| | | |
| | | public String getBeizhu() { |
| | | return beizhu; |
| | | } |
| | | |
| | | public void setBeizhu(String beizhu) { |
| | | this.beizhu = beizhu; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.ui; |
| | | |
| | | import android.content.pm.ActivityInfo; |
| | | import android.content.res.Configuration; |
| | | import android.content.res.Resources; |
| | | import android.os.Bundle; |
| | | |
| | | import androidx.fragment.app.FragmentActivity; |
| | | |
| | | public class BaseActivity extends FragmentActivity { |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle arg0) { |
| | | super.onCreate(arg0); |
| | | setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);// 锁定竖屏 |
| | | } |
| | | |
| | | public void onResume() { |
| | | super.onResume(); |
| | | // MobclickAgent.onResume(this); |
| | | } |
| | | |
| | | public void onPause() { |
| | | super.onPause(); |
| | | // MobclickAgent.onPause(this); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onConfigurationChanged(Configuration newConfig) { |
| | | if (newConfig.fontScale != 1)//非默认值 |
| | | getResources(); |
| | | super.onConfigurationChanged(newConfig); |
| | | } |
| | | |
| | | @Override |
| | | public Resources getResources() { |
| | | Resources res = super.getResources(); |
| | | if (res.getConfiguration().fontScale != 1) {//非默认值 |
| | | Configuration newConfig = new Configuration(); |
| | | newConfig.setToDefaults();//设置默认 |
| | | newConfig.fontScale = 1.0f; |
| | | res.updateConfiguration(newConfig, res.getDisplayMetrics()); |
| | | } |
| | | return res; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.ui; |
| | | |
| | | import android.content.Intent; |
| | | import android.os.Bundle; |
| | | import android.view.KeyEvent; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.view.ViewGroup; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.ProgressBar; |
| | | import android.widget.TextView; |
| | | |
| | | import com.alibaba.android.arouter.facade.annotation.Route; |
| | | import com.alibaba.android.arouter.launcher.ARouter; |
| | | import com.tencent.smtt.sdk.DownloadListener; |
| | | import com.tencent.smtt.sdk.WebChromeClient; |
| | | import com.tencent.smtt.sdk.WebSettings; |
| | | import com.tencent.smtt.sdk.WebView; |
| | | import com.tencent.smtt.sdk.WebViewClient; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.yeshi.base.utils.MGJavaInterface; |
| | | import com.yeshi.base.utils.RouteConstant; |
| | | import com.yeshi.base.utils.x5.X5WebView; |
| | | import com.yeshi.ec.base.R; |
| | | |
| | | @Route(path = RouteConstant.PATH_WEB_BROWSER) |
| | | public class BrowserActivity extends BaseActivity implements OnClickListener { |
| | | |
| | | private TextView tv_top_bar_left; |
| | | private TextView tv_top_bar_left2; |
| | | private TextView tv_top_bar_middle; |
| | | private X5WebView webview; |
| | | private FrameLayout fl_webview; |
| | | ProgressBar progressBar; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.browser_activity); |
| | | ARouter.getInstance().inject(this); |
| | | tv_top_bar_left = (TextView) findViewById(R.id.tv_top_bar_left); |
| | | tv_top_bar_left2 = (TextView) findViewById(R.id.tv_top_bar_left2); |
| | | tv_top_bar_left2.setVisibility(View.VISIBLE); |
| | | tv_top_bar_middle = (TextView) findViewById(R.id.tv_top_bar_middle); |
| | | fl_webview = (FrameLayout) findViewById(R.id.fl_webview); |
| | | tv_top_bar_left2.setText("关闭"); |
| | | tv_top_bar_left.setOnClickListener(this); |
| | | tv_top_bar_left2.setOnClickListener(this); |
| | | |
| | | webview = new X5WebView(BrowserActivity.this); |
| | | webview.setDownloadListener(new DownloadListener() { |
| | | |
| | | @Override |
| | | public void onDownloadStart(String arg0, String arg1, String arg2, |
| | | String arg3, long arg4) { |
| | | } |
| | | |
| | | }); |
| | | fl_webview.addView(webview, new FrameLayout.LayoutParams( |
| | | FrameLayout.LayoutParams.MATCH_PARENT, |
| | | FrameLayout.LayoutParams.MATCH_PARENT)); |
| | | WebSettings webSettings = webview.getSettings(); |
| | | webSettings.setJavaScriptEnabled(true); |
| | | webSettings.setDomStorageEnabled(true); |
| | | webview.addJavascriptInterface(new MGJavaInterface(BrowserActivity.this, webview), "yestv"); |
| | | webview.setDrawingCacheEnabled(true); |
| | | webview.setWebViewClient(new WebViewClient() { |
| | | @Override |
| | | public boolean shouldOverrideUrlLoading(WebView view, String url) { |
| | | if (url != null && url.startsWith("buwanprotocol://")) { |
| | | String murl = url.split("buwanprotocol://")[1]; |
| | | String[] params = murl.split("#"); |
| | | if (params[0].equalsIgnoreCase("playvideo")) { |
| | | Bundle bundle = new Bundle(); |
| | | bundle.putString("Id", params[1]); |
| | | bundle.putString("ResourceId", params[2]); |
| | | bundle.putString("DetailId", params[3]); |
| | | bundle.putString("Share", "0"); |
| | | bundle.putString("ThirdType", "0"); |
| | | ARouter.getInstance().build(RouteConstant.PATH_VIDEO_DETAIL) |
| | | .withBundle(null, bundle) |
| | | .navigation(); |
| | | } |
| | | return true; |
| | | } else if ((url != null && (url.contains("/tbopen/")) || (!url.startsWith("http")))) { |
| | | return true; |
| | | } |
| | | return super.shouldOverrideUrlLoading(webview, url); |
| | | } |
| | | |
| | | @Override |
| | | public void onPageFinished(WebView webView, String s) { |
| | | super.onPageFinished(webView, s); |
| | | } |
| | | }); |
| | | progressBar = findViewById(R.id.myProgressBar); |
| | | progressBar.setMax(100); |
| | | progressBar.setProgressDrawable(this.getResources().getDrawable( |
| | | R.drawable.color_progressbar)); |
| | | webview.setWebChromeClient(new WebChromeClient() { |
| | | |
| | | @Override |
| | | public void onReceivedTitle(WebView view, String title) { |
| | | tv_top_bar_middle.setText(title); |
| | | } |
| | | |
| | | @Override |
| | | public void onProgressChanged(WebView webView, int i) { |
| | | if (i == 100) { |
| | | progressBar.setVisibility(View.GONE); |
| | | } else { |
| | | if (View.INVISIBLE == progressBar.getVisibility()) { |
| | | progressBar.setVisibility(View.VISIBLE); |
| | | } |
| | | progressBar.setProgress(i); |
| | | } |
| | | super.onProgressChanged(webView, i); |
| | | } |
| | | }); |
| | | webview.loadUrl(getIntent().getStringExtra("url")); |
| | | } |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | MobclickAgent.onPageStart("网页"); |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | MobclickAgent.onPageEnd("网页"); |
| | | } |
| | | |
| | | @Override |
| | | protected void onDestroy() { |
| | | if (webview != null) { |
| | | webview.loadDataWithBaseURL(null, "", "text/html", "utf-8", null); |
| | | webview.clearHistory(); |
| | | |
| | | ((ViewGroup) webview.getParent()).removeView(webview); |
| | | webview.destroy(); |
| | | webview = null; |
| | | } |
| | | super.onDestroy(); |
| | | } |
| | | |
| | | @Override |
| | | protected void onStop() { |
| | | super.onStop(); |
| | | } |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | int id = v.getId(); |
| | | if (id == R.id.tv_top_bar_left) { |
| | | if (!webview.canGoBack()) |
| | | finish(); |
| | | else { |
| | | webview.goBack(); |
| | | } |
| | | } else if (id == R.id.tv_top_bar_left2) { |
| | | finish(); |
| | | } |
| | | } |
| | | |
| | | // 设置回退 |
| | | // 覆盖Activity类的onKeyDown(int keyCoder,KeyEvent event)方法 |
| | | @Override |
| | | public boolean onKeyDown(int keyCode, KeyEvent event) { |
| | | if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) { |
| | | webview.goBack(); // goBack()表示返回WebView的上一页面 |
| | | return true; |
| | | } |
| | | return super.onKeyDown(keyCode, event); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.ui; |
| | | |
| | | import java.util.Timer; |
| | | import java.util.TimerTask; |
| | | import java.util.regex.Matcher; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.content.pm.ActivityInfo; |
| | | import android.os.Bundle; |
| | | import android.os.Handler; |
| | | import android.os.Message; |
| | | import android.text.Editable; |
| | | import android.text.TextWatcher; |
| | | import android.view.View; |
| | | import android.widget.EditText; |
| | | import android.widget.TextView; |
| | | |
| | | import com.lcjian.library.util.SingleToast; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.yeshi.base.utils.BaseApiUtil; |
| | | import com.yeshi.base.utils.IsEmail; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.yeshi.ec.base.R; |
| | | |
| | | /** |
| | | * 忘记密码,修改密码 Created by weikou2015 on 2016/10/27. |
| | | */ |
| | | |
| | | public class ForgetPwdActivity extends BaseActivity implements |
| | | View.OnClickListener { |
| | | |
| | | private EditText et_email; |
| | | private EditText et_verfication_code; |
| | | private TextView tv_obtain_verfication_code; |
| | | private EditText et_pwd; |
| | | private TextView tv_confirm; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle arg0) { |
| | | super.onCreate(arg0); |
| | | setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); |
| | | setContentView(R.layout.activity_forget_pwd); |
| | | et_email = (EditText) findViewById(R.id.et_email); |
| | | et_verfication_code = (EditText) findViewById(R.id.et_verfication_code); |
| | | tv_obtain_verfication_code = (TextView) findViewById(R.id.tv_obtain_verfication_code); |
| | | et_pwd = (EditText) findViewById(R.id.et_pwd); |
| | | tv_confirm = (TextView) findViewById(R.id.tv_confirm); |
| | | |
| | | et_email.addTextChangedListener(new TextWatcher() { |
| | | |
| | | @Override |
| | | public void onTextChanged(CharSequence arg0, int arg1, int arg2, |
| | | int arg3) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void beforeTextChanged(CharSequence arg0, int arg1, |
| | | int arg2, int arg3) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable arg0) { |
| | | // et_email.getText().toString() |
| | | if (!StringUtils.isEmpty(et_verfication_code.getText() |
| | | .toString()) |
| | | && !StringUtils.isEmpty(et_pwd.getText().toString()) |
| | | && !StringUtils.isEmpty(arg0.toString())) { |
| | | tv_confirm.setBackground(getResources().getDrawable( |
| | | R.drawable.shape_login2)); |
| | | } else { |
| | | tv_confirm.setBackground(getResources().getDrawable( |
| | | R.drawable.shape_login1)); |
| | | } |
| | | if (!StringUtils.isEmpty(arg0.toString())) { |
| | | tv_obtain_verfication_code.setBackground(getResources() |
| | | .getDrawable(R.drawable.shape_login2)); |
| | | } else { |
| | | tv_obtain_verfication_code.setBackground(getResources() |
| | | .getDrawable(R.drawable.shape_login1)); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | et_verfication_code.addTextChangedListener(new TextWatcher() { |
| | | |
| | | @Override |
| | | public void onTextChanged(CharSequence arg0, int arg1, int arg2, |
| | | int arg3) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void beforeTextChanged(CharSequence arg0, int arg1, |
| | | int arg2, int arg3) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable arg0) { |
| | | if (!StringUtils.isEmpty(et_email.getText().toString()) |
| | | && !StringUtils.isEmpty(et_pwd.getText().toString()) |
| | | && !StringUtils.isEmpty(arg0.toString())) { |
| | | tv_confirm.setBackground(getResources().getDrawable( |
| | | R.drawable.shape_login2)); |
| | | } else { |
| | | tv_confirm.setBackground(getResources().getDrawable( |
| | | R.drawable.shape_login1)); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | |
| | | et_pwd.addTextChangedListener(new TextWatcher() { |
| | | |
| | | @Override |
| | | public void onTextChanged(CharSequence arg0, int arg1, int arg2, |
| | | int arg3) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void beforeTextChanged(CharSequence arg0, int arg1, |
| | | int arg2, int arg3) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable arg0) { |
| | | if (!StringUtils.isEmpty(et_verfication_code.getText() |
| | | .toString()) |
| | | && !StringUtils.isEmpty(et_email.getText().toString()) |
| | | && !StringUtils.isEmpty(arg0.toString())) { |
| | | tv_confirm.setBackground(getResources().getDrawable( |
| | | R.drawable.shape_login2)); |
| | | } else { |
| | | tv_confirm.setBackground(getResources().getDrawable( |
| | | R.drawable.shape_login1)); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | tv_obtain_verfication_code.setOnClickListener(this); |
| | | tv_confirm.setOnClickListener(this); |
| | | findViewById(R.id.tv_back).setOnClickListener(this); |
| | | } |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | int id = v.getId(); |
| | | if (id == R.id.tv_obtain_verfication_code) { |
| | | String email = et_email.getText().toString(); |
| | | if (StringUtils.isEmpty(email)) { |
| | | SingleToast.showToast(ForgetPwdActivity.this, "请先输入邮箱号"); |
| | | return; |
| | | } else { |
| | | Matcher m = IsEmail.isEmailAddress().matcher(email); |
| | | if (m.matches()) { |
| | | getVerficationCode(email); |
| | | } else { |
| | | SingleToast.showToast(ForgetPwdActivity.this, |
| | | "输入的邮箱账号有误,请查证!"); |
| | | return; |
| | | } |
| | | } |
| | | } else if (id == R.id.tv_confirm) { |
| | | String str = et_email.getText().toString(); |
| | | if (StringUtils.isEmpty(str)) { |
| | | SingleToast.showToast(ForgetPwdActivity.this, "请先输入邮箱号"); |
| | | return; |
| | | } else { |
| | | Matcher m = IsEmail.isEmailAddress().matcher(str); |
| | | if (!m.matches()) { |
| | | SingleToast.showToast(ForgetPwdActivity.this, |
| | | "输入的邮箱账号有误,请查证!"); |
| | | return; |
| | | } |
| | | } |
| | | if (StringUtils.isEmpty(et_pwd.getText().toString())) { |
| | | SingleToast.showToast(ForgetPwdActivity.this, "密码不能为空!"); |
| | | return; |
| | | } |
| | | if (et_pwd.getText().toString().length() < 6) { |
| | | SingleToast.showToast(ForgetPwdActivity.this, "密码长度不能低于6位!"); |
| | | return; |
| | | } |
| | | revisePwd(); |
| | | } else if (id == R.id.tv_back) { |
| | | finish(); |
| | | } |
| | | } |
| | | |
| | | Timer timer; |
| | | int timecount = 59; |
| | | |
| | | /** |
| | | * 修改密码 |
| | | */ |
| | | private void revisePwd() { |
| | | SharedPreferences sp = getSharedPreferences("user", |
| | | Context.MODE_PRIVATE); |
| | | String uid = sp.getString("uid", ""); |
| | | BaseApiUtil.revisePwd(this, uid, et_email.getText().toString(), |
| | | et_verfication_code.getText().toString(), et_pwd.getText() |
| | | .toString(), new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | SingleToast.showToast(ForgetPwdActivity.this, |
| | | "修改密码成功!"); |
| | | ForgetPwdActivity.this.finish(); |
| | | } else { |
| | | SingleToast.showToast(ForgetPwdActivity.this, |
| | | jsonObject.optString("Error") + ",修改密码失败!"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, |
| | | String responseString, Throwable throwable) { |
| | | super.onFailure(statusCode, headers, responseString, |
| | | throwable); |
| | | SingleToast.showToast(ForgetPwdActivity.this, "修改密码失败"); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void getVerficationCode(String email) { |
| | | timer = new Timer(); |
| | | timer.schedule(new MyTask(), 1000, 1000); |
| | | SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE); |
| | | String uid = sp.getString("uid", ""); |
| | | BaseApiUtil.getVerficationCode(ForgetPwdActivity.this, uid, email, |
| | | new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | SingleToast.showToast(ForgetPwdActivity.this, |
| | | "获取验证码成功,请打开邮箱查看!"); |
| | | } else { |
| | | SingleToast.showToast(ForgetPwdActivity.this, |
| | | "获取验证码失败,请重新获取!"); |
| | | handler.sendEmptyMessage(1); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | class MyTask extends TimerTask { |
| | | @Override |
| | | public void run() { |
| | | if (timecount > 0) { |
| | | handler.sendEmptyMessage(0); |
| | | } else { |
| | | handler.sendEmptyMessage(1); |
| | | } |
| | | } |
| | | } |
| | | |
| | | Handler handler = new Handler() { |
| | | @Override |
| | | public void handleMessage(Message msg) { |
| | | super.handleMessage(msg); |
| | | switch (msg.what) { |
| | | case 0: |
| | | tv_obtain_verfication_code.setClickable(false); |
| | | tv_obtain_verfication_code.setText("重新发送(" + timecount + "s)"); |
| | | timecount--; |
| | | break; |
| | | case 1: |
| | | timer.cancel(); |
| | | tv_obtain_verfication_code.setText("获取验证码"); |
| | | tv_obtain_verfication_code.setClickable(true); |
| | | timecount = 59; |
| | | break; |
| | | } |
| | | } |
| | | }; |
| | | } |
New file |
| | |
| | | package com.yeshi.base.ui; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONException; |
| | | import org.json.JSONObject; |
| | | |
| | | import android.app.ProgressDialog; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | | import android.content.SharedPreferences.Editor; |
| | | import android.content.pm.PackageInfo; |
| | | import android.content.pm.PackageManager; |
| | | import android.os.Bundle; |
| | | import android.os.Handler; |
| | | import android.os.Message; |
| | | import android.text.Editable; |
| | | import android.text.TextWatcher; |
| | | import android.util.Log; |
| | | import android.view.Gravity; |
| | | import android.view.KeyEvent; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.widget.CheckBox; |
| | | import android.widget.EditText; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.LinearLayout.LayoutParams; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.alibaba.android.arouter.facade.annotation.Route; |
| | | import com.alibaba.android.arouter.launcher.ARouter; |
| | | import com.lcjian.library.util.SingleToast; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.umeng.socialize.UMAuthListener; |
| | | import com.umeng.socialize.UMShareAPI; |
| | | import com.umeng.socialize.bean.SHARE_MEDIA; |
| | | import com.yeshi.base.utils.BaseApiUtil; |
| | | import com.yeshi.base.utils.RouteConstant; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.yeshi.ec.base.R; |
| | | |
| | | @Route(path = RouteConstant.PATH_USER_LOGIN) |
| | | public class LoginActivity extends BaseActivity implements OnClickListener { |
| | | // private Tencent mTencent; |
| | | public static final int RESULT_LOGIN = 10; |
| | | // private UserInfo mInfo; |
| | | private ProgressDialog dialog; |
| | | private TextView tv_qq; |
| | | private TextView tv_cancel;// 取消 |
| | | private boolean isTouchLogin;// 用户是否点击登录 |
| | | private String uid; |
| | | // private IUiListener listener;// 用于接收返回数据的监听 |
| | | private String loginType = "";// 登录类型 默认为空字符 QQ为1 |
| | | private String openId = "";// 用户第三方登录唯一识别码 |
| | | |
| | | private LinearLayout ll_login_content; |
| | | private ImageView iv_login_top; |
| | | private EditText et_name; |
| | | private EditText et_pwd; |
| | | private CheckBox cb_user_agreement; |
| | | private TextView tv_forget_pwd; |
| | | private TextView tv_register; |
| | | private TextView tv_login; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.act_login); |
| | | ARouter.getInstance().inject(this); |
| | | uid = getSharedPreferences("user", Context.MODE_PRIVATE).getString( |
| | | "uid", ""); |
| | | tv_cancel = (TextView) findViewById(R.id.login_tv_cancel); |
| | | tv_qq = (TextView) findViewById(R.id.login_tv_qq); |
| | | |
| | | tv_cancel.setOnClickListener(this); |
| | | tv_qq.setOnClickListener(this); |
| | | dialog = new ProgressDialog(this); |
| | | ll_login_content = (LinearLayout) findViewById(R.id.ll_login_content); |
| | | iv_login_top = (ImageView) findViewById(R.id.iv_login_top); |
| | | |
| | | int w = View.MeasureSpec.makeMeasureSpec(0, |
| | | View.MeasureSpec.UNSPECIFIED); |
| | | int h = View.MeasureSpec.makeMeasureSpec(0, |
| | | View.MeasureSpec.UNSPECIFIED); |
| | | ll_login_content.measure(w, h); |
| | | int width = ll_login_content.getMeasuredWidth(); |
| | | LayoutParams params = new LayoutParams(width, |
| | | (int) (width * 0.434)); |
| | | params.gravity = Gravity.CENTER_HORIZONTAL; |
| | | iv_login_top.setLayoutParams(params); |
| | | |
| | | et_name = (EditText) findViewById(R.id.et_name); |
| | | et_pwd = (EditText) findViewById(R.id.et_pwd); |
| | | et_name.addTextChangedListener(new TextWatcher() { |
| | | |
| | | @Override |
| | | public void onTextChanged(CharSequence arg0, int arg1, int arg2, |
| | | int arg3) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void beforeTextChanged(CharSequence arg0, int arg1, |
| | | int arg2, int arg3) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable arg0) { |
| | | if (!StringUtils.isEmpty(et_pwd.getText().toString()) |
| | | && !StringUtils.isEmpty(arg0.toString())) { |
| | | tv_login.setBackground(getResources().getDrawable( |
| | | R.drawable.shape_login2)); |
| | | } else { |
| | | tv_login.setBackground(getResources().getDrawable( |
| | | R.drawable.shape_login1)); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | et_pwd.addTextChangedListener(new TextWatcher() { |
| | | |
| | | @Override |
| | | public void onTextChanged(CharSequence arg0, int arg1, int arg2, |
| | | int arg3) { |
| | | // TODO Auto-generated method stub |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void beforeTextChanged(CharSequence arg0, int arg1, |
| | | int arg2, int arg3) { |
| | | // TODO Auto-generated method stub |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable arg0) { |
| | | if (!StringUtils.isEmpty(et_pwd.getText().toString()) |
| | | && !StringUtils.isEmpty(arg0.toString())) { |
| | | tv_login.setBackground(getResources().getDrawable( |
| | | R.drawable.shape_login2)); |
| | | } else { |
| | | tv_login.setBackground(getResources().getDrawable( |
| | | R.drawable.shape_login1)); |
| | | } |
| | | } |
| | | }); |
| | | cb_user_agreement = (CheckBox) findViewById(R.id.cb_user_agreement); |
| | | tv_forget_pwd = (TextView) findViewById(R.id.tv_forget_pwd); |
| | | tv_register = (TextView) findViewById(R.id.tv_register); |
| | | tv_login = (TextView) findViewById(R.id.tv_login); |
| | | tv_forget_pwd.setOnClickListener(this); |
| | | tv_register.setOnClickListener(this); |
| | | tv_login.setOnClickListener(this); |
| | | findViewById(R.id.tv_user_agreement).setOnClickListener(this); |
| | | } |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | int id = v.getId(); |
| | | if (id == R.id.login_tv_cancel) {// 取消 |
| | | finish(); |
| | | } else if (id == R.id.login_tv_qq) {// QQ登录 |
| | | if (isQQClientAvailable()) { |
| | | loginType = "1"; |
| | | // qq登录逻辑处理 点击登录后需要暂时锁定返回键和返回功能 不然会报错 |
| | | lockBack(true); |
| | | UMShareAPI.get(LoginActivity.this).getPlatformInfo(LoginActivity.this, SHARE_MEDIA.QQ, authListener); |
| | | } else { |
| | | Toast.makeText(LoginActivity.this, "QQ不可用,请查询手机是否安装QQ...", Toast.LENGTH_LONG).show(); |
| | | } |
| | | } else if (id == R.id.tv_forget_pwd) { |
| | | startActivity(new Intent(LoginActivity.this, |
| | | ForgetPwdActivity.class)); |
| | | } else if (id == R.id.tv_user_agreement) { |
| | | Intent intent = new Intent(LoginActivity.this, |
| | | BrowserActivity.class); |
| | | intent.putExtra("url", getString(R.string.agreement)); |
| | | startActivity(intent); |
| | | } else if (id == R.id.tv_register) { |
| | | startActivity(new Intent(LoginActivity.this, RegisterActivity.class)); |
| | | } else if (id == R.id.tv_login) { |
| | | if (cb_user_agreement.isChecked()) |
| | | emailLogin(); |
| | | else |
| | | SingleToast.showToast(LoginActivity.this, "选择同意用户协议后方可登陆"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 判断qq是否可用 |
| | | */ |
| | | public boolean isQQClientAvailable() { |
| | | final PackageManager packageManager = getPackageManager(); |
| | | List<PackageInfo> pinfo = packageManager.getInstalledPackages(0); |
| | | if (pinfo != null) { |
| | | for (int i = 0; i < pinfo.size(); i++) { |
| | | String pn = pinfo.get(i).packageName; |
| | | if (pn.equals("com.tencent.mobileqq")) { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | UMAuthListener authListener = new UMAuthListener() { |
| | | @Override |
| | | public void onStart(SHARE_MEDIA platform) { |
| | | dialog.show(); |
| | | } |
| | | |
| | | @Override |
| | | public void onComplete(SHARE_MEDIA platform, int action, |
| | | final Map<String, String> data) { |
| | | dialog.dismiss(); |
| | | Log.i("mResult", "返回的数据为----" + data); |
| | | BaseApiUtil.userLogin(LoginActivity.this, uid, data.get("name"), |
| | | data.get("openid"), data.get("iconurl"), |
| | | data.get("gender"), data.get("province"), data.get("city"), |
| | | loginType, new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | Log.i("mResult", "上传数据到服务器成功!"); |
| | | // SingleToast.showToast(LoginActivity.this, |
| | | // "数据上传成功!"); |
| | | // 写入sharedpreference |
| | | Editor edit = getSharedPreferences("user", |
| | | Context.MODE_PRIVATE).edit(); |
| | | edit.putString("portrait", data.get("iconurl")); |
| | | edit.putString("LoginUid", jsonObject |
| | | .getJSONObject("Data") |
| | | .getString("LoginUid")); |
| | | edit.putString("name", data.get("name")); |
| | | edit.putString("sex", data.get("gender")); |
| | | edit.commit(); |
| | | |
| | | SingleToast.showToast(LoginActivity.this, "登录成功"); |
| | | finish(); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, |
| | | String responseString, Throwable throwable) { |
| | | super.onFailure(statusCode, headers, |
| | | responseString, throwable); |
| | | SingleToast.showToast(LoginActivity.this, "登录失败"); |
| | | // Log.i("mResult", "上传数据到服务器成功!"); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | dialog.dismiss(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onError(SHARE_MEDIA platform, int action, Throwable t) { |
| | | lockBack(false); |
| | | dialog.dismiss(); |
| | | Toast.makeText(LoginActivity.this, "失败:" + t.getMessage(), |
| | | Toast.LENGTH_LONG).show(); |
| | | } |
| | | |
| | | @Override |
| | | public void onCancel(SHARE_MEDIA platform, int action) { |
| | | lockBack(false); |
| | | dialog.dismiss(); |
| | | Toast.makeText(LoginActivity.this, "取消了", Toast.LENGTH_LONG).show(); |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * Email登陆 |
| | | */ |
| | | private void emailLogin() { |
| | | SharedPreferences preferences = getSharedPreferences("user", |
| | | MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | String name = et_name.getText().toString(); |
| | | String pwd = et_pwd.getText().toString(); |
| | | if (StringUtils.isEmpty(name) || StringUtils.isEmpty(pwd)) { |
| | | SingleToast.showToast(this, "账号或密码为空!"); |
| | | return; |
| | | } |
| | | SingleToast.showToast(this, "开始登陆了"); |
| | | BaseApiUtil.emailLogin(this, uid, name, pwd, |
| | | new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | Log.i("mResult", |
| | | "登陆后返回的值为:" + jsonObject.toString()); |
| | | SharedPreferences sp = getSharedPreferences("user", |
| | | MODE_PRIVATE); |
| | | Editor edit = sp.edit(); |
| | | edit.putString("portrait", jsonObject |
| | | .optJSONObject("Data") |
| | | .optString("Portrait")); |
| | | edit.putString("LoginUid", jsonObject |
| | | .getJSONObject("Data").getString("Id")); |
| | | edit.putString( |
| | | "name", |
| | | jsonObject.optJSONObject("Data").optString( |
| | | "Nickname")); |
| | | edit.commit(); |
| | | SingleToast.showToast(LoginActivity.this, "登陆成功" |
| | | + "昵称为:" |
| | | + jsonObject.optJSONObject("Data") |
| | | .optString("Nickname")); |
| | | finish(); |
| | | } else { |
| | | SingleToast.showToast(LoginActivity.this, "登陆失败"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, |
| | | String responseString, Throwable throwable) { |
| | | super.onFailure(statusCode, headers, responseString, |
| | | throwable); |
| | | SingleToast.showToast(LoginActivity.this, "登陆失败"); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | if (!StringUtils.isEmpty(getSharedPreferences("user", |
| | | Context.MODE_PRIVATE).getString("LoginUid", ""))) { |
| | | finish(); |
| | | } |
| | | MobclickAgent.onPageStart("登陆页"); |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | MobclickAgent.onPageEnd("登陆页"); |
| | | } |
| | | |
| | | /** |
| | | * 锁定返回 |
| | | */ |
| | | private void lockBack(boolean isSure) { |
| | | tv_cancel.setEnabled(!isSure); |
| | | isTouchLogin = isSure; |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public boolean onKeyDown(int keyCode, KeyEvent event) { |
| | | if (isTouchLogin && keyCode == KeyEvent.KEYCODE_BACK) { |
| | | return false; |
| | | } |
| | | return super.onKeyDown(keyCode, event); |
| | | } |
| | | |
| | | // class BaseUiListener implements IUiListener { |
| | | // |
| | | // @Override |
| | | // public void onCancel() { |
| | | // lockBack(false); |
| | | // SingleToast.showToast(LoginActivity.this, "取消登录"); |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onComplete(Object arg0) { |
| | | // lockBack(false); |
| | | // // V2.0版本,参数类型由JSONObject 改成了Object,具体类型参考api文档 |
| | | // dialog = ProgressDialog.show(LoginActivity.this, "", "正在登录..."); |
| | | // Log.i("mResult", "登陆请求成功!"); |
| | | // updateUserInfo(); |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onError(UiError arg0) { |
| | | // lockBack(false); |
| | | // SingleToast.showToast(LoginActivity.this, "登录失败,请重试"); |
| | | // } |
| | | // } |
| | | // |
| | | @Override |
| | | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| | | super.onActivityResult(requestCode, resultCode, data); |
| | | UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data); |
| | | } |
| | | |
| | | // |
| | | // private void updateUserInfo() { |
| | | // if (mTencent != null && mTencent.isSessionValid()) { |
| | | // listener = new IUiListener() { |
| | | // @Override |
| | | // public void onError(UiError e) { |
| | | // Log.i("mResult", "登陆错误!"); |
| | | // // SingleToast.showToast(LoginActivity.this, "第三方登陆失败!"); |
| | | // dialog.dismiss(); |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onComplete(Object response) { |
| | | // // SingleToast.showToast(LoginActivity.this, "第三方登陆成功!"); |
| | | // JSONObject object = (JSONObject) response; |
| | | // Log.i("mResult", "登陆完成!" + response); |
| | | // if (object.has("openid")) {// 第一步,获取用户唯一识别码 |
| | | // try { |
| | | // openId = object.getString("openid"); |
| | | // mInfo.getUserInfo(listener); |
| | | // } catch (JSONException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // // 第二步才执行头像等信息的获取 |
| | | // if (object.has("nickname")) {// 用户基本信息:头像 昵称 |
| | | // // SingleToast.showToast(LoginActivity.this, "有nickName,即将进入handler"); |
| | | // Message msg = new Message(); |
| | | // msg.obj = response; |
| | | // msg.what = 0; |
| | | // mHandler.sendMessage(msg); |
| | | // }else{ |
| | | // // SingleToast.showToast(LoginActivity.this, "没有有nickName"); |
| | | // dialog.dismiss(); } |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onCancel() { |
| | | // |
| | | // } |
| | | // }; |
| | | // mInfo = new UserInfo(this, mTencent.getQQToken()); |
| | | // mInfo.getOpenId(listener); |
| | | // } else { |
| | | // SingleToast.showToast(LoginActivity.this, "暂时无法登陆!"); |
| | | // Log.i("mResult", "暂时无法登陆!"); |
| | | // dialog.dismiss(); |
| | | // } |
| | | // } |
| | | |
| | | Handler mHandler = new Handler() { |
| | | @Override |
| | | public void handleMessage(Message msg) { |
| | | if (msg.what == 0) { |
| | | final JSONObject response = (JSONObject) msg.obj; |
| | | try { |
| | | Log.i("mResult", |
| | | "头像路径:----" + response.getString("figureurl_qq_2")); |
| | | // SingleToast.showToast(LoginActivity.this, |
| | | // "第三方登陆成功,开始上传数据!"); |
| | | BaseApiUtil.userLogin(LoginActivity.this, uid, |
| | | response.getString("nickname"), openId, |
| | | response.getString("figureurl_qq_2"), |
| | | response.getString("gender"), |
| | | response.getString("province"), |
| | | response.getString("city"), loginType, |
| | | new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | Log.i("mResult", "上传数据到服务器成功!"); |
| | | // SingleToast.showToast(LoginActivity.this, |
| | | // "数据上传成功!"); |
| | | // 写入sharedpreference |
| | | Editor edit = getSharedPreferences("user", |
| | | Context.MODE_PRIVATE).edit(); |
| | | edit.putString("portrait", response |
| | | .getString("figureurl_qq_2")); |
| | | edit.putString("LoginUid", |
| | | jsonObject.getJSONObject("Data") |
| | | .getString("LoginUid")); |
| | | edit.putString("name", |
| | | response.getString("nickname")); |
| | | edit.putString("sex", |
| | | response.getString("gender")); |
| | | edit.commit(); |
| | | |
| | | SingleToast.showToast(LoginActivity.this, |
| | | "登录成功"); |
| | | finish(); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, |
| | | Header[] headers, |
| | | String responseString, |
| | | Throwable throwable) { |
| | | super.onFailure(statusCode, headers, |
| | | responseString, throwable); |
| | | SingleToast.showToast(LoginActivity.this, |
| | | "登录失败"); |
| | | // Log.i("mResult", "上传数据到服务器成功!"); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | dialog.dismiss(); |
| | | } |
| | | }); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | } |
New file |
| | |
| | | package com.yeshi.base.ui; |
| | | |
| | | import android.annotation.SuppressLint; |
| | | import android.app.Activity; |
| | | import android.app.AlertDialog; |
| | | import android.content.Context; |
| | | import android.content.DialogInterface; |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.BitmapFactory; |
| | | import android.os.Bundle; |
| | | import android.util.Base64; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.widget.DatePicker; |
| | | import android.widget.EditText; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.lcjian.library.util.Environment; |
| | | import com.lcjian.library.util.SingleToast; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.lcjian.library.util.glide.GlideCircleTransform; |
| | | import com.yeshi.base.utils.BaseApiUtil; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | import com.yeshi.base.utils.SelectPicUtil; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.yeshi.ec.base.R; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.File; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.util.Calendar; |
| | | |
| | | /** |
| | | * Created by weikou2015 on 2016/10/27. |
| | | */ |
| | | |
| | | public class PersonInfoActivity extends BaseActivity implements View.OnClickListener { |
| | | |
| | | private LinearLayout ll_portrait; |
| | | private LinearLayout ll_nickName; |
| | | private LinearLayout ll_birthday; |
| | | private LinearLayout ll_sex; |
| | | private LinearLayout ll_autograph; |
| | | |
| | | private ImageView iv_portrait; |
| | | private TextView tv_nickName; |
| | | private TextView tv_birthday; |
| | | private TextView tv_sex; |
| | | private TextView tv_autograph; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle arg0) { |
| | | super.onCreate(arg0); |
| | | setContentView(R.layout.activity_person_info); |
| | | ll_portrait = (LinearLayout) findViewById(R.id.ll_portrait_select); |
| | | ll_nickName = (LinearLayout) findViewById(R.id.ll_nickName); |
| | | ll_birthday = (LinearLayout) findViewById(R.id.ll_birthday); |
| | | ll_sex = (LinearLayout) findViewById(R.id.ll_sex); |
| | | ll_autograph = (LinearLayout) findViewById(R.id.ll_autograph); |
| | | iv_portrait = (ImageView) findViewById(R.id.iv_portrai_select); |
| | | tv_nickName = (TextView) findViewById(R.id.tv_nickName); |
| | | tv_birthday = (TextView) findViewById(R.id.tv_birthday); |
| | | tv_sex = (TextView) findViewById(R.id.tv_sex); |
| | | tv_autograph = (TextView) findViewById(R.id.tv_autograph); |
| | | |
| | | ll_portrait.setOnClickListener(this); |
| | | ll_nickName.setOnClickListener(this); |
| | | ll_birthday.setOnClickListener(this); |
| | | ll_sex.setOnClickListener(this); |
| | | ll_autograph.setOnClickListener(this); |
| | | findViewById(R.id.tv_back).setOnClickListener(this); |
| | | findViewById(R.id.tv_top_right).setOnClickListener(this); |
| | | getPersonInfo(); |
| | | } |
| | | |
| | | private void getPersonInfo() { |
| | | SharedPreferences sp = getSharedPreferences("user", Context.MODE_PRIVATE); |
| | | String loginUid = sp.getString("LoginUid", ""); |
| | | String uid = sp.getString("uid", ""); |
| | | BaseApiUtil.getPersonInfo(this, uid, loginUid, new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | Glide.with(PersonInfoActivity.this).load(BeibeiConstant.addPreFix(jsonObject.optJSONObject("Data").optString("Portrait"))).placeholder(R.drawable.ic_portrait_default).error(R.drawable.ic_portrait_default).into(iv_portrait); |
| | | tv_nickName.setText(jsonObject.optJSONObject("Data").optString("Nickname")); |
| | | tv_birthday.setText(jsonObject.optJSONObject("Data").optString("Birthday")); |
| | | tv_sex.setText(Integer.parseInt(jsonObject.optJSONObject("Data").optString("Sex")) == 0 ? "女" : "男"); |
| | | tv_autograph.setText(jsonObject.optJSONObject("Data").optString("Sign")); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | String imgBase64 = ""; |
| | | |
| | | @Override |
| | | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| | | // TODO Auto-generated method stub |
| | | super.onActivityResult(requestCode, resultCode, data); |
| | | if (resultCode == Activity.RESULT_OK) { |
| | | Bitmap bm = null; |
| | | bm = SelectPicUtil.onActivityResult(this, requestCode, |
| | | resultCode, data, imgWidth, imgHeight, imgWidth, |
| | | imgHeight); |
| | | |
| | | if (bm != null) { |
| | | if (bm.getByteCount() / 1024 > maxSize) { |
| | | bm = compressImage(bm); |
| | | } |
| | | String path = saveBitmapTofile(bm); |
| | | final File file = new File(path); |
| | | if (!file.exists()) { |
| | | return; |
| | | } |
| | | imgBase64 = bitmapToBase64(bm); |
| | | Log.i("mresult", "图片路劲为:" + path + "----requestcode:" + requestCode); |
| | | Glide.with(PersonInfoActivity.this).load(file).transform(new GlideCircleTransform(PersonInfoActivity.this)).into(iv_portrait); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private String bitmapToBase64(Bitmap bitmap) { |
| | | |
| | | String result = null; |
| | | ByteArrayOutputStream baos = null; |
| | | try { |
| | | if (bitmap != null) { |
| | | baos = new ByteArrayOutputStream(); |
| | | bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); |
| | | |
| | | baos.flush(); |
| | | baos.close(); |
| | | |
| | | byte[] bitmapBytes = baos.toByteArray(); |
| | | result = Base64.encodeToString(bitmapBytes, Base64.DEFAULT); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | if (baos != null) { |
| | | baos.flush(); |
| | | baos.close(); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private String saveBitmapTofile(Bitmap bm) { |
| | | String name = "img.png"; |
| | | File fDir = new File(Environment.getExternalStorageDirectory() + ""); |
| | | if (!fDir.exists()) { |
| | | fDir.mkdir(); |
| | | } |
| | | File picFile = new File(fDir, name); |
| | | try { |
| | | FileOutputStream out = new FileOutputStream(picFile); |
| | | bm.compress(Bitmap.CompressFormat.PNG, 100, out); |
| | | out.flush(); |
| | | out.close(); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return picFile.getPath(); |
| | | } |
| | | |
| | | @SuppressLint("SdCardPath") |
| | | |
| | | private int imgWidth = 400; |
| | | |
| | | private int imgHeight = 400; |
| | | |
| | | private int maxSize = 300; |
| | | |
| | | /* |
| | | * 压缩图片 |
| | | */ |
| | | private Bitmap compressImage(Bitmap image) { |
| | | |
| | | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| | | image.compress(Bitmap.CompressFormat.JPEG, 100, baos);// 质量压缩方法,这里100表示不压缩,把压缩后的数据存放到baos中 |
| | | int options = 100; |
| | | while (baos.toByteArray().length / 1024 > maxSize) { // 循环判断如果压缩后图片是否大于100kb,大于继续压缩 |
| | | baos.reset();// 重置baos即清空baos |
| | | image.compress(Bitmap.CompressFormat.JPEG, options, baos);// 这里压缩options%,把压缩后的数据存放到baos中 |
| | | options -= 10;// 每次都减少10 |
| | | } |
| | | ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());// 把压缩后的数据baos存放到ByteArrayInputStream中 |
| | | Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, null);// 把ByteArrayInputStream数据生成图片 |
| | | return bitmap; |
| | | } |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | int id = v.getId(); |
| | | if (id == R.id.tv_back) { |
| | | finish(); |
| | | } else if (id == R.id.ll_portrait_select) { |
| | | SelectPicUtil.getByAlbum(PersonInfoActivity.this); |
| | | } else if (id == R.id.ll_nickName) { |
| | | getNickName(); |
| | | } else if (id == R.id.ll_birthday) { |
| | | getDate(); |
| | | } else if (id == R.id.ll_sex) { |
| | | getSex(); |
| | | } else if (id == R.id.ll_autograph) {//个性签名 |
| | | getAutograph(); |
| | | } else if (id == R.id.tv_top_right) {//完成个人信息的修改 |
| | | upLoadRegisterData(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 上传个人信息 |
| | | */ |
| | | private void upLoadRegisterData() { |
| | | SharedPreferences sp = getSharedPreferences("user", Context.MODE_PRIVATE); |
| | | String uid = sp.getString("uid", ""); |
| | | String loginUid = sp.getString("LoginUid", ""); |
| | | BaseApiUtil.upLoadPersonInfo(this, uid, loginUid, mSex + "", tv_birthday.getText().toString(), |
| | | tv_autograph.getText().toString(), imgBase64, tv_nickName.getText().toString(), new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | SharedPreferences sharedPreferences = getSharedPreferences("user", Context.MODE_PRIVATE); |
| | | SharedPreferences.Editor editor = sharedPreferences.edit(); |
| | | editor.putString("name", tv_nickName.getText().toString()); |
| | | editor.commit(); |
| | | |
| | | SingleToast.showToast(PersonInfoActivity.this, "个人信息更新成功"); |
| | | finish(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private int mSex = 0; |
| | | |
| | | private void getSex() { |
| | | final String sex[] = new String[]{"女", "男"}; |
| | | new AlertDialog.Builder(this).setTitle("性别选择").setSingleChoiceItems( |
| | | sex, 0, new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | mSex = which; |
| | | } |
| | | }) |
| | | .setPositiveButton("确定", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | Log.i("mResult", "which的值为:" + which); |
| | | tv_sex.setText(sex[mSex]); |
| | | dialog.dismiss(); |
| | | } |
| | | }) |
| | | .setNegativeButton("取消", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | dialog.dismiss(); |
| | | } |
| | | }).show(); |
| | | } |
| | | |
| | | private void getAutograph() { |
| | | View v = LayoutInflater.from(this).inflate(R.layout.item_edit_dialog, null); |
| | | final AlertDialog alertDialog = new AlertDialog.Builder(PersonInfoActivity.this).setView(v).create(); |
| | | alertDialog.show(); |
| | | TextView tv_title = (TextView) v.findViewById(R.id.tv_dialog_title); |
| | | tv_title.setText("个性签名"); |
| | | final EditText et_msg = (EditText) v.findViewById(R.id.et_dialog_message); |
| | | TextView tv_cancel = (TextView) v.findViewById(R.id.tv_cancel); |
| | | TextView tv_confirm = (TextView) v.findViewById(R.id.tv_confirm); |
| | | tv_cancel.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | alertDialog.dismiss(); |
| | | } |
| | | }); |
| | | |
| | | tv_confirm.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | String str = et_msg.getText().toString(); |
| | | if (StringUtils.isEmpty(str)) { |
| | | SingleToast.showToast(PersonInfoActivity.this, "个性签名不能为空"); |
| | | return; |
| | | } else { |
| | | tv_autograph.setText(str); |
| | | alertDialog.dismiss(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | private void getNickName() { |
| | | final EditText et_msg = new EditText(this); |
| | | AlertDialog alertDialog = new AlertDialog.Builder(PersonInfoActivity.this).setView(et_msg).setTitle("昵称修改") |
| | | .setPositiveButton("确定", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | String str = et_msg.getText().toString(); |
| | | if (StringUtils.isEmpty(str)) { |
| | | SingleToast.showToast(PersonInfoActivity.this, "昵称不能为空"); |
| | | } else { |
| | | tv_nickName.setText(str); |
| | | dialog.dismiss(); |
| | | } |
| | | } |
| | | }).setNegativeButton("取消", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | dialog.dismiss(); |
| | | } |
| | | }).create(); |
| | | alertDialog.show(); |
| | | } |
| | | |
| | | /** |
| | | * 获取生日 |
| | | */ |
| | | String date = ""; |
| | | |
| | | private void getDate() { |
| | | View view = LayoutInflater.from(this).inflate(R.layout.item_datepicker, null); |
| | | final AlertDialog alertDialog = new AlertDialog.Builder(PersonInfoActivity.this).setView(view).create(); |
| | | alertDialog.show(); |
| | | DatePicker datePicker = (DatePicker) view.findViewById(R.id.datePicker); |
| | | TextView tv_cancel = (TextView) view.findViewById(R.id.tv_cancel); |
| | | final TextView tv_confirm = (TextView) view.findViewById(R.id.tv_confirm); |
| | | |
| | | Calendar calendar = Calendar.getInstance(); |
| | | int year = calendar.get(Calendar.YEAR); |
| | | int monthOfYear = calendar.get(Calendar.MONTH); |
| | | int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); |
| | | date = year + "/" + monthOfYear + "/" + dayOfMonth; |
| | | datePicker.init(year, monthOfYear, dayOfMonth, new DatePicker.OnDateChangedListener() { |
| | | @Override |
| | | public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) { |
| | | date = year + "/" + (monthOfYear + 1) + "/" + dayOfMonth; |
| | | } |
| | | }); |
| | | tv_cancel.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | alertDialog.dismiss(); |
| | | } |
| | | }); |
| | | tv_confirm.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | tv_birthday.setText(date); |
| | | alertDialog.dismiss(); |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.ui; |
| | | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | | import android.os.Bundle; |
| | | import android.os.Handler; |
| | | import android.os.Message; |
| | | import android.text.Editable; |
| | | import android.text.TextWatcher; |
| | | import android.view.Gravity; |
| | | import android.view.View; |
| | | import android.widget.CheckBox; |
| | | import android.widget.EditText; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.lcjian.library.util.SingleToast; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.yeshi.base.utils.BaseApiUtil; |
| | | import com.yeshi.base.utils.IsEmail; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.yeshi.ec.base.R; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.util.Timer; |
| | | import java.util.TimerTask; |
| | | import java.util.regex.Matcher; |
| | | |
| | | /** |
| | | * Created by weikou2015 on 2016/10/27. |
| | | */ |
| | | |
| | | public class RegisterActivity extends BaseActivity implements |
| | | View.OnClickListener { |
| | | |
| | | private LinearLayout ll_login_content; |
| | | private ImageView iv_register_top; |
| | | private EditText et_email; |
| | | private EditText et_pwd; |
| | | private EditText et_verfication_code; |
| | | private TextView tv_obtain_verfication_code; |
| | | private CheckBox cb_user_agreement; |
| | | private TextView tv_confirm; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle arg0) { |
| | | super.onCreate(arg0); |
| | | setContentView(R.layout.activity_register); |
| | | iv_register_top = (ImageView) findViewById(R.id.iv_register_top); |
| | | et_email = (EditText) findViewById(R.id.et_name); |
| | | et_pwd = (EditText) findViewById(R.id.et_pwd); |
| | | et_verfication_code = (EditText) findViewById(R.id.et_verfication_code); |
| | | tv_obtain_verfication_code = (TextView) findViewById(R.id.tv_obtain_verfication_code); |
| | | cb_user_agreement = (CheckBox) findViewById(R.id.cb_user_agreement); |
| | | tv_confirm = (TextView) findViewById(R.id.tv_confirm); |
| | | ll_login_content = (LinearLayout) findViewById(R.id.ll_login_content); |
| | | |
| | | int w = View.MeasureSpec.makeMeasureSpec(0, |
| | | View.MeasureSpec.UNSPECIFIED); |
| | | int h = View.MeasureSpec.makeMeasureSpec(0, |
| | | View.MeasureSpec.UNSPECIFIED); |
| | | ll_login_content.measure(w, h); |
| | | int width = ll_login_content.getMeasuredWidth(); |
| | | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, |
| | | (int) (width * 0.434)); |
| | | params.gravity = Gravity.CENTER_HORIZONTAL; |
| | | iv_register_top.setLayoutParams(params); |
| | | |
| | | et_email.addTextChangedListener(new TextWatcher() { |
| | | |
| | | @Override |
| | | public void onTextChanged(CharSequence arg0, int arg1, int arg2, |
| | | int arg3) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void beforeTextChanged(CharSequence arg0, int arg1, |
| | | int arg2, int arg3) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable arg0) { |
| | | // et_email.getText().toString() |
| | | if (!StringUtils.isEmpty(et_verfication_code.getText() |
| | | .toString()) |
| | | && !StringUtils.isEmpty(et_pwd.getText().toString()) |
| | | && !StringUtils.isEmpty(arg0.toString())) { |
| | | tv_confirm.setBackground(getResources().getDrawable( |
| | | R.drawable.shape_login2)); |
| | | } else { |
| | | tv_confirm.setBackground(getResources().getDrawable( |
| | | R.drawable.shape_login1)); |
| | | } |
| | | |
| | | if (!StringUtils.isEmpty(arg0.toString())) { |
| | | tv_obtain_verfication_code.setBackground(getResources() |
| | | .getDrawable(R.drawable.shape_login2)); |
| | | } else { |
| | | tv_obtain_verfication_code.setBackground(getResources() |
| | | .getDrawable(R.drawable.shape_login1)); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | et_verfication_code.addTextChangedListener(new TextWatcher() { |
| | | |
| | | @Override |
| | | public void onTextChanged(CharSequence arg0, int arg1, int arg2, |
| | | int arg3) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void beforeTextChanged(CharSequence arg0, int arg1, |
| | | int arg2, int arg3) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable arg0) { |
| | | if (!StringUtils.isEmpty(et_email.getText().toString()) |
| | | && !StringUtils.isEmpty(et_pwd.getText().toString()) |
| | | && !StringUtils.isEmpty(arg0.toString())) { |
| | | tv_confirm.setBackground(getResources().getDrawable( |
| | | R.drawable.shape_login2)); |
| | | } else { |
| | | tv_confirm.setBackground(getResources().getDrawable( |
| | | R.drawable.shape_login1)); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | |
| | | et_pwd.addTextChangedListener(new TextWatcher() { |
| | | |
| | | @Override |
| | | public void onTextChanged(CharSequence arg0, int arg1, int arg2, |
| | | int arg3) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void beforeTextChanged(CharSequence arg0, int arg1, |
| | | int arg2, int arg3) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable arg0) { |
| | | if (!StringUtils.isEmpty(et_verfication_code.getText() |
| | | .toString()) |
| | | && !StringUtils.isEmpty(et_email.getText().toString()) |
| | | && !StringUtils.isEmpty(arg0.toString())) { |
| | | tv_confirm.setBackground(getResources().getDrawable( |
| | | R.drawable.shape_login2)); |
| | | } else { |
| | | tv_confirm.setBackground(getResources().getDrawable( |
| | | R.drawable.shape_login1)); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | tv_obtain_verfication_code.setOnClickListener(this); |
| | | tv_confirm.setOnClickListener(this); |
| | | findViewById(R.id.tv_back).setOnClickListener(this); |
| | | findViewById(R.id.tv_user_agreement).setOnClickListener(this); |
| | | } |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | int id = v.getId(); |
| | | if (id == R.id.tv_back) { |
| | | finish(); |
| | | } else if (id == R.id.tv_user_agreement) { |
| | | Intent intent = new Intent(RegisterActivity.this, |
| | | BrowserActivity.class); |
| | | intent.putExtra("url", getString(R.string.agreement)); |
| | | startActivity(intent); |
| | | } else if (id == R.id.tv_obtain_verfication_code) { |
| | | String email = et_email.getText().toString(); |
| | | if (StringUtils.isEmpty(email)) { |
| | | SingleToast.showToast(RegisterActivity.this, "请先输入邮箱账号"); |
| | | } else { |
| | | Matcher m = IsEmail.isEmailAddress().matcher(email); |
| | | if (m.matches()) { |
| | | getVerficationCode(email); |
| | | } else { |
| | | SingleToast.showToast(RegisterActivity.this, |
| | | "输入的邮箱账号有误,请查证!"); |
| | | return; |
| | | } |
| | | } |
| | | } else if (id == R.id.tv_confirm) { |
| | | String email1 = et_email.getText().toString(); |
| | | String pwd = et_pwd.getText().toString(); |
| | | String verficationCode = et_verfication_code.getText().toString(); |
| | | if (StringUtils.isEmpty(email1)) { |
| | | SingleToast.showToast(RegisterActivity.this, "请先输入邮箱账号"); |
| | | return; |
| | | } else { |
| | | Matcher m = IsEmail.isEmailAddress().matcher(email1); |
| | | if (!m.matches()) { |
| | | SingleToast.showToast(RegisterActivity.this, |
| | | "输入的邮箱账号有误,请查证!"); |
| | | return; |
| | | } |
| | | } |
| | | if (StringUtils.isEmpty(pwd)) { |
| | | SingleToast.showToast(RegisterActivity.this, "密码不能为空"); |
| | | return; |
| | | } |
| | | if (pwd.length() < 6) { |
| | | SingleToast.showToast(RegisterActivity.this, "密码长度不能低于6位"); |
| | | return; |
| | | } |
| | | if (StringUtils.isEmpty(verficationCode)) { |
| | | SingleToast.showToast(RegisterActivity.this, "验证码不能为空"); |
| | | return; |
| | | } |
| | | userRegister(); |
| | | } |
| | | } |
| | | |
| | | private void userRegister() { |
| | | SharedPreferences sp = getSharedPreferences("user", |
| | | Context.MODE_PRIVATE); |
| | | final String uid = sp.getString("uid", ""); |
| | | BaseApiUtil.emailRegister(this, uid, et_email.getText().toString(), |
| | | et_pwd.getText().toString(), et_verfication_code.getText() |
| | | .toString(), "无名氏", new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | SingleToast.showToast(RegisterActivity.this, |
| | | "注册成功!"); |
| | | emailLogin(et_email.getText().toString(), et_pwd |
| | | .getText().toString(), uid); |
| | | } else { |
| | | SingleToast.showToast(RegisterActivity.this, |
| | | jsonObject.optString("Error") + ",注册失败!"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, |
| | | String responseString, Throwable throwable) { |
| | | super.onFailure(statusCode, headers, responseString, |
| | | throwable); |
| | | SingleToast.showToast(RegisterActivity.this, |
| | | "注册失败,请重新注册"); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 注册成功后登陆,获取登录信息 |
| | | */ |
| | | /** |
| | | * Email登陆 |
| | | */ |
| | | private void emailLogin(String email, String pwd, String uid) { |
| | | BaseApiUtil.emailLogin(RegisterActivity.this, uid, email, pwd, |
| | | new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | SharedPreferences sp = getSharedPreferences("user", |
| | | MODE_PRIVATE); |
| | | SharedPreferences.Editor edit = sp.edit(); |
| | | edit.putString("portrait", jsonObject |
| | | .optJSONObject("Data") |
| | | .optString("Portrait")); |
| | | edit.putString("LoginUid", jsonObject |
| | | .getJSONObject("Data").getString("Id")); |
| | | edit.putString( |
| | | "name", |
| | | jsonObject.optJSONObject("Data").optString( |
| | | "NickName")); |
| | | edit.commit(); |
| | | SingleToast |
| | | .showToast(RegisterActivity.this, "登陆成功"); |
| | | Intent intent = new Intent(RegisterActivity.this, |
| | | PersonInfoActivity.class); |
| | | startActivity(intent); |
| | | finish(); |
| | | } else { |
| | | SingleToast |
| | | .showToast(RegisterActivity.this, "登陆失败"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, |
| | | String responseString, Throwable throwable) { |
| | | super.onFailure(statusCode, headers, responseString, |
| | | throwable); |
| | | SingleToast.showToast(RegisterActivity.this, "登陆失败"); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | Timer timer; |
| | | int timecount = 59; |
| | | |
| | | private void getVerficationCode(String email) { |
| | | timer = new Timer(); |
| | | timer.schedule(new MyTask(), 1000, 1000); |
| | | SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE); |
| | | String uid = sp.getString("uid", ""); |
| | | BaseApiUtil.getVerficationCode(RegisterActivity.this, uid, email, |
| | | new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | SingleToast.showToast(RegisterActivity.this, |
| | | "获取验证码成功,请打开邮箱查看!"); |
| | | } else { |
| | | SingleToast.showToast(RegisterActivity.this, |
| | | "获取验证码失败,请重新获取!"); |
| | | handler.sendEmptyMessage(1); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | class MyTask extends TimerTask { |
| | | @Override |
| | | public void run() { |
| | | if (timecount > 0) { |
| | | handler.sendEmptyMessage(0); |
| | | } else { |
| | | handler.sendEmptyMessage(1); |
| | | } |
| | | } |
| | | } |
| | | |
| | | Handler handler = new Handler() { |
| | | @Override |
| | | public void handleMessage(Message msg) { |
| | | super.handleMessage(msg); |
| | | switch (msg.what) { |
| | | case 0: |
| | | tv_obtain_verfication_code.setClickable(false); |
| | | tv_obtain_verfication_code.setText("重新发送(" + timecount + "s)"); |
| | | timecount--; |
| | | break; |
| | | case 1: |
| | | timer.cancel(); |
| | | tv_obtain_verfication_code.setText("获取验证码"); |
| | | tv_obtain_verfication_code.setClickable(true); |
| | | timecount = 59; |
| | | break; |
| | | } |
| | | } |
| | | }; |
| | | } |
New file |
| | |
| | | package com.yeshi.base.ui.dialog; |
| | | |
| | | import android.app.Dialog; |
| | | import android.content.Context; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.widget.TextView; |
| | | |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.yeshi.ec.base.R; |
| | | |
| | | /** |
| | | * 用户协议弹框 |
| | | */ |
| | | public class LoadingDialogUtil { |
| | | |
| | | private static Dialog pd; |
| | | |
| | | public static void show(Context context) { |
| | | show(context, "", false); |
| | | } |
| | | |
| | | public static void show(Context context, String msg, boolean cancelable) { |
| | | try { |
| | | dismiss(); |
| | | //拿到dialog |
| | | pd = getLoadingDialog(context, msg); |
| | | //设置点击外围是否消失 |
| | | pd.setCancelable(cancelable); |
| | | pd.show(); |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | |
| | | //这里的加载效果自己随意定义 |
| | | public static Dialog getLoadingDialog(Context context, String msg) { |
| | | Dialog loading_dialog = new Dialog(context, R.style.Dialog); |
| | | View view = LayoutInflater.from(context).inflate(R.layout.dialog_loading, null); |
| | | TextView tv_msg = view.findViewById(R.id.tv_msg); |
| | | if (StringUtils.isEmpty(msg)) { |
| | | tv_msg.setVisibility(View.GONE); |
| | | } else { |
| | | tv_msg.setText(msg); |
| | | tv_msg.setVisibility(View.VISIBLE); |
| | | } |
| | | loading_dialog.setContentView(view); |
| | | loading_dialog.getWindow().setBackgroundDrawableResource(R.color.transparent); |
| | | loading_dialog.setCancelable(false); |
| | | return loading_dialog; |
| | | } |
| | | |
| | | |
| | | //在这里直接做了判断,大胆的放心的使用,保证不会出现空指针 |
| | | public static void dismiss() { |
| | | try { |
| | | if (pd != null && pd.isShowing()) { |
| | | pd.dismiss(); |
| | | } |
| | | pd = null; |
| | | } catch (Exception e) { |
| | | // TODO: handle exception |
| | | } finally { |
| | | pd = null; |
| | | } |
| | | } |
| | | |
| | | |
| | | public static boolean isShowing() { |
| | | try { |
| | | if (pd != null) { |
| | | return pd.isShowing(); |
| | | } |
| | | } catch (Exception e) { |
| | | // TODO: handle exception |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 设置dialog点击外部是否可以消失 |
| | | */ |
| | | public static void setCanceledOnTouchOutside(boolean b) { |
| | | try { |
| | | if (pd != null && pd.isShowing()) { |
| | | pd.setCanceledOnTouchOutside(b); |
| | | } |
| | | } catch (Exception e) { |
| | | // TODO: handle exception |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils; |
| | | |
| | | import android.app.Activity; |
| | | import android.util.Log; |
| | | import android.webkit.WebChromeClient; |
| | | import android.webkit.WebResourceRequest; |
| | | import android.webkit.WebView; |
| | | import android.webkit.WebViewClient; |
| | | import android.widget.Toast; |
| | | |
| | | import com.alibaba.android.arouter.launcher.ARouter; |
| | | import com.alibaba.baichuan.android.trade.AlibcTrade; |
| | | import com.alibaba.baichuan.android.trade.callback.AlibcTradeCallback; |
| | | import com.alibaba.baichuan.android.trade.model.AlibcShowParams; |
| | | import com.alibaba.baichuan.android.trade.model.OpenType; |
| | | import com.alibaba.baichuan.trade.biz.applink.adapter.AlibcFailModeType; |
| | | import com.alibaba.baichuan.trade.biz.context.AlibcTradeResult; |
| | | import com.alibaba.baichuan.trade.biz.core.taoke.AlibcTaokeParams; |
| | | import com.yeshi.base.utils.downutil.ApkUtil; |
| | | |
| | | import java.util.HashMap; |
| | | |
| | | /** |
| | | * 百川交易工具 |
| | | */ |
| | | public class AlibcTradeUtil { |
| | | private final static String TAG = "AlibcTradeUtil"; |
| | | |
| | | /** |
| | | * 用阿里百川打开链接 |
| | | * |
| | | * @param activity |
| | | * @param url |
| | | * @param webView |
| | | * @param webViewClient |
| | | * @param webChromeClient |
| | | * @param showParams |
| | | * @param taokeParams |
| | | * @param callback |
| | | */ |
| | | public static void openByUrl(Activity activity, String url, WebView webView, WebViewClient webViewClient, WebChromeClient webChromeClient, AlibcShowParams showParams, AlibcTaokeParams taokeParams, AlibcTradeCallback callback) { |
| | | if (showParams == null) { |
| | | showParams = new AlibcShowParams(); |
| | | } |
| | | |
| | | showParams.setOpenType(OpenType.Native); |
| | | showParams.setDegradeUrl("https://mos.m.taobao.com/activity_newer?from=pub&pid=mm_124933865_56750082_10647300249"); |
| | | // if (webView == null) |
| | | showParams.setNativeOpenFailedMode(AlibcFailModeType.AlibcNativeFailModeJumpDOWNLOAD); |
| | | //设置返回小把手 |
| | | showParams.setBackUrl("alisdk://"); |
| | | // taokeParams = null; |
| | | final Activity context = activity; |
| | | try { |
| | | if (callback != null) |
| | | AlibcTrade.openByUrl(activity, "", url, webView, |
| | | webViewClient, webChromeClient, showParams, |
| | | taokeParams, null, callback); |
| | | else |
| | | AlibcTrade.openByUrl(activity, "", url, webView, |
| | | webViewClient, webChromeClient, showParams, |
| | | taokeParams, new HashMap<String, String>(), new AlibcTradeCallback() { |
| | | @Override |
| | | public void onTradeSuccess(AlibcTradeResult alibcTradeResult) { |
| | | Log.i("AlibcTradeUtil", alibcTradeResult.toString()); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int i, String s) { |
| | | Log.i("AlibcTradeUtil", i + ":" + s); |
| | | if (i == -1) { |
| | | Toast.makeText(context, s, Toast.LENGTH_LONG).show(); |
| | | } |
| | | } |
| | | }); |
| | | } catch (Error e) { |
| | | |
| | | } |
| | | //如果未安装手机淘宝 |
| | | if (!ApkUtil.checkAPP(context, "com.taobao.taobao")) { |
| | | Toast.makeText(context, "请安装手机淘宝", Toast.LENGTH_SHORT).show(); |
| | | ARouter.getInstance().build(RouteConstant.PATH_WEB_BROWSER).withString("url", url).navigation(); |
| | | } |
| | | } |
| | | |
| | | |
| | | public static void openAuthLink(Activity activity, String authUrl) { |
| | | AlibcShowParams showParams = new AlibcShowParams(); |
| | | showParams.setOpenType(OpenType.Auto); |
| | | showParams.setNativeOpenFailedMode(AlibcFailModeType.AlibcNativeFailModeJumpDOWNLOAD); |
| | | //设置返回小把手 |
| | | showParams.setBackUrl("alisdk://"); |
| | | Log.i(TAG, "openAuthLink-start"); |
| | | |
| | | WebViewClient client = new WebViewClient() { |
| | | @Override |
| | | public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { |
| | | Log.i(TAG, "shouldOverrideUrlLoading"); |
| | | return super.shouldOverrideUrlLoading(view, request); |
| | | } |
| | | |
| | | @Override |
| | | public boolean shouldOverrideUrlLoading(WebView view, String url) { |
| | | Log.i(TAG, url); |
| | | return super.shouldOverrideUrlLoading(view, url); |
| | | } |
| | | }; |
| | | |
| | | // WebView webView=new WebView(activity); |
| | | |
| | | AlibcTrade.openByUrl(activity, "", authUrl, null, |
| | | client, null, showParams, |
| | | null, null, new AlibcTradeCallback() { |
| | | @Override |
| | | public void onTradeSuccess(AlibcTradeResult alibcTradeResult) { |
| | | Log.i(TAG, alibcTradeResult.toString()); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int i, final String s) { |
| | | Log.i(TAG, "失败回调:" + s); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils; |
| | | |
| | | import android.content.Context; |
| | | |
| | | import com.loopj.android.http.ResponseHandlerInterface; |
| | | import com.yeshi.base.utils.http.API; |
| | | |
| | | import java.util.LinkedHashMap; |
| | | |
| | | import static com.yeshi.base.utils.http.API.BASE_URL; |
| | | import static com.yeshi.base.utils.http.API.commonPost; |
| | | |
| | | public class BaseApiUtil { |
| | | |
| | | /** |
| | | * 修改密码 |
| | | * |
| | | * @param context |
| | | * @param uid |
| | | * @param handler |
| | | */ |
| | | public static void revisePwd(Context context, String uid, String email, |
| | | String verfycode, String pwd, ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("Method", "setPwd"); |
| | | params.put("Uid", uid); |
| | | params.put("Email", email); |
| | | params.put("Pwd", pwd); |
| | | params.put("VerifyCode", verfycode); |
| | | commonPost(context, API.BASE_URL + "user", params, handler); |
| | | } |
| | | |
| | | /** |
| | | * 获取验证码 |
| | | * |
| | | * @param context |
| | | * @param uid |
| | | * @param handler |
| | | */ |
| | | public static void getVerficationCode(Context context, String uid, |
| | | String name, ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("Method", "sendVerifyCode"); |
| | | params.put("Uid", uid); |
| | | params.put("Email", name); |
| | | commonPost(context, API.BASE_URL + "user", params, handler); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 用户登录 |
| | | * |
| | | * @param context |
| | | * @param uid 用户uid |
| | | * @param name 用户名称 |
| | | * @param openId 用户第三方登录唯一识别码 |
| | | * @param portrait 头像 |
| | | * @param sex 性别 |
| | | * @param loginType 登录类型:1 QQ |
| | | * @param handler |
| | | */ |
| | | public static void userLogin(Context context, String uid, String name, |
| | | String openId, String portrait, String sex, String loginType, |
| | | ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("Method", "userLogin"); |
| | | params.put("Uid", uid); |
| | | params.put("Name", name); |
| | | params.put("OpenId", openId); |
| | | params.put("Portrait", portrait); |
| | | params.put("Sex", sex); |
| | | params.put("LoginType", loginType); |
| | | commonPost(context, API.BASE_URL + "comment", params, handler); |
| | | } |
| | | |
| | | /** |
| | | * 用户登录 |
| | | * |
| | | * @param context |
| | | * @param uid 用户uid |
| | | * @param name 用户名称 |
| | | * @param openId 用户第三方登录唯一识别码 |
| | | * @param portrait 头像 |
| | | * @param sex 性别 |
| | | * @param loginType 登录类型:1 QQ |
| | | * @param handler |
| | | */ |
| | | public static void userLogin(Context context, String uid, String name, |
| | | String openId, String portrait, String sex, String province, |
| | | String city, String loginType, ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("Method", "userLogin"); |
| | | params.put("Uid", uid); |
| | | params.put("Name", name); |
| | | params.put("OpenId", openId); |
| | | params.put("Portrait", portrait); |
| | | params.put("Province", province); |
| | | params.put("City", city); |
| | | params.put("Sex", sex); |
| | | params.put("LoginType", loginType); |
| | | commonPost(context, BASE_URL + "comment", params, handler); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Email登陆 |
| | | * |
| | | * @param context |
| | | * @param uid |
| | | * @param handler |
| | | */ |
| | | public static void emailLogin(Context context, String uid, String name, |
| | | String pwd, ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("Method", "login"); |
| | | params.put("Uid", uid); |
| | | params.put("Email", name); |
| | | params.put("Pwd", pwd); |
| | | commonPost(context, BASE_URL + "user", params, handler); |
| | | } |
| | | |
| | | public static void emailRegister(Context context, String uid, String email, |
| | | String pwd, String verficationCode, String name, |
| | | ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("Method", "register"); |
| | | params.put("Uid", uid); |
| | | params.put("Email", email); |
| | | params.put("Pwd", pwd); |
| | | params.put("VerifyCode", verficationCode); |
| | | params.put("NickName", name); |
| | | commonPost(context, BASE_URL + "user", params, handler); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取个人信息 |
| | | * |
| | | * @param context |
| | | * @param uid |
| | | * @param handler |
| | | */ |
| | | public static void getPersonInfo(Context context, String uid, |
| | | String loginUid, ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("Method", "getLoginUserInfo"); |
| | | params.put("Uid", uid); |
| | | params.put("LoginUid", loginUid); |
| | | commonPost(context, BASE_URL + "user", params, handler); |
| | | } |
| | | |
| | | /** |
| | | * 上传个人信息 |
| | | * |
| | | * @param context |
| | | * @param uid |
| | | * @param handler |
| | | */ |
| | | public static void upLoadPersonInfo(Context context, String uid, |
| | | String loginUid, String sex, String birthday, String personSign, |
| | | String portrait, String nickName, ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("Method", "updateLoginUserInfo"); |
| | | params.put("Uid", uid); |
| | | params.put("LoginUid", loginUid); |
| | | params.put("Sex", sex); |
| | | params.put("BirthDay", birthday); |
| | | params.put("PersonalSign", personSign); |
| | | params.put("Portrait", portrait); |
| | | params.put("NickName", nickName); |
| | | commonPost(context, BASE_URL + "user", params, handler); |
| | | } |
| | | |
| | | |
| | | public static void getThirdVideoRequest(Context context, String uid, |
| | | String videoDetailId, String url, String step, String data, |
| | | ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("Method", "getThirdVideoRequest"); |
| | | params.put("Uid", uid); |
| | | params.put("Id", videoDetailId); |
| | | params.put("Url", url); |
| | | params.put("Step", step); |
| | | params.put("Data", data); |
| | | commonPost(context, BASE_URL + "other", params, null, handler, false); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils; |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Intent; |
| | | import android.webkit.JavascriptInterface; |
| | | import android.widget.Toast; |
| | | |
| | | import com.alibaba.baichuan.android.trade.model.AlibcShowParams; |
| | | import com.alibaba.baichuan.android.trade.model.OpenType; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.google.gson.Gson; |
| | | import com.lcjian.library.util.SystemCommon; |
| | | import com.lcjian.library.util.common.ClipboardUtil; |
| | | import com.lcjian.library.util.common.PackageUtils2; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.lcjian.library.util.security.MD5Utils; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.yeshi.base.utils.http.API; |
| | | |
| | | import org.json.JSONException; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.Map; |
| | | |
| | | import static android.content.Context.MODE_PRIVATE; |
| | | |
| | | public class BaseBWJavaInterface { |
| | | |
| | | Activity mContext; |
| | | |
| | | public BaseBWJavaInterface(Activity activity) { |
| | | mContext = activity; |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public String getUid() { |
| | | return mContext.getSharedPreferences("user", MODE_PRIVATE).getString("LoginUid", ""); |
| | | } |
| | | |
| | | |
| | | @JavascriptInterface |
| | | public String getVersion() { |
| | | return PackageUtils2.getVersionCode(mContext) + ""; |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public void toast(String str) { |
| | | Toast.makeText(mContext, str, Toast.LENGTH_LONG).show(); |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public String getSign(String str) { |
| | | return MD5Utils.getMD532(str + "@?,223Hbb88lll"); |
| | | } |
| | | |
| | | |
| | | @JavascriptInterface |
| | | public void jumpBaiChuan(String tbClientInfo, String url, String auctionId) { |
| | | AlibcShowParams alibcShowParams = new AlibcShowParams(); |
| | | alibcShowParams.setOpenType(OpenType.Auto); |
| | | JumpActivityUtil.jumpBaiChuan(mContext, tbClientInfo, url, auctionId, alibcShowParams); |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public void copyText(String atr) { |
| | | ClipboardUtil.copy(mContext, atr); |
| | | } |
| | | |
| | | |
| | | @JavascriptInterface |
| | | public void jumpPage(String pageClassName, String paramJson) { |
| | | Intent intent = null; |
| | | JSONObject param = null; |
| | | try { |
| | | if (StringUtils.isEmpty(paramJson)) { |
| | | param = null; |
| | | } else { |
| | | param = new JSONObject(paramJson); |
| | | } |
| | | if (StringUtils.isEmpty(pageClassName)) { |
| | | return; |
| | | } else { |
| | | intent = new Intent(mContext, Class.forName(JumpActivityUtil.filterActivityName(pageClassName))); |
| | | } |
| | | } catch (JSONException e) { |
| | | param = null; |
| | | e.printStackTrace(); |
| | | } catch (ClassNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (null != param) { |
| | | @SuppressWarnings("unchecked") |
| | | Iterator<String> its = param.keys(); |
| | | while (its.hasNext()) { |
| | | String key = its.next(); |
| | | String value = param.optString(key); |
| | | intent.putExtra(key, value); |
| | | } |
| | | } |
| | | mContext.startActivity(intent); |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public String getRequestBaseParams(String json) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<>(); |
| | | int version = PackageUtils2.getVersionCode(mContext); |
| | | if (!StringUtils.isEmpty(json)) { |
| | | JSONObject jsonObject = null; |
| | | try { |
| | | jsonObject = new JSONObject(json); |
| | | Iterator<String> iterator = jsonObject.keys(); |
| | | while (iterator.hasNext()) { |
| | | String key = iterator.next(); |
| | | params.put(key, jsonObject.optString(key)); |
| | | } |
| | | } catch (JSONException e) { |
| | | |
| | | } |
| | | } |
| | | |
| | | params.put("Package", mContext.getPackageName()); |
| | | params.put("Version", version + ""); |
| | | params.put("Device", SystemCommon.getDeviceId(mContext)); |
| | | params.put("Time", System.currentTimeMillis() + ""); |
| | | LinkedHashMap<String, String> map = API.validateParams(params,mContext); |
| | | |
| | | Gson gson = new Gson(); |
| | | String str = gson.toJson(map); |
| | | return str; |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public void umEventCount(String eventId, String paramsJSON) { |
| | | Map map = JSON.parseObject(paramsJSON); |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public void umEventCompute(String eventId, String paramsJSON, int du) { |
| | | Map map = JSON.parseObject(paramsJSON); |
| | | MobclickAgent.onEventValue(mContext, eventId, map, du); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 清空粘贴板 |
| | | */ |
| | | @JavascriptInterface |
| | | public void clearClipboard() { |
| | | ClipboardUtil.emptyClipboard(mContext); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils; |
| | | |
| | | public class BeibeiConstant { |
| | | public static final String HOST = "http://api.ysdq.yeshitv.com:8089"; |
| | | |
| | | // public static final String HOST = "http://192.168.1.200:8088"; |
| | | |
| | | // public static final String HOST = "http://192.168.1.122:8080"; |
| | | |
| | | /** |
| | | * @return true为没有连接代理服务器,false为连接了代理服务器,禁止访问请求服务器 |
| | | */ |
| | | public static boolean isDisableProxy() { |
| | | String proHost = null;// 代理主机 |
| | | int proPort = -1;// 端口号 |
| | | try { |
| | | proHost = android.net.Proxy.getDefaultHost(); |
| | | proPort = android.net.Proxy.getDefaultPort(); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | // return StringUtils.isEmpty(proHost) && proPort == -1; |
| | | return true;// 测试时关闭代理限制 |
| | | } |
| | | |
| | | public static final String QQ_ID = "1104492673"; |
| | | public static final String QQ_KEY = "AI6ri4IcDhsacEoP"; |
| | | |
| | | |
| | | public static final String BAICHUAN_APPKEY = "24980167"; |
| | | public static final String BAICHUAN_PID = "mm_124933865_56750082_19509850457"; |
| | | public static final String BAICHUAN_ADZONE_ID = BAICHUAN_PID.split("_")[3]; |
| | | |
| | | public static final boolean DEBUG = false; |
| | | public static final boolean ISHUAWEI = true; |
| | | public static boolean ADSHOW = true; |
| | | |
| | | /** |
| | | * 头像获取路劲可能不完整,需要手动添加完整 |
| | | * |
| | | * @param path |
| | | * @return |
| | | */ |
| | | public static String addPreFix(String path) { |
| | | if (path.contains("http")) { |
| | | return path; |
| | | } else { |
| | | path = HOST + "/BuWan" + path; |
| | | return path; |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils; |
| | | |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * Created by weikou2015 on 2016/10/27. |
| | | */ |
| | | |
| | | public class IsEmail { |
| | | public static Pattern isEmailAddress() { |
| | | Pattern p = Pattern.compile("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\\.([a-zA-Z0-9_-])+)+$"); |
| | | return p; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils; |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.webkit.WebChromeClient; |
| | | import android.webkit.WebViewClient; |
| | | |
| | | import com.alibaba.baichuan.android.trade.AlibcTrade; |
| | | import com.alibaba.baichuan.android.trade.AlibcTradeSDK; |
| | | import com.alibaba.baichuan.android.trade.callback.AlibcTradeCallback; |
| | | import com.alibaba.baichuan.android.trade.model.AlibcShowParams; |
| | | import com.alibaba.baichuan.android.trade.model.OpenType; |
| | | import com.alibaba.baichuan.android.trade.page.AlibcDetailPage; |
| | | import com.alibaba.baichuan.trade.biz.AlibcConstants; |
| | | import com.alibaba.baichuan.trade.biz.applink.adapter.AlibcFailModeType; |
| | | import com.alibaba.baichuan.trade.biz.context.AlibcTradeResult; |
| | | import com.alibaba.baichuan.trade.biz.core.taoke.AlibcTaokeParams; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.yeshi.base.entity.JumpDetail; |
| | | import com.yeshi.base.utils.downutil.StringUtils; |
| | | |
| | | import org.json.JSONException; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | |
| | | |
| | | public class JumpActivityUtil { |
| | | |
| | | public static void jumpActivity(Context mContext, |
| | | JumpDetail jumpDetail, JSONObject params) { |
| | | Intent intent = null; |
| | | org.json.JSONObject object = null; |
| | | try { |
| | | intent = new Intent(mContext, Class.forName(JumpActivityUtil.filterActivityName(jumpDetail.getActivity()))); |
| | | if (params != null) |
| | | object = new org.json.JSONObject(params); |
| | | } catch (ClassNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (object != null) { |
| | | @SuppressWarnings("unchecked") |
| | | Iterator<String> its = object.keys(); |
| | | while (its.hasNext()) { |
| | | String key = its.next(); |
| | | String value = object.optString(key); |
| | | intent.putExtra(key, value); |
| | | } |
| | | } |
| | | mContext.startActivity(intent); |
| | | } |
| | | |
| | | public static void jumpBaiChuan(Activity mActivity, String tbClientInfo, String url, String auctionId, AlibcShowParams alibcShowParams) { |
| | | AlibcTaokeParams alibcTaokeParams = null; |
| | | Map<String, String> exParams = new HashMap<>(); |
| | | exParams.put(AlibcConstants.ISV_CODE, "appisvcode"); |
| | | exParams.put("alibaba", "阿里巴巴");//自定义参数部分,可任意增删改 |
| | | |
| | | if (!StringUtils.isNullOrEmpty(tbClientInfo)) { |
| | | alibcTaokeParams = new AlibcTaokeParams("", "", ""); |
| | | alibcTaokeParams.setPid(BeibeiConstant.BAICHUAN_PID); |
| | | org.json.JSONObject object = null; |
| | | try { |
| | | object = new org.json.JSONObject(tbClientInfo); |
| | | } catch (JSONException e) { |
| | | |
| | | } |
| | | String pid = object.optString("pid"); |
| | | String appKey = object.optString("appKey"); |
| | | String adZoneId = object.optString("adZoneId"); |
| | | alibcTaokeParams.setPid(pid); |
| | | alibcTaokeParams.setAdzoneid(adZoneId); |
| | | alibcTaokeParams.pid = pid; |
| | | alibcTaokeParams.adzoneid = adZoneId; |
| | | alibcTaokeParams.extraParams = new HashMap<>(); |
| | | alibcTaokeParams.extraParams.put("taokeAppkey", appKey); |
| | | } else { |
| | | alibcTaokeParams = new AlibcTaokeParams("", "", ""); |
| | | alibcTaokeParams.setPid(BeibeiConstant.BAICHUAN_PID); |
| | | alibcTaokeParams.setAdzoneid(BeibeiConstant.BAICHUAN_ADZONE_ID); |
| | | alibcTaokeParams.pid = BeibeiConstant.BAICHUAN_PID; |
| | | alibcTaokeParams.adzoneid = BeibeiConstant.BAICHUAN_ADZONE_ID; |
| | | alibcTaokeParams.extraParams = new HashMap<>(); |
| | | alibcTaokeParams.extraParams.put("taokeAppkey", BeibeiConstant.BAICHUAN_APPKEY); |
| | | } |
| | | |
| | | if (!StringUtils.isNullOrEmpty(url)) { |
| | | AlibcTradeUtil.openByUrl(mActivity, |
| | | url, null, new WebViewClient(), new WebChromeClient(), |
| | | alibcShowParams, alibcTaokeParams, null); |
| | | |
| | | } else { |
| | | AlibcDetailPage basePage = new AlibcDetailPage(auctionId); |
| | | AlibcTrade.openByBizCode(mActivity, basePage, null, |
| | | new WebViewClient(), new WebChromeClient(), "nativeDetail", alibcShowParams, |
| | | alibcTaokeParams, null, new AlibcTradeCallback() { |
| | | |
| | | @Override |
| | | public void onTradeSuccess(AlibcTradeResult alibcTradeResult) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int i, String s) { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 跳转 |
| | | * |
| | | * @param context |
| | | * @param detail |
| | | * @param params |
| | | */ |
| | | public static void jumpPage(final Activity context, JumpDetail detail, JSONObject params) { |
| | | if (context == null) |
| | | return; |
| | | if (detail == null) |
| | | return; |
| | | |
| | | String type = detail.getType(); |
| | | switch (type) { |
| | | case "baichuan": |
| | | if (params == null) |
| | | return; |
| | | String url = params.getString("url"); |
| | | if (StringUtils.isNullOrEmpty(url)) |
| | | return; |
| | | |
| | | //跳转百川 |
| | | AlibcShowParams alibcShowParams = new AlibcShowParams(); |
| | | alibcShowParams.setOpenType(OpenType.Auto); |
| | | alibcShowParams.setNativeOpenFailedMode(AlibcFailModeType.AlibcNativeFailModeJumpBROWER); |
| | | // AlibcTrade.openByUrl(GoodsDetailActivityTB.this, "", |
| | | // url, null, new WebViewClient(), new WebChromeClient(), |
| | | // alibcShowParams, alibcTaokeParams, exParams, new MiDuoTradeCallback("")); |
| | | |
| | | AlibcTaokeParams alibcTaokeParams = new AlibcTaokeParams("", "", ""); |
| | | alibcTaokeParams.setPid(BeibeiConstant.BAICHUAN_PID); |
| | | alibcTaokeParams.setAdzoneid(BeibeiConstant.BAICHUAN_ADZONE_ID); |
| | | alibcTaokeParams.pid = BeibeiConstant.BAICHUAN_PID; |
| | | alibcTaokeParams.adzoneid = BeibeiConstant.BAICHUAN_ADZONE_ID; |
| | | alibcTaokeParams.extraParams = new HashMap<>(); |
| | | alibcTaokeParams.extraParams.put("taokeAppkey", BeibeiConstant.BAICHUAN_APPKEY); |
| | | |
| | | AlibcTradeSDK.setTaokeParams(alibcTaokeParams); |
| | | AlibcTradeUtil.openByUrl(context, |
| | | url, null, new WebViewClient(), new WebChromeClient(), |
| | | alibcShowParams, alibcTaokeParams, null); |
| | | break; |
| | | |
| | | default: { |
| | | try { |
| | | Intent intent = new Intent(context, Class.forName(JumpActivityUtil.filterActivityName(detail.getActivity()))); |
| | | if (params != null) |
| | | for (Iterator<String> keys = params.keySet().iterator(); keys.hasNext(); ) { |
| | | String key = keys.next(); |
| | | intent.putExtra(key, params.getString(key)); |
| | | } |
| | | context.startActivity(intent); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | public static String filterActivityName(String activity) { |
| | | if (activity == null) |
| | | return null; |
| | | return activity; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils; |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Intent; |
| | | import android.content.pm.PackageManager; |
| | | import android.webkit.JavascriptInterface; |
| | | import android.widget.ImageView; |
| | | import android.widget.TextView; |
| | | |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.tencent.smtt.sdk.WebView; |
| | | |
| | | import org.json.JSONException; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.util.Iterator; |
| | | |
| | | import androidx.core.content.ContextCompat; |
| | | |
| | | public class MGJavaInterface extends BaseBWJavaInterface { |
| | | |
| | | Activity mContext; |
| | | TextView tv_top_bar_middle, tv_top_bar_left2, tv_top_bar_right; |
| | | ImageView iv_right; |
| | | WebView webview; |
| | | |
| | | public MGJavaInterface(Activity activity, WebView webview) { |
| | | super(activity); |
| | | mContext = activity; |
| | | this.webview = webview; |
| | | } |
| | | |
| | | public MGJavaInterface(Activity activity, TextView tv_top_bar_middle |
| | | , TextView tv_top_bar_left2, TextView tv_top_bar_right |
| | | , ImageView iv_right, WebView webview) { |
| | | super(activity); |
| | | mContext = activity; |
| | | this.tv_top_bar_middle = tv_top_bar_middle; |
| | | this.tv_top_bar_left2 = tv_top_bar_left2; |
| | | this.tv_top_bar_right = tv_top_bar_right; |
| | | this.iv_right = iv_right; |
| | | this.webview = webview; |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public void setTitle(final String title) { |
| | | // tv_top_bar_middle.setText(title); |
| | | if (tv_top_bar_middle != null) |
| | | tv_top_bar_middle.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (null != title && !StringUtils.isEmpty(title.trim())) |
| | | tv_top_bar_middle.setText(title); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | @JavascriptInterface |
| | | public void jumpPageWithFinishCurrentPage(String pageClassName, String paramJson) { |
| | | Intent intent = null; |
| | | JSONObject param = null; |
| | | try { |
| | | if (StringUtils.isEmpty(paramJson)) { |
| | | param = null; |
| | | } else { |
| | | param = new JSONObject(paramJson); |
| | | } |
| | | if (StringUtils.isEmpty(pageClassName)) { |
| | | return; |
| | | } else { |
| | | intent = new Intent(mContext, Class.forName(JumpActivityUtil.filterActivityName(pageClassName))); |
| | | } |
| | | } catch (JSONException e) { |
| | | param = null; |
| | | e.printStackTrace(); |
| | | } catch (ClassNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (null != param) { |
| | | @SuppressWarnings("unchecked") |
| | | Iterator<String> its = param.keys(); |
| | | while (its.hasNext()) { |
| | | String key = its.next(); |
| | | String value = param.optString(key); |
| | | intent.putExtra(key, value); |
| | | } |
| | | } |
| | | mContext.startActivity(intent); |
| | | mContext.finish(); |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public void finishPage() { |
| | | mContext.runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | mContext.finish(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 淘宝授权 |
| | | * |
| | | * @param url |
| | | */ |
| | | @JavascriptInterface |
| | | public void tbAuth(String url) { |
| | | if (StringUtils.isEmpty(url)) |
| | | return; |
| | | AlibcTradeUtil.openAuthLink(mContext, url); |
| | | } |
| | | |
| | | // 判断权限集合 是否授权 false授权 true未授权 |
| | | public boolean lacksPermissions(String... permissions) { |
| | | for (String permission : permissions) { |
| | | if (lacksPermission(permission)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | // 判断是否缺少权限 |
| | | private boolean lacksPermission(String permission) { |
| | | //权限未授权 |
| | | return ContextCompat.checkSelfPermission(mContext, permission) == PackageManager.PERMISSION_DENIED; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils; |
| | | |
| | | public class RouteConstant { |
| | | |
| | | |
| | | public final static String PATH_USER_LOGIN = "/user/login"; |
| | | |
| | | public final static String PATH_WEB_BROWSER = "/web/browser"; |
| | | |
| | | public final static String PATH_VIDEO_SEARCH_RESULT = "/video/search/result"; |
| | | |
| | | public final static String PATH_VIDEO_DETAIL = "/video/detail"; |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils; |
| | | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.os.Environment; |
| | | import android.os.StatFs; |
| | | |
| | | |
| | | import com.yeshi.base.entity.SDCardEntity; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.File; |
| | | import java.io.InputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class SDCardUtil { |
| | | |
| | | public static long getAvailableInternalMemorySize() { |
| | | File path = Environment.getDataDirectory(); |
| | | StatFs stat = new StatFs(path.getPath()); |
| | | long blockSize = stat.getBlockSize(); |
| | | long availableBlocks = stat.getAvailableBlocks(); |
| | | return availableBlocks * blockSize; |
| | | } |
| | | |
| | | public static long getTotalInternalMemorySize() { |
| | | File path = Environment.getDataDirectory(); |
| | | StatFs stat = new StatFs(path.getPath()); |
| | | long blockSize = stat.getBlockSize(); |
| | | long totalBlocks = stat.getBlockCount(); |
| | | return totalBlocks * blockSize; |
| | | } |
| | | |
| | | public static boolean externalMemoryAvailable() { |
| | | return Environment.getExternalStorageState().equals( |
| | | Environment.MEDIA_MOUNTED); |
| | | } |
| | | |
| | | public static long getAvailableExternalMemorySize() { |
| | | if (externalMemoryAvailable()) { |
| | | File path = Environment.getExternalStorageDirectory(); |
| | | StatFs stat = new StatFs(path.getPath()); |
| | | long blockSize = stat.getBlockSize(); |
| | | long availableBlocks = stat.getAvailableBlocks(); |
| | | return availableBlocks * blockSize; |
| | | } else { |
| | | return -1; |
| | | } |
| | | } |
| | | |
| | | public static long getTotalExternalMemorySize() { |
| | | if (externalMemoryAvailable()) { |
| | | File path = Environment.getExternalStorageDirectory(); |
| | | StatFs stat = new StatFs(path.getPath()); |
| | | long blockSize = stat.getBlockSize(); |
| | | long totalBlocks = stat.getBlockCount(); |
| | | return totalBlocks * blockSize; |
| | | } else { |
| | | return -1; |
| | | } |
| | | } |
| | | |
| | | public static List getExtSDCardPath() { |
| | | List lResult = new ArrayList(); |
| | | try { |
| | | Runtime rt = Runtime.getRuntime(); |
| | | Process proc = rt.exec("mount"); |
| | | InputStream is = proc.getInputStream(); |
| | | InputStreamReader isr = new InputStreamReader(is); |
| | | BufferedReader br = new BufferedReader(isr); |
| | | String line; |
| | | while ((line = br.readLine()) != null) { |
| | | if (line.contains("extSdCard")) { |
| | | String[] arr = line.split(" "); |
| | | String path = arr[1]; |
| | | File file = new File(path); |
| | | if (file.isDirectory()) { |
| | | lResult.add(path); |
| | | } |
| | | } |
| | | } |
| | | isr.close(); |
| | | } catch (Exception e) { |
| | | } |
| | | return lResult; |
| | | } |
| | | |
| | | public static String getSotrageSize(long size) { |
| | | |
| | | if (size >= 1024) { |
| | | float s = ((float) size / 1024); |
| | | return (new java.text.DecimalFormat("#.00").format(s)) + "GB"; |
| | | } else { |
| | | return size + "MB"; |
| | | } |
| | | } |
| | | |
| | | @SuppressWarnings("deprecation") |
| | | private static SDCardEntity getSDCardEntity(String path) { |
| | | SDCardEntity se = new SDCardEntity(); |
| | | se.setPath(path); |
| | | try { |
| | | File ff = new File(path); |
| | | if (!ff.exists()) |
| | | ff.mkdirs(); |
| | | StatFs stat = new StatFs(path); |
| | | long blockSize = stat.getBlockSize(); |
| | | long availableBlocks = stat.getAvailableBlocks(); |
| | | long totalBlocks = stat.getBlockCount(); |
| | | se.setAvailableSize(availableBlocks * blockSize); |
| | | se.setTotalSize(totalBlocks * blockSize); |
| | | } catch (Exception e) { |
| | | File f = new File(path); |
| | | if (f.exists()) { |
| | | se.setAvailableSize(f.getFreeSpace()); |
| | | se.setTotalSize(f.getTotalSpace()); |
| | | } |
| | | } |
| | | return se; |
| | | } |
| | | |
| | | /** |
| | | * 获取外部存储卡 |
| | | * |
| | | * @param context |
| | | * @return |
| | | */ |
| | | public static SDCardEntity getSDCardPath(Context context) { |
| | | SDCardEntity entity = new SDCardEntity(); |
| | | // if (PackageUtils2.getAndroidOSVersion() > 9) { |
| | | StorageList list = new StorageList(context); |
| | | String[] sts = list.getVolumePaths(); |
| | | if (sts == null || sts.length == 0) |
| | | return null; |
| | | else { |
| | | if (sts[0].equalsIgnoreCase(Environment.MEDIA_MOUNTED)) { |
| | | entity = getSDCardEntity(sts[0]); |
| | | if (entity.getTotalSize() > 0) |
| | | return entity; |
| | | } else if (sts.length > 1) { |
| | | entity.setPath(sts[1]); |
| | | entity = getSDCardEntity(sts[1]); |
| | | if (entity.getTotalSize() > 0) |
| | | return entity; |
| | | } else |
| | | return null; |
| | | } |
| | | /* |
| | | * } else { if (Environment.getStorageState(Environment.) |
| | | * .equals(Environment.MEDIA_MOUNTED)) { // 为true的话,外置sd卡存在 } } |
| | | */ |
| | | |
| | | return null; |
| | | } |
| | | |
| | | public static void setDeaultStorage(Context context, int type) { |
| | | SharedPreferences share = context.getSharedPreferences("storagestate", |
| | | Context.MODE_PRIVATE); |
| | | SharedPreferences.Editor editor = share.edit(); |
| | | editor.putInt("stro", type); |
| | | editor.commit(); |
| | | } |
| | | |
| | | public static void initStorage(Context context) { |
| | | SharedPreferences share = context.getSharedPreferences("storagestate", |
| | | Context.MODE_PRIVATE); |
| | | if (!share.getBoolean("StorageSetting", false)) |
| | | return; |
| | | SDCardEntity entity = getSDCardPath(context); |
| | | if (entity != null) { |
| | | if (entity.getAvailableSize() > getAvailableExternalMemorySize()) { |
| | | setDeaultStorage(context, STORAGE_SDCARD); |
| | | } |
| | | } |
| | | SharedPreferences.Editor editor = share.edit(); |
| | | editor.putBoolean("StorageSetting", true); |
| | | editor.commit(); |
| | | |
| | | } |
| | | |
| | | public static int getDeaultStorage(Context context) { |
| | | SharedPreferences share = context.getSharedPreferences("storagestate", |
| | | Context.MODE_PRIVATE); |
| | | return share.getInt("stro", 0); |
| | | } |
| | | |
| | | public static String getDownLoadPath(Context context) { |
| | | String name = context.getPackageName(); |
| | | int type = getDeaultStorage(context); |
| | | if (type == STORAGE_MOBILE) { |
| | | // 下载文件存放到根目录 Download文件夹下 |
| | | // File f = Environment |
| | | // .getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); |
| | | |
| | | // 下载文件存放到app安装目录下 |
| | | File f = context.getExternalFilesDir("木瓜缓存文件"); |
| | | // File f = context.getExternalCacheDir(); |
| | | if (f == null) { |
| | | f = Environment |
| | | .getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); |
| | | } |
| | | if (!f.exists()) |
| | | f.mkdirs(); |
| | | return f.getPath() + "/"; |
| | | } else if (type == STORAGE_SDCARD) { |
| | | SDCardEntity entity = getSDCardPath(context); |
| | | if (entity == null) { |
| | | File f = Environment |
| | | .getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); |
| | | if (!f.exists()) |
| | | f.mkdirs(); |
| | | return f.getPath() + "/"; |
| | | } |
| | | String root = entity.getPath(); |
| | | if (!new File(root + File.separator + name).exists()) |
| | | new File(root + File.separator + name).mkdirs(); |
| | | if (!new File(root + File.separator + name + File.separator |
| | | + "video").exists()) |
| | | new File(root + File.separator + name + File.separator |
| | | + "video").mkdirs(); |
| | | return root + File.separator + name + File.separator + "video"; |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | public static SDCardEntity getDownLoadEntity(Context context) { |
| | | |
| | | String path = getDownLoadPath(context); |
| | | return getSDCardEntity(path); |
| | | } |
| | | |
| | | public final static int STORAGE_SDCARD = 1; |
| | | public final static int STORAGE_MOBILE = 0; |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils; |
| | | |
| | | import java.io.FileNotFoundException; |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.BitmapFactory; |
| | | import android.net.Uri; |
| | | import android.os.Environment; |
| | | import android.provider.MediaStore; |
| | | import android.widget.Toast; |
| | | |
| | | /** |
| | | * 选择本地图片工具类 <br> |
| | | * 因为直接获取图片容易崩溃,所以直接存入SD卡,再获取 <br> |
| | | * 又因为写法不正确容易导致部分机型无法使用,所以封装起来复用 <br> |
| | | * 使用方法: <br> |
| | | * 1、调用getByAlbum、getByCamera去获取图片 <br> |
| | | * 2、在onActivityResult中调用本工具类的onActivityResult方法进行处理 <br> |
| | | * 3、onActivityResult返回的Bitmap记得空指针判断 |
| | | * |
| | | * <br> |
| | | * <br> |
| | | * PS:本工具类只能处理裁剪图片,如果不想裁剪,不使用本工具类的onActivityResult,自己做处理即可 |
| | | * |
| | | * @author linin630 |
| | | * |
| | | */ |
| | | public class SelectPicUtil { |
| | | |
| | | /** 临时存放图片的地址,如需修改,请记得创建该路径下的文件夹 */ |
| | | private static final String lsimg = "file:///sdcard/temp.jpg"; |
| | | |
| | | public static final int GET_BY_ALBUM = 801;// 如果有冲突,记得修改 |
| | | public static final int GET_BY_CAMERA = 802;// 如果有冲突,记得修改 |
| | | public static final int CROP = 803;// 如果有冲突,记得修改 |
| | | |
| | | /** 从相册获取图片 */ |
| | | public static void getByAlbum(Activity act) { |
| | | Intent getAlbum = new Intent(Intent.ACTION_GET_CONTENT); |
| | | getAlbum.setType("image/*"); |
| | | act.startActivityForResult(getAlbum, GET_BY_ALBUM); |
| | | } |
| | | |
| | | /** 通过拍照获取图片 */ |
| | | public static void getByCamera(Activity act) { |
| | | String state = Environment.getExternalStorageState(); |
| | | if (state.equals(Environment.MEDIA_MOUNTED)) { |
| | | Intent getImageByCamera = new Intent( |
| | | MediaStore.ACTION_IMAGE_CAPTURE); |
| | | getImageByCamera |
| | | .putExtra(MediaStore.EXTRA_OUTPUT, Uri.parse(lsimg)); |
| | | getImageByCamera.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); |
| | | act.startActivityForResult(getImageByCamera, GET_BY_CAMERA); |
| | | } else { |
| | | Toast.makeText(act, "请确认已经插入SD卡", Toast.LENGTH_LONG).show(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理获取的图片,注意判断空指针,默认大小480*480,比例1:1 |
| | | */ |
| | | public static Bitmap onActivityResult(Activity act, int requestCode, |
| | | int resultCode, Intent data) { |
| | | return onActivityResult(act, requestCode, resultCode, data, 0, 0, 0, 0); |
| | | } |
| | | |
| | | /** |
| | | * 处理获取的图片,注意判断空指针 |
| | | */ |
| | | public static Bitmap onActivityResult(Activity act, int requestCode, |
| | | int resultCode, Intent data, int w, int h, int aspectX, int aspectY) { |
| | | Bitmap bm = null; |
| | | if (resultCode == Activity.RESULT_OK) { |
| | | Uri uri = null; |
| | | switch (requestCode) { |
| | | case GET_BY_ALBUM: |
| | | uri = data.getData(); |
| | | act.startActivityForResult(crop(uri, w, h, aspectX, aspectY), |
| | | CROP); |
| | | break; |
| | | case GET_BY_CAMERA: |
| | | uri = Uri.parse(lsimg); |
| | | act.startActivityForResult(crop(uri, w, h, aspectX, aspectY), |
| | | CROP); |
| | | break; |
| | | case CROP: |
| | | bm = dealCrop(act); |
| | | break; |
| | | } |
| | | } |
| | | return bm; |
| | | } |
| | | |
| | | /** 默认裁剪输出480*480,比例1:1 */ |
| | | public static Intent crop(Uri uri) { |
| | | return crop(uri, 480, 480, 1, 1); |
| | | } |
| | | |
| | | /** |
| | | * 裁剪,例如:输出100*100大小的图片,宽高比例是1:1 |
| | | * |
| | | * @param w |
| | | * 输出宽 |
| | | * @param h |
| | | * 输出高 |
| | | * @param aspectX |
| | | * 宽比例 |
| | | * @param aspectY |
| | | * 高比例 |
| | | */ |
| | | public static Intent crop(Uri uri, int w, int h, int aspectX, int aspectY) { |
| | | if (w == 0 && h == 0) { |
| | | w = h = 480; |
| | | } |
| | | if (aspectX == 0 && aspectY == 0) { |
| | | aspectX = aspectY = 1; |
| | | } |
| | | Intent intent = new Intent("com.android.camera.action.CROP"); |
| | | // 照片URL地址 |
| | | intent.setDataAndType(uri, "image/*"); |
| | | intent.putExtra("crop", "true"); |
| | | intent.putExtra("aspectX", aspectX); |
| | | intent.putExtra("aspectY", aspectY); |
| | | intent.putExtra("outputX", w); |
| | | intent.putExtra("outputY", h); |
| | | // 输出路径 |
| | | intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.parse(lsimg)); |
| | | // 输出格式 |
| | | intent.putExtra("outputFormat", "JPEG"); |
| | | // 不启用人脸识别 |
| | | intent.putExtra("noFaceDetection", true); |
| | | intent.putExtra("return-data", false); |
| | | return intent; |
| | | } |
| | | |
| | | /** 处理裁剪,获取裁剪后的图片 */ |
| | | public static Bitmap dealCrop(Context context) { |
| | | // 裁剪返回 |
| | | Uri uri = Uri.parse(lsimg); |
| | | Bitmap bitmap = null; |
| | | try { |
| | | bitmap = BitmapFactory.decodeStream(context.getContentResolver() |
| | | .openInputStream(uri)); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return bitmap; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils; |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Context; |
| | | import android.os.storage.StorageManager; |
| | | |
| | | import java.lang.reflect.Method; |
| | | |
| | | public class StorageList { |
| | | private Context context; |
| | | private StorageManager mStorageManager; |
| | | private Method mMethodGetPaths; |
| | | |
| | | public StorageList(Context context) { |
| | | this.context = context; |
| | | if (context != null) { |
| | | mStorageManager = (StorageManager) context |
| | | .getSystemService(Activity.STORAGE_SERVICE); |
| | | try { |
| | | mMethodGetPaths = mStorageManager.getClass().getMethod( |
| | | "getVolumePaths"); |
| | | } catch (NoSuchMethodException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public String[] getVolumePaths() { |
| | | String[] paths = null; |
| | | try { |
| | | |
| | | paths = (String[]) mMethodGetPaths.invoke(mStorageManager); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // catch (IllegalAccessException e) { |
| | | // e.printStackTrace(); |
| | | // } catch (InvocationTargetException e) { |
| | | // e.printStackTrace(); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | return paths; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils; |
| | | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.Locale; |
| | | |
| | | import android.util.Log; |
| | | |
| | | public class TimeUtils { |
| | | /** |
| | | * |
| | | * @param millis |
| | | * 要转化的毫秒数。 |
| | | * @param isWhole |
| | | * 是否强制全部显示小时/分。 |
| | | * @param isFormat |
| | | * 时间数字是否要格式化,如果true:少位数前面补全;如果false:少位数前面不补全。 |
| | | * @return 返回时间字符串:小时/分/秒/毫秒的格式(如:24903600 --> 06小时55分钟)。 |
| | | */ |
| | | public static String millisToStringShort(long millis, boolean isWhole, |
| | | boolean isFormat) { |
| | | String h = ""; |
| | | String m = ""; |
| | | if (isWhole) { |
| | | h = isFormat ? "00小时" : "0小时"; |
| | | m = isFormat ? "00分钟" : "0分钟"; |
| | | } |
| | | |
| | | long temp = millis; |
| | | |
| | | long hper = 60 * 60 * 1000; |
| | | long mper = 60 * 1000; |
| | | long sper = 1000; |
| | | |
| | | if (temp / hper > 0) { |
| | | if (isFormat) { |
| | | h = temp / hper < 10 ? "0" + temp / hper : temp / hper + ""; |
| | | } else { |
| | | h = temp / hper + ""; |
| | | } |
| | | h += "小时"; |
| | | } |
| | | temp = temp % hper; |
| | | |
| | | if (temp / mper > 0) { |
| | | if (isFormat) { |
| | | m = temp / mper < 10 ? "0" + temp / mper : temp / mper + ""; |
| | | } else { |
| | | m = temp / mper + ""; |
| | | } |
| | | m += "分钟"; |
| | | } |
| | | |
| | | return h + m; |
| | | } |
| | | |
| | | /** |
| | | * @param millis |
| | | * 要转化的日期毫秒数。 |
| | | * @param pattern |
| | | * 要转化为的字符串格式(如:yyyy-MM-dd HH:mm:ss)。 |
| | | * @return 返回日期字符串。 |
| | | */ |
| | | public static String millisToStringDate(long millis, String pattern) { |
| | | SimpleDateFormat format = new SimpleDateFormat(pattern, |
| | | Locale.getDefault()); |
| | | return format.format(new Date(millis)); |
| | | } |
| | | |
| | | /** |
| | | * @param millis |
| | | * 要转化的日期毫秒数。 |
| | | * @param pattern |
| | | * 要转化为的字符串格式(如:yyyy-MM-dd HH:mm:ss)。 |
| | | * @return 返回日期字符串(yyyy_MM_dd_HH_mm_ss)。 |
| | | */ |
| | | public static String millisToStringFilename(long millis, String pattern) { |
| | | String dateStr = millisToStringDate(millis, pattern); |
| | | return dateStr.replaceAll("[- :]", "_"); |
| | | } |
| | | |
| | | public static long oneHourMillis = 60 * 60 * 1000; // 一小时的毫秒数 |
| | | public static long oneDayMillis = 24 * oneHourMillis; // 一天的毫秒数 |
| | | public static long oneYearMillis = 365 * oneDayMillis; // 一年的毫秒数 |
| | | |
| | | /** |
| | | * 1小时内用,多少分钟前; 超过1小时,显示时间而无日期; 如果是昨天,则显示昨天 超过昨天再显示日期; 超过1年再显示年。 |
| | | * |
| | | * @param millis |
| | | * @return |
| | | */ |
| | | public static String millisToLifeString(long millis) { |
| | | long now = System.currentTimeMillis(); |
| | | long todayStart = string2Millis(millisToStringDate(now, "yyyy-MM-dd"), |
| | | "yyyy-MM-dd"); |
| | | |
| | | // 一小时内 |
| | | if (now - millis <= oneHourMillis && now - millis > 0l) { |
| | | String m = millisToStringShort(now - millis, false, false); |
| | | return "".equals(m) ? "1分钟内" : m + "前"; |
| | | } |
| | | |
| | | // 大于今天开始开始值,小于今天开始值加一天(即今天结束值) |
| | | if (millis >= todayStart && millis <= oneDayMillis + todayStart) { |
| | | return "今天 " + millisToStringDate(millis, "HH:mm"); |
| | | } |
| | | |
| | | // 大于(今天开始值减一天,即昨天开始值) |
| | | if (millis > todayStart - oneDayMillis) { |
| | | return "一天前 "; |
| | | } |
| | | |
| | | if (millis > todayStart - oneDayMillis - oneDayMillis) { |
| | | return "二天前 "; |
| | | } |
| | | if (millis > todayStart - oneDayMillis - oneDayMillis - oneDayMillis) { |
| | | return "三天前 "; |
| | | } |
| | | |
| | | long thisYearStart = string2Millis(millisToStringDate(now, "yyyy"), |
| | | "yyyy"); |
| | | // 大于今天小于今年 |
| | | // if (millis > thisYearStart) { |
| | | // return millisToStringDate(millis, "MM月dd日HH:mm"); |
| | | // } |
| | | // return millisToStringDate(millis, "yyyy年MM月dd日HH:mm"); |
| | | return millisToStringDate(millis, "yyyy年MM月dd日HH:mm"); |
| | | } |
| | | |
| | | /** |
| | | * 字符串解析成毫秒数 |
| | | * |
| | | * @param str |
| | | * @param pattern |
| | | * @return |
| | | */ |
| | | public static long string2Millis(String str, String pattern) { |
| | | SimpleDateFormat format = new SimpleDateFormat(pattern, |
| | | Locale.getDefault()); |
| | | long millis = 0; |
| | | try { |
| | | millis = format.parse(str).getTime(); |
| | | } catch (ParseException e) { |
| | | Log.e("TAG", e.getMessage()); |
| | | } |
| | | return millis; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.ad; |
| | | |
| | | public enum AdTypeEnum { |
| | | gdt("广点通"), csj("穿山甲"), gdt2("广点通2.0"); |
| | | |
| | | private String name; |
| | | |
| | | private AdTypeEnum(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.ad; |
| | | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.yeshi.base.entity.ad.AdPositionEnum; |
| | | |
| | | import org.json.JSONException; |
| | | import org.json.JSONObject; |
| | | |
| | | //广告帮助 |
| | | public class AdUtil { |
| | | |
| | | public enum AD_TYPE { |
| | | gdt("广点通"), csj("穿山甲"), gdt2("广点通2.0"); |
| | | |
| | | private String name; |
| | | |
| | | private AD_TYPE(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 保存广告配置 |
| | | * |
| | | * @param context |
| | | * @param json |
| | | */ |
| | | public static void saveAdConfig(Context context, JSONObject json) { |
| | | SharedPreferences share = context.getSharedPreferences("adConfig", Context.MODE_PRIVATE); |
| | | SharedPreferences.Editor editor = share.edit(); |
| | | editor.putString("config", json.toString()); |
| | | editor.commit(); |
| | | } |
| | | |
| | | /** |
| | | * 获取广告类型 |
| | | * |
| | | * @param context |
| | | * @param position |
| | | * @return |
| | | */ |
| | | public static AdTypeEnum getAdType(Context context, AdPositionEnum position) { |
| | | SharedPreferences share = context.getSharedPreferences("adConfig", Context.MODE_PRIVATE); |
| | | String config = share.getString("config", ""); |
| | | if (!StringUtils.isEmpty(config)) {//万一没设置起就用广点通 |
| | | try { |
| | | JSONObject object = new JSONObject(config); |
| | | object = object.optJSONObject(position.getPositionName()); |
| | | if (object != null) |
| | | return AdTypeEnum.valueOf(object.optString("type")); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } catch (Exception e1) { |
| | | return null; |
| | | } |
| | | } else { |
| | | return AdTypeEnum.gdt; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static String getAdPid(Context context, AdPositionEnum position) { |
| | | SharedPreferences share = context.getSharedPreferences("adConfig", Context.MODE_PRIVATE); |
| | | String config = share.getString("config", ""); |
| | | if (!StringUtils.isEmpty(config)) {//万一没设置起就用广点通 |
| | | try { |
| | | JSONObject object = new JSONObject(config); |
| | | object = object.optJSONObject(position.getPositionName()); |
| | | if (object != null) |
| | | return object.optString("pid"); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } catch (Exception e1) { |
| | | return null; |
| | | } |
| | | } else { |
| | | return null; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.ad; |
| | | |
| | | public class CSJConstant { |
| | | public final static String APP_ID="5115334"; |
| | | |
| | | |
| | | //视频详情 |
| | | public static String CODE_FULL_VIDEO_VIDEO_DETAIL = "945573782"; |
| | | |
| | | //首页大广告 |
| | | public static String RECOMMEND_BIG_IMG_AD = "946360135"; |
| | | |
| | | //开屏广告 |
| | | public static String SPLASH_AD = "887396145"; |
| | | |
| | | //开屏广告热启动 |
| | | public static String SPLASH_AD_HOT = "887455481"; |
| | | |
| | | //软件退出广告 |
| | | public static String APP_EXIT = "945469133"; |
| | | |
| | | //视频前贴 |
| | | public static String PLAY_VIDEO_PRE = "945379614"; |
| | | |
| | | //视频详情页视频播放器底部 |
| | | public static String VIDEO_DETAIL_PLAYER_BOTTOM = "945548900"; |
| | | |
| | | //视频详情页猜你喜欢底部 |
| | | public static String VIDEO_DETAIL_GUESSLIKE_TOP = "945548915"; |
| | | |
| | | //视频搜索页 |
| | | public static String VIDEO_SEARCH = "945552227"; |
| | | |
| | | //PPTV激励视频 |
| | | public static String VIDEO_REWARD_PPTV = "945914112"; |
| | | |
| | | |
| | | //影视豆激励视频 |
| | | public static String GOLDCORN_REWARD_PPTV = "946039290"; |
| | | |
| | | |
| | | //无效广告 |
| | | public static String INVALID_AD = "111111111"; |
| | | |
| | | public static String PPTV_INTERSTITIALAD="946078773"; |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.ad; |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Context; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.FrameLayout; |
| | | |
| | | import com.bytedance.sdk.openadsdk.AdSlot; |
| | | import com.bytedance.sdk.openadsdk.TTAdDislike; |
| | | import com.bytedance.sdk.openadsdk.TTAdManager; |
| | | import com.bytedance.sdk.openadsdk.TTAdNative; |
| | | import com.bytedance.sdk.openadsdk.TTNativeExpressAd; |
| | | import com.lcjian.library.util.common.DimenUtils; |
| | | import com.qq.e.ads.cfg.VideoOption; |
| | | import com.qq.e.ads.nativ.ADSize; |
| | | import com.qq.e.ads.nativ.NativeExpressAD; |
| | | import com.qq.e.ads.nativ.NativeExpressADView; |
| | | import com.qq.e.ads.nativ.express2.AdEventListener; |
| | | import com.qq.e.ads.nativ.express2.NativeExpressAD2; |
| | | import com.qq.e.ads.nativ.express2.NativeExpressADData2; |
| | | import com.qq.e.ads.nativ.express2.VideoOption2; |
| | | import com.qq.e.comm.util.AdError; |
| | | import com.yeshi.base.entity.ad.ExpressAdContainer; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 信息流广告管理 |
| | | */ |
| | | public class ExpressAdManager { |
| | | |
| | | |
| | | final static String TAG = "ExpressAdManager"; |
| | | |
| | | AdUtil.AD_TYPE sourceType = AdUtil.AD_TYPE.gdt; |
| | | |
| | | private TTAdNative mTTAdNative; |
| | | private Context mContext; |
| | | |
| | | |
| | | public ExpressAdManager(AdUtil.AD_TYPE adSource, Context context) { |
| | | sourceType = adSource; |
| | | this.mContext = context; |
| | | if (sourceType == AdUtil.AD_TYPE.csj) { |
| | | TTAdManager ttAdManager = TTAdManagerHolder.get(); |
| | | mTTAdNative = ttAdManager.createAdNative(context); |
| | | // TTAdManagerHolder.get().requestPermissionIfNecessary(context); |
| | | } |
| | | } |
| | | |
| | | public AdUtil.AD_TYPE getSourceType() { |
| | | return sourceType; |
| | | } |
| | | |
| | | //加载小广告 |
| | | |
| | | /** |
| | | * 加载广告 |
| | | * |
| | | * @param widthDP |
| | | * @param heightDP |
| | | * @param count |
| | | * @param adLoadListener |
| | | */ |
| | | public void loadAd(int widthDP, int heightDP, String pid, int count, final IAdLoadListener adLoadListener) { |
| | | if (sourceType == AdUtil.AD_TYPE.gdt) { |
| | | loadGDT(pid, widthDP, heightDP, count, new IGDTAdLoadListener() { |
| | | @Override |
| | | public void onSuccess(List<NativeExpressADView> adList) { |
| | | List<ExpressAdContainer> adContainerList = new ArrayList<>(); |
| | | if (adList != null) |
| | | for (NativeExpressADView adView : adList) { |
| | | adContainerList.add(new ExpressAdContainer(adView)); |
| | | } |
| | | adLoadListener.onSuccess(adContainerList); |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccess2(List<NativeExpressADData2> adList) { |
| | | |
| | | } |
| | | }, mContext); |
| | | } else if (sourceType == AdUtil.AD_TYPE.gdt2) { |
| | | loadGDT2(pid, widthDP, heightDP, count, new IGDTAdLoadListener() { |
| | | @Override |
| | | public void onSuccess(List<NativeExpressADView> adList) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccess2(List<NativeExpressADData2> adList) { |
| | | List<ExpressAdContainer> adContainerList = new ArrayList<>(); |
| | | if (adList != null) |
| | | for (NativeExpressADData2 ad : adList) { |
| | | adContainerList.add(new ExpressAdContainer(ad)); |
| | | } |
| | | adLoadListener.onSuccess(adContainerList); |
| | | } |
| | | }, mContext); |
| | | |
| | | } else if (sourceType == AdUtil.AD_TYPE.csj) { |
| | | loadCSJ(pid, widthDP, heightDP, count, new ICSJAdLoadListener() { |
| | | @Override |
| | | public void onSuccess(List<TTNativeExpressAd> adList) { |
| | | List<ExpressAdContainer> adContainerList = new ArrayList<>(); |
| | | if (adList != null) { |
| | | for (TTNativeExpressAd adView : adList) { |
| | | adContainerList.add(new ExpressAdContainer(adView)); |
| | | } |
| | | } |
| | | adLoadListener.onSuccess(adContainerList); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 加载广点通广告 |
| | | * |
| | | * @param positionId |
| | | * @param count |
| | | * @param adLoadListener |
| | | * @param context |
| | | */ |
| | | private void loadGDT(String positionId, int widthDP, int heightDP, int count, final IGDTAdLoadListener adLoadListener, Context context) { |
| | | |
| | | |
| | | NativeExpressAD nativeExpressAD = new NativeExpressAD(context, new ADSize(ADSize.FULL_WIDTH, ADSize.AUTO_HEIGHT), |
| | | positionId, new NativeExpressAD.NativeExpressADListener() { |
| | | |
| | | @Override |
| | | public void onADLoaded(List<NativeExpressADView> list) { |
| | | if (adLoadListener != null) |
| | | adLoadListener.onSuccess(list); |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderFail(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderSuccess(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADExposure(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADClicked(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADClosed(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADLeftApplication(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADOpenOverlay(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADCloseOverlay(NativeExpressADView nativeExpressADView) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onNoAD(AdError adError) { |
| | | if (adLoadListener != null) |
| | | adLoadListener.onSuccess(null); |
| | | } |
| | | }); // 传入Activity |
| | | nativeExpressAD.setVideoOption(new VideoOption.Builder() |
| | | .setAutoPlayPolicy(VideoOption.AutoPlayPolicy.WIFI) // WIFI 环境下可以自动播放视频 |
| | | .setAutoPlayMuted(true) // 自动播放时为静音 |
| | | .build()); // |
| | | nativeExpressAD.setVideoPlayPolicy(VideoOption.VideoPlayPolicy.AUTO); |
| | | nativeExpressAD.loadAD(count); |
| | | } |
| | | |
| | | /** |
| | | * 2.0版本广点通原生 |
| | | * |
| | | * @param positionId |
| | | * @param widthDP |
| | | * @param heightDP |
| | | * @param count |
| | | * @param adLoadListener |
| | | * @param context |
| | | */ |
| | | private void loadGDT2(String positionId, int widthDP, int heightDP, int count, final IGDTAdLoadListener adLoadListener, Context context) { |
| | | |
| | | Log.i(TAG, String.format("loadGDT2:positionId-%s widthDP-%s heightDP-%s", positionId, widthDP, heightDP)); |
| | | |
| | | NativeExpressAD2 nativeExpressAD2 = new NativeExpressAD2(context, positionId, new NativeExpressAD2.AdLoadListener() { |
| | | @Override |
| | | public void onLoadSuccess(List<NativeExpressADData2> list) { |
| | | if (adLoadListener != null) |
| | | adLoadListener.onSuccess2(list); |
| | | } |
| | | |
| | | @Override |
| | | public void onNoAD(AdError adError) { |
| | | if (adLoadListener != null) |
| | | adLoadListener.onSuccess2(null); |
| | | } |
| | | }); |
| | | |
| | | nativeExpressAD2.setAdSize(widthDP, heightDP); |
| | | VideoOption2.Builder builder = new VideoOption2.Builder(); |
| | | builder.setAutoPlayPolicy(VideoOption2.AutoPlayPolicy.WIFI) // WIFI 环境下可以自动播放视频 |
| | | .setAutoPlayMuted(true) // 自动播放时为静音 |
| | | .setDetailPageMuted(false) // 视频详情页播放时不静音 |
| | | .setMaxVideoDuration(0) // 设置返回视频广告的最大视频时长(闭区间,可单独设置),单位:秒,默认为 0 代表无限制,合法输入为:5<=maxVideoDuration<=60. 此设置会影响广告填充,请谨慎设置 |
| | | .setMinVideoDuration(0); // 设置返回视频广告的最小视频时长(闭区间,可单独设置),单位:秒,默认为 0 代表无限制, 此设置会影响广告填充,请谨慎设置 |
| | | nativeExpressAD2.setVideoOption2(builder.build()); |
| | | nativeExpressAD2.loadAd(count); |
| | | } |
| | | |
| | | /** |
| | | * 穿山甲广告 |
| | | * |
| | | * @param codeId |
| | | * @param width |
| | | * @param height |
| | | * @param count |
| | | * @param adLoadListener |
| | | */ |
| | | private void loadCSJ(String codeId, int width, int height, int count, final ICSJAdLoadListener adLoadListener) { |
| | | count = count > 3 ? 3 : count; |
| | | AdSlot adSlot = new AdSlot.Builder() |
| | | .setCodeId(codeId) |
| | | .setSupportDeepLink(true) |
| | | .setExpressViewAcceptedSize(width, height) |
| | | .setAdCount(count) //请求广告数量为1到3条 |
| | | .build(); |
| | | mTTAdNative.loadNativeExpressAd(adSlot, new TTAdNative.NativeExpressAdListener() { |
| | | @Override |
| | | public void onError(int i, String s) { |
| | | adLoadListener.onSuccess(null); |
| | | } |
| | | |
| | | @Override |
| | | public void onNativeExpressAdLoad(List<TTNativeExpressAd> list) { |
| | | adLoadListener.onSuccess(list); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 渲染模板和填充广告 |
| | | * |
| | | * @param activity |
| | | * @param ad |
| | | * @param fl_ad |
| | | * @param adEventListener |
| | | */ |
| | | public static void renderAndFillAd(Activity activity, final ExpressAdContainer ad, final FrameLayout fl_ad, final IAdEventListener adEventListener) { |
| | | |
| | | if (ad == null) {//广告为空 |
| | | fl_ad.setVisibility(View.GONE); |
| | | } else { |
| | | fl_ad.setVisibility(View.VISIBLE); |
| | | if (ad.getGdt() != null) { |
| | | if (fl_ad.getChildCount() > 0 && fl_ad.getChildAt(0) == ad.getGdt()) { |
| | | return; |
| | | } |
| | | fl_ad.removeAllViews(); |
| | | ad.getGdt().render(); |
| | | if (ad.getGdt().getParent() != null) { |
| | | ((ViewGroup) ad.getGdt().getParent()).removeAllViews(); |
| | | } |
| | | fl_ad.addView(ad.getGdt()); |
| | | } else if (ad.getGdt2() != null) { |
| | | if (fl_ad.getChildCount() > 0 && fl_ad.getChildAt(0) == ad.getGdt2().getAdView()) { |
| | | return; |
| | | } |
| | | fl_ad.removeAllViews(); |
| | | |
| | | ad.getGdt2().setAdEventListener(new AdEventListener() { |
| | | @Override |
| | | public void onClick() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onExposed() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderSuccess() { |
| | | try { |
| | | if (ad.getGdt2().getAdView().getParent() != null) { |
| | | ((ViewGroup) ad.getGdt2().getAdView().getParent()).removeAllViews(); |
| | | } |
| | | fl_ad.addView(ad.getGdt2().getAdView()); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderFail() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onAdClosed() { |
| | | if (adEventListener != null) { |
| | | adEventListener.closeAd(ad); |
| | | } |
| | | } |
| | | }); |
| | | ad.getGdt2().render(); |
| | | |
| | | } else if (ad.getCsj() != null) { |
| | | if (fl_ad.getChildCount() > 0 && fl_ad.getChildAt(0) == ad.getCsj().getExpressAdView()) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | ad.getCsj().setDislikeCallback(activity, new TTAdDislike.DislikeInteractionCallback() { |
| | | |
| | | @Override |
| | | public void onSelected(int i, String s) { |
| | | if (adEventListener != null) { |
| | | adEventListener.closeAd(ad); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onCancel() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onRefuse() { |
| | | |
| | | } |
| | | |
| | | }); |
| | | ad.getCsj().render(); |
| | | if (ad.getCsj().getExpressAdView().getParent() != null) { |
| | | ((ViewGroup) ad.getCsj().getExpressAdView().getParent()).removeAllViews(); |
| | | } |
| | | fl_ad.addView(ad.getCsj().getExpressAdView()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 渲染广告 |
| | | * |
| | | * @param activity |
| | | * @param ad |
| | | * @param adRenderListener |
| | | * @param adEventListener |
| | | */ |
| | | public static void renderAd(Activity activity, final ExpressAdContainer ad, final IAdRenderListener adRenderListener, final IAdEventListener adEventListener) { |
| | | |
| | | if (ad == null) {//广告为空 |
| | | return; |
| | | } |
| | | |
| | | if (ad.getGdt() != null) { |
| | | ad.getGdt().render(); |
| | | List<ExpressAdContainer> list = new ArrayList<>(); |
| | | list.add(ad); |
| | | if (adRenderListener != null) |
| | | adRenderListener.onRenderSuccess(list); |
| | | } else if (ad.getGdt2() != null) { |
| | | ad.getGdt2().setAdEventListener(new AdEventListener() { |
| | | @Override |
| | | public void onClick() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onExposed() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderSuccess() { |
| | | List<ExpressAdContainer> list = new ArrayList<>(); |
| | | list.add(ad); |
| | | if (adRenderListener != null) |
| | | adRenderListener.onRenderSuccess(list); |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderFail() { |
| | | List<ExpressAdContainer> list = new ArrayList<>(); |
| | | list.add(ad); |
| | | if (adRenderListener != null) |
| | | adRenderListener.onRenderFail(list); |
| | | } |
| | | |
| | | @Override |
| | | public void onAdClosed() { |
| | | if (adEventListener != null) |
| | | adEventListener.closeAd(ad); |
| | | } |
| | | }); |
| | | ad.getGdt2().render(); |
| | | |
| | | } else if (ad.getCsj() != null) { |
| | | ad.getCsj().setExpressInteractionListener(new TTNativeExpressAd.ExpressAdInteractionListener() { |
| | | @Override |
| | | public void onAdClicked(View view, int i) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onAdShow(View view, int i) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderFail(View view, String s, int i) { |
| | | List<ExpressAdContainer> list = new ArrayList<>(); |
| | | list.add(ad); |
| | | if (adRenderListener != null) |
| | | adRenderListener.onRenderFail(list); |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderSuccess(View view, float v, float v1) { |
| | | Log.d(TAG, "onRenderSuccess"); |
| | | List<ExpressAdContainer> list = new ArrayList<>(); |
| | | list.add(ad); |
| | | if (adRenderListener != null) |
| | | adRenderListener.onRenderSuccess(list); |
| | | } |
| | | }); |
| | | if (activity != null) |
| | | ad.getCsj().setDislikeCallback(activity, new TTAdDislike.DislikeInteractionCallback() { |
| | | |
| | | @Override |
| | | public void onSelected(int i, String s) { |
| | | if (adEventListener != null) { |
| | | adEventListener.closeAd(ad); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onCancel() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onRefuse() { |
| | | |
| | | } |
| | | |
| | | |
| | | }); |
| | | ad.getCsj().render(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 为广告绑定关闭事件 |
| | | * |
| | | * @param activity |
| | | * @param ad |
| | | * @param adEventListener |
| | | */ |
| | | public static void bindCloseListener(Activity activity, final ExpressAdContainer ad, final IAdEventListener adEventListener) { |
| | | |
| | | if (ad == null) {//广告为空 |
| | | return; |
| | | } |
| | | |
| | | if (ad.getGdt() != null) { |
| | | return; |
| | | } else if (ad.getGdt2() != null) { |
| | | ad.getGdt2().setAdEventListener(new AdEventListener() { |
| | | @Override |
| | | public void onClick() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onExposed() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderSuccess() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderFail() { |
| | | } |
| | | |
| | | @Override |
| | | public void onAdClosed() { |
| | | if (adEventListener != null) |
| | | adEventListener.closeAd(ad); |
| | | } |
| | | }); |
| | | |
| | | } else if (ad.getCsj() != null) { |
| | | ad.getCsj().setExpressInteractionListener(new TTNativeExpressAd.ExpressAdInteractionListener() { |
| | | @Override |
| | | public void onAdClicked(View view, int i) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onAdShow(View view, int i) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderFail(View view, String s, int i) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderSuccess(View view, float v, float v1) { |
| | | |
| | | } |
| | | }); |
| | | ad.getCsj().setDislikeCallback(activity, new TTAdDislike.DislikeInteractionCallback() { |
| | | |
| | | |
| | | @Override |
| | | public void onSelected(int i, String s) { |
| | | if (adEventListener != null) { |
| | | adEventListener.closeAd(ad); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onCancel() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onRefuse() { |
| | | |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 填充广告 |
| | | * |
| | | * @param ad |
| | | * @param fl_ad |
| | | */ |
| | | public static void fillAd(final ExpressAdContainer ad, final FrameLayout fl_ad) { |
| | | |
| | | fl_ad.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (ad == null) {//广告为空 |
| | | fl_ad.setVisibility(View.GONE); |
| | | } else { |
| | | fl_ad.setVisibility(View.VISIBLE); |
| | | if (ad.getGdt() != null) { |
| | | if (fl_ad.getChildCount() > 0 && fl_ad.getChildAt(0) == ad.getGdt()) { |
| | | return; |
| | | } |
| | | if (ad.getGdt().getParent() != null) { |
| | | ((ViewGroup) ad.getGdt().getParent()).removeAllViews(); |
| | | } |
| | | fl_ad.removeAllViews(); |
| | | fl_ad.addView(ad.getGdt()); |
| | | } else if (ad.getGdt2() != null) { |
| | | if (fl_ad.getChildCount() > 0 && fl_ad.getChildAt(0) == ad.getGdt2().getAdView()) { |
| | | return; |
| | | } |
| | | if (ad.getGdt2().getAdView().getParent() != null) { |
| | | ((ViewGroup) ad.getGdt2().getAdView().getParent()).removeAllViews(); |
| | | } |
| | | fl_ad.removeAllViews(); |
| | | fl_ad.addView(ad.getGdt2().getAdView()); |
| | | |
| | | } else if (ad.getCsj() != null) { |
| | | if (fl_ad.getChildCount() > 0 && fl_ad.getChildAt(0) == ad.getCsj().getExpressAdView()) { |
| | | return; |
| | | } |
| | | if (ad.getCsj().getExpressAdView().getParent() != null) { |
| | | ((ViewGroup) ad.getCsj().getExpressAdView().getParent()).removeAllViews(); |
| | | } |
| | | fl_ad.removeAllViews(); |
| | | fl_ad.addView(ad.getCsj().getExpressAdView()); |
| | | } |
| | | } |
| | | if (fl_ad.getChildCount() > 0) { |
| | | fl_ad.getChildAt(0).setVisibility(View.VISIBLE); |
| | | fl_ad.getChildAt(0).post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | interface IGDTAdLoadListener { |
| | | public void onSuccess(List<NativeExpressADView> adList); |
| | | |
| | | public void onSuccess2(List<NativeExpressADData2> adList); |
| | | } |
| | | |
| | | interface ICSJAdLoadListener { |
| | | public void onSuccess(List<TTNativeExpressAd> adList); |
| | | } |
| | | |
| | | |
| | | public interface IAdLoadListener { |
| | | public void onSuccess(List<ExpressAdContainer> adList); |
| | | } |
| | | |
| | | public interface IAdRenderListener { |
| | | public void onRenderSuccess(List<ExpressAdContainer> adList); |
| | | |
| | | public void onRenderFail(List<ExpressAdContainer> adList); |
| | | } |
| | | |
| | | public interface IAdEventListener { |
| | | public void closeAd(ExpressAdContainer ad); |
| | | } |
| | | |
| | | |
| | | public interface IAdShowListener { |
| | | public void show(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.ad; |
| | | |
| | | public class GDTConstant { |
| | | |
| | | public static String GDT_APP_ID = "1106112837"; |
| | | |
| | | public static String GDT_SPLASH_AD_ID = "6081008616843580";// 开屏广告位ID |
| | | |
| | | public static String PID_HOME_RECOMMEND_BIG_IMG = "2002104884851984"; |
| | | |
| | | public static String PID_VIDEO_DETAIL_PLAYER = "5061928359494942"; |
| | | |
| | | public static String PID_SPLASH_HOT = "4081479119572059"; |
| | | //视频播放器下方广告位 |
| | | public static String PID_2_VIDEO_DETAIL_PLAY_EXPRESS1 = "9031528552257617"; |
| | | //相关视频下方广告位 |
| | | public static String PID_2_VIDEO_DETAIL_PLAY_EXPRESS2 = "7091428572856609"; |
| | | //视频列表 - 自渲染 |
| | | public static String PID_2_VIDEO_LIST_SMALL_AD_COLUMN3 = "4061924585347177"; |
| | | //自渲染 |
| | | public static String PID_2_VIDEO_LIST_SMALL_AD_COLUMN2 = "3002604884575372"; |
| | | |
| | | //专辑搜索结果 |
| | | public static String PID_2_SEARCH_RESULT_ALBUM = "4062403844473309"; |
| | | |
| | | |
| | | //PPTV视频前贴 |
| | | public static String PID_2_VIDEO_DETAIL_PLAYER_PRE_PPTV = "5091266068484315"; |
| | | |
| | | //PPTV激励视频 |
| | | public static String PID_2_VIDEO_DETAIL_PLAYER_REWARD_PPTV = "9051467743649673"; |
| | | |
| | | //影视豆激励视频 |
| | | public static String PID_2_GOLDCORN_REWARD = "9051467743649673"; |
| | | |
| | | //退出广告 |
| | | public static String PID_2_EXIT = "6091485426868623"; |
| | | |
| | | //搜索 |
| | | public static final String GDT_HOME_AND_PLAY_BIG_PICTURE = "3041305616723820"; |
| | | |
| | | //视频列表页面 |
| | | public static String GDT_TEMPLATE_SEARCH_RESULT="9071202636920710"; |
| | | |
| | | //APP退出 |
| | | public static final String GDT_EXIT_DIALOG = "8051402676338159"; |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.ad; |
| | | |
| | | import android.content.Context; |
| | | import android.view.View; |
| | | import android.widget.ImageView; |
| | | import android.widget.TextView; |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.qq.e.ads.cfg.VideoOption; |
| | | import com.qq.e.ads.nativ.NativeADUnifiedListener; |
| | | import com.qq.e.ads.nativ.NativeUnifiedAD; |
| | | import com.qq.e.ads.nativ.NativeUnifiedADData; |
| | | import com.qq.e.ads.nativ.widget.NativeAdContainer; |
| | | import com.qq.e.comm.util.AdError; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 广点通自渲染广告 |
| | | */ |
| | | public class GDTNativeADUnifiedManager { |
| | | |
| | | private final static String TAG = "GDTNativeADUnifiedManager"; |
| | | |
| | | public static void loadAD(String position, int count, Context context, final IAdLoadListener adLoadListener) { |
| | | NativeUnifiedAD mAdManager = new NativeUnifiedAD(context, position, new NativeADUnifiedListener() { |
| | | |
| | | @Override |
| | | public void onNoAD(AdError adError) { |
| | | if (adLoadListener != null) |
| | | adLoadListener.onSuccess(null); |
| | | } |
| | | |
| | | @Override |
| | | public void onADLoaded(List<NativeUnifiedADData> list) { |
| | | if (adLoadListener != null) |
| | | adLoadListener.onSuccess(list); |
| | | } |
| | | }); |
| | | mAdManager.setVideoADContainerRender(VideoOption.VideoADContainerRender.SDK); |
| | | mAdManager.loadData(count); |
| | | } |
| | | |
| | | /** |
| | | * 渲染单图广告 |
| | | * |
| | | * @param iv_picture |
| | | * @param tv_title |
| | | * @param adData |
| | | */ |
| | | public static void renderSinglePicture(ImageView iv_picture, TextView tv_title, NativeAdContainer na, final NativeUnifiedADData adData) { |
| | | Glide.with(iv_picture.getContext()).load(adData.getImgUrl()).into(iv_picture); |
| | | tv_title.setText(adData.getTitle()); |
| | | List<View> list = new ArrayList<>(); |
| | | list.add(iv_picture); |
| | | list.add(tv_title); |
| | | adData.bindAdToView(na.getContext(), na, null, list); |
| | | } |
| | | |
| | | |
| | | public interface IAdLoadListener { |
| | | public void onSuccess(List<NativeUnifiedADData> adList); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.ad; |
| | | |
| | | import android.content.Context; |
| | | |
| | | import com.bytedance.sdk.openadsdk.TTAdConfig; |
| | | import com.bytedance.sdk.openadsdk.TTAdConstant; |
| | | import com.bytedance.sdk.openadsdk.TTAdManager; |
| | | import com.bytedance.sdk.openadsdk.TTAdSdk; |
| | | import com.yeshi.ec.base.R; |
| | | |
| | | /** |
| | | * 可以用一个单例来保存TTAdManager实例,在需要初始化sdk的时候调用 |
| | | */ |
| | | public class TTAdManagerHolder { |
| | | |
| | | private static boolean sInit; |
| | | |
| | | |
| | | public static TTAdManager get() { |
| | | if (!sInit) { |
| | | throw new RuntimeException("TTAdSdk is not init, please check."); |
| | | } |
| | | return TTAdSdk.getAdManager(); |
| | | } |
| | | |
| | | public static void init(Context context) { |
| | | doInit(context); |
| | | } |
| | | |
| | | //step1:接入网盟广告sdk的初始化操作,详情见接入文档和穿山甲平台说明 |
| | | private static void doInit(Context context) { |
| | | if (!sInit) { |
| | | try { |
| | | TTAdSdk.init(context, buildConfig(context)); |
| | | sInit = true; |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | private static TTAdConfig buildConfig(Context context) { |
| | | return new TTAdConfig.Builder() |
| | | .appId(CSJConstant.APP_ID) |
| | | .useTextureView(true) //使用TextureView控件播放视频,默认为SurfaceView,当有SurfaceView冲突的场景,可以使用TextureView |
| | | .appName(context.getString(R.string.app_name)) |
| | | .titleBarTheme(TTAdConstant.TITLE_BAR_THEME_DARK) |
| | | .allowShowNotify(true) //是否允许sdk展示通知栏提示 |
| | | .allowShowPageWhenScreenLock(true) //是否在锁屏场景支持展示广告落地页 |
| | | .debug(true) //测试阶段打开,可以通过日志排查问题,上线时去除该调用 |
| | | .directDownloadNetworkType(TTAdConstant.NETWORK_STATE_WIFI) |
| | | .supportMultiProcess(true)//是否支持多进程 |
| | | .asyncInit(true) |
| | | .needClearTaskReset() |
| | | //.httpStack(new MyOkStack3())//自定义网络库,demo中给出了okhttp3版本的样例,其余请自行开发或者咨询工作人员。 |
| | | .build(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.downutil; |
| | | |
| | | import android.content.ComponentName; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.pm.ApplicationInfo; |
| | | import android.content.pm.PackageManager; |
| | | import android.content.pm.PackageManager.NameNotFoundException; |
| | | |
| | | import com.loopj.android.http.AsyncHttpClient; |
| | | import com.loopj.android.http.JsonHttpResponseHandler; |
| | | import com.loopj.android.http.RequestParams; |
| | | |
| | | import org.json.JSONException; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileNotFoundException; |
| | | import java.net.URLDecoder; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.TreeSet; |
| | | |
| | | public class ApkUtil { |
| | | |
| | | public static void openApk(Context context, String packageName, |
| | | String mainActivity) { |
| | | try { |
| | | Intent intent = new Intent(); |
| | | ComponentName cmp = new ComponentName(packageName, mainActivity); |
| | | intent.setAction(Intent.ACTION_MAIN); |
| | | intent.addCategory(Intent.CATEGORY_LAUNCHER); |
| | | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | intent.setComponent(cmp); |
| | | |
| | | context.startActivity(intent); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | // 检查某个应用是否安装 |
| | | public static boolean checkAPP(Context context, String packageName) { |
| | | if (packageName == null || "".equals(packageName)) |
| | | return false; |
| | | try { |
| | | ApplicationInfo info = context.getPackageManager() |
| | | .getApplicationInfo(packageName, |
| | | PackageManager.GET_UNINSTALLED_PACKAGES); |
| | | return true; |
| | | } catch (NameNotFoundException e) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | // public static void OpenListeners(int id, String type) { |
| | | // final String mType = type; |
| | | // final int mId = id; |
| | | // Map<String, String> params = new HashMap<String, String>(); |
| | | // params.put("Method", "setMoney"); |
| | | //// params.put("Uid", AppContext.userInfo.getId() + ""); |
| | | // params.put("Id", id + ""); |
| | | // params.put("Type", type); |
| | | //// RandomCode = AppContext.userInfo.getRandomCode(); |
| | | // params.put("RCode", RandomCode); |
| | | // params.put("Platform", platform); |
| | | // post("http://123.57.155.55:8080/YouHuiZhuan/API/money", params, null, |
| | | // new JsonHttpResponseHandler() { |
| | | // |
| | | // @Override |
| | | // public void onStart() { |
| | | // super.onStart(); |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onFinish() { |
| | | // super.onFinish(); |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onSuccess(int statusCode, Header[] headers, |
| | | // JSONObject response) { |
| | | // // TODO Auto-generated method stub |
| | | // super.onSuccess(statusCode, headers, response); |
| | | // Log.i("tasklist", response.toString()); |
| | | // if (mType.equalsIgnoreCase("1")) { |
| | | //// AppContext.startRecord(mId, 3 + ""); |
| | | // } |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onFailure(int statusCode, Header[] headers, |
| | | // Throwable throwable, JSONArray errorResponse) { |
| | | // super.onFailure(statusCode, headers, throwable, |
| | | // errorResponse); |
| | | // // UIUtils.showToast(context, "请求服务器失败"); |
| | | // } |
| | | // }); |
| | | // } |
| | | |
| | | public static String RandomCode; |
| | | final static String platform = "Android"; |
| | | private static AsyncHttpClient client = new AsyncHttpClient(); |
| | | |
| | | // public static void money(Map<String, String> params, |
| | | // JsonHttpResponseHandler handler) { |
| | | // if (StringUtils.isNullOrEmpty(RandomCode) |
| | | // && AppContext.userInfo != null) { |
| | | // RandomCode = AppContext.userInfo.getRandomCode(); |
| | | // } |
| | | // RandomCode = AppContext.userInfo.getRandomCode(); |
| | | // params.put("RCode", RandomCode); |
| | | // params.put("Platform", platform); |
| | | // post("http://123.57.155.55:8080/YouHuiZhuan/API/money", params, null, |
| | | // handler); |
| | | // } |
| | | |
| | | public static void post(String url, Map<String, String> map, |
| | | HashMap<String, File> fileMap, JsonHttpResponseHandler handler) { |
| | | RequestParams params = new RequestParams(); |
| | | TreeSet<String> treeSet = new TreeSet<String>(); |
| | | Set<String> set = map.keySet(); |
| | | Iterator<String> it = set.iterator(); |
| | | String sign = ""; |
| | | String org = ""; |
| | | JSONObject object = new JSONObject(); |
| | | while (it.hasNext()) { |
| | | String key = it.next(); |
| | | treeSet.add(key); |
| | | } |
| | | it = treeSet.iterator(); |
| | | while (it.hasNext()) { |
| | | String key = it.next(); |
| | | try { |
| | | object.put(key, map.get(key)); |
| | | } catch (JSONException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | // if (!StringUtils.isNullOrEmpty(map.get(key))) |
| | | // org += map.get(key) + "---"; |
| | | } |
| | | |
| | | // sign = StringUtils.MD5(org + "youHUIzhuan2015"); |
| | | try { |
| | | String iSign = URLDecoder.decode(sign, "UTF-8"); |
| | | object.put("Sign", iSign); |
| | | } catch (Exception e2) { |
| | | // TODO Auto-generated catch block |
| | | e2.printStackTrace(); |
| | | } |
| | | params.put("Data", object.toString()); |
| | | if (fileMap != null) { |
| | | Set<String> fileSet = fileMap.keySet(); |
| | | it = fileSet.iterator(); |
| | | |
| | | while (it.hasNext()) { |
| | | String key = it.next(); |
| | | try { |
| | | params.put(key, fileMap.get(key)); |
| | | } catch (FileNotFoundException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | client.post(url, params, handler); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.downutil; |
| | | |
| | | //常量 |
| | | public class Contents { |
| | | // 根目�? |
| | | public static String ROOT = "kkshow"; |
| | | // 消息缓存目录 |
| | | public final static String CHATINFO = "Chat"; |
| | | // 消息图片缓存目录 |
| | | public final static String CHATIMG = "Image"; |
| | | // 消息声音缓存目录 |
| | | public final static String CHATVOICE = "Voice"; |
| | | // 缩略图缓存目�? |
| | | public final static String THUMBIMAGE = "ThumbImage"; |
| | | // 消息接收过滤�? |
| | | public final static String CHAT_MESSAGE_RECIVER_FILTER = "chat_message_reciver_filter"; |
| | | // 图片缓存 |
| | | public final static String CACHE = "Chche"; |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.downutil; |
| | | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.net.Uri; |
| | | import android.os.AsyncTask; |
| | | import android.util.Log; |
| | | |
| | | import java.io.File; |
| | | |
| | | /** |
| | | * @author weikou2015 下载工具类 |
| | | */ |
| | | public class DownFiles extends AsyncTask<String, Integer, String> implements |
| | | DownLoadFile.FileProgressListener { |
| | | private static final String TAG = "DownFiles"; |
| | | // TextView tv; |
| | | Context context; |
| | | IProgress progress; |
| | | |
| | | public DownFiles(Context context, IProgress progress) { |
| | | // this.tv = tv; |
| | | this.context = context; |
| | | this.progress = progress; |
| | | } |
| | | |
| | | @Override |
| | | protected void onProgressUpdate(Integer... values) { |
| | | super.onProgressUpdate(values); |
| | | Log.i(TAG, "下载进度:" + values[0]); |
| | | if (progress != null) |
| | | progress.getProgress(values[0]); |
| | | // if (values[0] == 100) { |
| | | // tv.setText("完成"); |
| | | // } else { |
| | | // tv.setText("下载" + values[0] + "%"); |
| | | // } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | protected String doInBackground(String... params) { |
| | | String url = params[0]; |
| | | // 下载 |
| | | DownLoadFile dl = new DownLoadFile(); |
| | | String[] urls = url.split("/"); |
| | | String name = ""; |
| | | if (urls.length > 0) |
| | | name = FileUtils.getRootPath(context) + File.separator |
| | | + urls[urls.length - 1]; |
| | | else |
| | | name = FileUtils.getRootPath(context) + File.separator |
| | | + System.currentTimeMillis() + ".apk"; |
| | | System.out.println("APK名称:" + name); |
| | | try { |
| | | File f = dl.downLoadFile(this, name, url, context); |
| | | return f.getPath(); |
| | | } catch (Exception e) { |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | // 完成网络请求 |
| | | @Override |
| | | protected void onPostExecute(String result) { |
| | | super.onPostExecute(result); |
| | | if (!StringUtils.isNullOrEmpty(result)&&result.endsWith(".apk")) { |
| | | Intent intent = new Intent(Intent.ACTION_VIEW); |
| | | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | intent.setDataAndType(Uri.fromFile(new File(result)), |
| | | "application/vnd.android.package-archive"); |
| | | context.startActivity(intent); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void update(int progress) { |
| | | publishProgress(progress); |
| | | } |
| | | |
| | | public interface IProgress { |
| | | public void getProgress(int p); |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.downutil; |
| | | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.net.Uri; |
| | | import android.os.AsyncTask; |
| | | import android.util.Log; |
| | | |
| | | import java.io.File; |
| | | |
| | | /** |
| | | * @author weikou2015 下载工具类 |
| | | */ |
| | | public class DownLoadApks extends AsyncTask<String, Integer, String> implements |
| | | DownLoadFile.FileProgressListener { |
| | | private static final String TAG = "DownLoadApks"; |
| | | // TextView tv; |
| | | Context context; |
| | | IProgress progress; |
| | | String apkType; |
| | | |
| | | public DownLoadApks(Context context, IProgress progress, String apkType) { |
| | | // this.tv = tv; |
| | | this.context = context; |
| | | this.progress = progress; |
| | | this.apkType = apkType; |
| | | } |
| | | |
| | | @Override |
| | | protected void onProgressUpdate(Integer... values) { |
| | | super.onProgressUpdate(values); |
| | | Log.i(TAG, "下载进度:" + values[0]); |
| | | if (progress != null) |
| | | progress.getProgress(values[0]); |
| | | // if (values[0] == 100) { |
| | | // tv.setText("完成"); |
| | | // } else { |
| | | // tv.setText("下载" + values[0] + "%"); |
| | | // } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | protected String doInBackground(String... params) { |
| | | String url = params[0]; |
| | | // 下载 |
| | | DownLoadFile dl = new DownLoadFile(); |
| | | String[] urls = url.split("/"); |
| | | String name = ""; |
| | | if (urls.length > 0) |
| | | name = FileUtils.getRootPath(context) + File.separator |
| | | + urls[urls.length - 1]; |
| | | else |
| | | name = FileUtils.getRootPath(context) + File.separator |
| | | + System.currentTimeMillis() + ".apk"; |
| | | System.out.println("APK名称:" + name); |
| | | try { |
| | | File f = dl.downLoadFile(this, name, url, context); |
| | | return f.getPath(); |
| | | } catch (Exception e) { |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | // 完成网络请求 |
| | | @Override |
| | | protected void onPostExecute(String result) { |
| | | super.onPostExecute(result); |
| | | if (!ApkUtil.checkAPP(context, apkType)) { |
| | | Intent intent = new Intent(Intent.ACTION_VIEW); |
| | | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | intent.setDataAndType(Uri.fromFile(new File(result)), |
| | | "application/vnd.android.package-archive"); |
| | | context.startActivity(intent); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void update(int progress) { |
| | | publishProgress(progress); |
| | | } |
| | | |
| | | public interface IProgress { |
| | | public void getProgress(int p); |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.downutil; |
| | | |
| | | import android.content.Context; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.net.URL; |
| | | import java.net.URLConnection; |
| | | |
| | | public class DownLoadFile { |
| | | public File downLoadFile(FileProgressListener listener, String filePath, |
| | | String _urlStr, Context context) throws Exception { |
| | | // 准备拼接新的文件名(保存在存储卡后的文件名) |
| | | // String newFilename = _urlStr.substring(_urlStr.lastIndexOf("/") + 1); |
| | | // UIUtils.showMiddleToast(context, "文件开始下载"); |
| | | File file = new File((filePath + "").trim()); |
| | | // 如果目标文件已经存在,则删除。产生覆盖旧文件的效果 |
| | | |
| | | // 构造URL |
| | | URL url = new URL(_urlStr); |
| | | System.out.println("下载地址:" + _urlStr); |
| | | // 打开连接 |
| | | URLConnection con = url.openConnection(); |
| | | // 获得文件的长度 |
| | | int contentLength = con.getContentLength(); |
| | | if (file.exists() && Math.abs(file.length() - contentLength) < 100) { |
| | | return file; |
| | | } else { |
| | | if (file.exists()) |
| | | file.delete(); |
| | | } |
| | | if (file.exists()) { |
| | | // file.delete(); |
| | | } else { |
| | | try { |
| | | file.createNewFile(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | System.out.println("长度 :" + contentLength); |
| | | // 输入流 |
| | | InputStream is = con.getInputStream(); |
| | | // 1K的数据缓冲 |
| | | byte[] bs = new byte[1024]; |
| | | // 读取到的数据长度 |
| | | int len; |
| | | int count = 0; |
| | | // 输出的文件流 |
| | | OutputStream os = new FileOutputStream((filePath + "").trim()); |
| | | // 开始读取 |
| | | while ((len = is.read(bs)) != -1) { |
| | | os.write(bs, 0, len); |
| | | count += len; |
| | | if (listener != null) |
| | | listener.update((int) ((float) count / contentLength * 100)); |
| | | } |
| | | // 完毕,关闭所有链接 |
| | | os.close(); |
| | | is.close(); |
| | | |
| | | return file; |
| | | } |
| | | |
| | | public interface FileProgressListener { |
| | | public void update(int parent); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.downutil; |
| | | |
| | | import android.content.Context; |
| | | import android.database.Cursor; |
| | | |
| | | import com.mozillaonline.providers.DownloadManager; |
| | | import com.yeshi.base.entity.db.DownloadTable; |
| | | |
| | | public class DownloadUtils { |
| | | |
| | | public static String getOfflinePath(Context context, String videoId, |
| | | String videoDetailId) { |
| | | String offlinePath = null; |
| | | Cursor downloadCursor = context.getContentResolver().query( |
| | | DownloadTable.CONTENT_URI, |
| | | null, |
| | | DownloadTable.VIDEO_ID + " = ? AND " |
| | | + DownloadTable.VIDEO_DETAIL_ID + " = ? ", |
| | | new String[] { videoId, videoDetailId }, null); |
| | | if (downloadCursor.moveToFirst()) { |
| | | DownloadManager downloadManager = new DownloadManager( |
| | | context.getContentResolver(), context.getPackageName()); |
| | | downloadManager.setAccessAllDownloads(true); |
| | | DownloadManager.Query baseQuery = new DownloadManager.Query() |
| | | .setOnlyIncludeVisibleInDownloadsUi(true); |
| | | baseQuery.setFilterById(downloadCursor.getLong(downloadCursor |
| | | .getColumnIndex(DownloadTable.TASK_ID))); |
| | | Cursor c = downloadManager.query(baseQuery); |
| | | if (c.moveToFirst()) { |
| | | int status = c.getInt(c |
| | | .getColumnIndexOrThrow(DownloadManager.COLUMN_STATUS)); |
| | | if (status == DownloadManager.STATUS_SUCCESSFUL) { |
| | | offlinePath = c |
| | | .getString(c |
| | | .getColumnIndexOrThrow(DownloadManager.COLUMN_LOCAL_URI)); |
| | | } |
| | | } |
| | | c.close(); |
| | | } |
| | | downloadCursor.close(); |
| | | return offlinePath; |
| | | } |
| | | |
| | | public static boolean isOffline(Context context, String videoId, |
| | | String videoDetailId) { |
| | | Cursor downloadCursor = context.getContentResolver().query( |
| | | DownloadTable.CONTENT_URI, |
| | | null, |
| | | DownloadTable.VIDEO_ID + " = ? AND " |
| | | + DownloadTable.VIDEO_DETAIL_ID + " = ? ", |
| | | new String[] { videoId, videoDetailId }, null); |
| | | if (downloadCursor.moveToFirst()) { |
| | | return true; |
| | | } |
| | | downloadCursor.close(); |
| | | return false; |
| | | } |
| | | |
| | | public static String getSaveDir(Context context) { |
| | | |
| | | return null; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.downutil; |
| | | |
| | | import android.content.Context; |
| | | import android.graphics.Bitmap; |
| | | import android.os.Environment; |
| | | import android.os.StatFs; |
| | | |
| | | import com.yeshi.base.entity.SDCardEntity; |
| | | import com.yeshi.base.utils.SDCardUtil; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | |
| | | public class FileUtils { |
| | | // 获取sd卡路径 |
| | | public static String getSDCardPath() { |
| | | if (Environment.getExternalStorageState().equals( |
| | | Environment.MEDIA_MOUNTED)) { |
| | | File file = new File(Environment.getExternalStorageDirectory() |
| | | .getPath()); |
| | | if (!file.exists()) |
| | | file.mkdirs(); |
| | | return file.getPath(); |
| | | } else |
| | | return null; |
| | | } |
| | | |
| | | // 获取根目录 |
| | | public static String getRootPath(Context context) { |
| | | |
| | | if (StringUtils.isNullOrEmpty(getSDCardPath())) { |
| | | File file = null; |
| | | |
| | | SDCardEntity entity = SDCardUtil.getSDCardPath(context); |
| | | if (entity != null) |
| | | file = new File(entity.getPath() + File.separator |
| | | + Contents.ROOT); |
| | | if (file == null) |
| | | return null; |
| | | if (!file.exists()) |
| | | file.mkdirs(); |
| | | return file.getPath(); |
| | | } else { |
| | | File file = new File(getSDCardPath() + File.separator |
| | | + Contents.ROOT); |
| | | if (file.getFreeSpace() == 0) { |
| | | SDCardEntity entity = SDCardUtil.getSDCardPath(context); |
| | | if (entity != null) |
| | | file = new File(entity.getPath() + File.separator |
| | | + Contents.ROOT); |
| | | } |
| | | if (!file.exists()) |
| | | file.mkdirs(); |
| | | return file.getPath(); |
| | | } |
| | | } |
| | | |
| | | // 获取消息缓存文件夹 |
| | | public static String getChatInfoPath(Context context) { |
| | | if (StringUtils.isNullOrEmpty(getRootPath(context))) { |
| | | return null; |
| | | } else { |
| | | File file = new File(getRootPath(context) + File.separator |
| | | + Contents.CHATINFO); |
| | | if (!file.exists()) |
| | | file.mkdirs(); |
| | | return file.getPath(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 写文本文�?在Android系统中,文件保存�?/data/data/PACKAGE_NAME/files 目录�? |
| | | * |
| | | * @param context |
| | | * @param msg |
| | | */ |
| | | public static void write(Context context, String fileName, String content) { |
| | | if (content == null) |
| | | content = ""; |
| | | |
| | | try { |
| | | FileOutputStream fos = context.openFileOutput(fileName, |
| | | Context.MODE_PRIVATE); |
| | | fos.write(content.getBytes()); |
| | | |
| | | fos.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 读取文本文件 |
| | | * |
| | | * @param context |
| | | * @param fileName |
| | | * @return |
| | | */ |
| | | public static String read(Context context, String fileName) { |
| | | try { |
| | | FileInputStream in = context.openFileInput(fileName); |
| | | return readInStream(in); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | private static String readInStream(FileInputStream inStream) { |
| | | try { |
| | | ByteArrayOutputStream outStream = new ByteArrayOutputStream(); |
| | | byte[] buffer = new byte[512]; |
| | | int length = -1; |
| | | while ((length = inStream.read(buffer)) != -1) { |
| | | outStream.write(buffer, 0, length); |
| | | } |
| | | |
| | | outStream.close(); |
| | | inStream.close(); |
| | | return outStream.toString(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static File createFile(String folderPath, String fileName) { |
| | | File destDir = new File(folderPath); |
| | | if (!destDir.exists()) { |
| | | destDir.mkdirs(); |
| | | } |
| | | return new File(folderPath, fileName + fileName); |
| | | } |
| | | |
| | | public static void copyFile(InputStream in, File file) { |
| | | |
| | | if (!file.exists()) { |
| | | try { |
| | | file.createNewFile(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | if (file.exists()) { |
| | | try { |
| | | FileOutputStream os = new FileOutputStream(file); |
| | | |
| | | byte[] b = new byte[1024]; |
| | | |
| | | int len = -1; |
| | | |
| | | while ((len = in.read(b)) != -1) { |
| | | os.write(b, 0, len); |
| | | } |
| | | |
| | | in.close(); |
| | | os.close(); |
| | | |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 向手机写图片 |
| | | * |
| | | * @param buffer |
| | | * @param folder |
| | | * @param fileName |
| | | * @return |
| | | */ |
| | | public static boolean writeFile(byte[] buffer, String folder, |
| | | String fileName) { |
| | | boolean writeSucc = false; |
| | | |
| | | boolean sdCardExist = Environment.getExternalStorageState().equals( |
| | | Environment.MEDIA_MOUNTED); |
| | | |
| | | String folderPath = ""; |
| | | if (sdCardExist) { |
| | | folderPath = Environment.getExternalStorageDirectory() |
| | | + File.separator + folder + File.separator; |
| | | } else { |
| | | writeSucc = false; |
| | | } |
| | | |
| | | File fileDir = new File(folderPath); |
| | | if (!fileDir.exists()) { |
| | | fileDir.mkdirs(); |
| | | } |
| | | |
| | | File file = new File(folderPath + fileName); |
| | | FileOutputStream out = null; |
| | | try { |
| | | out = new FileOutputStream(file); |
| | | out.write(buffer); |
| | | writeSucc = true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | out.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | return writeSucc; |
| | | } |
| | | |
| | | /** |
| | | * 根据文件绝对路径获取文件名 |
| | | * |
| | | * @param filePath |
| | | * @return |
| | | */ |
| | | public static String getFileName(String filePath) { |
| | | if (StringUtils.isNullOrEmpty(filePath)) |
| | | return ""; |
| | | return filePath.substring(filePath.lastIndexOf(File.separator) + 1); |
| | | } |
| | | |
| | | /** |
| | | * 根据文件的绝对路径获取文件名但不包含扩展名 |
| | | * |
| | | * @param filePath |
| | | * @return |
| | | */ |
| | | public static String getFileNameNoFormat(String filePath) { |
| | | if (StringUtils.isNullOrEmpty(filePath)) { |
| | | return ""; |
| | | } |
| | | int point = filePath.lastIndexOf('.'); |
| | | return filePath.substring(filePath.lastIndexOf(File.separator) + 1, |
| | | point); |
| | | } |
| | | |
| | | /** |
| | | * 获取文件扩展名 |
| | | * |
| | | * @param fileName |
| | | * @return |
| | | */ |
| | | public static String getFileFormat(String fileName) { |
| | | if (StringUtils.isNullOrEmpty(fileName)) |
| | | return ""; |
| | | |
| | | int point = fileName.lastIndexOf('.'); |
| | | return fileName.substring(point + 1); |
| | | } |
| | | |
| | | /** |
| | | * 获取文件大小 |
| | | * |
| | | * @param filePath |
| | | * @return |
| | | */ |
| | | public static long getFileSize(String filePath) { |
| | | long size = 0; |
| | | |
| | | File file = new File(filePath); |
| | | if (file != null && file.exists()) { |
| | | size = file.length(); |
| | | } |
| | | return size; |
| | | } |
| | | |
| | | /** |
| | | * 获取文件大小 |
| | | * |
| | | * @param size |
| | | * 字节 |
| | | * @return |
| | | */ |
| | | public static String getFileSize(long size) { |
| | | if (size <= 0) |
| | | return "0"; |
| | | java.text.DecimalFormat df = new java.text.DecimalFormat("##.##"); |
| | | float temp = (float) size / 1024; |
| | | if (temp >= 1024) { |
| | | return df.format(temp / 1024) + "M"; |
| | | } else { |
| | | return df.format(temp) + "K"; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转换文件大小 |
| | | * |
| | | * @param fileS |
| | | * @return B/KB/MB/GB |
| | | */ |
| | | public static String formatFileSize(long fileS) { |
| | | java.text.DecimalFormat df = new java.text.DecimalFormat("#.00"); |
| | | String fileSizeString = ""; |
| | | if (fileS < 1024) { |
| | | fileSizeString = df.format((double) fileS) + "B"; |
| | | } else if (fileS < 1048576) { |
| | | fileSizeString = df.format((double) fileS / 1024) + "KB"; |
| | | } else if (fileS < 1073741824) { |
| | | fileSizeString = df.format((double) fileS / 1048576) + "MB"; |
| | | } else { |
| | | fileSizeString = df.format((double) fileS / 1073741824) + "G"; |
| | | } |
| | | return fileSizeString; |
| | | } |
| | | |
| | | /** |
| | | * 获取目录文件大小 |
| | | * |
| | | * @param dir |
| | | * @return |
| | | */ |
| | | public static long getDirSize(File dir) { |
| | | if (dir == null) { |
| | | return 0; |
| | | } |
| | | if (!dir.isDirectory()) { |
| | | return 0; |
| | | } |
| | | long dirSize = 0; |
| | | File[] files = dir.listFiles(); |
| | | for (File file : files) { |
| | | if (file.isFile()) { |
| | | dirSize += file.length(); |
| | | } else if (file.isDirectory()) { |
| | | dirSize += file.length(); |
| | | dirSize += getDirSize(file); // 递归调用继续统计 |
| | | } |
| | | } |
| | | return dirSize; |
| | | } |
| | | |
| | | /** |
| | | * 获取目录文件个数 |
| | | * |
| | | * @param dir |
| | | * @return |
| | | */ |
| | | public long getFileList(File dir) { |
| | | long count = 0; |
| | | File[] files = dir.listFiles(); |
| | | count = files.length; |
| | | for (File file : files) { |
| | | if (file.isDirectory()) { |
| | | count = count + getFileList(file);// 递归 |
| | | count--; |
| | | } |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | public static byte[] toBytes(InputStream in) throws IOException { |
| | | ByteArrayOutputStream out = new ByteArrayOutputStream(); |
| | | int ch; |
| | | while ((ch = in.read()) != -1) { |
| | | out.write(ch); |
| | | } |
| | | byte buffer[] = out.toByteArray(); |
| | | out.close(); |
| | | return buffer; |
| | | } |
| | | |
| | | /** |
| | | * �?��文件是否存在 |
| | | * |
| | | * @param name |
| | | * @return |
| | | */ |
| | | public static boolean checkFileExists(String name) { |
| | | boolean status; |
| | | if (!name.equals("")) { |
| | | File path = Environment.getExternalStorageDirectory(); |
| | | File newPath = new File(path.toString() + name); |
| | | status = newPath.exists(); |
| | | } else { |
| | | status = false; |
| | | } |
| | | return status; |
| | | } |
| | | |
| | | public static boolean existFile(String path) { |
| | | |
| | | File file = new File(path); |
| | | |
| | | return file.isFile() && file.exists(); |
| | | } |
| | | |
| | | /** |
| | | * 计算SD卡的剩余空间 |
| | | * |
| | | * @return 返回-1,说明没有安装sd�? |
| | | */ |
| | | public static long getFreeDiskSpace() { |
| | | String status = Environment.getExternalStorageState(); |
| | | long freeSpace = 0; |
| | | if (status.equals(Environment.MEDIA_MOUNTED)) { |
| | | try { |
| | | File path = Environment.getExternalStorageDirectory(); |
| | | StatFs stat = new StatFs(path.getPath()); |
| | | long blockSize = stat.getBlockSize(); |
| | | long availableBlocks = stat.getAvailableBlocks(); |
| | | freeSpace = availableBlocks * blockSize / 1024; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } else { |
| | | return -1; |
| | | } |
| | | return (freeSpace); |
| | | } |
| | | |
| | | /** |
| | | * 新建目录 |
| | | * |
| | | * @param directoryName |
| | | * @return |
| | | */ |
| | | public static boolean createDirectory(String directoryName) { |
| | | boolean status; |
| | | if (!directoryName.equals("")) { |
| | | File path = Environment.getExternalStorageDirectory(); |
| | | File newPath = new File(path.toString() + directoryName); |
| | | status = newPath.mkdir(); |
| | | status = true; |
| | | } else |
| | | status = false; |
| | | return status; |
| | | } |
| | | |
| | | /** |
| | | * �?��是否安装SD�? |
| | | * |
| | | * @return |
| | | */ |
| | | public static boolean checkSaveLocationExists() { |
| | | String sDCardStatus = Environment.getExternalStorageState(); |
| | | boolean status; |
| | | if (sDCardStatus.equals(Environment.MEDIA_MOUNTED)) { |
| | | status = true; |
| | | } else |
| | | status = false; |
| | | return status; |
| | | } |
| | | |
| | | /** |
| | | * 删除目录(包括:目录里的所有文�? |
| | | * |
| | | * @param fileName |
| | | * @return |
| | | */ |
| | | public static boolean deleteDirectory(String fileName) { |
| | | boolean status; |
| | | SecurityManager checker = new SecurityManager(); |
| | | |
| | | if (!fileName.equals("")) { |
| | | |
| | | File path = Environment.getExternalStorageDirectory(); |
| | | File newPath = new File(path.toString() + fileName); |
| | | checker.checkDelete(newPath.toString()); |
| | | if (newPath.isDirectory()) { |
| | | String[] listfile = newPath.list(); |
| | | // delete all files within the specified directory and then |
| | | // delete the directory |
| | | try { |
| | | for (int i = 0; i < listfile.length; i++) { |
| | | File deletedFile = new File(newPath.toString() + "/" |
| | | + listfile[i].toString()); |
| | | deletedFile.delete(); |
| | | } |
| | | newPath.delete(); |
| | | |
| | | status = true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | status = false; |
| | | } |
| | | |
| | | } else |
| | | status = false; |
| | | } else |
| | | status = false; |
| | | return status; |
| | | } |
| | | |
| | | /** |
| | | * 删除文件 |
| | | * |
| | | * @param fileName |
| | | * @return |
| | | */ |
| | | public static boolean deleteFile(String fileName) { |
| | | boolean status; |
| | | SecurityManager checker = new SecurityManager(); |
| | | |
| | | if (!fileName.equals("")) { |
| | | |
| | | File path = Environment.getExternalStorageDirectory(); |
| | | File newPath = new File(path.toString() + fileName); |
| | | checker.checkDelete(newPath.toString()); |
| | | if (newPath.isFile()) { |
| | | try { |
| | | |
| | | newPath.delete(); |
| | | status = true; |
| | | } catch (SecurityException se) { |
| | | se.printStackTrace(); |
| | | status = false; |
| | | } |
| | | } else |
| | | status = false; |
| | | } else |
| | | status = false; |
| | | return status; |
| | | } |
| | | |
| | | public static final String getTempFilePath(Context context) { |
| | | |
| | | return context.getCacheDir() + File.separator + "temp"; |
| | | |
| | | } |
| | | |
| | | public static String getSDPath() { |
| | | File sdDir = null; |
| | | boolean sdCardExist = Environment.getExternalStorageState().equals( |
| | | Environment.MEDIA_MOUNTED); // 判断sd卡是否存�? |
| | | if (sdCardExist) { |
| | | sdDir = Environment.getExternalStorageDirectory();// 获取跟目�? |
| | | } |
| | | return sdDir.getPath(); |
| | | } |
| | | |
| | | // 将图片保存到指定的路径 |
| | | public static String savePic(String filePath, String name, Bitmap bitmap) { |
| | | File file = new File(filePath); |
| | | if (!file.exists()) |
| | | file.mkdirs(); |
| | | |
| | | File f = new File(filePath + File.separator + name); |
| | | try { |
| | | f.createNewFile(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | FileOutputStream fOut = null; |
| | | try { |
| | | fOut = new FileOutputStream(f); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | bitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut); |
| | | try { |
| | | fOut.flush(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | try { |
| | | fOut.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return f.getPath(); |
| | | } |
| | | |
| | | // 将图片保存到指定的路径 |
| | | public static String savePic(String filePath, Bitmap bitmap) { |
| | | File f = new File(filePath); |
| | | try { |
| | | f.createNewFile(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | FileOutputStream fOut = null; |
| | | try { |
| | | fOut = new FileOutputStream(f); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | bitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut); |
| | | try { |
| | | fOut.flush(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | try { |
| | | fOut.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return f.getPath(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.downutil; |
| | | |
| | | import android.content.Context; |
| | | import android.os.Build; |
| | | import android.telephony.TelephonyManager; |
| | | import android.text.Spannable; |
| | | import android.text.SpannableStringBuilder; |
| | | import android.text.style.ForegroundColorSpan; |
| | | import android.text.style.RelativeSizeSpan; |
| | | import android.widget.TextView; |
| | | |
| | | import java.security.MessageDigest; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.text.DecimalFormat; |
| | | import java.util.List; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | public class StringUtils { |
| | | |
| | | public static boolean isInt(String text) { |
| | | if (text == null || text.length() == 0) { |
| | | return false; |
| | | } |
| | | try { |
| | | Integer.parseInt(text); |
| | | return true; |
| | | } catch (Exception e) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | public static final String[] imageEndWiths = new String[] { ".jpg", ".gif", |
| | | ".png", ".bmp" }; |
| | | |
| | | public static boolean isEmail(String email) { |
| | | String regex = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"; |
| | | Pattern p = Pattern.compile(regex); |
| | | Matcher m = p.matcher(email); |
| | | return m.find(); |
| | | } |
| | | |
| | | /** |
| | | * 是否是正确的电话号码 |
| | | * |
| | | * @param mobile |
| | | * @return |
| | | */ |
| | | public static boolean isMobile(String mobile) { |
| | | |
| | | String regex = "^((13[0-9])|(15[^4,\\D])|(18[0-9]))\\d{8}$"; |
| | | Pattern p = Pattern.compile(regex); |
| | | Matcher m = p.matcher(mobile); |
| | | |
| | | if (mobile == null || mobile.equals("") || mobile.length() != 11) { |
| | | |
| | | return false; |
| | | |
| | | } else { |
| | | return m.find(); |
| | | } |
| | | } |
| | | |
| | | public static boolean isVoice(String text) { |
| | | |
| | | return text.toLowerCase().endsWith(".amr"); |
| | | |
| | | } |
| | | |
| | | public static boolean isImage(String text) { |
| | | text = text.toLowerCase(); |
| | | for (int i = 0; i < imageEndWiths.length; i++) { |
| | | String endWidth = imageEndWiths[i]; |
| | | if (text.endsWith(endWidth)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public static String createNewFileName(String fileName) { |
| | | |
| | | int i = fileName.lastIndexOf("."); |
| | | |
| | | String end = fileName.substring(i, fileName.length()); |
| | | |
| | | return System.currentTimeMillis() + end; |
| | | |
| | | } |
| | | |
| | | public static boolean isTrimEmpty(String text) { |
| | | if (text == null || text.trim().length() == 0) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public static boolean isNullOrEmpty(String text) { |
| | | if (text == null || text.length() == 0 || text.equals("null")) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public static String itrim(String beginTimeDis) { |
| | | if (beginTimeDis != null) { |
| | | int length = beginTimeDis.length(); |
| | | StringBuffer buffer = new StringBuffer(); |
| | | for (int i = 0; i < length; i++) { |
| | | char c = beginTimeDis.charAt(i); |
| | | if (c != ':') { |
| | | buffer.append(c); |
| | | } else { |
| | | buffer.append(":"); |
| | | } |
| | | } |
| | | return buffer.toString(); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | public static String getLocationDis(double distance) { |
| | | if (distance < 0) { |
| | | return "0m"; |
| | | } else if (distance < 100) { |
| | | int d = (int) distance; |
| | | return d + "m"; |
| | | } else { |
| | | String desc = ""; |
| | | |
| | | double f = distance / 1000d; |
| | | |
| | | DecimalFormat df = new DecimalFormat("#.###"); |
| | | |
| | | desc = df.format(f); |
| | | |
| | | return desc + "km"; |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | public static int toInt(String nextText, int i) { |
| | | try { |
| | | int value = Integer.parseInt(nextText); |
| | | return value; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return i; |
| | | } |
| | | |
| | | /** |
| | | * 身份证验�? |
| | | * |
| | | * @param card |
| | | * @return |
| | | */ |
| | | public static boolean isIdCard(String card) { |
| | | Pattern p = Pattern.compile("^(\\d{14}|\\d{17})(\\d|[xX])$"); |
| | | Matcher matcher = p.matcher(card); |
| | | return matcher.matches(); |
| | | } |
| | | |
| | | public static boolean isCharecter(String str) { |
| | | String regEx = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#�?…�?&*()—�?+|{}【�?‘;:�?“�?。,、?]"; |
| | | Pattern p = Pattern.compile(regEx); |
| | | Matcher m = p.matcher(str); |
| | | return m.find(); |
| | | } |
| | | |
| | | private static final char HEX_DIGITS[] = { '0', '1', '2', '3', '4', '5', |
| | | '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; |
| | | |
| | | private static String toHexString(byte[] b) { |
| | | // String to byte |
| | | StringBuilder sb = new StringBuilder(b.length * 2); |
| | | for (int i = 0; i < b.length; i++) { |
| | | sb.append(HEX_DIGITS[(b[i] & 0xf0) >>> 4]); |
| | | sb.append(HEX_DIGITS[b[i] & 0x0f]); |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /* |
| | | * MD5加密 |
| | | */ |
| | | public static String MD5(String s) { |
| | | try { |
| | | // Create MD5 Hash |
| | | MessageDigest digest = MessageDigest |
| | | .getInstance("MD5"); |
| | | digest.update(s.getBytes()); |
| | | byte messageDigest[] = digest.digest(); |
| | | |
| | | return toHexString(messageDigest); |
| | | } catch (NoSuchAlgorithmException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return ""; |
| | | } |
| | | |
| | | public static String getSimpleString(String st) { |
| | | if (isNullOrEmpty(st)) { |
| | | return "暂无"; |
| | | } |
| | | return st; |
| | | } |
| | | |
| | | // 判断List是否为空 |
| | | |
| | | public static boolean listIsNullOrEmpty(List<String> list) { |
| | | if (list == null || list.size() == 0) |
| | | return true; |
| | | else |
| | | return false; |
| | | } |
| | | |
| | | // 获取手机型号 |
| | | public static String PeopleModel() { |
| | | Build bd = new Build(); |
| | | String model = bd.MODEL; |
| | | return model; |
| | | }; |
| | | |
| | | public static String PeopleDeviceId(Context context) { |
| | | TelephonyManager tm = (TelephonyManager) context |
| | | .getSystemService(Context.TELEPHONY_SERVICE); |
| | | String deviceid = tm.getDeviceId(); |
| | | return deviceid; |
| | | } |
| | | |
| | | public static void getdiffrentColor(TextView tv, int color, int start, |
| | | int end) { |
| | | SpannableStringBuilder style = new SpannableStringBuilder(tv.getText()); |
| | | ForegroundColorSpan redSpan = new ForegroundColorSpan(color); |
| | | style.setSpan(redSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); |
| | | tv.setText(style); |
| | | } |
| | | |
| | | public static void getdiffrentColor(TextView tv, int color, int size, |
| | | int start, int end) { |
| | | SpannableStringBuilder style = new SpannableStringBuilder(tv.getText()); |
| | | ForegroundColorSpan redSpan = new ForegroundColorSpan(color); |
| | | style.setSpan(redSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); |
| | | RelativeSizeSpan sizeSpan = new RelativeSizeSpan(size); |
| | | style.setSpan(sizeSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); |
| | | tv.setText(style); |
| | | } |
| | | |
| | | public static String get2Number(int number) { |
| | | if (number >= 0 && number < 10) |
| | | return "0" + number; |
| | | else |
| | | return number + ""; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.http; |
| | | |
| | | import android.content.Context; |
| | | |
| | | import com.lcjian.library.util.ManifestDataUtil; |
| | | import com.lcjian.library.util.common.PackageUtils2; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.lcjian.library.util.security.MD5Utils; |
| | | import com.loopj.android.http.AsyncHttpClient; |
| | | import com.loopj.android.http.RequestParams; |
| | | import com.loopj.android.http.ResponseHandlerInterface; |
| | | import com.loopj.android.http.SyncHttpClient; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileNotFoundException; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.Map.Entry; |
| | | |
| | | public class API { |
| | | |
| | | public static final boolean isDebug = false; |
| | | |
| | | private static final String TAG = "BeibeiVideoAPI"; |
| | | |
| | | public static String ERROR_NOTICE = ""; |
| | | |
| | | public static String HOST = "http://api.ysdq.yeshitv.com:8089"; |
| | | |
| | | public static String BASE_URL = HOST + "/BuWan/api/v2/"; |
| | | |
| | | private static AsyncHttpClient asyncHttpClient = new AsyncHttpClient(); |
| | | |
| | | private static SyncHttpClient syncHttpClient = new SyncHttpClient(); |
| | | |
| | | static { |
| | | asyncHttpClient.setTimeout(60 * 1000); |
| | | syncHttpClient.setTimeout(60 * 1000); |
| | | asyncHttpClient.setURLEncodingEnabled(false); |
| | | syncHttpClient.setURLEncodingEnabled(false); |
| | | } |
| | | |
| | | public static void postRequest(Context context, String url, LinkedHashMap<String, String> params, |
| | | ResponseHandlerInterface handler) { |
| | | commonPost(context, url, params, handler); |
| | | } |
| | | |
| | | |
| | | public static LinkedHashMap<String, String> validateParams( |
| | | LinkedHashMap<String, String> params, Context context) { |
| | | params.put("System", "1"); |
| | | StringBuilder sign = new StringBuilder(); |
| | | sign.append(params.get("Method")) |
| | | .append(StringUtils.isEmpty(params.get("Uid")) ? params.get("Device") |
| | | : params.get("Uid")).append(params.get("System")); |
| | | params.put("Sign", MD5Utils.getMD532(sign.toString())); |
| | | params.put("Platform", "Android"); |
| | | params.put("Channel", ManifestDataUtil.getAppMetaData(context, "UMENG_CHANNEL")); |
| | | return params; |
| | | } |
| | | |
| | | @SuppressWarnings("unused") |
| | | private static void commonGet(Context context, String url, |
| | | LinkedHashMap<String, String> params, |
| | | ResponseHandlerInterface handler) { |
| | | commonGet(context, url, params, handler, true); |
| | | } |
| | | |
| | | public static void commonGet(Context context, String url, |
| | | LinkedHashMap<String, String> params, |
| | | ResponseHandlerInterface handler, boolean asyn) { |
| | | params.put("Package", context.getPackageName()); |
| | | LinkedHashMap<String, String> map = validateParams(params, context); |
| | | |
| | | RequestParams requestParams = new RequestParams(map); |
| | | if (asyn) { |
| | | (asyncHttpClient).get(context, url, requestParams, handler); |
| | | } else { |
| | | (syncHttpClient).get(context, url, requestParams, handler); |
| | | } |
| | | } |
| | | |
| | | public static void commonPost(Context context, String url, |
| | | LinkedHashMap<String, String> params, |
| | | ResponseHandlerInterface handler) { |
| | | commonPost(context, url, params, null, handler); |
| | | } |
| | | |
| | | public static void commonPost(Context context, String url, |
| | | LinkedHashMap<String, String> params, HashMap<String, File> files, |
| | | ResponseHandlerInterface handler) { |
| | | commonPost(context, url, params, files, handler, true); |
| | | } |
| | | |
| | | public static void commonPost(Context context, String url, |
| | | LinkedHashMap<String, String> params, HashMap<String, File> files, |
| | | ResponseHandlerInterface handler, boolean asyn) { |
| | | params.put("Package", "com.mugua.mgvideo");//context.getPackageName() |
| | | int version = PackageUtils2.getVersionCode(context); |
| | | params.put("Version", version + ""); |
| | | |
| | | LinkedHashMap<String, String> map = validateParams(params, context); |
| | | RequestParams requestParams = new RequestParams(map); |
| | | |
| | | if (files != null) { |
| | | for (Entry<String, File> entry : files.entrySet()) { |
| | | try { |
| | | requestParams.put(entry.getKey(), entry.getValue()); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | if (asyn) { |
| | | // asyncHttpClient.setProxy("192.168.1.122", 8888); |
| | | asyncHttpClient.post(context, url, requestParams, handler); |
| | | } else { |
| | | // asyncHttpClient.setProxy("192.168.1.122", 8888); |
| | | syncHttpClient.post(context, url, requestParams, handler); |
| | | } |
| | | } |
| | | |
| | | public static void commonGet(Context context, String url, |
| | | RequestParams params, ResponseHandlerInterface handler, boolean asyn) { |
| | | if (asyn) { |
| | | asyncHttpClient.get(context, url, params, handler); |
| | | } else { |
| | | syncHttpClient.get(context, url, params, handler); |
| | | } |
| | | } |
| | | |
| | | public static void commonGet(Context context, String url, |
| | | ResponseHandlerInterface handler, boolean asyn) { |
| | | if (asyn) { |
| | | asyncHttpClient.get(context, url, handler); |
| | | } else { |
| | | syncHttpClient.get(context, url, handler); |
| | | } |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.http; |
| | | |
| | | import android.annotation.SuppressLint; |
| | | import android.util.Log; |
| | | |
| | | import com.lcjian.library.util.security.DEScrypt; |
| | | import com.loopj.android.http.TextHttpResponseHandler; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | public abstract class BasicTextHttpResponseHandler extends |
| | | TextHttpResponseHandler { |
| | | |
| | | private static final String TAG = "BasicTextHttpResponseHandler"; |
| | | |
| | | public abstract void onSuccessPerfect(int statusCode, Header[] headers, |
| | | JSONObject jsonObject) throws Exception; |
| | | |
| | | @SuppressLint("LongLogTag") |
| | | @Override |
| | | public void onSuccess(int statusCode, Header[] headers, |
| | | String responseString) { |
| | | try { |
| | | responseString = DEScrypt.decode(responseString); |
| | | Log.v(TAG, |
| | | "onSuccess statusCode:" + statusCode |
| | | + System.getProperty("line.separator") + "headers:" |
| | | + headers.toString() |
| | | + System.getProperty("line.separator") |
| | | + "responseString:" + responseString |
| | | + System.getProperty("line.separator")); |
| | | JSONObject jsonObject = new JSONObject(responseString); |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Log.i(TAG, "onSuccess 处理成功"); |
| | | } else { |
| | | Log.i(TAG, "onSuccess 处理失败:" + jsonObject.getString("Error")); |
| | | } |
| | | onSuccessPerfect(statusCode, headers, jsonObject); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @SuppressLint("LongLogTag") |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, |
| | | String responseString, Throwable throwable) { |
| | | responseString = DEScrypt.decode(responseString); |
| | | Log.i(TAG, |
| | | "onFailure statusCode:" + statusCode |
| | | + System.getProperty("line.separator") + "headers:" |
| | | + toHeadersString(headers) |
| | | + System.getProperty("line.separator") |
| | | + "responseString:" + responseString |
| | | + System.getProperty("line.separator") + "throwable:" |
| | | + throwable.getMessage()); |
| | | } |
| | | |
| | | private String toHeadersString(Header[] headers) { |
| | | StringBuilder builder = new StringBuilder(); |
| | | if (headers != null) { |
| | | for (Header header : headers) { |
| | | builder.append(header.toString() + ";"); |
| | | } |
| | | } |
| | | return builder.toString(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.http; |
| | | |
| | | import android.content.Context; |
| | | import android.os.AsyncTask; |
| | | import android.text.TextUtils; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.JsonSyntaxException; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.loopj.android.http.SyncHttpClient; |
| | | import com.loopj.android.http.TextHttpResponseHandler; |
| | | import com.yeshi.base.utils.BaseApiUtil; |
| | | import com.yeshi.base.utils.BeibeiConstant; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONException; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.io.IOException; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.MalformedURLException; |
| | | import java.net.URL; |
| | | import java.util.Map; |
| | | import java.util.Map.Entry; |
| | | |
| | | public class GetDownLoadTask extends AsyncTask<String, Long, String[]> { |
| | | |
| | | private Context mContext; |
| | | |
| | | private String path; |
| | | |
| | | private String userAgent; |
| | | |
| | | private String leTvDada; |
| | | |
| | | private String baseUrl; |
| | | |
| | | public GetDownLoadTask(Context mContext) { |
| | | super(); |
| | | this.mContext = mContext; |
| | | } |
| | | |
| | | public Context getContext() { |
| | | return mContext; |
| | | } |
| | | |
| | | int reCount = 0; |
| | | |
| | | // 获取视频链接 |
| | | private String[] getUrl(final String... params) { |
| | | baseUrl = params[0]; |
| | | path = params[0]; |
| | | if (!TextUtils.isEmpty(path)) { |
| | | reCount = 0; |
| | | if (isContains(params[2], path)) { |
| | | getThirdUrl(path, params[1], "", ""); |
| | | } else if (path.contains("http")) { |
| | | path = "http://flv.wandoujia.com/hack/flv/download?url=" + path |
| | | + "?ref=pinapple&format=HIGH&f=android&v=2.2.0"; |
| | | // 进行豌豆荚同步请求 3-请求三次 |
| | | String result = getWanDouJiaUrl(path); |
| | | if (StringUtils.isBlank(result)) {// 无法解析 |
| | | String uid = mContext.getSharedPreferences("user", |
| | | Context.MODE_PRIVATE).getString("uid", ""); |
| | | /* |
| | | * BeibeiVideoAPI.getRealUrl(mContext, uid, params[1], |
| | | * params[0], new BasicTextHttpResponseHandler() { |
| | | * |
| | | * @Override public void onSuccessPerfect(int statusCode, |
| | | * Header[] headers, JSONObject jsonObject) throws Exception |
| | | * { if (jsonObject != null) { path = |
| | | * jsonObject.optString("Data"); } } }); |
| | | */ |
| | | |
| | | getThirdUrl(baseUrl, params[1], "", ""); |
| | | } else { |
| | | // path = result; |
| | | } |
| | | |
| | | } else { |
| | | path = BeibeiConstant.HOST + "/BeiBeiVideo" + path; |
| | | } |
| | | } |
| | | System.out.println("返回地址"); |
| | | reCount = 0; |
| | | while (isContains(params[2], path) && reCount < 3) { |
| | | getThirdUrl(path, params[1], "", ""); |
| | | reCount++; |
| | | try { |
| | | Thread.sleep(reCount * 2 * 1000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | reCount = 0; |
| | | |
| | | return new String[] { path, userAgent }; |
| | | } |
| | | |
| | | private boolean isContains(String list, String path) { |
| | | if (list != null && list.length() > 0) { |
| | | String[] sts = list.split(","); |
| | | for (String st : sts) { |
| | | if (path.contains(st)) |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private String getWanDouJiaUrl(String url) { |
| | | String result = ""; |
| | | int count = 0; |
| | | while (StringUtils.isBlank(result) && count < 3) { |
| | | count++; |
| | | try { |
| | | URL u = new URL(url); |
| | | HttpURLConnection connection = (HttpURLConnection) u |
| | | .openConnection(); |
| | | connection.setReadTimeout(60 * 1000); |
| | | connection.setConnectTimeout(60 * 1000); |
| | | connection.setRequestMethod("GET"); |
| | | int responseCode = connection.getResponseCode(); |
| | | if (responseCode == 200 || responseCode == 302) { |
| | | result = connection.getURL().toString(); |
| | | break; |
| | | } |
| | | } catch (MalformedURLException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | protected String[] doInBackground(final String... params) { |
| | | return getUrl(params); |
| | | } |
| | | |
| | | private void getThirdUrl(final String pa, final String videoDetailId, |
| | | final String setp, final String data) { |
| | | String uid = mContext |
| | | .getSharedPreferences("user", Context.MODE_PRIVATE).getString( |
| | | "uid", ""); |
| | | BaseApiUtil.getThirdVideoRequest(mContext, uid, videoDetailId, pa, |
| | | setp, data, new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | getLeTvDada(jsonObject); |
| | | if (!StringUtils.isBlank(jsonObject.optJSONObject( |
| | | "Data").optString("Step")) |
| | | && Integer.parseInt(jsonObject |
| | | .optJSONObject("Data").optString( |
| | | "Step")) > 1) { |
| | | getThirdUrl( |
| | | pa, |
| | | videoDetailId, |
| | | (Integer.parseInt(jsonObject |
| | | .optJSONObject("Data") |
| | | .optString("Step")) - 1) |
| | | + "", leTvDada); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | private void getLeTvDada(JSONObject jsonObject) throws JsonSyntaxException, |
| | | JSONException { |
| | | Map<String, String> headersMap = new Gson().fromJson(jsonObject |
| | | .getJSONObject("Data").getJSONObject("Header").toString(), |
| | | new TypeToken<Map<String, String>>() { |
| | | }.getType()); |
| | | SyncHttpClient syncHttpClient = new SyncHttpClient(); |
| | | syncHttpClient.setURLEncodingEnabled(false); |
| | | syncHttpClient.setTimeout(60 * 1000); |
| | | for (Entry<String, String> entry : headersMap.entrySet()) { |
| | | syncHttpClient.addHeader(entry.getKey(), entry.getValue()); |
| | | } |
| | | syncHttpClient.setURLEncodingEnabled(false); |
| | | syncHttpClient.get(mContext, jsonObject.getJSONObject("Data") |
| | | .getString("Url"), new TextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onSuccess(int statusCode, Header[] headers, |
| | | String responseString) { |
| | | leTvDada = responseString; |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, |
| | | String responseString, Throwable throwable) { |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.ui; |
| | | |
| | | /** |
| | | * Created by weikou2015 on 2017/6/28. |
| | | */ |
| | | |
| | | import android.graphics.Canvas; |
| | | import android.graphics.Paint; |
| | | import android.graphics.Rect; |
| | | import android.view.View; |
| | | |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | |
| | | |
| | | /** |
| | | * This class is from the v7 samples of the Android SDK. It's not by me! |
| | | * <p/> |
| | | * See the license above for details. |
| | | */ |
| | | public class DividerItemDecoration extends RecyclerView.ItemDecoration { |
| | | /** |
| | | * 水平方向 |
| | | */ |
| | | public static final int HORIZONTAL = LinearLayoutManager.HORIZONTAL; |
| | | |
| | | /** |
| | | * 垂直方向 |
| | | */ |
| | | public static final int VERTICAL = LinearLayoutManager.VERTICAL; |
| | | |
| | | // 画笔 |
| | | private Paint paint; |
| | | // 布局方向 |
| | | private int orientation = 2; |
| | | // 分割线颜色 |
| | | private int color; |
| | | //列数 暂定最多2列 |
| | | private int numColumn = 1; |
| | | // 分割线尺寸 |
| | | private int size = 2; |
| | | // 分割线尺寸 |
| | | private boolean haveHeader; |
| | | //是否有分割线 |
| | | private boolean haveDivider = true; |
| | | private boolean isSet = false; |
| | | |
| | | public DividerItemDecoration() { |
| | | this(VERTICAL); |
| | | orientation = 2; |
| | | } |
| | | |
| | | public DividerItemDecoration(int orientation) { |
| | | this.orientation = orientation; |
| | | |
| | | paint = new Paint(); |
| | | } |
| | | |
| | | @Override |
| | | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { |
| | | super.getItemOffsets(outRect, view, parent, state); |
| | | int position = parent.getChildAdapterPosition(view); |
| | | outRect.bottom = size * 2; |
| | | if (numColumn > 1) { |
| | | if (haveHeader) { |
| | | if (position == 0) { |
| | | return; |
| | | } else { |
| | | position -= 1; |
| | | } |
| | | } |
| | | if (position % numColumn == 0) { |
| | | outRect.right = size; |
| | | } else if (position % numColumn == (numColumn - 1)) { |
| | | outRect.left = size; |
| | | } else { |
| | | outRect.left = size; |
| | | outRect.right = size; |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { |
| | | super.onDrawOver(c, parent, state); |
| | | // if (orientation == VERTICAL) { |
| | | // drawHorizontal(c, parent); |
| | | // } else { |
| | | // drawVertical(c, parent); |
| | | // } |
| | | } |
| | | |
| | | /** |
| | | * 设置分割线颜色 |
| | | * |
| | | * @param color 颜色 |
| | | */ |
| | | public void setColor(int color) { |
| | | this.color = color; |
| | | paint.setColor(color); |
| | | } |
| | | |
| | | /** |
| | | * 设置列数 |
| | | * |
| | | * @param numColumn 列数 |
| | | */ |
| | | public void setNumColumn(int numColumn) { |
| | | this.numColumn = numColumn; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 是否加入header |
| | | * |
| | | * @param haveHeader header |
| | | */ |
| | | public void isHaveHeader(boolean haveHeader) { |
| | | this.haveHeader = haveHeader; |
| | | } |
| | | |
| | | /** |
| | | * 是否加入header |
| | | * |
| | | * @param haveDivider header |
| | | */ |
| | | public void isHaveDivider(boolean haveDivider) { |
| | | this.haveDivider = haveDivider; |
| | | } |
| | | |
| | | /** |
| | | * 设置分割线尺寸 |
| | | * |
| | | * @param size 尺寸 |
| | | */ |
| | | public void setSize(int size) { |
| | | this.size = size; |
| | | } |
| | | |
| | | // 绘制垂直分割线 |
| | | protected void drawVertical(Canvas c, RecyclerView parent) { |
| | | final int top = parent.getPaddingTop(); |
| | | final int bottom = parent.getHeight() - parent.getPaddingBottom(); |
| | | |
| | | int childCount = parent.getChildCount(); |
| | | for (int i = 0; i < childCount; i++) { |
| | | if (haveHeader && i == 1 && !isSet) { |
| | | isSet = true; |
| | | continue; |
| | | } |
| | | final View child = parent.getChildAt(i); |
| | | final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); |
| | | final int left = child.getRight() + params.rightMargin; |
| | | final int right = left + size; |
| | | |
| | | c.drawRect(left, top, right, bottom, paint); |
| | | } |
| | | } |
| | | |
| | | // 绘制水平分割线 |
| | | protected void drawHorizontal(Canvas c, RecyclerView parent) { |
| | | final int left = parent.getPaddingLeft(); |
| | | final int right = parent.getWidth() - parent.getPaddingRight(); |
| | | |
| | | final int childCount = parent.getChildCount(); |
| | | for (int i = 0; i < childCount; i++) { |
| | | if (haveHeader && i == 0 && !isSet) { |
| | | isSet = true; |
| | | continue; |
| | | } |
| | | final View child = parent.getChildAt(i); |
| | | final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); |
| | | final int top = child.getBottom() + params.bottomMargin; |
| | | final int bottom = top + size; |
| | | |
| | | c.drawRect(left, top, right, bottom, paint); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.user; |
| | | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | |
| | | import static android.content.Context.MODE_PRIVATE; |
| | | |
| | | public class UserUtil { |
| | | |
| | | private static Gson gson = new GsonBuilder().serializeNulls().create(); |
| | | |
| | | |
| | | /** |
| | | * 是否同意了用户协议 |
| | | * |
| | | * @param context |
| | | * @return |
| | | */ |
| | | public static boolean isAgreeUserProtocol(Context context) { |
| | | SharedPreferences sp = context.getSharedPreferences("user", MODE_PRIVATE); |
| | | String protocol = sp.getString("protocol-agree", ""); |
| | | if (StringUtils.isEmpty(protocol)) |
| | | return false; |
| | | else |
| | | return true; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 同意用户协议 |
| | | * |
| | | * @param context |
| | | */ |
| | | public static void agreeUserProtocol(Context context) { |
| | | SharedPreferences sp = context.getSharedPreferences("user", MODE_PRIVATE); |
| | | SharedPreferences.Editor editor = sp.edit(); |
| | | editor.putString("protocol-agree", "1"); |
| | | editor.commit(); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户ID |
| | | * |
| | | * @param context |
| | | * @return |
| | | */ |
| | | public static String getUid(Context context) { |
| | | SharedPreferences preferences = context.getSharedPreferences("user", MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | return uid; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.video; |
| | | |
| | | import com.yeshi.base.entity.video.VideoType; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class VideoTypeUtil { |
| | | public static String getVideoTypeName(VideoType type) { |
| | | String result = ""; |
| | | List<String> nameList = new ArrayList<String>(); |
| | | nameList.add(type.getName()); |
| | | while (type.getParent() != null) { |
| | | type = type.getParent(); |
| | | nameList.add(type.getName()); |
| | | } |
| | | for (int i = nameList.size() - 1; i >= 0; i--) { |
| | | result += nameList.get(i) + "-"; |
| | | } |
| | | if (result.endsWith("-")) |
| | | result = result.substring(0, result.length() - 1); |
| | | return result; |
| | | } |
| | | |
| | | public static String getVideoRootName(VideoType type) { |
| | | while (type.getParent() != null) { |
| | | type = type.getParent(); |
| | | } |
| | | return type.getName(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.x5; |
| | | |
| | | public interface WebViewJavaScriptFunction { |
| | | |
| | | void onJsFunctionCalled(String tag); |
| | | } |
New file |
| | |
| | | package com.yeshi.base.utils.x5; |
| | | |
| | | import android.annotation.SuppressLint; |
| | | import android.content.Context; |
| | | import android.graphics.Canvas; |
| | | import android.util.AttributeSet; |
| | | import android.view.View; |
| | | import android.widget.TextView; |
| | | |
| | | import com.tencent.smtt.sdk.CookieSyncManager; |
| | | import com.tencent.smtt.sdk.WebSettings; |
| | | import com.tencent.smtt.sdk.WebSettings.LayoutAlgorithm; |
| | | import com.tencent.smtt.sdk.WebView; |
| | | import com.tencent.smtt.sdk.WebViewClient; |
| | | |
| | | public class X5WebView extends WebView { |
| | | TextView title; |
| | | private WebViewClient client = new WebViewClient() { |
| | | /** |
| | | * 防止加载网页时调起系统浏览器 |
| | | */ |
| | | public boolean shouldOverrideUrlLoading(WebView view, String url) { |
| | | view.loadUrl(url); |
| | | return true; |
| | | } |
| | | }; |
| | | |
| | | @SuppressLint("SetJavaScriptEnabled") |
| | | public X5WebView(Context arg0, AttributeSet arg1) { |
| | | super(arg0, arg1); |
| | | this.setWebViewClient(client); |
| | | // this.setWebChromeClient(chromeClient); |
| | | // WebStorage webStorage = WebStorage.getInstance(); |
| | | initWebViewSettings(); |
| | | this.getView().setClickable(true); |
| | | } |
| | | |
| | | private void initWebViewSettings() { |
| | | WebSettings webSetting = this.getSettings(); |
| | | webSetting.setJavaScriptEnabled(true); |
| | | // webSetting.setJavaScriptCanOpenWindowsAutomatically(true); |
| | | webSetting.setAllowFileAccess(true); |
| | | webSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS); |
| | | webSetting.setSupportZoom(true); |
| | | webSetting.setBuiltInZoomControls(true); |
| | | webSetting.setUseWideViewPort(true); |
| | | webSetting.setSupportMultipleWindows(true); |
| | | // webSetting.setLoadWithOverviewMode(true); |
| | | webSetting.setAppCacheEnabled(true); |
| | | // webSetting.setDatabaseEnabled(true); |
| | | webSetting.setDomStorageEnabled(true); |
| | | webSetting.setGeolocationEnabled(true); |
| | | webSetting.setAppCacheMaxSize(Long.MAX_VALUE); |
| | | // webSetting.setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY); |
| | | webSetting.setPluginState(WebSettings.PluginState.ON_DEMAND); |
| | | // webSetting.setRenderPriority(WebSettings.RenderPriority.HIGH); |
| | | webSetting.setCacheMode(WebSettings.LOAD_NO_CACHE); |
| | | |
| | | // this.getSettingsExtension().setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);//extension |
| | | // settings 的设计 |
| | | webSetting.setUserAgent(webSetting.getUserAgentString().replace("TBS","MG").replace("MQQBrowser","MUGUABrowser")); |
| | | webSetting.setTextZoom(100); |
| | | |
| | | CookieSyncManager.createInstance(getContext()); |
| | | CookieSyncManager.getInstance().sync(); |
| | | } |
| | | |
| | | @Override |
| | | protected boolean drawChild(Canvas canvas, View child, long drawingTime) { |
| | | boolean ret = super.drawChild(canvas, child, drawingTime); |
| | | canvas.save(); |
| | | // Paint paint = new Paint(); |
| | | // paint.setColor(0x7fff0000); |
| | | // paint.setTextSize(24.f); |
| | | // paint.setAntiAlias(true); |
| | | // if (getX5WebViewExtension() != null) { |
| | | // canvas.drawText(this.getContext().getPackageName() + "-pid:" |
| | | // + android.os.Process.myPid(), 10, 50, paint); |
| | | // canvas.drawText( |
| | | // "X5 Core:" + QbSdk.getTbsVersion(this.getContext()), 10, |
| | | // 100, paint); |
| | | // } else { |
| | | // canvas.drawText(this.getContext().getPackageName() + "-pid:" |
| | | // + android.os.Process.myPid(), 10, 50, paint); |
| | | // canvas.drawText("Sys Core", 10, 100, paint); |
| | | // } |
| | | // canvas.drawText(Build.MANUFACTURER, 10, 150, paint); |
| | | // canvas.drawText(Build.MODEL, 10, 200, paint); |
| | | // canvas.restore(); |
| | | return ret; |
| | | } |
| | | |
| | | public X5WebView(Context arg0) { |
| | | super(arg0); |
| | | setBackgroundColor(85621); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <selector xmlns:android="http://schemas.android.com/apk/res/android" > |
| | | |
| | | <item android:state_pressed="true" android:color="@color/qq_blue"></item> |
| | | <item android:state_pressed="false" android:color="@color/black"></item> |
| | | |
| | | </selector> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <selector xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | <item android:drawable="@drawable/ic_user_agreement_unchecked" android:state_checked="true"></item> |
| | | <item android:drawable="@drawable/ic_user_agreement_checked" android:state_checked="false"></item> |
| | | |
| | | </selector> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android" > |
| | | |
| | | <corners android:radius="5dp" /> |
| | | |
| | | <solid android:color="@color/gray2" /> |
| | | |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android" > |
| | | |
| | | <corners android:radius="5dp" /> |
| | | |
| | | <solid android:color="@color/blue4" /> |
| | | |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android" > |
| | | |
| | | <corners android:radius="5dp" /> |
| | | |
| | | <solid android:color="@color/blue2" /> |
| | | |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android" > |
| | | |
| | | <corners android:radius="5dp" /> |
| | | |
| | | <solid android:color="@android:color/white" /> |
| | | |
| | | <stroke |
| | | android:width="1px" |
| | | android:color="@color/blue4" /> |
| | | |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:background="@color/white" |
| | | android:orientation="vertical" > |
| | | |
| | | <FrameLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="48dp" |
| | | android:background="@color/top_bar_color" > |
| | | |
| | | <TextView |
| | | android:id="@+id/login_tv_cancel" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:drawableLeft="@drawable/ic_back" |
| | | android:drawablePadding="3dp" |
| | | android:gravity="center_vertical" |
| | | android:padding="8dp" |
| | | android:text="返回" |
| | | android:textColor="@color/white" |
| | | android:textSize="16sp" /> |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | android:paddingBottom="6dp" |
| | | android:paddingTop="6dp" |
| | | android:text="帐号登录" |
| | | android:textColor="@color/white" |
| | | android:textSize="20sp" /> |
| | | </FrameLayout> |
| | | |
| | | <ScrollView |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" > |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:orientation="vertical" > |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/ll_login_content" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_horizontal" |
| | | android:layout_marginLeft="50dp" |
| | | android:layout_marginRight="50dp" |
| | | android:layout_marginTop="50dp" |
| | | android:orientation="vertical" > |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_login_top" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | android:src="@drawable/ic_login_top" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="40dp" |
| | | android:orientation="horizontal" > |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:text="账号:" /> |
| | | |
| | | <EditText |
| | | android:id="@+id/et_name" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:background="@null" |
| | | android:digits="@string/rule_email" |
| | | android:inputType="textEmailAddress" |
| | | android:singleLine="true" /> |
| | | </LinearLayout> |
| | | |
| | | <View |
| | | android:layout_width="match_parent" |
| | | android:layout_height="1px" |
| | | android:layout_marginTop="6dp" |
| | | android:background="@color/light_gray" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="10dp" |
| | | android:orientation="horizontal" > |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:text="密码:" /> |
| | | |
| | | <EditText |
| | | android:id="@+id/et_pwd" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:background="@null" |
| | | android:digits="@string/rule_password" |
| | | android:inputType="textPassword" |
| | | android:singleLine="true" /> |
| | | </LinearLayout> |
| | | |
| | | <View |
| | | android:layout_width="match_parent" |
| | | android:layout_height="1px" |
| | | android:layout_marginTop="6dp" |
| | | android:background="@color/light_gray" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="left" |
| | | android:layout_marginTop="10dp" |
| | | android:orientation="horizontal" > |
| | | |
| | | <CheckBox |
| | | android:id="@+id/cb_user_agreement" |
| | | android:layout_width="15dp" |
| | | android:layout_height="15dp" |
| | | android:layout_gravity="center_vertical" |
| | | android:background="@drawable/selector_user_agreement_checkbox" |
| | | android:button="@null" |
| | | android:checked="true" |
| | | android:gravity="center" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_user_agreement" |
| | | android:layout_width="0dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="5dp" |
| | | android:layout_weight="1" |
| | | android:text="@string/user_agreement" |
| | | android:textColor="@color/blue4" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_forget_pwd" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="20dp" |
| | | android:ellipsize="end" |
| | | android:singleLine="true" |
| | | android:text="忘记密码?" |
| | | android:textColor="@color/gray" /> |
| | | </LinearLayout> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:layout_marginTop="20dp" |
| | | android:orientation="horizontal" > |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_register" |
| | | android:layout_width="0dp" |
| | | android:layout_height="38dp" |
| | | android:layout_marginRight="5dp" |
| | | android:layout_weight="1" |
| | | android:background="@drawable/shape_register" |
| | | android:gravity="center" |
| | | android:text="注册" |
| | | android:textColor="@color/blue2" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_login" |
| | | android:layout_width="0dp" |
| | | android:layout_height="38dp" |
| | | android:layout_marginLeft="5dp" |
| | | android:layout_weight="1" |
| | | android:background="@drawable/shape_login1" |
| | | android:gravity="center" |
| | | android:text="登陆" |
| | | android:textColor="@color/white" /> |
| | | </LinearLayout> |
| | | </LinearLayout> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="30dp" |
| | | android:background="@color/white" |
| | | android:orientation="vertical" |
| | | android:paddingBottom="20dp" > |
| | | |
| | | <TextView |
| | | android:id="@+id/textView" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="30dp" |
| | | android:gravity="center" |
| | | android:text="第三方账号登陆" |
| | | android:textColor="@color/gray" |
| | | android:textSize="18sp" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/login_tv_qq" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_horizontal" |
| | | android:layout_marginTop="15dp" |
| | | android:drawablePadding="6dp" |
| | | android:drawableTop="@drawable/img_qq" |
| | | android:gravity="center_horizontal" |
| | | android:padding="4dp" |
| | | android:text="QQ登陆" |
| | | android:textColor="@drawable/selector_qqblue_font" |
| | | android:textSize="16sp" /> |
| | | </LinearLayout> |
| | | </LinearLayout> |
| | | </ScrollView> |
| | | |
| | | </LinearLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:orientation="vertical" > |
| | | |
| | | <FrameLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="48dp" |
| | | android:background="@color/top_bar_color" > |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_back" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:drawableLeft="@drawable/ic_back" |
| | | android:drawablePadding="3dp" |
| | | android:gravity="center_vertical" |
| | | android:padding="8dp" |
| | | android:text="返回" |
| | | android:textColor="@color/white" |
| | | android:textSize="16sp" /> |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | android:paddingBottom="6dp" |
| | | android:paddingTop="6dp" |
| | | android:text="忘记密码" |
| | | android:textColor="@color/white" |
| | | android:textSize="20sp" /> |
| | | </FrameLayout> |
| | | |
| | | <ScrollView |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" > |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:layout_marginTop="30dp" |
| | | android:gravity="center" |
| | | android:orientation="vertical" > |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_login_top" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | android:src="@drawable/ic_login_top" /> |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/ll_login_content" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | android:layout_marginLeft="50dp" |
| | | android:layout_marginRight="50dp" |
| | | android:orientation="vertical" > |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="40dp" |
| | | android:orientation="horizontal" > |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:text="账号:" /> |
| | | |
| | | <EditText |
| | | android:id="@+id/et_email" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="30dp" |
| | | android:background="@null" |
| | | android:digits="@string/rule_email" |
| | | android:inputType="textEmailAddress" |
| | | android:paddingLeft="15dp" |
| | | android:paddingRight="15dp" |
| | | android:singleLine="true" |
| | | android:textSize="14sp" /> |
| | | </LinearLayout> |
| | | |
| | | <View |
| | | android:layout_width="match_parent" |
| | | android:layout_height="1px" |
| | | android:layout_marginTop="6dp" |
| | | android:background="@color/light_gray" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_horizontal" |
| | | android:layout_marginTop="10dp" |
| | | android:orientation="horizontal" > |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:text="验证码: " /> |
| | | |
| | | <EditText |
| | | android:id="@+id/et_verfication_code" |
| | | android:layout_width="0dp" |
| | | android:layout_height="30dp" |
| | | android:layout_weight="1" |
| | | android:background="@null" |
| | | android:digits="0123456789" |
| | | android:inputType="number" |
| | | android:paddingLeft="15dp" |
| | | android:paddingRight="15dp" |
| | | android:singleLine="true" |
| | | android:textSize="14sp" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_obtain_verfication_code" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="30dp" |
| | | android:layout_gravity="center_vertical" |
| | | android:layout_marginLeft="20dp" |
| | | android:background="@drawable/shape_get_verify_code" |
| | | android:ellipsize="end" |
| | | android:padding="5dp" |
| | | android:singleLine="true" |
| | | android:text="获取验证码" |
| | | android:textColor="@color/white" /> |
| | | </LinearLayout> |
| | | |
| | | <View |
| | | android:layout_width="match_parent" |
| | | android:layout_height="1px" |
| | | android:layout_marginTop="6dp" |
| | | android:background="@color/light_gray" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_horizontal" |
| | | android:layout_marginTop="10dp" |
| | | android:orientation="horizontal" > |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:text="密码: " /> |
| | | |
| | | <EditText |
| | | android:id="@+id/et_pwd" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="30dp" |
| | | android:background="@null" |
| | | android:digits="@string/rule_password" |
| | | android:inputType="textPassword" |
| | | android:paddingLeft="15dp" |
| | | android:paddingRight="15dp" |
| | | android:singleLine="true" |
| | | android:textSize="14sp" /> |
| | | </LinearLayout> |
| | | |
| | | <View |
| | | android:layout_width="match_parent" |
| | | android:layout_height="1px" |
| | | android:layout_marginTop="6dp" |
| | | android:background="@color/light_gray" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_confirm" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="38dp" |
| | | android:layout_marginTop="50dp" |
| | | android:background="@drawable/shape_login1" |
| | | android:gravity="center" |
| | | android:text="完成" |
| | | android:textColor="@color/white" /> |
| | | </LinearLayout> |
| | | </LinearLayout> |
| | | </ScrollView> |
| | | |
| | | <View |
| | | android:id="@+id/v_status_bar" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="15dp" |
| | | android:background="@color/top_bar_color" /> |
| | | |
| | | <FrameLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="48dp" |
| | | android:background="@color/top_bar_color" > |
| | | |
| | | <TextView |
| | | android:id="@+id/login_tv_cancel" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:drawableLeft="@drawable/ic_back" |
| | | android:drawablePadding="3dp" |
| | | android:gravity="center_vertical" |
| | | android:padding="8dp" |
| | | android:text="返回" |
| | | android:textColor="@color/white" |
| | | android:textSize="16sp" /> |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | android:paddingBottom="6dp" |
| | | android:paddingTop="6dp" |
| | | android:text="注册" |
| | | android:textColor="@color/white" |
| | | android:textSize="20sp" /> |
| | | </FrameLayout> |
| | | |
| | | </LinearLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:orientation="vertical"> |
| | | |
| | | |
| | | <FrameLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="48dp" |
| | | android:background="@color/top_bar_color"> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_back" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:drawableLeft="@drawable/ic_back" |
| | | android:drawablePadding="3dp" |
| | | android:gravity="center_vertical" |
| | | android:padding="8dp" |
| | | android:text="返回" |
| | | android:textColor="@color/white" |
| | | android:textSize="16sp" /> |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | android:paddingBottom="6dp" |
| | | android:paddingTop="6dp" |
| | | android:text="个人资料" |
| | | android:textColor="@color/white" |
| | | android:textSize="20sp" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_top_right" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="right|center_vertical" |
| | | android:padding="8dp" |
| | | android:paddingBottom="6dp" |
| | | android:paddingTop="6dp" |
| | | android:text="完成" |
| | | android:textColor="@color/white" |
| | | android:textSize="16sp" /> |
| | | </FrameLayout> |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/ll_portrait_select" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="80dp" |
| | | android:layout_marginTop="20dp" |
| | | android:background="@color/white" |
| | | android:orientation="horizontal"> |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:layout_marginLeft="20dp" |
| | | android:text="修改头像" /> |
| | | |
| | | <View |
| | | android:layout_width="0dp" |
| | | android:layout_height="1px" |
| | | android:layout_weight="1" /> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_portrai_select" |
| | | android:layout_width="60dp" |
| | | android:layout_height="60dp" |
| | | android:layout_gravity="center_vertical" |
| | | android:layout_marginRight="20dp" |
| | | android:scaleType="centerInside" |
| | | android:src="@drawable/ic_portrait_default" /> |
| | | |
| | | <ImageView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:layout_marginRight="20dp" |
| | | android:src="@drawable/ic_input" /> |
| | | </LinearLayout> |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/ll_nickName" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="40dp" |
| | | android:layout_marginTop="10dp" |
| | | android:background="@color/white"> |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:layout_marginLeft="20dp" |
| | | android:text="昵称" /> |
| | | |
| | | <View |
| | | android:layout_width="0dp" |
| | | android:layout_height="1px" |
| | | android:layout_weight="1" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_nickName" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:layout_marginRight="20dp" |
| | | android:drawablePadding="3dp" |
| | | android:drawableRight="@drawable/ic_input" |
| | | android:text="编辑昵称" |
| | | android:textColor="@color/gray" /> |
| | | </LinearLayout> |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/ll_birthday" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="40dp" |
| | | android:layout_marginTop="1dp" |
| | | android:background="@color/white"> |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:layout_marginLeft="20dp" |
| | | android:text="生日" /> |
| | | |
| | | <View |
| | | android:layout_width="0dp" |
| | | android:layout_height="1px" |
| | | android:layout_weight="1" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_birthday" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:layout_marginRight="20dp" |
| | | android:drawablePadding="3dp" |
| | | android:drawableRight="@drawable/ic_input" |
| | | android:text="点击设置生日" |
| | | android:textColor="@color/gray" /> |
| | | </LinearLayout> |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/ll_sex" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="40dp" |
| | | android:layout_marginTop="1dp" |
| | | android:background="@color/white"> |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:layout_marginLeft="20dp" |
| | | android:text="性别" /> |
| | | |
| | | <View |
| | | android:layout_width="0dp" |
| | | android:layout_height="1px" |
| | | android:layout_weight="1" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_sex" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:layout_marginRight="20dp" |
| | | android:drawablePadding="3dp" |
| | | android:drawableRight="@drawable/ic_input" |
| | | android:text="男" |
| | | android:textColor="@color/gray" /> |
| | | </LinearLayout> |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/ll_autograph" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="10dp" |
| | | android:background="@color/white"> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="0dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginBottom="5dp" |
| | | android:layout_marginTop="5dp" |
| | | android:layout_weight="1" |
| | | android:orientation="vertical"> |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="20dp" |
| | | android:text="个性签名" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_autograph" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="20dp" |
| | | android:layout_marginTop="5dp" |
| | | android:text="个性签名" |
| | | android:textColor="@color/gray" /> |
| | | </LinearLayout> |
| | | |
| | | <ImageView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:layout_marginRight="20dp" |
| | | android:src="@drawable/ic_input" /> |
| | | </LinearLayout> |
| | | </LinearLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:orientation="vertical" > |
| | | |
| | | <FrameLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="48dp" |
| | | android:background="@color/top_bar_color" > |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_back" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:drawableLeft="@drawable/ic_back" |
| | | android:drawablePadding="3dp" |
| | | android:gravity="center_vertical" |
| | | android:padding="8dp" |
| | | android:text="返回" |
| | | android:textColor="@color/white" |
| | | android:textSize="16sp" /> |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | android:paddingBottom="6dp" |
| | | android:paddingTop="6dp" |
| | | android:text="注册" |
| | | android:textColor="@color/white" |
| | | android:textSize="20sp" /> |
| | | </FrameLayout> |
| | | |
| | | <ScrollView |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" > |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/ll_login_content" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="50dp" |
| | | android:layout_marginRight="50dp" |
| | | android:layout_marginTop="50dp" |
| | | android:gravity="center" |
| | | android:orientation="vertical" > |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_register_top" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | android:src="@drawable/ic_login_top" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="15dp" |
| | | android:orientation="horizontal" > |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:gravity="center" |
| | | android:text="邮箱:" /> |
| | | |
| | | <EditText |
| | | android:id="@+id/et_name" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="30dp" |
| | | android:background="@null" |
| | | android:digits="@string/rule_email" |
| | | android:inputType="textEmailAddress" |
| | | android:paddingLeft="8dp" |
| | | android:paddingRight="8dp" |
| | | android:singleLine="true" |
| | | android:textSize="14sp" /> |
| | | </LinearLayout> |
| | | |
| | | <View |
| | | android:layout_width="match_parent" |
| | | android:layout_height="1px" |
| | | android:background="@color/light_gray" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="10dp" |
| | | android:orientation="horizontal" > |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:gravity="center" |
| | | android:text="密码:" /> |
| | | |
| | | <EditText |
| | | android:id="@+id/et_pwd" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="30dp" |
| | | android:background="@null" |
| | | android:digits="@string/rule_password" |
| | | android:inputType="textPassword" |
| | | android:paddingLeft="8dp" |
| | | android:paddingRight="8dp" |
| | | android:singleLine="true" |
| | | android:textSize="14sp" /> |
| | | </LinearLayout> |
| | | |
| | | <View |
| | | android:layout_width="match_parent" |
| | | android:layout_height="1px" |
| | | android:background="@color/light_gray" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="left" |
| | | android:layout_marginTop="10dp" |
| | | android:orientation="horizontal" > |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:gravity="center" |
| | | android:text="验证码:" /> |
| | | |
| | | <EditText |
| | | android:id="@+id/et_verfication_code" |
| | | android:layout_width="0dp" |
| | | android:layout_height="30dp" |
| | | android:layout_weight="1" |
| | | android:background="@null" |
| | | android:digits="0123456789" |
| | | android:inputType="number" |
| | | android:paddingLeft="15dp" |
| | | android:paddingRight="15dp" |
| | | android:singleLine="true" |
| | | android:textSize="14sp" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_obtain_verfication_code" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="30dp" |
| | | android:layout_gravity="center_vertical" |
| | | android:layout_marginLeft="20dp" |
| | | android:background="@drawable/shape_get_verify_code" |
| | | android:ellipsize="end" |
| | | android:padding="5dp" |
| | | android:singleLine="true" |
| | | android:text="获取验证码" |
| | | android:textColor="@color/white" /> |
| | | </LinearLayout> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_vertical" |
| | | android:layout_marginTop="8dp" |
| | | android:orientation="horizontal" > |
| | | |
| | | <CheckBox |
| | | android:id="@+id/cb_user_agreement" |
| | | android:layout_width="15dp" |
| | | android:layout_height="15dp" |
| | | android:layout_gravity="center_vertical" |
| | | android:background="@drawable/selector_user_agreement_checkbox" |
| | | android:button="@null" |
| | | android:checked="true" |
| | | android:gravity="center" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_user_agreement" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="5dp" |
| | | android:text="@string/user_agreement" |
| | | android:textColor="@color/blue4" /> |
| | | </LinearLayout> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_confirm" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="38dp" |
| | | android:layout_marginTop="50dp" |
| | | android:background="@drawable/shape_login1" |
| | | android:gravity="center" |
| | | android:text="确认" |
| | | android:textColor="@color/white" /> |
| | | </LinearLayout> |
| | | </ScrollView> |
| | | |
| | | </LinearLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:orientation="vertical" > |
| | | |
| | | |
| | | <RelativeLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="48dp" |
| | | android:background="@color/black" |
| | | android:gravity="center_vertical" |
| | | android:orientation="horizontal" > |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_top_bar_left" |
| | | style="@style/TextBuleNormal" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_alignParentLeft="true" |
| | | android:layout_alignParentStart="true" |
| | | android:layout_centerVertical="true" |
| | | android:drawableLeft="@drawable/ic_back" |
| | | android:drawablePadding="3dp" |
| | | android:gravity="center" |
| | | android:padding="8dp" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_top_bar_left2" |
| | | style="@style/TextBuleNormal" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_centerVertical="true" |
| | | android:layout_toRightOf="@id/tv_top_bar_left" |
| | | android:gravity="center" |
| | | android:paddingBottom="8dp" |
| | | android:paddingLeft="3dp" |
| | | android:paddingRight="8dp" |
| | | android:paddingTop="8dp" |
| | | android:visibility="gone" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_top_bar_middle" |
| | | style="@style/TextBuleLarge" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_centerInParent="true" |
| | | android:ellipsize="end" |
| | | android:maxLength="6" |
| | | android:singleLine="true" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_top_bar_right" |
| | | style="@style/TextBuleNormal" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_alignParentEnd="true" |
| | | android:layout_alignParentRight="true" |
| | | android:layout_centerVertical="true" |
| | | android:padding="8dp" /> |
| | | </RelativeLayout> |
| | | |
| | | <ProgressBar |
| | | android:id="@+id/myProgressBar" |
| | | style="?android:attr/progressBarStyleHorizontal" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="3dp" |
| | | android:background="@color/yellow" /> |
| | | |
| | | <FrameLayout |
| | | android:id="@+id/fl_webview" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="0dp" |
| | | android:layout_weight="1" > |
| | | </FrameLayout> |
| | | |
| | | </LinearLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | xmlns:app="http://schemas.android.com/apk/res-auto" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | android:gravity="center" |
| | | android:orientation="vertical"> |
| | | |
| | | <com.github.ybq.android.spinkit.SpinKitView |
| | | android:id="@+id/spin_kit" |
| | | style="@style/SpinKitView.Large.Circle" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | app:SpinKit_Color="@color/colorLoading" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_msg" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="5dp" |
| | | android:textColor="@color/colorLoading"></TextView> |
| | | |
| | | |
| | | </LinearLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:background="@color/register_gray" |
| | | android:orientation="vertical"> |
| | | |
| | | <TextView |
| | | android:id="@+id/textView2" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | android:background="@color/white" |
| | | android:gravity="center" |
| | | android:padding="5dp" |
| | | android:text="生日选择" |
| | | android:textSize="18sp" /> |
| | | |
| | | <DatePicker |
| | | android:id="@+id/datePicker" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_horizontal" |
| | | android:background="@color/white" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="5dp"> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_cancel" |
| | | android:layout_width="0dp" |
| | | android:layout_height="38dp" |
| | | android:layout_gravity="center" |
| | | android:layout_weight="1" |
| | | android:background="@color/white" |
| | | android:gravity="center" |
| | | android:text="取消" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_confirm" |
| | | android:layout_width="0dp" |
| | | android:layout_height="38dp" |
| | | android:layout_gravity="center" |
| | | android:layout_marginLeft="5dp" |
| | | android:layout_weight="1" |
| | | android:background="@color/white" |
| | | android:gravity="center" |
| | | android:text="确认" /> |
| | | </LinearLayout> |
| | | </LinearLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:background="@color/register_gray" |
| | | android:orientation="vertical"> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_dialog_title" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:background="@color/white" |
| | | android:gravity="center" |
| | | android:padding="8dp" |
| | | android:textSize="20sp" |
| | | android:textStyle="bold" /> |
| | | |
| | | <EditText |
| | | android:id="@+id/et_dialog_message" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="150dp" |
| | | android:layout_margin="5dp" |
| | | android:background="@color/white" |
| | | android:padding="8dp" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="38dp"> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_cancel" |
| | | android:layout_width="0dp" |
| | | android:layout_height="match_parent" |
| | | android:layout_gravity="center" |
| | | android:layout_margin="5dp" |
| | | android:layout_weight="1" |
| | | android:background="@color/white" |
| | | android:gravity="center" |
| | | android:text="取消" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_confirm" |
| | | android:layout_width="0dp" |
| | | android:layout_height="match_parent" |
| | | android:layout_margin="5dp" |
| | | android:layout_weight="1" |
| | | android:background="@color/white" |
| | | android:gravity="center" |
| | | android:text="确认" /> |
| | | </LinearLayout> |
| | | </LinearLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <resources> |
| | | <color name="transparent">#00000000</color> |
| | | <color name="blue1">#ff028cf7</color> |
| | | <color name="white">#FFFFFFFF</color> |
| | | <color name="red">#FFe9372d</color> |
| | | <color name="yellow">#FFf7db00</color> |
| | | <color name="white_discover">#bbFFFFFF</color> |
| | | <color name="goods_divider_color">#fff1f1f1</color> |
| | | <color name="black1">#ff161514</color> |
| | | <color name="qq_blue">#4CAFEA</color> |
| | | <color name="blue">#FFFFFFFF</color> |
| | | <color name="blue2">#ff028cf7</color> |
| | | <color name="blue3">#FF067cf6</color> |
| | | <color name="blue4">#ff78c2fc</color> |
| | | <color name="gray">#ff999999</color> |
| | | <color name="gray2">#ffd0d0d0</color> |
| | | <color name="bg_download_so">#FF987b63</color> |
| | | <color name="top_bar_color">#ff333333</color> |
| | | <color name="black">#ff333333</color> |
| | | <color name="light_gray">#ffcccccc</color> |
| | | <color name="register_gray">#f3f2f0</color> |
| | | <color name="bg">#ffeeeeee</color> |
| | | <color name="fill_color">#30EE0A</color> |
| | | <color name="green">#2ac600</color> |
| | | <color name="main_color">#fff9644e</color> |
| | | <color name="page_color">#32B1E6</color> |
| | | <color name="light_light_gray">#F2F2F2</color> |
| | | <!-- <color name="register_gray">#323544</color> --> |
| | | <color name="backgroud_gray">#fafafa</color> |
| | | <color name="message_backgroud_gray">#f5f5f5</color> |
| | | <color name="category_unique_lv_item">#2880BF</color> |
| | | <color name="category_star_tv_font">#656565</color> |
| | | |
| | | <drawable name="blued">#ff009fe1</drawable> |
| | | |
| | | <color name="colorAccent">#FF4081</color> |
| | | |
| | | <color name="transparent_gray">#99666666</color> |
| | | |
| | | |
| | | <color name="colorLoading">#159FFF</color> |
| | | </resources> |
New file |
| | |
| | | <resources> |
| | | <string name="agreement" translatable="false">http://111.231.250.166/mugua/userAgreenment.html</string> |
| | | <string name="rule_email">0123456789abcdefghijklmnopqrstuvwxyz@.</string> |
| | | <string name="rule_password">0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`¬!"£$%^*()~=#{}[];':,./?/*-_+<>@&</string> |
| | | <string name="user_agreement">用户使用协议&隐私条款</string> |
| | | |
| | | </resources> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <resources> |
| | | |
| | | <style name="TextWhiteSmall"> |
| | | <item name="android:textColor">@android:color/white</item> |
| | | <item name="android:textAppearance">?android:attr/textAppearanceSmall</item> |
| | | </style> |
| | | |
| | | <style name="TextWhiteNormal"> |
| | | <item name="android:textColor">@android:color/white</item> |
| | | <item name="android:textAppearance">?android:attr/textAppearance</item> |
| | | </style> |
| | | |
| | | <style name="TextBule"> |
| | | <item name="android:textColor">@color/blue2</item> |
| | | </style> |
| | | |
| | | <style name="TextBule1"> |
| | | <item name="android:textColor">@color/blue</item> |
| | | </style> |
| | | |
| | | <style name="TextBule2"> |
| | | <item name="android:textColor">@color/blue2</item> |
| | | </style> |
| | | |
| | | <style name="TextBuleLarge" parent="TextBule1"> |
| | | <item name="android:textAppearance">?android:attr/textAppearanceLarge</item> |
| | | </style> |
| | | |
| | | <style name="TextBuleMedium" parent="TextBule1"> |
| | | <item name="android:textAppearance">?android:attr/textAppearanceMedium</item> |
| | | </style> |
| | | |
| | | <style name="TextBuleNormal" parent="TextBule1"> |
| | | <item name="android:textAppearance">?android:attr/textAppearance</item> |
| | | </style> |
| | | |
| | | <style name="TextBuleSmall" parent="TextBule"> |
| | | <item name="android:textAppearance">?android:attr/textAppearanceSmall</item> |
| | | </style> |
| | | |
| | | <style name="TextBlackNormal"> |
| | | <item name="android:textColor">@color/black</item> |
| | | <item name="android:textAppearance">?android:attr/textAppearance</item> |
| | | </style> |
| | | |
| | | <style name="TextBlackSmall"> |
| | | <item name="android:textColor">@color/black</item> |
| | | <item name="android:textAppearance">?android:attr/textAppearanceSmall</item> |
| | | </style> |
| | | |
| | | <style name="TextBlackMedium"> |
| | | <item name="android:textColor">@color/black</item> |
| | | <item name="android:textAppearance">?android:attr/textAppearanceMedium</item> |
| | | </style> |
| | | |
| | | </resources> |
New file |
| | |
| | | package com.yeshi.ec.base; |
| | | |
| | | import org.junit.Test; |
| | | |
| | | import static org.junit.Assert.*; |
| | | |
| | | /** |
| | | * Example local unit test, which will execute on the development machine (host). |
| | | * |
| | | * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> |
| | | */ |
| | | public class ExampleUnitTest { |
| | | @Test |
| | | public void addition_isCorrect() { |
| | | assertEquals(4, 2 + 2); |
| | | } |
| | | } |
| | |
| | | dependencies { |
| | | // api fileTree(include: '*.jar', dir: 'libs') |
| | | api 'com.squareup.okhttp3:okhttp:3.8.1' |
| | | api 'com.android.support:support-v4:27.1.1' |
| | | api 'com.android.support:recyclerview-v7:27.1.1' |
| | | api 'androidx.legacy:legacy-support-v4:1.0.0' |
| | | api 'androidx.recyclerview:recyclerview:1.0.0' |
| | | api project(':library-NineOldAndroids') |
| | | api 'com.github.bumptech.glide:glide:4.9.0' |
| | | api 'com.google.code.gson:gson:1.7.1' |
| | |
| | | // api files('libs/android-async-http-1.4.8.jar') |
| | | |
| | | api 'com.taobao.android:utdid4all:1.5.2' |
| | | api 'com.alibaba:arouter-api:1.4.1' |
| | | } |
| | | |
| | | android { |
| | |
| | | import android.content.SharedPreferences; |
| | | import android.content.pm.PackageManager; |
| | | import android.provider.Settings.Secure; |
| | | import android.support.v4.content.ContextCompat; |
| | | import androidx.core.content.ContextCompat; |
| | | import android.telephony.TelephonyManager; |
| | | |
| | | public class DeviceUuidFactory { |
| | |
| | | package com.lcjian.library; |
| | | |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.Fragment; |
| | | import androidx.fragment.app.Fragment; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | |
| | | import android.database.Cursor; |
| | | import android.database.sqlite.SQLiteDatabase; |
| | | import android.net.Uri; |
| | | import android.support.v4.content.AsyncTaskLoader; |
| | | import androidx.loader.content.AsyncTaskLoader; |
| | | |
| | | public class CursorLoader extends AsyncTaskLoader<Cursor> { |
| | | final ForceLoadContentObserver mObserver; |
| | |
| | | package com.lcjian.library.emotion; |
| | | |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.Fragment; |
| | | import androidx.fragment.app.Fragment; |
| | | import android.view.Gravity; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | |
| | | package com.lcjian.library.emotion; |
| | | |
| | | import android.support.v4.app.Fragment; |
| | | import androidx.fragment.app.Fragment; |
| | | |
| | | public class EmotionsFragment extends Fragment { |
| | | |
| | |
| | | import android.database.Cursor; |
| | | import android.net.Uri; |
| | | import android.os.Build; |
| | | import android.support.v4.content.FileProvider; |
| | | import androidx.core.content.FileProvider; |
| | | import android.util.Log; |
| | | import android.webkit.MimeTypeMap; |
| | | |
| | | import com.lcjian.lcjianlibrary.BuildConfig; |
| | | |
| | | import java.io.File; |
| | | |
| | |
| | | //判断是否是AndroidN以及更高的版本 |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| | | intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
| | | Uri contentUri = FileProvider.getUriForFile(context.getApplicationContext(), BuildConfig.APPLICATION_ID + ".fileprovider", file); |
| | | Uri contentUri = FileProvider.getUriForFile(context.getApplicationContext(), getPackageName() + ".fileprovider", file); |
| | | intent.setDataAndType(contentUri, "application/vnd.android.package-archive"); |
| | | } else { |
| | | Uri uri = Uri.fromFile(file); |
| | |
| | | |
| | | import android.app.Dialog; |
| | | import android.content.Context; |
| | | import android.support.v4.app.Fragment; |
| | | import androidx.fragment.app.Fragment; |
| | | import android.view.Gravity; |
| | | import android.view.View; |
| | | import android.view.Window; |
| | |
| | | package com.lcjian.library.util; |
| | | |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.FragmentManager; |
| | | import android.support.v4.app.FragmentTransaction; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentManager; |
| | | import androidx.fragment.app.FragmentTransaction; |
| | | import android.util.Log; |
| | | |
| | | public class FragmentSwitchHelper { |
| | |
| | | import android.net.Uri; |
| | | import android.os.Environment; |
| | | import android.provider.MediaStore; |
| | | import android.support.v4.app.Fragment; |
| | | import androidx.fragment.app.Fragment; |
| | | |
| | | public class ImageChooseHelper { |
| | | |
| | |
| | | package com.lcjian.library.util; |
| | | |
| | | import android.content.Context; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import android.util.AttributeSet; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | |
| | | import android.app.ActivityManager; |
| | | import android.content.Context; |
| | | import android.graphics.Bitmap; |
| | | import android.support.v4.util.LruCache; |
| | | import androidx.collection.LruCache; |
| | | |
| | | /** |
| | | * 从内存读取数据速度是最快的,为了更大限度使用内存,这里使用了两层缓存。 硬引用缓存不会轻易被回收,用来保存常用数据,不常用的转入软引用缓存。 |
| | |
| | | return metric.heightPixels; |
| | | } |
| | | |
| | | |
| | | public static int getScreenWidth(Context context) { |
| | | DisplayMetrics dm = context.getResources().getDisplayMetrics(); |
| | | return dm.widthPixels; |
| | | } |
| | | |
| | | public static int getScreenHeight(Context context) { |
| | | DisplayMetrics dm = context.getResources().getDisplayMetrics(); |
| | | return dm.heightPixels; |
| | | } |
| | | |
| | | /** |
| | | * 根据手机的分辨率从 dp 的单位 转成为 px(像素) |
| | | */ |
| | |
| | | import android.graphics.BitmapShader; |
| | | import android.graphics.Canvas; |
| | | import android.graphics.Paint; |
| | | import android.support.annotation.NonNull; |
| | | import androidx.annotation.NonNull; |
| | | |
| | | import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; |
| | | import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; |
| | |
| | | import android.graphics.Canvas; |
| | | import android.graphics.Paint; |
| | | import android.graphics.RectF; |
| | | import android.support.annotation.NonNull; |
| | | import androidx.annotation.NonNull; |
| | | |
| | | import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; |
| | | import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; |
| | |
| | | package com.lcjian.library.widget; |
| | | |
| | | import android.content.Context; |
| | | import android.support.v4.view.ViewPager; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | import android.util.AttributeSet; |
| | | import android.view.View; |
| | | |
| | |
| | | |
| | | import android.content.Context; |
| | | import android.graphics.drawable.Drawable; |
| | | import android.support.annotation.Nullable; |
| | | import androidx.annotation.Nullable; |
| | | import android.util.AttributeSet; |
| | | import android.widget.ImageView; |
| | | |
| | |
| | | import android.content.res.Resources; |
| | | import android.content.res.TypedArray; |
| | | import android.graphics.Canvas; |
| | | import android.support.v4.view.MotionEventCompat; |
| | | import android.support.v4.view.ViewCompat; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import androidx.core.view.MotionEventCompat; |
| | | import androidx.core.view.ViewCompat; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import android.util.AttributeSet; |
| | | import android.util.DisplayMetrics; |
| | | import android.util.Log; |
| | |
| | | import android.graphics.Paint; |
| | | import android.graphics.Rect; |
| | | import android.graphics.RectF; |
| | | import android.support.v4.view.ViewCompat; |
| | | import androidx.core.view.ViewCompat; |
| | | import android.view.View; |
| | | import android.view.animation.AnimationUtils; |
| | | import android.view.animation.Interpolator; |
New file |
| | |
| | | plugins { |
| | | id 'com.android.library' |
| | | } |
| | | |
| | | android { |
| | | compileSdkVersion 28 |
| | | buildToolsVersion "28.0.3" |
| | | |
| | | defaultConfig { |
| | | minSdkVersion 17 |
| | | targetSdkVersion 28 |
| | | versionCode 1 |
| | | versionName "1.0" |
| | | |
| | | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| | | consumerProguardFiles "consumer-rules.pro" |
| | | |
| | | javaCompileOptions { |
| | | annotationProcessorOptions { |
| | | arguments = [AROUTER_MODULE_NAME: project.getName()] |
| | | } |
| | | } |
| | | } |
| | | |
| | | buildTypes { |
| | | release { |
| | | minifyEnabled false |
| | | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| | | } |
| | | } |
| | | compileOptions { |
| | | sourceCompatibility JavaVersion.VERSION_1_8 |
| | | targetCompatibility JavaVersion.VERSION_1_8 |
| | | } |
| | | } |
| | | |
| | | dependencies { |
| | | |
| | | implementation 'androidx.appcompat:appcompat:1.1.0' |
| | | implementation 'com.google.android.material:material:1.1.0' |
| | | implementation project(path: ':library-base') |
| | | implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0' |
| | | implementation project(path: ':library-common') |
| | | testImplementation 'junit:junit:4.+' |
| | | androidTestImplementation 'androidx.test.ext:junit:1.1.1' |
| | | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' |
| | | |
| | | annotationProcessor'com.alibaba:arouter-compiler:1.2.2' |
| | | |
| | | } |
New file |
| | |
| | | # Add project specific ProGuard rules here. |
| | | # You can control the set of applied configuration files using the |
| | | # proguardFiles setting in build.gradle. |
| | | # |
| | | # For more details, see |
| | | # http://developer.android.com/guide/developing/tools/proguard.html |
| | | |
| | | # If your project uses WebView with JS, uncomment the following |
| | | # and specify the fully qualified class name to the JavaScript interface |
| | | # class: |
| | | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { |
| | | # public *; |
| | | #} |
| | | |
| | | # Uncomment this to preserve the line number information for |
| | | # debugging stack traces. |
| | | #-keepattributes SourceFile,LineNumberTable |
| | | |
| | | # If you keep the line number information, uncomment this to |
| | | # hide the original source file name. |
| | | #-renamesourcefileattribute SourceFile |
New file |
| | |
| | | package com.yeshi.ec.search; |
| | | |
| | | import android.content.Context; |
| | | |
| | | import androidx.test.platform.app.InstrumentationRegistry; |
| | | import androidx.test.ext.junit.runners.AndroidJUnit4; |
| | | |
| | | import org.junit.Test; |
| | | import org.junit.runner.RunWith; |
| | | |
| | | import static org.junit.Assert.*; |
| | | |
| | | /** |
| | | * Instrumented test, which will execute on an Android device. |
| | | * |
| | | * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> |
| | | */ |
| | | @RunWith(AndroidJUnit4.class) |
| | | public class ExampleInstrumentedTest { |
| | | @Test |
| | | public void useAppContext() { |
| | | // Context of the app under test. |
| | | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); |
| | | assertEquals("com.yeshi.ec.search.test", appContext.getPackageName()); |
| | | } |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| | | package="com.yeshi.ec.search"> |
| | | |
| | | <application> |
| | | <activity |
| | | android:name=".ui.SearchResultActivity" |
| | | android:screenOrientation="portrait"></activity> |
| | | </application> |
| | | </manifest> |
New file |
| | |
| | | package com.yeshi.ec.search.ui; |
| | | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.graphics.Color; |
| | | import android.graphics.Typeface; |
| | | import android.graphics.drawable.Drawable; |
| | | import android.os.Bundle; |
| | | import android.text.Editable; |
| | | import android.text.TextUtils; |
| | | import android.text.TextWatcher; |
| | | import android.view.KeyEvent; |
| | | import android.view.LayoutInflater; |
| | | import android.view.MotionEvent; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.view.View.OnTouchListener; |
| | | import android.view.ViewGroup; |
| | | import android.view.inputmethod.EditorInfo; |
| | | import android.widget.EditText; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.ProgressBar; |
| | | import android.widget.TextView; |
| | | |
| | | import com.alibaba.android.arouter.facade.annotation.Route; |
| | | import com.alibaba.android.arouter.launcher.ARouter; |
| | | 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.common.DimenUtils; |
| | | import com.lcjian.library.util.common.SoftKeyboardUtils; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.qq.e.ads.cfg.VideoOption; |
| | | import com.qq.e.ads.nativ.NativeADUnifiedListener; |
| | | import com.qq.e.ads.nativ.NativeUnifiedAD; |
| | | import com.qq.e.ads.nativ.NativeUnifiedADData; |
| | | import com.qq.e.comm.util.AdError; |
| | | import com.yeshi.base.entity.ad.ExpressAdContainer; |
| | | import com.yeshi.base.entity.video.VideoContent; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.yeshi.base.entity.video.VideoType; |
| | | import com.yeshi.base.ui.BaseActivity; |
| | | import com.yeshi.base.utils.RouteConstant; |
| | | import com.yeshi.base.utils.ad.ExpressAdManager; |
| | | import com.yeshi.base.utils.ad.GDTConstant; |
| | | import com.yeshi.base.utils.http.BasicTextHttpResponseHandler; |
| | | import com.yeshi.base.utils.ui.DividerItemDecoration; |
| | | import com.yeshi.ec.search.R; |
| | | import com.yeshi.ec.search.util.SearchApiUtil; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | |
| | | @Route(path = RouteConstant.PATH_VIDEO_SEARCH_RESULT) |
| | | public class SearchResultActivity extends BaseActivity implements |
| | | OnClickListener { |
| | | |
| | | private EditText et_search_key; |
| | | |
| | | private TextView tv_search_cancel; |
| | | |
| | | private RecyclerView rv_video_search; |
| | | |
| | | private List<VideoContent> mVideoInfos; |
| | | |
| | | private SearchResultAdapter adapter; |
| | | |
| | | |
| | | private int mCurrentPage = 1; |
| | | |
| | | private String mCurrentType = "0"; |
| | | |
| | | private String mCurrentKey; |
| | | |
| | | private boolean mFirst = true; |
| | | |
| | | private SwipeRefreshLayout rl_search_result; |
| | | |
| | | private ExpressAdManager expressAdManager; |
| | | |
| | | private boolean isLoad; |
| | | |
| | | private View loading; |
| | | |
| | | private LinearLayout ll_top_bar; |
| | | |
| | | List<VideoType> typeList; |
| | | |
| | | private LinearLayout ll_empty; |
| | | |
| | | private SearchSuggestFragment suggestFragment; |
| | | |
| | | private FrameLayout fl_suggest; |
| | | |
| | | //赚影视豆 |
| | | private Runnable makeGoldCornRunnable; |
| | | |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.search_result_activity); |
| | | ARouter.getInstance().inject(this); |
| | | |
| | | suggestFragment = new SearchSuggestFragment(); |
| | | |
| | | rl_search_result = findViewById(R.id.rl_search_result); |
| | | et_search_key = findViewById(R.id.et_search_key); |
| | | tv_search_cancel = findViewById(R.id.tv_search_cancel); |
| | | rv_video_search = findViewById(R.id.rv_video_search); |
| | | ll_top_bar = findViewById(R.id.ll_top_bar); |
| | | ll_empty = findViewById(R.id.ll_empty); |
| | | fl_suggest = findViewById(R.id.fl_suggest); |
| | | |
| | | tv_search_cancel.setOnClickListener(this); |
| | | et_search_key.addTextChangedListener(new TextWatcher() { |
| | | |
| | | @Override |
| | | public void onTextChanged(CharSequence s, int start, int before, |
| | | int count) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void beforeTextChanged(CharSequence s, int start, int count, |
| | | int after) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable s) { |
| | | if (!TextUtils.isEmpty(s.toString())) { |
| | | et_search_key.setCompoundDrawablesWithIntrinsicBounds(0, 0, |
| | | R.drawable.ic_clear, 0); |
| | | } else { |
| | | et_search_key.setCompoundDrawablesWithIntrinsicBounds(0, 0, |
| | | 0, 0); |
| | | } |
| | | if (mFirst) { |
| | | mFirst = false; |
| | | } else { |
| | | suggestSearch(s != null ? s.toString() : null); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | et_search_key.setOnTouchListener(new OnTouchListener() { |
| | | |
| | | @Override |
| | | public boolean onTouch(View v, MotionEvent event) { |
| | | // getCompoundDrawables() 可以获取一个长度为4的数组, |
| | | // 存放drawableLeft,Right,Top,Bottom四个图片资源对象 |
| | | // index=2 表示的是 drawableRight 图片资源对象 |
| | | Drawable drawable = et_search_key.getCompoundDrawables()[2]; |
| | | if (drawable == null) |
| | | return false; |
| | | |
| | | if (event.getAction() != MotionEvent.ACTION_UP) |
| | | return false; |
| | | |
| | | // drawable.getIntrinsicWidth() 获取drawable资源图片呈现的宽度 |
| | | if (event.getX() > et_search_key.getWidth() |
| | | - et_search_key.getPaddingRight() |
| | | - drawable.getIntrinsicWidth()) { |
| | | et_search_key.setText(""); |
| | | } |
| | | return false; |
| | | } |
| | | }); |
| | | |
| | | |
| | | et_search_key.setOnEditorActionListener(new TextView.OnEditorActionListener() { |
| | | @Override |
| | | public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { |
| | | if (actionId == EditorInfo.IME_ACTION_SEARCH) { |
| | | startSearch(); |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | }); |
| | | |
| | | |
| | | mCurrentKey = getIntent().getStringExtra("key"); |
| | | et_search_key.setText(mCurrentKey); |
| | | et_search_key.setSelection(mCurrentKey.length()); |
| | | // et_search_key.setText(mCurrentKey); |
| | | |
| | | mVideoInfos = new ArrayList<>(); |
| | | rl_search_result.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { |
| | | @Override |
| | | public void onRefresh() { |
| | | mCurrentPage = 1; |
| | | search(mCurrentKey, mCurrentType); |
| | | } |
| | | }); |
| | | |
| | | |
| | | rv_video_search.setLayoutManager(new MyLinearLayoutManager(getApplicationContext())); |
| | | DividerItemDecoration decoration = new DividerItemDecoration(); |
| | | decoration.setSize(DimenUtils.dip2px(rv_video_search.getContext(), 15)); |
| | | rv_video_search.addItemDecoration(decoration); |
| | | |
| | | adapter = new SearchResultAdapter(this, mVideoInfos, new SearchResultAdapter.VideoAlbumNavClickListener() { |
| | | @Override |
| | | public void onNav(int p) { |
| | | navClick(p); |
| | | } |
| | | }); |
| | | loading = LayoutInflater.from(this).inflate(R.layout.item_loading, null); |
| | | loading.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); |
| | | loading.setVisibility(View.GONE); |
| | | adapter.setFooterView(loading); |
| | | |
| | | rv_video_search.setAdapter(adapter); |
| | | rv_video_search.addOnScrollListener(new RecyclerView.OnScrollListener() { |
| | | @Override |
| | | public void onScrollStateChanged(RecyclerView recyclerView, int newState) { |
| | | super.onScrollStateChanged(recyclerView, newState); |
| | | LinearLayoutManager manager = (LinearLayoutManager) recyclerView.getLayoutManager(); |
| | | int first = manager.findFirstVisibleItemPosition(); |
| | | int last = manager.findLastVisibleItemPosition(); |
| | | int total = manager.getItemCount(); |
| | | if (newState == RecyclerView.SCROLL_STATE_IDLE) { |
| | | if ((!isLoad) && last == total - 1 && mVideoInfos.size() < 1000) { |
| | | if (mVideoInfos != null && mVideoInfos.size() > 0 && !rl_search_result.isRefreshing()) {//列表中有数据才能加载更多 |
| | | mCurrentPage++; |
| | | isLoad = true; |
| | | loading.setVisibility(View.VISIBLE); |
| | | search(mCurrentKey, mCurrentType); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onScrolled(RecyclerView recyclerView, int dx, final int dy) { |
| | | super.onScrolled(recyclerView, dx, dy); |
| | | } |
| | | }); |
| | | |
| | | rl_search_result.setRefreshing(true); |
| | | search(mCurrentKey, mCurrentType); |
| | | } |
| | | |
| | | private void startSearch() { |
| | | if (StringUtils.isEmpty(et_search_key.getEditableText() |
| | | .toString())) { |
| | | mCurrentKey = et_search_key.getText().toString(); |
| | | } else { |
| | | mCurrentKey = et_search_key.getEditableText().toString(); |
| | | } |
| | | SoftKeyboardUtils.hideSoftInput(SearchResultActivity.this); |
| | | mCurrentPage = 1; |
| | | rl_search_result.setRefreshing(true); |
| | | //清除顶部分类 |
| | | typeList = null; |
| | | search(mCurrentKey, mCurrentType); |
| | | } |
| | | |
| | | |
| | | private void initTopBar() { |
| | | int p = 0; |
| | | ll_top_bar.removeAllViews(); |
| | | LayoutInflater inflater = LayoutInflater.from(getApplicationContext()); |
| | | for (int i = 0; i < typeList.size(); i++) { |
| | | final View view = inflater.inflate(R.layout.item_search_result_top_bar_content, null); |
| | | TextView tv_name = view.findViewById(R.id.tv_name); |
| | | tv_name.setText(typeList.get(i).getName()); |
| | | setTopBarSelect(tv_name, i == p); |
| | | ll_top_bar.addView(view); |
| | | ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) view.getLayoutParams(); |
| | | params.rightMargin = DimenUtils.dip2px(getApplicationContext(), 17); |
| | | params.leftMargin = DimenUtils.dip2px(getApplicationContext(), 10); |
| | | view.setTag(i); |
| | | view.setOnClickListener(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | int p = Integer.parseInt(view.getTag() + ""); |
| | | navClick(p); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void navClick(int p) { |
| | | if (typeList == null || typeList.size() <= p) |
| | | return; |
| | | selectTopBar(p); |
| | | VideoType vt = typeList.get(p); |
| | | |
| | | if (StringUtils.isBlank(mCurrentType) || !mCurrentType.equalsIgnoreCase(vt.getId())) { |
| | | mCurrentPage = 1; |
| | | mCurrentType = vt.getId(); |
| | | rl_search_result.setRefreshing(true); |
| | | search(mCurrentKey, mCurrentType); |
| | | } |
| | | } |
| | | |
| | | private void setTopBarSelect(TextView tv_name, boolean selected) { |
| | | if (selected) { |
| | | tv_name.setBackgroundResource(R.drawable.vpi__tab_selected_focused_holo); |
| | | tv_name.setTextSize(19); |
| | | tv_name.setTextColor(getResources().getColor(R.color.search_nav_highlight_text_color)); |
| | | tv_name.setPadding(0, 0, 0, DimenUtils.dip2px(getApplicationContext(), 5)); |
| | | tv_name.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); |
| | | } else { |
| | | tv_name.setBackground(null); |
| | | tv_name.setTextSize(14); |
| | | tv_name.setTextColor(getResources().getColor(R.color.nav_text_color)); |
| | | tv_name.setPadding(0, 0, 0, 0); |
| | | tv_name.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL)); |
| | | } |
| | | } |
| | | |
| | | private void selectTopBar(int p) { |
| | | for (int i = 0; i < ll_top_bar.getChildCount(); i++) { |
| | | TextView tv = ll_top_bar.getChildAt(i).findViewById(R.id.tv_name); |
| | | setTopBarSelect(tv, i == p); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void hiddenSuggestFragment() { |
| | | fl_suggest.setVisibility(View.GONE); |
| | | getSupportFragmentManager().beginTransaction().remove(suggestFragment).commitAllowingStateLoss(); |
| | | } |
| | | |
| | | private void showSuggestFragment(String key, List<String> list) { |
| | | Bundle bundle = new Bundle(); |
| | | bundle.putString("key", key); |
| | | bundle.putString("list", new Gson().toJson(list)); |
| | | fl_suggest.setVisibility(View.VISIBLE); |
| | | suggestFragment.setItemClickListener(new SearchSuggestFragment.OnItemClickListener() { |
| | | @Override |
| | | public void onClick(String st) { |
| | | mFirst = true; |
| | | hiddenSuggestFragment(); |
| | | et_search_key.setText(st); |
| | | startSearch(); |
| | | } |
| | | }); |
| | | |
| | | suggestFragment.setArguments(bundle); |
| | | getSupportFragmentManager().beginTransaction().replace(R.id.fl_suggest, suggestFragment).commitAllowingStateLoss(); |
| | | } |
| | | |
| | | |
| | | private void suggestSearch(String key) { |
| | | if (StringUtils.isEmpty(key)) { |
| | | hiddenSuggestFragment(); |
| | | } |
| | | |
| | | SharedPreferences preferences = getSharedPreferences("user", |
| | | Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | SearchApiUtil.suggestSearch(this, key, |
| | | new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | List<String> results = null; |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | results = gson.fromJson(jsonObject |
| | | .getJSONObject("Data").getJSONArray("data") |
| | | .toString(), new TypeToken<List<String>>() { |
| | | }.getType()); |
| | | |
| | | |
| | | // SuggestKeysAdapter adapter = new SuggestKeysAdapter(getApplicationContext(), results); |
| | | // et_search_key.setAdapter(adapter); |
| | | // adapter.notifyDataSetChanged(); |
| | | } |
| | | |
| | | if (results != null && results.size() > 0) { |
| | | showSuggestFragment(key, results); |
| | | suggestFragment.setData(key, results); |
| | | } else { |
| | | hiddenSuggestFragment(); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private synchronized void fillAD(List<ExpressAdContainer> adList) { |
| | | |
| | | //判断当前页面是否需要广告 |
| | | int albumCount = 0; |
| | | if (mVideoInfos != null && mVideoInfos.size() > 0) |
| | | for (int i = 0; i < mVideoInfos.size(); i++) { |
| | | VideoContent vc = mVideoInfos.get(i); |
| | | if (vc.getType() == VideoContent.TYPE_AD) { |
| | | //更新广告 |
| | | vc.setAd(adList.get(0)); |
| | | adapter.notifyItemChanged(i); |
| | | return; |
| | | } else if (vc.getVideo().getShowType() == 1) { |
| | | albumCount++; |
| | | } |
| | | } |
| | | |
| | | if (albumCount >= 1) { |
| | | VideoContent videoContent = VideoContent.createAdContent(adList.get(0)); |
| | | mVideoInfos.add(1, videoContent); |
| | | adapter.notifyItemInserted(1); |
| | | } |
| | | |
| | | } |
| | | |
| | | //拉取2.0的自渲染广告 |
| | | private void loadAd() { |
| | | //TODO 填充广告ID |
| | | String pid = GDTConstant.PID_2_SEARCH_RESULT_ALBUM; |
| | | NativeUnifiedAD mAdManager = new NativeUnifiedAD(this, pid, new NativeADUnifiedListener() { |
| | | |
| | | @Override |
| | | public void onNoAD(AdError adError) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADLoaded(List<NativeUnifiedADData> list) { |
| | | if (list != null && list.size() > 0) { |
| | | List<ExpressAdContainer> adList = new ArrayList<>(); |
| | | adList.add(new ExpressAdContainer(list.get(0))); |
| | | fillAD(adList); |
| | | } |
| | | } |
| | | }); |
| | | mAdManager.setVideoPlayPolicy(VideoOption.VideoPlayPolicy.AUTO); |
| | | mAdManager.loadData(1); |
| | | } |
| | | |
| | | // private void loadAd() { |
| | | // ExpressAdContainer ad = SearchResultAdManager.getInstance(getApplicationContext()).consumeAD(); |
| | | // if (ad == null) { |
| | | // SearchResultAdManager.getInstance(getApplicationContext()).loadAD(1, new ExpressAdManager.IAdLoadListener() { |
| | | // @Override |
| | | // public void onSuccess(List<ExpressAdContainer> adList) { |
| | | // fillAD(adList); |
| | | // } |
| | | // }); |
| | | // } else { |
| | | // List<ExpressAdContainer> adList = new ArrayList<>(); |
| | | // adList.add(ad); |
| | | // fillAD(adList); |
| | | // } |
| | | // //加载下一个需要的广告 |
| | | // SearchResultAdManager.getInstance(getApplicationContext()).autoLoadAd(); |
| | | // } |
| | | |
| | | |
| | | private void search(String key, String videoType) { |
| | | SearchApiUtil.search(this, key, videoType, |
| | | mCurrentPage, |
| | | new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | hiddenSuggestFragment(); |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | JSONObject rootData = jsonObject.getJSONObject("Data"); |
| | | List<VideoInfo> videoInfos = gson.fromJson( |
| | | |
| | | rootData.getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | | }.getType()); |
| | | |
| | | //设置导航栏 |
| | | if (rootData.opt("typeList") != null) { |
| | | if (typeList == null) { |
| | | typeList = gson.fromJson( |
| | | rootData |
| | | .getJSONArray("typeList").toString(), |
| | | new TypeToken<List<VideoType>>() { |
| | | }.getType()); |
| | | initTopBar(); |
| | | } |
| | | } |
| | | |
| | | List<VideoContent> videoContentList = new ArrayList<>(); |
| | | for (VideoInfo video : videoInfos) { |
| | | videoContentList.add(VideoContent.createVideoContent(video)); |
| | | } |
| | | |
| | | |
| | | //记录当前的广告信息 |
| | | VideoContent adContent = null; |
| | | int adContentP = -1; |
| | | if (mCurrentPage <= 1) { |
| | | for (int i = 0; i < mVideoInfos.size(); i++) { |
| | | if (mVideoInfos.get(i).getType() == VideoContent.TYPE_AD) { |
| | | adContent = mVideoInfos.get(i); |
| | | adContentP = i; |
| | | } |
| | | } |
| | | mVideoInfos.clear(); |
| | | } |
| | | |
| | | mVideoInfos.addAll(videoContentList); |
| | | if (adContent != null && mVideoInfos.size() >= adContentP) { |
| | | mVideoInfos.add(adContentP, adContent); |
| | | } |
| | | adapter.notifyDataSetChanged(); |
| | | |
| | | if (mVideoInfos != null && mVideoInfos.size() > 0) { |
| | | //有值 |
| | | ll_empty.setVisibility(View.GONE); |
| | | rl_search_result.setVisibility(View.VISIBLE); |
| | | } else { |
| | | //无值 |
| | | ll_empty.setVisibility(View.VISIBLE); |
| | | rl_search_result.setVisibility(View.GONE); |
| | | } |
| | | |
| | | if (mCurrentPage == 1) { |
| | | loadAd(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | isLoad = false; |
| | | rl_search_result.setRefreshing(false); |
| | | loading.setVisibility(View.GONE); |
| | | } |
| | | }); |
| | | |
| | | saveHistory(key); |
| | | } |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | } |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | int id = v.getId(); |
| | | if (id == R.id.tv_search_cancel) { |
| | | if (fl_suggest.getVisibility() == View.VISIBLE) { |
| | | hiddenSuggestFragment(); |
| | | } else { |
| | | finish(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void saveHistory(String key) { |
| | | // 获取搜索框信息 |
| | | SharedPreferences historySp = getSharedPreferences("search_history", |
| | | Context.MODE_PRIVATE); |
| | | String history = historySp.getString("history", ""); |
| | | |
| | | key = key.replace(",", ""); |
| | | String[] historyArray = history.split(","); |
| | | List<String> temps = new ArrayList<String>(); |
| | | for (int i = 0; i < historyArray.length && i < 20; i++) { |
| | | if (!TextUtils.isEmpty(historyArray[i]) |
| | | && !historyArray[i].equals(key)) { |
| | | temps.add(historyArray[i]); |
| | | } |
| | | } |
| | | temps.add(key); |
| | | StringBuilder builder = new StringBuilder(); |
| | | for (String str : temps) { |
| | | builder.append(str).append(","); |
| | | } |
| | | historySp |
| | | .edit() |
| | | .putString("history", |
| | | builder.substring(0, builder.length() - 1)).commit(); |
| | | } |
| | | |
| | | |
| | | class MyLinearLayoutManager extends LinearLayoutManager { |
| | | |
| | | public MyLinearLayoutManager(Context context) { |
| | | super(context); |
| | | } |
| | | |
| | | @Override |
| | | public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) { |
| | | try { |
| | | super.onLayoutChildren(recycler, state); |
| | | } catch (IndexOutOfBoundsException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected void onDestroy() { |
| | | super.onDestroy(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.ec.search.ui; |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Intent; |
| | | import android.graphics.Color; |
| | | import android.graphics.Typeface; |
| | | import android.text.SpannableString; |
| | | import android.text.Spanned; |
| | | import android.text.style.AbsoluteSizeSpan; |
| | | import android.text.style.ForegroundColorSpan; |
| | | import android.text.style.StyleSpan; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.alibaba.android.arouter.facade.Postcard; |
| | | import com.alibaba.android.arouter.launcher.ARouter; |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.request.RequestOptions; |
| | | import com.lcjian.library.util.common.DimenUtils; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.lcjian.library.util.glide.GlideRoundTransform; |
| | | import com.lcjian.library.widget.RatioLayout; |
| | | import com.qq.e.ads.nativ.NativeADEventListener; |
| | | import com.qq.e.ads.nativ.NativeUnifiedADData; |
| | | import com.qq.e.ads.nativ.widget.NativeAdContainer; |
| | | import com.qq.e.comm.util.AdError; |
| | | import com.yeshi.base.entity.video.VideoContent; |
| | | import com.yeshi.base.entity.video.VideoDetailInfo; |
| | | import com.yeshi.base.entity.video.VideoInfo; |
| | | import com.yeshi.base.utils.RouteConstant; |
| | | import com.yeshi.ec.search.R; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | | /** |
| | | * 一列视频样式 |
| | | */ |
| | | public class SearchResultAdapter extends RecyclerView.Adapter { |
| | | |
| | | private static final String TAG = "SearchResultAdapter"; |
| | | private List<VideoContent> contentList; |
| | | |
| | | private Activity mContext; |
| | | |
| | | private LayoutInflater inflater; |
| | | |
| | | private View headerView; |
| | | |
| | | private View footerView; |
| | | |
| | | |
| | | private final static int TYPE_HEADER = 10001; |
| | | private final static int TYPE_FOOTER = 10002; |
| | | |
| | | private final static int TYPE_VIDEO_ALBUM = 11; |
| | | private final static int TYPE_VIDEO_SIMPLE = 12; |
| | | |
| | | private VideoAlbumNavClickListener mVideoAlbumNavClickListener; |
| | | |
| | | |
| | | public void setHeaderView(View headerView) { |
| | | this.headerView = headerView; |
| | | } |
| | | |
| | | public void setFooterView(View footerView) { |
| | | this.footerView = footerView; |
| | | } |
| | | |
| | | public SearchResultAdapter(Activity context, List<VideoContent> contentList, VideoAlbumNavClickListener mVideoAlbumNavClickListener) { |
| | | this.contentList = contentList; |
| | | mContext = context; |
| | | inflater = LayoutInflater.from(context); |
| | | this.mVideoAlbumNavClickListener = mVideoAlbumNavClickListener; |
| | | } |
| | | |
| | | @NonNull |
| | | @Override |
| | | public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
| | | |
| | | if (viewType == TYPE_HEADER) { |
| | | return new HeaderViewHolder(headerView); |
| | | } else if (viewType == TYPE_FOOTER) { |
| | | return new HeaderViewHolder(footerView); |
| | | } else if (viewType == VideoContent.TYPE_AD) { |
| | | return new VideoAdHolder(inflater.inflate(R.layout.item_album_list_ad, parent, false)); |
| | | } else if (viewType == TYPE_VIDEO_ALBUM) { |
| | | return new AlbumVideoHolder(inflater.inflate(R.layout.item_video_search_result_album, parent, false)); |
| | | } else if (viewType == TYPE_VIDEO_SIMPLE) { |
| | | return new SimpleVideoHolder(inflater.inflate(R.layout.item_video_search_result_video, parent, false)); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
| | | if ((holder instanceof HeaderViewHolder) || (holder instanceof FooterViewHolder)) { |
| | | return; |
| | | } |
| | | |
| | | if (headerView != null) |
| | | position = position - 1; |
| | | |
| | | final VideoContent videoContent = contentList.get(position); |
| | | if (holder instanceof AlbumVideoHolder) { |
| | | final AlbumVideoHolder albumVideoHolder = (AlbumVideoHolder) holder; |
| | | final VideoInfo info = videoContent.getVideo(); |
| | | |
| | | try { |
| | | String pic = info.getVpicture(); |
| | | if (StringUtils.isBlank(pic)) |
| | | pic = info.getPicture(); |
| | | |
| | | |
| | | albumVideoHolder.rl_picture.setTag(pic); |
| | | albumVideoHolder.rl_picture.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | Glide.with(mContext).load(albumVideoHolder.rl_picture.getTag() + "").apply(new RequestOptions().centerCrop()).transition(withCrossFade()).placeholder(R.drawable.shape_video_list_cover_placeholder).into(albumVideoHolder.iv_picture); |
| | | } catch (IllegalArgumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } catch (IllegalArgumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | albumVideoHolder.tv_name.setText(info.getName() + ""); |
| | | albumVideoHolder.tv_type.setText(info.getTag()); |
| | | albumVideoHolder.tv_actors.setText(info.getMainActor()); |
| | | if (info.getFree() == 1) { |
| | | albumVideoHolder.iv_vip.setVisibility(View.VISIBLE); |
| | | } else { |
| | | albumVideoHolder.iv_vip.setVisibility(View.GONE); |
| | | } |
| | | |
| | | //导演 |
| | | if (StringUtils.isEmpty(info.getDirector())) { |
| | | albumVideoHolder.tv_director.setVisibility(View.GONE); |
| | | } else { |
| | | albumVideoHolder.tv_director.setVisibility(View.VISIBLE); |
| | | albumVideoHolder.tv_director.setText("导演:" + info.getDirector()); |
| | | } |
| | | |
| | | |
| | | if (info.getDefinition() == 1) { |
| | | albumVideoHolder.iv_high.setVisibility(View.VISIBLE); |
| | | } else { |
| | | albumVideoHolder.iv_high.setVisibility(View.GONE); |
| | | } |
| | | |
| | | |
| | | albumVideoHolder.tv_play.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | myClick(info, v, 0); |
| | | } |
| | | }); |
| | | |
| | | //是否显示更多信息 |
| | | if (videoContent.getVideo().getAlbumMoreInfo() != null) { |
| | | albumVideoHolder.ll_nav.setVisibility(View.VISIBLE); |
| | | albumVideoHolder.tv_nav_name.setText(videoContent.getVideo().getAlbumMoreInfo().getName()); |
| | | } else { |
| | | albumVideoHolder.ll_nav.setVisibility(View.GONE); |
| | | } |
| | | |
| | | albumVideoHolder.ll_nav.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (videoContent.getVideo().getAlbumMoreInfo() != null) { |
| | | if (mVideoAlbumNavClickListener != null) |
| | | mVideoAlbumNavClickListener.onNav(videoContent.getVideo().getAlbumMoreInfo().getJumpPosition()); |
| | | } |
| | | } |
| | | }); |
| | | //设置分数 |
| | | if (!StringUtils.isEmpty(videoContent.getVideo().getScore())) { |
| | | albumVideoHolder.tv_score.setVisibility(View.VISIBLE); |
| | | String st = "评分:" + videoContent.getVideo().getScore() + " "; |
| | | SpannableString spannableString = new SpannableString(st); |
| | | spannableString.setSpan(new AbsoluteSizeSpan(DimenUtils.spToPixels(18, mContext)), 3, st.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); |
| | | spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#FFBA00")), 3, st.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); |
| | | spannableString.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), 3, st.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); |
| | | albumVideoHolder.tv_score.setText(spannableString); |
| | | } else { |
| | | albumVideoHolder.tv_score.setVisibility(View.GONE); |
| | | } |
| | | |
| | | |
| | | //设置专辑 |
| | | if (videoContent.getVideo().getVideoDetailList() == null || videoContent.getVideo().getVideoDetailList().size() == 0) { |
| | | albumVideoHolder.ll_videos.setVisibility(View.GONE); |
| | | } else { |
| | | albumVideoHolder.ll_videos.setVisibility(View.VISIBLE); |
| | | final List<VideoDetailInfo> videoDetailInfos = videoContent.getVideo().getVideoDetailList(); |
| | | albumVideoHolder.tv_video_1.setVisibility(videoDetailInfos.size() - 1 >= 0 ? View.VISIBLE : View.INVISIBLE); |
| | | albumVideoHolder.tv_video_2.setVisibility(videoDetailInfos.size() - 2 >= 0 ? View.VISIBLE : View.INVISIBLE); |
| | | albumVideoHolder.tv_video_3.setVisibility(videoDetailInfos.size() - 3 >= 0 ? View.VISIBLE : View.INVISIBLE); |
| | | albumVideoHolder.tv_video_4.setVisibility(videoDetailInfos.size() - 4 >= 0 ? View.VISIBLE : View.INVISIBLE); |
| | | albumVideoHolder.tv_video_5.setVisibility(videoDetailInfos.size() - 5 >= 0 ? View.VISIBLE : View.INVISIBLE); |
| | | if (videoDetailInfos.size() <= 5) { |
| | | if (albumVideoHolder.tv_video_1.getVisibility() == View.VISIBLE) |
| | | albumVideoHolder.tv_video_1.setText(videoDetailInfos.get(0).getTag()); |
| | | if (albumVideoHolder.tv_video_2.getVisibility() == View.VISIBLE) |
| | | albumVideoHolder.tv_video_2.setText(videoDetailInfos.get(1).getTag()); |
| | | if (albumVideoHolder.tv_video_3.getVisibility() == View.VISIBLE) |
| | | albumVideoHolder.tv_video_3.setText(videoDetailInfos.get(2).getTag()); |
| | | if (albumVideoHolder.tv_video_4.getVisibility() == View.VISIBLE) |
| | | albumVideoHolder.tv_video_4.setText(videoDetailInfos.get(3).getTag()); |
| | | if (albumVideoHolder.tv_video_5.getVisibility() == View.VISIBLE) |
| | | albumVideoHolder.tv_video_5.setText(videoDetailInfos.get(4).getTag()); |
| | | } else { |
| | | albumVideoHolder.tv_video_1.setText(videoDetailInfos.get(0).getTag()); |
| | | albumVideoHolder.tv_video_2.setText(videoDetailInfos.get(1).getTag()); |
| | | albumVideoHolder.tv_video_3.setText("..."); |
| | | albumVideoHolder.tv_video_4.setText(videoDetailInfos.get(videoDetailInfos.size() - 2).getTag()); |
| | | albumVideoHolder.tv_video_5.setText(videoDetailInfos.get(videoDetailInfos.size() - 1).getTag()); |
| | | } |
| | | albumVideoHolder.tv_video_1.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (albumVideoHolder.tv_video_1.getVisibility() == View.VISIBLE) { |
| | | myClick(info, v, 0); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | albumVideoHolder.tv_video_2.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (albumVideoHolder.tv_video_2.getVisibility() == View.VISIBLE) { |
| | | myClick(info, v, 1); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | albumVideoHolder.tv_video_3.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (albumVideoHolder.tv_video_3.getVisibility() == View.VISIBLE) { |
| | | if (videoDetailInfos.size() > 5) |
| | | myClick(info, v, 0); |
| | | else |
| | | myClick(info, v, 3); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | albumVideoHolder.tv_video_4.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (albumVideoHolder.tv_video_4.getVisibility() == View.VISIBLE) { |
| | | myClick(info, v, Integer.parseInt(videoDetailInfos.get(3).getTag())); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | albumVideoHolder.tv_video_5.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (albumVideoHolder.tv_video_5.getVisibility() == View.VISIBLE) { |
| | | myClick(info, v, Integer.parseInt(videoDetailInfos.get(4).getTag())); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | } else if (holder instanceof SimpleVideoHolder) { |
| | | final VideoInfo info = videoContent.getVideo(); |
| | | SimpleVideoHolder simpleVideoHolder = (SimpleVideoHolder) holder; |
| | | simpleVideoHolder.rl_picture.setTag(info.getPicture()); |
| | | simpleVideoHolder.rl_picture.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | Glide.with(mContext).load(simpleVideoHolder.rl_picture.getTag() + "").apply(new RequestOptions().centerCrop()).transition(withCrossFade()).transform(new GlideRoundTransform(mContext, 6)).placeholder(R.drawable.shape_video_list_cover_placeholder).into(simpleVideoHolder.iv_movie_cover); |
| | | } catch (IllegalArgumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | simpleVideoHolder.tv_movie_title.setText(info.getName() + ""); |
| | | |
| | | if (info.getFree() == 1) { |
| | | simpleVideoHolder.iv_vip.setVisibility(View.VISIBLE); |
| | | } else { |
| | | simpleVideoHolder.iv_vip.setVisibility(View.GONE); |
| | | } |
| | | |
| | | if (!StringUtils.isBlank(info.getTag())) |
| | | simpleVideoHolder.tv_tag.setText(info.getTag()); |
| | | else |
| | | simpleVideoHolder.tv_tag.setText(""); |
| | | |
| | | simpleVideoHolder.view.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | myClick(info, v, 0); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } else if (holder instanceof VideoAdHolder) { |
| | | final VideoAdHolder viewHolder = (VideoAdHolder) holder; |
| | | if (videoContent.getAd().getGdt2Unfied() != null) { |
| | | NativeUnifiedADData ad = videoContent.getAd().getGdt2Unfied(); |
| | | |
| | | |
| | | viewHolder.rl_picture.setTag(ad.getImgUrl()); |
| | | viewHolder.rl_picture.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | Glide.with(mContext).load(viewHolder.rl_picture.getTag() + "").apply(new RequestOptions().centerCrop()).transition(withCrossFade()).placeholder(R.drawable.shape_video_list_cover_placeholder).into(viewHolder.iv_picture); |
| | | } catch (IllegalArgumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | viewHolder.tv_name.setText(ad.getTitle()); |
| | | viewHolder.tv_actors.setText(ad.getDesc()); |
| | | |
| | | |
| | | List<View> clickableViews = new ArrayList<>(); |
| | | clickableViews.add(viewHolder.tv_play); |
| | | clickableViews.add(viewHolder.view); |
| | | ad.setNativeAdEventListener(new NativeADEventListener() { |
| | | @Override |
| | | public void onADExposed() { |
| | | Log.i(TAG, "onADExposed"); |
| | | } |
| | | |
| | | @Override |
| | | public void onADClicked() { |
| | | Log.i(TAG, "onADClicked"); |
| | | } |
| | | |
| | | @Override |
| | | public void onADError(AdError adError) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADStatusChanged() { |
| | | Log.i(TAG, "onADStatusChanged"); |
| | | } |
| | | }); |
| | | //删除多余广告标识 |
| | | for (int i = 0; i < viewHolder.mNativeAdContainer.getChildCount(); i++) { |
| | | if (viewHolder.mNativeAdContainer.getChildAt(i) instanceof ImageView) { |
| | | viewHolder.mNativeAdContainer.removeViewAt(i); |
| | | i--; |
| | | } |
| | | } |
| | | // 将布局与广告进行绑定 |
| | | ad.bindAdToView(mContext, viewHolder.mNativeAdContainer, null, clickableViews); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int getItemCount() { |
| | | int count = contentList.size(); |
| | | if (headerView != null) |
| | | count++; |
| | | if (footerView != null) |
| | | count++; |
| | | return count; |
| | | } |
| | | |
| | | /** |
| | | * 获取内容类型 |
| | | * |
| | | * @param videoContent |
| | | * @return |
| | | */ |
| | | //获取内容的类型 |
| | | private int getContentType(VideoContent videoContent) { |
| | | if (videoContent.getType() == VideoContent.TYPE_AD) |
| | | return VideoContent.TYPE_AD; |
| | | else { |
| | | if (videoContent.getVideo().getShowType() == 1) |
| | | return TYPE_VIDEO_ALBUM; |
| | | else |
| | | return TYPE_VIDEO_SIMPLE; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int getItemViewType(int position) { |
| | | int count = getItemCount(); |
| | | if (count == contentList.size()) { |
| | | return getContentType(contentList.get(position)); |
| | | } else { |
| | | if (headerView != null) { |
| | | if (position == 0) |
| | | return TYPE_HEADER; |
| | | else if (position - 1 < contentList.size()) |
| | | return getContentType(contentList.get(position - 1)); |
| | | else |
| | | return TYPE_FOOTER; |
| | | } else { |
| | | if (position < contentList.size()) |
| | | return getContentType(contentList.get(position)); |
| | | else |
| | | return TYPE_FOOTER; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | private void myClick(VideoInfo info, final View v, int p) { |
| | | Postcard postcard = ARouter.getInstance().build(RouteConstant.PATH_VIDEO_DETAIL).withString("from", "search").withSerializable("video_info", info); |
| | | if (p > 0) |
| | | postcard.withInt("playing_position", p); |
| | | postcard.navigation(); |
| | | } |
| | | |
| | | class VideoAdHolder extends RecyclerView.ViewHolder { |
| | | ImageView iv_picture; |
| | | TextView tv_name; |
| | | TextView tv_type; |
| | | TextView tv_actors; |
| | | TextView tv_play; |
| | | View view; |
| | | NativeAdContainer mNativeAdContainer; |
| | | RatioLayout rl_picture; |
| | | |
| | | public VideoAdHolder(View view) { |
| | | super(view); |
| | | this.view = view; |
| | | this.view = view; |
| | | iv_picture = view.findViewById(R.id.iv_picture); |
| | | tv_name = view.findViewById(R.id.tv_name); |
| | | tv_type = view.findViewById(R.id.tv_type); |
| | | tv_actors = view.findViewById(R.id.tv_actors); |
| | | tv_play = view.findViewById(R.id.tv_play); |
| | | mNativeAdContainer = view.findViewById(R.id.root); |
| | | rl_picture = view.findViewById(R.id.rl_picture); |
| | | } |
| | | } |
| | | |
| | | |
| | | class AlbumVideoHolder extends RecyclerView.ViewHolder { |
| | | |
| | | ImageView iv_picture; |
| | | ImageView iv_vip; |
| | | ImageView iv_high; |
| | | TextView tv_name; |
| | | TextView tv_type; |
| | | TextView tv_actors; |
| | | TextView tv_director; |
| | | TextView tv_play; |
| | | TextView tv_nav_name; |
| | | TextView tv_nav_more; |
| | | TextView tv_score; |
| | | LinearLayout ll_videos; |
| | | FrameLayout ll_nav; |
| | | TextView tv_video_1, tv_video_2, tv_video_3, tv_video_4, tv_video_5; |
| | | View view; |
| | | RatioLayout rl_picture; |
| | | |
| | | public AlbumVideoHolder(View view) { |
| | | super(view); |
| | | this.view = view; |
| | | iv_picture = view.findViewById(R.id.iv_picture); |
| | | tv_name = view.findViewById(R.id.tv_name); |
| | | tv_type = view.findViewById(R.id.tv_type); |
| | | tv_actors = view.findViewById(R.id.tv_actors); |
| | | tv_play = view.findViewById(R.id.tv_play); |
| | | ll_videos = view.findViewById(R.id.ll_videos); |
| | | tv_video_1 = view.findViewById(R.id.tv_video_1); |
| | | tv_video_2 = view.findViewById(R.id.tv_video_2); |
| | | tv_video_3 = view.findViewById(R.id.tv_video_3); |
| | | tv_video_4 = view.findViewById(R.id.tv_video_4); |
| | | tv_video_5 = view.findViewById(R.id.tv_video_5); |
| | | iv_vip = view.findViewById(R.id.iv_vip); |
| | | iv_high = view.findViewById(R.id.iv_high); |
| | | ll_nav = view.findViewById(R.id.ll_nav); |
| | | tv_nav_name = view.findViewById(R.id.tv_nav_name); |
| | | tv_nav_more = view.findViewById(R.id.tv_nav_more); |
| | | tv_score = view.findViewById(R.id.tv_score); |
| | | tv_director = view.findViewById(R.id.tv_director); |
| | | rl_picture = view.findViewById(R.id.rl_picture); |
| | | } |
| | | } |
| | | |
| | | class SimpleVideoHolder extends RecyclerView.ViewHolder { |
| | | ImageView iv_movie_cover; |
| | | ImageView iv_vip; |
| | | RatioLayout rl_picture; |
| | | |
| | | TextView tv_movie_title, tv_tag; |
| | | View view; |
| | | |
| | | public SimpleVideoHolder(View view) { |
| | | super(view); |
| | | this.view = view; |
| | | iv_movie_cover = view.findViewById(R.id.iv_movie_cover); |
| | | tv_movie_title = view.findViewById(R.id.tv_movie_title); |
| | | tv_tag = view.findViewById(R.id.tv_tag); |
| | | iv_vip = view.findViewById(R.id.iv_vip); |
| | | rl_picture = view.findViewById(R.id.rl_picture); |
| | | } |
| | | } |
| | | |
| | | class HeaderViewHolder extends RecyclerView.ViewHolder { |
| | | public HeaderViewHolder(View view) { |
| | | super(view); |
| | | } |
| | | } |
| | | |
| | | class FooterViewHolder extends RecyclerView.ViewHolder { |
| | | public FooterViewHolder(View view) { |
| | | super(view); |
| | | } |
| | | } |
| | | |
| | | |
| | | public interface VideoAlbumNavClickListener { |
| | | public void onNav(int p); |
| | | } |
| | | |
| | | } |
library-search/src/main/java/com/yeshi/ec/search/ui/SearchSuggestFragment.java
library-search/src/main/java/com/yeshi/ec/search/util/SearchApiUtil.java
library-search/src/main/res/drawable-xhdpi/ic_activity_main_search.png
library-search/src/main/res/drawable-xhdpi/ic_clear.png
library-search/src/main/res/drawable-xhdpi/ic_empty.png
library-search/src/main/res/drawable-xhdpi/ic_search_result_nav_in.png
library-search/src/main/res/drawable-xhdpi/icon_high.png
library-search/src/main/res/drawable-xhdpi/icon_suggest_search.png
library-search/src/main/res/drawable-xhdpi/icon_suggest_search_input.png
library-search/src/main/res/drawable-xhdpi/icon_video_vip.png
library-search/src/main/res/drawable-xhdpi/vpi__tab_selected_focused_holo.9.png
library-search/src/main/res/drawable/shape_search_bg.xml
library-search/src/main/res/drawable/shape_video_detail_episode_selected.xml
library-search/src/main/res/drawable/shape_video_detail_episode_unselected.xml
library-search/src/main/res/drawable/shape_video_list_cover_placeholder.xml
library-search/src/main/res/drawable/shape_video_search_result_album_play.xml
library-search/src/main/res/layout/fragment_search_suggest.xml
library-search/src/main/res/layout/item_album_list_ad.xml
library-search/src/main/res/layout/item_loading.xml
library-search/src/main/res/layout/item_search_result_top_bar_content.xml
library-search/src/main/res/layout/item_search_suggest.xml
library-search/src/main/res/layout/item_video_search_result_album.xml
library-search/src/main/res/layout/item_video_search_result_video.xml
library-search/src/main/res/layout/search_result_activity.xml
library-search/src/main/res/layout/search_result_top_bar.xml
library-search/src/main/res/values/colors.xml
library-search/src/main/res/values/style.xml
library-search/src/test/java/com/yeshi/ec/search/ExampleUnitTest.java
library-video/.gitignore
library-video/build.gradle
library-video/consumer-rules.pro
library-video/libs/FunshionAD-1.3.16.aar
library-video/libs/FunshionBase-2.0.0.0.aar
library-video/libs/FunshionBase-2.0.0.2.aar
library-video/libs/FunshionPlaySDK-2.0.0.2-buwanysdq.aar
library-video/libs/library-VideoPlayer.aar
library-video/proguard-rules.pro
library-video/src/androidTest/java/com/yeshi/ec/search/ExampleInstrumentedTest.java
library-video/src/main/AndroidManifest.xml
library-video/src/main/java/com/yeshi/video/entity/Comment.java
library-video/src/main/java/com/yeshi/video/entity/CommentReply.java
library-video/src/main/java/com/yeshi/video/entity/FunshionPlayInfo.java
library-video/src/main/java/com/yeshi/video/entity/PushEpisode.java
library-video/src/main/java/com/yeshi/video/entity/UserInfoVO.java
library-video/src/main/java/com/yeshi/video/ui/EpisodeFragment.java
library-video/src/main/java/com/yeshi/video/ui/FunshionPlayerFragment.java
library-video/src/main/java/com/yeshi/video/ui/IQYVideoFragment.java
library-video/src/main/java/com/yeshi/video/ui/PPTVPlayFragment.java
library-video/src/main/java/com/yeshi/video/ui/VideoDetailActivity.java
library-video/src/main/java/com/yeshi/video/ui/VideoDetailFragment.java
library-video/src/main/java/com/yeshi/video/ui/VideoEpisodeFragment.java
library-video/src/main/java/com/yeshi/video/ui/VideoEpisodeFragment2.java
library-video/src/main/java/com/yeshi/video/ui/VideoEpisodeFragment3.java
library-video/src/main/java/com/yeshi/video/ui/VideoEpisodeFragment4.java
library-video/src/main/java/com/yeshi/video/ui/VideoIntroductionFragment.java
library-video/src/main/java/com/yeshi/video/ui/VideoPlayerBrowserActivity.java
library-video/src/main/java/com/yeshi/video/ui/VideoPlayerFragment.java
library-video/src/main/java/com/yeshi/video/ui/VideoReviewFragment.java
library-video/src/main/java/com/yeshi/video/ui/VideoReviewPopupWindow.java
library-video/src/main/java/com/yeshi/video/ui/adapter/EpisodeAdapter.java
library-video/src/main/java/com/yeshi/video/ui/adapter/EpisodeAdapter2.java
library-video/src/main/java/com/yeshi/video/ui/adapter/EpisodePagerAdapter.java
library-video/src/main/java/com/yeshi/video/ui/adapter/GridEpisodeAdapter.java
library-video/src/main/java/com/yeshi/video/ui/adapter/GridEpisodeAdapter2.java
library-video/src/main/java/com/yeshi/video/ui/adapter/GridEpisodeAdapter3.java
library-video/src/main/java/com/yeshi/video/ui/adapter/GridEpisodeAdapter4.java
library-video/src/main/java/com/yeshi/video/ui/adapter/GridVideoAdapter1.java
library-video/src/main/java/com/yeshi/video/ui/adapter/VideoDetailAdapter.java
library-video/src/main/java/com/yeshi/video/ui/adapter/VideoReplyAdapter.java
library-video/src/main/java/com/yeshi/video/ui/adapter/VideoReviewAdapter.java
library-video/src/main/java/com/yeshi/video/utils/FunshionConstant.java
library-video/src/main/java/com/yeshi/video/utils/IPageEventListener.java
library-video/src/main/java/com/yeshi/video/utils/PPJavaInterface.java
library-video/src/main/java/com/yeshi/video/utils/VideoApiUtil.java
library-video/src/main/java/com/yeshi/video/utils/VideoUtil.java
library-video/src/main/java/com/yeshi/video/utils/ad/FullVideoAdManager.java
library-video/src/main/res/anim/pop_dismiss.xml
library-video/src/main/res/anim/pop_show.xml
library-video/src/main/res/anim/slide_in_from_bottom.xml
library-video/src/main/res/anim/slide_out_to_bottom.xml
library-video/src/main/res/drawable-xhdpi/a.9.png
library-video/src/main/res/drawable-xhdpi/btn_blue_corner.9.png
library-video/src/main/res/drawable-xhdpi/btn_blue_corner_highlight.9.png
library-video/src/main/res/drawable-xhdpi/download_failure.png
library-video/src/main/res/drawable-xhdpi/episode_offlined.9.png
library-video/src/main/res/drawable-xhdpi/episode_offlined2.9.png
library-video/src/main/res/drawable-xhdpi/episode_playing.9.png
library-video/src/main/res/drawable-xhdpi/episode_playing2.9.png
library-video/src/main/res/drawable-xhdpi/episode_unwatched.9.png
library-video/src/main/res/drawable-xhdpi/episode_unwatched2.9.png
library-video/src/main/res/drawable-xhdpi/from_other.png
library-video/src/main/res/drawable-xhdpi/ic_back_two.png
library-video/src/main/res/drawable-xhdpi/ic_comment_num.png
library-video/src/main/res/drawable-xhdpi/ic_default_cover.png
library-video/src/main/res/drawable-xhdpi/ic_download_so.png
library-video/src/main/res/drawable-xhdpi/ic_favourite_highlight.png
library-video/src/main/res/drawable-xhdpi/ic_favourites.png
library-video/src/main/res/drawable-xhdpi/ic_gif_loading.png
library-video/src/main/res/drawable-xhdpi/ic_launcher.png
library-video/src/main/res/drawable-xhdpi/ic_offlinecache.png
library-video/src/main/res/drawable-xhdpi/ic_offlinecache_highlight.png
library-video/src/main/res/drawable-xhdpi/ic_play_num.png
library-video/src/main/res/drawable-xhdpi/ic_select_play.png
library-video/src/main/res/drawable-xhdpi/ic_video_detail_favourite1.png
library-video/src/main/res/drawable-xhdpi/ic_video_detail_favourite2.png
library-video/src/main/res/drawable-xhdpi/icon_browser_array.png
library-video/src/main/res/drawable-xhdpi/icon_browser_more.png
library-video/src/main/res/drawable-xhdpi/icon_browser_more_copy.png
library-video/src/main/res/drawable-xhdpi/icon_browser_more_open.png
library-video/src/main/res/drawable-xhdpi/icon_browser_more_refresh.png
library-video/src/main/res/drawable-xhdpi/icon_player_back.png
library-video/src/main/res/drawable-xhdpi/iv_report_more.png
library-video/src/main/res/drawable-xhdpi/more_introduction.png
library-video/src/main/res/drawable-xhdpi/more_introduction2.png
library-video/src/main/res/drawable-xhdpi/person_img.png
library-video/src/main/res/drawable-xhdpi/pro_bg.png
library-video/src/main/res/drawable-xhdpi/review_reply.png
library-video/src/main/res/drawable-xhdpi/tv_review_deliver.png
library-video/src/main/res/drawable-xhdpi/tv_review_deliver_but.png
library-video/src/main/res/drawable-xhdpi/tv_review_edit.9.png
library-video/src/main/res/drawable/progress_drawable2.xml
library-video/src/main/res/drawable/review_deliver_button.xml
library-video/src/main/res/drawable/selector_btn_recent.xml
library-video/src/main/res/drawable/selector_favourite.xml
library-video/src/main/res/drawable/selector_offline.xml
library-video/src/main/res/drawable/shape_player_browser_more_bg.xml
library-video/src/main/res/drawable/shape_splash_ad.xml
library-video/src/main/res/drawable/shape_video_detail_ad_input.xml
library-video/src/main/res/layout/activity_play_video_browser.xml
library-video/src/main/res/layout/browser_pptv_activity.xml
library-video/src/main/res/layout/fragment_episode.xml
library-video/src/main/res/layout/fragment_iqiyi_video.xml
library-video/src/main/res/layout/fragment_player_funshion.xml
library-video/src/main/res/layout/item_episode.xml
library-video/src/main/res/layout/item_funshion_gdt_ad_view.xml
library-video/src/main/res/layout/item_funshion_self_ad_view.xml
library-video/src/main/res/layout/item_reply.xml
library-video/src/main/res/layout/item_resource.xml
library-video/src/main/res/layout/item_review.xml
library-video/src/main/res/layout/movie_item6.xml
library-video/src/main/res/layout/notify_item.xml
library-video/src/main/res/layout/video_detail_activity.xml
library-video/src/main/res/layout/video_detail_fragment.xml
library-video/src/main/res/layout/video_episode_fragment.xml
library-video/src/main/res/layout/video_episode_fragment2.xml
library-video/src/main/res/layout/video_episode_fragment3.xml
library-video/src/main/res/layout/video_episode_fragment4.xml
library-video/src/main/res/layout/video_introduction.xml
library-video/src/main/res/layout/video_introduction_fragment.xml
library-video/src/main/res/layout/video_review_fragment.xml
library-video/src/main/res/layout/video_review_popupwindow.xml
library-video/src/main/res/layout/videodetail_top.xml
library-video/src/main/res/values/colors.xml
library-video/src/main/res/values/string.xml
library-video/src/main/res/values/style.xml
library-video/src/test/java/com/yeshi/ec/search/ExampleUnitTest.java
library-vitamio/build.gradle
settings.gradle |