@Nullable @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.recycler_view, container, false); RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); Adapter adapter = new Adapter(getActivity(), Arrays.asList(DATAS)); recyclerView.setAdapter(adapter); adapter.setOnItemClickListener( new XORecyclerBaseAdapter.OnItemClickListener() { @Override public void onItemClick(View view, Object t, int position) { ExpandFromEnterFragment fragment = ExpandFromEnterFragment.newInstance((String) t); ChangeBounds set = new ChangeBounds(); fragment.setSharedElementEnterTransition(set); fragment.setSharedElementEnterTransition(set); getActivity() .getSupportFragmentManager() .beginTransaction() .replace(R.id.fragment_container, fragment) .addSharedElement(view, getString(R.string.coordinator_trans)) .addToBackStack(null) .commit(); } }); return rootView; }
public static RuleNames tryGetRuleNames(AbstractRule rule) { Adapter adapter = (Adapter) EcoreUtil.getAdapter(rule.eAdapters(), RuleNames.class); if (adapter == null) { return null; } return adapter.getRuleNames(); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); HashMap<String, String> map = null; String[][] vehicleTypeData = { {"Two (includes motorcycle)", "$5.00", "$6.00", "$7.00"}, {"Three", "$7.50", "$9.00", "$10.50"}, {"Four", "$10.00", "$12.00", "$14.00"}, {"Five", "$12.50", "$15.00", "$17.50"}, {"Six or more", "$15.00", "$18.00", "$21.00"} }; map = new HashMap<String, String>(); map.put("number_axles", "Number of Axles"); map.put("goodtogo_pass", "Good To Go! Pass"); map.put("pay_by_cash", "Cash"); map.put("pay_by_mail", "Pay By Mail"); mAdapter.addSeparatorItem(map); for (int i = 0; i < vehicleTypeData.length; i++) { map = new HashMap<String, String>(); map.put("number_axles", vehicleTypeData[i][0]); map.put("goodtogo_pass", vehicleTypeData[i][1]); map.put("pay_by_cash", vehicleTypeData[i][2]); map.put("pay_by_mail", vehicleTypeData[i][3]); mAdapter.addItem(map); } }
public static RuleNames getRuleNames(AbstractRule rule) { Adapter adapter = (Adapter) EcoreUtil.getAdapter(rule.eAdapters(), RuleNames.class); if (adapter == null) { throw new IllegalStateException("Cannot find adapter"); } return adapter.getRuleNames(); }
@SuppressWarnings({"rawtypes", "unchecked"}) public String toString(Distribution distribution) { Adapter adapter = map.get(distribution.getClass()); String args[] = adapter.toParameters(distribution); String out = adapter.category; for (String a : args) out += "," + a; return out; }
private void setupViewPager(ViewPager viewPager) { Adapter adapter = new Adapter(getSupportFragmentManager()); adapter.addFragment(new EventsFragment(), "Events "); adapter.addFragment(new CalenderFragment(), "Calender"); adapter.addFragment(new ScoreBoardFragment(), "ScoreBoard"); adapter.addFragment(new ClubsFragment(), "Clubs"); viewPager.setAdapter(adapter); }
@LauncherAPI public static AuthProvider newProvider(String name, BlockConfigEntry block) { VerifyHelper.verifyIDName(name); Adapter<AuthProvider> authHandlerAdapter = VerifyHelper.getMapValue( AUTH_PROVIDERS, name, String.format("Unknown auth provider: '%s'", name)); return authHandlerAdapter.convert(block); }
public void testRoundTrip() throws Exception { Adapter a = new Adapter(); a.setUniqueId(DEFAULT_KEY); AdapterStateSummary s1 = new AdapterStateSummary(a); AdaptrisMarshaller cm = DefaultMarshaller.getDefaultMarshaller(); String xml = cm.marshal(s1); AdapterStateSummary s2 = (AdapterStateSummary) cm.unmarshal(xml); assertRoundtripEquality(s1, s2); }
@Override public Class<?>[] getAdapterTypes() { Adapter anno = getClass().getAnnotation(Adapter.class); if (anno == null) { throw new IllegalStateException( "Invalid AnnotatedAdapterFactory class. Must be annotated with Adapter annotation"); } return anno.interfaces(); }
private void setupViewPager(ViewPager viewPager) { Adapter adapter = new Adapter(getSupportFragmentManager()); adapter.addFragment(new BloomFragment(), "One"); adapter.addFragment(new BloomFragment(), "Two"); adapter.addFragment(new BloomFragment(), "Three"); adapter.addFragment(new BloomFragment(), "Four"); viewPager.setAdapter(adapter); }
@Override public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { Adapter adapter = new Adapter(cursor); adapter.setHasStableIds(true); mRecyclerView.setAdapter(adapter); int columnCount = getResources().getInteger(R.integer.list_column_count); StaggeredGridLayoutManager sglm = new StaggeredGridLayoutManager(columnCount, StaggeredGridLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(sglm); }
public static RuleNames getRuleNames(Grammar grammar, boolean cache) { if (cache) { Adapter adapter = (Adapter) EcoreUtil.getAdapter(grammar.eAdapters(), RuleNames.class); if (adapter == null) { return new RuleNames(grammar, true); } return adapter.getRuleNames(); } return new RuleNames(grammar, false); }
public void testAdapterStateSummaryAdapterInit() throws Exception { Adapter a = new Adapter(); a.setUniqueId(DEFAULT_KEY); a.getChannelList().addChannel(new Channel()); LifecycleHelper.init(a); AdapterStateSummary summary = new AdapterStateSummary(a); assertEquals(DEFAULT_KEY, summary.getAdapterState().getKey()); assertEquals(InitialisedState.class.getName(), summary.getAdapterState().getValue()); assertNotNull(summary.getLastStopTime()); assertNull(summary.getLastStartTime()); }
@Override @SuppressWarnings("unchecked") public Class<O> getAdaptableType() { Adapter anno = getClass().getAnnotation(Adapter.class); if (anno == null) { throw new IllegalStateException( "Invalid AnnotatedAdapterFactory class: " + getClass().getName() + ". Must be annotated with Adapter annotation"); } return (Class<O>) anno.type(); }
public void testAdapterStateSummaryAdapter() throws Exception { Adapter a = new Adapter(); a.setUniqueId(DEFAULT_KEY); a.getChannelList().addChannel(new Channel()); AdapterStateSummary summary = new AdapterStateSummary(a); assertNotNull(summary); assertNotNull(summary.getLastStopTime()); assertNull(summary.getLastStartTime()); assertEquals(DEFAULT_KEY, summary.getAdapterState().getKey()); assertEquals(ClosedState.class.getName(), summary.getAdapterState().getValue()); assertEquals(0, summary.getChannelStates().size()); }
private void setupViewPager(ViewPager viewPager) { Adapter adapter = new Adapter(getSupportFragmentManager()); adapter.addFragment( AppWatcherListFragment.newInstance(Filters.TAB_ALL, mPreferences.getSortIndex()), getString(R.string.tab_all)); adapter.addFragment( InstalledListFragment.newInstance(Filters.TAB_INSTALLED, mPreferences.getSortIndex()), getString(R.string.tab_installed)); adapter.addFragment( AppWatcherListFragment.newInstance(Filters.TAB_UNINSTALLED, mPreferences.getSortIndex()), getString(R.string.tab_not_installed)); viewPager.setAdapter(adapter); }
@Override public void onChanged() { Adapter<?> adapter = getAdapter(); if (adapter != null && emptyView != null) { if (adapter.getItemCount() == 0) { emptyView.setVisibility(View.VISIBLE); MyRecyclerView.this.setVisibility(View.GONE); } else { emptyView.setVisibility(View.GONE); MyRecyclerView.this.setVisibility(View.VISIBLE); } } }
private void setupViewPager(ViewPager viewPager) { Adapter adapter = new Adapter(getActivity().getSupportFragmentManager()); adapter.addFragment(new RankingUsersFragment(), "China All"); adapter.addFragment(new RankingUsersFragment("language:Java"), "Java"); adapter.addFragment(new RankingUsersFragment("language:C"), "C"); adapter.addFragment(new RankingUsersFragment("language:Objective-C"), "Objective-C"); adapter.addFragment(new RankingUsersFragment("language:csharp"), "C#"); adapter.addFragment(new RankingUsersFragment("language:Python"), "Python"); adapter.addFragment(new RankingUsersFragment("language:PHP"), "PHP"); adapter.addFragment(new RankingUsersFragment("language:JavaScript"), "JavaScript"); adapter.addFragment(new RankingUsersFragment("language:Ruby"), "Ruby"); viewPager.setAdapter(adapter); }
@Override public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { Adapter adapter = new Adapter(cursor); adapter.setHasStableIds(true); mRecyclerView.setAdapter(adapter); int columnCount = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ? 2 : 3; StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(columnCount, StaggeredGridLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(staggeredGridLayoutManager); SpacesItemDecoration decoration = new SpacesItemDecoration(4); mRecyclerView.addItemDecoration(decoration); }
@SuppressWarnings("unchecked") public <T extends Distribution> T toDistribution(String value, Class<T> clazz) { StringTokenizer st = new StringTokenizer(value, ", \t\f"); if (!st.hasMoreTokens()) throw new DistributionFormatException("Missing ditribution type"); String type = st.nextToken(); ObjectMap<String, Adapter<?>> categories = typeMap.get(clazz); Adapter<T> converter = (Adapter<T>) categories.get(type); if (converter == null) throw new DistributionFormatException( "Cannot create a '" + clazz.getSimpleName() + "' of type '" + type + "'"); String[] args = new String[st.countTokens()]; for (int i = 0; i < args.length; i++) args[i] = st.nextToken(); return converter.toDistribution(args); }
@Override public void setAdapter(Adapter adapter) { final Adapter oldAdapter = getAdapter(); if (oldAdapter != null) { oldAdapter.unregisterAdapterDataObserver(observer); } super.setAdapter(adapter); if (adapter != null) { adapter.registerAdapterDataObserver(observer); } checkIfEmpty(); }
/** notify the list data was changed. so refresh the list. */ public void notifyDataSetChanged() { if (refreshLayout.isRefreshing()) { refreshLayout.setRefreshing(false); } if (0 == listAdapter.getItemCount() && (null == getDataProvider() || getDataProvider().isLastPage())) { showEmptyView(); } else { hideEmptyView(); } listAdapter.notifyDataSetChanged(); }
@Override public void process(CompilationUnitDeclaration cud, int i) { super.process(cud, i); ClassFile[] classFiles = cud.compilationResult().getClassFiles(); Map<ClassFile, CompiledClass> results = new LinkedHashMap<ClassFile, CompiledClass>(); for (ClassFile classFile : classFiles) { createCompiledClass(classFile, results); } List<CompiledClass> compiledClasses = new ArrayList<CompiledClass>(results.values()); addBinaryTypes(compiledClasses); ICompilationUnit icu = cud.compilationResult().compilationUnit; Adapter adapter = (Adapter) icu; CompilationUnitBuilder builder = adapter.getBuilder(); // TODO this code was added for the arquillian gwt extension if (cud.types != null) { for (TypeDeclaration type : cud.types) { if (type.methods != null) { if (isAnnotationPresent(RunWith.class.getSimpleName(), type.annotations)) { Set<AbstractMethodDeclaration> filteredMethods = new HashSet<AbstractMethodDeclaration>(); boolean match = false; for (AbstractMethodDeclaration decl : type.methods) { if (decl.annotations != null) { // TODO make this configurable if ((isAnnotationPresent(RunAsGwtClient.class.getSimpleName(), decl.annotations) || isAnnotationPresent( RunAsGwtClient.class.getSimpleName(), type.annotations)) && !isAnnotationPresent(Deployment.class.getSimpleName(), decl.annotations)) { filteredMethods.add(decl); } else { match = true; System.out.println("Ignoring non-translatable method:\n" + decl.toString()); } } } if (match) { type.methods = filteredMethods.toArray(new AbstractMethodDeclaration[filteredMethods.size()]); } } } } } processor.process(builder, cud, compiledClasses); }
public String getNameForSenderOf(TdApi.Message item) { return sGetNameForSenderOf(adapter.getUserHolder(), item); // int fromId = item.fromId; // assertTrue(fromId != 0); // TdApi.User user = adapter.getUserHolder().getUser(fromId); // return Utils.uiName(user); }
@Override public void onBindViewHolder(ViewHolder holder, int position) { int type = getItemViewType(position); if (type != TYPE_FOOTER) { mInternalAdapter.onBindViewHolder(holder, position); } }
@Override public int getItemCount() { int count = mInternalAdapter.getItemCount(); if (mIsFooterEnable) count++; return count; }
@Override public void onRequestFinish(MApiRequest req, MApiResponse resp) { if (resp.result() instanceof ForumListBean) { adapter.setData(((ForumListBean) resp.result()).data); } loading.setVisibility(View.GONE); }
public void printAttributeName(PrintNode row, AttributePath attributePath, Adapter scda) throws Exception { for (int j = 0; j < attributes.size(); j++) { Attribute currentAttribute = (Attribute) attributes.get(j); int attributeLength = currentAttribute.name.length() + 2; if (currentAttribute.getClass() == DVA.class && attributePath.levelsOfIndirection() <= 0) { // If the attribute we want is found or we just want everything, output if (attributePath.attribute.equals("*")) { PrintCell cell = new PrintCell(); cell.setOutput(String.format("%s", currentAttribute.name)); row.addCell(cell); } else if (attributePath.attribute.equals(currentAttribute.name)) { PrintCell cell = new PrintCell(); cell.setOutput(String.format("%s", currentAttribute.name)); row.addCell(cell); return; } } if (currentAttribute.getClass() == EVA.class && attributePath.levelsOfIndirection() > 0) { String evaName = attributePath.getIndirection(attributePath.levelsOfIndirection() - 1); if (evaName.equals(currentAttribute.name)) { ClassDef targetClass = scda.getClass(((EVA) currentAttribute).baseClassName); attributePath.removeIndirection(attributePath.levelsOfIndirection() - 1); targetClass.printAttributeName(row, attributePath, scda); attributePath.addIndirection(evaName); return; } } } // Got here if we didn't get what we need in this class int i = 0; while (i < superClasses.size()) { try { ClassDef superClass = scda.getClass(((String) superClasses.get(i))); superClass.printAttributeName(row, attributePath, scda); i++; } catch (NoSuchFieldException nsfe) { if (i < superClasses.size()) { i++; } else { throw nsfe; } } } }
private void doRestoreState(Adapter adapter) { if (stateRestored || adapter == null || adapter.getItemCount() == 0) return; stateRestored = true; if (delayedState != null) { super.onRestoreInstanceState(delayedState); delayedState = null; } }
@CallSuper @Override public void setAdapter(Adapter adapter) { if (getAdapter() != null) getAdapter().unregisterAdapterDataObserver(dataObserver); if (adapter != null) adapter.registerAdapterDataObserver(dataObserver); doRestoreState(adapter); super.setAdapter(adapter); }