Java Code Examples for android.support.v4.widget.SwipeRefreshLayout#setColorSchemeResources()

The following examples show how to use android.support.v4.widget.SwipeRefreshLayout#setColorSchemeResources() . 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: SecondLayerFragment.java    From Netease with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreateViewLazy(Bundle savedInstanceState) {
	super.onCreateViewLazy(savedInstanceState);
	tabName = getArguments().getString(INTENT_STRING_TABNAME);
	position = getArguments().getInt(INTENT_INT_POSITION);
	//临时处理下
	position = position % 5;
	indexModel = new IndexModel();

	setContentView(R.layout.fragment_tabmain_item);

	swiper = (SwipeRefreshLayout)findViewById(R.id.swipe_refresh);
	swiper.setOnRefreshListener(this);
	swiper.setColorSchemeResources(android.R.color.holo_green_light,
			android.R.color.holo_green_dark);

       mRecyclerView = (RecyclerView)findViewById(R.id.rv_recycler_view);
	llm = new LinearLayoutManager(getActivity());
       mRecyclerView.setLayoutManager(llm);
	normalRecyclerViewAdapter = new NormalRecyclerViewAdapter(getActivity(), mOneNewsItemList, mRecyclerView);
       mRecyclerView.setAdapter(normalRecyclerViewAdapter);
	getIndexNews();
	setOnLoadMoreListerner();
}
 
Example 2
Source File: BaseActivity.java    From v2ex with Apache License 2.0 6 votes vote down vote up
private void trySetupSwipeRefresh() {
    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
    if (mSwipeRefreshLayout != null) {
        mSwipeRefreshLayout.setColorSchemeResources(
                R.color.refresh_progress_1,
                R.color.refresh_progress_2,
                R.color.refresh_progress_3);
        mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                requestDataRefresh();
            }
        });

        if (mSwipeRefreshLayout instanceof MultiSwipeRefreshLayout) {
            MultiSwipeRefreshLayout mswrl = (MultiSwipeRefreshLayout) mSwipeRefreshLayout;
            mswrl.setCanChildScrollUpCallback(this);
        }
    }
}
 
Example 3
Source File: ClosedTickets.java    From faveo-helpdesk-android-app with Open Software License 3.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    if (rootView == null) {
        rootView = inflater.inflate(R.layout.fragment_recycler, container, false);
        textViewTotalCount= (TextView) rootView.findViewById(R.id.totalcount);
        swipeRefresh = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefresh);
        if (InternetReceiver.isConnected()){
            swipeRefresh.setRefreshing(true);
            new FetchFirst(getActivity()).execute();
        }


        swipeRefresh.setColorSchemeResources(R.color.faveo_blue);
        swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                new FetchFirst(getActivity()).execute();
            }
        });
        tv = (TextView) rootView.findViewById(R.id.empty_view);
    }
    //  ((MainActivity) getActivity()).setActionBarTitle(getString(R.string.closed_tickets));
    return rootView;
}
 
Example 4
Source File: NewFragment.java    From Girls with Apache License 2.0 5 votes vote down vote up
@Override
protected void initView() {
    mSwipeRefreshLayout = (SwipeRefreshLayout) context.findViewById(R.id.sw_layout);
    mRecyclerView = (RecyclerView) context.findViewById(R.id.receiverview);

    mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
    mSwipeRefreshLayout.setOnRefreshListener(this);
}
 
Example 5
Source File: RankDetailsFragment.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
@Override
public View initView(LayoutInflater inflater, @Nullable ViewGroup container,
                     @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_rank_details, container, false);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
    mRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh);
    mRefreshLayout.setColorSchemeResources(R.color.colorPrimary, R.color.pink_500,
            R.color.purple_500, R.color.blue_500);
    mUrl = getArguments().getString("url");
    return view;
}
 
Example 6
Source File: BaseFragment.java    From V2EX with GNU General Public License v3.0 5 votes vote down vote up
protected void setSwipeRefreshTheme(SwipeRefreshLayout swipeRefreshLayout){
    if (!(getActivity() instanceof BaseActivity)){
        return;
    }
    swipeRefreshLayout.setColorSchemeResources(
            getResolveAttrId(R.attr.attr_color_accent),
            getResolveAttrId(R.attr.attr_color_primary_dark));
}
 
Example 7
Source File: InboxTickets.java    From faveo-helpdesk-android-app with Open Software License 3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    if (rootView == null) {
        rootView = inflater.inflate(R.layout.fragment_recycler, container, false);
        swipeRefresh = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefresh);
        recyclerView = (RecyclerView) rootView.findViewById(R.id.cardList);
        recyclerView.setHasFixedSize(false);
        textViewTotalCount= (TextView) rootView.findViewById(R.id.totalcount);
        final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(linearLayoutManager);

        if (InternetReceiver.isConnected()){
            swipeRefresh.setRefreshing(true);
            new FetchFirst(getActivity()).execute();
        }

        swipeRefresh.setColorSchemeResources(R.color.faveo_blue);
        swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                new FetchFirst(getActivity()).execute();
            }
        });
        tv = (TextView) rootView.findViewById(R.id.empty_view);
    }
   // ((MainActivity) getActivity()).setActionBarTitle(getString(R.string.inbox_tickets));
    return rootView;
}
 
Example 8
Source File: MainFragment.java    From CSDN with Apache License 2.0 5 votes vote down vote up
private void initView() {
    mSwipeRefresh = (SwipeRefreshLayout) getView().findViewById(R.id.id_swiperefresh);
    mSwipeRefresh.setColorSchemeResources(R.color.colorPrimary, R.color.colorPrimary,
            R.color.colorPrimary, R.color.colorPrimary);
    mRecycleView = (RecyclerView) getView().findViewById(R.id.id_recycleview);
    mManager = new LinearLayoutManager(getActivity());
    mRecycleView.setLayoutManager(mManager);
    mRecycleView.setItemAnimator(new DefaultItemAnimator());
}
 
Example 9
Source File: MyGroupFragment.java    From Social with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.my_group_fragment_layout,container,false);

    handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what){
                case OkhttpUtil.MESSAGE_MY_GROUP_LIST:
                    handleMyGroupList(msg);
                    break;
            }
        }
    };

    listView = (ListView)view.findViewById(R.id.id_my_group_fg_listview);
    listView.setOnItemClickListener(this);
    list_mygroup = new ArrayList<>();
    getMyGroupList();

    intentFilter = new IntentFilter();
    intentFilter.addAction("com.allever.social.refresh_group_list");
    intentFilter.addAction("com.allever.social.refresh_my_group_group_list");
    receiver = new AddGroupReceiver();
    getActivity().registerReceiver(receiver, intentFilter);

    swipeRefreshLayout = (SwipeRefreshLayout)view.findViewById(R.id.id_my_group_fg_refresh);
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.colorAccent, R.color.colorPrimary,
            com.hyphenate.easeui.R.color.holo_orange_light, com.hyphenate.easeui.R.color.holo_red_light);

    return view;
}
 
Example 10
Source File: BaseFragment.java    From hr with GNU Affero General Public License v3.0 5 votes vote down vote up
public void setHasSwipeRefreshView(View parent, int resource_id,
                                   SwipeRefreshLayout.OnRefreshListener listener) {
    mSwipeRefresh = (SwipeRefreshLayout) parent.findViewById(resource_id);
    mSwipeRefresh.setOnRefreshListener(listener);
    mSwipeRefresh.setColorSchemeResources(R.color.android_blue,
            R.color.android_green,
            R.color.android_orange_dark,
            R.color.android_red);
}
 
Example 11
Source File: RadicalsFragment.java    From WaniKani-for-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
    rootView = layoutInflater.inflate(R.layout.fragment_radicals, viewGroup, false);

    mMessageSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.radicals_message_swipe_refresh);
    mMessageSwipeRefreshLayout.setOnRefreshListener(this);
    mMessageSwipeRefreshLayout.setColorSchemeResources(R.color.swipe_refresh);

    mGrid = (StickyGridHeadersGridView) rootView.findViewById(R.id.radicals_grid);
    mGrid.setOnItemClickListener(new gridItemClickListener());

    mListFlipper = (ViewFlipper) rootView.findViewById(R.id.radicals_list_flipper);
    mMessageFlipper = (ViewFlipper) rootView.findViewById(R.id.radicals_message_flipper);

    mMessageIcon = (ImageView) rootView.findViewById(R.id.radicals_message_icon);
    mMessageTitle = (TextView) rootView.findViewById(R.id.radicals_message_title);
    mMessageSummary = (TextView) rootView.findViewById(R.id.radicals_message_summary);

    if (!PrefManager.isLegendLearned()) {
        showLegend();
    }

    fetchLevelAndData();

    setHasOptionsMenu(true);

    return rootView;
}
 
