Java Code Examples for android.widget.GridView

The following examples show how to use android.widget.GridView. These examples are extracted from open source projects. 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 Project: letv   Source File: ListViewActivity.java    License: Apache License 2.0 6 votes vote down vote up
protected void onCreate(Bundle bundle) {
    z.c();
    super.onCreate(bundle);
    if (getIntent() != null) {
        this.a = (c) getIntent().getSerializableExtra(z);
        c cVar = this.a;
        z.c();
        View gridView = new GridView(getApplicationContext());
        gridView.setNumColumns(2);
        List list = cVar.u;
        gridView.setAdapter(new e(this, Integer.MIN_VALUE, list));
        gridView.setOnItemClickListener(new d(this, list));
        setContentView(gridView);
        return;
    }
    z.d();
}
 
Example 2
Source Project: pearl   Source File: DisplayActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_display);
    ArrayList<String> listofURLs= new ArrayList<String>();
     listofURLs = getIntent().getStringArrayListExtra("list");


    //Used for testing purpose. It works
  //  Object ret = Pearl.retrieveJsonObject("0tag");
    //Toast.makeText(DisplayActivity.this, ""+ret.toString(), Toast.LENGTH_SHORT).show();
    //Log.d("Checksum",""+ret.toString());

    final ClassicAdapter adapter = new ClassicAdapter(DisplayActivity.this, listofURLs);
    grid=(GridView)findViewById(R.id.grid);
    grid.setAdapter(adapter);
    grid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

            Toast.makeText(DisplayActivity.this, "Position " + adapterView.getChildAt(i).getTag()   + "", Toast.LENGTH_SHORT).show();
        }
    });
}
 
Example 3
Source Project: TraceByAmap   Source File: PoiListAdapter.java    License: MIT License 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
        holder = new ViewHolder();
        convertView = View.inflate(ctx, R.layout.listview_item, null);
        holder.poititle = (TextView) convertView
               .findViewById(R.id.poititle);
        holder.subpois = (GridView) convertView.findViewById(R.id.listview_item_gridview);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    PoiItem item = list.get(position);
    holder.poititle.setText(item.getTitle());
    if (item.getSubPois().size() > 0) {
        List<SubPoiItem> subPoiItems = item.getSubPois();
        SubPoiAdapter subpoiAdapter=new SubPoiAdapter(ctx, subPoiItems); 
        holder.subpois.setAdapter(subpoiAdapter); 
    }


    return convertView;
}
 
Example 4
Source Project: BiliShare   Source File: BaseSharePlatformSelector.java    License: Apache License 2.0 6 votes vote down vote up
protected static GridView createShareGridView(final Context context, AdapterView.OnItemClickListener onItemClickListener) {
    GridView grid = new GridView(context);
    ListAdapter adapter = new ArrayAdapter<ShareTarget>(context, 0, shareTargets) {
        // no need scroll
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.bili_socialize_shareboard_item, parent, false);
            view.setBackgroundDrawable(null);
            ImageView image = (ImageView) view.findViewById(R.id.bili_socialize_shareboard_image);
            TextView platform = (TextView) view.findViewById(R.id.bili_socialize_shareboard_pltform_name);

            ShareTarget target = getItem(position);
            image.setImageResource(target.iconId);
            platform.setText(target.titleId);
            return view;
        }
    };
    grid.setNumColumns(-1);
    grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
    grid.setColumnWidth(context.getResources().getDimensionPixelSize(R.dimen.bili_socialize_shareboard_size));
    grid.setLayoutParams(new ViewGroup.LayoutParams(-1, -2));
    grid.setSelector(R.drawable.bili_socialize_selector_item_background);
    grid.setAdapter(adapter);
    grid.setOnItemClickListener(onItemClickListener);
    return grid;
}
 
