Java Code Examples for android.widget.ScrollView

The following are top voted examples for showing how to use android.widget.ScrollView. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Review-   File: FavActivity.java   Source Code and License 6 votes vote down vote up
public static void scrollToBottom(final ScrollView scroll, final View inner) {

        Handler mHandler = new Handler();

        mHandler.post(new Runnable() {
            public void run() {
                if (scroll == null || inner == null) {
                    return;
                }

                int offset = inner.getMeasuredHeight() - scroll.getHeight();
                if (offset < 0) {
                    offset = 0;
                }

                scroll.smoothScrollTo(0, offset);
            }
        });
    }
 
Example 2
Project: aarLibrary   File: XRefreshContentView.java   Source Code and License 6 votes vote down vote up
public boolean canChildPullUp() {
    if (child instanceof AbsListView) {
        AbsListView absListView = (AbsListView) child;
        return canScrollVertically(child, 1)
                || absListView.getLastVisiblePosition() != mTotalItemCount - 1;
    } else if (child instanceof WebView) {
        WebView webview = (WebView) child;
        if (webview instanceof XWebView) {
            return !((XWebView) webview).isBottom();
        } else {
            float left = webview.getContentHeight() * webview.getScale();
            int right = webview.getHeight() + webview.getScrollY();
            return left != right;
        }
    } else if (child instanceof ScrollView) {
        ScrollView scrollView = (ScrollView) child;
        View childView = scrollView.getChildAt(0);
        if (childView != null) {
            return canScrollVertically(child, 1)
                    || scrollView.getScrollY() < childView.getHeight() - scrollView.getHeight();
        }
    } else {
        return canScrollVertically(child, 1);
    }
    return true;
}
 
Example 3
Project: XPrivacy   File: ActivityMain.java   Source Code and License 6 votes vote down vote up
private void optionTutorial() {
	((ScrollView) findViewById(R.id.svTutorialHeader)).setVisibility(View.VISIBLE);
	((ScrollView) findViewById(R.id.svTutorialDetails)).setVisibility(View.VISIBLE);
	int userId = Util.getUserId(Process.myUid());
	PrivacyManager.setSetting(userId, PrivacyManager.cSettingTutorialMain, Boolean.FALSE.toString());

	Dialog dlgUsage = new Dialog(this);
	dlgUsage.requestWindowFeature(Window.FEATURE_LEFT_ICON);
	dlgUsage.setTitle(R.string.title_usage_header);
	dlgUsage.setContentView(R.layout.usage);
	dlgUsage.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher));
	dlgUsage.setCancelable(true);
	dlgUsage.show();
}
 
Example 4
Project: Hotspot-master-devp   File: SubjectActivity.java   Source Code and License 6 votes vote down vote up
@Override
public void getViews() {
    mInflater = LayoutInflater.from(context);
    mCustomWebView = (CustomWebView) findViewById(R.id.webview_custom);
    back = (ImageView) findViewById(R.id.back);
    toleft_iv_right = (ImageView) findViewById(R.id.toleft_iv_right);
    recommend_listview = (ListView) findViewById(R.id.recommend_listview);
    shareWeixinIV = (ImageView) findViewById(R.id.share_weixin);
    shareFriendsIV = (ImageView) findViewById(R.id.share_friends);
    shareQqIV = (ImageView) findViewById(R.id.share_qq);
    shareWeiboIV = (ImageView) findViewById(R.id.share_weibo);
    recommend_layout = (LinearLayout)findViewById(R.id.recommend_layout);
    share = (ImageView) findViewById(R.id.share);
    mProgressLayout = (ProgressBarView) findViewById(R.id.pbv_loading);
    allProgressLayuot = (ProgressBarView) findViewById(R.id.all_pbv_loading);
    share_layout = (LinearLayout)findViewById(R.id.share_layout);
    info = (ScrollView) findViewById(R.id.info);
}
 
Example 5
Project: nowweather   File: WeatherActivity.java   Source Code and License 6 votes vote down vote up
private void initView() {
    weatherLayout = (ScrollView)findViewById(R.id.weather_layout);
    titleCity = (TextView)findViewById(R.id.title_city);
    titleUpdateTime = (TextView)findViewById(R.id.title_update_time);
    degreeText = (TextView)findViewById(R.id.degree_text);
    weatherInfoText = (TextView)findViewById(R.id.weather_info_text);
    forecastLayout = (LinearLayout)findViewById(R.id.forecast_layout);
    aqiText = (TextView)findViewById(R.id.aqi_text);
    pm25Text = (TextView)findViewById(R.id.pm25_text);
    comfortText = (TextView)findViewById(R.id.comfort_text);
    carWashText = (TextView)findViewById(R.id.car_wash_text);
    sportText = (TextView)findViewById(R.id.sport_text);
    bingPicImg = (ImageView)findViewById(R.id.bing_pic);
    swipeRefresh = (SwipeRefreshLayout)findViewById(R.id.swipe_refresh);
    drawerlayout = (DrawerLayout)findViewById(R.id.drawer_layout);
    navButton = (Button)findViewById(R.id.nav_button);
}
 
Example 6
Project: CustomAndroidOneSheeld   File: TwitterFragment.java   Source Code and License 6 votes vote down vote up
@Override
public void onImageUploaded(final String tweet) {
    // TODO Auto-generated method stub
    uiHandler.removeCallbacksAndMessages(null);
    uiHandler.post(new Runnable() {

        @Override
        public void run() {
            if (canChangeUI()) {
                OneSheeldTextView tweetItem = (OneSheeldTextView) activity
                        .getLayoutInflater().inflate(
                                R.layout.tweet_item,
                                lastTweetTextContainer, false);
                tweetItem.setText(tweet);
                lastTweetTextContainer.addView(tweetItem);
                ((ScrollView) lastTweetTextContainer.getParent())
                        .invalidate();
            }
        }
    });
}
 
Example 7
Project: qmui   File: QDDialogFragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onBuildContent(QMUIDialog dialog, ScrollView parent) {
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    int padding = QMUIDisplayHelper.dp2px(mContext, 20);
    layout.setPadding(padding, padding, padding, padding);
    mEditText = new EditText(mContext);
    QMUIViewHelper.setBackgroundKeepingPadding(mEditText, QMUIResHelper.getAttrDrawable(mContext, R.attr.qmui_list_item_bg_with_border_bottom));
    mEditText.setHint("输入框");
    LinearLayout.LayoutParams editTextLP = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, QMUIDisplayHelper.dpToPx(50));
    editTextLP.bottomMargin = QMUIDisplayHelper.dp2px(getContext(), 15);
    mEditText.setLayoutParams(editTextLP);
    layout.addView(mEditText);
    TextView textView = new TextView(mContext);
    textView.setLineSpacing(QMUIDisplayHelper.dp2px(getContext(), 4), 1.0f);
    textView.setText("观察聚焦输入框后,键盘升起降下时 dialog 的高度自适应变化。\n\n" +
            "QMUI Android 的设计目的是用于辅助快速搭建一个具备基本设计还原效果的 Android 项目," +
            "同时利用自身提供的丰富控件及兼容处理,让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。" +
            "不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。");
    textView.setTextColor(ContextCompat.getColor(getContext(), R.color.app_color_description));
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    layout.addView(textView);
    return layout;
}
 