Example 12
Source File: HomeFragment.java    From NHentai-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {
	View view = inflater.inflate(R.layout.fragment_home, container, false);

	mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout);
	mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
	mLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
	mRecyclerView.setLayoutManager(mLayoutManager);
	mRecyclerView.setHasFixedSize(true);

	mBooks = new ArrayList<>();
	mAdapter = new BookListRecyclerAdapter(mRecyclerView, mBooks);
	setRecyclerViewAdapter(mAdapter);

	mSwipeRefreshLayout.setColorSchemeResources(
			R.color.deep_purple_500, R.color.pink_500, R.color.orange_500, R.color.brown_500,
			R.color.indigo_500, R.color.blue_500, R.color.teal_500, R.color.green_500
	);
	mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
		@Override
		public void onRefresh() {
			if (!mSwipeRefreshLayout.isRefreshing()) {
				mSwipeRefreshLayout.setRefreshing(true);
			}

			mBooks = new ArrayList<>();
			mAdapter = new BookListRecyclerAdapter(mRecyclerView, mBooks);
			setRecyclerViewAdapter(mAdapter);
			new PageGetTask().execute(mNowPage = 1);
		}
	});

	new PageGetTask().execute(mNowPage);

	return view;
}
 
Example 13
Source File: BaseHomeFragment.java    From ExpressHelper with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
	View rootView = inflater.inflate(R.layout.fragment_home, container, false);

	if (mSets == null) {
		mSets = Settings.getInstance(getActivity().getApplicationContext());
	}

	refreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefreshLayout);

	mRecyclerView = (ObservableRecyclerView) rootView.findViewById(R.id.scroll);
	mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
	mRecyclerView.setHasFixedSize(true);
	headerView = inflater.inflate(R.layout.padding, null);

	Activity parentActivity = getActivity();
	context = parentActivity.getApplicationContext();
	if (parentActivity instanceof ObservableScrollViewCallbacks) {
		// Scroll to the specified position after layout
		Bundle args = getArguments();
		if (args != null && args.containsKey(ARG_INITIAL_POSITION)) {
			final int initialPosition = args.getInt(ARG_INITIAL_POSITION, 0);
			ScrollUtils.addOnGlobalLayoutListener(mRecyclerView, new Runnable() {
				@Override
				public void run() {
					mRecyclerView.scrollVerticallyToPosition(initialPosition);
				}
			});
		}
		mRecyclerView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
	}

	refreshLayout.setProgressViewEndTarget(
			true,
			getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_default_height_material) +
					getResources().getDimensionPixelOffset(R.dimen.tab_height)
	);
	refreshLayout.setColorSchemeResources(R.color.blue_500);
	refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
		@Override
		public void onRefresh() {
			mHandler.sendEmptyMessage(FLAG_REFRESH_LIST);
		}
	});

	mDB = ((MainActivity) getActivity()).mExpressDB;
	setUpAdapter();

	return rootView;
}
 
Example 14
Source File: BaseListFragment.java    From FlowGeek with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onViewCreated(final View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh);
    mListView = (RecyclerView) view.findViewById(R.id.list_view);
    mErrorLayout = (ErrorLayout) view.findViewById(R.id.error_frame);


    if (getRefreshable()){
        mSwipeRefreshLayout.setOnRefreshListener(this);
        mSwipeRefreshLayout.setColorSchemeResources(
                R.color.swipe_refresh_first, R.color.swipe_refresh_second,
                R.color.swipe_refresh_third, R.color.swipe_refresh_four
        );
        mSwipeRefreshLayout.setProgressBackgroundColorSchemeResource(
                UIHelper.getAttrResourceFromTheme(R.attr.refresh_progress_background, getActivity().getTheme())
        );
    }

    mErrorLayout.setOnActiveClickListener(this);

    mListView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
    mListView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(getActivity())
            .color(setDividerColor())
            .size(setDividerSize())
            .build());

    if (mAdapter!=null){
        mListView.setAdapter(mAdapter);
    }else{
        mAdapter = onSetupAdapter();
        mListView.setAdapter(mAdapter);
        mAdapter.setOnLoadingListener(this);
        mErrorLayout.setState(ErrorLayout.LOADING);
    }


    if (savedInstanceState != null){
        if (mState == STATE_REFRESHING && getRefreshable()
                && savedInstanceState.getInt(BUNDLE_STATE_REFRESH, STATE_NONE) == STATE_REFRESHING){
            mSwipeRefreshLayout.post(new Runnable() {
                @Override
                public void run() {
                    mSwipeRefreshLayout.setRefreshing(true);
                }
            });
        }

        if (mState == STATE_CACHE_LOADING && getRefreshable()
                && savedInstanceState.getInt(BUNDLE_STATE_REFRESH, STATE_NONE) == STATE_CACHE_LOADING){
            mErrorLayout.setState(ErrorLayout.LOADING);
        }
    }

}
 
