Commit c0611b2a by gao.chao

WEB,起屏页

parent 853e66ed
......@@ -23,7 +23,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppThemeNoActionBar">
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......@@ -31,6 +31,9 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".StartActivity"
android:theme="@style/AppThemeLaunch" />
<activity android:name=".FunctionActivity" />
<activity android:name=".OnMultiClickActivity" />
<activity android:name=".PermissionActivity" />
......
......@@ -52,5 +52,11 @@ public class PageActivity extends BaseActivity {
gotoActivity(FragmentInteractiveActivity2.class);
}
});
findViewById(R.id.b6).setOnClickListener(new OnMultiClickListener() {
@Override
public void onMultiClick(View v) {
gotoActivity(StartActivity.class);
}
});
}
}
package com.mayi.demo;
import com.mayi.fastdevelop.commonpage.BaseStartActivity;
public class StartActivity extends BaseStartActivity<ViewActviity,ViewActviity,ViewActviity>{
@Override
public Class<ViewActviity> getGuideActivity() {
return ViewActviity.class;
}
@Override
public Class<ViewActviity> getLoginActivity() {
return ViewActviity.class;
}
@Override
public Class<ViewActviity> getMainActivity() {
return ViewActviity.class;
}
}
......@@ -38,6 +38,12 @@
android:layout_height="wrap_content"
android:text="Activity与Fragment之间交互\n不可以左右滑动" />
<Button
android:id="@+id/b6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="起屏页" />
</LinearLayout>
......
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<!--<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">-->
<!--&lt;!&ndash; Customize your theme here. &ndash;&gt;-->
<!--<item name="colorPrimary">@color/colorPrimary</item>-->
<!--<item name="colorPrimaryDark">@color/colorPrimaryDark</item>-->
<!--<item name="colorAccent">@color/colorAccent</item>-->
<!--</style>-->
</resources>
package com.mayi.fastdevelop.bean;
import java.io.Serializable;
/**
* 首页表格item
*/
public class HomeItem implements Serializable {
private String name; //item名字
private String img; //item图片
private String goPage; //点击跳转页面
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getImg() {
return img;
}
public void setImg(String img) {
this.img = img;
}
public String getGoPage() {
return goPage;
}
public void setGoPage(String goPage) {
this.goPage = goPage;
}
}
package com.mayi.fastdevelop.bean;
import java.io.Serializable;
/**
* 用户信息
*/
public class UserInfo implements Serializable{
private String userId; //用户ID
private String token; //会话token
private String phone; //手机号
private String upDtatUrl; //APP更新地址
private String headAddress; //头像地址
private String address; //详细地址
private String provinceCode; //省ID
private String provinceName; //省名称
private String cityCode; //市ID
private String cityName; //市名称
private String areaCode; //区ID
private String areaName; //区名称
private String email; // 邮箱
private String nickName; // 昵称
private String age; // 年龄
private String gender; // 性别 male(男)/female(女)
private String status; // 帐号状态
private String qcord; // 二维码字段
private String qcordImg; // 二维码图片
private String other1; //备用字段1
private String other2; //备用字段2
private String other3; //备用字段3
private String other4; //备用字段4
private String other5; //备用字段5
private String other6; //备用字段6
private String other7; //备用字段7
private String other8; //备用字段8
private String other9; //备用字段9
private String other10; //备用字段10
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getUpDtatUrl() {
return upDtatUrl;
}
public void setUpDtatUrl(String upDtatUrl) {
this.upDtatUrl = upDtatUrl;
}
public String getHeadAddress() {
return headAddress;
}
public void setHeadAddress(String headAddress) {
this.headAddress = headAddress;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getProvinceCode() {
return provinceCode;
}
public void setProvinceCode(String provinceCode) {
this.provinceCode = provinceCode;
}
public String getProvinceName() {
return provinceName;
}
public void setProvinceName(String provinceName) {
this.provinceName = provinceName;
}
public String getCityCode() {
return cityCode;
}
public void setCityCode(String cityCode) {
this.cityCode = cityCode;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
public String getAreaCode() {
return areaCode;
}
public void setAreaCode(String areaCode) {
this.areaCode = areaCode;
}
public String getAreaName() {
return areaName;
}
public void setAreaName(String areaName) {
this.areaName = areaName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getQcord() {
return qcord;
}
public void setQcord(String qcord) {
this.qcord = qcord;
}
public String getQcordImg() {
return qcordImg;
}
public void setQcordImg(String qcordImg) {
this.qcordImg = qcordImg;
}
public String getOther1() {
return other1;
}
public void setOther1(String other1) {
this.other1 = other1;
}
public String getOther2() {
return other2;
}
public void setOther2(String other2) {
this.other2 = other2;
}
public String getOther3() {
return other3;
}
public void setOther3(String other3) {
this.other3 = other3;
}
public String getOther4() {
return other4;
}
public void setOther4(String other4) {
this.other4 = other4;
}
public String getOther5() {
return other5;
}
public void setOther5(String other5) {
this.other5 = other5;
}
public String getOther6() {
return other6;
}
public void setOther6(String other6) {
this.other6 = other6;
}
public String getOther7() {
return other7;
}
public void setOther7(String other7) {
this.other7 = other7;
}
public String getOther8() {
return other8;
}
public void setOther8(String other8) {
this.other8 = other8;
}
public String getOther9() {
return other9;
}
public void setOther9(String other9) {
this.other9 = other9;
}
public String getOther10() {
return other10;
}
public void setOther10(String other10) {
this.other10 = other10;
}
}
package com.mayi.fastdevelop.commonpage;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.comnon.Key;
import com.mayi.fastdevelop.comnon.UserManager;
import com.mayi.fastdevelop.util.SpUtil;
import com.tencent.smtt.sdk.WebSettings;
import com.tencent.smtt.sdk.WebView;
/**
* APP启动闪屏页
*/
public abstract class BaseStartActivity<T extends BaseActivity, T1 extends BaseActivity, T2 extends BaseActivity> extends BaseActivity {
private Handler mHandler;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//清除浏览器缓存
WebView webView = new WebView(this);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.clearCache(true);
webView.clearHistory();
webView.clearFormData();
getCacheDir().delete();
mHandler = new Handler();
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
gotoNext();
}
}, 1000);
}
private void gotoNext() {
if (SpUtil.get(Key.FIRST_LOGIN, true)) { // 首次登录 -- 》广告页
SpUtil.set(Key.FIRST_LOGIN, false);
gotoActivityAndFinish(getGuideActivity());
} else {// 非首次 --> 判断有没有缓存用户信息
if (TextUtils.isEmpty(SpUtil.get(Key.USER_INFO, ""))) {
// 没有本地缓存 直接登录
gotoActivityAndFinish(getLoginActivity());
} else {
// 有本地缓存 免登录 直接到首页
UserManager.getUserInfo();
gotoActivityAndFinish(getMainActivity());
}
}
}
@Override
protected void onDestroy() {
mHandler.removeCallbacksAndMessages(null);
super.onDestroy();
}
public abstract Class<T> getGuideActivity();//获取广告页Activity
public abstract Class<T1> getLoginActivity();//获取登录页Activity
public abstract Class<T2> getMainActivity();//获取首页Activity
}
package com.mayi.fastdevelop.commonpage;
import android.Manifest;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
......@@ -24,9 +23,11 @@ import android.webkit.JavascriptInterface;
import com.mayi.fastdevelop.R;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.comnon.Key;
import com.mayi.fastdevelop.comnon.RequestCode;
import com.mayi.fastdevelop.util.BitmapUtil;
import com.mayi.fastdevelop.util.DialogUtils;
import com.mayi.fastdevelop.util.SpUtil;
import com.mayi.fastdevelop.view.CustomTitleBar;
import com.mayi.fastdevelop.view.dialog.BaseDialog;
import com.tencent.smtt.export.external.interfaces.GeolocationPermissionsCallback;
......@@ -214,8 +215,8 @@ public class WebActivity extends BaseActivity {
}
//app调用web方法
public void appCallJs(String method, String data) {
webView.loadUrl("javascript:appCallJs.invoking;(" + method + ","+data+")");
public void appCallJs(String method, String data) {
webView.loadUrl("javascript:appCallJs.invoking;(" + method + "," + data + ")");
}
......@@ -246,6 +247,8 @@ public class WebActivity extends BaseActivity {
Uri content_url = Uri.parse(data);
intent.setData(content_url);
startActivity(intent);
} else if (TextUtils.equals("getUserInfo", method)) {//给web传递用户信息
appCallJs("setUserInfo", SpUtil.get(Key.USER_INFO, ""));
}
}
});
......@@ -255,10 +258,10 @@ public class WebActivity extends BaseActivity {
* 跳转原生页面
* 待扩展
*
* @param s
* @param pageName
* @param parameter
*/
public void goPage(String s, String parameter) {
public void goPage(String pageName, String parameter) {
}
......@@ -342,7 +345,7 @@ public class WebActivity extends BaseActivity {
protected Object doInBackground(Object[] objects) {
if (!TextUtils.isEmpty(mCurrentPhotoPath)) {
BitmapUtil.zoomsInImageFile(mCurrentPhotoPath, mCurrentPhotoPath,
Bitmap.CompressFormat.JPEG, 900, 100);
Bitmap.CompressFormat.JPEG, 900, 80);
}
return null;
}
......
......@@ -2,4 +2,8 @@ package com.mayi.fastdevelop.comnon;
public class Key {
public static final String ANT_DOWNLOAD_ID = "ant_download_id";
/* 用户信息 */
public static final String USER_INFO = "userinfo";
/*是否首次登录*/
public static final String FIRST_LOGIN = "first_login";
}
package com.mayi.fastdevelop.comnon;
import android.text.TextUtils;
import com.alibaba.fastjson.JSON;
import com.mayi.fastdevelop.bean.UserInfo;
import com.mayi.fastdevelop.util.SpUtil;
public class UserManager {
private static UserInfo userInfo;
/**
* 获取本地的用户信息
*
* @return 用户信息
*/
public static UserInfo getUserInfo() {
if (userInfo == null) {
synchronized (UserManager.class) {
if (userInfo == null) {
String s = SpUtil.get(Key.USER_INFO, "");
if (!TextUtils.isEmpty(s)) {
userInfo = JSON.parseObject(s, UserInfo.class);
}
}
}
}
return userInfo;
}
/**
* 设置用户信息
*
* @param json
*/
public static void setUserInfo(String json) {
if (!TextUtils.isEmpty(json)) {
synchronized (UserManager.class) {
SpUtil.set(Key.USER_INFO, json);
userInfo = JSON.parseObject(json, UserInfo.class);
}
}
}
/**
* 清除用户信息
*/
public static void clearUserInfo() {
synchronized (UserManager.class) {
SpUtil.set(Key.USER_INFO, null);
userInfo = null;
}
}
}
<resources>
<style name="AppThemeLaunch" parent="AppTheme">
<item name="android:windowBackground">@mipmap/bg_launch</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<!--去除滑动时 顶部和底部的阴影-->
<item name="android:overScrollMode">never</item>
</style>
<!-- 自定义loading dialog -->
<style name="style_common_loading_dialog" parent="android:style/Theme.Dialog">
<item name="android:backgroundDimEnabled">true</item><!--模糊-->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment