E/RecyclerView: No adapter attached; skipping layout (Using Fragment)
I have been reading the different answers here on stackoverflow and on this blog post and tried to implement their solutions but I am still getting the error:No adapter attached; skipping layout. help me.
[code]package vn.jupviec.frontend.android.monitor.app.ui.candidate;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.w3c.dom.Text;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import butterknife.BindView;
import vn.jupviec.frontend.android.monitor.app.R;
import vn.jupviec.frontend.android.monitor.app.domain.candidate.TrainingDTO;
import vn.jupviec.frontend.android.monitor.app.util.Utils;
/**
* Created by Windows 10 Gamer on 16/12/2016.
*/
public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.RecyclerViewHolder> {
private static final String TAG = "RecyclerView";
private List<TrainingDTO> mTrainingDTOs;
private Context mContext;
private LayoutInflater mLayoutInflater;
private String today;
private static final DateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
AdapterInterface buttonListener;
public RecyclerAdapter(Context context, List<TrainingDTO> datas, AdapterInterface buttonListener) {
mContext = context;
mTrainingDTOs = datas;
this.mLayoutInflater = LayoutInflater.from(mContext);
this.buttonListener = buttonListener;
}
@Override
public RecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.candidate_item, parent, false);
// View itemView = mLayoutInflater.inflate(R.layout.candidate_item, parent, false);
return new RecyclerViewHolder(itemView);
}
@Override
public void onBindViewHolder(RecyclerViewHolder holder, int position) {
final ObjectMapper mapper = new ObjectMapper();
final TrainingDTO trainingDTO = mapper.convertValue(mTrainingDTOs.get(position), TrainingDTO.class);
holder.tvName.setText(trainingDTO.getMaidName());
holder.status.setVisibility(View.GONE);
Date date = new Date();
String currentDate = sdf.format(date);
for (TrainingDTO.TrainingDetailDto td : trainingDTO.getListTrain()) {
today = Utils.formatDate((long) td.getTrainingDate(),"dd/MM/yyyy");
break;
}
if(currentDate.equals(today)) {
holder.status.setVisibility(View.VISIBLE);
holder.status.setText("(M?i)");
}
holder.btnHistory.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(mContext,R.string.msg_no_candidate_history,Toast.LENGTH_SHORT).show();
}
});
holder.btnTest.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
buttonListener.showComment(trainingDTO);
}
});
}
@Override
public int getItemCount() {
int size ;
if(mTrainingDTOs != null && !mTrainingDTOs.isEmpty()) {
size = mTrainingDTOs.size();
}
else {
size = 0;
}
return size;
}
class RecyclerViewHolder extends RecyclerView.ViewHolder {
private TextView tvName;
private Button btnTest;
private Button btnHistory;
private TextView status;
public RecyclerViewHolder(View itemView) {
super(itemView);
tvName = (TextView) itemView.findViewById(R.id.txtName);
btnTest = (Button) itemView.findViewById(R.id.btnTest);
btnHistory = (Button) itemView.findViewById(R.id.btnHistory);
status = (TextView)itemView.findViewById(R.id.status);
}
}
public boolean removeItem(int position) {
if (mTrainingDTOs.size() >= position + 1) {
mTrainingDTOs.remove(position);
return true;
}
return false;
}
public interface AdapterInterface {
void showComment(TrainingDTO trainingDTO);
void showHistory(TrainingDTO trainingDTO);
}
}
package vn.jupviec.frontend.android.monitor.app.ui.candidate;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ClipDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RoundRectShape;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import retrofit.Callback;
import retrofit.RetrofitError;
import retrofit.client.Response;
import vn.jupviec.frontend.android.monitor.app.R;
import vn.jupviec.frontend.android.monitor.app.domain.ResultDTO;
import vn.jupviec.frontend.android.monitor.app.domain.candidate.TrainingDTO;
import vn.jupviec.frontend.android.monitor.app.domain.training.CandidateService;
import vn.jupviec.frontend.android.monitor.app.util.Constants;
import vn.jupviec.frontend.android.monitor.app.util.Utils;
/**
* Created by Windows 10 Gamer on 09/12/2016.
*/
public class FragmentTapNew extends Fragment implements RecyclerAdapter.AdapterInterface {
private static final String TAG = FragmentTapNew.class.getSimpleName();
Activity myContext = null;
private OnItemSelectedListener listener;
ShapeDrawable shapeDrawable;
@BindView(R.id.lvToday)
RecyclerView lvToday;
@BindView(R.id.textView)
TextView textView;
@BindView(R.id.pb_loading)
ProgressBar pbLoading;
private Unbinder unbinder;
private boolean loading = true;
int pastVisiblesItems, visibleItemCount, totalItemCount;
ArrayList<TrainingDTO> mTrainingDTO ;
RecyclerAdapter mTrainingDTOAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.activity_candidate_training, container, false);
unbinder = ButterKnife.bind(this, v);
initViews();
return v;
}
private void initViews() {
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity().getApplicationContext());
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
lvToday.setHasFixedSize(true);
lvToday.setNestedScrollingEnabled(false);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
today();
}
});
t.start();
}
private boolean isNetworkConnected() {
ConnectivityManager cm = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();
if (ni == null) {
Toast.makeText(getActivity(), R.string.err_cannot_establish_connection, Toast.LENGTH_SHORT).show();
return false;
} else
return true;
}
private void today() {
if(isNetworkConnected()){
String token = "a";
Integer date = 0;
setLoadingVisible(true);
CandidateService.getApiDummyClient(getContext()).getCandidate(
token,
date,
Constants.TRAINING,
Arrays.asList(Constants.TRAINING_DAY_NEW),
new Callback<ResultDTO>() {
@Override
public void success(ResultDTO resultDTO, Response response) {
setLoadingVisible(false);
mTrainingDTO = (ArrayList<TrainingDTO>) resultDTO.getData();
if (mTrainingDTO.size() == 0) {
if(textView!=null) {
textView.setVisibility(View.VISIBLE);
textView.setTextColor(Color.RED);
textView.setGravity(Gravity.CENTER | Gravity.BOTTOM);
}
} else {
if(textView!=null) {
textView.setVisibility(View.GONE);
}
if(null==mTrainingDTOAdapter) {
mTrainingDTOAdapter = new RecyclerAdapter(getActivity(), mTrainingDTO, FragmentTapNew.this);
lvToday.setAdapter(mTrainingDTOAdapter);
} else {
lvToday.setAdapter(mTrainingDTOAdapter);
mTrainingDTOAdapter.notifyDataSetChanged();
}
lvToday.invalidate();
}
}
@Override
public void failure(RetrofitError error) {
Log.e(TAG, "JV-ERROR: " + error.getMessage());
Log.e(TAG, "JV-ERROR: " + error.getSuccessType());
}
});
}
}
@Override
public void onResume() {
setLoadingVisible(false);
initViews();
lvToday.setAdapter(mTrainingDTOAdapter);
super.onResume();
}
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
private void setLoadingVisible(boolean visible) {
// pbLoading.getIndeterminateDrawable().setColorFilter(0xFFFF0000, android.graphics.PorterDuff.Mode.MULTIPLY);
if(pbLoading!=null) {
pbLoading.setVisibility(visible ? View.VISIBLE : View.GONE);
lvToday.setVisibility(visible ? View.GONE : View.VISIBLE);
}
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
if (activity instanceof OnItemSelectedListener) {
listener = (OnItemSelectedListener) activity;
} else {
throw new ClassCastException(activity.toString()
+ " ph?i implemenet MyListFragment.OnItemSelectedListener");
}
}
@Override
public void onDetach() {
super.onDetach();
listener = null;
}
@Override
public void showComment(TrainingDTO trainingDTO) {
Intent intent = new Intent(getContext(), CommentActivity.class);
intent.putExtra(Constants.ARG_NAME_DETAIL, trainingDTO);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getContext().startActivity(intent);
}
@Override
public void showHistory(TrainingDTO trainingDTO) {
Intent intent = new Intent(getContext(), HistoryActivity.class);
intent.putExtra(Constants.ARG_CANDIDATE_HISTORY_DETAIL, trainingDTO);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getContext().startActivity(intent);
}
public interface OnItemSelectedListener {
void showComment(TrainingDTO trainingDTO);
void showHistory(TrainingDTO trainingDTO);
}
}[/code]
Android detect which layer is clicked on VectorDrawable
I have an SVG file which looks like
[img]
https://i.stack.imgur.com/7WGBz.png[/img]
When converted through Android Vector Studio, the xml looks like
[code]<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="580dp"
android:height="400dp"
android:viewportWidth="580.0"
android:viewportHeight="400.0">
<path
android:name="someName"
android:pathData="M0,30a30,30 0,1 0,60 0a30,30 0,1 0,-60 0z"
android:strokeColor="#000"
android:fillColor="#fff"
android:strokeWidth="1.5"/>
<path
android:name="someOtherName"
android:pathData="M60,100a40,40 0,1 0,80 0a40,40 0,1 0,-80 0z"
android:strokeColor="#000"
android:fillColor="#000"
android:strokeWidth="1.5"/>
</vector>[/code]
When any of the circles or paths of this vector are clicked, I want to know which layer or circle has been clicked. I could not find any method which will let me know that there are two layers or which layer has been clicked.
From this answer it looks like getting inner elements of a VectorDrawable is not possible. So is there any way I can get to know exactly which circle/layer is clicked?
Play .flac file using MediaPlayer class in android
I am using the following code successfully on Lollipop. But it is not working on Marshmellow.
[code]for (int i = 0; i < all_track_size; i++) {
SongDetailModel model = new SongDetailModel();
String path = SharedPreferenceUtil.getString("all_track_path" + i, "");
model.setSong_path(path);
array_all_track.add(model);
}
if (array_all_track.get(pos).getSong_path().endsWith(".mp3") ||
array_all_track.get(pos).getSong_path().endsWith(".flac") ||
array_all_track.get(pos).getSong_path().endsWith(".wav")) {
filePath = array_all_track.get(pos).getSong_path();
Log.d(TAG, " : SELECTED SONG : " + filePath);
}[/code]
Search filter Expandablelistview Header Items
I'm about to create an expandableListview with implemented Searchview. My SearchView can filter child items and only the child items. I want to create a search filter that can also filter the header items in expandablelistview. how can I do that?
here's my code for the expandablelistview with search filter. here is my Adapter:
[code]package com.teamamazing.search;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Locale;
import android.content.Context;
import android.graphics.Typeface;
import android.media.MediaPlayer;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;
import android.view.View.OnClickListener;
public class Accomodation_Adapter extends BaseExpandableListAdapter {
private Context context;
private ArrayList<AccomodationHeaderRow> headerRows;
private ArrayList<AccomodationHeaderRow> originalList;
public Accomodation_Adapter(Context context, ArrayList<AccomodationHeaderRow> headerRows) {
this.context = context;
this.headerRows = new ArrayList<AccomodationHeaderRow>();
this.headerRows.addAll(headerRows);
this.originalList = new ArrayList<AccomodationHeaderRow>();
this.originalList.addAll(headerRows);
}
@Override
public Object getChild(int groupPosition, int childPosition) {
ArrayList<AccomodationChildRow> childRows = headerRows.get(groupPosition).getChildRow();
return childRows.get(childPosition);
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
View view, ViewGroup parent) {
AccomodationChildRow child = (AccomodationChildRow) getChild(groupPosition, childPosition);
if (view == null) {
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = layoutInflater.inflate(R.layout.activity_accomodation_child_row, null);
}
TextView name = (TextView) view.findViewById(R.id.child_items);;
name.setText(child.getName().trim());
return view;
}
@Override
public int getChildrenCount(int groupPosition) {
ArrayList<AccomodationChildRow> childRows = headerRows.get(groupPosition).getChildRow();
return childRows.size();
}
@Override
public Object getGroup(int groupPosition) {
return headerRows.get(groupPosition);
}
@Override
public int getGroupCount() {
return headerRows.size();
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View view,
ViewGroup parent) {
AccomodationHeaderRow accomodationHeaderRow = (AccomodationHeaderRow) getGroup(groupPosition);
if (view == null) {
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = layoutInflater.inflate(R.layout.activity_accomodation_header_row, null);
}
TextView heading = (TextView) view.findViewById(R.id.accomodation_headings);
heading.setText(accomodationHeaderRow.getName().trim());
// If group is expanded then change the text into bold and change the
// icon
if (isExpanded) {
heading.setTypeface(null, Typeface.BOLD);
heading.setCompoundDrawablesWithIntrinsicBounds(0, 0,
0, 0);
} else {
// If group is not expanded then change the text back into normal
// and change the icon
heading.setTypeface(null, Typeface.NORMAL);
heading.setCompoundDrawablesWithIntrinsicBounds(0, 0,
0, 0);
}
return view;
}
@Override
public boolean hasStableIds() {
return true;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
public void filterData(String query){
query = query.toLowerCase();
Log.v("Accomodation_Adapter", String.valueOf(headerRows.size()));
headerRows.clear();
if(query.isEmpty()){
headerRows.addAll(originalList);
}
else {
for(AccomodationHeaderRow accomodationHeaderRow: originalList){
ArrayList<AccomodationChildRow> accomodationChildRows = accomodationHeaderRow.getChildRow();
ArrayList<AccomodationChildRow> newList = new ArrayList<AccomodationChildRow>();
for(AccomodationChildRow accomodationChildRow: accomodationChildRows){
if(accomodationChildRow.getName().toLowerCase().contains(query)){
newList.add(accomodationChildRow);
}
}
if(newList.size() > 0){
AccomodationHeaderRow nAccomodationHeaderRows =
new AccomodationHeaderRow(accomodationHeaderRow.getName(),newList);
headerRows.add(nAccomodationHeaderRows);
}
}
}
Log.v("Accomodation_Adapter", String.valueOf(headerRows.size()));
notifyDataSetChanged();
}
}[/code]
Google Play Console Developer Monitoring errors
Good afternoon. 1) A question about Google Play Console Developer. In the error reports, there is a "Crash Link" field, which contains a link to Crash Link. Is it possible to download in a report not a link, but a stack trace? If not, is it possible to provide access to the stack trace to the user without giving it access to the Google Play Developer Console?
2) Is it possible in Google Play Developer Console reports to update statistics every 10 minutes for errors? The task is to organize monitoring the operational monitoring of errors. If someone had to do this, tell me please options.
3) Is it possible to pull out the stack trace specified in the "Crash Link" field of the report using the gsutil utility?
Move Layout Up when Soft Keyboard appears
I have login page with Email Id ,Password & LOGIN button. Right now when any one of the Edit Text gain focus then system keyboard hides my Login button. I want to push my layout above when keyboard appears keeping LOGIN button above of keyboard.
P.S I've tried all solution like adjust Pan|adjust Resize, adjust Pan,adjust Resize"
in manifest as well as in Java code
But none of thing worked for me.
[code] <ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/newl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="145dp"
android:drawablePadding="8dp"
android:layout_gravity="center_horizontal"
android:src="@drawable/ic_clock"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Timetracker"
android:fontFamily="LucidaGrande"
android:textSize="30dp"
android:textAlignment="center"
android:layout_marginTop="15dp"
android:layout_gravity="center_horizontal"
android:id="@+id/tt"
android:textColor="#FFFFFF"
android:layout_centerHorizontal="true"
/>
<LinearLayout
android:layout_below="@+id/tt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="30dp"
>
<ImageView
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ico_user"
android:layout_centerVertical="true"
/>
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#FFFFFF"
android:drawablePadding="12dp"
android:textSize="15dp"
android:layout_marginRight="45dp"
android:fontFamily="Sans Serif"
android:layout_centerInParent="true"
android:textColor="#FFFFFF"
android:background="@android:color/transparent"
android:id="@+id/spinner2"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_arrow_drop_down_black_24dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>
</RelativeLayout>
<View
android:layout_below="@+id/rel"
android:layout_width="match_parent"
android:background="#FFF"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_height="1dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_ico_lock"
android:drawablePadding="12dp"
android:layout_marginTop="30dp"
android:layout_below="@+id/rel"
android:layout_marginRight="7dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="12dp"
android:hint="Password"
android:background="@android:color/transparent"
android:textColorHint="#FFFFFF"
android:textSize="20dp"
android:textColor="#FFFFFF"
android:id="@+id/editText"
android:inputType="textPassword"
android:backgroundTint="#FFFFFF"
/>
<View
android:layout_below="@+id/editText"
android:layout_width="match_parent"
android:background="#FFF"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_height="1dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_below="@+id/editText"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:background="#FFFFFF"
android:text="LOG IN"
android:id="@+id/log"
android:textColor="#D04045"/>
</LinearLayout>
</LinearLayout>
</ScrollView>[/code]
Appium throws error Failed to start session , Device not listed.
I have written code for parallel execution to start appium driver based on port and device ids given from Testng . Selenium hub is starting and registering code but the code that instantiates the driver after setting desired capabilities give null driver with error Failed to start the appium session , device id <> not listed.