Java Code Examples for android.widget.RelativeLayout#setGravity()

The following examples show how to use android.widget.RelativeLayout#setGravity() . 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: QRefreshLayout.java    From QRefreshLayout with MIT License 6 votes vote down vote up
public QRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    setNestedScrollingEnabled(true);

    viewRefresh = new DefaultRefreshView(context);
    viewLoad = new DefaultLoadView(context);
    viewRefreshContainer = new RelativeLayout(context);
    viewRefreshContainer.setGravity(Gravity.CENTER);
    viewRefreshContainer.addView(viewRefresh);
    viewLoadContainer = new RelativeLayout(context);
    viewLoadContainer.setGravity(Gravity.CENTER);
    viewLoadContainer.addView(viewLoad);
    viewLoadContainer.setVisibility(GONE);
    addView(viewRefreshContainer);
    addView(viewLoadContainer);
    ensureTarget();
}
 
Example 2
Source File: GuardaInputLayout.java    From guarda-android-wallets with GNU General Public License v3.0 6 votes vote down vote up
private View getEraseView(Context context) {
    GridLayout.LayoutParams params = new GridLayout.LayoutParams();
    params.setGravity(Gravity.FILL);
    params.rowSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f);
    params.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f);

    RelativeLayout relativeLayout = new RelativeLayout(context);
    relativeLayout.setLayoutParams(params);
    relativeLayout.setGravity(Gravity.CENTER);
    relativeLayout.setBackground(context.getResources().getDrawable(R.drawable.ripple));
    relativeLayout.setId(R.id.input_erase);

    ImageView eraseView = new ImageView(context);
    eraseView.setImageResource(R.drawable.ic_erase);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    eraseView.setLayoutParams(layoutParams);

    relativeLayout.addView(eraseView);
    relativeLayout.setOnClickListener(this);
    return relativeLayout;
}
 
Example 3
Source File: WeiboDialog.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
private void initWebView()
{
    mWebViewContainer = new RelativeLayout(getContext());
    mWebView = new WebView(getContext());
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setSavePassword(false);
    mWebView.setWebViewClient(new WeiboWebViewClient(null));
    mWebView.requestFocus();
    mWebView.setScrollBarStyle(0);
    mWebView.setVisibility(4);
    NetworkHelper.clearCookies(mContext, mAuthUrl);
    mWebView.loadUrl(mAuthUrl);
    android.widget.RelativeLayout.LayoutParams layoutparams = new android.widget.RelativeLayout.LayoutParams(-1, -1);
    android.widget.RelativeLayout.LayoutParams layoutparams1 = new android.widget.RelativeLayout.LayoutParams(-1, -1);
    DisplayMetrics displaymetrics = getContext().getResources().getDisplayMetrics();
    int i = (int)(10F * displaymetrics.density);
    layoutparams1.setMargins(i, i, i, i);
    Drawable drawable = ResourceManager.getNinePatchDrawable(mContext, 1);
    mWebViewContainer.setBackgroundDrawable(drawable);
    mWebViewContainer.addView(mWebView, layoutparams1);
    mWebViewContainer.setGravity(17);
    int j = 1 + ResourceManager.getDrawable(mContext, 2).getIntrinsicWidth() / 2;
    layoutparams.setMargins(j, (int)(25F * displaymetrics.density), j, j);
    mRootContainer.addView(mWebViewContainer, layoutparams);
}
 
Example 4
Source File: PluginActivity.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, TAG + ":onCreate");

    RelativeLayout relativeLayout = new RelativeLayout(this);
    relativeLayout.setGravity(Gravity.CENTER);

    TextView textView = new TextView(this);
    textView.setText("启动插件APK中的PluginActivity,成功!");

    relativeLayout.addView(textView);
    setContentView(relativeLayout);
}
 
Example 5
Source File: ContextMenuBuilder.java    From ticdesign with Apache License 2.0 5 votes vote down vote up
@NonNull
private RelativeLayout createDialogContent(Context dialogContext) {
    // Use a RelativeLayout to wrap the menu, so we can set the height to match_parent.
    RelativeLayout layout = new RelativeLayout(dialogContext);
    layout.setGravity(Gravity.CENTER);

    mMenuLayout = (MenuFloatingLayout) LayoutInflater.from(dialogContext)
            .inflate(R.layout.menu_floating_layout_ticwear, layout, false);

    mMenuLayout.clear();

    layout.addView(mMenuLayout);
    return layout;
}
 
