Firebase托管重定向移动和桌面设备

时间:2018-11-05 20:37:05

标签: firebase-hosting

如果要从移动设备访问index.html,请尝试将指向/mobile/index.html的指向重定向到/desktop/index.html,否则,如果要从www.somedomain.com/index.html加载,请从桌面加载它。

www.somedomain.comfirebase.json应该在服务器端public class HatStoreAdapter extends RecyclerView.Adapter<HatStoreAdapter.MyViewHolder> { private String[] mDataset; // Provide a reference to the views for each data item // Complex data items may need more than one view per item, and private Context mContext; private List<HatStoreCard> appsList; private HatAdapterListener listener; public class MyViewHolder extends RecyclerView.ViewHolder { public TextView title, count; public ImageView thumbnail, overflow; public CardView cardView; public MyViewHolder(View view) { super(view); title = (TextView) view.findViewById(R.id.hattitle); count = (TextView) view.findViewById(R.id.hatdesc); thumbnail = (ImageView) view.findViewById(R.id.hatthumbnail); overflow = (ImageView) view.findViewById(R.id.hatoverflow); cardView = view.findViewById(R.id.hatcard_view); } } public HatStoreAdapter(Context mContext, List<HatStoreCard> appsList, HatAdapterListener listener) { this.mContext = mContext; this.appsList = appsList; this.listener = listener; } @Override public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View itemView = LayoutInflater.from(parent.getContext()) .inflate(R.layout.hatstorecardview, parent, false); return new MyViewHolder(itemView); } @Override public void onBindViewHolder(final MyViewHolder holder, int postition) { HatStoreCard app = appsList.get(holder.getAdapterPosition()); holder.title.setText(app.getName()); holder.count.setText(app.getDescription()); // loading album cover using Glide library if (CardAnimationConfig.animating) { setFadeAnimation(holder.cardView); } Glide.with(mContext).load(app.getAppicon()).into(holder.thumbnail); Log.e(getClass().getName(), "Drawable: "+ app.getAppicon().toString()); holder.overflow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showPopupMenu(holder.overflow); } }); holder.cardView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { listener.onHatSelected(holder.getAdapterPosition(), HatDetailsArrayHelper.getTitle(holder.getAdapterPosition()), HatDetailsArrayHelper.getDescription(holder.getAdapterPosition()), HatDetailsArrayHelper.getThumbnailImage(holder.getAdapterPosition()), HatDetailsArrayHelper.getType(holder.getAdapterPosition()), HatDetailsArrayHelper.getPrice(holder.getAdapterPosition()), HatDetailsArrayHelper.getDownloadableRes(holder.getAdapterPosition()), appsList.get(holder.getAdapterPosition()).getRequiredVersion(), appsList.get(holder.getAdapterPosition()).getHatID()); } }); holder.thumbnail.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { listener.onHatSelected(holder.getAdapterPosition(), HatDetailsArrayHelper.getTitle(holder.getAdapterPosition()), HatDetailsArrayHelper.getDescription(holder.getAdapterPosition()), HatDetailsArrayHelper.getThumbnailImage(holder.getAdapterPosition()), HatDetailsArrayHelper.getType(holder.getAdapterPosition()), HatDetailsArrayHelper.getPrice(holder.getAdapterPosition()), HatDetailsArrayHelper.getDownloadableRes(holder.getAdapterPosition()), appsList.get(holder.getAdapterPosition()).getRequiredVersion(), appsList.get(holder.getAdapterPosition()).getHatID()); } }); } /** * Showing popup menu when tapping on 3 dots */ private void showPopupMenu(View view) { // inflate menu PopupMenu popup = new PopupMenu(mContext, view); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.storecard_menu, popup.getMenu()); popup.setOnMenuItemClickListener(new MyMenuItemClickListener()); popup.show(); } /** * Click listener for popup menu items */ class MyMenuItemClickListener implements PopupMenu.OnMenuItemClickListener { public MyMenuItemClickListener() { } @Override public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.action_download: Toast.makeText(mContext, "Ladataan", Toast.LENGTH_SHORT).show(); return true; default: } return false; } } @Override public int getItemCount() { return appsList.size(); } public interface HatAdapterListener { void onHatSelected(int position, String hatname, String hatdescription, String hatthumbnail, String hattype, int hatprice, String appdownloadableres, int requiredversion, int hatID); } public Intent getItemIntent(int postition, Context context) { Intent intent = intents.get(postition); return intent; } private void setFadeAnimation(View view) { AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f); anim.setDuration(200); view.startAnimation(anim); } } 中重定向到适当的文件夹,具体取决于从设备访问的位置。

这可以从Firebase托管中完成吗?感谢有人可以提供解决方案。

0 个答案:

没有答案