From 87258756d370a1ccedf16ffd9ef91dc5e9925738 Mon Sep 17 00:00:00 2001 From: apple <18201497620@163.com> Date: Fri, 25 Jun 2021 15:48:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E4=BA=9Bview=E7=A9=BA=E6=8C=87?= =?UTF-8?q?=E9=92=88=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiktok/activity/FocusActivity.kt | 15 +--- .../tiktok/activity/ShowImageActivity.kt | 6 +- .../com/bytedance/tiktok/application/App.kt | 2 - .../application/MyExceptionHandler.java | 84 ------------------- .../main/res/layout/activity_show_image.xml | 2 +- 5 files changed, 6 insertions(+), 103 deletions(-) delete mode 100644 app/src/main/java/com/bytedance/tiktok/application/MyExceptionHandler.java diff --git a/app/src/main/java/com/bytedance/tiktok/activity/FocusActivity.kt b/app/src/main/java/com/bytedance/tiktok/activity/FocusActivity.kt index dd7447c..6b9de89 100644 --- a/app/src/main/java/com/bytedance/tiktok/activity/FocusActivity.kt +++ b/app/src/main/java/com/bytedance/tiktok/activity/FocusActivity.kt @@ -1,13 +1,11 @@ package com.bytedance.tiktok.activity import androidx.fragment.app.Fragment -import androidx.viewpager.widget.ViewPager -import butterknife.BindView -import com.androidkun.xtablayout.XTabLayout import com.bytedance.tiktok.R import com.bytedance.tiktok.base.BaseActivity import com.bytedance.tiktok.base.CommPagerAdapter import com.bytedance.tiktok.fragment.FansFragment +import kotlinx.android.synthetic.main.activity_focus.* import java.util.* /** @@ -16,11 +14,6 @@ import java.util.* * description 粉丝关注人页面 */ class FocusActivity : BaseActivity() { - @BindView(R.id.tablayout) - var tabLayout: XTabLayout? = null - - @BindView(R.id.viewpager) - var viewPager: ViewPager? = null private val fragments = ArrayList() private var pagerAdapter: CommPagerAdapter? = null @@ -33,10 +26,10 @@ class FocusActivity : BaseActivity() { override fun init() { for (i in titles.indices) { fragments.add(FansFragment()) - tabLayout!!.addTab(tabLayout!!.newTab().setText(titles[i])) + tablayout!!.addTab(tablayout!!.newTab().setText(titles[i])) } pagerAdapter = CommPagerAdapter(supportFragmentManager, fragments, titles) - viewPager!!.adapter = pagerAdapter - tabLayout!!.setupWithViewPager(viewPager) + viewpager!!.adapter = pagerAdapter + tablayout!!.setupWithViewPager(viewpager) } } \ No newline at end of file diff --git a/app/src/main/java/com/bytedance/tiktok/activity/ShowImageActivity.kt b/app/src/main/java/com/bytedance/tiktok/activity/ShowImageActivity.kt index 9ce2a47..40a4d27 100644 --- a/app/src/main/java/com/bytedance/tiktok/activity/ShowImageActivity.kt +++ b/app/src/main/java/com/bytedance/tiktok/activity/ShowImageActivity.kt @@ -1,15 +1,11 @@ package com.bytedance.tiktok.activity import android.view.View -import android.widget.ImageView -import butterknife.BindView import com.bytedance.tiktok.R import com.bytedance.tiktok.base.BaseActivity +import kotlinx.android.synthetic.main.activity_show_image.* class ShowImageActivity : BaseActivity() { - @JvmField - @BindView(R.id.iv_head) - var ivHead: ImageView? = null override fun setLayoutId(): Int { return R.layout.activity_show_image diff --git a/app/src/main/java/com/bytedance/tiktok/application/App.kt b/app/src/main/java/com/bytedance/tiktok/application/App.kt index 14491de..c45fe81 100644 --- a/app/src/main/java/com/bytedance/tiktok/application/App.kt +++ b/app/src/main/java/com/bytedance/tiktok/application/App.kt @@ -17,7 +17,5 @@ class App : Application() { DoraemonKit.install(this, "pId") BlockCanary.install(this, AppBlockCanaryContext()).start() - - Thread.setDefaultUncaughtExceptionHandler(MyExceptionHandler()) } } \ No newline at end of file diff --git a/app/src/main/java/com/bytedance/tiktok/application/MyExceptionHandler.java b/app/src/main/java/com/bytedance/tiktok/application/MyExceptionHandler.java deleted file mode 100644 index aa09142..0000000 --- a/app/src/main/java/com/bytedance/tiktok/application/MyExceptionHandler.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.bytedance.tiktok.application; - -import androidx.annotation.NonNull; - -import java.io.File; - -/** - * create by apple - * create on 2021/5/28 - * description - */ -class MyExceptionHandler implements Thread.UncaughtExceptionHandler { - - @Override - public void uncaughtException(@NonNull Thread t, @NonNull Throwable e) { - File file = dealException(thread, throwable); - //上传服务器 - - } - - /*** 导出异常信息到SD卡 ** @param e */ - private File dealException(Thread thread, Throwable throwable) { - String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); - File crashFolder = new File(mContext.getExternalCacheDir().getAbsoluteFile(), CrashMonitor.DEFAULT_JAVA_CRASH_FOLDER_NAME); - if (!crashFolder.exists()) { - crashFolder.mkdirs(); - } - File crashFile = new File(crashFolder, time + FILE_NAME_SUFFIX); - try { - // 往文件中写入数据 - PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(crashFile))); - pw.println(time); - pw.println(thread); - pw.println(getPhoneInfo()); - throwable.printStackTrace(pw); //将异常信息堆栈写入文件 - // 写入crash堆栈 - pw.close(); - } catch (IOException ex) { - ex.printStackTrace(); - } - return crashFile; - } - - private String getPhoneInfo() { - PackageManager pm = mContext.getPackageManager(); - PackageInfo pi = null; - StringBuilder sb = new StringBuilder(); - - try { - pi = pm.getPackageInfo(mContext.getPackageName(), PackageManager.GET_ACTIVITIES); - - // App版本 - sb.append("App Version: "); - sb.append(pi.versionName); - sb.append("_"); - sb.append(pi.versionCode + "\n"); - } catch (PackageManager.NameNotFoundException e) { - e.printStackTrace(); - } - - // Android版本号 - sb.append("OS Version: "); - sb.append(Build.VERSION.RELEASE); - sb.append("_"); - sb.append(Build.VERSION.SDK_INT + "\n"); - - // 手机制造商 - sb.append("Vendor: "); - sb.append(Build.MANUFACTURER + "\n"); - - // 手机型号 - sb.append("Model: "); - sb.append(Build.MODEL + "\n"); - - // CPU架构 - sb.append("CPU: "); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - sb.append(Arrays.toString(Build.SUPPORTED_ABIS)); - } else { - sb.append(Build.CPU_ABI); - } - return sb.toString(); - } -} diff --git a/app/src/main/res/layout/activity_show_image.xml b/app/src/main/res/layout/activity_show_image.xml index 6ae754f..b480210 100644 --- a/app/src/main/res/layout/activity_show_image.xml +++ b/app/src/main/res/layout/activity_show_image.xml @@ -8,7 +8,7 @@ android:background="@color/color_bg_theme">