Example 15
Source File: FirstFragment.java    From myapplication with Apache License 2.0 4 votes vote down vote up
private void initViews() {
        isConnected = SystemUtils.checkNetworkConnection(getActivity());

        mRelativeLayout = (RelativeLayout) view.findViewById(R.id.home_title_rout);
        TextView titleTextTv = (TextView) view.findViewById(R.id.home_title_tv);
        ImageView titleRightImv = (ImageView) view.findViewById(R.id.title_right_imv);
        titleTextTv.setText(getTime());

        refreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.home_refreshLayout);
        refreshLayout.setColorSchemeResources(
                R.color.swipeRefreshLayout,
                R.color.swipeRefreshLayout,
                R.color.swipeRefreshLayout,
                R.color.swipeRefreshLayout);

        homeListView = (ListView) view.findViewById(R.id.home_listView);
        adapter = new NewsAdapter(getActivity(), R.layout.home_listview_item);
        homeListView.setAdapter(adapter);

        if (isConnected) new HomeLoadNewsTask(adapter).execute();
        else SystemUtils.noNetworkAlert(getActivity());

        // 双击事件,回顶部栏
        mRelativeLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //实现数组的移位操作,点击一次,左移一位,末尾补上当前开机时间(cpu的时间)
                System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);
                mHits[mHits.length - 1] = SystemClock.uptimeMillis();

                //双击事件的时间间隔500ms
                if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) {
                    Log.i("TAG", "I am here!");

//                    mScrollView.scrollTo(0, 0);  // 滑动置顶部
                    homeListView.setSelection(0);
                    homeListView.setSelectionAfterHeaderView();
                    homeListView.smoothScrollToPosition(0);
                }
            }
        });
    }
 
Example 16
Source File: ListViewActivity.java    From Airbnb-Android-Google-Map-View with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list_view);

    getSupportActionBar().setTitle("List View");
    mSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
    mRecyclerView = (RecyclerView) findViewById(R.id.rv_lisiting);

    mLoadingMoreDataProgress = (ProgressBar) findViewById(R.id.loading_progress);


    mLoadingMoreDataProgress.getIndeterminateDrawable().setColorFilter(0xff00b1c7, PorterDuff.Mode.MULTIPLY);
    mLoadingMoreDataProgress.setVisibility(View.GONE);


    mRecyclerView.setHasFixedSize(false);
    mLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mAdapter = new ListViewAdapter(mAddressList, this);
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.requestLayout();

    mSwipeLayout.setColorSchemeResources(R.color.gomalan_bule_bg);

    mAddressModel=new AddressModel(this, new BaseInterface() {
        @Override
        public void handleNetworkCall(Object object, int requestCode) {
            if (requestCode == NetworkConstants.ADDRESS_REQUEST) {
                if (object instanceof ArrayList) {
                    mAddressList = new ArrayList<>();
                    mAddressList = (ArrayList) object;
                    mAdapter = new ListViewAdapter(mAddressList, ListViewActivity.this);
                    mRecyclerView.setAdapter(mAdapter);
                    mAdapter.notifyDataSetChanged();
                }
                else{
                    Toast.makeText(ListViewActivity.this, (String)object,Toast.LENGTH_LONG).show();
                }
            }
        }
    });



    mAddressModel.fetchAddressFromServer();

}
 
Example 17
Source File: RefreshAndLoadFragment.java    From meiShi with Apache License 2.0 4 votes vote down vote up
@Override
protected void onFragmentCreate() {
    mSwipeRefreshWidget = (SwipeRefreshLayout) getView().findViewById(R.id.swipe_refresh_widget);
    mSwipeRefreshWidget.setColorSchemeResources(R.color.colorPrimary);
    mSwipeRefreshWidget.setOnRefreshListener(this);
}
 