Example 6
Source File: InfiniteScrollAdapter.java    From tickmate with GNU General Public License v3.0 5 votes vote down vote up
public InfiniteScrollAdapter(Context context, T adapter, int itemWidth,
                             int itemHeight) {
    mAdapter = adapter;
    RelativeLayout layout = new RelativeLayout(context);
    layout.setLayoutParams(new GridView.LayoutParams(itemWidth,
            itemHeight));
    layout.setGravity(Gravity.CENTER);
    layout.addView(new ProgressBar(context));

    mProgressView = layout;
}
 
Example 7
Source File: RNCameraInstanceView.java    From react-native-camera-android with MIT License 5 votes vote down vote up
public final void setupLayout() {
    this.mPreview = new CameraPreview(this.getContext());
    RelativeLayout mCameraView = new RelativeLayout(this.getContext());
    mCameraView.setGravity(17);
    mCameraView.setBackgroundColor(-16777216);
    mCameraView.addView(this.mPreview);
    this.addView(mCameraView);
    this.mViewFinderView = this.createViewFinderView(this.getContext());
    if(this.mViewFinderView instanceof View) {

    } else {
        throw new IllegalArgumentException("IViewFinder object returned by \'createViewFinderView()\' should be instance of android.view.View");
    }
}
 
Example 8
Source File: CollectionView.java    From TiCollectionView with MIT License 5 votes vote down vote up
private void layoutSearchView(TiViewProxy searchView) {
	TiUIView search = searchView.getOrCreateView();
	RelativeLayout layout = new RelativeLayout(proxy.getActivity());
	layout.setGravity(Gravity.NO_GRAVITY);
	layout.setPadding(0, 0, 0, 0);
	addSearchLayout(layout, searchView, search);
	setNativeView(layout);	
}
 
Example 9
Source File: AppRunnerService.java    From PHONK with GNU General Public License v3.0 5 votes vote down vote up
public RelativeLayout initLayout() {
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    // set the parent
    parentScriptedLayout = new RelativeLayout(this);
    parentScriptedLayout.setLayoutParams(layoutParams);
    parentScriptedLayout.setGravity(Gravity.BOTTOM);
    parentScriptedLayout.setBackgroundColor(getResources().getColor(R.color.transparent));

    return parentScriptedLayout;
}
 
Example 10
Source File: ChannelTabPageIndicator.java    From letv with Apache License 2.0 5 votes vote down vote up
protected void addTab(int index, CharSequence text, int iconResId) {
    TabView tabView = new TabView(this, getContext(), text);
    tabView.setIndex(index);
    tabView.setFocusable(true);
    tabView.setOnClickListener(this.mTabClickListener);
    if (iconResId != 0) {
        tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
    }
    int width = this.mMeanWidth == -1 ? getTabWidth(text) : this.mMeanWidth;
    if (this.mMeanWidth != -1) {
        tabView.setSize(this.mMeanWidth, UIsUtils.dipToPx(38.0f));
    } else {
        tabView.setSize(width, UIsUtils.dipToPx(38.0f));
    }
    RelativeLayout relativeLayout = new RelativeLayout(this.mContext);
    relativeLayout.setGravity(17);
    relativeLayout.setLayoutParams(new LayoutParams(-2, UIsUtils.dipToPx(38.0f)));
    LayoutParams params = new LayoutParams(-2, UIsUtils.dipToPx(38.0f));
    params.setMargins(TAB_MARGIN, 0, TAB_MARGIN, 0);
    tabView.setLayoutParams(params);
    relativeLayout.addView(tabView);
    if (this.mIsHome) {
        ThemeDataManager.getInstance(this.mContext).setContentTheme(tabView, ThemeDataManager.NAME_TOP_NAVIGATION_COLOR);
    }
    ImageView imageView = new ImageView(this.mContext);
    LayoutParams imageViewParams = new LayoutParams(width, UIsUtils.dipToPx(2.0f));
    imageViewParams.setMargins(TAB_MARGIN, UIsUtils.dipToPx(36.0f), TAB_MARGIN, 0);
    imageView.setLayoutParams(imageViewParams);
    relativeLayout.addView(imageView);
    imageView.setBackgroundDrawable(getResources().getDrawable(2130838177));
    if (this.mIsHome) {
        ThemeDataManager.getInstance(this.mContext).setShapeSelectorViewTheme(imageView, ThemeDataManager.NAME_TOP_NAVIGATION_COLOR, 2, true);
    }
    this.mTabLayout.addView(relativeLayout);
}
 