Example 5
Source Project: MediaChooser   Source File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);
    folderViewButton = (Button) findViewById(R.id.folderButton);
    fileViewButton = (Button) findViewById(R.id.fileButton);
    gridView = (GridView) findViewById(R.id.gridView);
    folderViewButton.setOnClickListener(clickListener);
    fileViewButton.setOnClickListener(clickListener);

    IntentFilter videoIntentFilter = new IntentFilter(MediaChooser.VIDEO_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
    registerReceiver(videoBroadcastReceiver, videoIntentFilter);

    IntentFilter imageIntentFilter = new IntentFilter(MediaChooser.IMAGE_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
    registerReceiver(imageBroadcastReceiver, imageIntentFilter);

}
 
Example 6
Source Project: PictureChooseLib   Source File: GalleryChooseActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gallery_choose);
    mGalleryGrid = (GridView) findViewById(R.id.pi_gallery_choose_grid);
    if(getIntent() != null){
        mTitleBarBackground = getIntent().getIntExtra(Constants.TITLE_BAR_BACKGROUND,mTitleBarBackground);
    }
    setTitleBarBackground(mTitleBarBackground);
    setTitleText(R.string.ps_gallery_choose);
    setRightText(R.string.ps_cancel);
    mGalleryList = new ArrayList<>();
    mGalleryChooseAdapter = new GalleryChooseAdapter(this,mGalleryList);
    mGalleryGrid.setAdapter(mGalleryChooseAdapter);
    mGalleryGrid.setOnItemClickListener(this);
    getGalleryList();
}
 
Example 7
Source Project: android-DoneBar   Source File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Prepare list of samples in this dashboard.
    mSamples = new Sample[]{
        new Sample(R.string.donebaractivity_title, R.string.donebaractivity_description,
                DoneBarActivity.class),
        new Sample(R.string.donebuttonactivity_title, R.string.donebuttonactivity_description,
                DoneButtonActivity.class),
    };

    // Prepare the GridView
    mGridView = (GridView) findViewById(android.R.id.list);
    mGridView.setAdapter(new SampleAdapter());
    mGridView.setOnItemClickListener(this);
}
 
Example 8
Source Project: Huochexing12306   Source File: EditImageAty.java    License: Apache License 2.0 6 votes vote down vote up
private void initViews() {
	GridView gvIcons = (GridView) findViewById(R.id.icons);
	SimpleAdapter adapter = new SimpleAdapter(this, getIcons(),
			R.layout.item_editimage, new String[] { "item", "resId" },
			new int[] { R.id.item_editimage_ivIcon,
					R.id.item_editimaeg_tvResId });
	gvIcons.setAdapter(adapter);
	gvIcons.setOnItemClickListener(new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
				long arg3) {
			TextView tv1 = (TextView) arg1
					.findViewById(R.id.item_editimaeg_tvResId);
			int resId = Integer.valueOf(tv1.getText().toString());
			Intent intent = new Intent();
			intent.putExtra(RESULT, resId);
			EditImageAty.this.setResult(EditImageAty.this.getIntent()
					.getIntExtra(C_RESULT_CODE, 0), intent);
			EditImageAty.this.finish();
		}
	});
}
 
Example 9
Source Project: AndroidAll   Source File: GridLayoutAnimationFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void initViews(View view) {
    super.initViews(view);

    setLabel("GridLayoutAnimation");

    GridView grid = view.findViewById(R.id.grid_view);
    dataList.addAll(getData());
    mGridAdapter = new GridAdapter();
    grid.setAdapter(mGridAdapter);


    Button addData = view.findViewById(R.id.btn_start);
    addData.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            addData();
        }
    });
}
 
Example 10
Source Project: Contacts   Source File: GridDialogFragment.java    License: MIT License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
	View view = inflater.inflate(getCustomLayout(), container, false);

	gridView = (GridView) view.findViewById(R.id.grid);

	View emptyView = getEmptyView();

	if (emptyView != null)
	{
		emptyView.setId(android.R.id.empty);

		((ViewGroup) gridView.getParent()).addView(emptyView);

		gridView.setEmptyView(emptyView);
	}

	return view;
}
 