Example 8
Project: myCoolWeather   File: WeatherActivity.java   Source Code and License 6 votes vote down vote up
private void initView() {
    weatherLayout = (ScrollView) findViewById(R.id.weather_layout);
    titileCity = (TextView) findViewById(R.id.title_city);
    titleUpdateTime = (TextView) findViewById(R.id.title_update_time);
    degressText = (TextView) findViewById(R.id.degress_text);
    weatherInfoText = (TextView) findViewById(R.id.weather_info_text);
    forecastLayout = (LinearLayout) findViewById(R.id.forecast_layout);
    aqiText = (TextView) findViewById(R.id.aqi_text);
    pm25Text = (TextView) findViewById(R.id.pm25_text);
    comfortText = (TextView) findViewById(R.id.comfort_text);
    carWashText = (TextView) findViewById(R.id.car_wash_text);
    sportText = (TextView) findViewById(R.id.sport_text);

    bingPicImg = (ImageView) findViewById(R.id.bing_pic_img);
    swipeRefresh = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh);

    swipeRefresh.setColorSchemeResources(R.color.colorPrimary);

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    navButton = (Button) findViewById(R.id.nav_button);
}
 
Example 9
Project: CustomAndroidOneSheeld   File: TwitterFragment.java   Source Code and License 6 votes vote down vote up
@Override
public void onDirectMessageSent(final String userHandle,
                                final String msg) {
    // TODO Auto-generated method stub
    uiHandler.removeCallbacksAndMessages(null);
    uiHandler.post(new Runnable() {

        @Override
        public void run() {
            if (canChangeUI()) {
                OneSheeldTextView tweetItem = (OneSheeldTextView) activity
                        .getLayoutInflater().inflate(
                                R.layout.tweet_item,
                                lastTweetTextContainer, false);
                tweetItem.setText(activity.getString(R.string.twitter_to)+": " + userHandle + ", "+activity.getString(R.string.twitter_message)+": "
                        + msg);
                lastTweetTextContainer.addView(tweetItem);
                ((ScrollView) lastTweetTextContainer.getParent())
                        .invalidate();
            }
        }
    });
}
 
Example 10
Project: android_ui   File: ScrollableWrapper.java   Source Code and License 6 votes vote down vote up
/**
 * Wraps the given <var>scrollableView</var> into scrollable wrapper implementation that best
 * suits to the type of the given view.
 *
 * @param scrollableView The scrollable view to be wrapped into scrollable wrapper.
 * @return New scrollable wrapper instance. See description of this class for supported wrappers.
 */
@SuppressWarnings("unchecked")
public static <V extends View> ScrollableWrapper<V> wrapScrollableView(@NonNull V scrollableView) {
	if (scrollableView instanceof AbsListView) {
		return new AbsListViewWrapper((AbsListView) scrollableView);
	} else if (scrollableView instanceof RecyclerView) {
		return new RecyclerViewWrapper((RecyclerView) scrollableView);
	} else if (scrollableView instanceof ScrollView) {
		return new ScrollViewWrapper((ScrollView) scrollableView);
	} else if (scrollableView instanceof HorizontalScrollView) {
		return new HorizontalScrollViewWrapper((HorizontalScrollView) scrollableView);
	} else if (scrollableView instanceof ViewPager) {
		return new ViewPagerWrapper((ViewPager) scrollableView);
	} else if (scrollableView instanceof WebView) {
		return new WebViewWrapper((WebView) scrollableView);
	}
	return new ViewWrapper(scrollableView);
}
 
Example 11
Project: RabbitCloud   File: PtrDefaultHandler2.java   Source Code and License 6 votes vote down vote up
public static boolean canChildScrollDown(View view) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (view instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else if (view instanceof ScrollView) {
            ScrollView scrollView = (ScrollView) view;
            if (scrollView.getChildCount() == 0) {
                return false;
            } else {
                return scrollView.getScrollY() < scrollView.getChildAt(0).getHeight() - scrollView.getHeight();
            }
        } else {
            return false;
        }
    } else {
        return view.canScrollVertically(1);
    }
}
 
Example 12
Project: RNLearn_Project1   File: ReactScrollViewTestCase.java   Source Code and License 6 votes vote down vote up
public void testScrollEvents() {
  ScrollView scrollView = getViewAtPath(0);

  dragUp();

  waitForBridgeAndUIIdle();
  mScrollListenerModule.waitForScrollIdle();
  waitForBridgeAndUIIdle();

  ArrayList<Double> yOffsets = mScrollListenerModule.getYOffsets();
  assertFalse("Expected to receive at least one scroll event", yOffsets.isEmpty());
  assertTrue("Expected offset to be greater than 0", yOffsets.get(yOffsets.size() - 1) > 0);
  assertTrue(
      "Expected no item click event fired",
      mScrollListenerModule.getItemsPressed().isEmpty());
  assertEquals(
      "Expected last offset to be offset of scroll view",
      PixelUtil.toDIPFromPixel(scrollView.getScrollY()),
      yOffsets.get(yOffsets.size() - 1).doubleValue(),
      1e-5);
  assertTrue("Begin and End Drag should be called", mScrollListenerModule.dragEventsMatch());
}
 