Example 11
Source File: EmptyFragment.java    From secureit with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {    	
	
    if ((savedInstanceState != null) && savedInstanceState.containsKey(CONTENT)) {
        mContent = savedInstanceState.getString(CONTENT);
    }
	
    TextView text = new TextView(getActivity());
    text.setGravity(Gravity.CENTER);
    text.setText(mContent);
    text.setTextSize(20 * getResources().getDisplayMetrics().density);

    RelativeLayout layout = new RelativeLayout(getActivity());
    layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    layout.setGravity(Gravity.CENTER);
    
    RelativeLayout alert = new RelativeLayout(getActivity());
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.leftMargin = 20;
    params.rightMargin = 20;
    params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    alert.setLayoutParams(params);
    alert.setBackgroundResource(R.drawable.red_back);
    alert.setPadding(30, 0, 30, 0);
    alert.addView(text);
    layout.addView(alert);
  
    return layout;
}
 
Example 12
Source File: MovieActivity.java    From android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onResume() {
    if (AppUtils.isChromecastPluginInstalled(this)) {
        mCastManager = CastApplication.getCastManager(this);
    }
    if (null != mCastManager) {
        mCastManager.addVideoCastConsumer(mCastConsumer);
        mCastManager.incrementUiCounter();
    }

    adlayout = (RelativeLayout) findViewById(R.id.ad);
    if (AppUtils.canShowAds(this)) {
        //Starting RevMob session
        RevMob revmob = RevMob.start(this); // RevMob App ID configured in the AndroidManifest.xml file
        RevMobBanner banner = revmob.createBanner(this);
        ArrayList<String> interests = new ArrayList<String>();
        interests.add("games");
        interests.add("mobile");
        interests.add("advertising");
        revmob.setUserInterests(interests);
        adlayout.addView(banner);
        adlayout.setGravity(Gravity.BOTTOM);
    }else{
        adlayout.setVisibility(View.GONE);
    }


    super.onResume();
}
 
Example 13
Source File: TargetAppCompatActivity.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, TAG + ":onCreate");

    RelativeLayout relativeLayout = new RelativeLayout(this);
    relativeLayout.setGravity(Gravity.CENTER);

    TextView textView = new TextView(this);
    textView.setText("未注册的TargetAppCompatActivity,成功!");

    relativeLayout.addView(textView);
    setContentView(relativeLayout);
}
 
Example 14
Source File: BlogDateAdapter.java    From LoveTalkClient with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
	// TODO Auto-generated method stub
	AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	RelativeLayout ll = new RelativeLayout(mContext);
	ll.setLayoutParams(lp);
	ll.setGravity(Gravity.CENTER);

	RelativeLayout.LayoutParams lpblogTime = new RelativeLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpblogTime.setMargins(24, 10, 0, 0);
	TextView blogTime = getTextView();
	blogTime.setLayoutParams(lpblogTime);
	blogTime.setTextColor(Color.RED);
	blogTime.setText(listTime.get(position).toString());
	blogTime.setTextSize(14);
	blogTime.setPadding(0, 0, 0, 0);

	RelativeLayout.LayoutParams lpblogContent = new RelativeLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpblogContent.setMargins(0, 70, 0, 0);
	TextView blogContent = getTextView();
	blogContent.setLayoutParams(lpblogContent);
	blogContent.setTextColor(Color.BLACK);
	blogContent.setText(listBlog.get(position).toString());
	blogContent.setTextSize(14);
	blogContent.setPadding(0, 0, 0, 0);


	ll.addView(blogTime);
	ll.addView(blogContent);

	return ll;
}
 
Example 15
Source File: PluginAppCompatActivity.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, TAG + ":onCreate");

    RelativeLayout relativeLayout = new RelativeLayout(this);
    relativeLayout.setGravity(Gravity.CENTER);

    TextView textView = new TextView(this);
    textView.setText("启动插件APK中的PluginAppCompatActivity,成功!");

    relativeLayout.addView(textView);
    setContentView(relativeLayout);
}
 
