android – Enviar una variable de un Activity a una Clase

tengo una app que estoy desarrollando y necesito enviar una variable desde mi activity al Repo de mi RecyclerView de tipo class, para usarlo en un whereEqualTo de Firebase. Necesito ayuda porque no consigo como lograrlo.

Este es el codigo de mi Repo de tipo class

package com.ezdev.chepesdelivery.ui.RecyMenu

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.google.firebase.firestore.FirebaseFirestore

class RepoMenu {

    fun getTiendaData(): LiveData<MutableList<Plato>> {
        val mutableData = MutableLiveData<MutableList<Plato>>()
        FirebaseFirestore.getInstance().collection("Platos").whereEqualTo("tienda", "AquiVaMiVariable").get()
            .addOnSuccessListener { result ->
                mutableData.value = result.documents.map { snap ->
                    snap.run {
                        Plato(
                            getString("plato") ?: "default",
                            getString("descripcion") ?: "default",
                            getBoolean("stock") ?: false,
                            getString("precio") ?: "default",
                        )
                    }
                }.toMutableList()
            }


        return mutableData
    }


}

La variable la usare para filtrar los elementos que necesito con el whereEqualTo.

Y este es mi activity

package com.ezdev.chepesdelivery

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import com.ezdev.chepesdelivery.ui.RecyMenu.MyAdapterMenu
import com.ezdev.chepesdelivery.ui.RecyMenu.MyViewModelMenu
import com.google.firebase.firestore.FirebaseFirestore
import kotlinx.android.synthetic.main.activity_pedir.*


class PedirActivity : AppCompatActivity(), MyAdapterMenu.OnTiendaListener {

    private lateinit var adapter: MyAdapterMenu
    private val viewModel by lazy { ViewModelProvider(this).get(MyViewModelMenu::class.java)}


    private val db = FirebaseFirestore.getInstance()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_pedir)

        var nombreTienda = intent.getStringExtra("nombreTienda") //Este es la variable que necesito enviar
        var tiendaEmail = intent.getStringExtra("emailTienda")


        title = "Menu de $nombreTienda"

        adapter = MyAdapterMenu(this, this)

        recyclerViewMenu.layoutManager = LinearLayoutManager(this)
        recyclerViewMenu.addItemDecoration(DividerItemDecoration(this,DividerItemDecoration.VERTICAL))
        recyclerViewMenu.adapter = adapter
        observeData()


    }

    fun observeData(){
        viewModel.fetchTiendaData().observe(this, Observer {

            adapter.setListData(it)
            adapter.notifyDataSetChanged()

        })
    }

    override fun onItemClick(nombre: String) {



    }

}

La variable que necesito enviar es la que dice nombreTienda.

Bueno es seria todo, no se si tenga que compartir los demas codigos que estan en mi RecyclerView como mi Adapter o mi ViewModel, si es necesario para que me ayuden me dicen y los agrego.

android studio – How to stop a custom dialog fragment animation from repeating when activity is resumed?

The behavior I am talking about in the question can be seen in this video: https://streamable.com/ltefj2 There I am first showing the animations of my dialog and then the unwanted behavior that occurs when closing the app and then reopening it again.

Here is all the code that I used to implement these custom animations:

dialog_show_anim.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="300"
        android:fromYDelta="100%p"
        android:toYDelta="0%p" />
</set>

dialog_dismiss_anim.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="300"
        android:fromYDelta="0%p"
        android:toYDelta="100%p" />
</set>

Then I created a style:

    <style name="DialogAnimation">
        <item name="android:windowEnterAnimation">@anim/dialog_show_anim</item>
        <item name="android:windowExitAnimation">@anim/dialog_dismiss_anim</item>
    </style>

And finally in my dialog fragment’s onCreateView() method I wrote this:

getDialog().getWindow().setWindowAnimations(R.style.DialogAnimation);

What I’ve tried so far: I tried to interchange between the line above and this line

getDialog().getWindow().setWindowAnimations(0);

in my dialog class with flags that point out which one and when should be set, but a lot problems emerged mainly because setWindowAnimations() seemed to only work when placed in onCreateView(), onStart() or onResume().

I searched for a while but couldn’t find a solution anywhere. Can you help me fix this repeating of the animation when reopening the app or possibly point out another way to implement these animations without that problem ever occurring?

java – Back to previous activity from a fragment?

I have a pager adapter with three fragments, and i want to know how can i go back to the previous activity when im inside a fragment? i tried on back pressed but just close the app after click on back button.

Adapter :

public class PagerAdapter extends FragmentStateAdapter {


ArrayList<Fragment> arrayList = new ArrayList<>();


public PagerAdapter(@NonNull FragmentManager fragmentManager, @NonNull Lifecycle lifecycle) {
    super(fragmentManager, lifecycle);
}




@NonNull
@Override
public Fragment createFragment(int position) {
    Fragment fragment = new Fragment();
    switch (position){
        case 0: fragment = new VataFragment();
        break;
        case 1: fragment = new PittaFragment();
        break;
        case 2: fragment = new KhapaFragment();
        break;

    }
    return fragment;
}

@Override
public int getItemCount() {
    return arrayList.size();
}

public void addFragment(Fragment fragment) {
    arrayList.add(fragment);
}

Fragment 1 :

public class VataFragment extends Fragment {


public VataFragment() {
    // Required empty public constructor
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_vata, container, false);