Example 11
Source Project: MobileGuard   Source File: MainActivity.java    License: MIT License 6 votes vote down vote up
/**
     * 1
     * init view
     */
    protected void initView() {
        setContentView(R.layout.activity_main);
        // bind
        gvMenu = (GridView) findViewById(R.id.gv_menu);
//        ivLightEffect = (ImageView) findViewById(R.id.iv_light_effect);
        rlCircle = findViewById(R.id.rl_circle);
        tvRamUseRate = (TextView) findViewById(R.id.tv_ram_use_rate);

        // start animation
        Animation rotateAnimation = AnimationUtils.loadAnimation(this, R.anim.rotate_forever);
        rlCircle.startAnimation(rotateAnimation);

//        Animation blinkAnimation = AnimationUtils.loadAnimation(this, R.anim.blink_forever);
//        ivLightEffect.startAnimation(blinkAnimation);
    }
 
Example 12
Source Project: BigApp_Discuz_Android   Source File: ThreadReplyActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean initWidget() {
    ActionBarUtils.setHomeActionBar(this, R.drawable.ic_back);


    gridView = (GridView) findViewById(R.id.gridView);
    et = (EmoticonsEditText) findViewById(R.id.et);
    et1 = (EmoticonsEditText) findViewById(R.id.et1);
    tb = (ToggleButton) findViewById(R.id.tb);
    spinner = (BetterSpinner) findViewById(R.id.spinner);
    chooseThread = (TextView) findViewById(R.id.chooseThread);

    tb.setOnClickListener(this);

    et1.setVisibility(View.GONE);

    if (!FileUtils.isExists(SmileyUtils.getSmileyZipFilePath(this))) {
        tb.setVisibility(View.GONE);
    }

    return super.initWidget();
}
 
Example 13
Source Project: palmsuda   Source File: MainViewHelper.java    License: Apache License 2.0 6 votes vote down vote up
private GridView createGridView(List<ModuleItem> items) {
	GridView gView = (GridView) mInflater.inflate(R.layout.main_gridview,
			null);
	gView.setVerticalSpacing(vspace);
	gView.setPadding(0, vspace / 2, 0, 0);
	GdvAdapter adapter = new GdvAdapter(mActivity,
			mActivity.getImageWorker(), gView);
	adapter.setData(items);
	gView.setAdapter(adapter);
	gView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
		@Override
		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
				long arg3) {
			ModuleItem item = (ModuleItem) arg0.getAdapter().getItem(arg2);
			mActivity.gridViewClick(mAItem, item);
		}
	});
	return gView;
}
 
Example 14
Source Project: Contacts   Source File: GridFragment.java    License: MIT License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
	View view = inflater.inflate(getCustomLayout(), container, false);

	gridView = (GridView) view.findViewById(R.id.grid);

	View emptyView = getEmptyView();

	if (emptyView != null)
	{
		emptyView.setId(android.R.id.empty);

		((ViewGroup) gridView.getParent()).addView(emptyView);

		gridView.setEmptyView(emptyView);
	}

	return view;
}
 
Example 15
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	gridView = (GridView) inflater.inflate(R.layout.date_grid_fragment,
			container, false);
	// Client normally needs to provide the adapter and onItemClickListener
	// before the fragment is attached to avoid complex crash due to
	// fragment life cycles
	if (gridAdapter != null) {
		gridView.setAdapter(gridAdapter);
	}

	if (onItemClickListener != null) {
		gridView.setOnItemClickListener(onItemClickListener);
	}
	if(onItemLongClickListener != null) {
		gridView.setOnItemLongClickListener(onItemLongClickListener);
	}
	return gridView;
}
 
