15个文件已删除
32个文件已修改
74个文件已添加
| | |
| | | abiFilters 'armeabi-v7a', 'arm64-v8a'//, 'x86', 'x86_64' |
| | | } |
| | | |
| | | manifestPlaceholders = [ |
| | | JPUSH_PKGNAME : applicationId, |
| | | //JPush 上注册的包名对应的 Appkey. |
| | | JPUSH_APPKEY : "6f219d3bfa78428537090fef", |
| | | //暂时填写默认值即可. |
| | | JPUSH_CHANNEL : "default", |
| | | |
| | | //若不集成厂商通道,可直接跳过以下配置 |
| | | MEIZU_APPKEY : "MZ-魅族的APPKEY", |
| | | MEIZU_APPID : "MZ-魅族的APPID", |
| | | XIAOMI_APPID : "MI-小米的APPID", |
| | | XIAOMI_APPKEY : "MI-小米的APPKEY", |
| | | OPPO_APPKEY : "OP-oppo的APPKEY", |
| | | OPPO_APPID : "OP-oppo的APPID", |
| | | OPPO_APPSECRET : "OP-oppo的APPSECRET", |
| | | VIVO_APPKEY : "vivo的APPKEY", |
| | | VIVO_APPID : "vivo的APPID" |
| | | ] |
| | | |
| | | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| | | |
| | | multiDexEnabled true |
| | | } |
| | | //NDK r17 之后不再支持 mips 平台 |
| | | packagingOptions { |
| | | doNotStrip '*/mips/*.so' |
| | | doNotStrip '*/mips64/*.so' |
| | | } |
| | | |
| | | buildTypes { |
| | |
| | | |
| | | implementation 'androidx.cardview:cardview:1.0.0' |
| | | implementation 'com.google.android.material:material:1.3.0' |
| | | |
| | | //极光推送 |
| | | implementation 'cn.jiguang.sdk:jcore:3.2.4' |
| | | implementation 'cn.jiguang.sdk:jpush:4.6.4' |
| | | } |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| | | xmlns:tools="http://schemas.android.com/tools" |
| | | package="com.yeshi.makemoney.video.app"> |
| | | package="com.yeshi.makemoney.video"> |
| | | |
| | | <uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission> |
| | | |
| | | <permission |
| | | android:name="${applicationId}.permission.JPUSH_MESSAGE" |
| | | android:protectionLevel="signature" /> |
| | | <uses-permission android:name="${applicationId}.permission.JPUSH_MESSAGE" /> |
| | | |
| | | <uses-permission android:name="android.permission.VIBRATE" /><!--振动器权限,JPUSH支持通知开启振动功能,小米推送必须--> |
| | | |
| | | <application |
| | | android:name="MyApplication" |
| | | android:name=".app.MyApplication" |
| | | android:allowBackup="true" |
| | | android:icon="@mipmap/ic_launcher" |
| | | android:label="@string/app_name" |
| | | android:supportsRtl="true" |
| | | tools:replace="android:allowBackup,android:theme" |
| | | android:theme="@style/Theme.Android"> |
| | | android:theme="@style/Theme.Android" |
| | | tools:replace="android:allowBackup,android:theme"> |
| | | |
| | | <meta-data |
| | | android:name="UMENG_CHANNEL" |
| | |
| | | |
| | | |
| | | <activity |
| | | android:name=".ui.SplashActivity" |
| | | android:name=".app.ui.SplashActivity" |
| | | android:label="@string/app_name"> |
| | | <intent-filter> |
| | | <action android:name="android.intent.action.MAIN" /> |
| | |
| | | </activity> |
| | | |
| | | <activity |
| | | android:name=".ui.MainActivity" |
| | | android:name=".app.ui.MainActivity" |
| | | android:configChanges="keyboard|orientation|screenSize" |
| | | android:exported="true" |
| | | android:launchMode="singleTask"></activity> |
| | | |
| | | <activity |
| | | android:name=".wxapi.WXEntryActivity" |
| | | android:exported="true" |
| | | android:label="@string/app_name" |
| | | android:launchMode="singleTask" |
| | | android:taskAffinity="${applicationId}" |
| | | android:theme="@android:style/Theme.Translucent.NoTitleBar"></activity> |
| | | |
| | | <!-- 极光推送--> |
| | | <service |
| | | android:name=".app.push.MyJpushService" |
| | | android:enabled="true" |
| | | android:exported="false" |
| | | android:process=":pushcore"> |
| | | <intent-filter> |
| | | <action android:name="cn.jiguang.user.service.action" /> |
| | | </intent-filter> |
| | | </service> |
| | | |
| | | <receiver |
| | | android:name=".app.push.MyJpushReceiver" |
| | | android:enabled="true" |
| | | android:exported="false"> |
| | | <intent-filter> |
| | | <!--Required 用户注册 SDK 的 intent--> |
| | | <action android:name="cn.jpush.android.intent.REGISTRATION" /> |
| | | <!--Required 用户接收 SDK 消息的 intent--> |
| | | <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> |
| | | <!--Required 用户接收 SDK 通知栏信息的 intent--> |
| | | <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> |
| | | <!--Required 用户打开自定义通知栏的 intent--> |
| | | <action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> |
| | | <!-- 接收网络变化 连接/断开 since 1.6.3 --> |
| | | <action android:name="cn.jpush.android.intent.CONNECTION" /> |
| | | |
| | | <category android:name="${applicationId}" /> |
| | | </intent-filter> |
| | | </receiver> |
| | | |
| | | <activity |
| | | android:name=".app.push.PushOpenClickActivity" |
| | | android:exported="true"> |
| | | |
| | | <intent-filter> |
| | | <action android:name="cn.jpush.android.intent.JNotifyActivity" /> |
| | | <category android:name="android.intent.category.DEFAULT" /><!--Required SDK核心功能 since 4.2.2--> |
| | | <category android:name="${applicationId}" /> |
| | | </intent-filter> |
| | | |
| | | </activity> |
| | | |
| | | <!-- <activity--> |
| | | <!-- android:name="cn.jpush.android.service.JNotifyActivity"--> |
| | | <!-- android:exported="true"--> |
| | | <!-- android:taskAffinity="jpush.custom"--> |
| | | <!-- android:theme="@style/JPushTheme">--> |
| | | <!-- <intent-filter>--> |
| | | <!-- <action android:name="cn.jpush.android.intent.JNotifyActivity" />--> |
| | | <!-- <category android:name="android.intent.category.DEFAULT" /><!–Required SDK核心功能 since 4.2.2–>--> |
| | | <!-- <category android:name="${applicationId}" />--> |
| | | <!-- </intent-filter>--> |
| | | <!-- </activity>--> |
| | | |
| | | |
| | | </application> |
| | | |
| | | </manifest> |
| | |
| | | |
| | | import android.app.Application; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | |
| | | import com.bytedance.sdk.dp.DPSdkConfig; |
| | | import com.bytedance.sdk.openadsdk.TTAdSdk; |
| | | import com.demo.library_flutter.utils.FlutterPageUtil; |
| | | import com.google.gson.Gson; |
| | | import com.yeshi.makemoney.video.app.R; |
| | | import com.yeshi.makemoney.video.app.utils.Constant; |
| | | import com.yeshi.makemoney.video.app.utils.UserUtil; |
| | | import com.yeshi.makemoney.video.app.utils.api.HttpApiUtil; |
| | | import com.demo.lib.common.util.ManifestDataUtil; |
| | | import com.demo.library_ad.AdUtil; |
| | | import com.demo.library_dp.DPUtil; |
| | | import com.demo.lib.common.util.ManifestDataUtil; |
| | | import com.demo.library_flutter.FlutterCommonActivity; |
| | | import com.demo.library_flutter.message.AdMethodChannel; |
| | | import com.demo.library_flutter.message.DataMethodChannel; |
| | | import com.demo.library_flutter.message.UIMethodChannel; |
| | | import com.demo.library_flutter.nativeview.CSJExpressNativeViewFactory; |
| | | import com.demo.library_flutter.nativeview.DrawVideoNativeViewFactory; |
| | | import com.demo.library_flutter.nativeview.GDTExpressNativeViewFactory; |
| | | import com.demo.library_flutter.utils.FlutterPageUtil; |
| | | import com.google.gson.Gson; |
| | | import com.idlefish.flutterboost.FlutterBoost; |
| | | import com.idlefish.flutterboost.FlutterBoostDelegate; |
| | | import com.idlefish.flutterboost.FlutterBoostRouteOptions; |
| | | import com.idlefish.flutterboost.FlutterBoostSetupOptions; |
| | | import com.idlefish.flutterboost.containers.FlutterBoostActivity; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.umeng.commonsdk.UMConfigure; |
| | | import com.yeshi.makemoney.video.R; |
| | | import com.yeshi.makemoney.video.app.utils.Constant; |
| | | import com.yeshi.makemoney.video.app.utils.UserUtil; |
| | | import com.yeshi.makemoney.video.app.utils.api.HttpApiUtil; |
| | | import com.yeshi.makemoney.video.app.utils.ui.JumpPageUtil; |
| | | |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.Map; |
| | | |
| | | import androidx.multidex.MultiDex; |
| | | import cn.jpush.android.api.JPushInterface; |
| | | import io.flutter.Log; |
| | | import io.flutter.embedding.android.FlutterActivityLaunchConfigs; |
| | | import io.flutter.plugin.common.EventChannel; |
| | | import io.flutter.plugin.common.StandardMessageCodec; |
| | | import io.flutter.plugin.platform.PlatformViewRegistry; |
| | | |
| | |
| | | initDPSDK(application, initListener); |
| | | } |
| | | }); |
| | | |
| | | initJPush(application); |
| | | |
| | | } |
| | | |
| | |
| | | @Override |
| | | public void pushFlutterRoute(FlutterBoostRouteOptions options) { |
| | | Log.i(TAG, "pushFlutterRoute"); |
| | | Log.i(TAG, "参数:"+new Gson().toJson(options.arguments())); |
| | | Log.i(TAG, "参数:" + new Gson().toJson(options.arguments())); |
| | | FlutterPageUtil.jumpPage(options.pageName(), options.arguments(), options.uniqueId()); |
| | | } |
| | | |
| | |
| | | PlatformViewRegistry registry = engine.getPlatformViewsController().getRegistry(); |
| | | registry.registerViewFactory("ad-csj-express-view", new CSJExpressNativeViewFactory(engine.getDartExecutor().getBinaryMessenger(), StandardMessageCodec.INSTANCE)); |
| | | registry.registerViewFactory("ad-gdt-express-view", new GDTExpressNativeViewFactory(engine.getDartExecutor().getBinaryMessenger(), StandardMessageCodec.INSTANCE)); |
| | | registry.registerViewFactory("ad-draw-video-view", new DrawVideoNativeViewFactory(engine.getDartExecutor().getBinaryMessenger(), StandardMessageCodec.INSTANCE)); |
| | | //数据接口 |
| | | new DataMethodChannel(engine.getDartExecutor().getBinaryMessenger(), application.getApplicationContext(), new DataMethodChannel.DataListener() { |
| | | @Override |
| | | public Map<String, Object> getBaseRequestParams(Map<String, Object> params) { |
| | | public Map<String, String> getBaseRequestParams(Map<String, String> params) { |
| | | LinkedHashMap<String, String> ps = new LinkedHashMap<>(); |
| | | if (params != null) |
| | | for (Iterator<String> its = params.keySet().iterator(); its.hasNext(); ) { |
| | |
| | | ps.put(key, params.get(key).toString()); |
| | | } |
| | | } |
| | | HttpApiUtil.getRequestParams(application.getApplicationContext(), ps); |
| | | return null; |
| | | return HttpApiUtil.getRequestParams(application.getApplicationContext(), ps); |
| | | } |
| | | }); |
| | | //UI接口 |
| | |
| | | @Override |
| | | public boolean isStatusBarDefaultLight() { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public void jumpAppPage(String type, Map<String, Object> params) { |
| | | //跳转应用列表 |
| | | if (JumpPageUtil.AppJumpType.valueOf(type) == null) { |
| | | //未知跳转类型 |
| | | return; |
| | | } |
| | | JumpPageUtil.jump(JumpPageUtil.AppJumpType.valueOf(type), params, FlutterBoost.instance().currentActivity()); |
| | | } |
| | | }); |
| | | // //广告接口 |
| | |
| | | } |
| | | |
| | | |
| | | private static void initJPush(Application application) { |
| | | JPushInterface.setDebugMode(true); |
| | | JPushInterface.init(application); |
| | | } |
| | | |
| | | public interface InitListener { |
| | | public void onFinish(); |
| | | } |
New file |
| | |
| | | package com.yeshi.makemoney.video.app.entity.goldcorn; |
| | | |
| | | public class GoldCornTaskInfo { |
| | | private int price; |
| | | private boolean finish; |
| | | |
| | | public int getPrice() { |
| | | return price; |
| | | } |
| | | |
| | | public void setPrice(int price) { |
| | | this.price = price; |
| | | } |
| | | |
| | | public boolean isFinish() { |
| | | return finish; |
| | | } |
| | | |
| | | public void setFinish(boolean finish) { |
| | | this.finish = finish; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.makemoney.video.app.push; |
| | | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.util.Log; |
| | | |
| | | import com.demo.lib.common.util.common.StringUtils; |
| | | import com.yeshi.makemoney.video.app.utils.api.BasicTextHttpResponseHandler; |
| | | import com.yeshi.makemoney.video.app.utils.api.HttpApiUtil; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONException; |
| | | import org.json.JSONObject; |
| | | |
| | | import cn.jpush.android.api.CustomMessage; |
| | | import cn.jpush.android.api.NotificationMessage; |
| | | import cn.jpush.android.service.JPushMessageReceiver; |
| | | |
| | | public class MyJpushReceiver extends JPushMessageReceiver { |
| | | |
| | | |
| | | private static final String TAG = MyJpushReceiver.class.getSimpleName(); |
| | | |
| | | //注册成功 |
| | | @Override |
| | | public void onRegister(Context context, String s) { |
| | | super.onRegister(context, s); |
| | | Log.i(TAG, "onRegister:" + s); |
| | | if (StringUtils.isEmpty(s)) { |
| | | return; |
| | | } |
| | | //获取token |
| | | //上传token |
| | | HttpApiUtil.uploadPushRegId(context, s, new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | super.onSuccessPerfect(statusCode, headers, jsonObject); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | //收到消息 |
| | | |
| | | |
| | | @Override |
| | | public void onMessage(Context context, CustomMessage customMessage) { |
| | | super.onMessage(context, customMessage); |
| | | } |
| | | |
| | | @Override |
| | | public void onNotifyMessageArrived(Context context, NotificationMessage notificationMessage) { |
| | | super.onNotifyMessageArrived(context, notificationMessage); |
| | | Log.i(TAG, "收到通知消息:" + notificationMessage.toString()); |
| | | } |
| | | |
| | | @Override |
| | | public void onNotifyMessageOpened(Context context, NotificationMessage notificationMessage) { |
| | | super.onNotifyMessageOpened(context, notificationMessage); |
| | | //intent:#Intent;component=com.yeshi.makemoney.video/.app.push.PushOpenClickActivity;end |
| | | Log.i(TAG, "通知打开:" + notificationMessage.toString()); |
| | | String extra = notificationMessage.notificationExtras; |
| | | if (StringUtils.isEmpty(extra)) { |
| | | return; |
| | | } |
| | | try { |
| | | JSONObject json = new JSONObject(extra); |
| | | String type = json.optString("type"); |
| | | String params = json.opt("params") + ""; |
| | | context.startActivity(PushOpenClickActivity.createIntent(context, type, params)); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onMultiActionClicked(Context context, Intent intent) { |
| | | super.onMultiActionClicked(context, intent); |
| | | Log.i(TAG, "onMultiActionClicked"); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.makemoney.video.app.push; |
| | | |
| | | import cn.jpush.android.service.JCommonService; |
| | | |
| | | public class MyJpushService extends JCommonService { |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.makemoney.video.app.push; |
| | | |
| | | import android.app.Activity; |
| | | import android.app.ActivityManager; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.os.Bundle; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | import android.webkit.WebChromeClient; |
| | | import android.webkit.WebViewClient; |
| | | import android.widget.TextView; |
| | | |
| | | import com.demo.lib.common.activity.BaseActivity; |
| | | import com.demo.lib.common.util.common.StringUtils; |
| | | import com.yeshi.makemoney.video.app.ui.MainActivity; |
| | | import com.yeshi.makemoney.video.app.utils.ui.JumpPageUtil; |
| | | |
| | | import org.json.JSONException; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | |
| | | import cn.jpush.android.api.JPushInterface; |
| | | |
| | | public class PushOpenClickActivity extends BaseActivity { |
| | | |
| | | public static PushData pushData = null; |
| | | |
| | | private static final String TAG = "OpenClickActivity"; |
| | | private TextView mTextView; |
| | | |
| | | public static Intent createIntent(Context context, String type, String params) { |
| | | Intent intent = new Intent(context, PushOpenClickActivity.class); |
| | | intent.putExtra("type", type); |
| | | intent.putExtra("params", params); |
| | | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | return intent; |
| | | } |
| | | |
| | | |
| | | private static void jump(Activity context, String type, String params) throws ClassNotFoundException, JSONException { |
| | | pushData = null; |
| | | Log.i(TAG, String.format("%s:%s", type, params)); |
| | | Map<String, Object> ps = null; |
| | | if (!StringUtils.isEmpty(params)) { |
| | | ps = new HashMap<>(); |
| | | JSONObject jsonObject = new JSONObject(params); |
| | | for (Iterator<String> keys = jsonObject.keys(); keys.hasNext(); ) { |
| | | String key = keys.next(); |
| | | ps.put(key, jsonObject.get(key)); |
| | | } |
| | | } |
| | | JumpPageUtil.jump(JumpPageUtil.AppJumpType.valueOf(type), ps, context); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | mTextView = new TextView(this); |
| | | setContentView(mTextView); |
| | | JSONObject extra = handleOpenClick(); |
| | | if (extra == null) { |
| | | finish(); |
| | | return; |
| | | } |
| | | |
| | | String params = extra.optString("params"); |
| | | String type = extra.optString("type"); |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.append("\n"); |
| | | builder.append("params:" + params); |
| | | mTextView.setText(builder.toString()); |
| | | if (!isAppRunning(getApplicationContext(), getPackageName())) { |
| | | //暂存数据 |
| | | pushData = new PushData(type, params); |
| | | Intent intent = new Intent(this, MainActivity.class); |
| | | startActivity(intent); |
| | | finish(); |
| | | } else { |
| | | try { |
| | | jump(this, type, params); |
| | | finish(); |
| | | } catch (ClassNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | private String getPushData() { |
| | | String data = null; |
| | | //获取华为平台附带的jpush信息 |
| | | if (getIntent().getData() != null) { |
| | | data = getIntent().getData().toString(); |
| | | } |
| | | //获取fcm、oppo、vivo、华硕、小米平台附带的jpush信息 |
| | | if (TextUtils.isEmpty(data) && getIntent().getExtras() != null) { |
| | | data = getIntent().getExtras().getString("JMessageExtra"); |
| | | } |
| | | return data; |
| | | } |
| | | |
| | | private JSONObject handleOpenClick() { |
| | | Log.d(TAG, "用户点击打开了通知"); |
| | | String data = getPushData(); |
| | | Log.w(TAG, "msg content is " + String.valueOf(data)); |
| | | if (TextUtils.isEmpty(data)) return null; |
| | | try { |
| | | JSONObject jsonObject = new JSONObject(data); |
| | | String msgId = jsonObject.optString("msg_id"); |
| | | byte whichPushSDK = (byte) jsonObject.optInt("rom_type"); |
| | | //上报点击事件 |
| | | JPushInterface.reportNotificationOpened(this, msgId, whichPushSDK); |
| | | JSONObject extras = jsonObject.optJSONObject("n_extras"); |
| | | if (extras != null) { |
| | | return extras; |
| | | } |
| | | } catch (JSONException e) { |
| | | Log.w(TAG, "parse notification error"); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | //获取推送SDK的名称 |
| | | private String getPushSDKName(byte whichPushSDK) { |
| | | String name; |
| | | switch (whichPushSDK) { |
| | | case 0: |
| | | name = "jpush"; |
| | | break; |
| | | case 1: |
| | | name = "xiaomi"; |
| | | break; |
| | | case 2: |
| | | name = "huawei"; |
| | | break; |
| | | case 3: |
| | | name = "meizu"; |
| | | break; |
| | | case 4: |
| | | name = "oppo"; |
| | | break; |
| | | case 5: |
| | | name = "vivo"; |
| | | break; |
| | | case 6: |
| | | name = "asus"; |
| | | break; |
| | | case 8: |
| | | name = "fcm"; |
| | | break; |
| | | default: |
| | | name = "jpush"; |
| | | } |
| | | return name; |
| | | } |
| | | |
| | | |
| | | private boolean isAppRunning(Context context, String packageName) { |
| | | ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); |
| | | ActivityManager.RunningTaskInfo info = manager.getRunningTasks(1).get(0); |
| | | Log.i(TAG, "numActivities:" + info.numActivities); |
| | | Log.i(TAG, "numRunning:" + info.numRunning); |
| | | |
| | | if (info.numActivities < 2) |
| | | return false; |
| | | else |
| | | return true; |
| | | } |
| | | |
| | | public static void resumeJumpActivity(Activity context) { |
| | | if (pushData != null) { |
| | | try { |
| | | jump(context, pushData.type, pushData.getParams()); |
| | | } catch (ClassNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | class PushData { |
| | | private String params; |
| | | private String type; |
| | | |
| | | public PushData(String type, String params) { |
| | | this.params = params; |
| | | this.type = type; |
| | | } |
| | | |
| | | public String getParams() { |
| | | return params; |
| | | } |
| | | |
| | | public void setParams(String params) { |
| | | this.params = params; |
| | | } |
| | | |
| | | public String getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(String type) { |
| | | this.type = type; |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import android.os.Bundle; |
| | | import android.view.View; |
| | | |
| | | import com.yeshi.makemoney.video.app.R; |
| | | import com.yeshi.makemoney.video.R; |
| | | import com.demo.lib.common.RetainViewFragment; |
| | | |
| | | import java.util.List; |
| | |
| | | import android.content.DialogInterface; |
| | | import android.content.Intent; |
| | | import android.os.Bundle; |
| | | import android.util.Log; |
| | | import android.view.KeyEvent; |
| | | import android.view.View; |
| | | import android.widget.RadioButton; |
| | |
| | | import com.demo.lib.common.activity.BaseActivity; |
| | | import com.demo.lib.common.dialog.DialogUtil; |
| | | import com.demo.lib.common.util.FragmentSwitchHelperV2; |
| | | import com.demo.lib.common.util.common.StringUtils; |
| | | import com.demo.library_flutter.FlutterCommonActivity; |
| | | import com.demo.library_flutter.FlutterMineFragment; |
| | | import com.demo.library_flutter.FlutterRecommendFragment; |
| | | import com.demo.library_flutter.utils.FlutterPageUtil; |
| | | import com.idlefish.flutterboost.containers.FlutterBoostFragment; |
| | | import com.jaeger.library.StatusBarUtil; |
| | | import com.yeshi.makemoney.video.app.R; |
| | | import com.yeshi.makemoney.video.R; |
| | | import com.yeshi.makemoney.video.app.push.PushOpenClickActivity; |
| | | import com.yeshi.makemoney.video.app.ui.dialog.ExitDialog; |
| | | import com.yeshi.makemoney.video.app.ui.main.DYNewsFragment; |
| | | import com.yeshi.makemoney.video.app.ui.main.HomeFragment; |
| | | import com.yeshi.makemoney.video.app.ui.main.MineFragment; |
| | | import com.yeshi.makemoney.video.app.ui.main.NovelFragment; |
| | | import com.yeshi.makemoney.video.app.utils.api.BasicTextHttpResponseHandler; |
| | | import com.yeshi.makemoney.video.app.utils.api.HttpApiUtil; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | import androidx.fragment.app.Fragment; |
| | | import cn.jpush.android.api.JPushInterface; |
| | | |
| | | public class MainActivity extends BaseActivity { |
| | | |
| | | private static final String TAG = "MainActivity"; |
| | | private AQuery mAQuery; |
| | | private FragmentSwitchHelperV2 mFragmentSwitchHelper; |
| | | private RadioGroup rg_nav; |
| | |
| | | mFragmentSwitchHelper = FragmentSwitchHelperV2.create(R.id.fl_container, getSupportFragmentManager(), fs); |
| | | } |
| | | |
| | | |
| | | //初始化 |
| | | private void init() { |
| | | String regId = JPushInterface.getRegistrationID(getApplicationContext()); |
| | | if (StringUtils.isEmpty(regId)) { |
| | | return; |
| | | } |
| | | HttpApiUtil.uploadPushRegId(getApplicationContext(), regId, new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | super.onSuccessPerfect(statusCode, headers, jsonObject); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, String jsonObject, Throwable e) { |
| | | super.onFailure(statusCode, headers, jsonObject, e); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | |
| | | DialogUtil.dismiss(exitDialog); |
| | | } |
| | | }).create(); |
| | | init(); |
| | | } |
| | | |
| | | ExitDialog exitDialog = null; |
| | |
| | | } |
| | | return super.onKeyDown(keyCode, event); |
| | | } |
| | | |
| | | @Override |
| | | protected void onNewIntent(Intent intent) { |
| | | Log.i(TAG, "onNewIntent"); |
| | | int position = intent.getIntExtra("position", -1); |
| | | if (position < 0) |
| | | return; |
| | | |
| | | try { |
| | | switch (position) { |
| | | case 0: |
| | | findViewById(R.id.rb_nav_recommend).performClick(); |
| | | break; |
| | | case 1: |
| | | findViewById(R.id.rb_nav_discover).performClick(); |
| | | break; |
| | | case 2: |
| | | findViewById(R.id.rb_nav_team).performClick(); |
| | | break; |
| | | case 3: |
| | | findViewById(R.id.rb_nav_mine).performClick(); |
| | | break; |
| | | } |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | super.onNewIntent(intent); |
| | | } |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | PushOpenClickActivity.resumeJumpActivity(this); |
| | | } |
| | | } |
| | |
| | | import android.view.ViewGroup; |
| | | |
| | | import com.yeshi.makemoney.video.app.MyApplication; |
| | | import com.yeshi.makemoney.video.app.R; |
| | | import com.yeshi.makemoney.video.R; |
| | | import com.yeshi.makemoney.video.app.ui.dialog.PermissionAuthNotifyDialog; |
| | | import com.yeshi.makemoney.video.app.ui.dialog.UserProtocolDialog; |
| | | import com.yeshi.makemoney.video.app.utils.AppConfigUtil; |
| | |
| | | import android.widget.ProgressBar; |
| | | import android.widget.TextView; |
| | | |
| | | import com.yeshi.makemoney.video.app.R; |
| | | import com.yeshi.makemoney.video.R; |
| | | import com.yeshi.makemoney.video.app.utils.AppConfigUtil; |
| | | import com.yeshi.makemoney.video.app.utils.FileUtils; |
| | | import com.yeshi.makemoney.video.app.utils.browser.MyJavaInterface; |
| | |
| | | import android.widget.TextView; |
| | | |
| | | |
| | | import com.yeshi.makemoney.video.app.R; |
| | | import com.yeshi.makemoney.video.R; |
| | | import com.yeshi.makemoney.video.app.utils.browser.BaseJavaInterface; |
| | | import com.demo.lib.common.util.common.StringUtils; |
| | | |
| | |
| | | import android.widget.FrameLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.yeshi.makemoney.video.app.R; |
| | | import com.yeshi.makemoney.video.R; |
| | | import com.demo.lib.common.util.SystemCommon; |
| | | |
| | | |
New file |
| | |
| | | package com.yeshi.makemoney.video.app.ui.dialog; |
| | | |
| | | import android.app.Activity; |
| | | import android.app.Dialog; |
| | | import android.content.Context; |
| | | import android.content.DialogInterface; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.demo.lib.common.util.SystemCommon; |
| | | import com.yeshi.makemoney.video.R; |
| | | import com.yeshi.makemoney.video.app.utils.videos.VideoGoldCornUtil; |
| | | |
| | | |
| | | /** |
| | | * 用户协议弹框 |
| | | */ |
| | | public class GoldCornDoubleDialog extends Dialog { |
| | | |
| | | private static String TAG = "GoldCornDoubleDialog"; |
| | | |
| | | public GoldCornDoubleDialog(Context context) { |
| | | super(context); |
| | | this.setCancelable(false); |
| | | } |
| | | |
| | | public GoldCornDoubleDialog(Context context, int theme) { |
| | | super(context, theme); |
| | | this.setCancelable(false); |
| | | } |
| | | |
| | | |
| | | public static class Builder { |
| | | private Activity context; |
| | | private GoldCornDoubleCallBack callBack; |
| | | |
| | | private int goldCorn; |
| | | |
| | | public Builder(Activity context) { |
| | | this.context = context; |
| | | } |
| | | |
| | | |
| | | public Builder setGoldCorn(int goldCorn) { |
| | | this.goldCorn = goldCorn; |
| | | return this; |
| | | } |
| | | |
| | | public Builder setCallBack(GoldCornDoubleCallBack callBack) { |
| | | this.callBack = callBack; |
| | | return this; |
| | | } |
| | | |
| | | public GoldCornDoubleDialog create() { |
| | | LayoutInflater inflater = (LayoutInflater) context |
| | | .getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
| | | final GoldCornDoubleDialog dialog = new GoldCornDoubleDialog(context, R.style.Dialog); |
| | | dialog.setCanceledOnTouchOutside(false); |
| | | final View layout = inflater.inflate(R.layout.dialog_goldcorn_double, null); |
| | | dialog.addContentView(layout, new FrameLayout.LayoutParams( |
| | | FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT)); |
| | | |
| | | AQuery mAquery = new AQuery(layout); |
| | | mAquery.id(R.id.cb_notify).checked(VideoGoldCornUtil.isDoubleNotify(context)); |
| | | mAquery.id(R.id.tv_goldcorn_old).text(goldCorn + ""); |
| | | mAquery.id(R.id.tv_goldcorn_new).text(goldCorn * 2 + ""); |
| | | mAquery.id(R.id.tv_positive).clicked(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | VideoGoldCornUtil.setDoubleNotify(mAquery.id(R.id.cb_notify).isChecked(), context); |
| | | if (callBack != null) { |
| | | callBack.onPositive(!mAquery.id(R.id.cb_notify).isChecked()); |
| | | } else { |
| | | dialog.dismiss(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | mAquery.id(R.id.iv_close).clicked(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (callBack != null) { |
| | | callBack.onCancel(); |
| | | } else { |
| | | dialog.dismiss(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | dialog.setContentView(layout); |
| | | |
| | | android.view.WindowManager.LayoutParams params = dialog.getWindow() |
| | | .getAttributes(); |
| | | params.width = (int) ((SystemCommon.getScreenWidth(context) * 3) / 4); |
| | | params.height = android.view.WindowManager.LayoutParams.WRAP_CONTENT; |
| | | dialog.getWindow().setAttributes(params); |
| | | return dialog; |
| | | } |
| | | } |
| | | |
| | | public interface GoldCornDoubleCallBack { |
| | | void onPositive(boolean notify); |
| | | |
| | | void onCancel(); |
| | | } |
| | | } |
| | |
| | | import android.widget.FrameLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.yeshi.makemoney.video.app.R; |
| | | import com.yeshi.makemoney.video.R; |
| | | import com.demo.lib.common.util.SystemCommon; |
| | | import com.demo.lib.common.util.common.StringUtils; |
| | | |
| | |
| | | import android.widget.FrameLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.yeshi.makemoney.video.app.R; |
| | | import com.yeshi.makemoney.video.R; |
| | | import com.yeshi.makemoney.video.app.ui.common.SimpleBrowserActivity; |
| | | import com.demo.lib.common.util.SystemCommon; |
| | | import com.demo.lib.common.util.common.StringUtils; |
| | |
| | | package com.yeshi.makemoney.video.app.ui.main; |
| | | |
| | | import android.os.Bundle; |
| | | import android.text.GetChars; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | |
| | |
| | | import com.demo.lib.common.RetainViewFragment; |
| | | import com.demo.lib.common.util.common.DimenUtils; |
| | | import com.jaeger.library.StatusBarUtil; |
| | | import com.yeshi.makemoney.video.app.R; |
| | | import com.yeshi.makemoney.video.R; |
| | | import com.yeshi.makemoney.video.app.utils.UserUtil; |
| | | import com.yeshi.makemoney.video.app.utils.api.BasicTextHttpResponseHandler; |
| | | import com.yeshi.makemoney.video.app.utils.api.HttpApiUtil; |
| | | import com.yeshi.makemoney.video.app.utils.videos.NewsGoldCornUtil; |
| | | import com.yeshi.makemoney.video.app.utils.videos.VideoGoldCornUtil; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.util.Map; |
| | | |
| | |
| | | * 主页面--快手视频 |
| | | */ |
| | | public class DYNewsFragment extends RetainViewFragment { |
| | | |
| | | //最少的浏览时间 |
| | | private final Long MIN_SPACE_TIME = 1000 * 5L; |
| | | |
| | | private static final String TAG = "DYNewsFragment"; |
| | | private IDPWidget mIDPWidget; |
| | | |
| | |
| | | super(); |
| | | } |
| | | |
| | | private Fragment fragment; |
| | | private long startTime; |
| | | |
| | | |
| | | @Override |
| | |
| | | public void onDPNewsDetailEnter(Map<String, Object> map) { |
| | | log("onDPNewsDetailEnter"); |
| | | // DPEventCollectUtil.newsDetailEnter(getContext(), map); |
| | | if (startTime == 0L) { |
| | | startTime = System.currentTimeMillis(); |
| | | } |
| | | |
| | | if (System.currentTimeMillis() - startTime > MIN_SPACE_TIME) { |
| | | startTime = System.currentTimeMillis(); |
| | | addCount(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onDPNewsDetailExit(Map<String, Object> map) { |
| | | log("onDPNewsDetailExit"); |
| | | if (startTime > 0) { |
| | | if (System.currentTimeMillis() - startTime > MIN_SPACE_TIME) { |
| | | startTime = 0L; |
| | | addCount(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | })); |
| | | |
| | | Fragment fragment = mIDPWidget.getFragment(); |
| | |
| | | Log.d(TAG, String.valueOf(msg)); |
| | | } |
| | | |
| | | private void addCount() { |
| | | NewsGoldCornUtil.addNewsCount(getContext()); |
| | | if (!UserUtil.isLogin(getContext())) { |
| | | return; |
| | | } |
| | | |
| | | int num = NewsGoldCornUtil.getNewsCount(getContext()); |
| | | HttpApiUtil.scanNews(getContext(), num, new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | super.onSuccessPerfect(statusCode, headers, jsonObject); |
| | | if (jsonObject.optInt("code") == 0) { |
| | | //减去上传的数量 |
| | | NewsGoldCornUtil.setNewsCount(NewsGoldCornUtil.getNewsCount(getContext()) - num, getContext()); |
| | | //上传成功 |
| | | JSONObject data = jsonObject.optJSONObject("data"); |
| | | VideoGoldCornUtil.showInComeToast(data.optInt("goldCorn"), getContext()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, String jsonObject, Throwable e) { |
| | | super.onFailure(statusCode, headers, jsonObject, e); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.yeshi.makemoney.video.app.ui.main; |
| | | |
| | | import android.animation.ValueAnimator; |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.os.Bundle; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.view.animation.AccelerateDecelerateInterpolator; |
| | | import android.view.animation.Animation; |
| | | import android.view.animation.AnimationUtils; |
| | | import android.view.animation.DecelerateInterpolator; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.bytedance.sdk.dp.DPWidgetDrawParams; |
| | | import com.bytedance.sdk.dp.IDPDrawListener; |
| | | import com.bytedance.sdk.dp.IDPNewsListener; |
| | | import com.bytedance.sdk.dp.IDPWidget; |
| | | import com.demo.lib.common.RetainViewFragment; |
| | | import com.demo.lib.common.util.common.DimenUtils; |
| | | import com.demo.library_flutter.FlutterRecommendFragment; |
| | | import com.demo.library_flutter.utils.FlutterPageUtil; |
| | | import com.idlefish.flutterboost.FlutterBoost; |
| | | import com.idlefish.flutterboost.containers.FlutterBoostFragment; |
| | | import com.jaeger.library.StatusBarUtil; |
| | | import com.yeshi.makemoney.video.app.R; |
| | | import com.yeshi.makemoney.video.R; |
| | | import com.yeshi.makemoney.video.app.entity.goldcorn.GoldCornTaskInfo; |
| | | import com.yeshi.makemoney.video.app.entity.user.UserInfo; |
| | | import com.yeshi.makemoney.video.app.ui.subview.CircleProgressView; |
| | | import com.yeshi.makemoney.video.app.utils.UserUtil; |
| | | import com.yeshi.makemoney.video.app.utils.videos.DPHolder; |
| | | import com.yeshi.makemoney.video.app.utils.videos.DrawVideoGoldCornManager; |
| | | import com.yeshi.makemoney.video.app.utils.videos.DrawVideoHBManager; |
| | | import com.yeshi.makemoney.video.app.utils.videos.VideoGoldCornUtil; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.Timer; |
| | | import java.util.TimerTask; |
| | | |
| | | import androidx.fragment.app.Fragment; |
| | | |
| | |
| | | private AQuery mAquery; |
| | | private IDPWidget mIDPWidget; |
| | | |
| | | private DrawVideoHBManager mDrawVideoHBManager; |
| | | |
| | | @Override |
| | | public int getContentResource() { |
| | | return R.layout.fragment_home; |
| | | } |
| | | |
| | | |
| | | private void init() { |
| | | initVideo(); |
| | | mAquery.id(R.id.tv_login).clicked(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | //去登录 |
| | | FlutterPageUtil.jumpPage("LoginPage", null, null); |
| | | } |
| | | }); |
| | | |
| | | //初始化视频播放计时器 |
| | | if (VideoGoldCornUtil.getPrice(getContext()) != null) { |
| | | DrawVideoGoldCornManager.getInstance().init(new DrawVideoGoldCornManager.PlayTimerCallBack() { |
| | | @Override |
| | | public void onProcess(int process) { |
| | | // Log.i(TAG, "process:" + process); |
| | | mDrawVideoHBManager.onProcess(process); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | StatusBarUtil.setDarkMode(getActivity()); |
| | | mAquery = new AQuery(contentView); |
| | | initVideo(); |
| | | mDrawVideoHBManager = new DrawVideoHBManager(); |
| | | mDrawVideoHBManager.init(contentView, getActivity()); |
| | | init(); |
| | | } |
| | | |
| | | private void initVideo() { |
| | | mIDPWidget = DPHolder.getInstance().buildDrawWidget(DPWidgetDrawParams.obtain().hideClose(true, null) |
| | | .drawContentType(DPWidgetDrawParams.DRAW_CONTENT_TYPE_ALL) |
| | | .enableRefresh(true) |
| | | .customCategory("风景") |
| | | .listener(new IDPNewsListener() { |
| | | // .customCategory("风景") |
| | | .listener(new IDPDrawListener() { |
| | | @Override |
| | | public void onDPRefreshFinish() { |
| | | log("onDPRefreshFinish"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPNewsItemClick(Map<String, Object> map) { |
| | | log("onDPNewsItemClick"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoPlay(Map<String, Object> map) { |
| | | log("onDPVideoPlay"); |
| | | DrawVideoGoldCornManager.getInstance().videoPlay(); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoPause(Map<String, Object> map) { |
| | | log("onDPVideoPause"); |
| | | DrawVideoGoldCornManager.getInstance().videoPause(); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoContinue(Map<String, Object> map) { |
| | | log("onDPVideoContinue"); |
| | | DrawVideoGoldCornManager.getInstance().videoPlay(); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoOver(Map<String, Object> map) { |
| | | log("onDPVideoOver"); |
| | | DrawVideoGoldCornManager.getInstance().videoPause(); |
| | | // DPEventCollectUtil.playDrawVideo(getContext(), null, "dy", "home", false); |
| | | } |
| | | |
| | |
| | | public void onDPVideoCompletion(Map<String, Object> map) { |
| | | log("onDPVideoCompletion"); |
| | | super.onDPVideoCompletion(map); |
| | | DrawVideoGoldCornManager.getInstance().videoPause(); |
| | | // DPEventCollectUtil.playDrawVideo(getContext(), null, "dy", "home", true); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPNewsDetailEnter(Map<String, Object> map) { |
| | | log("onDPNewsDetailEnter"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPNewsDetailExit(Map<String, Object> map) { |
| | | log("onDPNewsDetailExit"); |
| | | } |
| | | |
| | | |
| | | })); |
| | | |
| | |
| | | public void onResume() { |
| | | super.onResume(); |
| | | Log.i(TAG, "onResume"); |
| | | if (UserUtil.isLogin(getContext())) { |
| | | mAquery.id(R.id.ll_login).visibility(View.GONE); |
| | | } else { |
| | | mAquery.id(R.id.ll_login).visibility(View.VISIBLE); |
| | | } |
| | | |
| | | if (mIDPWidget != null && mIDPWidget.getFragment() != null) { |
| | | mIDPWidget.getFragment().onResume(); |
| | | } |
| | | |
| | | |
| | | mDrawVideoHBManager.refreshTaskInfo(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void onPause() { |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onDestroy() { |
| | | super.onDestroy(); |
| | | DrawVideoGoldCornManager.getInstance().destory(); |
| | | mDrawVideoHBManager.destory(); |
| | | } |
| | | } |
| | |
| | | import com.demo.lib.common.RetainViewFragment; |
| | | import com.demo.library_flutter.FlutterMineFragment; |
| | | import com.idlefish.flutterboost.containers.FlutterBoostFragment; |
| | | import com.yeshi.makemoney.video.app.R; |
| | | import com.yeshi.makemoney.video.R; |
| | | |
| | | import java.util.HashMap; |
| | | |
| | |
| | | |
| | | import com.bytedance.novel.pangolin.NovelSDK; |
| | | import com.demo.lib.common.RetainViewFragment; |
| | | import com.yeshi.makemoney.video.app.R; |
| | | import com.yeshi.makemoney.video.R; |
| | | import com.yeshi.makemoney.video.app.utils.UserUtil; |
| | | import com.yeshi.makemoney.video.app.utils.api.BasicTextHttpResponseHandler; |
| | | import com.yeshi.makemoney.video.app.utils.api.HttpApiUtil; |
| | | import com.yeshi.makemoney.video.app.utils.videos.NovelGoldCornUtil; |
| | | import com.yeshi.makemoney.video.app.utils.videos.VideoGoldCornUtil; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import androidx.fragment.app.FragmentManager; |
| | | |
| | |
| | | public void onResume() { |
| | | super.onResume(); |
| | | NovelSDK.INSTANCE.getNovelFragment().onResume(); |
| | | // DPEventCollectUtil.uploadNovelReadTime(getContext()); |
| | | //今日阅读的时间 |
| | | uploadReadTime(); |
| | | } |
| | | |
| | | |
| | | private void uploadReadTime() { |
| | | long todayReadTime = NovelSDK.INSTANCE.getNovelReadingDuration(); |
| | | if (todayReadTime <= 0L) { |
| | | return; |
| | | } |
| | | |
| | | long lastDuration = NovelGoldCornUtil.getReadTime(getContext()); |
| | | if (lastDuration == todayReadTime) { |
| | | return; |
| | | } |
| | | |
| | | NovelGoldCornUtil.setReadTime(todayReadTime, getContext()); |
| | | |
| | | if (!UserUtil.isLogin(getContext())) { |
| | | return; |
| | | } |
| | | //上传 |
| | | HttpApiUtil.readNovel(getContext(), (int) (todayReadTime / 1000), new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | super.onSuccessPerfect(statusCode, headers, jsonObject); |
| | | if (jsonObject.optInt("code") == 0) { |
| | | JSONObject data = jsonObject.optJSONObject("data"); |
| | | VideoGoldCornUtil.showInComeToast(data.optInt("goldCorn"), getContext()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, String jsonObject, Throwable e) { |
| | | super.onFailure(statusCode, headers, jsonObject, e); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
New file |
| | |
| | | package com.yeshi.makemoney.video.app.ui.subview; |
| | | |
| | | import android.animation.ValueAnimator; |
| | | import android.content.Context; |
| | | import android.graphics.Canvas; |
| | | import android.graphics.Color; |
| | | import android.graphics.Paint; |
| | | import android.graphics.RectF; |
| | | import android.text.TextUtils; |
| | | import android.util.AttributeSet; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | import android.view.animation.DecelerateInterpolator; |
| | | |
| | | import com.demo.lib.common.util.common.DimenUtils; |
| | | import com.yeshi.makemoney.video.app.utils.videos.DrawVideoGoldCornManager; |
| | | |
| | | public class CircleProgressView extends View { |
| | | private static final String TAG = "CircleProgressView"; |
| | | |
| | | private int mCircleLineStrokeWidth = 8; |
| | | |
| | | private final int mTxtStrokeWidth = 2; |
| | | |
| | | // 画圆所在的距形区域 |
| | | private final RectF mRectF; |
| | | |
| | | private final Paint mPaint; |
| | | |
| | | private final Context mContext; |
| | | |
| | | private int mMaxProgress = 1000; |
| | | |
| | | private int mProgress = 0; |
| | | |
| | | |
| | | public CircleProgressView(Context context, AttributeSet attrs) { |
| | | super(context, attrs); |
| | | mContext = context; |
| | | mRectF = new RectF(); |
| | | mPaint = new Paint(); |
| | | mCircleLineStrokeWidth = DimenUtils.dip2px(context, 3); |
| | | } |
| | | |
| | | @Override |
| | | protected void onDraw(Canvas canvas) { |
| | | super.onDraw(canvas); |
| | | int width = this.getWidth(); |
| | | int height = this.getHeight(); |
| | | |
| | | if (width != height) { |
| | | int min = Math.min(width, height); |
| | | width = min; |
| | | height = min; |
| | | } |
| | | |
| | | // 设置画笔相关属性 |
| | | mPaint.setAntiAlias(true); |
| | | mPaint.setColor(Color.TRANSPARENT); |
| | | canvas.drawColor(Color.TRANSPARENT); |
| | | mPaint.setStrokeWidth(mCircleLineStrokeWidth); |
| | | mPaint.setStyle(Paint.Style.STROKE); |
| | | // 位置 |
| | | mRectF.left = mCircleLineStrokeWidth / 2; // 左上角x |
| | | mRectF.top = mCircleLineStrokeWidth / 2; // 左上角y |
| | | mRectF.right = width - mCircleLineStrokeWidth / 2; // 左下角x |
| | | mRectF.bottom = height - mCircleLineStrokeWidth / 2; // 右下角y |
| | | |
| | | // 绘制圆圈,进度条背景 |
| | | canvas.drawArc(mRectF, -90, 360, false, mPaint); |
| | | mPaint.setColor(Color.rgb(0xff, 0xF5, 0xA9)); |
| | | //矩形、开始角度、扫过角度、是否实心、画笔 |
| | | canvas.drawArc(mRectF, -90, ((float) mProgress / mMaxProgress) * 360, false, mPaint); |
| | | } |
| | | |
| | | public int getMaxProgress() { |
| | | return mMaxProgress; |
| | | } |
| | | |
| | | public void setMaxProgress(int maxProgress) { |
| | | this.mMaxProgress = maxProgress; |
| | | } |
| | | |
| | | public void setProgress(int progress) { |
| | | this.mProgress = progress; |
| | | this.invalidate(); |
| | | } |
| | | |
| | | public void setAnimProgress(int p) { |
| | | //设置属性动画 |
| | | ValueAnimator valueAnimator = new ValueAnimator().ofInt(mProgress, p); |
| | | valueAnimator.setDuration(DrawVideoGoldCornManager.SPACE); |
| | | //监听值的变化 |
| | | valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { |
| | | @Override |
| | | public void onAnimationUpdate(ValueAnimator animation) { |
| | | int currentV = (Integer) animation.getAnimatedValue(); |
| | | Log.e("fwc", "current" + currentV); |
| | | mProgress = currentV; |
| | | invalidate(); |
| | | } |
| | | }); |
| | | valueAnimator.start(); |
| | | } |
| | | |
| | | //非UI线程调用 |
| | | public void setProgressNotInUiThread(int progress) { |
| | | this.mProgress = progress; |
| | | this.postInvalidate(); |
| | | } |
| | | } |
| | |
| | | import android.util.AttributeSet; |
| | | |
| | | |
| | | import com.yeshi.makemoney.video.app.R; |
| | | import com.yeshi.makemoney.video.R; |
| | | |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | |
| | |
| | | public class Constant { |
| | | public final static boolean DEBUG = false; |
| | | |
| | | public final static String HOST = "http://xxx"; |
| | | public final static String HOST = "http://192.168.3.122:8082"; |
| | | |
| | | public final static String DOWNLOAD_DIR_NAME = "xxx"; |
| | | |
New file |
| | |
| | | package com.yeshi.makemoney.video.app.utils; |
| | | |
| | | import android.content.Context; |
| | | |
| | | import com.tencent.mm.opensdk.modelmsg.SendAuth; |
| | | import com.tencent.mm.opensdk.openapi.IWXAPI; |
| | | import com.tencent.mm.opensdk.openapi.WXAPIFactory; |
| | | import com.yeshi.makemoney.video.R; |
| | | |
| | | public class WXUtil { |
| | | // IWXAPI 是第三方app和微信通信的openApi接口 |
| | | private static IWXAPI api; |
| | | |
| | | public static IWXAPI getApi() { |
| | | |
| | | return api; |
| | | } |
| | | |
| | | public static void regToWx(Context context) { |
| | | String appId = context.getString(R.string.wx_app_id); |
| | | // 通过WXAPIFactory工厂,获取IWXAPI的实例 |
| | | api = WXAPIFactory.createWXAPI(context, appId, true); |
| | | // 将应用的appId注册到微信 |
| | | api.registerApp(appId); |
| | | } |
| | | |
| | | /** |
| | | * 开始授权 |
| | | */ |
| | | public static void startAuth() { |
| | | SendAuth.Req req = new SendAuth.Req(); |
| | | req.scope = "snsapi_userinfo"; |
| | | req.state = "wechat_sdk_demo_test"; |
| | | api.sendReq(req); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.util.Log; |
| | | import android.widget.Toast; |
| | | |
| | | import com.yeshi.makemoney.video.app.utils.Constant; |
| | |
| | | import com.demo.lib.common.util.device.DeviceInfoUtil; |
| | | import com.demo.lib.common.util.device.MobileUtil; |
| | | import com.demo.lib.common.util.security.MD5Utils; |
| | | import com.yeshi.makemoney.video.app.utils.UserUtil; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | |
| | | private static final String TAG = "HttpApiUtil"; |
| | | |
| | | public static String BASE_URL = Constant.HOST + "/fanli/api/v1/"; |
| | | public static String BASE_URL = Constant.HOST + "/api/v1/"; |
| | | |
| | | public static OkHttpClient mOkHttpClient;//okHttpClient 实例 |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 请求demo |
| | | * |
| | | * @param context |
| | | * @param handler |
| | | */ |
| | | public static void xxx(Context context, BasicTextHttpResponseHandler handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | commonPostWithFailture(context, BASE_URL + "xxx/xxx", params, handler); |
| | | } |
| | | |
| | | |
| | | public static void getConfig(Context context, BasicTextHttpResponseHandler handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | commonPostWithFailture(context, BASE_URL + "xxx/xxx", params, handler); |
| | | } |
| | | |
| | | |
| | | public static void uploadPushRegId(Context context, String regId, BasicTextHttpResponseHandler handler) { |
| | | Log.i(TAG,"uploadPushRegId:"+regId); |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | String uid = UserUtil.getUid(context); |
| | | if (!StringUtils.isEmpty(uid)) |
| | | params.put("uid", uid); |
| | | params.put("regId", regId); |
| | | commonPostWithFailture(context, BASE_URL + "user/uploadPushRegId", params, handler); |
| | | } |
| | | |
| | | /** |
| | | * 获取任务信息 |
| | | * |
| | | * @param context |
| | | * @param type |
| | | * @param handler |
| | | */ |
| | | public static void getTaskInfo(Context context, String type, BasicTextHttpResponseHandler handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | String uid = UserUtil.getUid(context); |
| | | if (!StringUtils.isEmpty(uid)) |
| | | params.put("uid", uid); |
| | | params.put("type", type); |
| | | commonPostWithFailture(context, BASE_URL + "goldcorn/getTaskInfo", params, handler); |
| | | } |
| | | |
| | | /** |
| | | * 观看短视频 |
| | | * |
| | | * @param context |
| | | * @param second |
| | | * @param handler |
| | | */ |
| | | public static void watchDrawVideo(Context context, int second, boolean isDouble, BasicTextHttpResponseHandler handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("timeSeconds", second + ""); |
| | | String uid = UserUtil.getUid(context); |
| | | params.put("uid", uid); |
| | | params.put("type", "watchVideo"); |
| | | params.put("doubles", isDouble + ""); |
| | | commonPostWithFailture(context, BASE_URL + "goldcorn/doTask", params, handler); |
| | | } |
| | | |
| | | /** |
| | | * 读小说 |
| | | * |
| | | * @param context |
| | | * @param second |
| | | * @param handler |
| | | */ |
| | | public static void readNovel(Context context, int second, BasicTextHttpResponseHandler handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("timeSeconds", second + ""); |
| | | String uid = UserUtil.getUid(context); |
| | | params.put("uid", uid); |
| | | params.put("type", "readNovel"); |
| | | commonPostWithFailture(context, BASE_URL + "goldcorn/doTask", params, handler); |
| | | } |
| | | |
| | | /** |
| | | * 浏览资讯 |
| | | * |
| | | * @param context |
| | | * @param num |
| | | * @param handler |
| | | */ |
| | | public static void scanNews(Context context, int num, BasicTextHttpResponseHandler handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("num", num + ""); |
| | | String uid = UserUtil.getUid(context); |
| | | params.put("uid", uid); |
| | | params.put("type", "scanNews"); |
| | | commonPostWithFailture(context, BASE_URL + "goldcorn/doTask", params, handler); |
| | | } |
| | | |
| | | |
| | | private static void commonPost(Context context, String url, |
| | |
| | | for (String str : list) { |
| | | sign += str + "&"; |
| | | } |
| | | return MD5Utils.getMD532(sign + "buXiNjie2017!"); |
| | | return MD5Utils.getMD532(sign + "BuWan*@_%MakeMoney!!"); |
| | | } |
| | | |
| | | |
| | |
| | | long time = System.currentTimeMillis(); |
| | | String deviceType = DeviceInfoUtil.getSystemModel(context); |
| | | params.put("packages", context.getPackageName()); |
| | | params.put("Version", version + ""); |
| | | params.put("version", version + ""); |
| | | params.put("platform", "android"); |
| | | params.put("channel", ManifestDataUtil.getAppMetaData(context, "UMENG_CHANNEL")); |
| | | params.put("osVersion", MobileUtil.getSystemVersion()); |
| | | params.put("deviceType", StringUtils.isEmpty(deviceType) ? "" : deviceType); |
| | | params.put("time", time + ""); |
| | | params.put("timestamp", time + ""); |
| | | params.put("device", DeviceInfoUtil.getDeviceId(context)); |
| | | params.put("utdid", DeviceInfoUtil.getUtdid(context)); |
| | | params.put("utdId", DeviceInfoUtil.getUtdid(context)); |
| | | return params; |
| | | } |
| | | } |
| | |
| | | import android.widget.Toast; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.yeshi.makemoney.video.app.R; |
| | | import com.yeshi.makemoney.video.R; |
| | | import com.yeshi.makemoney.video.app.utils.JumpActivityUtil; |
| | | import com.yeshi.makemoney.video.app.utils.api.HttpApiUtil; |
| | | import com.demo.library_ec.AlibcTradeUtil; |
New file |
| | |
| | | package com.yeshi.makemoney.video.app.utils.ui; |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | |
| | | import com.alibaba.baichuan.trade.biz.AlibcTradeCallback; |
| | | import com.alibaba.baichuan.trade.biz.context.AlibcTradeResult; |
| | | import com.demo.lib.common.util.common.StringUtils; |
| | | import com.demo.library_ec.AlibcTradeUtil; |
| | | import com.demo.library_flutter.utils.FlutterPageUtil; |
| | | import com.yeshi.makemoney.video.app.ui.MainActivity; |
| | | import com.yeshi.makemoney.video.app.utils.UserUtil; |
| | | |
| | | import java.util.Map; |
| | | |
| | | public class JumpPageUtil { |
| | | public enum AppJumpType { |
| | | //邀请 |
| | | invite, |
| | | //短视频 |
| | | drawVideo, |
| | | //资讯 |
| | | news, |
| | | //小说 |
| | | novel, |
| | | //提现 |
| | | extract, |
| | | //签到 |
| | | signIn, |
| | | //网页 |
| | | web, |
| | | //百川 |
| | | baichuan; |
| | | } |
| | | |
| | | private static boolean needLogin(Context context) { |
| | | if (!UserUtil.isLogin(context)) { |
| | | FlutterPageUtil.jumpPage("LoginPage", null, null); |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | public static void jump(AppJumpType type, Map<String, Object> params, Activity activity) { |
| | | if (activity == null) { |
| | | return; |
| | | } |
| | | if (type == AppJumpType.invite) { |
| | | if (!needLogin(activity)) { |
| | | return; |
| | | } |
| | | FlutterPageUtil.jumpPage("InviteFriendsPage", params, null); |
| | | } else if (type == AppJumpType.drawVideo) { |
| | | activity.startActivity(new Intent(activity, MainActivity.class).putExtra("position", 0).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); |
| | | } else if (type == AppJumpType.news) { |
| | | activity.startActivity(new Intent(activity, MainActivity.class).putExtra("position", 1).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); |
| | | } else if (type == AppJumpType.novel) { |
| | | activity.startActivity(new Intent(activity, MainActivity.class).putExtra("position", 2).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); |
| | | |
| | | } else if (type == AppJumpType.extract) { |
| | | if (!needLogin(activity)) { |
| | | return; |
| | | } |
| | | FlutterPageUtil.jumpPage("BalancePage", params, null); |
| | | } else if (type == AppJumpType.signIn) { |
| | | FlutterPageUtil.jumpPage("TaskPage", params, null); |
| | | } else if (type == AppJumpType.web) { |
| | | FlutterPageUtil.jumpPage("BrowserPage", params, null); |
| | | } else if (type == AppJumpType.baichuan) { |
| | | if (params == null) { |
| | | return; |
| | | } |
| | | String url = params.get("url") + ""; |
| | | if (StringUtils.isEmpty(url)) { |
| | | return; |
| | | } |
| | | AlibcTradeUtil.openUrl(activity, url, null, null, null, new AlibcTradeCallback() { |
| | | |
| | | @Override |
| | | public void onTradeSuccess(AlibcTradeResult alibcTradeResult) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int i, String s) { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import android.view.View; |
| | | import android.widget.TextView; |
| | | |
| | | import com.yeshi.makemoney.video.app.R; |
| | | import com.yeshi.makemoney.video.R; |
| | | |
| | | |
| | | public class TopBarUtil { |
New file |
| | |
| | | package com.yeshi.makemoney.video.app.utils.videos; |
| | | |
| | | import android.content.Context; |
| | | import android.widget.Toast; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.yeshi.makemoney.video.app.entity.goldcorn.GoldCornTaskInfo; |
| | | import com.yeshi.makemoney.video.app.utils.api.BasicTextHttpResponseHandler; |
| | | import com.yeshi.makemoney.video.app.utils.api.HttpApiUtil; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.Timer; |
| | | import java.util.TimerTask; |
| | | |
| | | public class DrawVideoGoldCornManager { |
| | | public final static int SPACE = 40; |
| | | |
| | | //一圈10s |
| | | final static int CIRCLE_TIME = 10 * 1000; |
| | | |
| | | //播放时间 |
| | | Long playTime = 0L; |
| | | //视频播放状态 |
| | | boolean videoPlaying = false; |
| | | //手动暂停 |
| | | boolean paused = false; |
| | | |
| | | private boolean finish = true; |
| | | |
| | | |
| | | private static DrawVideoGoldCornManager instance; |
| | | private Timer timer; |
| | | |
| | | public static DrawVideoGoldCornManager getInstance() { |
| | | if (instance == null) { |
| | | instance = new DrawVideoGoldCornManager(); |
| | | } |
| | | return instance; |
| | | } |
| | | |
| | | /** |
| | | * 初始化实例 |
| | | */ |
| | | public void init(final PlayTimerCallBack callBack) { |
| | | playTime = 0L; |
| | | timer = new Timer(); |
| | | timer.schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | if (finish) { |
| | | return; |
| | | } |
| | | |
| | | if (playTime == null || paused) { |
| | | return; |
| | | } |
| | | if (videoPlaying) { |
| | | playTime += SPACE; |
| | | if (playTime % CIRCLE_TIME == 0L) { |
| | | //转满一圈后先暂停,然后回调 |
| | | stop(); |
| | | if (callBack != null) { |
| | | callBack.onProcess(1000); |
| | | } |
| | | } else { |
| | | int process = new BigDecimal(playTime).divide(new BigDecimal(CIRCLE_TIME), 3, RoundingMode.FLOOR).multiply(new BigDecimal(1000)).intValue(); |
| | | callBack.onProcess(process); |
| | | } |
| | | } |
| | | } |
| | | }, SPACE, SPACE); |
| | | } |
| | | |
| | | |
| | | public void videoPlay() { |
| | | videoPlaying = true; |
| | | } |
| | | |
| | | |
| | | public void videoPause() { |
| | | videoPlaying = false; |
| | | } |
| | | |
| | | /** |
| | | * 暂停计时 |
| | | */ |
| | | public void pause() { |
| | | paused = true; |
| | | } |
| | | |
| | | public void stop() { |
| | | playTime = null; |
| | | } |
| | | |
| | | /** |
| | | * 重新开始计时 |
| | | */ |
| | | public void restart() { |
| | | playTime = 0L; |
| | | } |
| | | |
| | | |
| | | public void continu() { |
| | | paused = false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 销毁实例 |
| | | */ |
| | | public void destory() { |
| | | if (timer != null) { |
| | | playTime = null; |
| | | videoPlaying = false; |
| | | timer.cancel(); |
| | | timer = null; |
| | | } |
| | | } |
| | | |
| | | |
| | | public boolean isFinish() { |
| | | return finish; |
| | | } |
| | | |
| | | /** |
| | | * 获取播放时间 |
| | | * |
| | | * @return |
| | | */ |
| | | public long getPlayTime() { |
| | | return playTime; |
| | | } |
| | | |
| | | public interface PlayTimerCallBack { |
| | | |
| | | /** |
| | | * 播放进度百分比 |
| | | * |
| | | * @param process |
| | | */ |
| | | public void onProcess(int process); |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 是否正在计数 |
| | | * |
| | | * @return |
| | | */ |
| | | public boolean isCounting() { |
| | | |
| | | return playTime != null && !paused && videoPlaying; |
| | | } |
| | | |
| | | |
| | | public void getTaskInfo(Context context, final ITaskInfoResult result) { |
| | | HttpApiUtil.getTaskInfo(context, "watchVideo", new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | super.onSuccessPerfect(statusCode, headers, jsonObject); |
| | | if (jsonObject == null || jsonObject.optInt("code") != 0) { |
| | | result.onResult(null); |
| | | return; |
| | | } |
| | | |
| | | JSONObject data = jsonObject.optJSONObject("data"); |
| | | |
| | | GoldCornTaskInfo info = new Gson().fromJson(data.toString(), GoldCornTaskInfo.class); |
| | | finish = info.isFinish(); |
| | | VideoGoldCornUtil.setPrice(context, info.getPrice()); |
| | | result.onResult(info); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, String jsonObject, Throwable e) { |
| | | super.onFailure(statusCode, headers, jsonObject, e); |
| | | result.onResult(null); |
| | | Toast.makeText(context, "网络请求出错", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | public interface ITaskInfoResult { |
| | | |
| | | public void onResult(GoldCornTaskInfo info); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.makemoney.video.app.utils.videos; |
| | | |
| | | import android.animation.ValueAnimator; |
| | | import android.app.Activity; |
| | | import android.app.Dialog; |
| | | import android.content.Context; |
| | | import android.content.DialogInterface; |
| | | import android.graphics.drawable.AnimationDrawable; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.view.animation.AccelerateDecelerateInterpolator; |
| | | import android.view.animation.Animation; |
| | | import android.widget.Toast; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.demo.lib.common.dialog.DialogUtil; |
| | | import com.demo.lib.common.util.common.DimenUtils; |
| | | import com.demo.lib.common.util.ui.LoadingDialogUtil; |
| | | import com.demo.library_ad.AdUtil; |
| | | import com.demo.library_ad.RewardAdUtil; |
| | | import com.yeshi.makemoney.video.R; |
| | | import com.yeshi.makemoney.video.app.entity.goldcorn.GoldCornTaskInfo; |
| | | import com.yeshi.makemoney.video.app.ui.dialog.GoldCornDoubleDialog; |
| | | import com.yeshi.makemoney.video.app.ui.subview.CircleProgressView; |
| | | import com.yeshi.makemoney.video.app.utils.UserUtil; |
| | | import com.yeshi.makemoney.video.app.utils.api.BasicTextHttpResponseHandler; |
| | | import com.yeshi.makemoney.video.app.utils.api.HttpApiUtil; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.util.Timer; |
| | | import java.util.TimerTask; |
| | | |
| | | public class DrawVideoHBManager { |
| | | |
| | | private final String TAG = "DrawVideoHBManager"; |
| | | |
| | | private final int MAX_CIRCLE = 6; |
| | | |
| | | private AQuery mAquery; |
| | | private Context mContext; |
| | | private CircleProgressView progressView; |
| | | private Activity mActivity; |
| | | private Dialog mDialog; |
| | | |
| | | //加倍按钮倒计时 |
| | | Timer doubleTimer; |
| | | int doubleTime = 0; |
| | | |
| | | private boolean reward = false; |
| | | |
| | | |
| | | /** |
| | | * 初始化 |
| | | * |
| | | * @param view |
| | | */ |
| | | public void init(View view, Activity activity) { |
| | | |
| | | mAquery = new AQuery(view); |
| | | mContext = view.getContext(); |
| | | mActivity = activity; |
| | | progressView = (CircleProgressView) mAquery.id(R.id.cb_process).getView(); |
| | | |
| | | mAquery.id(R.id.fl_hb).clicked(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | refreshTaskInfo(); |
| | | } |
| | | }); |
| | | |
| | | //加倍领取金币先消失 |
| | | mAquery.id(R.id.fl_double_btn).visibility(View.GONE); |
| | | mAquery.id(R.id.fl_double_btn).clicked(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (mDialog != null) { |
| | | DialogUtil.dismiss(mDialog); |
| | | } |
| | | |
| | | if (VideoGoldCornUtil.isDoubleNotify(mContext)) { |
| | | startDoubleTask(); |
| | | return; |
| | | } |
| | | |
| | | |
| | | //TODO 弹框 |
| | | mDialog = new GoldCornDoubleDialog.Builder(mActivity).setGoldCorn(VideoGoldCornUtil.getVideoPlayCircle(mContext) * VideoGoldCornUtil.getPrice(mContext)).setCallBack(new GoldCornDoubleDialog.GoldCornDoubleCallBack() { |
| | | @Override |
| | | public void onPositive(boolean notify) { |
| | | startDoubleTask(); |
| | | } |
| | | |
| | | @Override |
| | | public void onCancel() { |
| | | DialogUtil.dismiss(mDialog); |
| | | } |
| | | }).create(); |
| | | mDialog.setOnShowListener(new DialogInterface.OnShowListener() { |
| | | @Override |
| | | public void onShow(DialogInterface dialog) { |
| | | //暂停计费 |
| | | DrawVideoGoldCornManager.getInstance().pause(); |
| | | } |
| | | }); |
| | | |
| | | mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { |
| | | |
| | | @Override |
| | | public void onDismiss(DialogInterface dialog) { |
| | | //恢复计费 |
| | | DrawVideoGoldCornManager.getInstance().continu(); |
| | | } |
| | | }); |
| | | |
| | | |
| | | DialogUtil.show(mDialog); |
| | | } |
| | | }); |
| | | |
| | | //初始化总的金币数量 |
| | | if (VideoGoldCornUtil.getPrice(mContext) != null) { |
| | | setTotalGoldCornText(0, VideoGoldCornUtil.getVideoPlayCircle(mContext)); |
| | | } |
| | | initAnimation(); |
| | | } |
| | | |
| | | /** |
| | | * 进度回调 |
| | | * |
| | | * @param process |
| | | */ |
| | | public void onProcess(int process) { |
| | | |
| | | mActivity.runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | progressView.setProgress(process); |
| | | |
| | | //达到100% |
| | | if (process == 1000) { |
| | | int oldCircle = VideoGoldCornUtil.getVideoPlayCircle(mContext); |
| | | //增加圈数 |
| | | VideoGoldCornUtil.addVideoPlayCircle(mContext, 1); |
| | | //更新总的金币数显示 |
| | | mAquery.id(R.id.tv_total_goldcorn).getView().postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | setTotalGoldCornText(oldCircle, VideoGoldCornUtil.getVideoPlayCircle(mContext)); |
| | | } |
| | | }, 1000); |
| | | |
| | | |
| | | //进度条消失,然后播放动画 |
| | | mAquery.id(R.id.fl_hb).getView().postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | mAquery.id(R.id.cb_process).visibility(View.INVISIBLE); |
| | | hbHide(); |
| | | } |
| | | }, 500); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 刷新任务信息 |
| | | */ |
| | | public void refreshTaskInfo() { |
| | | //获取任务信息 |
| | | DrawVideoGoldCornManager.getInstance().getTaskInfo(mContext, new DrawVideoGoldCornManager.ITaskInfoResult() { |
| | | @Override |
| | | public void onResult(GoldCornTaskInfo info) { |
| | | if (info != null) { |
| | | if (info.isFinish()) { |
| | | //任务完成后要隐藏覆盖物 |
| | | mAquery.id(R.id.fl_cover).visibility(View.GONE); |
| | | } else { |
| | | mAquery.id(R.id.fl_cover).visibility(View.VISIBLE); |
| | | } |
| | | |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 销毁数据 |
| | | */ |
| | | public void destory() { |
| | | if (doubleTimer != null) { |
| | | doubleTimer.cancel(); |
| | | doubleTimer = null; |
| | | } |
| | | //todo 移除callback |
| | | // mAquery.id(R.id.tv_total_goldcorn).getView().removeCallbacks(); |
| | | } |
| | | |
| | | /** |
| | | * 开始加倍任务 |
| | | */ |
| | | private void startDoubleTask() { |
| | | if (reward) { |
| | | uploadData(true); |
| | | return; |
| | | } |
| | | |
| | | //TODO 去看广告 |
| | | LoadingDialogUtil.show(mActivity); |
| | | RewardAdUtil.loadAD(AdUtil.AD_TYPE.csj, "948550219", mActivity, new RewardAdUtil.RewardAdListener() { |
| | | @Override |
| | | public void onADLoad() { |
| | | Log.i(TAG, "onADLoad"); |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoCached() { |
| | | Log.i(TAG, "onVideoCached"); |
| | | } |
| | | |
| | | @Override |
| | | public void onADShow() { |
| | | Log.i(TAG, "onADShow"); |
| | | mActivity.runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | LoadingDialogUtil.dismiss(); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onAdClose() { |
| | | Log.i(TAG, "onAdClose"); |
| | | if (reward) { |
| | | uploadData(true); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onReward() { |
| | | Log.i(TAG, "onReward"); |
| | | reward = true; |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onError(String msg) { |
| | | Log.i(TAG, "onError:" + msg); |
| | | mActivity.runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | LoadingDialogUtil.dismiss(); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 上传数据 |
| | | * |
| | | * @param isDouble |
| | | */ |
| | | boolean isUploading = false; |
| | | |
| | | /** |
| | | * 上报数据 |
| | | * |
| | | * @param isDouble |
| | | */ |
| | | private void uploadData(boolean isDouble) { |
| | | //如果没有登录就返回 |
| | | if (!UserUtil.isLogin(mContext)) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | if (isUploading) { |
| | | return; |
| | | } |
| | | isUploading = true; |
| | | |
| | | int circle = VideoGoldCornUtil.getVideoPlayCircle(mContext); |
| | | HttpApiUtil.watchDrawVideo(mContext, circle * DrawVideoGoldCornManager.CIRCLE_TIME / 1000, isDouble, new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | if (isDouble) { |
| | | LoadingDialogUtil.show(mActivity); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | super.onSuccessPerfect(statusCode, headers, jsonObject); |
| | | if (jsonObject.optInt("code") == 0) { |
| | | int goldCorn = jsonObject.optJSONObject("data").optInt("goldCorn"); |
| | | int leftCount = jsonObject.optJSONObject("data").optInt("leftCount"); |
| | | if (leftCount == 0) { |
| | | refreshTaskInfo(); |
| | | } |
| | | |
| | | uploadSuccess(goldCorn, circle); |
| | | } else { |
| | | //TODO 业务错误 |
| | | Toast.makeText(mContext, jsonObject.optString("msg"), Toast.LENGTH_SHORT).show(); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, String jsonObject, Throwable e) { |
| | | super.onFailure(statusCode, headers, jsonObject, e); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | isUploading = false; |
| | | LoadingDialogUtil.dismiss(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | //上传成功 |
| | | private synchronized void uploadSuccess(int goldCorn, int oldCircle) { |
| | | //激励视频观看设置为未观看 |
| | | reward = false; |
| | | VideoGoldCornUtil.showInComeToast(goldCorn, mContext); |
| | | int leftCircle = VideoGoldCornUtil.getVideoPlayCircle(mContext) - oldCircle; |
| | | if (leftCircle < MAX_CIRCLE) { |
| | | //隐藏倒计时按钮 |
| | | mAquery.id(R.id.fl_double_btn).visibility(View.GONE); |
| | | } |
| | | resetDubleTimer(); |
| | | VideoGoldCornUtil.setVideoPlayCircle(leftCircle, mContext); |
| | | setTotalGoldCornText(oldCircle, leftCircle); |
| | | } |
| | | |
| | | |
| | | private void resetDubleTimer() { |
| | | //加倍按钮倒计时设置为空 |
| | | doubleTime = 0; |
| | | mAquery.id(R.id.fl_double_btn).clickable(true); |
| | | if (doubleTimer != null) { |
| | | doubleTimer.cancel(); |
| | | doubleTimer = null; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 隐藏红包图像显示 |
| | | */ |
| | | private void hbHide() { |
| | | mAquery.id(R.id.iv_hb).animate(R.anim.anim_hb_hidden, new Animation.AnimationListener() { |
| | | |
| | | @Override |
| | | public void onAnimationStart(Animation animation) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onAnimationEnd(Animation animation) { |
| | | mAquery.id(R.id.iv_hb).visibility(View.GONE); |
| | | |
| | | mAquery.id(R.id.fl_goldcorn).visibility(View.VISIBLE); |
| | | mAquery.id(R.id.fl_goldcorn).animate(R.anim.anim_goldcorn_show, new Animation.AnimationListener() { |
| | | @Override |
| | | public void onAnimationStart(Animation animation) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onAnimationEnd(Animation animation) { |
| | | //开始掉金币 |
| | | startGoldCornDown(); |
| | | |
| | | mAquery.id(R.id.tv_goldcorn).getView().postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //开始展示钱 |
| | | mAquery.id(R.id.tv_goldcorn).text(VideoGoldCornUtil.getPrice(mContext) + ""); |
| | | mAquery.id(R.id.tv_goldcorn).visibility(View.VISIBLE); |
| | | mAquery.id(R.id.tv_goldcorn).animate(R.anim.anim_goldcorn_show); |
| | | mAquery.id(R.id.iv_goldcorn_bg).visibility(View.VISIBLE); |
| | | AnimationDrawable animationDrawable = (AnimationDrawable) mAquery.id(R.id.iv_goldcorn_bg).getImageView().getDrawable(); |
| | | animationDrawable.start(); |
| | | } |
| | | }, 500); |
| | | |
| | | |
| | | //2秒后从新开始循环 |
| | | mAquery.id(R.id.fl_goldcorn).getView().postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | initAnimation(); |
| | | DrawVideoGoldCornManager.getInstance().restart(); |
| | | } |
| | | }, 2000); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onAnimationRepeat(Animation animation) { |
| | | |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onAnimationRepeat(Animation animation) { |
| | | |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置总的金币数量 |
| | | * |
| | | * @param fromCircle |
| | | * @param toCircle |
| | | */ |
| | | private void setTotalGoldCornText(int fromCircle, int toCircle) { |
| | | int price = VideoGoldCornUtil.getPrice(mContext); |
| | | ValueAnimator valueAnimator = new ValueAnimator().ofInt(price * fromCircle, price * toCircle); |
| | | valueAnimator.setDuration(500); |
| | | //监听值的变化 |
| | | valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { |
| | | @Override |
| | | public void onAnimationUpdate(ValueAnimator animation) { |
| | | int currentV = (Integer) animation.getAnimatedValue(); |
| | | mAquery.id(R.id.tv_total_goldcorn).text("+" + currentV); |
| | | } |
| | | }); |
| | | valueAnimator.start(); |
| | | //是否需要展示加倍按钮 |
| | | if (VideoGoldCornUtil.getVideoPlayCircle(mContext) >= MAX_CIRCLE && doubleTimer == null) { |
| | | mAquery.id(R.id.fl_double_btn).visibility(View.VISIBLE); |
| | | doubleTimer = new Timer(); |
| | | doubleTimer.schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | |
| | | mActivity.runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (DrawVideoGoldCornManager.getInstance().isCounting()) { |
| | | mAquery.id(R.id.pb_hide).getProgressBar().setProgress(doubleTime); |
| | | doubleTime++; |
| | | if (doubleTime > 120) { |
| | | mAquery.id(R.id.fl_double_btn).clickable(false); |
| | | //超过2分钟自动上报 |
| | | uploadData(false); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | }, 0, 1000); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 将动画初始化到最初的状态 |
| | | */ |
| | | private void initAnimation() { |
| | | for (int i = leftDPs.length - 1; i >= 0; i--) { |
| | | int resId = mContext.getResources().getIdentifier("iv_goldcorn_" + (i + 1), "id", mContext.getPackageName()); |
| | | mAquery.id(resId).margin(leftDPs[i], -20, 0, 0); |
| | | } |
| | | if (mAquery.id(R.id.fl_goldcorn).getView().getVisibility() == View.VISIBLE) { |
| | | mAquery.id(R.id.fl_goldcorn).animate(R.anim.anim_goldcorn_hidden, new Animation.AnimationListener() { |
| | | @Override |
| | | public void onAnimationStart(Animation animation) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onAnimationEnd(Animation animation) { |
| | | mAquery.id(R.id.fl_goldcorn).visibility(View.GONE); |
| | | mAquery.id(R.id.cb_process).visibility(View.VISIBLE); |
| | | mAquery.id(R.id.iv_hb).animate(R.anim.anim_hb_show, new Animation.AnimationListener() { |
| | | @Override |
| | | public void onAnimationStart(Animation animation) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onAnimationEnd(Animation animation) { |
| | | mAquery.id(R.id.iv_hb).visibility(View.VISIBLE); |
| | | } |
| | | |
| | | @Override |
| | | public void onAnimationRepeat(Animation animation) { |
| | | |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onAnimationRepeat(Animation animation) { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | mAquery.id(R.id.tv_goldcorn).visibility(View.GONE); |
| | | progressView.setProgress(0); |
| | | } |
| | | |
| | | final float[] leftDPs = new float[]{-5, +5, 0, -3, +3}; |
| | | final float[] topDPs = new float[]{32 - 10, 32 - 10, 30 - 10, 40 - 10, 40 - 10}; |
| | | |
| | | /** |
| | | * 开始金币掉落动画 |
| | | */ |
| | | private void startGoldCornDown() { |
| | | |
| | | for (int i = leftDPs.length - 1; i >= 0; i--) { |
| | | startGoldCornDown("iv_goldcorn_" + (i + 1), leftDPs[i], topDPs[i]); |
| | | } |
| | | } |
| | | |
| | | private void startGoldCornDown(String id, float leftDP, float topDP) { |
| | | int resId = mContext.getResources().getIdentifier(id, "id", mContext.getPackageName()); |
| | | mAquery.id(resId).margin(leftDP, -20, 0, 0); |
| | | ValueAnimator anim = ValueAnimator.ofFloat(-20, topDP); |
| | | anim.setDuration(300); |
| | | anim.setRepeatCount(0); |
| | | anim.setStartDelay((int) (Math.random() * 300)); |
| | | //先加速再减速 |
| | | anim.setInterpolator(new AccelerateDecelerateInterpolator()); |
| | | anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { |
| | | @Override |
| | | public void onAnimationUpdate(ValueAnimator animation) { |
| | | |
| | | float currentValue = (float) animation.getAnimatedValue(); |
| | | // 获得改变后的值 |
| | | mAquery.id(resId).margin(leftDP, currentValue, 0, 0); |
| | | } |
| | | }); |
| | | anim.start(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.makemoney.video.app.utils.videos; |
| | | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | |
| | | public class NewsGoldCornUtil { |
| | | |
| | | /** |
| | | * 增加资讯阅读数量 |
| | | * |
| | | * @param context |
| | | */ |
| | | public static void addNewsCount(Context context) { |
| | | SharedPreferences sharedPreferences = context.getSharedPreferences("news_goldcorn", Context.MODE_PRIVATE); |
| | | int old = sharedPreferences.getInt("count", 0); |
| | | SharedPreferences.Editor editor = sharedPreferences.edit(); |
| | | editor.putInt("count", old + 1); |
| | | editor.commit(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取资讯阅读数量 |
| | | * |
| | | * @param context |
| | | * @return |
| | | */ |
| | | public static int getNewsCount(Context context) { |
| | | SharedPreferences sharedPreferences = context.getSharedPreferences("news_goldcorn", Context.MODE_PRIVATE); |
| | | int count = sharedPreferences.getInt("count", 0); |
| | | return count; |
| | | } |
| | | |
| | | /** |
| | | * 设置资讯阅读数量 |
| | | * |
| | | * @param count |
| | | * @param context |
| | | */ |
| | | public static void setNewsCount(int count, Context context) { |
| | | SharedPreferences sharedPreferences = context.getSharedPreferences("news_goldcorn", Context.MODE_PRIVATE); |
| | | SharedPreferences.Editor editor = sharedPreferences.edit(); |
| | | editor.putInt("count", count); |
| | | editor.commit(); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.makemoney.video.app.utils.videos; |
| | | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | |
| | | public class NovelGoldCornUtil { |
| | | |
| | | |
| | | /** |
| | | * 获取小说阅读时间 |
| | | * |
| | | * @param context |
| | | * @return |
| | | */ |
| | | public static long getReadTime(Context context) { |
| | | SharedPreferences sharedPreferences = context.getSharedPreferences("novel_goldcorn", Context.MODE_PRIVATE); |
| | | return sharedPreferences.getLong("duration", 0L); |
| | | } |
| | | |
| | | /** |
| | | * 设置小说阅读时间 |
| | | * |
| | | * @param duration |
| | | * @param context |
| | | */ |
| | | public static void setReadTime(long duration, Context context) { |
| | | SharedPreferences sharedPreferences = context.getSharedPreferences("news_goldcorn", Context.MODE_PRIVATE); |
| | | SharedPreferences.Editor editor = sharedPreferences.edit(); |
| | | editor.putLong("duration", duration); |
| | | editor.commit(); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.makemoney.video.app.utils.videos; |
| | | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | | import android.graphics.Color; |
| | | import android.view.Gravity; |
| | | import android.view.View; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.demo.lib.common.util.common.DimenUtils; |
| | | import com.yeshi.makemoney.video.R; |
| | | |
| | | public class VideoGoldCornUtil { |
| | | |
| | | |
| | | /** |
| | | * 增加视频播放圈数 |
| | | * |
| | | * @param context |
| | | * @param circle |
| | | */ |
| | | public static void addVideoPlayCircle(Context context, int circle) { |
| | | SharedPreferences sharedPreferences = context.getSharedPreferences("video_goldcorn", Context.MODE_PRIVATE); |
| | | int old = sharedPreferences.getInt("circle", 0); |
| | | SharedPreferences.Editor editor = sharedPreferences.edit(); |
| | | editor.putInt("circle", old + circle); |
| | | editor.commit(); |
| | | } |
| | | |
| | | /** |
| | | * 获取视频播放圈数 |
| | | * |
| | | * @param context |
| | | * @return |
| | | */ |
| | | public static int getVideoPlayCircle(Context context) { |
| | | SharedPreferences sharedPreferences = context.getSharedPreferences("video_goldcorn", Context.MODE_PRIVATE); |
| | | return sharedPreferences.getInt("circle", 0); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 清除视频播放圈数 |
| | | * |
| | | * @param context |
| | | */ |
| | | public static void clearVideoPlayCircle(Context context) { |
| | | SharedPreferences sharedPreferences = context.getSharedPreferences("video_goldcorn", Context.MODE_PRIVATE); |
| | | SharedPreferences.Editor editor = sharedPreferences.edit(); |
| | | editor.remove("circle"); |
| | | editor.commit(); |
| | | } |
| | | |
| | | public static void setVideoPlayCircle(int circle, Context context) { |
| | | SharedPreferences sharedPreferences = context.getSharedPreferences("video_goldcorn", Context.MODE_PRIVATE); |
| | | SharedPreferences.Editor editor = sharedPreferences.edit(); |
| | | editor.putInt("circle", circle); |
| | | editor.commit(); |
| | | } |
| | | |
| | | /** |
| | | * 获取单价 |
| | | * |
| | | * @param context |
| | | * @return |
| | | */ |
| | | public static Integer getPrice(Context context) { |
| | | |
| | | SharedPreferences sharedPreferences = context.getSharedPreferences("video_goldcorn", Context.MODE_PRIVATE); |
| | | //获取1分钟的钱 |
| | | int price = sharedPreferences.getInt("price", 1); |
| | | //计算1圈的钱 |
| | | return (int) (price * DrawVideoGoldCornManager.CIRCLE_TIME / 1000 / (60.0f)); |
| | | } |
| | | |
| | | /** |
| | | * 设置单价 |
| | | * |
| | | * @param context |
| | | * @param goldCorn |
| | | */ |
| | | public static void setPrice(Context context, int goldCorn) { |
| | | SharedPreferences sharedPreferences = context.getSharedPreferences("video_goldcorn", Context.MODE_PRIVATE); |
| | | SharedPreferences.Editor editor = sharedPreferences.edit(); |
| | | editor.putInt("price", goldCorn); |
| | | editor.commit(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 入账提醒 |
| | | * |
| | | * @param goldCorn |
| | | */ |
| | | public static void showInComeToast(int goldCorn, Context context) { |
| | | Toast result = new Toast(context); |
| | | TextView v = new TextView(context); |
| | | v.setTextColor(Color.parseColor("#F5EBA4")); |
| | | v.setBackgroundResource(R.drawable.shape_goldcorn_toast_bg); |
| | | v.setText(goldCorn + "金币已入账"); |
| | | int px = DimenUtils.dipToPixels(1, context); |
| | | result.setView(v); |
| | | result.setDuration(Toast.LENGTH_SHORT); |
| | | result.setGravity(Gravity.BOTTOM, 0, px * 200); |
| | | result.show(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 是否加倍提醒 |
| | | * |
| | | * @param context |
| | | * @return |
| | | */ |
| | | public static boolean isDoubleNotify(Context context) { |
| | | SharedPreferences sharedPreferences = context.getSharedPreferences("video_goldcorn", Context.MODE_PRIVATE); |
| | | return sharedPreferences.getBoolean("double_notify", false); |
| | | } |
| | | |
| | | public static void setDoubleNotify(boolean notify, Context context) { |
| | | SharedPreferences sharedPreferences = context.getSharedPreferences("video_goldcorn", Context.MODE_PRIVATE); |
| | | SharedPreferences.Editor editor = sharedPreferences.edit(); |
| | | editor.putBoolean("double_notify", notify); |
| | | editor.commit(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.makemoney.video.wxapi; |
| | | |
| | | import com.jarvan.fluwx.wxapi.FluwxWXEntryActivity; |
| | | |
| | | public class WXEntryActivity extends FluwxWXEntryActivity { |
| | | |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <set xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | <scale |
| | | android:duration="100" |
| | | android:fromXScale="1" |
| | | android:fromYScale="1" |
| | | android:pivotX="50%" |
| | | android:pivotY="70%" |
| | | android:fillAfter="true" |
| | | android:toXScale="0" |
| | | android:toYScale="0" |
| | | android:interpolator="@android:anim/accelerate_decelerate_interpolator" |
| | | /> |
| | | |
| | | </set> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <set xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | <scale |
| | | android:duration="100" |
| | | android:fromXScale="0" |
| | | android:fromYScale="0" |
| | | android:pivotX="50%" |
| | | android:pivotY="70%" |
| | | android:fillAfter="true" |
| | | android:toXScale="1" |
| | | android:toYScale="1" |
| | | android:interpolator="@android:anim/accelerate_decelerate_interpolator" |
| | | /> |
| | | |
| | | </set> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <set xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | <scale |
| | | android:duration="100" |
| | | android:fromXScale="0" |
| | | android:fromYScale="0" |
| | | android:pivotX="50%" |
| | | android:pivotY="70%" |
| | | android:fillAfter="true" |
| | | android:toXScale="1" |
| | | android:toYScale="1" |
| | | android:interpolator="@android:anim/accelerate_decelerate_interpolator" |
| | | /> |
| | | |
| | | </set> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <set xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | <scale |
| | | android:duration="100" |
| | | android:fillAfter="true" |
| | | android:fromXScale="1" |
| | | android:fromYScale="1" |
| | | android:interpolator="@android:anim/accelerate_decelerate_interpolator" |
| | | android:pivotX="50%" |
| | | android:pivotY="50%" |
| | | android:toXScale="0" |
| | | android:toYScale="0" /> |
| | | |
| | | </set> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <set xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | <scale |
| | | android:duration="100" |
| | | android:fillAfter="true" |
| | | android:fromXScale="0" |
| | | android:fromYScale="0" |
| | | android:interpolator="@android:anim/accelerate_decelerate_interpolator" |
| | | android:pivotX="50%" |
| | | android:pivotY="50%" |
| | | android:toXScale="1" |
| | | android:toYScale="1" /> |
| | | |
| | | </set> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <animation-list xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:oneshot="true"> |
| | | <item |
| | | android:drawable="@drawable/anim_goldcorn_light_1_00000" |
| | | android:duration="40" /> |
| | | <item |
| | | android:drawable="@drawable/anim_goldcorn_light_1_00001" |
| | | android:duration="40" /> |
| | | <item |
| | | android:drawable="@drawable/anim_goldcorn_light_1_00002" |
| | | android:duration="40" /> |
| | | <item |
| | | android:drawable="@drawable/anim_goldcorn_light_1_00003" |
| | | android:duration="40" /> |
| | | <item |
| | | android:drawable="@drawable/anim_goldcorn_light_1_00004" |
| | | android:duration="40" /> |
| | | <item |
| | | android:drawable="@drawable/anim_goldcorn_light_1_00005" |
| | | android:duration="40" /> |
| | | <item |
| | | android:drawable="@drawable/anim_goldcorn_light_1_00006" |
| | | android:duration="40" /> |
| | | <item |
| | | android:drawable="@drawable/anim_goldcorn_light_1_00007" |
| | | android:duration="40" /> |
| | | <item |
| | | android:drawable="@drawable/anim_goldcorn_light_1_00008" |
| | | android:duration="40" /> |
| | | <item |
| | | android:drawable="@drawable/anim_goldcorn_light_1_00009" |
| | | android:duration="40" /> |
| | | <item |
| | | android:drawable="@drawable/anim_goldcorn_light_1_00010" |
| | | android:duration="40" /> |
| | | <item |
| | | android:drawable="@drawable/anim_goldcorn_light_1_00011" |
| | | android:duration="40" /> |
| | | <item |
| | | android:drawable="@drawable/anim_goldcorn_light_1_00012" |
| | | android:duration="40" /> |
| | | </animation-list> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | <item android:id="@android:id/background"> |
| | | <shape> |
| | | <!--设置ProgressBar进度条圆角半径--> |
| | | <corners android:radius="1dp" /> |
| | | <solid android:color="@color/transparent" /> |
| | | </shape> |
| | | </item> |
| | | <item android:id="@android:id/progress"> |
| | | <clip> |
| | | <shape> |
| | | <corners android:radius="1dp" /> |
| | | <solid android:color="#80000000" /> |
| | | </shape> |
| | | </clip> |
| | | </item> |
| | | |
| | | </layer-list> |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <selector xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | <item android:drawable="@drawable/ic_checked" android:state_checked="true"></item> |
| | | <item android:drawable="@drawable/ic_unchecked" android:state_checked="false"></item> |
| | | <item android:drawable="@drawable/ic_checked_common" android:state_checked="true"></item> |
| | | <item android:drawable="@drawable/ic_unchecked_common" android:state_checked="false"></item> |
| | | |
| | | </selector> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <selector xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | <item android:state_checked="true"> |
| | | |
| | | <set> |
| | | <objectAnimator android:duration="200" android:propertyName="textSize" android:valueFrom="15" android:valueTo="16" android:valueType="floatType" /> |
| | | </set> |
| | | |
| | | </item> |
| | | <item android:state_checked="false"> |
| | | |
| | | <set> |
| | | <objectAnimator android:duration="200" android:propertyName="textSize" android:valueFrom="16" android:valueTo="15" android:valueType="floatType" /> |
| | | </set> |
| | | |
| | | </item> |
| | | |
| | | </selector> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <selector xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | |
| | | </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_checked" android:state_checked="true"></item> |
| | | <item android:drawable="@drawable/ic_unchecked" 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="13dp" /> |
| | | <solid android:color="@color/exit_dialog_nagative_bg_color" /> |
| | | </shape> |
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="#80000000" /> |
| | | <padding android:left="10dp" android:right="10dp" android:top="4dp" android:bottom="4dp"></padding> |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | <corners |
| | | android:bottomLeftRadius="20dp" |
| | | android:topLeftRadius="20dp" /> |
| | | <solid android:color="@color/black" /> |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | <corners |
| | | android:radius="80dp" /> |
| | | <solid android:color="#80000000" /> |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | <corners android:radius="13dp" /> |
| | | <solid android:color="#A0000000" /> |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | <corners android:radius="13dp" /> |
| | | <solid android:color="#FE003E" /> |
| | | <padding |
| | | android:bottom="8dp" |
| | | android:left="30dp" |
| | | android:right="30dp" |
| | | android:top="8dp"></padding> |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | <corners android:radius="13dp" /> |
| | | |
| | | <solid android:color="@color/theme" /> |
| | | |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | <corners android:radius="13dp" /> |
| | | |
| | | <solid android:color="@color/white" /> |
| | | |
| | | </shape> |
| | |
| | | android:layout_width="51dp" |
| | | android:layout_height="31dp" |
| | | android:layout_alignParentRight="true" |
| | | android:background="@drawable/selector_checked" |
| | | android:background="@drawable/selector_switch" |
| | | android:button="@null" /> |
| | | </RelativeLayout> |
| | | |
| | |
| | | xmlns:tools="http://schemas.android.com/tools" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:background="@drawable/shape_white_corner_radius_3" |
| | | android:background="@drawable/shape_white_corner_radius_common" |
| | | android:gravity="center_horizontal" |
| | | android:orientation="vertical" |
| | | android:padding="20dp"> |
| | | android:padding="10dp"> |
| | | |
| | | <TextView |
| | | android:layout_width="match_parent" |
| | |
| | | android:layout_width="0dp" |
| | | android:layout_height="35dp" |
| | | android:layout_weight="1" |
| | | android:background="@color/theme" |
| | | android:background="@drawable/shape_theme_corner_radius_common" |
| | | android:gravity="center" |
| | | android:text="再看看" |
| | | android:textColor="@color/white" |
| | | android:textSize="15sp"></TextView> |
| | | |
| | | <View |
| | | android:layout_width="18dp" |
| | | android:layout_width="10dp" |
| | | android:layout_height="1dp"></View> |
| | | |
| | | |
| | |
| | | android:layout_width="0dp" |
| | | android:layout_height="35dp" |
| | | android:layout_weight="1" |
| | | android:background="@color/exit_dialog_nagative_bg_color" |
| | | android:background="@drawable/shape_exit_dialog_negative_bg" |
| | | android:gravity="center" |
| | | android:text="狠心离开" |
| | | android:textColor="@color/white" |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | xmlns:tools="http://schemas.android.com/tools" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:gravity="center_horizontal" |
| | | android:orientation="vertical"> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:background="@drawable/shape_white_corner_radius_common" |
| | | android:gravity="center_horizontal" |
| | | android:orientation="vertical" |
| | | android:padding="11dp"> |
| | | |
| | | <TextView |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:gravity="center" |
| | | android:paddingTop="10dp" |
| | | android:paddingBottom="10dp" |
| | | android:text="金币加倍" |
| | | android:textColor="@color/theme" |
| | | android:textSize="18sp" |
| | | android:textStyle="bold"></TextView> |
| | | |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:gravity="center" |
| | | android:paddingTop="20dp"> |
| | | |
| | | <ImageView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:src="@drawable/ic_goldcorn_double_dialog_video"></ImageView> |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="5dp" |
| | | android:text="看广告金币加倍" |
| | | android:textColor="@color/black" |
| | | android:textSize="14sp"></TextView> |
| | | |
| | | |
| | | </LinearLayout> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:gravity="center" |
| | | android:paddingTop="10dp"> |
| | | |
| | | <ImageView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="21dp" |
| | | android:src="@drawable/icon_home_goldcorn"></ImageView> |
| | | |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_goldcorn_old" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="2dp" |
| | | android:text="500" |
| | | android:textColor="#FF8316" |
| | | android:textSize="15sp" |
| | | android:textStyle="bold"></TextView> |
| | | |
| | | <View |
| | | android:layout_width="10dp" |
| | | android:layout_height="1dp"></View> |
| | | |
| | | |
| | | <ImageView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="21dp" |
| | | android:src="@drawable/ic_goldcorn_double_dialog_double"></ImageView> |
| | | |
| | | <View |
| | | android:layout_width="10dp" |
| | | android:layout_height="1dp"></View> |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="2dp" |
| | | android:text="=" |
| | | android:textColor="#FF8316" |
| | | android:textSize="15sp" |
| | | android:textStyle="bold"></TextView> |
| | | |
| | | <View |
| | | android:layout_width="5dp" |
| | | android:layout_height="1dp"></View> |
| | | |
| | | |
| | | <ImageView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="21dp" |
| | | android:src="@drawable/icon_home_goldcorn"></ImageView> |
| | | |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_goldcorn_new" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="2dp" |
| | | android:text="1000" |
| | | android:textColor="#FF8316" |
| | | android:textSize="15sp" |
| | | android:textStyle="bold"></TextView> |
| | | |
| | | |
| | | </LinearLayout> |
| | | |
| | | |
| | | <CheckBox |
| | | android:id="@+id/cb_notify" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="20dp" |
| | | android:button="@drawable/selector_checked" |
| | | android:padding="6dp" |
| | | android:text="不弹出此框,直接加倍" |
| | | android:textColor="#999999" |
| | | android:textSize="10sp"></CheckBox> |
| | | |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_positive" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="42dp" |
| | | android:background="@drawable/shape_theme_corner_radius_common" |
| | | android:gravity="center" |
| | | android:text="去加倍" |
| | | android:textColor="@color/white" |
| | | android:textSize="15sp"></TextView> |
| | | |
| | | </LinearLayout> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_close" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="10dp" |
| | | android:padding="7dp" |
| | | android:src="@drawable/icon_dialog_close"></ImageView> |
| | | |
| | | |
| | | </LinearLayout> |
| | |
| | | |
| | | <FrameLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | android:layout_height="match_parent" |
| | | android:background="@color/black"> |
| | | |
| | | <FrameLayout |
| | | android:id="@+id/fl_videos" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | </FrameLayout> |
| | | android:layout_height="match_parent"></FrameLayout> |
| | | |
| | | |
| | | <FrameLayout |
| | | android:id="@+id/fl_cover" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"></FrameLayout> |
| | | android:layout_height="match_parent"> |
| | | |
| | | |
| | | <!-- 红包进度与动画 --> |
| | | |
| | | <FrameLayout |
| | | android:id="@+id/fl_hb" |
| | | android:layout_width="50dp" |
| | | android:layout_height="60dp" |
| | | android:layout_gravity="left|top" |
| | | android:layout_marginLeft="10dp" |
| | | android:layout_marginTop="100dp"> |
| | | |
| | | <View |
| | | android:layout_width="50dp" |
| | | android:layout_height="50dp" |
| | | android:layout_gravity="bottom" |
| | | android:background="@drawable/shape_home_hb_bg"></View> |
| | | |
| | | |
| | | <FrameLayout |
| | | android:id="@+id/fl_goldcorn" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:layout_gravity="center_horizontal|bottom" |
| | | android:layout_marginBottom="10dp" |
| | | android:visibility="gone"> |
| | | |
| | | <ImageView |
| | | android:layout_width="30.5dp" |
| | | android:layout_height="41dp" |
| | | android:layout_gravity="bottom|center_horizontal" |
| | | android:src="@drawable/ic_home_hb_bg"></ImageView> |
| | | |
| | | <FrameLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | <!-- 若干硬币 --> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_goldcorn_1" |
| | | android:layout_width="14dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_horizontal" |
| | | android:layout_marginLeft="5dp" |
| | | android:layout_marginTop="34dp" |
| | | android:src="@drawable/icon_home_goldcorn"></ImageView> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_goldcorn_2" |
| | | android:layout_width="14dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_horizontal" |
| | | android:layout_marginLeft="-5dp" |
| | | android:layout_marginTop="34dp" |
| | | android:src="@drawable/icon_home_goldcorn"></ImageView> |
| | | |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_goldcorn_3" |
| | | android:layout_width="14dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_horizontal" |
| | | android:layout_marginLeft="0dp" |
| | | android:layout_marginTop="32dp" |
| | | android:src="@drawable/icon_home_goldcorn"></ImageView> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_goldcorn_4" |
| | | android:layout_width="12dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_horizontal" |
| | | android:layout_marginLeft="5dp" |
| | | android:layout_marginTop="-20dp" |
| | | android:src="@drawable/icon_home_goldcorn"></ImageView> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_goldcorn_5" |
| | | android:layout_width="12dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_horizontal" |
| | | android:layout_marginLeft="10dp" |
| | | android:layout_marginTop="-20dp" |
| | | android:src="@drawable/icon_home_goldcorn"></ImageView> |
| | | |
| | | |
| | | </FrameLayout> |
| | | |
| | | |
| | | <ImageView |
| | | android:layout_width="25dp" |
| | | android:layout_height="22.5dp" |
| | | android:layout_gravity="bottom|center_horizontal" |
| | | android:src="@drawable/ic_home_hb_fg"></ImageView> |
| | | |
| | | <FrameLayout |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="bottom|center_horizontal"> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_goldcorn_bg" |
| | | android:layout_width="25dp" |
| | | android:layout_height="20dp" |
| | | android:scaleType="centerCrop" |
| | | android:src="@drawable/anim_goldcorn_num_show_bg" |
| | | android:visibility="gone"> |
| | | |
| | | </ImageView> |
| | | |
| | | |
| | | <TextView |
| | | android:layout_marginTop="1dp" |
| | | android:id="@+id/tv_goldcorn" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | android:text="20" |
| | | android:textColor="#F5EBA4" |
| | | android:textSize="12sp" |
| | | android:textStyle="bold" |
| | | android:visibility="gone"></TextView> |
| | | |
| | | </FrameLayout> |
| | | |
| | | |
| | | </FrameLayout> |
| | | |
| | | <FrameLayout |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_horizontal|bottom" |
| | | android:visibility="visible"> |
| | | |
| | | <com.yeshi.makemoney.video.app.ui.subview.CircleProgressView |
| | | android:id="@+id/cb_process" |
| | | style="?android:attr/progressBarStyleLarge" |
| | | android:layout_width="50dp" |
| | | android:layout_height="50dp"> |
| | | |
| | | </com.yeshi.makemoney.video.app.ui.subview.CircleProgressView> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_hb" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="30dp" |
| | | android:layout_gravity="center" |
| | | android:src="@drawable/ic_home_hb"></ImageView> |
| | | </FrameLayout> |
| | | |
| | | |
| | | </FrameLayout> |
| | | |
| | | |
| | | <!-- 金币加倍 --> |
| | | <LinearLayout |
| | | android:id="@+id/ll_double" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="right|top" |
| | | android:layout_marginTop="40dp" |
| | | android:background="@drawable/shape_home_double_bg" |
| | | android:gravity="center_vertical" |
| | | android:orientation="horizontal" |
| | | android:paddingLeft="5dp" |
| | | android:paddingTop="4dp" |
| | | android:paddingRight="5dp" |
| | | android:paddingBottom="4dp"> |
| | | |
| | | <ImageView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:src="@drawable/icon_home_goldcorn"></ImageView> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_total_goldcorn" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="5dp" |
| | | android:layout_marginRight="8dp" |
| | | android:shadowColor="#ffd37200" |
| | | android:shadowDx="0" |
| | | android:shadowDy="1" |
| | | android:shadowRadius="3.0" |
| | | android:text="+0" |
| | | android:textColor="#fff5eba4" |
| | | android:textSize="13sp"></TextView> |
| | | |
| | | <FrameLayout |
| | | android:id="@+id/fl_double_btn" |
| | | android:layout_width="64dp" |
| | | android:layout_height="21dp"> |
| | | |
| | | <ImageView |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:src="@drawable/ic_home_double_recieve"></ImageView> |
| | | |
| | | |
| | | <ProgressBar |
| | | android:id="@+id/pb_hide" |
| | | style="?android:attr/progressBarStyleHorizontal" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:max="120" |
| | | android:maxHeight="21dp" |
| | | android:minHeight="21dp" |
| | | android:progress="0" |
| | | android:progressDrawable="@drawable/process_drawable"></ProgressBar> |
| | | |
| | | |
| | | </FrameLayout> |
| | | |
| | | |
| | | </LinearLayout> |
| | | |
| | | |
| | | </FrameLayout> |
| | | |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/ll_login" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="bottom" |
| | | android:layout_margin="8dp" |
| | | android:background="@drawable/shape_home_login_bg" |
| | | android:gravity="center_vertical" |
| | | android:paddingLeft="12dp" |
| | | android:paddingTop="8dp" |
| | | android:paddingRight="12dp" |
| | | android:paddingBottom="8dp"> |
| | | |
| | | <ImageView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:src="@drawable/ic_home_login"></ImageView> |
| | | |
| | | <View |
| | | android:layout_width="0dp" |
| | | android:layout_height="1dp" |
| | | android:layout_weight="1"></View> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_login" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:background="@drawable/shape_home_login_btn_bg" |
| | | android:text="去登录" |
| | | android:textColor="@color/white" |
| | | android:textSize="15sp"></TextView> |
| | | |
| | | </LinearLayout> |
| | | |
| | | |
| | | </FrameLayout> |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <resources> |
| | | |
| | | <color name="theme">#FFBB86FC</color> |
| | | <color name="theme">#FE003E</color> |
| | | |
| | | <color name="purple_200">#FFBB86FC</color> |
| | | <color name="purple_500">#FF6200EE</color> |
| | |
| | | <color name="black">#FF000000</color> |
| | | <color name="white">#FFFFFFFF</color> |
| | | |
| | | <color name="loading_color">#FF03DAC5</color> |
| | | <color name="loading_color">#FE003E</color> |
| | | <color name="transparent">#00000000</color> |
| | | |
| | | <color name="splash_bg_color"> |
| | |
| | | <resources> |
| | | <string name="app_name">赚钱短视频</string> |
| | | <string name="umeng_key">625d3bd430a4f67780a84e5c</string> |
| | | <string name="wx_app_id">wx123123</string> |
| | | |
| | | <string name="ad_gdt_appid"></string> |
| | | <string name="ad_csj_appid">5290972</string> |
| | |
| | | <item name="android:layout_height">match_parent</item> |
| | | <item name="android:layout_weight">1</item> |
| | | <item name="android:button">@null</item> |
| | | <item name="android:textSize">14sp</item> |
| | | <item name="android:textSize">15sp</item> |
| | | <item name="android:background">@color/transparent</item> |
| | | <item name="android:textAppearance">?android:attr/textAppearanceSmall</item> |
| | | <item name="android:drawablePadding">0dp</item> |
| | | <item name="android:textColor">@drawable/selector_nav_home_text_color</item> |
| | | <item name="android:gravity">center</item> |
| | | <item name="android:stateListAnimator">@drawable/selector_nav_home_text_size</item> |
| | | </style> |
| | | |
| | | |
| | | |
| | | <!-- 设置界面的ITEM样式 --> |
| | | <style name="settingsItemStyle"> |
| | | <item name="android:layout_height">70dp</item> |
New file |
| | |
| | | package com.demo.library_ad; |
| | | |
| | | import android.app.Activity; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | |
| | | import com.bytedance.sdk.openadsdk.AdSlot; |
| | | import com.bytedance.sdk.openadsdk.TTAdConstant; |
| | | import com.bytedance.sdk.openadsdk.TTAdLoadType; |
| | | import com.bytedance.sdk.openadsdk.TTAdManager; |
| | | import com.bytedance.sdk.openadsdk.TTAdNative; |
| | | import com.bytedance.sdk.openadsdk.TTRewardVideoAd; |
| | | import com.bytedance.sdk.openadsdk.TTSplashAd; |
| | | import com.demo.lib.common.util.common.DimenUtils; |
| | | import com.qq.e.ads.rewardvideo.RewardVideoAD; |
| | | import com.qq.e.ads.rewardvideo.RewardVideoADListener; |
| | | import com.qq.e.ads.splash.SplashAD; |
| | | import com.qq.e.ads.splash.SplashADListener; |
| | | import com.qq.e.comm.util.AdError; |
| | | |
| | | import java.util.Map; |
| | | |
| | | public class RewardAdUtil { |
| | | |
| | | /** |
| | | * 加载开屏广告 |
| | | * |
| | | * @param adType |
| | | * @param pid |
| | | * @param context |
| | | * @param rewardAdListener |
| | | */ |
| | | public static void loadAD(AdUtil.AD_TYPE adType, String pid, Activity context, final RewardAdListener rewardAdListener) { |
| | | if (adType == null) { |
| | | rewardAdListener.onError("广告类型为空"); |
| | | return; |
| | | } |
| | | if (AdUtil.AD_TYPE.csj == adType) { |
| | | loadCSJ(context, pid, rewardAdListener); |
| | | } else if (AdUtil.AD_TYPE.gdt == adType) { |
| | | loadGDT(context, pid, rewardAdListener); |
| | | } else { |
| | | rewardAdListener.onError("广告类型未知"); |
| | | } |
| | | } |
| | | |
| | | private static void loadGDT(Activity context, String pid, final RewardAdListener rewardAdListener) { |
| | | RewardVideoAD rewardVideoAD = new RewardVideoAD(context, pid, new RewardVideoADListener() { |
| | | @Override |
| | | public void onADLoad() { |
| | | rewardAdListener.onADLoad(); |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoCached() { |
| | | rewardAdListener.onVideoCached(); |
| | | } |
| | | |
| | | @Override |
| | | public void onADShow() { |
| | | rewardAdListener.onADShow(); |
| | | } |
| | | |
| | | @Override |
| | | public void onADExpose() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onReward(Map<String, Object> map) { |
| | | rewardAdListener.onReward(); |
| | | } |
| | | |
| | | @Override |
| | | public void onADClick() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoComplete() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADClose() { |
| | | rewardAdListener.onAdClose(); |
| | | } |
| | | |
| | | @Override |
| | | public void onError(AdError adError) { |
| | | rewardAdListener.onError(adError.getErrorMsg()); |
| | | } |
| | | }); |
| | | rewardVideoAD.loadAD(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 加载穿山甲广告 |
| | | * |
| | | * @param context |
| | | * @param vg_ad |
| | | * @param splashAdListener |
| | | */ |
| | | /** |
| | | * @param context |
| | | * @param code 代码位 |
| | | * @param rewardAdListener |
| | | */ |
| | | private static void loadCSJ(Activity context, String code, final RewardAdListener rewardAdListener) { |
| | | TTAdManager ttAdManager = null; |
| | | try { |
| | | ttAdManager = TTAdManagerHolder.get(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (ttAdManager == null) { |
| | | if (rewardAdListener != null) |
| | | rewardAdListener.onError("SDK未初始化"); |
| | | return; |
| | | } |
| | | |
| | | AdSlot adSlot = new AdSlot.Builder() |
| | | .setCodeId(code) |
| | | //模板广告需要设置期望个性化模板广告的大小,单位dp,激励视频场景,只要设置的值大于0即可 |
| | | .setExpressViewAcceptedSize(500, 500)//附加参数 |
| | | .setOrientation(TTAdConstant.VERTICAL) //必填参数,期望视频的播放方向:TTAdConstant.HORIZONTAL 或 TTAdConstant.VERTICAL |
| | | .setAdLoadType(TTAdLoadType.LOAD)//推荐使用,用于标注此次的广告请求用途为预加载(当做缓存)还是实时加载,方便后续为开发者优化相关策略 |
| | | .build(); |
| | | TTAdNative mTTAdNative = ttAdManager.createAdNative(context.getApplicationContext()); |
| | | mTTAdNative.loadRewardVideoAd(adSlot, new TTAdNative.RewardVideoAdListener() { |
| | | @Override |
| | | public void onError(int i, String s) { |
| | | rewardAdListener.onError(s); |
| | | } |
| | | |
| | | @Override |
| | | public void onRewardVideoAdLoad(TTRewardVideoAd ttRewardVideoAd) { |
| | | rewardAdListener.onADLoad(); |
| | | } |
| | | |
| | | @Override |
| | | public void onRewardVideoCached() { |
| | | rewardAdListener.onVideoCached(); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onRewardVideoCached(TTRewardVideoAd ttRewardVideoAd) { |
| | | rewardAdListener.onVideoCached(); |
| | | ttRewardVideoAd.setRewardAdInteractionListener(new TTRewardVideoAd.RewardAdInteractionListener() { |
| | | @Override |
| | | public void onAdShow() { |
| | | rewardAdListener.onADShow(); |
| | | } |
| | | |
| | | @Override |
| | | public void onAdVideoBarClick() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onAdClose() { |
| | | rewardAdListener.onAdClose(); |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoComplete() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoError() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onRewardVerify(boolean b, int i, String s, int i1, String s1) { |
| | | //奖励是否有效 |
| | | if (b) { |
| | | rewardAdListener.onReward(); |
| | | } else { |
| | | rewardAdListener.onError("获取奖励失败:" + s1); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onSkippedVideo() { |
| | | |
| | | } |
| | | }); |
| | | ttRewardVideoAd.showRewardVideoAd(context); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | public interface RewardAdListener { |
| | | public void onADLoad(); |
| | | |
| | | public void onVideoCached(); |
| | | |
| | | public void onADShow(); |
| | | |
| | | public void onAdClose(); |
| | | |
| | | public void onReward(); |
| | | |
| | | public void onError(String msg); |
| | | } |
| | | |
| | | } |
| | |
| | | --> |
| | | <resources> |
| | | <color name="dim_foreground_dark">#bebebe</color> |
| | | <color name="loading_color">#FF03DAC5</color> |
| | | <color name="loading_color">#FE003E</color> |
| | | <color name="transparent">#00000000</color> |
| | | </resources> |
| | |
| | | android:allowBackup="true" |
| | | android:icon="@mipmap/ic_launcher" |
| | | android:label="@string/app_name" |
| | | android:roundIcon="@mipmap/ic_launcher_round" |
| | | android:supportsRtl="true" |
| | | android:theme="@style/Theme.Android"> |
| | | <activity |
| | |
| | | break; |
| | | case "getBaseRequestParams": |
| | | //获取请求参数 |
| | | Map<String, Object> params = (Map<String, Object>) call.arguments; |
| | | Map<String, String> params = (Map<String, String>) call.arguments; |
| | | params = dataListener.getBaseRequestParams(params); |
| | | //转json返回 |
| | | result.success(JSONObject.toJSON(params)); |
| | |
| | | } |
| | | |
| | | public interface DataListener { |
| | | public Map<String, Object> getBaseRequestParams(Map<String, Object> params); |
| | | public Map<String, String> getBaseRequestParams(Map<String, String> params); |
| | | } |
| | | } |
| | |
| | | StatusBarUtil.setDarkMode(FlutterBoost.instance().currentActivity()); |
| | | } |
| | | break; |
| | | //跳转原生页面 |
| | | case "jumpAppPage": { |
| | | Map<String, Object> params = (Map<String, Object>) call.arguments; |
| | | String type = params.get("type").toString(); |
| | | Map<String, Object> ps = (Map<String, Object>) params.get("params"); |
| | | dataListener.jumpAppPage(type, ps); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | }); |
| | |
| | | public interface DataListener { |
| | | //状态栏是否默认浅色 |
| | | public boolean isStatusBarDefaultLight(); |
| | | |
| | | public void jumpAppPage(String type, Map<String, Object> params); |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.demo.library_flutter.nativeview; |
| | | |
| | | import android.content.Context; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.widget.FrameLayout; |
| | | |
| | | import com.bytedance.sdk.dp.DPSdk; |
| | | import com.bytedance.sdk.dp.DPWidgetDrawParams; |
| | | import com.bytedance.sdk.dp.IDPNewsListener; |
| | | import com.bytedance.sdk.dp.IDPWidget; |
| | | import com.demo.library_flutter.R; |
| | | import com.idlefish.flutterboost.FlutterBoost; |
| | | import com.qq.e.ads.nativ.NativeExpressAD; |
| | | import com.qq.e.ads.nativ.NativeExpressADView; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentActivity; |
| | | import androidx.fragment.app.FragmentManager; |
| | | import io.flutter.plugin.common.BinaryMessenger; |
| | | import io.flutter.plugin.common.MethodCall; |
| | | import io.flutter.plugin.common.MethodChannel; |
| | | import io.flutter.plugin.platform.PlatformView; |
| | | |
| | | class DrawVideoNativeView implements PlatformView { |
| | | private static String TAG = "DrawVideoNativeView"; |
| | | private Map<String, Object> params; |
| | | private MethodChannel methodChannel; |
| | | private Context mContext; |
| | | private FragmentManager mFragmentManager; |
| | | private View contentView; |
| | | |
| | | |
| | | public DrawVideoNativeView(int viewId, Context context, Map<String, Object> params, BinaryMessenger binaryMessenger) { |
| | | this.params = params; |
| | | this.mContext = context; |
| | | methodChannel = new MethodChannel(binaryMessenger, "ad-draw-video-view-" + viewId); |
| | | methodChannel.setMethodCallHandler(new MethodChannel.MethodCallHandler() { |
| | | @Override |
| | | public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) { |
| | | if ("refresh".equalsIgnoreCase(call.method)) { |
| | | //刷新 |
| | | |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public View getView() { |
| | | |
| | | if (contentView == null) { |
| | | contentView = LayoutInflater.from(mContext).inflate(R.layout.fragment_draw_video, null); |
| | | if (mFragmentManager == null) { |
| | | FragmentActivity fragmentActivity = (FragmentActivity) FlutterBoost.instance().currentActivity(); |
| | | mFragmentManager = fragmentActivity.getSupportFragmentManager(); |
| | | } |
| | | initVideo(); |
| | | } |
| | | return contentView; |
| | | } |
| | | |
| | | private void initVideo() { |
| | | IDPWidget mIDPWidget = DPSdk.factory().createDraw(DPWidgetDrawParams.obtain().hideClose(true, null) |
| | | .drawContentType(DPWidgetDrawParams.DRAW_CONTENT_TYPE_ALL) |
| | | .enableRefresh(true) |
| | | .customCategory("风景") |
| | | .listener(new IDPNewsListener() { |
| | | @Override |
| | | public void onDPRefreshFinish() { |
| | | log("onDPRefreshFinish"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPNewsItemClick(Map<String, Object> map) { |
| | | log("onDPNewsItemClick"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoPlay(Map<String, Object> map) { |
| | | log("onDPVideoPlay"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoPause(Map<String, Object> map) { |
| | | log("onDPVideoPause"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoContinue(Map<String, Object> map) { |
| | | log("onDPVideoContinue"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoOver(Map<String, Object> map) { |
| | | log("onDPVideoOver"); |
| | | // DPEventCollectUtil.playDrawVideo(getContext(), null, "dy", "home", false); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoCompletion(Map<String, Object> map) { |
| | | log("onDPVideoCompletion"); |
| | | super.onDPVideoCompletion(map); |
| | | // DPEventCollectUtil.playDrawVideo(getContext(), null, "dy", "home", true); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPNewsDetailEnter(Map<String, Object> map) { |
| | | log("onDPNewsDetailEnter"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPNewsDetailExit(Map<String, Object> map) { |
| | | log("onDPNewsDetailExit"); |
| | | } |
| | | |
| | | |
| | | })); |
| | | |
| | | Fragment fragment = mIDPWidget.getFragment(); |
| | | if (fragment != null) { |
| | | mFragmentManager.beginTransaction().replace(R.id.fl_container_draw_video, fragment).commitAllowingStateLoss(); |
| | | } |
| | | } |
| | | |
| | | private static void log(String msg) { |
| | | Log.d(TAG, String.valueOf(msg)); |
| | | } |
| | | |
| | | @Override |
| | | public void dispose() { |
| | | |
| | | } |
| | | } |
| | | |
New file |
| | |
| | | package com.demo.library_flutter.nativeview; |
| | | |
| | | |
| | | import android.content.Context; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import io.flutter.plugin.common.BinaryMessenger; |
| | | import io.flutter.plugin.common.MessageCodec; |
| | | import io.flutter.plugin.platform.PlatformView; |
| | | import io.flutter.plugin.platform.PlatformViewFactory; |
| | | |
| | | public class DrawVideoNativeViewFactory extends PlatformViewFactory { |
| | | |
| | | |
| | | private BinaryMessenger binaryMessenger; |
| | | |
| | | /** |
| | | * @param createArgsCodec the codec used to decode the args parameter of {@link #create}. |
| | | */ |
| | | public DrawVideoNativeViewFactory(BinaryMessenger binaryMessenger, MessageCodec<Object> createArgsCodec) { |
| | | super(createArgsCodec); |
| | | this.binaryMessenger = binaryMessenger; |
| | | } |
| | | |
| | | @Override |
| | | public PlatformView create(Context context, int viewId, Object args) { |
| | | //参数 |
| | | Map params = (Map) args; |
| | | DrawVideoNativeView view = new DrawVideoNativeView(viewId, context, params, binaryMessenger); |
| | | return view; |
| | | } |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | xmlns:app="http://schemas.android.com/apk/res-auto" |
| | | xmlns:tools="http://schemas.android.com/tools" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | tools:context=".FlutterCommonActivity"> |
| | | |
| | | <FrameLayout |
| | | android:id="@+id/fl_container_draw_video" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"></FrameLayout> |
| | | |
| | | </androidx.constraintlayout.widget.ConstraintLayout> |
New file |
| | |
| | | import 'dart:convert'; |
| | | |
| | | import 'package:flutter/material.dart'; |
| | | import 'package:makemoney/model/msg/app_notify_msg_model.dart'; |
| | | import 'package:makemoney/utils/encrypt_util.dart'; |
| | | import '../../utils/string_util.dart'; |
| | | import '../../utils/user_util.dart'; |
| | | |
| | | import 'http.dart'; |
| | | import 'dart:io'; |
| | | |
| | | class MsgApiUtil { |
| | | ///获取页面通知信息 |
| | | static Future<AppNotifyMsgModel?> getNotifyMsg( |
| | | BuildContext context, String type) async { |
| | | var result = await HttpUtil.baseRequest( |
| | | context, "/api/v1/msg/getNotifyMsg", {"type": type}, () {}); |
| | | if (result.success) { |
| | | var data = result.data; |
| | | if (data == null) { |
| | | return null; |
| | | } |
| | | |
| | | if (data["code"] == 0) { |
| | | return AppNotifyMsgModel.fromJson(data["data"]); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | ///获取用户消息 |
| | | static Future<Map<String, dynamic>?> getUserMsg( |
| | | BuildContext context, int page) async { |
| | | Map<String, dynamic> params = {}; |
| | | params["uid"] = await UserUtil.getUid(); |
| | | params["page"] = page; |
| | | |
| | | var result = await HttpUtil.baseRequest( |
| | | context, "/api/v1/msg/getUserMsg", params, () {}); |
| | | if (result.success) { |
| | | return result.data; |
| | | } |
| | | return null; |
| | | } |
| | | } |
New file |
| | |
| | | /// icon : "http://" |
| | | /// name : "名称" |
| | | /// process : "进度" |
| | | /// price : "单价" |
| | | /// actionName : "按钮名称" |
| | | /// active : true |
| | | /// jumpType : "baichuan" |
| | | |
| | | class TaskListModel { |
| | | TaskListModel({ |
| | | String? icon, |
| | | String? name, |
| | | String? process, |
| | | int? price, |
| | | String? priceUnit, |
| | | String? actionName, |
| | | bool? active, |
| | | String? jumpType, |
| | | }) { |
| | | _icon = icon; |
| | | _name = name; |
| | | _process = process; |
| | | _price = price; |
| | | _priceUnit=priceUnit; |
| | | _actionName = actionName; |
| | | _active = active; |
| | | _jumpType = jumpType; |
| | | } |
| | | |
| | | TaskListModel.fromJson(dynamic json) { |
| | | _icon = json['icon']; |
| | | _name = json['name']; |
| | | _process = json['process']; |
| | | _price = json['price']; |
| | | _priceUnit=json['priceUnit']; |
| | | _actionName = json['actionName']; |
| | | _active = json['active']; |
| | | _jumpType = json['jumpType']; |
| | | } |
| | | |
| | | String? _icon; |
| | | String? _name; |
| | | String? _process; |
| | | int? _price; |
| | | String? _priceUnit; |
| | | String? _actionName; |
| | | bool? _active; |
| | | String? _jumpType; |
| | | |
| | | String? get icon => _icon; |
| | | |
| | | String? get name => _name; |
| | | |
| | | String? get process => _process; |
| | | |
| | | int? get price => _price; |
| | | |
| | | String? get priceUnit => _priceUnit; |
| | | |
| | | String? get actionName => _actionName; |
| | | |
| | | bool? get active => _active; |
| | | |
| | | String? get jumpType => _jumpType; |
| | | |
| | | Map<String, dynamic> toJson() { |
| | | final map = <String, dynamic>{}; |
| | | map['icon'] = _icon; |
| | | map['name'] = _name; |
| | | map['process'] = _process; |
| | | map['price'] = _price; |
| | | map['priceUnit'] = _priceUnit; |
| | | map['actionName'] = _actionName; |
| | | map['active'] = _active; |
| | | map['jumpType'] = _jumpType; |
| | | return map; |
| | | } |
| | | } |
New file |
| | |
| | | /// close : false |
| | | /// content : "这是团队测试通知团队测试通知团队测试通知团队测试通知团队测试通知团队测试通知团队测试通知团队测试通知" |
| | | /// link : "http://www.baidu.com" |
| | | /// md5 : "6003334c675bc07a627345e406573ef0" |
| | | |
| | | class AppNotifyMsgModel { |
| | | AppNotifyMsgModel({ |
| | | bool? close, |
| | | String? content, |
| | | String? link, |
| | | String? md5, |
| | | }) { |
| | | _close = close; |
| | | _content = content; |
| | | _link = link; |
| | | _md5 = md5; |
| | | } |
| | | |
| | | |
| | | AppNotifyMsgModel.fromJson(dynamic json) { |
| | | _close = json['close']; |
| | | _content = json['content']; |
| | | _link = json['link']; |
| | | _md5 = json['md5']; |
| | | } |
| | | |
| | | bool? _close; |
| | | String? _content; |
| | | String? _link; |
| | | String? _md5; |
| | | |
| | | bool? get close => _close; |
| | | |
| | | String? get content => _content; |
| | | |
| | | String? get link => _link; |
| | | |
| | | String? get md5 => _md5; |
| | | |
| | | Map<String, dynamic> toJson() { |
| | | final map = <String, dynamic>{}; |
| | | map['close'] = _close; |
| | | map['content'] = _content; |
| | | map['link'] = _link; |
| | | map['md5'] = _md5; |
| | | return map; |
| | | } |
| | | } |
New file |
| | |
| | | /// id : "22384-extract-1650781076696" |
| | | /// type : {"icon":"","name":"余额提现"} |
| | | /// contentList : [{"title":"提现金额","content":"10元"},{"title":"提现状态","content":"提现失败"},{"title":"备注","content":"这是测试备注,测试备注,测试备注"}] |
| | | /// createTime : "2022.04.24 14:17" |
| | | |
| | | class UserMsgModel { |
| | | UserMsgModel({ |
| | | String? id, |
| | | Type? type, |
| | | List<ContentList>? contentList, |
| | | String? createTime, |
| | | }) { |
| | | _id = id; |
| | | _type = type; |
| | | _contentList = contentList; |
| | | _createTime = createTime; |
| | | } |
| | | |
| | | UserMsgModel.fromJson(dynamic json) { |
| | | _id = json['id']; |
| | | _type = json['type'] != null ? Type.fromJson(json['type']) : null; |
| | | if (json['contentList'] != null) { |
| | | _contentList = []; |
| | | json['contentList'].forEach((v) { |
| | | _contentList?.add(ContentList.fromJson(v)); |
| | | }); |
| | | } |
| | | _createTime = json['createTime']; |
| | | } |
| | | |
| | | String? _id; |
| | | Type? _type; |
| | | List<ContentList>? _contentList; |
| | | String? _createTime; |
| | | |
| | | String? get id => _id; |
| | | |
| | | Type? get type => _type; |
| | | |
| | | List<ContentList>? get contentList => _contentList; |
| | | |
| | | String? get createTime => _createTime; |
| | | |
| | | Map<String, dynamic> toJson() { |
| | | final map = <String, dynamic>{}; |
| | | map['id'] = _id; |
| | | if (_type != null) { |
| | | map['type'] = _type?.toJson(); |
| | | } |
| | | if (_contentList != null) { |
| | | map['contentList'] = _contentList?.map((v) => v.toJson()).toList(); |
| | | } |
| | | map['createTime'] = _createTime; |
| | | return map; |
| | | } |
| | | } |
| | | |
| | | /// title : "提现金额" |
| | | /// content : "10元" |
| | | |
| | | class ContentList { |
| | | ContentList({ |
| | | String? title, |
| | | String? content, |
| | | }) { |
| | | _title = title; |
| | | _content = content; |
| | | } |
| | | |
| | | ContentList.fromJson(dynamic json) { |
| | | _title = json['title']; |
| | | _content = json['content']; |
| | | } |
| | | |
| | | String? _title; |
| | | String? _content; |
| | | |
| | | String? get title => _title; |
| | | |
| | | String? get content => _content; |
| | | |
| | | Map<String, dynamic> toJson() { |
| | | final map = <String, dynamic>{}; |
| | | map['title'] = _title; |
| | | map['content'] = _content; |
| | | return map; |
| | | } |
| | | } |
| | | |
| | | /// icon : "" |
| | | /// name : "余额提现" |
| | | |
| | | class Type { |
| | | Type({ |
| | | String? icon, |
| | | String? name, |
| | | }) { |
| | | _icon = icon; |
| | | _name = name; |
| | | } |
| | | |
| | | Type.fromJson(dynamic json) { |
| | | _icon = json['icon']; |
| | | _name = json['name']; |
| | | } |
| | | |
| | | String? _icon; |
| | | String? _name; |
| | | |
| | | String? get icon => _icon; |
| | | |
| | | String? get name => _name; |
| | | |
| | | Map<String, dynamic> toJson() { |
| | | final map = <String, dynamic>{}; |
| | | map['icon'] = _icon; |
| | | map['name'] = _name; |
| | | return map; |
| | | } |
| | | } |
New file |
| | |
| | | import 'dart:io'; |
| | | import 'dart:ui'; |
| | | |
| | | import 'package:flutter/cupertino.dart'; |
| | | import 'package:flutter/material.dart'; |
| | | import 'package:makemoney/api/msg_api.dart'; |
| | | import 'package:makemoney/api/team_api.dart'; |
| | | import 'package:makemoney/model/msg/app_notify_msg_model.dart'; |
| | | import 'package:makemoney/model/msg/user_msg_model.dart'; |
| | | import 'package:makemoney/model/team/team_member_list_vo.dart'; |
| | | import 'package:makemoney/ui/mine/invite_friends.dart'; |
| | | import 'package:makemoney/ui/widget/base_ui.dart'; |
| | | import 'package:makemoney/ui/widget/button.dart'; |
| | | import 'package:makemoney/ui/widget/images_widget.dart'; |
| | | import 'package:makemoney/ui/widget/refresh_listview.dart'; |
| | | import '../../ui/common/browser.dart'; |
| | | import '../../utils/config_util.dart'; |
| | | import '../../utils/share_preference.dart'; |
| | | import '../../utils/string_util.dart'; |
| | | import '../../utils/ui_constant.dart'; |
| | | import '../../ui/widget/nav.dart'; |
| | | import '../../utils/pageutils.dart'; |
| | | |
| | | import 'advice_submit.dart'; |
| | | import 'package:launch_review/launch_review.dart'; |
| | | import 'package:package_info/package_info.dart'; |
| | | import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart'; |
| | | |
| | | class MsgPage extends StatefulWidget { |
| | | MsgPage({Key? key, required this.title}) : super(key: key); |
| | | |
| | | // This widget is the home page of your application. It is stateful, meaning |
| | | // that it has a State object (defined below) that contains fields that affect |
| | | // how it looks. |
| | | |
| | | // This class is the configuration for the state. It holds the values (in this |
| | | // case the title) provided by the parent (in this case the App widget) and |
| | | // used by the build method of the State. Fields in a Widget subclass are |
| | | // always marked "final". |
| | | |
| | | final String title; |
| | | |
| | | @override |
| | | _MsgPageState createState() => _MsgPageState(); |
| | | } |
| | | |
| | | class _MsgPageState extends State<MsgPage> with SingleTickerProviderStateMixin { |
| | | int _page = 1; |
| | | List<UserMsgModel>? _msgList; |
| | | final MyRefreshController _refreshController = |
| | | MyRefreshController(initialRefresh: false); |
| | | |
| | | @override |
| | | void initState() { |
| | | super.initState(); |
| | | _refresh(); |
| | | } |
| | | |
| | | BoxDecoration getItemDecoration(Color bgColor, Color shadowColor) { |
| | | return BoxDecoration( |
| | | borderRadius: const BorderRadius.all(Radius.elliptical(10, 10)), |
| | | color: bgColor, |
| | | boxShadow: [ |
| | | BoxShadow( |
| | | color: shadowColor, |
| | | blurRadius: 2.0, |
| | | offset: const Offset(0.0, 5.0), //阴影y轴偏移量 |
| | | spreadRadius: 1 //阴影扩散程度 |
| | | ) |
| | | ]); |
| | | } |
| | | |
| | | //下拉刷新 |
| | | void _refresh() { |
| | | if (_refreshController.dataNormal != null) { |
| | | _refreshController.dataNormal!(); |
| | | } |
| | | _refreshController.loadComplete(); |
| | | _getUserMsg(1); |
| | | } |
| | | |
| | | //上拉加载 |
| | | void _loadMore() { |
| | | _getUserMsg(_page + 1); |
| | | } |
| | | |
| | | //获取队员列表 |
| | | void _getUserMsg(int page) async { |
| | | setState(() { |
| | | _page = page; |
| | | }); |
| | | |
| | | Map<String, dynamic>? result = await MsgApiUtil.getUserMsg(context, _page); |
| | | |
| | | _refreshController.refreshCompleted(); |
| | | _refreshController.loadComplete(); |
| | | |
| | | if (result == null && |
| | | _page == 1 && |
| | | (_msgList == null || _msgList!.isEmpty)) { |
| | | _refreshController.apiError!(); |
| | | } |
| | | |
| | | if (result == null || result["code"] != 0) { |
| | | //页码回滚 |
| | | if (_page > 1) { |
| | | setState(() { |
| | | _page = _page - 1; |
| | | }); |
| | | } |
| | | return; |
| | | } |
| | | //解析数据 |
| | | int count = result["data"]["count"]; |
| | | List<dynamic> list = result["data"]["list"]; |
| | | List<UserMsgModel> tempList = []; |
| | | list.forEach((element) { |
| | | tempList.add(UserMsgModel.fromJson(element)); |
| | | }); |
| | | |
| | | if (_page == 1) { |
| | | setState(() { |
| | | _msgList = tempList; |
| | | }); |
| | | } else { |
| | | _msgList = _msgList ?? []; |
| | | setState(() { |
| | | _msgList!.addAll(tempList); |
| | | }); |
| | | } |
| | | |
| | | //判断数据 |
| | | |
| | | if (_msgList!.isEmpty) { |
| | | //空数据 |
| | | _refreshController.dataEmpty!(); |
| | | } else { |
| | | _refreshController.dataNormal!(); |
| | | if (count <= _msgList!.length) { |
| | | //没有数据了 |
| | | _refreshController.loadNoData(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @override |
| | | Widget build(BuildContext context) { |
| | | return Scaffold( |
| | | backgroundColor: const Color(0xFFFFFFFF), |
| | | body: Column( |
| | | children: [ |
| | | TopNavBar(title: "消息"), |
| | | Expanded( |
| | | child: Container( |
| | | alignment: Alignment.topCenter, |
| | | color: const Color(0xFFF0F0F0), |
| | | child: RefreshListView( |
| | | refreshController: _refreshController, |
| | | refresh: () { |
| | | _refresh(); |
| | | }, |
| | | loadMore: () { |
| | | _loadMore(); |
| | | }, |
| | | content: ListView.builder( |
| | | padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), |
| | | itemCount: _msgList == null ? 0 : _msgList!.length, |
| | | itemBuilder: (BuildContext context, int index) { |
| | | return getItemView(index); |
| | | }, |
| | | ), |
| | | ), |
| | | )) |
| | | ], |
| | | )); |
| | | } |
| | | |
| | | Widget getItemView(int index) { |
| | | return Container( |
| | | margin: const EdgeInsets.only(top: 11), |
| | | padding: const EdgeInsets.fromLTRB(15, 0, 10, 0), |
| | | decoration: BoxDecoration( |
| | | color: Colors.white, borderRadius: BorderRadius.circular(13)), |
| | | child: Column( |
| | | children: [ |
| | | SizedBox( |
| | | height: 50, |
| | | child: Row( |
| | | crossAxisAlignment: CrossAxisAlignment.center, |
| | | children: [ |
| | | ClipRRect( |
| | | borderRadius: BorderRadius.circular(20), |
| | | child: CommonImage( |
| | | _msgList![index].type!.icon!.isEmpty |
| | | ? "assets/imgs/ic_portrait_default.png" |
| | | : _msgList![index].type!.icon!, |
| | | width: 30, |
| | | height: 30)), |
| | | const SizedBox( |
| | | width: 10, |
| | | ), |
| | | Text( |
| | | _msgList![index].type!.name!, |
| | | style: TextStyle(fontSize: 18), |
| | | ), |
| | | Expanded( |
| | | child: Text( |
| | | _msgList![index].createTime!, |
| | | textAlign: TextAlign.end, |
| | | style: const TextStyle( |
| | | fontSize: 16, color: Color(0xFF999999)), |
| | | )) |
| | | ], |
| | | )), |
| | | const SizedBox( |
| | | height: 2, |
| | | ), |
| | | Column( |
| | | children: _msgList![index].contentList!.map((e) { |
| | | return Padding( |
| | | padding: const EdgeInsets.only(top: 5, bottom: 5), |
| | | child: Row( |
| | | crossAxisAlignment: CrossAxisAlignment.start, |
| | | children: [ |
| | | Expanded( |
| | | flex: 2, |
| | | child: Text(e.title!, |
| | | style: const TextStyle( |
| | | fontSize: 16, color: Color(0xFF999999)))), |
| | | Expanded( |
| | | flex: 5, |
| | | child: HtmlWidget(e.content!, |
| | | textStyle: const TextStyle(fontSize: 16))) |
| | | ], |
| | | )); |
| | | }).toList(), |
| | | ), |
| | | const SizedBox( |
| | | height: 10, |
| | | ) |
| | | ], |
| | | )); |
| | | } |
| | | } |
New file |
| | |
| | | ///微信授权帮助类 |
| | | import 'dart:convert'; |
| | | |
| | | import 'package:flutter/cupertino.dart'; |
| | | import 'package:fluwx_no_pay/fluwx_no_pay.dart' as fluwx; |
| | | import 'package:makemoney/api/http.dart'; |
| | | import 'package:makemoney/ui/widget/refresh_listview.dart'; |
| | | import 'package:makemoney/utils/user_util.dart'; |
| | | |
| | | import 'ui_utils.dart'; |
| | | |
| | | class WXAuthUtil { |
| | | static init(BuildContext context, StringCallback callback) { |
| | | fluwx |
| | | .registerWxApi( |
| | | appId: "wx420b62b9213e0fc9", |
| | | universalLink: "https://your.univerallink.com/link/") |
| | | .then((value) { |
| | | print("微信初始化完成:$value"); |
| | | fluwx.weChatResponseEventHandler.listen((res) { |
| | | dismissDialog(context); |
| | | print("微信回调:${res.errCode} - ${res.errStr}"); |
| | | if (res is fluwx.WeChatAuthResponse) { |
| | | fluwx.WeChatAuthResponse response = res; |
| | | print("微信获取到的code: ${response.code}"); |
| | | int errCode = response.errCode; |
| | | if (errCode == 0) { |
| | | String? code = response.code; |
| | | if (code == null) { |
| | | ToastUtil.toast("微信授权失败,请稍后再试", context); |
| | | return; |
| | | } |
| | | callback(code); |
| | | } else if (errCode == -4) { |
| | | //showToast("用户拒绝授权"); |
| | | } else if (errCode == -2) { |
| | | // showToast("用户取消授权"); |
| | | } else { |
| | | ToastUtil.toast("微信授权失败,请稍后再试", context); |
| | | return; |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | ///开始授权 |
| | | static startAuth(BuildContext context) async { |
| | | bool installed = await wxInstalled(); |
| | | if (!installed) { |
| | | ToastUtil.toast("尚未安装微信", context); |
| | | return; |
| | | } |
| | | |
| | | showLoading(context); |
| | | fluwx |
| | | .sendWeChatAuth(scope: "snsapi_userinfo", state: "wechat_sdk_demo_test") |
| | | .then((value) { |
| | | print("微信授权登录回调:$value"); |
| | | }); |
| | | } |
| | | |
| | | ///是否安装了微信 |
| | | static Future<bool> wxInstalled() async { |
| | | return await fluwx.isWeChatInstalled; |
| | | } |
| | | } |