Example 13
Project: arch-users-forum   File: ViewTopicActivity.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.view_topic_activity);
    Intent intent = getIntent();
    String forum_link = intent.getStringExtra("link_to_get");
    cr= new CrawlerRunnable();
    cr.initiate_url(forum_link);
    cr.start();
    t = (TextView)findViewById(R.id.text_view2);
    t.setOnClickListener(listener);
    t.setVisibility(View.INVISIBLE);
    sv = (ScrollView)findViewById(R.id.scroll_view3);
    ll = (LinearLayout)findViewById(R.id.linear_layout3);
    try {
        handler.removeCallbacks(time_task);
        handler.postDelayed(time_task, 1000);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 14
Project: boohee_v5.6   File: BitmapUtil.java   Source Code and License 6 votes vote down vote up
public static Bitmap getBitmapByView(ScrollView scrollView) {
    int h = 0;
    for (int i = 0; i < scrollView.getChildCount(); i++) {
        h += scrollView.getChildAt(i).getHeight();
    }
    Bitmap bitmap = Bitmap.createBitmap(scrollView.getWidth(), h, Config.ARGB_8888);
    scrollView.draw(new Canvas(bitmap));
    return bitmap;
}
 
Example 15
Project: weex-3d-map   File: ScreenShot.java   Source Code and License 6 votes vote down vote up
public static View findFirstScrollerByRootView(View  rootView){

        View firstScrollView = null;

        if(null != rootView){
            allViews = ViewUtil.getAllChildViews(rootView);
            for (View view:allViews
                 ) {
                if(view instanceof ScrollView){
                    firstScrollView = view;
                    break;
                }
            }
        }
        return firstScrollView;
    }
 
Example 16
Project: EasyUpdateApplication   File: ms_AlertDialog.java   Source Code and License 6 votes vote down vote up
private void initAlertDialog(Context context)
{
	layout = LayoutInflater.from(context).inflate(R.layout.ms_dialog, null);
	
	custom_view = (ViewGroup)layout.findViewById(R.id.id_custom_view);
	
	title = (TextView)layout.findViewById(R.id.id_title);
	content = (TextView)layout.findViewById(R.id.id_content_text);
	button_bar = (LinearLayout)layout.findViewById(R.id.bar_button);
	positive = (Button)layout.findViewById(R.id.button_positive);
	negative = (Button)layout.findViewById(R.id.button_negative);
	scroll = (ScrollView)layout.findViewById(R.id.id_scroll);
	list = (ListView)layout.findViewById(R.id.id_list);
	recycler = (RecyclerView)layout.findViewById(R.id.id_recycler);
	
	builder = new AlertDialog.Builder(context)
	    .setView(layout);

	dialog = builder.create();
	dialog.show();
}
 
Example 17
Project: CustomAndroidOneSheeld   File: TwitterFragment.java   Source Code and License 6 votes vote down vote up
@Override
public void onRecieveTweet(final String tweet) {
    // TODO Auto-generated method stub
    if (canChangeUI()) {
        uiHandler.removeCallbacksAndMessages(null);
        uiHandler.post(new Runnable() {

            @Override
            public void run() {
                OneSheeldTextView tweetItem = (OneSheeldTextView) activity
                        .getLayoutInflater().inflate(
                                R.layout.tweet_item,
                                lastTweetTextContainer, false);
                tweetItem.setText(tweet);
                lastTweetTextContainer.addView(tweetItem);
                ((ScrollView) lastTweetTextContainer.getParent())
                        .invalidate();
            }
        });
    }
}
 
Example 18
Project: weex-3d-map   File: WXRenderStatement.java   Source Code and License 6 votes vote down vote up
/**
 * create RootView ,every weex Instance View has a rootView;
 * @see com.taobao.weex.dom.WXDomStatement#createBody(JSONObject)
 */
void createBody(WXComponent component) {
  long start = System.currentTimeMillis();
  component.createView(mGodComponent, -1);
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.renderPerformanceLog("createView", (System.currentTimeMillis() - start));
  }
  start = System.currentTimeMillis();
  component.applyLayoutAndEvent(component);
  component.bindData(component);

  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.renderPerformanceLog("bind", (System.currentTimeMillis() - start));
  }

  if (component instanceof WXScroller) {
    WXScroller scroller = (WXScroller) component;
    if (scroller.getInnerView() instanceof ScrollView) {
      mWXSDKInstance.setRootScrollView((ScrollView) scroller.getInnerView());
    }
  }
  mWXSDKInstance.setRootView(mGodComponent.getRealView());
  if (mWXSDKInstance.getRenderStrategy() != WXRenderStrategy.APPEND_ONCE) {
    mWXSDKInstance.onViewCreated(mGodComponent);
  }
}
 
Example 19
Project: letv   File: LeBoxMainActivity.java   Source Code and License 6 votes vote down vote up
public void onRefresh(PullToRefreshBase<ScrollView> pullToRefreshBase) {
    LeboxConnectManager.getInstance().setConnectProgressReciver(new ConnectProgressReciver() {
        public void notifyProgress(int p) {
            switch (p) {
                case 27:
                    LeBoxMainActivity.this.mPullToRefreshScrollView.getLoadingLayoutProxy().setLastUpdatedLabel("");
                    LeBoxMainActivity.this.mPullToRefreshScrollView.onRefreshComplete();
                    LeBoxMainActivity.this.initData(false);
                    return;
                default:
                    if (10 <= p && p < 27) {
                        String text = Util.getConnectProcessPrompt(p);
                        if (!TextUtils.isEmpty(text)) {
                            LeBoxMainActivity.this.mPullToRefreshScrollView.getLoadingLayoutProxy().setLastUpdatedLabel(text);
                            return;
                        }
                        return;
                    }
                    return;
            }
        }
    });
    LeboxConnectManager.getInstance().startConnect();
}
 
Example 20
Project: Huochexing12306   File: PullToRefreshView.java   Source Code and License 6 votes vote down vote up
/**
 * init AdapterView like ListView,GridView and so on;or init ScrollView
 * 
 * @description hylin 2012-7-30下午8:48:12
 */
private void initContentAdapterView() {
	int count = getChildCount();
	if (count < 3) {
		throw new IllegalArgumentException(
				"this layout must contain 3 child views,and AdapterView or ScrollView must in the second position!");
	}
	View view = null;
	for (int i = 0; i < count - 1; ++i) {
		view = getChildAt(i);
		if (view instanceof AdapterView<?>) {
			mAdapterView = (AdapterView<?>) view;
		}
		if (view instanceof ScrollView) {
			// finish later
			mScrollView = (ScrollView) view;
		}
	}
	if (mAdapterView == null && mScrollView == null) {
		throw new IllegalArgumentException(
				"must contain a AdapterView or ScrollView in this layout!");
	}
}
 