Example 16
Source Project: SVG-Android   Source File: IconSampleActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_icon_sample);
    setTitle(getIntent().getStringExtra("title"));

    GridView gridView = (GridView) findViewById(R.id.icon_grid);
    gridView.setAdapter(new ArrayAdapter<Integer>(this, R.layout.item_icon, ICONS) {

        @NonNull
        @Override
        public View getView(int position, android.view.View convertView, @NonNull ViewGroup parent) {
            ViewHolder holder;
            if (convertView == null) {
                convertView = LayoutInflater.from(IconSampleActivity.this).inflate(R.layout.item_icon, parent, false);
                holder = new ViewHolder();
                holder.imageview = (ImageView)(convertView.findViewById(R.id.item_image));
                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }
            holder.imageview.setImageResource(ICONS[position]);
            return convertView;
        }
    });
}
 
Example 17
Source Project: GreenDamFileExploere   Source File: VideoActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_video);
    mViewNothing = findViewById(R.id.nothing);

    mGridView = (GridView) findViewById(R.id.mVideoGrideView);
    mAdapter = new VideoGridViewAdapter(this, mVideos, mGridView);
    mGridView.setAdapter(mAdapter);

    mGridView.setOnItemClickListener(this);
    mGridView.setOnItemLongClickListener(this);

    mThread = new VideoLoadThread();
    mThread.start();
}
 
Example 18
Source Project: MyHearts   Source File: CityActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void initView() {

    initData();

    View view = View.inflate(this, R.layout.head_city_list, null);
    gridView = (GridView) view.findViewById(R.id.gridview_hot);
    gridViewAdapter = new CityGridViewAdapter(this, hotCity);
    gridView.setAdapter(gridViewAdapter);
    gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));

    sideBar = (SideBar) findViewById(R.id.sidrbar);
    dialog = (TextView) findViewById(R.id.dialog);
    sideBar.setTextView(dialog);

    sortListView = (ListView) findViewById(R.id.country_lvcountry);
    sortListView.addHeaderView(view);
    adapter = new SortAdapter(this, SourceDateList);
    sortListView.setAdapter(adapter);
    clearEditText = (ClearCityEditText) findViewById(R.id.filter_edit);
}
 
Example 19
@SuppressLint("NewApi")
private long calculateAnimationDelay() {
    long delay;

    int lastVisiblePosition = getAbsListView().getLastVisiblePosition();
    int firstVisiblePosition = getAbsListView().getFirstVisiblePosition();

    int numberOfItemsOnScreen = lastVisiblePosition - firstVisiblePosition;
    int numberOfAnimatedItems = mLastAnimatedPosition - mFirstAnimatedPosition;

    if (numberOfItemsOnScreen + 1 < numberOfAnimatedItems) {
        delay = getAnimationDelayMillis();

        if (getAbsListView() instanceof GridView && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            delay += getAnimationDelayMillis() * ((mLastAnimatedPosition + 1) % ((GridView) getAbsListView()).getNumColumns());
        }
    } else {
        long delaySinceStart = (mLastAnimatedPosition - mFirstAnimatedPosition + 1) * getAnimationDelayMillis();
        delay = mAnimationStartMillis + getInitialDelayMillis() + delaySinceStart - System.currentTimeMillis();
    }
    return Math.max(0, delay);
}
 
Example 20
Source Project: MediaChooser   Source File: VideoFragment.java    License: Apache License 2.0 6 votes vote down vote up
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

		if(mView == null){
			mView = inflater.inflate(R.layout.view_grid_layout_media_chooser, container, false);

			mVideoGridView = (GridView)mView.findViewById(R.id.gridViewFromMediaChooser);

			if (getArguments() != null) {
				initVideos(getArguments().getString("name"));
			}else{
				initVideos();
			}

		}else{
			((ViewGroup) mView.getParent()).removeView(mView);
			if(mVideoAdapter == null || mVideoAdapter.getCount() == 0){
				Toast.makeText(getActivity(), getActivity().getString(R.string.no_media_file_available), Toast.LENGTH_SHORT).show();
			}
		}

		return mView;
	}
 
Example 21
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    main = (RelativeLayout) inflater.inflate(R.layout.fragment_msspreview, container, false);
    gv = (GridView) main.findViewById(R.id.gv_mss);
    mssPA = new MSSPreviewAdapter();
    gv.setAdapter(mssPA);
    gv.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View view,
                                int position, long arg3) {


        }
    });
    return main;
}
 