Example 16
Source File: ConfirmPopup.java    From MyBookshelf with GNU General Public License v3.0 4 votes vote down vote up
@Nullable
protected View makeHeaderView() {
    if (null != headerView) {
        return headerView;
    }
    RelativeLayout topButtonLayout = new RelativeLayout(activity);
    int height = ConvertUtils.toPx(activity, topHeight);
    topButtonLayout.setLayoutParams(new RelativeLayout.LayoutParams(MATCH_PARENT, height));
    topButtonLayout.setBackgroundColor(topBackgroundColor);
    topButtonLayout.setGravity(Gravity.CENTER_VERTICAL);

    cancelButton = new TextView(activity);
    cancelButton.setVisibility(cancelVisible ? View.VISIBLE : View.GONE);
    RelativeLayout.LayoutParams cancelParams = new RelativeLayout.LayoutParams(WRAP_CONTENT, MATCH_PARENT);
    cancelParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    cancelParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    cancelButton.setLayoutParams(cancelParams);
    cancelButton.setBackgroundColor(Color.TRANSPARENT);
    cancelButton.setGravity(Gravity.CENTER);
    int padding = ConvertUtils.toPx(activity, topPadding);
    cancelButton.setPadding(padding, 0, padding, 0);
    if (!TextUtils.isEmpty(cancelText)) {
        cancelButton.setText(cancelText);
    }
    cancelButton.setTextColor(ConvertUtils.toColorStateList(cancelTextColor, pressedTextColor));
    if (cancelTextSize != 0) {
        cancelButton.setTextSize(cancelTextSize);
    }
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
            onCancel();
        }
    });
    topButtonLayout.addView(cancelButton);

    if (null == titleView) {
        TextView textView = new TextView(activity);
        RelativeLayout.LayoutParams titleParams = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
        int margin = ConvertUtils.toPx(activity, topPadding);
        titleParams.leftMargin = margin;
        titleParams.rightMargin = margin;
        titleParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
        titleParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
        textView.setLayoutParams(titleParams);
        textView.setGravity(Gravity.CENTER);
        if (!TextUtils.isEmpty(titleText)) {
            textView.setText(titleText);
        }
        textView.setTextColor(titleTextColor);
        if (titleTextSize != 0) {
            textView.setTextSize(titleTextSize);
        }
        titleView = textView;
    }
    topButtonLayout.addView(titleView);

    submitButton = new TextView(activity);
    RelativeLayout.LayoutParams submitParams = new RelativeLayout.LayoutParams(WRAP_CONTENT, MATCH_PARENT);
    submitParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    submitParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    submitButton.setLayoutParams(submitParams);
    submitButton.setBackgroundColor(Color.TRANSPARENT);
    submitButton.setGravity(Gravity.CENTER);
    submitButton.setPadding(padding, 0, padding, 0);
    if (!TextUtils.isEmpty(submitText)) {
        submitButton.setText(submitText);
    }
    submitButton.setTextColor(ConvertUtils.toColorStateList(submitTextColor, pressedTextColor));
    if (submitTextSize != 0) {
        submitButton.setTextSize(submitTextSize);
    }
    submitButton.setOnClickListener(v -> {
        dismiss();
        onSubmit();
    });
    topButtonLayout.addView(submitButton);

    return topButtonLayout;
}
 
Example 17
Source File: ConfirmPopup.java    From a with GNU General Public License v3.0 4 votes vote down vote up
@Nullable
protected View makeHeaderView() {
    if (null != headerView) {
        return headerView;
    }
    RelativeLayout topButtonLayout = new RelativeLayout(activity);
    int height = ConvertUtils.toPx(activity, topHeight);
    topButtonLayout.setLayoutParams(new RelativeLayout.LayoutParams(MATCH_PARENT, height));
    topButtonLayout.setBackgroundColor(topBackgroundColor);
    topButtonLayout.setGravity(Gravity.CENTER_VERTICAL);

    cancelButton = new TextView(activity);
    cancelButton.setVisibility(cancelVisible ? View.VISIBLE : View.GONE);
    RelativeLayout.LayoutParams cancelParams = new RelativeLayout.LayoutParams(WRAP_CONTENT, MATCH_PARENT);
    cancelParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    cancelParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    cancelButton.setLayoutParams(cancelParams);
    cancelButton.setBackgroundColor(Color.TRANSPARENT);
    cancelButton.setGravity(Gravity.CENTER);
    int padding = ConvertUtils.toPx(activity, topPadding);
    cancelButton.setPadding(padding, 0, padding, 0);
    if (!TextUtils.isEmpty(cancelText)) {
        cancelButton.setText(cancelText);
    }
    cancelButton.setTextColor(ConvertUtils.toColorStateList(cancelTextColor, pressedTextColor));
    if (cancelTextSize != 0) {
        cancelButton.setTextSize(cancelTextSize);
    }
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
            onCancel();
        }
    });
    topButtonLayout.addView(cancelButton);

    if (null == titleView) {
        TextView textView = new TextView(activity);
        RelativeLayout.LayoutParams titleParams = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
        int margin = ConvertUtils.toPx(activity, topPadding);
        titleParams.leftMargin = margin;
        titleParams.rightMargin = margin;
        titleParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
        titleParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
        textView.setLayoutParams(titleParams);
        textView.setGravity(Gravity.CENTER);
        if (!TextUtils.isEmpty(titleText)) {
            textView.setText(titleText);
        }
        textView.setTextColor(titleTextColor);
        if (titleTextSize != 0) {
            textView.setTextSize(titleTextSize);
        }
        titleView = textView;
    }
    topButtonLayout.addView(titleView);

    submitButton = new TextView(activity);
    RelativeLayout.LayoutParams submitParams = new RelativeLayout.LayoutParams(WRAP_CONTENT, MATCH_PARENT);
    submitParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    submitParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    submitButton.setLayoutParams(submitParams);
    submitButton.setBackgroundColor(Color.TRANSPARENT);
    submitButton.setGravity(Gravity.CENTER);
    submitButton.setPadding(padding, 0, padding, 0);
    if (!TextUtils.isEmpty(submitText)) {
        submitButton.setText(submitText);
    }
    submitButton.setTextColor(ConvertUtils.toColorStateList(submitTextColor, pressedTextColor));
    if (submitTextSize != 0) {
        submitButton.setTextSize(submitTextSize);
    }
    submitButton.setOnClickListener(v -> {
        dismiss();
        onSubmit();
    });
    topButtonLayout.addView(submitButton);

    return topButtonLayout;
}
 