Example 21
Project: HtmlNative   File: SourceHtmlActivity.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String source = getIntent().getStringExtra(INTENT_SOURCE_CODE);

    TextView sourceCodeTxt = new TextView(this);
    sourceCodeTxt.setBackgroundColor(Color.parseColor("#363636"));
    sourceCodeTxt.setTextColor(Color.WHITE);
    if (source != null) {
        sourceCodeTxt.setText(source);
    }

    ScrollView scrollView = new ScrollView(this);
    scrollView.addView(sourceCodeTxt, new FrameLayout.LayoutParams(FrameLayout.LayoutParams
            .MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    setContentView(scrollView);
}
 
Example 22
Project: mybotproject-Android   File: MainActivity.java   Source Code and License 6 votes vote down vote up
/**
     * Adds a message dialog view to the UI.
     *
     * @param message ConversationMessage containing a message and the sender.
     */
    private void addMessageFromUser(ConversationMessage message) {
        View messageView;
        LinearLayout messageContainer = (LinearLayout) findViewById(R.id.message_container);

        if (message.getUser().equals(USER_WATSON)) {
            messageView = this.getLayoutInflater().inflate(R.layout.watson_text, messageContainer, false);
            TextView watsonMessageText = (TextView) messageView.findViewById(R.id.watsonTextView);
            watsonMessageText.setText(message.getMessageText());
            if (message.getMessageText() != null)
                Log.i("User will see this", message.getMessageText());
//            if (message.getMessageText().contains("violations")) {
//                Log.i("Inside VIOlations","Vioation indisa");
//                messageView = this.getLayoutInflater().inflate(R.layout.watson_text, messageContainer, false);
////                TextView watsonMessageText = (TextView)messageView.findViewById(R.id.watsonTextView);
//                watsonMessageText.setText("you have fines");
//            }
        } else {
            messageView = this.getLayoutInflater().inflate(R.layout.user_text, messageContainer, false);
            TextView userMessageText = (TextView) messageView.findViewById(R.id.userTextView);
            userMessageText.setText(message.getMessageText());
        }

        messageContainer.addView(messageView);

        // Scroll to the bottom of the view so the user sees the update.
        final ScrollView scrollView = (ScrollView) findViewById(R.id.message_scrollview);
        scrollView.post(new Runnable() {
            @Override
            public void run() {
                scrollView.fullScroll(View.FOCUS_DOWN);
            }
        });
    }
 
Example 23
Project: AgentWebX5   File: ScrollingUtil.java   Source Code and License 6 votes vote down vote up
public static void scrollAViewBy(View view, int height) {
    if (view instanceof RecyclerView) ((RecyclerView) view).scrollBy(0, height);
    else if (view instanceof ScrollView) ((ScrollView) view).smoothScrollBy(0, height);
    else if (view instanceof AbsListView) ((AbsListView) view).smoothScrollBy(height, 0);
    else {
        try {
            Method method = view.getClass().getDeclaredMethod("smoothScrollBy", Integer.class, Integer.class);
            method.invoke(view, 0, height);
        } catch (Exception e) {
            view.scrollBy(0, height);
        }
    }
}
 
Example 24
Project: AgentWebX5   File: ScrollingUtil.java   Source Code and License 6 votes vote down vote up
public static void scrollToBottom(final ScrollView scrollView) {
    if (scrollView != null) {
        scrollView.post(new Runnable() {
            @Override
            public void run() {
                scrollView.fullScroll(ScrollView.FOCUS_DOWN);
            }
        });
    }
}
 
Example 25
Project: https-github.com-hyb1996-NoRootScriptDroid   File: ConsoleView.java   Source Code and License 5 votes vote down vote up
private void init() {
    inflate(getContext(), R.layout.console_view, this);
    mTextView = (TextView) findViewById(R.id.content);
    mTextView.setMovementMethod(new ScrollingMovementMethod());
    mContentContainer = (ScrollView) findViewById(R.id.content_container);
    initEditText();
    initSubmitButton();
}
 
Example 26
Project: aos-Video   File: TVCardView.java   Source Code and License 5 votes vote down vote up
@Override
public void restoreFocus(ScrollView sv) {
    if (lastFocused == -1 && findViewById(R.id.imageView) != null&&slaveView!=null)
        findViewById(R.id.imageView).requestFocus();
    else {
        if (others.size() > lastFocused) {
            if (others.get(lastFocused) instanceof FocusableTVCardView)
                ((FocusableTVCardView) others.get(lastFocused)).restoreFocus((ScrollView) findViewById(R.id.contentScrollView));
            else if(slaveView!=null)
                others.get(lastFocused).requestFocus();
        }
    }

}
 
Example 27
Project: GitHub   File: DemoMainActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void initView() {//必须调用
	exitAnim = R.anim.bottom_push_out;

	rlDemoMainTopbar = findViewById(R.id.rlDemoMainTopbar);

	ivDemoMainHead = findViewById(R.id.ivDemoMainHead, this);
	tvDemoMainHeadName = findViewById(R.id.tvDemoMainHeadName, this);

	svDemoMain = (ScrollView) findViewById(R.id.svDemoMain);
}
 
Example 28
Project: GitHub   File: DemoMainActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void initView() {//必须调用
	exitAnim = R.anim.bottom_push_out;

	rlDemoMainTopbar = findViewById(R.id.rlDemoMainTopbar);

	ivDemoMainHead = findViewById(R.id.ivDemoMainHead, this);
	tvDemoMainHeadName = findViewById(R.id.tvDemoMainHeadName, this);

	svDemoMain = (ScrollView) findViewById(R.id.svDemoMain);
}
 
Example 29
Project: PullToLoad   File: PullToRefreshLayout.java   Source Code and License 5 votes vote down vote up
boolean canScrollUp() {
    int size = mInAreaViewGroups.size();
    for (int i = 0; i < size; i++) {
        ViewGroup viewGroup = mInAreaViewGroups.get(i);
        if (viewGroup != null && viewGroup.isEnabled() && viewGroup.getVisibility() != GONE) {
            if (viewGroup instanceof RecyclerView
                    || viewGroup instanceof AbsListView
                    || viewGroup instanceof ScrollView)
                return ViewCompat.canScrollVertically(viewGroup, -1);
        }
    }
    return mRootView == null || ViewCompat.canScrollVertically(mRootView, -1);
}
 
Example 30
Project: SmartRefreshLayout   File: RefreshContentWrapper.java   Source Code and License 5 votes vote down vote up
protected boolean isScrollableView(View view) {
    return view instanceof AbsListView
            || view instanceof ScrollView
            || view instanceof ScrollingView
            || view instanceof NestedScrollingChild
            || view instanceof NestedScrollingParent
            || view instanceof WebView
            || view instanceof ViewPager;
}
 
Example 31
Project: boohee_v5.6   File: SummaryActivity$$ViewInjector.java   Source Code and License 5 votes vote down vote up
public void inject(Finder finder, T target, Object source) {
    target.sv_main = (ScrollView) finder.castView((View) finder.findRequiredView(source, R.id
            .sv_main, "field 'sv_main'"), R.id.sv_main, "field 'sv_main'");
    target.ll_card_breakfast = (LinearLayout) finder.castView((View) finder.findRequiredView
            (source, R.id.ll_card_breakfast, "field 'll_card_breakfast'"), R.id
            .ll_card_breakfast, "field 'll_card_breakfast'");
    target.ll_card_snacks_breakfast = (LinearLayout) finder.castView((View) finder
            .findRequiredView(source, R.id.ll_card_snacks_breakfast, "field " +
                    "'ll_card_snacks_breakfast'"), R.id.ll_card_snacks_breakfast, "field " +
            "'ll_card_snacks_breakfast'");
    target.ll_card_lunch = (LinearLayout) finder.castView((View) finder.findRequiredView
            (source, R.id.ll_card_lunch, "field 'll_card_lunch'"), R.id.ll_card_lunch, "field" +
            " 'll_card_lunch'");
    target.ll_card_snacks_lunch = (LinearLayout) finder.castView((View) finder
            .findRequiredView(source, R.id.ll_card_snacks_lunch, "field " +
                    "'ll_card_snacks_lunch'"), R.id.ll_card_snacks_lunch, "field " +
            "'ll_card_snacks_lunch'");
    target.ll_card_dinner = (LinearLayout) finder.castView((View) finder.findRequiredView
            (source, R.id.ll_card_dinner, "field 'll_card_dinner'"), R.id.ll_card_dinner,
            "field 'll_card_dinner'");
    target.ll_card_snacks_dinner = (LinearLayout) finder.castView((View) finder
            .findRequiredView(source, R.id.ll_card_snacks_dinner, "field " +
                    "'ll_card_snacks_dinner'"), R.id.ll_card_snacks_dinner, "field " +
            "'ll_card_snacks_dinner'");
    target.ll_card_sport = (LinearLayout) finder.castView((View) finder.findRequiredView
            (source, R.id.ll_card_sport, "field 'll_card_sport'"), R.id.ll_card_sport, "field" +
            " 'll_card_sport'");
    target.tv_diet_calory = (TextView) finder.castView((View) finder.findRequiredView(source,
            R.id.tv_diet_calory, "field 'tv_diet_calory'"), R.id.tv_diet_calory, "field " +
            "'tv_diet_calory'");
    target.tv_sport_calory = (TextView) finder.castView((View) finder.findRequiredView
            (source, R.id.tv_sport_calory, "field 'tv_sport_calory'"), R.id.tv_sport_calory,
            "field 'tv_sport_calory'");
    target.tv_date = (TextView) finder.castView((View) finder.findRequiredView(source, R.id
            .tv_date, "field 'tv_date'"), R.id.tv_date, "field 'tv_date'");
}
 
Example 32
Project: FingerprintIdentify   File: MainActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mTvTips = (TextView) findViewById(R.id.mTvTips);
    mScrollView = (ScrollView) findViewById(R.id.mScrollView);

    long time = System.currentTimeMillis();
    append("new FingerprintIdentify() ");
    mFingerprintIdentify = new FingerprintIdentify(getApplicationContext(), new BaseFingerprint.FingerprintIdentifyExceptionListener() {
        @Override
        public void onCatchException(Throwable exception) {
            append("\nException:" + exception.getLocalizedMessage());
        }
    });

    append("\n" + getString(R.string.time) + (System.currentTimeMillis() - time) + "ms");
    append("\nisHardwareEnable() " + mFingerprintIdentify.isHardwareEnable());
    append("\nisRegisteredFingerprint() " + mFingerprintIdentify.isRegisteredFingerprint());
    append("\nisFingerprintEnable() " + mFingerprintIdentify.isFingerprintEnable());

    if (!mFingerprintIdentify.isFingerprintEnable()) {
        append("\n" + getString(R.string.not_support));
        return;
    }

    append("\n" + getString(R.string.click_to_start));
}
 