Example 18
Source File: TopicActivity.java    From Android-Carbon-Forum with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //注册一个广播用于回复成功时,刷新主题
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction("action.refreshTopic");
    LocalBroadcastManager.getInstance(this).registerReceiver(mRefreshTopicBroadcastReceiver, intentFilter);
    //取得启动该Activity的Intent对象
    Intent mIntent = getIntent();
    //取出Intent中附加的数据
    mTopic = mIntent.getStringExtra("Topic");
    mTopicID = mIntent.getStringExtra("TopicID");
    mTopicPage = mIntent.getStringExtra("TargetPage");
    setContentView(R.layout.activity_topic);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if(mTopic != null) {
        getSupportActionBar().setTitle(mTopic);
    }
    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.activity_topic_swipe_refresh_layout);
    mSwipeRefreshLayout.setColorSchemeResources(
            R.color.material_light_blue_700,
            R.color.material_red_700,
            R.color.material_orange_700,
            R.color.material_light_green_700
    );
    mSwipeRefreshLayout.setOnRefreshListener(this);
    /*
    if(Integer.parseInt(mTopicPage) == 1) {
        mTopicTitle = (TextView) findViewById(R.id.title);
        mTopicTitle.setText(mTopic);
    }
    */
    //RecyclerView
    mRecyclerView = (RecyclerView) findViewById(R.id.post_list);
    mRecyclerView.setHasFixedSize(true);
    final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                int lastVisibleItem = layoutManager.findLastCompletelyVisibleItemPosition();
                int totalItemCount = layoutManager.getItemCount();
                if (lastVisibleItem >= (totalItemCount - 5) && enableScrollListener && currentPage < totalPage) {
                    loadPost(currentPage + 1);
                }
            }
        }
    });
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mAdapter = new PostAdapter(this, false);
    mAdapter.setData(postList);
    mRecyclerView.setAdapter(mAdapter);

    mFloatingActionButton = (FloatingActionButton) findViewById(R.id.fab);
    mFloatingActionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(TopicActivity.this, ReplyActivity.class);
            intent.putExtra("TopicID", mTopicID);
            intent.putExtra("PostID", "0");
            intent.putExtra("PostFloor", "0");
            intent.putExtra("UserName", "0");
            intent.putExtra("DefaultContent", "");
            startActivity(intent);
        }
    });
    if(!CarbonForumApplication.isLoggedIn()){
        mFloatingActionButton.setVisibility(View.INVISIBLE);
    }
    loadPost(Integer.parseInt(mTopicPage));
}
 
Example 19
Source File: TenDayForecastFragment.java    From android-weather with MIT License 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    //Set up the xml layout
    View rootView = inflater.inflate(R.layout.fragment_main, container, false);

    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.rv);
    mCoordinatorLayoutView = rootView.findViewById(R.id.tendayforecast_coordinator_layout);

    // use this setting to improve performance if you know that changes
    // in content do not change the layout size of the RecyclerView
    mRecyclerView.setHasFixedSize(true);

    mLayoutManager = new LinearLayoutManager(this.getActivity());
    mRecyclerView.setLayoutManager(mLayoutManager);
    // Set up initial adapter (until we retrieve our data) so there is no skipping the layout
    mRecyclerView.setAdapter(new RecyclerAdapter(getActivity(), new ArrayList<Day>(), null));


    // Attempt to restore weather data from savedInstanceState
    if (savedInstanceState != null) {
        days = savedInstanceState.getParcelableArrayList(SAVED_DAYS);
        if (mRecyclerAdapter == null) {
            initializeAdapter();
        } else {
            mRecyclerAdapter.notifyDataSetChanged();
        }
    }
    // If we couldn't retrieve days from a saved instance state
    if (days == null || days.size() == 0) {
        initializeData();
    }

    mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.tendayforecast_swipe_refresh_layout);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            initializeData();
            initializeAdapter();
            mRecyclerView.refreshDrawableState();
        }
    });
    mSwipeRefreshLayout.setColorSchemeResources(R.color.swiperefresh);

    return rootView;
}
 
Example 20
Source File: U.java    From datmusic-android with Apache License 2.0 2 votes vote down vote up
/**
 * Setting colors to swiperefreshlayout
 *
 * @param swipeRefreshLayout swprl
 */
public static void setColorScheme(SwipeRefreshLayout swipeRefreshLayout) {
    swipeRefreshLayout.setColorSchemeResources(R.color.primary, R.color.sea_green, R.color.yellow, R.color.red);
}