Example 18
Source File: EmptyLayout.java    From AndroidEmptyLayout with Apache License 2.0 4 votes vote down vote up
private void changeEmptyType() {

        setDefaultValues();
        refreshMessages();

        // insert views in the root view
        if (!mViewsAdded) {
            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            lp.addRule(RelativeLayout.CENTER_IN_PARENT);
            mEmptyRelativeLayout = new RelativeLayout(getContext());
            mEmptyRelativeLayout.setGravity(Gravity.CENTER);
            mEmptyRelativeLayout.setLayoutParams(lp);
            if (mEmptyView!=null) mEmptyRelativeLayout.addView(mEmptyView);
            if (mLoadingView!=null) mEmptyRelativeLayout.addView(mLoadingView);
            if (mErrorView!=null) mEmptyRelativeLayout.addView(mErrorView);
            mViewsAdded = true;
            mEmptyRelativeLayout.setVisibility(VISIBLE);
            addView(mEmptyRelativeLayout);
        }


        // change empty type
            View loadingAnimationView = null;
            if (mLoadingAnimationViewId > 0) loadingAnimationView = findViewById(mLoadingAnimationViewId);
            switch (mEmptyType) {
                case TYPE_EMPTY:
                    if (mEmptyView!=null) mEmptyView.setVisibility(View.VISIBLE);
                    if (mErrorView!=null) mErrorView.setVisibility(View.GONE);
                    if (mLoadingView!=null) {
                        mLoadingView.setVisibility(View.GONE);
                        if (loadingAnimationView!=null && loadingAnimationView.getAnimation()!=null) loadingAnimationView.getAnimation().cancel();
                    }
                    break;
                case TYPE_ERROR:
                    if (mEmptyView!=null) mEmptyView.setVisibility(View.GONE);
                    if (mErrorView!=null) mErrorView.setVisibility(View.VISIBLE);
                    if (mLoadingView!=null) {
                        mLoadingView.setVisibility(View.GONE);
                        if (loadingAnimationView!=null && loadingAnimationView.getAnimation()!=null) loadingAnimationView.getAnimation().cancel();
                    }
                    break;
                case TYPE_LOADING:
                    if (mEmptyView!=null) mEmptyView.setVisibility(View.GONE);
                    if (mErrorView!=null) mErrorView.setVisibility(View.GONE);
                    if (mLoadingView!=null) {
                        mLoadingView.setVisibility(View.VISIBLE);
                        if (mLoadingAnimation != null && loadingAnimationView!=null) {
                            loadingAnimationView.startAnimation(mLoadingAnimation);
                        }
                        else if (loadingAnimationView!=null) {
                            loadingAnimationView.startAnimation(getRotateAnimation());
                        }
                    }
                    break;
                default:
                    break;
            }
    }
 