Example 33
Project: RNLearn_Project1   File: JSResponderTestCase.java   Source Code and License 5 votes vote down vote up
public void testResponderLocksScrollView() {
  ScrollView scrollView = getViewByTestId("scroll_view");
  assertNotNull(scrollView);
  assertEquals(0, scrollView.getScrollY());

  float inpx40dp = PixelUtil.toPixelFromDIP(40f);
  float inpx100dp = PixelUtil.toPixelFromDIP(100f);

  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  gestureGenerator
      .startGesture(30, 30 + inpx100dp)
      .dragTo(30 + inpx40dp, 30, 10, 1200)
      .endGesture(180, 100);

  waitForBridgeAndUIIdle();

  assertTrue("Expected to scroll by at least 80 dp", scrollView.getScrollY() >= inpx100dp * .8f);

  int previousScroll = scrollView.getScrollY();

  gestureGenerator
      .startGesture(30, 30 + inpx100dp)
      .dragTo(30 + inpx40dp, 30 + inpx100dp, 10, 1200);

  waitForBridgeAndUIIdle();

  gestureGenerator
      .dragTo(30 + inpx40dp, 30, 10, 1200)
      .endGesture();

  waitForBridgeAndUIIdle();
  assertEquals("Expected not to scroll", scrollView.getScrollY(), previousScroll);

}
 
Example 34
Project: GitHub   File: BGARefreshScrollingUtil.java   Source Code and License 5 votes vote down vote up
public static void scrollToBottom(final ScrollView scrollView) {
    if (scrollView != null) {
        scrollView.post(new Runnable() {
            @Override
            public void run() {
                scrollView.fullScroll(ScrollView.FOCUS_DOWN);
            }
        });
    }
}
 
Example 35
Project: letv   File: LetvVipActivity.java   Source Code and License 5 votes vote down vote up
private void initUI() {
    setRedPacketFrom(new RedPacketFrom(0));
    this.mRootView.loading(true);
    this.mHead = getLayoutInflater().inflate(R.layout.letv_vip_activity_header, null);
    this.mRootView.addView(this.mHead, new LayoutParams(-1, -2));
    this.mIsSeniorVip = getIntent().getBooleanExtra("isSeniorVip", false);
    this.mProductImageView = (ImageView) findViewById(R.id.sproduct_pic);
    this.mScrollView = (ScrollView) findViewById(R.id.letv_vip_activity_layout);
    this.mBackIv = (ImageView) this.mHead.findViewById(R.id.vip_back_btn);
    this.mBackIv.setOnClickListener(this);
    this.mMobileDevicesVipButton = (Button) findViewById(R.id.mobile_devices_vip_btn);
    this.mMobileDevicesVipButton.setText(TipUtils.getTipMessage("90067", 2131101101));
    this.mSuperVipButton = (Button) findViewById(R.id.super_vip_btn);
    this.mSuperVipButton.setText(TipUtils.getTipMessage("90068", 2131101134));
    this.mLetvLoginTextView = (TextView) findViewById(R.id.letv_vip_login_tv);
    this.mLetvLoginTextView.setOnClickListener(this);
    this.mMobileDevicesVipButton.setOnClickListener(this);
    this.mSuperVipButton.setOnClickListener(this);
    this.mVipImageView = (ImageView) findViewById(R.id.vip_imageview);
    this.mSuperVipTipTv = (TextView) findViewById(R.id.super_vip_tip_tv);
    this.mMemberShipServiceAgreement = (TextView) findViewById(R.id.membershipa_service_agreement);
    this.mMemberShipServiceAgreement.setOnClickListener(this);
    this.mExchangeBtn = (Button) findViewById(R.id.exchange_btn);
    this.mExchangeBtn.setOnClickListener(this);
    this.mVipNameTv = (TextView) findViewById(R.id.vip_name_tv);
    UIs.zoomView(320, 98, this.mProductImageView);
    requestAutoPaySignStatusTask("1");
    StatisticsUtils.staticticsInfoPost(this, "19", "b3", null, -1, null, PageIdConstant.vipPage, NetworkUtils.DELIMITER_LINE, NetworkUtils.DELIMITER_LINE, NetworkUtils.DELIMITER_LINE, NetworkUtils.DELIMITER_LINE, NetworkUtils.DELIMITER_LINE);
}
 
