Java Code Examples for com.blankj.utilcode.util.ActivityUtils#getTopActivity()

The following examples show how to use com.blankj.utilcode.util.ActivityUtils#getTopActivity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LargePictureManager.java    From DoraemonKit with Apache License 2.0 6 votes vote down vote up
/**
 * 保存在内部里的图片信息
 *
 * @param url
 * @param memorySize
 * @param width
 * @param height
 */
public void saveImageInfo(String url, double memorySize, int width, int height, String framework) {
    if (ActivityUtils.getTopActivity() instanceof UniversalActivity) {
        return;
    }
    LargeImageInfo largeImageInfo;
    if (LARGE_IMAGE_INFO_MAP.containsKey(url)) {
        largeImageInfo = LARGE_IMAGE_INFO_MAP.get(url);
    } else {
        largeImageInfo = new LargeImageInfo();
        LARGE_IMAGE_INFO_MAP.put(url, largeImageInfo);
        largeImageInfo.setUrl(url);
    }
    largeImageInfo.setMemorySize(memorySize);
    largeImageInfo.setWidth(width);
    largeImageInfo.setHeight(height);
    largeImageInfo.setFramework(framework);
}
 
Example 2
Source File: ActivityCounter.java    From DoraemonKit with Apache License 2.0 6 votes vote down vote up
public void render() {
    mRenderStartTime = System.currentTimeMillis();
    final Activity activity = ActivityUtils.getTopActivity();
    if (activity != null && activity.getWindow() != null) {
        mCurrentActivity = activity.getClass().getSimpleName();
        activity.getWindow().getDecorView().post(new Runnable() {
            @Override
            public void run() {
                activity.getWindow().getDecorView().post(new Runnable() {
                    @Override
                    public void run() {
                        renderEnd();
                    }
                });
            }
        });
    } else {
        renderEnd();
    }
}
 
Example 3
Source File: LargePictureManager.java    From DoraemonKit with Apache License 2.0 5 votes vote down vote up
/**
 * @param url
 * @param size
 */
public void process(String url, int size) {
    if (ActivityUtils.getTopActivity() instanceof UniversalActivity) {
        return;
    }
    if (PerformanceSpInfoConfig.isLargeImgOpen()) {
        //转化成kb
        double fileSize = (double) (size / 1024.0);
        saveImageInfo(url, fileSize);
    }

}
 
Example 4
Source File: LargePictureManager.java    From DoraemonKit with Apache License 2.0 5 votes vote down vote up
/**
 * 保存网络图片信息
 *
 * @param url
 * @param fileSize
 */
private void saveImageInfo(String url, double fileSize) {
    if (ActivityUtils.getTopActivity() instanceof UniversalActivity) {
        return;
    }
    LargeImageInfo largeImageInfo;
    if (LARGE_IMAGE_INFO_MAP.containsKey(url)) {
        largeImageInfo = LARGE_IMAGE_INFO_MAP.get(url);
    } else {
        largeImageInfo = new LargeImageInfo();
        LARGE_IMAGE_INFO_MAP.put(url, largeImageInfo);
        largeImageInfo.setUrl(url);
    }
    largeImageInfo.setFileSize(fileSize);
}
 
Example 5
Source File: ActivityCounter.java    From DoraemonKit with Apache License 2.0 5 votes vote down vote up
public void pause() {
    mStartTime = System.currentTimeMillis();
    mPauseCostTime = 0;
    mRenderCostTime = 0;
    mOtherCostTime = 0;
    mLaunchCostTime = 0;
    mLaunchStartTime = 0;
    mTotalCostTime = 0;
    mPreviousActivity = null;
    Activity activity = ActivityUtils.getTopActivity();
    if (activity != null) {
        mPreviousActivity = activity.getClass().getSimpleName();
    }
}
 
Example 6
Source File: ViewCheckInfoDokitView.java    From DoraemonKit with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewSelected(@Nullable View current, @NonNull List<View> checkViewList) {

    mNext.setVisibility(checkViewList.size() > 1 ? View.VISIBLE : View.GONE);
    mPre.setVisibility(checkViewList.size() > 1 ? View.VISIBLE : View.GONE);

    if (current == null) {
        mName.setText("");
        mId.setText("");
        mPosition.setText("");
        mDesc.setText("");
    } else {
        mName.setText(getResources().getString(R.string.dk_view_check_info_class, current.getClass().getSimpleName()));
        String idText = getResources().getString(R.string.dk_view_check_info_id, UIUtils.getIdText(current));
        mId.setText(idText);
        String positionText = getResources().getString(R.string.dk_view_check_info_size, current.getWidth(), current.getHeight());
        mPosition.setText(positionText);
        String descText = getViewExtraInfo(current);
        if (TextUtils.isEmpty(descText)) {
            mDesc.setVisibility(View.GONE);
        } else {
            mDesc.setText(descText);
            mDesc.setVisibility(View.VISIBLE);
        }
        Activity activity = ActivityUtils.getTopActivity();
        if (activity != null) {
            String activityText = activity.getClass().getSimpleName();
            setTextAndVisible(mActivityInfo, getResources().getString(R.string.dk_view_check_info_activity, activityText));
            String fragmentText = getVisibleFragment(activity);
            if (!TextUtils.isEmpty(fragmentText)) {
                setTextAndVisible(mFragmentInfo, getResources().getString(R.string.dk_view_check_info_fragment, fragmentText));
            } else {
                setTextAndVisible(mFragmentInfo, "");
            }
        } else {
            setTextAndVisible(mActivityInfo, "");
            setTextAndVisible(mFragmentInfo, "");
        }
    }
}
 
Example 7
Source File: ViewCheckDokitView.java    From DoraemonKit with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Context context) {
    mTraverHandlerThread = new HandlerThread(TAG);
    mTraverHandlerThread.start();
    mTraverHandler = new Handler(mTraverHandlerThread.getLooper());
    mFindCheckViewRunnable = new FindCheckViewRunnable();
    mResumedActivity = ActivityUtils.getTopActivity();
    LifecycleListenerUtil.registerListener(this);
}
 
Example 8
Source File: QPMGetTopActivityExecutor.java    From QPM with Apache License 2.0 5 votes vote down vote up
@Override
public void exec() throws QPMException {
    Activity topActivity = ActivityUtils.getTopActivity();
    if (topActivity != null) {
        analysys.onCollectTopActivityInfo(topActivity.getLocalClassName());
    }
}
 
Example 9
Source File: BaseFloatView.java    From AndroidUtilCode with Apache License 2.0 5 votes vote down vote up
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    Activity topActivity = ActivityUtils.getTopActivity();
    if (topActivity != null) {
        if (topActivity.getWindow().getDecorView().dispatchKeyEvent(event)) {
            return true;
        }
    }
    return super.dispatchKeyEvent(event);
}
 
Example 10
Source File: CountDownDokitView.java    From DoraemonKit with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Context context) {
    activity = ActivityUtils.getTopActivity();
}
 
Example 11
Source File: AbsDokitView.java    From DoraemonKit with Apache License 2.0 4 votes vote down vote up
public Activity getActivity() {
    if (mAttachActivity != null) {
        return mAttachActivity.get();
    }
    return ActivityUtils.getTopActivity();
}
 
Example 12
Source File: DokitIntent.java    From DoraemonKit with Apache License 2.0 4 votes vote down vote up
public DokitIntent(Class<? extends AbsDokitView> targetClass) {
    this.activity = ActivityUtils.getTopActivity();
    this.targetClass = targetClass;
    tag = targetClass.getSimpleName();
}