Example 22
Source Project: CameraV   Source File: GalleryFragment.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater li, ViewGroup container,
		Bundle savedInstanceState) {
	super.onCreateView(li, container, savedInstanceState);

	rootView = li.inflate(R.layout.fragment_gallery, null);
	mediaDisplayGrid = (GridView) rootView
			.findViewById(R.id.media_display_grid);
	noMedia = (RelativeLayout) rootView
			.findViewById(R.id.media_display_no_media);
	noMedia.setVisibility(View.GONE);
	
	progressWait = (ProgressBar) rootView.findViewById(R.id.progressWait);
	progressWait.setVisibility(View.GONE);
	
	mEncodingMedia = rootView.findViewById(R.id.media_encoding);
	mEncodingMedia.setVisibility(View.GONE);
	mEncodingMedia.findViewById(R.id.ivClose).setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			mEncodingMedia.setVisibility(View.GONE);
		}
	});
	return rootView;
}
 
Example 23
Source Project: PinyinSearchLibrary   Source File: T9SearchFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected View initView(LayoutInflater inflater, ViewGroup container) {
	View view = inflater.inflate(R.layout.fragment_t9_search, container,
			false);
	mT9SearchGv = (GridView) view.findViewById(R.id.t9_search_grid_view);
	mT9SearchGv.setAdapter(mAppInfoAdapter);
	mSearchResultPromptTv = (TextView) view
			.findViewById(R.id.search_result_prompt_text_view);
	mT9TelephoneDialpadView = (T9TelephoneDialpadView) view
			.findViewById(R.id.t9_telephone_dialpad_view);
	mT9TelephoneDialpadView.setOnT9TelephoneDialpadView(this);
	mKeyboardSwitchLayout = view.findViewById(R.id.keyboard_switch_layout);
	mKeyboardSwitchIv = (ImageView) view
			.findViewById(R.id.keyboard_switch_image_view);
	showKeyboard();
	return view;
}
 
Example 24
Source Project: AdDetector   Source File: FloatWindow.java    License: Apache License 2.0 6 votes vote down vote up
public FloatWindow(final Context context) {
	super(context);
	LayoutInflater.from(context).inflate(R.layout.float_folder, this);
	View view = findViewById(R.id.big_window_layout);
	viewWidth = view.getLayoutParams().width;
	viewHeight = view.getLayoutParams().height;
	Button close = (Button) findViewById(R.id.finishBtn);
	close.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			// close float window,stop service.
			MyWindowManager.removeBigWindow(context);
			Intent intent = new Intent(getContext(), FloatWindowService.class);
			context.stopService(intent);
		}
	});
	appWall = (GridView) findViewById(R.id.app_wall);
	List<AppInfo> apps = getAllInstalledSysApps(context);
	AppWallAdapter adapter = new AppWallAdapter(context, 0, apps, appWall);
	appWall.setAdapter(adapter);
	appWall.setOnItemClickListener(new ItemClickListener() );
	appWall.setOnItemLongClickListener(new ItemLongClickListener());
}
 
Example 25
Source Project: BlackLight   Source File: EmoticonFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	View v = inflater.inflate(R.layout.emoticon_fragment, null);
	mGrid = (GridView) v.findViewById(R.id.emoticon_grid);
	
	// adapter
	mAdapter = new EmoticonAdapter(getActivity());
	mGrid.setAdapter(mAdapter);
	
	// listener
	mGrid.setOnItemClickListener(this);
	
	return v;
}
 
Example 26
Source Project: SoloPi   Source File: IndexActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 初始化界面
 */
private void initView() {
    mPanel = (HeadControlPanel) findViewById(R.id.head_layout);
    mPanel.setMiddleTitle(getString(R.string.app_name));
    mPanel.setInfoIconClickListener(R.drawable.icon_config, new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(IndexActivity.this, SettingsActivity.class));
        }
    });
    mGridView = (GridView) findViewById(R.id.tools_grid);
}
 
