com.hippo.yorozuya.AssertUtils Java Examples
The following examples show how to use
com.hippo.yorozuya.AssertUtils.
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: FabLayout.java From MHViewer with Apache License 2.0 | 6 votes |
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { AssertUtils.assertEquals("Measure mode must be MeasureSpec.EXACTLY", MeasureSpec.getMode(widthMeasureSpec), MeasureSpec.EXACTLY); AssertUtils.assertEquals("Measure mode must be MeasureSpec.EXACTLY", MeasureSpec.getMode(heightMeasureSpec), MeasureSpec.EXACTLY); int width = MeasureSpec.getSize(widthMeasureSpec); int height = MeasureSpec.getSize(heightMeasureSpec); int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec( width - getPaddingLeft() - getPaddingRight(), MeasureSpec.AT_MOST); int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec( height - getPaddingTop() - getPaddingBottom(), MeasureSpec.AT_MOST); measureChildren(childWidthMeasureSpec, childHeightMeasureSpec); setMeasuredDimension(width, height); }
Example #2
Source File: SignInScene.java From MHViewer with Apache License 2.0 | 6 votes |
@Nullable @Override public View onCreateView2(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.scene_login, container, false); View loginForm = ViewUtils.$$(view, R.id.login_form); mProgress = ViewUtils.$$(view, R.id.progress); mUsernameLayout = (TextInputLayout) ViewUtils.$$(loginForm, R.id.username_layout); mUsername = mUsernameLayout.getEditText(); AssertUtils.assertNotNull(mUsername); mPasswordLayout = (TextInputLayout) ViewUtils.$$(loginForm, R.id.password_layout); mPassword = mPasswordLayout.getEditText(); AssertUtils.assertNotNull(mPassword); mSignIn = ViewUtils.$$(loginForm, R.id.sign_in); mSkipSigningIn = (TextView) ViewUtils.$$(loginForm, R.id.skip_signing_in); mSkipSigningIn.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG); mPassword.setOnEditorActionListener(this); mSignIn.setOnClickListener(this); mSkipSigningIn.setOnClickListener(this); return view; }
Example #3
Source File: FabLayout.java From EhViewer with Apache License 2.0 | 6 votes |
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { AssertUtils.assertEquals("Measure mode must be MeasureSpec.EXACTLY", MeasureSpec.getMode(widthMeasureSpec), MeasureSpec.EXACTLY); AssertUtils.assertEquals("Measure mode must be MeasureSpec.EXACTLY", MeasureSpec.getMode(heightMeasureSpec), MeasureSpec.EXACTLY); int width = MeasureSpec.getSize(widthMeasureSpec); int height = MeasureSpec.getSize(heightMeasureSpec); int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec( width - getPaddingLeft() - getPaddingRight(), MeasureSpec.AT_MOST); int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec( height - getPaddingTop() - getPaddingBottom(), MeasureSpec.AT_MOST); measureChildren(childWidthMeasureSpec, childHeightMeasureSpec); setMeasuredDimension(width, height); }
Example #4
Source File: GalleryInfoScene.java From EhViewer with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") @Nullable @Override public View onCreateView3(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.scene_gallery_info, container, false); Context context = getContext2(); AssertUtils.assertNotNull(context); mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view); InfoAdapter adapter = new InfoAdapter(); mRecyclerView.setAdapter(adapter); mRecyclerView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false)); LinearDividerItemDecoration decoration = new LinearDividerItemDecoration( LinearDividerItemDecoration.VERTICAL, AttrResources.getAttrColor(context, R.attr.dividerColor), LayoutUtils.dp2pix(context, 1)); decoration.setPadding(context.getResources().getDimensionPixelOffset(R.dimen.keyline_margin)); mRecyclerView.addItemDecoration(decoration); mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT))); mRecyclerView.setClipToPadding(false); mRecyclerView.setHasFixedSize(true); mRecyclerView.setOnItemClickListener(this); return view; }
Example #5
Source File: GalleryListScene.java From MHViewer with Apache License 2.0 | 6 votes |
@Override public View onCreateDrawerView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { Context context = getContext2(); AssertUtils.assertNotNull(context); View view = inflater.inflate(R.layout.drawer_list, container, false); Toolbar toolbar = (Toolbar) ViewUtils.$$(view, R.id.toolbar); this.timeView = (RadioGridGroup) ViewUtils.$$(view, R.id.draw_top_time); this.categoryView = (RadioGridGroup) ViewUtils.$$(view, R.id.draw_top_category); updateTopCategory(); toolbar.setTitle(R.string.category_tip); return view; }
Example #6
Source File: FavoritesScene.java From MHViewer with Apache License 2.0 | 6 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Context context = getContext2(); AssertUtils.assertNotNull(context); mClient = EhApplication.getEhClient(context); mFavCatArray = Settings.getFavCat(); mFavCountArray = Settings.getFavCount(); mFavLocalCount = Settings.getFavLocalCount(); mFavCountSum = Settings.getFavCloudCount(); if (savedInstanceState == null) { onInit(); } else { onRestore(savedInstanceState); } }
Example #7
Source File: DB.java From Nimingban with Apache License 2.0 | 6 votes |
private static void insertDefaultACCommonPosts() { ACCommonPostDao dao = sDaoSession.getACCommonPostDao(); dao.deleteAll(); int size = 13; String[] names = { "人,是会思考的芦苇", "丧尸图鉴", "壁纸楼", "足控福利", "淡定红茶", "胸器福利", "黑妹", "总有一天", "这是芦苇", "赵日天", "二次元女友", "什么鬼", "Banner画廊"}; String[] ids = { "6064422", "585784", "117617", "103123", "114373", "234446", "55255", "328934", "49607", "1738904", "553505", "5739391", "6538597"}; AssertUtils.assertEquals("ids.size must be size", size, ids.length); AssertUtils.assertEquals("names.size must be size", size, names.length); for (int i = 0; i < size; i++) { ACCommonPostRaw raw = new ACCommonPostRaw(); raw.setName(names[i]); raw.setPostid(ids[i]); dao.insert(raw); } }
Example #8
Source File: SecurityScene.java From MHViewer with Apache License 2.0 | 6 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Context context = getContext2(); AssertUtils.assertNotNull(context); mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); if (null != mSensorManager) { mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); if (null != mAccelerometer) { mShakeDetector = new ShakeDetector(); mShakeDetector.setOnShakeListener(this); } } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { mFingerprintManager = context.getSystemService(FingerprintManager.class); } if (null == savedInstanceState) { mRetryTimes = MAX_RETRY_TIMES; } else { mRetryTimes = savedInstanceState.getInt(KEY_RETRY_TIMES); } }
Example #9
Source File: SecurityScene.java From EhViewer with Apache License 2.0 | 6 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Context context = getContext2(); AssertUtils.assertNotNull(context); mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); if (null != mSensorManager) { mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); if (null != mAccelerometer) { mShakeDetector = new ShakeDetector(); mShakeDetector.setOnShakeListener(this); } } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { mFingerprintManager = context.getSystemService(FingerprintManager.class); } if (null == savedInstanceState) { mRetryTimes = MAX_RETRY_TIMES; } else { mRetryTimes = savedInstanceState.getInt(KEY_RETRY_TIMES); } }
Example #10
Source File: GalleryInfoScene.java From MHViewer with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") @Nullable @Override public View onCreateView3(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.scene_gallery_info, container, false); Context context = getContext2(); AssertUtils.assertNotNull(context); mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view); InfoAdapter adapter = new InfoAdapter(); mRecyclerView.setAdapter(adapter); mRecyclerView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false)); LinearDividerItemDecoration decoration = new LinearDividerItemDecoration( LinearDividerItemDecoration.VERTICAL, AttrResources.getAttrColor(context, R.attr.dividerColor), LayoutUtils.dp2pix(context, 1)); decoration.setPadding(context.getResources().getDimensionPixelOffset(R.dimen.keyline_margin)); mRecyclerView.addItemDecoration(decoration); mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT))); mRecyclerView.setClipToPadding(false); mRecyclerView.setHasFixedSize(true); mRecyclerView.setOnItemClickListener(this); return view; }
Example #11
Source File: FavoritesScene.java From EhViewer with Apache License 2.0 | 6 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Context context = getContext2(); AssertUtils.assertNotNull(context); mClient = EhApplication.getEhClient(context); mFavCatArray = Settings.getFavCat(); mFavCountArray = Settings.getFavCount(); mFavLocalCount = Settings.getFavLocalCount(); mFavCountSum = Settings.getFavCloudCount(); if (savedInstanceState == null) { onInit(); } else { onRestore(savedInstanceState); } }
Example #12
Source File: Settings.java From EhViewer with Apache License 2.0 | 5 votes |
public static void putFavCat(String[] value) { AssertUtils.assertEquals(10, value.length); sSettingsPre.edit() .putString(KEY_FAV_CAT_0, value[0]) .putString(KEY_FAV_CAT_1, value[1]) .putString(KEY_FAV_CAT_2, value[2]) .putString(KEY_FAV_CAT_3, value[3]) .putString(KEY_FAV_CAT_4, value[4]) .putString(KEY_FAV_CAT_5, value[5]) .putString(KEY_FAV_CAT_6, value[6]) .putString(KEY_FAV_CAT_7, value[7]) .putString(KEY_FAV_CAT_8, value[8]) .putString(KEY_FAV_CAT_9, value[9]) .apply(); }
Example #13
Source File: GalleryPreviewsScene.java From EhViewer with Apache License 2.0 | 5 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Context context = getContext2(); AssertUtils.assertNotNull(context); mClient = EhApplication.getEhClient(context); if (savedInstanceState == null) { onInit(); } else { onRestore(savedInstanceState); } }
Example #14
Source File: EhEngine.java From MHViewer with Apache License 2.0 | 5 votes |
public static Void addFavoritesRange(@Nullable EhClient.Task task, OkHttpClient okHttpClient, long[] gidArray, String[] tokenArray, int dstCat) throws Throwable { AssertUtils.assertEquals(gidArray.length, tokenArray.length); for (int i = 0, n = gidArray.length; i < n; i++) { addFavorites(task, okHttpClient, gidArray[i], tokenArray[i], dstCat, null); } return null; }
Example #15
Source File: MaxSizeContainer.java From EhViewer with Apache License 2.0 | 5 votes |
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { AssertUtils.assertEquals("getChildCount() must be 1", 1, getChildCount()); View child = getChildAt(0); if (child.getVisibility() != GONE) { child.measure(getMeasureSpec(widthMeasureSpec, mMaxWidth), getMeasureSpec(heightMeasureSpec, mMaxHeight)); setMeasuredDimension(child.getMeasuredWidth(), child.getMeasuredHeight()); } else { setMeasuredDimension(0, 0); } }
Example #16
Source File: Settings.java From EhViewer with Apache License 2.0 | 5 votes |
public static void putFavCount(int[] count) { AssertUtils.assertEquals(10, count.length); sSettingsPre.edit() .putInt(KEY_FAV_COUNT_0, count[0]) .putInt(KEY_FAV_COUNT_1, count[1]) .putInt(KEY_FAV_COUNT_2, count[2]) .putInt(KEY_FAV_COUNT_3, count[3]) .putInt(KEY_FAV_COUNT_4, count[4]) .putInt(KEY_FAV_COUNT_5, count[5]) .putInt(KEY_FAV_COUNT_6, count[6]) .putInt(KEY_FAV_COUNT_7, count[7]) .putInt(KEY_FAV_COUNT_8, count[8]) .putInt(KEY_FAV_COUNT_9, count[9]) .apply(); }
Example #17
Source File: DownloadLabelsScene.java From EhViewer with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") @Nullable @Override public View onCreateView3(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.scene_label_list, container, false); mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view); TextView tip = (TextView) ViewUtils.$$(view, R.id.tip); mViewTransition = new ViewTransition(mRecyclerView, tip); Context context = getContext2(); AssertUtils.assertNotNull(context); Drawable drawable = DrawableManager.getVectorDrawable(context, R.drawable.big_label); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); tip.setCompoundDrawables(null, drawable, null, null); tip.setText(R.string.no_download_label); // drag & drop manager RecyclerViewDragDropManager dragDropManager = new RecyclerViewDragDropManager(); dragDropManager.setDraggingItemShadowDrawable( (NinePatchDrawable) context.getResources().getDrawable(R.drawable.shadow_8dp)); RecyclerView.Adapter adapter = new LabelAdapter(); adapter.setHasStableIds(true); adapter = dragDropManager.createWrappedAdapter(adapter); // wrap for dragging mAdapter = adapter; final GeneralItemAnimator animator = new SwipeDismissItemAnimator(); mRecyclerView.setLayoutManager(new LinearLayoutManager(context)); mRecyclerView.setAdapter(adapter); mRecyclerView.setItemAnimator(animator); dragDropManager.attachRecyclerView(mRecyclerView); updateView(); return view; }
Example #18
Source File: GalleryPreviewsScene.java From EhViewer with Apache License 2.0 | 5 votes |
@Nullable @Override public View onCreateView3(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { ContentLayout contentLayout = (ContentLayout) inflater.inflate( R.layout.scene_gallery_previews, container, false); contentLayout.hideFastScroll(); mRecyclerView = contentLayout.getRecyclerView(); Context context = getContext2(); AssertUtils.assertNotNull(context); Resources resources = context.getResources(); mAdapter = new GalleryPreviewAdapter(); mRecyclerView.setAdapter(mAdapter); int columnWidth = resources.getDimensionPixelOffset(Settings.getThumbSizeResId()); AutoGridLayoutManager layoutManager = new AutoGridLayoutManager(context, columnWidth); layoutManager.setStrategy(AutoGridLayoutManager.STRATEGY_SUITABLE_SIZE); mRecyclerView.setLayoutManager(layoutManager); mRecyclerView.setClipToPadding(false); mRecyclerView.setOnItemClickListener(this); int padding = LayoutUtils.dp2pix(context, 4); MarginItemDecoration decoration = new MarginItemDecoration(padding, padding, padding, padding, padding); mRecyclerView.addItemDecoration(decoration); decoration.applyPaddings(mRecyclerView); mHelper = new GalleryPreviewHelper(); contentLayout.setHelper(mHelper); // Only refresh for the first time if (!mHasFirstRefresh) { mHasFirstRefresh = true; mHelper.firstRefresh(); } return contentLayout; }
Example #19
Source File: DownloadsScene.java From EhViewer with Apache License 2.0 | 5 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Context context = getContext2(); AssertUtils.assertNotNull(context); mDownloadManager = EhApplication.getDownloadManager(context); mDownloadManager.addDownloadInfoListener(this); if (savedInstanceState == null) { onInit(); } else { onRestore(savedInstanceState); } }
Example #20
Source File: MaxSizeContainer.java From EhViewer with Apache License 2.0 | 5 votes |
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { AssertUtils.assertEquals("getChildCount() must be 1", 1, getChildCount()); View child = getChildAt(0); if (child.getVisibility() != GONE) { child.layout(0, 0, r - l, b - t); } }
Example #21
Source File: ProgressScene.java From EhViewer with Apache License 2.0 | 5 votes |
@Nullable @Override public View onCreateView2(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.scene_progress, container, false); View progress = ViewUtils.$$(view, R.id.progress); mTip = (TextView) ViewUtils.$$(view, R.id.tip); Context context = getContext2(); AssertUtils.assertNotNull(context); Drawable drawable = DrawableManager.getVectorDrawable(context, R.drawable.big_sad_pandroid); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); mTip.setCompoundDrawables(null, drawable, null, null); mTip.setOnClickListener(this); mTip.setText(mError); mViewTransition = new ViewTransition(progress, mTip); if (mValid) { mViewTransition.showView(0, false); } else { mViewTransition.showView(1, false); } return view; }
Example #22
Source File: GalleryDetailScene.java From EhViewer with Apache License 2.0 | 5 votes |
private void ensurePopMenu() { if (mPopupMenu != null) { return; } Context context = getContext2(); AssertUtils.assertNotNull(context); PopupMenu popup = new PopupMenu(context, mOtherActions, Gravity.TOP); mPopupMenu = popup; popup.getMenuInflater().inflate(R.menu.scene_gallery_detail, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_open_in_other_app: String url = getGalleryDetailUrl(false); Activity activity = getActivity2(); if (null != url && null != activity) { UrlOpener.openUrl(activity, url, false); } break; case R.id.action_refresh: if (mState != STATE_REFRESH && mState != STATE_REFRESH_HEADER) { adjustViewVisibility(STATE_REFRESH, true); request(); } break; } return true; } }); }
Example #23
Source File: GalleryDetailScene.java From EhViewer with Apache License 2.0 | 5 votes |
private void bindViewSecond() { GalleryDetail gd = mGalleryDetail; if (gd == null) { return; } if (mThumb == null || mTitle == null || mUploader == null || mCategory == null || mLanguage == null || mPages == null || mSize == null || mPosted == null || mFavoredTimes == null || mRatingText == null || mRating == null || mTorrent == null) { return; } Resources resources = getResources2(); AssertUtils.assertNotNull(resources); mThumb.load(EhCacheKeyFactory.getThumbKey(gd.gid), gd.thumb); mTitle.setText(EhUtils.getSuitableTitle(gd)); mUploader.setText(gd.uploader); mCategory.setText(EhUtils.getCategory(gd.category)); mCategory.setTextColor(EhUtils.getCategoryColor(gd.category)); updateDownloadText(); mLanguage.setText(gd.language); mPages.setText(resources.getQuantityString( R.plurals.page_count, gd.pages, gd.pages)); mSize.setText(gd.size); mPosted.setText(gd.posted); mFavoredTimes.setText(resources.getString(R.string.favored_times, gd.favoriteCount)); mRatingText.setText(getAllRatingText(gd.rating, gd.ratingCount)); mRating.setRating(gd.rating); updateFavoriteDrawable(); mTorrent.setText(resources.getString(R.string.torrent_count, gd.torrentCount)); bindTags(gd.tags); bindComments(gd.comments.comments); bindPreviews(gd); }
Example #24
Source File: GalleryDetailScene.java From EhViewer with Apache License 2.0 | 5 votes |
private boolean prepareData() { Context context = getContext2(); AssertUtils.assertNotNull(context); if (mGalleryDetail != null) { return true; } long gid = getGid(); if (gid == -1) { return false; } // Get from cache mGalleryDetail = EhApplication.getGalleryDetailCache(context).get(gid); if (mGalleryDetail != null) { return true; } EhApplication application = (EhApplication) context.getApplicationContext(); if (application.containGlobalStuff(mRequestId)) { // request exist return true; } // Do request return request(); }
Example #25
Source File: QuickSearchScene.java From EhViewer with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") @Nullable @Override public View onCreateView3(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.scene_label_list, container, false); mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view); TextView tip = (TextView) ViewUtils.$$(view, R.id.tip); mViewTransition = new ViewTransition(mRecyclerView, tip); Context context = getContext2(); AssertUtils.assertNotNull(context); Drawable drawable = DrawableManager.getVectorDrawable(context, R.drawable.big_search); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); tip.setCompoundDrawables(null, drawable, null, null); tip.setText(R.string.no_quick_search); // drag & drop manager RecyclerViewDragDropManager dragDropManager = new RecyclerViewDragDropManager(); dragDropManager.setDraggingItemShadowDrawable( (NinePatchDrawable) context.getResources().getDrawable(R.drawable.shadow_8dp)); RecyclerView.Adapter adapter = new QuickSearchAdapter(); adapter.setHasStableIds(true); adapter = dragDropManager.createWrappedAdapter(adapter); // wrap for dragging mAdapter = adapter; final GeneralItemAnimator animator = new DraggableItemAnimator(); mRecyclerView.setLayoutManager(new LinearLayoutManager(context)); mRecyclerView.setAdapter(adapter); mRecyclerView.setItemAnimator(animator); dragDropManager.attachRecyclerView(mRecyclerView); updateView(); return view; }
Example #26
Source File: EhEngine.java From EhViewer with Apache License 2.0 | 5 votes |
public static Void addFavoritesRange(@Nullable EhClient.Task task, OkHttpClient okHttpClient, long[] gidArray, String[] tokenArray, int dstCat) throws Throwable { AssertUtils.assertEquals(gidArray.length, tokenArray.length); for (int i = 0, n = gidArray.length; i < n; i++) { addFavorites(task, okHttpClient, gidArray[i], tokenArray[i], dstCat, null); } return null; }
Example #27
Source File: FavoritesParser.java From EhViewer with Apache License 2.0 | 5 votes |
public static Result parse(String body) throws Exception { if (body.contains("This page requires you to log on.</p>")) { throw new EhException(GetText.getString(R.string.need_sign_in)); } String[] catArray = new String[10]; int[] countArray = new int[10]; try { Document d = Jsoup.parse(body); Element ido = JsoupUtils.getElementByClass(d, "ido"); //noinspection ConstantConditions Elements fps = ido.getElementsByClass("fp"); // Last one is "fp fps" AssertUtils.assertEquals(11, fps.size()); for (int i = 0; i < 10; i++) { Element fp = fps.get(i); countArray[i] = ParserUtils.parseInt(fp.child(0).text(), 0); catArray[i] = ParserUtils.trim(fp.child(2).text()); } } catch (Throwable e) { ExceptionUtils.throwIfFatal(e); e.printStackTrace(); throw new ParseException("Parse favorites error", body); } GalleryListParser.Result result = GalleryListParser.parse(body); Result re = new Result(); re.catArray = catArray; re.countArray = countArray; re.pages = result.pages; re.nextPage = result.nextPage; re.galleryInfoList = result.galleryInfoList; return re; }
Example #28
Source File: MaxSizeContainer.java From MHViewer with Apache License 2.0 | 5 votes |
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { AssertUtils.assertEquals("getChildCount() must be 1", 1, getChildCount()); View child = getChildAt(0); if (child.getVisibility() != GONE) { child.layout(0, 0, r - l, b - t); } }
Example #29
Source File: MaxSizeContainer.java From MHViewer with Apache License 2.0 | 5 votes |
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { AssertUtils.assertEquals("getChildCount() must be 1", 1, getChildCount()); View child = getChildAt(0); if (child.getVisibility() != GONE) { child.measure(getMeasureSpec(widthMeasureSpec, mMaxWidth), getMeasureSpec(heightMeasureSpec, mMaxHeight)); setMeasuredDimension(child.getMeasuredWidth(), child.getMeasuredHeight()); } else { setMeasuredDimension(0, 0); } }
Example #30
Source File: Settings.java From MHViewer with Apache License 2.0 | 5 votes |
public static void putFavCount(int[] count) { AssertUtils.assertEquals(10, count.length); sSettingsPre.edit() .putInt(KEY_FAV_COUNT_0, count[0]) .putInt(KEY_FAV_COUNT_1, count[1]) .putInt(KEY_FAV_COUNT_2, count[2]) .putInt(KEY_FAV_COUNT_3, count[3]) .putInt(KEY_FAV_COUNT_4, count[4]) .putInt(KEY_FAV_COUNT_5, count[5]) .putInt(KEY_FAV_COUNT_6, count[6]) .putInt(KEY_FAV_COUNT_7, count[7]) .putInt(KEY_FAV_COUNT_8, count[8]) .putInt(KEY_FAV_COUNT_9, count[9]) .apply(); }