2020-12-16 19:26:53 +00:00
|
|
|
package cc.pogoda.mobile.pogodacc.activity.handler;
|
|
|
|
|
2021-10-14 20:00:47 +00:00
|
|
|
import android.app.Activity;
|
2020-12-16 19:26:53 +00:00
|
|
|
import android.content.Intent;
|
|
|
|
import android.view.View;
|
|
|
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
2021-10-14 20:00:47 +00:00
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
|
|
2020-12-16 19:26:53 +00:00
|
|
|
import cc.pogoda.mobile.pogodacc.activity.StationDetailsActivity;
|
2021-10-13 19:00:10 +00:00
|
|
|
import cc.pogoda.mobile.pogodacc.type.ParceableFavsCallReason;
|
2020-12-16 19:26:53 +00:00
|
|
|
import cc.pogoda.mobile.pogodacc.type.WeatherStation;
|
|
|
|
|
|
|
|
public class AllStationsActRecyclerViewButtonClickEvent implements View.OnClickListener {
|
|
|
|
|
|
|
|
WeatherStation station;
|
|
|
|
|
|
|
|
AppCompatActivity p;
|
|
|
|
|
|
|
|
Intent intent;
|
|
|
|
|
2021-10-13 19:00:10 +00:00
|
|
|
ParceableFavsCallReason.Reason reason;
|
|
|
|
|
|
|
|
public AllStationsActRecyclerViewButtonClickEvent(WeatherStation wx, AppCompatActivity parent, ParceableFavsCallReason.Reason r) {
|
2020-12-16 19:26:53 +00:00
|
|
|
station = wx;
|
|
|
|
p = parent;
|
2021-10-13 19:00:10 +00:00
|
|
|
reason = r;
|
2020-12-16 19:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2021-11-10 22:04:05 +00:00
|
|
|
if (reason == null || reason == ParceableFavsCallReason.Reason.FAVOURITES || reason == ParceableFavsCallReason.Reason.ALL_STATIONS) {
|
2021-10-13 19:00:10 +00:00
|
|
|
intent = new Intent(p, StationDetailsActivity.class);
|
|
|
|
intent.putExtra("station", station);
|
2020-12-16 19:26:53 +00:00
|
|
|
|
2021-10-13 19:00:10 +00:00
|
|
|
p.startActivity(intent);
|
2020-12-16 19:26:53 +00:00
|
|
|
|
2021-10-14 20:00:47 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (reason == ParceableFavsCallReason.Reason.EXPORT_SELECT) {
|
|
|
|
|
|
|
|
EventBus.getDefault().post(station);
|
|
|
|
|
|
|
|
p.setResult(Activity.RESULT_OK);
|
|
|
|
|
|
|
|
p.finish();
|
|
|
|
|
2021-10-13 19:00:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-12-16 19:26:53 +00:00
|
|
|
}
|
|
|
|
}
|