Example 27
Source Project: EmoticonGIFKeyboard   Source File: GifFragment.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("DanglingJavadoc")
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mViewFlipper = view.findViewById(R.id.gif_view_flipper);
    mErrorTv = view.findViewById(R.id.error_textview);

    //Set the grid view
    mGifGridAdapter = new GifGridAdapter(mContext, mGifs, this);

    /**
     * Instead of using recycler view,we are stick to the GRidView here because in recycler view
     * items from the grid column are not getting displayed until user scrolls up-down. There is
     * no solution found for this problem,
     * @see https://stackoverflow.com/questions/29460164/recyclerview-refreshes-items-only-when-scrolling-down-and-up
     */
    GridView gridView = view.findViewById(R.id.gif_gridView);
    gridView.setNumColumns(getResources().getInteger(R.integer.gif_recycler_view_span_size));
    gridView.setAdapter(mGifGridAdapter);

    //Load the list of trending GIFs.
    if (mGifs.isEmpty()) {
        if (mTrendingGifTask != null) mTrendingGifTask.cancel(true);
        mTrendingGifTask = new TrendingGifTask();
        mTrendingGifTask.execute();
        mViewFlipper.setDisplayedChild(0);
    } else {
        mViewFlipper.setDisplayedChild(1);
    }
}
 
Example 28
Source Project: CommonPullToRefresh   Source File: PtrFrameLayout.java    License: Apache License 2.0 5 votes vote down vote up
public void setLoadMoreEnable(boolean loadMoreEnable) {
    if (this.isLoadMoreEnable == loadMoreEnable) {
        return;
    }
    this.isLoadMoreEnable = loadMoreEnable;
    if (!hasInitLoadMoreView && isLoadMoreEnable) {
        mContentView = getContentView();
        if (null == loadMoreViewFactory) {
            loadMoreViewFactory = new DefaultLoadMoreViewFooter();
        }
        mLoadMoreView = loadMoreViewFactory.madeLoadMoreView();

        if (null == mLoadMoreHandler) {
            if (mContentView instanceof GridView) {
                mLoadMoreHandler = new GridViewHandler();
            } else if (mContentView instanceof AbsListView) {
                mLoadMoreHandler = new ListViewHandler();
            } else if (mContentView instanceof RecyclerView) {
                mLoadMoreHandler = new RecyclerViewHandler();
            }
        }

        if (null == mLoadMoreHandler) {
            throw new IllegalStateException("unSupported contentView !");
        }

        hasInitLoadMoreView = mLoadMoreHandler.handleSetAdapter(mContentView, mLoadMoreView,
                onClickLoadMoreListener);
        mLoadMoreHandler.setOnScrollBottomListener(mContentView, onScrollBottomListener);
        return;
    }

    if (hasInitLoadMoreView) {
        if (isLoadMoreEnable) {
            mLoadMoreHandler.addFooter();
        } else {
            mLoadMoreHandler.removeFooter();
        }
    }
}
 
Example 29
Source Project: MiBandDecompiled   Source File: PullToRefreshGridView.java    License: Apache License 2.0 5 votes vote down vote up
protected final GridView createRefreshableView(Context context, AttributeSet attributeset)
{
    Object obj;
    if (android.os.Build.VERSION.SDK_INT >= 9)
    {
        obj = new l(this, context, attributeset);
    } else
    {
        obj = new k(this, context, attributeset);
    }
    ((GridView) (obj)).setId(0x7f0a0021);
    return ((GridView) (obj));
}
 
Example 30
Source Project: glimmr   Source File: PhotoGridFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    if (BuildConfig.DEBUG) {
        Log.d("(PhotoGridFragment)" + getLogTag(), "onResume");
    }
    if (!mPhotos.isEmpty()) {
        GridView gridView = (GridView) mLayout.findViewById(R.id.gridview);
        gridView.setVisibility(View.VISIBLE);
    }
}