Example 36
Project: xmrwallet   File: GenerateReviewFragment.java   Source Code and License 5 votes vote down vote up
void showAdvancedInfo() {
    llAdvancedInfo.setVisibility(View.VISIBLE);
    bAdvancedInfo.setVisibility(View.GONE);
    scrollview.post(new Runnable() {
        @Override
        public void run() {
            scrollview.fullScroll(ScrollView.FOCUS_DOWN);
        }
    });
}
 
Example 37
Project: diary   File: Diary.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    // Get preferences
    getPreferences();

    if (darkTheme)
        setTheme(R.style.AppDarkTheme);

    setContentView(R.layout.main);

    textView = (EditText) findViewById(R.id.text);
    scrollView = (ScrollView) findViewById(R.id.scroll);
    markdownView = (MarkdownView) findViewById(R.id.markdown);

    accept = findViewById(R.id.accept);
    edit = findViewById(R.id.edit);

    WebSettings settings = markdownView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setBuiltInZoomControls(true);
    settings.setDisplayZoomControls(false);

    setListeners();

    gestureDetector =
        new GestureDetector(this, new GestureListener());

    if (savedInstanceState == null)
    {
        // Set the date
        today();

        // Check for sent media
        mediaCheck(getIntent());
    }
}
 
Example 38
Project: BlackList   File: SMSSendFragment.java   Source Code and License 5 votes vote down vote up
private void moveScroll() {
    View view = getView();
    if (view != null) {
        final ScrollView scroll = (ScrollView) view.findViewById(R.id.scroll);
        scroll.post(new Runnable() {
            @Override
            public void run() {
                scroll.fullScroll(ScrollView.FOCUS_DOWN);
            }
        });
    }
}
 
Example 39
Project: Idea-ChainSelector   File: ChainSelectorView.java   Source Code and License 5 votes vote down vote up
private void compileScroll() {
    postDelayed(new Runnable() {
        @Override
        public void run() {
            scrollView.fullScroll(ScrollView.FOCUS_RIGHT);
        }
    }, 100);
}
 
Example 40
Project: Tribe   File: InterceptLayout.java   Source Code and License 5 votes vote down vote up
public boolean svPullUpIntercept(View child) {
    boolean intercept = false;
    ScrollView scrollView = (ScrollView) child;
    View scrollChild = scrollView.getChildAt(0);

    if (scrollView.getScrollY() >= (scrollChild.getHeight() - scrollView.getHeight())) {
        intercept = true;
    }
    return intercept;
}
 
Example 41
Project: FBEventSync   File: LogViewActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_log_view);
    Toolbar toolbar = (Toolbar) findViewById(R.id.logview_toolbar);
    setSupportActionBar(toolbar);

    ActionBar ab = getSupportActionBar();
    ab.setDisplayHomeAsUpEnabled(true);

    mTextView = (TextView) findViewById(R.id.log_text_view);
    mScrollView = (ScrollView) findViewById(R.id.log_scroll_view);
}
 
Example 42
Project: pius1   File: SlideBottomPanel.java   Source Code and License 5 votes vote down vote up
/**
 *  Copy From ScrollView (API Level >= 14)
 * @param direction Negative to check scrolling up, positive to check
 *                  scrolling down.
 *   @return true if the scrollView can be scrolled in the specified direction,
 *         false otherwise
 */
private  boolean scrollViewCanScrollVertically(ScrollView scrollView,int direction) {
    final int offset = Math.max(0, scrollView.getScrollY());
    final int range = computeVerticalScrollRange(scrollView) - scrollView.getHeight();
    if (range == 0) return false;
    if (direction < 0) { //scroll up
        return offset > 0;
    } else {//scroll down
        return offset < range - 1;
    }
}
 
Example 43
Project: MusicX-music-player   File: EdgeGlowUtil.java   Source Code and License 5 votes vote down vote up
public static void setEdgeGlowColor(@NonNull ScrollView scrollView, @ColorInt int color) {
    invalidateScrollViewFields();
    try {
        Object ee;
        ee = SCROLL_VIEW_FIELD_EDGE_GLOW_TOP.get(scrollView);
        setEffectColor(ee, color);
        ee = SCROLL_VIEW_FIELD_EDGE_GLOW_BOTTOM.get(scrollView);
        setEffectColor(ee, color);
    } catch (Exception ex) {
        if (BuildConfig.DEBUG) ex.printStackTrace();
    }
}
 
Example 44
Project: Forge   File: GeneratorFragment.java   Source Code and License 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    // Get fragment context
    context = getContext();
    // Set up global variables
    setUpGlobals();
    // Set up user interface variables and UI
    setUpUserInterface();
    // Get any account that is stored in temporary storage
    ForgeAccount currentAccount = CurrentManager.loadCurrentAccount(context);
    if (currentAccount != null) {
        // If the account exists
        if (currentAccount.getEmail() != null) {
            // If the account has an email, load that account
            load(currentAccount);
        }
    } else {
        // If the account doesn't exist, generate a new one
        account = generator.forgeAccount(Util.isNetworkAvailable(context), (String) mailDomain.getSelectedItem());
    }
    // Display the account
    displayAccount();
    // Open shared preferences
    SharedPreferences sharedPref = context.getSharedPreferences(context.getString(R.string.shared_prefs), Context.MODE_PRIVATE);
    if (sharedPref.getBoolean(FIRST_RUN, true)) {
        // If it is the first run of the app, show the tutorial
        Tutorial tutorial = new Tutorial(getActivity(),
                R.id.refresh,
                R.id.refresh_username,
                R.id.copy_username,
                R.id.email_list,
                (ScrollView) view.findViewById(R.id.scroll));
        tutorial.startTutorial();
        // Mark the app as having been run
        SharedPreferences.Editor editor = sharedPref.edit();
        editor.putBoolean(FIRST_RUN, false);
        editor.apply();
    }
}
 
Example 45
Project: Forge   File: Tutorial.java   Source Code and License 5 votes vote down vote up
/**
 * @param activity      the activity to show the tutorial on
 * @param refreshGlobal the global refresh button ID
 * @param refreshLocal  the local refresh button ID
 * @param copy          the copy button ID
 * @param inbox         the inbox ID
 * @param scrollView    the activity scrollview
 */

public Tutorial(Activity activity, int refreshGlobal, int refreshLocal, int copy, int inbox, ScrollView scrollView) {
    this.activity = activity;
    // Set up tutorial view targets
    this.refreshGlobal = new ViewTarget(refreshGlobal, activity);
    this.refreshLocal = new ViewTarget(refreshLocal, activity);
    this.copy = new ViewTarget(copy, activity);
    this.inbox = new ViewTarget(inbox, activity);
    this.scrollView = scrollView;
    // Set tutorial position
    position = 0;
}
 