    // Inflate the layout for this fragment
    return view;

}

Please help me!! If we choose any activity in top menu bar category then slide below collection view in swipe right direction in swift 4 thanks

Evertime we Click on top menu and below collection same collection cell right slide how??

java – How to pass a list of objects from one activity to another using parcelable

I want to pass the list of itemselected or ItemsInCart to another activity. My Items Model implements parcelable. The problem is an getting error below in my PlaceOrder class.

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.recyclerview.widget.RecyclerView.setLayoutManager(androidx.recyclerview.widget.RecyclerView$LayoutManager)' on a null object reference at com.example.Project1.SecondActivity.onCreate(SecondActivity.java:59)

Below is the code

Model Item;

public class Item implements Parcelable {
private int iid;
private String itenname;
private String itemprice;
private String itemstock;
private int totalInCart;
private List<Item> items;

public Item(int iid, String itenname, String itemprice, String itemstock, int totalInCart,List<Item> items) {
    this.iid = iid;
    this.itenname = itenname;
    this.itemprice = itemprice;
    this.itemstock = itemstock;
    this.totalInCart = totalInCart;
    this.items = items;
}

protected Item(Parcel in) {
    iid = in.readInt();
    itenname = in.readString();
    itemprice = in.readString();
    itemstock = in.readString();
    totalInCart = in.readInt();
    items = in.createTypedArrayList(Item.CREATOR);
}

public static final Creator<Item> CREATOR = new Creator<Item>() {
    @Override
    public Item createFromParcel(Parcel in) {
        return new Item(in);
    }

    @Override
    public Item() newArray(int size) {
        return new Item(size);
    }
};

public List<Item> getItems() {
    return items;
}

public void setItems(List<Item> items) {
    this.items = items;
}

public int getIid() {
    return iid;
}

public void setIid(int iid) {
    this.iid = iid;
}

public String getItenname() {
    return itenname;
}

public void setItenname(String itenname) {
    this.itenname = itenname;
}

public String getItemprice() {
    return itemprice;
}

public void setItemprice(String itemprice) {
    this.itemprice = itemprice;
}

public String getItemstock() {
    return itemstock;
}

public void setItemstock(String itemstock) {
    this.itemstock = itemstock;
}

public int getTotalInCart() {
    return totalInCart;
}

public void setTotalInCart(int totalInCart) {
    this.totalInCart = totalInCart;
}

@Override
public int describeContents() {
    return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
    dest.writeInt(iid);
    dest.writeString(itenname);
    dest.writeString(itemprice);
    dest.writeString(itemstock);
    dest.writeInt(totalInCart);
    dest.writeTypedList(items);
}

}

First Activity;
The list that i want to pass to second activity is ‘itemsInCart’

buttonCheckout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (itemsInCart==null||itemsInCart.size()<=0){
                Toast.makeText(List_Items.this, "Please add some items to the cart.", Toast.LENGTH_SHORT).show();
                return;
            }

           ArrayList<Item> additems = new ArrayList<Item>();
            for (int i = 0; i < itemsInCart.size(); i++){
                additems.add(itemsInCart.get(i));
            }

            Intent intent = new Intent(MainActivity.this,DisplaySelectedItems.class);
            intent.putParcelableArrayListExtra ("Itemselected", additems);
            startActivity(intent);

        }
    });

Second Activity (in OnCreate method):

Bundle bundle = getIntent().getExtras();
    ArrayList<Item> selecteditems = bundle.getParcelableArrayList("Itemselected");

    CartItemsInRecyclerView.setLayoutManager(new LinearLayoutManager(this)); 
    placeOrderAdapter = new PlaceOrder_Adapter((ArrayList<Item>) items); <- This is line 59 of the error
    CartItemsInRecyclerView.setAdapter(placeOrderAdapter);

I have found similar questions and tried their solutions but all is not working.
Please advise on what i have to change.

logging – Is it possible and how to log a website internal connection activity?

For instance, I have developed a WordPress website and prepared to deploy to client’s server. Since they request the site to be scanned in their VPN server first. For some reason, the application connects to many external resources and because the VPN is blocked the site from connecting to other location than its internal address, it is very slow. The slowness is believed to be due to blocking and retrial until giving up.

Since the application consists of a lot of plugins. What connection it is trying to make is not so obvious and straightforward.

Is it possible to track/log what the connection it is trying to made? If it is possible, I could do it in local server environment level and coding level to make a list of connection that it is trying to connect. And then I could use this list to discuss with the client and ask for white listing.

eg. normal connection log /user activity utility could log
user A with IP A visit > website.

But currently, if the site itself connect to

  • wordpress.org <<< possible log it down?
  • website B …
  • website C

Any hints, suggestions, insight is highly appreciated.
Thanks a lot.

Rootkit activity

If a hacker have installed remote access tool/rootkit on your computer, when they open site, where you’re logged in on your computer remotely, will their ip show up in that account activity? Or will it show up as your ip address?

I faced by Anomaly Activity on CPU usage on my server

Hello.

I have several dedicated servers that run virtual servers normally.

[B]Recently, an important virtual server consumes a very la… | Read the rest of https://www.webhostingtalk.com/showthread.php?t=1845763&goto=newpost

Staff activity | NulledTeam UnderGround

Premium upgrade:

This XF2 add-on along with the entire collection can be purchased for $25.00 USD. Your Premium upgrade will allow you to download as many XF2 add-ons as you like for one year. Please see the entire collection located in the Resources area at this URL:

https://www.xf2addons.com/

Note: all my XF1 add-ons are still 100% free and are supported by donations.

Description:

Shows activity of Administrative and Moderating user groups.

This add-on allows…

.

Monitor disk activity by process and by file in linux like windows ressource monitor

There are so many tools to monitor disk activity in linux like htop, dstat or iotop. However I didn’t find any way to monitor disk activity by process and by file. In windows ressource monitor does this job perfect.

enter image description here

I’m looking for a console tool to do the same in linux.