Example 19
Source File: TVShowActivity.java    From android with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    VideoCastManager.checkGooglePlayServices(this);

    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);

    setTheme(mPrefs.getString("current_theme", "holo_light").equals("holo_dark") ? R.style.AppThemeDark : R.style.AppThemeLight);

    super.onCreate(savedInstanceState);

    AppUtils.setStatusTint(this);
    Bundle extras = getIntent().getExtras();
    mSeries = extras.getString(ARG_SERIES);
    mLink = extras.getString(ARG_LINK);
    mImageUri = extras.getString(ARG_IMAGE_URI);
    mRating = extras.getInt(ARG_RATING);

    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);

    setContentView(R.layout.activity_tv_show);

    adlayout = (RelativeLayout) findViewById(R.id.ad);
    if (AppUtils.canShowAds(this)) {
        //Starting RevMob session
        RevMob revmob = RevMob.start(this); // RevMob App ID configured in the AndroidManifest.xml file
        RevMobBanner banner = revmob.createBanner(this);
        ArrayList<String> interests = new ArrayList<String>();
        interests.add("games");
        interests.add("mobile");
        interests.add("advertising");
        revmob.setUserInterests(interests);
        adlayout.addView(banner);
        adlayout.setGravity(Gravity.BOTTOM);
    }else{
        adlayout.setVisibility(View.GONE);
    }


    if (savedInstanceState == null) {
        FragmentManager fm = getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        ft.replace(R.id.fragment_container, SeasonsFragment.newInstance(mSeries, mLink, mImageUri, mRating));
        ft.commit();
    }

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(mSeries);

    if (AppUtils.isChromecastPluginInstalled(this)) {
        mCastManager = CastApplication.getCastManager(this.getApplicationContext());
    }
    // -- Adding MiniController
    mMini = (MiniController) findViewById(R.id.miniController1);
    if (mCastManager != null) {
        mCastManager.addMiniController(mMini);
    }

    mCastConsumer = new VideoCastConsumerImpl() {

        @Override
        public void onFailed(int resourceId, int statusCode) {

        }

        @Override
        public void onConnectionSuspended(int cause) {
            Log.d(TAG, "onConnectionSuspended() was called with cause: " + cause);
            AppUtils.showToast(TVShowActivity.this, R.string.connection_temp_lost);
        }

        @Override
        public void onConnectivityRecovered() {
            AppUtils.showToast(TVShowActivity.this, R.string.connection_recovered);
        }

        @Override
        public void onCastDeviceDetected(final MediaRouter.RouteInfo info) {
            if (!SettingsActivity.isFtuShown(TVShowActivity.this)) {
                SettingsActivity.setFtuShown(TVShowActivity.this);

                Log.d(TAG, "Route is visible: " + info);
                new Handler().postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        if (mediaRouteMenuItem.isVisible()) {
                            Log.d(TAG, "Cast Icon is visible: " + info.getName());
                            showFtu();
                        }
                    }
                }, 1000);
            }
        }
    };

    if (mCastManager != null) {
        mCastManager.reconnectSessionIfPossible(this, false);
    }
}
 
Example 20
Source File: BlogAdapter.java    From LoveTalkClient with Apache License 2.0 4 votes vote down vote up
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
	// TODO Auto-generated method stub
	AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	RelativeLayout ll = new RelativeLayout(mContext);
	ll.setLayoutParams(lp);
	ll.setGravity(Gravity.CENTER);

	RelativeLayout.LayoutParams lpblogTime = new RelativeLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpblogTime.setMargins(250, 10, 0, 0);
	final TextView blogTime = getTextView();
	blogTime.setLayoutParams(lpblogTime);
	blogTime.setTextColor(Color.RED);
	blogTime.setText(listTime.get(position).toString());
	blogTime.setTextSize(14);
	blogTime.setPadding(0, 0, 0, 0);

	RelativeLayout.LayoutParams lpblogContent = new RelativeLayout.LayoutParams(
			600, LayoutParams.WRAP_CONTENT);
	lpblogContent.setMargins(0, 70, 0, 0);
	final TextView blogContent = getTextView();
	blogContent.setLayoutParams(lpblogContent);
	blogContent.setTextColor(Color.GRAY);
	blogContent.setText(listBlog.get(position).toString());
	blogContent.setTextSize(14);
	blogContent.setPadding(0, 0, 0, 0);

	ll.addView(blogTime);
	ll.addView(blogContent);

	ll.setOnClickListener(new OnClickListener() {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			blogContent.setTextColor(Color.BLACK);
		}
	});

	return ll;
}