Example 46
Project: boohee_v5.6   File: ScrollViewDelegate.java   Source Code and License 5 votes vote down vote up
public boolean isViewBeingDragged(MotionEvent event, ScrollView view) {
    if (view.getChildCount() == 0) {
        return true;
    }
    view.getLocationOnScreen(this.mViewLocationResult);
    int viewLeft = this.mViewLocationResult[0];
    int viewTop = this.mViewLocationResult[1];
    this.mRect.set(viewLeft, viewTop, view.getWidth() + viewLeft, view.getHeight() + viewTop);
    int rawX = (int) event.getRawX();
    int rawY = (int) event.getRawY();
    return this.mRect.contains(rawX, rawY) ? isReadyForPull(view, (float) (rawX - this.mRect
            .left), (float) (rawY - this.mRect.top)) : false;
}
 
Example 47
Project: RNLearn_Project1   File: CatalystSubviewsClippingTestCase.java   Source Code and License 5 votes vote down vote up
private void scrollToDpInUIThread(final int yPositionInDP) throws Throwable {
  final ScrollView mainScrollView = getViewByTestId("scroll_view");
  runTestOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          mainScrollView.scrollTo(0, (int) PixelUtil.toPixelFromDIP(yPositionInDP));
        }
      });
  waitForBridgeAndUIIdle();
}
 
Example 48
Project: letv   File: NestedScrollView.java   Source Code and License 5 votes vote down vote up
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    NestedScrollView nsvHost = (NestedScrollView) host;
    event.setClassName(ScrollView.class.getName());
    AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
    record.setScrollable(nsvHost.getScrollRange() > 0);
    record.setScrollX(nsvHost.getScrollX());
    record.setScrollY(nsvHost.getScrollY());
    record.setMaxScrollX(nsvHost.getScrollX());
    record.setMaxScrollY(nsvHost.getScrollRange());
}
 
Example 49
Project: SunmiUI   File: ListDialog.java   Source Code and License 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
protected void init() {
    scrollView = (ScrollView) dialog.findViewById(R.id.scrollView);
    list = (LinearLayout) dialog.findViewById(R.id.list);
    View cancel =  dialog.findViewById(R.id.btn_cancel);
    cancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            cancel();
        }
    });
}
 
Example 50
Project: RNLearn_Project1   File: ReactScrollViewTestCase.java   Source Code and License 5 votes vote down vote up
public void testScrolling() {
  ScrollView scrollView = getViewAtPath(0);
  assertNotNull(scrollView);
  assertEquals(0, scrollView.getScrollY());

  dragUp();

  assertTrue("Expected to scroll by at least 50 pixels", scrollView.getScrollY() >= 50);
}
 
Example 51
Project: OpenEyesReading-android   File: CustomLayout.java   Source Code and License 5 votes vote down vote up
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);
    if (changed && isfrist) {// 只需实例化一次
        sv = (ScrollView) getChildAt(0);// 该自定义布局写入xml文件时,其子布局的第一个必须是ScrollView时,这里才能getChildAt(0) 实例化ScrollView
        sv.setOverScrollMode(View.OVER_SCROLL_NEVER);// 去掉ScrollView 滑动到底部继续滑动时会出现杂色块
        sv.setOnTouchListener(this);
        isfrist = false;
    }
}
 
Example 52
Project: RootPGPExplorer   File: SanityCheckRootTools.java   Source Code and License 5 votes vote down vote up
protected void print(CharSequence text) {
    mTextView.append(text);
    mScrollView.post(new Runnable() {
        public void run() {
            mScrollView.fullScroll(ScrollView.FOCUS_DOWN);
        }
    });
}
 
Example 53
Project: android-apps   File: ReadBookActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_read_book);

  catalog = getIntent().getStringExtra("catalog");
  href = getIntent().getStringExtra("href");
  name = getIntent().getStringExtra("name");
  order = getIntent().getBooleanExtra("order", false);

  toolbar = (Toolbar) findViewById(R.id.toolbar);
  toolbar.setTitle(catalog);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      ReadBookActivity.this.finish();
    }
  });
  scrollView = (ScrollView) findViewById(R.id.scroll_view);
  refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh_layout);
  refreshLayout.setOnRefreshListener(this);
  contentTv = (TextView) findViewById(R.id.contentTv);
  prevBtn = (Button) findViewById(R.id.prevBtn);
  nextBtn = (Button) findViewById(R.id.nextBtn);
  prevBtn.setOnClickListener(this);
  nextBtn.setOnClickListener(this);
  //初始化本地保存的书箱信息
  localBookData = SharedPreferencesUtil.getLocalBooks(this);
  localBook = FormatUtil.findByName(localBookData, name);
  catalogIndex = FormatUtil.findByCatalog(localBook.getCatalogs(), catalog);
  initData();
}
 
Example 54
Project: chromium-for-android-56-debug-video   File: ConnectionInfoPopup.java   Source Code and License 5 votes vote down vote up
/** Displays the ConnectionInfoPopup. */
@CalledByNative
private void showDialog() {
    ScrollView scrollView = new ScrollView(mContext);
    scrollView.addView(mContainer);
    mDialog.addContentView(scrollView,
            new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.MATCH_PARENT));

    mDialog.getWindow().setLayout(
            ViewGroup.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    mDialog.show();
}
 
Example 55
Project: BookyMcBookface   File: BookListActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_book_list);

    listHolder = (ViewGroup)findViewById(R.id.book_list_holder);
    listScroller = (ScrollView)findViewById(R.id.book_list_scroller);
    tv = (TextView)findViewById(R.id.progress_text);
    checkStorageAccess(false);

    data = getSharedPreferences("booklist", Context.MODE_PRIVATE);

    if (!data.contains(SORTORDER_KEY)) {
        setSortOrder(SortOrder.Default);
    }

    //getApplicationContext().deleteDatabase(BookDb.DBNAME);

    db = BookyApp.getDB(this);

    viewAdder = new BookListAdderHandler(this);
    update();

    recentread = db.getMostRecentlyRead();

    listScroller.postDelayed(new Runnable() {
        @Override
        public void run() {

            populateBooks();
        }
    }, 100);
}
 
Example 56
Project: Renrentou   File: ConvertUtils.java   Source Code and License 5 votes vote down vote up
/**
 * 把view转化为bitmap(截图)
 * 参见:http://www.cnblogs.com/lee0oo0/p/3355468.html
 */
public static Bitmap toBitmap(View view) {
    int width = view.getWidth();
    int height = view.getHeight();
    if (view instanceof ListView) {
        height = 0;
        // 获取listView实际高度
        ListView listView = (ListView) view;
        for (int i = 0; i < listView.getChildCount(); i++) {
            height += listView.getChildAt(i).getHeight();
        }
    } else if (view instanceof ScrollView) {
        height = 0;
        // 获取scrollView实际高度
        ScrollView scrollView = (ScrollView) view;
        for (int i = 0; i < scrollView.getChildCount(); i++) {
            height += scrollView.getChildAt(i).getHeight();
        }
    }
    view.setDrawingCacheEnabled(true);
    view.clearFocus();
    view.setPressed(false);
    boolean willNotCache = view.willNotCacheDrawing();
    view.setWillNotCacheDrawing(false);
    // Reset the drawing cache background color to fully transparent for the duration of this operation
    int color = view.getDrawingCacheBackgroundColor();
    view.setDrawingCacheBackgroundColor(Color.WHITE);//截图去黑色背景(透明像素)
    if (color != Color.WHITE) {
        view.destroyDrawingCache();
    }
    view.buildDrawingCache();
    Bitmap cacheBitmap = view.getDrawingCache();
    if (cacheBitmap == null) {
        return null;
    }
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawBitmap(cacheBitmap, 0, 0, null);
    canvas.save(Canvas.ALL_SAVE_FLAG);
    canvas.restore();
    if (!bitmap.isRecycled()) {
       // LogUtils.verbose("recycle bitmap: " + bitmap.toString());
        bitmap.recycle();
    }
    // Restore the view
    view.destroyDrawingCache();
    view.setWillNotCacheDrawing(willNotCache);
    view.setDrawingCacheBackgroundColor(color);
    return bitmap;
}
 
Example 57
Project: RNLearn_Project1   File: JSResponderTestCase.java   Source Code and License 5 votes vote down vote up
public void testResponderLocksScrollView() {
  ScrollView scrollView = getViewByTestId("scroll_view");
  assertNotNull(scrollView);
  assertEquals(0, scrollView.getScrollY());

  float inpx40dp = PixelUtil.toPixelFromDIP(40f);
  float inpx100dp = PixelUtil.toPixelFromDIP(100f);

  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  gestureGenerator
      .startGesture(30, 30 + inpx100dp)
      .dragTo(30 + inpx40dp, 30, 10, 1200)
      .endGesture(180, 100);

  waitForBridgeAndUIIdle();

  assertTrue("Expected to scroll by at least 80 dp", scrollView.getScrollY() >= inpx100dp * .8f);

  int previousScroll = scrollView.getScrollY();

  gestureGenerator
      .startGesture(30, 30 + inpx100dp)
      .dragTo(30 + inpx40dp, 30 + inpx100dp, 10, 1200);

  waitForBridgeAndUIIdle();

  gestureGenerator
      .dragTo(30 + inpx40dp, 30, 10, 1200)
      .endGesture();

  waitForBridgeAndUIIdle();
  assertEquals("Expected not to scroll", scrollView.getScrollY(), previousScroll);

}
 
Example 58
Project: showroom-android   File: ShowroomActivity.java   Source Code and License 4 votes vote down vote up
@SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Make activity fullscreen
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    ActionBar supportActionBar = getSupportActionBar();
    if (null != supportActionBar)
        supportActionBar.hide();

    setContentView(R.layout.sr_main_activity);

    // Get UI parts
    // main layout
    mainLayout = (LinearLayout) findViewById(R.id.sr_main_content_layout);
    sliderContainer = (SliderContainer) findViewById(R.id.sr_slide_pager_container);
    sliderCounterLabel = (TextView) findViewById(R.id.sr_slider_position_counter);
    contactButton = (AppCompatButton) findViewById(R.id.sr_btn_contact);
    // title bar layout
    titleLayout = (FrameLayout) findViewById(R.id.sr_title_layout);
    titleHelpButton = findViewById(R.id.sr_title_help_btn);
    titleIcon = (ImageView) findViewById(R.id.sr_title_icon);
    // help layout (hidden when app starts)
    helpLayout = (RelativeLayout) findViewById(R.id.sr_help_layout);
    helpLayoutBottomPanel = (FrameLayout) findViewById(R.id.sr_help_layout_bottom_panel);
    helpLayoutScrollView = (ScrollView) findViewById(R.id.sr_help_layout_scroll_view);
    helpLayoutTitleBackground = (ImageView) findViewById(R.id.sr_help_layout_title_background);
    helpLayoutTextHeader = (TextView) findViewById(R.id.sr_help_layout_text_header);
    helpLayoutTextContent = (TextView) findViewById(R.id.sr_help_layout_text_content);

    // Add content to slider through adapter
    sliderAdapter = new SliderAdapter(this, SlideCardEntity.prepareDataset());
    sliderContainer.getSlider().setAdapter(sliderAdapter);

    // Get screen dimensions for animation purposes
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    screenWidthPx = size.x;
    screenHeightPx = size.y;
    screenDiagonalPx = (int) Math.sqrt(size.x * size.x + size.y * size.y);

    // calculations for animation purposes
    globalPaddingPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30, getResources().getDisplayMetrics());
    helpButtonSizePx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30, getResources().getDisplayMetrics());
    titleBtnHelpCenterX = (int) (screenWidthPx - globalPaddingPx - helpButtonSizePx / 2);
    titleBtnHelpCenterY = (int) (globalPaddingPx + helpButtonSizePx / 2);

    // Change current slider page index in label and fix description text view size
    sliderContainer.getSlider().addOnPageChangeListener(new OnPageChangeListenerAdapter() {
        @SuppressLint("SetTextI18n")
        @Override
        public void onPageSelected(int position) {
            sliderCounterLabel.setText((position + 1) + "/" + sliderAdapter.getCount());
        }
    });

    // Contact button should open a link in browser
    contactButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.sr_contact_us_btn_link))));
        }
    });

    bindHelpButton();
    bindHelpScreenBottomBarButtons();
    addScrollListenerToHelpScreenContent();

    sliderCounterLabel.setText((sliderContainer.getSlider().getCurrentItem() + 1) + "/" + sliderAdapter.getCount());

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
            WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);

    playInitialAnimations();
}
 
Example 59
Project: GitHub   File: DemoSQLActivity.java   Source Code and License 4 votes vote down vote up
@Override
public void initView() {//必须在onCreate方法内调用
	
	tvDemoSQLInfo = (TextView) findViewById(R.id.tvDemoSQLInfo);

	svDemoSQL = (ScrollView) findViewById(R.id.svDemoSQL);

	tvDemoSQLShow0 = (TextView) findViewById(R.id.tvDemoSQLShow0);
	tvDemoSQLShow1 = (TextView) findViewById(R.id.tvDemoSQLShow1);

	etDemoSQLQueryColumn = (EditText) findViewById(R.id.etDemoSQLQueryColumn);
	etDemoSQLQueryValue = (EditText) findViewById(R.id.etDemoSQLQueryValue);

	etDemoSQLEditColumn = (EditText) findViewById(R.id.etDemoSQLEditColumn);
	etDemoSQLEditValue = (EditText) findViewById(R.id.etDemoSQLEditValue);
}
 
Example 60
Project: QMUI_Android   File: QMUIDialog.java   Source Code and License 4 votes vote down vote up
public int onGetScrollHeight() {
    return ScrollView.LayoutParams.WRAP_CONTENT;
}