Hi I'm building a singleton instance for AFNetworking 3.x

my ApiClient.h

@interface ApiClient : AFHTTPSessionManager
+ (ApiClient *)sharedInstance;

-(instancetype)initWithBaseURL:(NSURL *)url sessionConfiguration:(NSURLSessionConfiguration *)configuration;

my ApiClient.m

+ (ApiClient *)sharedInstance {
    static ApiClient *sharedInstance = nil;
    static dispatch_once_t oncePredicate;
    dispatch_once(&oncePredicate, ^{
        NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
        sharedInstance = [[self alloc] initWithBaseURL:[NSURL URLWithString:SINGPOST_BASE_URL] sessionConfiguration:sessionConfiguration];

    });
return sharedInstance;
}

The problem is i cannot initiate an singleton instance

-(instancetype)initWithBaseURL:(NSURL *)url sessionConfiguration:(NSURLSessionConfiguration *)configuration {

    [super initWithBaseURL:url sessionConfiguration:url];
    return self;
}

I got 2 error as bellow pic enter image description here

Anyone know. What wrong with my singleton design? Any help is much appreciate! Thanks

PS: i have tried initwithURL only is not working without the session configuration

I have an iOS app that I want to be able to send and receive instances of its own file type. The flow would be:

  • User 1 selects a Share function in the app. This generates a file of my type (say, file.myextension) and shares it using a UIActivityViewController. They send it somehow to User 2 (AirDrop, email, whatever).
  • User 2 receives the file and opens it. The system offers to open it using my app.

I've got the first part working. I can generate file.myExtension and give the UIActivityViewController a file URL to it. This shows up correctly in AirDrop on user 1's device, and I can transfer the file using AirDrop or email or whatever. But the receiving device refuses to show my app as an option to open the file.

I have tried:

  • Declaring Exported and Imported UTIs and a Document Type as per this Apple Q&A. I've triple-checked that all the IDs are the same and all the plist keys are spelled correctly.
  • I've tried both an Exported and Imported UTI alone (with a Document Type). This article seems to say that the Imported one is what I want if I want to open a file type. This SO answer says that registering a type I own and want to open means I just want Exported. Neither on its own worked.

My question: what do I have to do to be able to open a file extension that I own on iOS? Do I define both Imported and Exported UTIs, along with a Document Type? Just one of exported or imported? Any unexpected required attributes?

I have issue when I try to push view controller in willTransitionToPresentationStyle:. The view was blinking for a split second before it fully expanded. It might be a small glitch or bug since iOS 10 and Xcode 8 are still in beta. But when I manually requested to change presentation style to MSMessagesAppPresentationStyleExpanded by calling requestPresentationStyle: after I push view controller, it went to expand mode more smoothly. Does anyone have similar issue?

I want to know how to write a privacy policy that I see in all ios app, knowing that my app contains photos that users take, and their number to register the application.

I'm picturing a graph paper like interface, as you click on any given box within the graph it gets colored in. I'm doing this to draw rough shape outlines.

My question is what is the best approach to do this? Draw the lines for the graph and track where the touches occur and color accordingly? Make some array of buttons? Maybe using spritekit?

I'm not too worried about efficiency as I'm not doing anything too complicated but I'm just trying to find some common design ideas behind it.

Im currently using Google Drive REST API in order to create folder/files in my Drive.

However i would like to know how could i use the rest api to display an image from Drive in my app ? Is that even possible ?

I created an app that stream video from server, on server side (PHP) I use this code to pass the MySQL query result via JSON array contain a result of video title size and views.

 $query="select * from video_tble ;";
 $result=mysqli_query($con,$query);
 $row=mysqli_fetch_all($result,MYSQLI_ASSOC);
 $respones_result=array();
 $response_result=$row;
 echo json_encode(array("server_response_result"=>$response_result));

But I don't know how to retrieve a multidimensional array using JSON object.

 JSONObject jsonObject1=new JSONObject(json);
 JSONArray jsonArray1=jsonObject1.getJSONArray("server_response_result");
 JSONObject JO1=jsonArray1.getJSONObject(0);
 String [] title =...?

If it was a name value pair then I follow this strategy:

 String title1=JO1.getString("title");

But I don't know what to do on multidimensional array.

is it possible to get sharedprocedure for parameter cause i would like to have

parameters.setPreviewFrameRate(20);
parameters.setPreviewSize(352, 288);
camera.setDisplayOrientation(90);

as a setting so the user can change thoose values

i tryed with this but it can't be initalized

    String PreviewFPS;
    String Previewsize;
    String Displayor;

    PreviewFPS = setingPreferences.getString("previewfps", "");
    Previewsize = setingPreferences.getString("screensize", "");
    Displayor = setingPreferences.getString("orientation", "");

    parameters.setPreviewFrameRate(PreviewFPS);
    parameters.setPreviewSize(Previewsize);
    camera.setDisplayOrientation(Displayor);

After i made some changes in an AsynTask i get this error when running the app: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.popularmovies/com.example.android.popularmovies.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class fragment

This is the activity_main.xml file.

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/fragment"
      android:name="com.example.android.popularmovies.MainActivityFragment"
      tools:layout="@layout/fragment_main"
      android:layout_width="match_parent"
      android:layout_height="match_parent"/>

And this is the MainActivity.java file:

package com.example.android.popularmovies;


import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;



public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}
}

Thanks for any help you can provide! ;)

I have problem with use onTouchEvent in class which edit ImageView in mainActivity

.XML file I work with this ImageView

Here Are class which write/rewrite on imageview

public class ItemsInPacagesImageView  {

int vsk,vsk2, srk,vskconst,sizetext;
Canvas c;
Paint paint;
ImageView imageview;
Typeface font;
myTrip prvy;
String nazovtripu;
Context context;




public ItemsInPacagesImageView(ImageView img,Context context,String nazovtripu,int pacage) {
    //super(context);

    this.imageview=img;
    this.nazovtripu=nazovtripu;
    this.context=context;

    prvy= DeSerializuj(nazovtripu);
  //  Serializuj(prvy,nazovtripu);



    vsk = context.getResources().getDimensionPixelSize(R.dimen.vyskalist);
    if (prvy.getPocItem()!=pacage){
    vsk= vsk*prvy.getPocItem();}
    vsk2 = context.getResources().getDimensionPixelSize(R.dimen.vyskatext);
    srk =  context.getResources().getDimensionPixelSize(R.dimen.sirkafulllist);
    vskconst =  context.getResources().getDimensionPixelSize(R.dimen.vyskalist2);
    sizetext = context.getResources().getDimensionPixelSize(R.dimen.sizetext);
    font = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Light.ttf");
    img.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, vsk));


    Bitmap b = Bitmap.createBitmap(srk,
            vsk, Bitmap.Config.ARGB_8888);
    c = new Canvas(b);
    c.drawColor(Color.WHITE);
    imageview.setImageBitmap(b);


    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.FILL);



    for (int i=1;i<50;i++) {
        if (prvy.citajItem(0,i)!=null) {
            int pom=vsk2 + (i-1)*vskconst;
            DalsiPrvok(paint, c, prvy.citajItem(0,i), 450, pom, sizetext,font);
           // prvy.setPocItem(prvy.getPocItem()+1);
        } else {break;}

    }
    imageview.invalidate();

}

protected void DalsiPrvok(Paint paint, Canvas canvas, String text, float xx, float yy, double aa, Typeface font) {

     paint.setColor(Color.BLACK);
    paint.setTypeface(font);
    float textSize = paint.getTextSize();
    paint.setTextSize((float) aa);
    canvas.drawText(text, xx, yy, paint);
    paint.setTextSize(textSize);

}


public boolean onTouchEvent(MotionEvent event) {
    int e = event.getAction(); // vrati parametre udalosti
    if (e == MotionEvent.ACTION_DOWN) {

        paint.setColor(Color.YELLOW);
        c.drawRect(0,0,srk,vsk,paint);
        imageview.invalidate();


    }
    //  HighScoreZ();


    return false;

}


public myTrip DeSerializuj( String odkial) {
    odkial=odkial+".dat";
    myTrip   prvy = null;
    try {
        File file = new File(context.getFilesDir(), odkial);
        FileInputStream fi = new FileInputStream(file);
        ObjectInputStream oi = new ObjectInputStream(fi);
        prvy = (myTrip) oi.readObject();
        oi.close();
        fi.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return prvy;
}

public void Serializuj( myTrip serTrip,String kam){
    kam=kam + ".dat";
    try {
        File file = new File(context.getFilesDir(), kam);
        FileOutputStream fo = new FileOutputStream(file);
        ObjectOutputStream ou = new ObjectOutputStream(fo);
        ou.writeObject(serTrip);
        ou.close();
        fo.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

I have onTouchEvent with thin letter because I can't use onTouchEvent if program run. I tried extends ImageView or View or my MainActivity. If I extends ↑ onTouchEvent was good letters but I did not get code on onTouchEvent.

All code run good, thise class write on Imageview on Mainactivity all. But I need Implement into onTouchEvent...

I call thise class on MainActivity ..

ItemsInPacagesImageView itemimg= new ItemsInPacagesImageView(imglist1,tentocontext,druhy.getNazovTripu(),0);

Please If have some ideas ako resolve my problem Help me.

**Please help me use in ItemsInPacagesImageView ontouchevent or gesturedetector Thanks **

Thanks

I am working on an android application. Meanwhile i got chance to work on another application similar to first. I have just copy my previous code to new
project.

1) src files

2) res files

3) manifest

4) build.gradle

and then I change packagename from com.abc to com.xyz in

1) build.gradle

2) Manifest

3) src files

Now i have installed first app in my device and try to install second one but it does not work. Same error also occur when i have installed second app and try to install first one.

Here is the error

enter image description here

Is there any other thing i need to change apart from packagename??

I have create an image button like

ImageButton ib = new ImageButton(this); ib.setBackgroundResource(R.drawable.ic_launcher); ib.setOnTouchListener(new View.OnTouchListener() { private int initialX; private int initialY; private float initialTouchX; private float initialTouchY; @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: initialX = params.x; initialY = params.y; initialTouchX = event.getRawX(); initialTouchY = event.getRawY(); return true; case MotionEvent.ACTION_UP: return true; case MotionEvent.ACTION_MOVE: params.x = initialX + (int) (event.getRawX() - initialTouchX); params.y = initialY + (int) (event.getRawY() - initialTouchY); windowManager.updateViewLayout(chatHead, params); return true; } return false; } });.

I want to use onclick event in the code.

I am trying to find the current location of user when clicking on a button( I am also using PermissionDispatcher library ). When I am pressing the button nothing happens (not in Android Moniter) and also a Toast should appear but it is not, Here is my code:

mButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View arg0) {
               getLocation();
            }
        });

And then I am using the function getLocation() to check if location services are on, airplane mode is off, and finally display location using getLastKnownLocation() (but if it is null then using requestLocationUpdates()), here is the function and some other functions to find location:

@NeedsPermission({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION})
    protected void getLocation() {
        if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
            MainActivityPermissionsDispatcher.getLocationWithCheck(MainActivity.this);
        else {
            if (isLocationEnabled(MainActivity.this) && !isAirplaneModeOn(MainActivity.this)) {
                locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
                criteria = new Criteria();
                bestProvider = String.valueOf(locationManager.getBestProvider(criteria, true));
                Location location = locationManager.getLastKnownLocation(bestProvider);
                if (location != null) {
                    Log.d("Location", "GPS is on");
                    latitude = location.getLatitude();
                    longitude = location.getLongitude();
                    Toast.makeText(MainActivity.this, "latitude:" + latitude + " longitude:" + longitude, Toast.LENGTH_SHORT).show();
                    Log.d("Location", latitude + " " + longitude);
                } else {
                    locationManager.requestLocationUpdates(bestProvider, 1000, 0, this);
                }
            } else {
                if (isAirplaneModeOn(MainActivity.this)) {
                    AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);
                    dialog.setMessage("Can't find location with Airplane mode on, would you like to turn it off now?");
                    dialog.setPositiveButton(R.string.button_allow, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface paramDialogInterface, int paramInt) {
                            Intent myIntent = new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS);
                            MainActivity.this.startActivity(myIntent);
                        }
                    });
                    dialog.setNegativeButton(R.string.button_deny, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface paramDialogInterface, int paramInt) {
                        }
                    });
                    dialog.show();
                } else {
                    AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);
                    dialog.setMessage("Location services are off, would you like to turn them on now?");
                    dialog.setPositiveButton(R.string.button_allow, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface paramDialogInterface, int paramInt) {
                            Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                            MainActivity.this.startActivity(myIntent);
                        }
                    });
                    dialog.setNegativeButton(R.string.button_deny, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface paramDialogInterface, int paramInt) {
                        }
                    });
                    dialog.show();
                }
            }
        }
    }


  @Override
    @NeedsPermission({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION})
    protected void onPause() {
        super.onPause();
        if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED)
            locationManager.removeUpdates(this);
    }

    @Override
    @NeedsPermission({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION})
    public void onLocationChanged(Location location) {
        if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
            MainActivityPermissionsDispatcher.onLocationChangedWithCheck(MainActivity.this, location);
        else {
            locationManager.removeUpdates(this);
            latitude = location.getLatitude();
            longitude = location.getLongitude();
            Toast.makeText(MainActivity.this, "latitude:" + latitude + " longitude:" + longitude, Toast.LENGTH_SHORT).show();
            Log.d("Location", latitude + " " + longitude);
        }
    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {

    }

    @Override
    public void onProviderEnabled(String provider) {

    }

    @Override
    public void onProviderDisabled(String provider) {

    }

I am checking if Airplane mode is on and location services are on using this code:

@SuppressWarnings("deprecation")
    public static boolean isAirplaneModeOn(Context context) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
            return Settings.System.getInt(context.getContentResolver(),
                    Settings.System.AIRPLANE_MODE_ON, 0) != 0;
        } else {
            return Settings.Global.getInt(context.getContentResolver(),
                    Settings.Global.AIRPLANE_MODE_ON, 0) != 0;
        }
    }

public boolean isLocationEnabled(final Context context) {
        boolean gps_enabled = false;
        boolean network_enabled = false;
        locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        try {
            gps_enabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        } catch (Exception ex) {
            ex.printStackTrace();
            removeItem();
            myToast = Toast.makeText(context, "Error with location services", Toast.LENGTH_LONG);
            myToast.show();
        }
        try {
            network_enabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
        } catch (Exception ex) {
            ex.printStackTrace();
            removeItem();
            myToast = Toast.makeText(context, "Error with location services", Toast.LENGTH_LONG);
            myToast.show();
        }
        return !(!gps_enabled && !network_enabled);
    }

When I run the code and press the button, I see the status bar location icon (meaning it is searching or something) but I can't see the latitude and longitude on screen ( Toast ) or in Android Monitor. is there anything wrong with this code?

Notice: removeitem() function is used to remove existing Toast on screen if there is. And also, sorry for my English :) Thanks!

I have a countdown timer, that starts when user Logged In. After 10 Minutes it Logged Out User.

It works fine, but if user stops application, then timer stops working, and user is logged in forever.

So i put this whole thing in a service, so that it will work, either user stops application or not.

The problem is that, this has stopped working after adding Countdown Timer in Service. I have checked it on debug mode, and its not going into the service- onCreate method.

This is how i am calling the service.

 startService(new Intent(this,LogoutService.class));

My Service Class, calls the CountdownTimer Class, first this code was written in the place where i write startService() now

public class LogoutService extends Service {

    @Override
    public void onCreate() {
        UserLoggedInTimer logoutTimer= new UserLoggedInTimer(60000,1000);
        logoutTimer.setContext(getApplicationContext());
        logoutTimer.start();
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

The countdown timer works perfectly fine when i call it without service, but here its just not getting into the service, i hope it will work fine, once my application starts the above service successfully.

This question already has an answer here:

I have a JSON file which contains a list of numbers. I'm accessing this using the code

getAirlineProfile().getRestrictedFlightNumbers();

and then I have an input text field where user can enter a text. I'm comparing this text to the list of numbers in the JSON file. I can't compare a text to an int so I have converted the text to int. But now when the user tries to enter a number, I get a Null Pointer crash.

private EditText flightNumber;

 @Override
        public void afterTextChanged(Editable s) {
            if(!flightNumber.getText().toString().isEmpty()) {
                int flightNo = Integer.parseInt(flightNumber.getText().toString());
                if (getAirlineProfile().getRestrictedFlightNumbers().contains(flightNo)) {
                    saveButton.setEnabled(false);
                    Toast.makeText(getApplicationContext(), getText(R.string.flight_warning), Toast.LENGTH_LONG)
                            .show();
                } else {
                    saveButton.setEnabled(true);
                    saveButton.setVisibility(View.VISIBLE);
                }
            }
            verifyFlightKeyData();
            checkMandatoryFields();

        }

LOG of where the crash happens

 java.lang.NullPointerException
         at com.miairline.chooseflight.FlightDataActivity$1.afterTextChanged(FlightDataActivity.java:113)

This is the line which is causing the crash:

 if (getAirlineProfile().getRestrictedFlightNumbers().contains(flightNo)) ;

Is it possible to have a tablayout inside a tab of another tablayout? I have created the following image for a better explanation. The slide movement desired is as it is described in the image.

enter image description here

My main activity

Xml

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabMode="fixed"
            app:tabGravity="fill"/>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"  />

</android.support.design.widget.CoordinatorLayout>

Code

public class MainActivity extends AppCompatActivity {

    private TabLayout tabLayout;

    private final static int[] tabIcons = {
            R.drawable.ic_tab_1,
            R.drawable.ic_tab_2,
            R.drawable.ic_tab_3,
            R.drawable.ic_tab_4
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
        setupViewPager(viewPager);

        tabLayout = (TabLayout) findViewById(R.id.tabs);
        tabLayout.setupWithViewPager(viewPager);
        setupTabIcons();
    }

    private void setupTabIcons() {
        tabLayout.getTabAt(0).setIcon(tabIcons[0]);
        tabLayout.getTabAt(1).setIcon(tabIcons[1]);
        tabLayout.getTabAt(2).setIcon(tabIcons[2]);
        tabLayout.getTabAt(3).setIcon(tabIcons[3]);
    }

    private void setupViewPager(ViewPager viewPager) {
        ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
        adapter.addFrag(new Fragment1());
        adapter.addFrag(new Fragment2());
        adapter.addFrag(new Fragment3());
        adapter.addFrag(new Fragment4());
        viewPager.setAdapter(adapter);
    }

    class ViewPagerAdapter extends FragmentPagerAdapter {

        private final List<Fragment> mFragmentList = new ArrayList<>();

        ViewPagerAdapter(FragmentManager manager) {
            super(manager);
        }

        @Override
        public Fragment getItem(int position) {
            return mFragmentList.get(position);
        }

        @Override
        public int getCount() {
            return mFragmentList.size();
        }

        void addFrag(Fragment fragment) {
            mFragmentList.add(fragment);
        }
    }
}

Fragments

Xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:background="@android:color/holo_blue_light"
    android:id="@+id/fragment_1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="myContext">

    <TextView
        android:text="It is just a text."
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />

</RelativeLayout>

Code

public class Fragment1 extends Fragment {

    public Fragment1() { }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment.
        return inflater.inflate(R.layout.fragment_1, container, false);
    }
}

How should Fragment2_A and Fragment2_B XML and Java code be?

I have a EditText view :

  <EditText
            android:id="@+id/vorgabezeit"
            android:layout_width="50dp"
            android:layout_height="wrap_content"
            android:background="#0277BD"
            android:imeOptions="actionDone"
            android:inputType="numberDecimal"
            android:maxLength="5"
            android:textAlignment="textEnd"
            android:textColor="#ffffff"
            android:textCursorDrawable="@null"
            android:textStyle="bold"
            />

The value entered in this EditText I would like to use it in an math operation. Before I had fixed values :

public void submitOrder(View view) {
                displayPrice((procente / myEditNum) * mitarbeiter);}

where variables were defined as :

    int procente = 120;
    int mitarbeiter = 1;

now, I searched for hours on the web how to take that value entered in EditText and use id further, and this is as close as I got :

    public class MainActivity extends AppCompatActivity {
    int procente = 120;
    int mitarbeiter = 1;
    EditText myEdit = (EditText) findViewById(R.id.vorgabezeit);
    String myEditValue = myEdit.getText().toString();
    double myEditNum = Double.parseDouble(myEditValue);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void submitOrder(View view) {
                displayPrice((procente / myEditNum) * mitarbeiter);}

The app crashes from the start ... Please don't kick my b***a too hard, it's my first week in XML and Java. Thank you for your patience anad help.

Best regards, Robert

when i scroll on Recyclerview my app was force close but i don't know what does i need to do

please help me to fix my problem

here is screenshots: the main page of app- when i scroll the reyclerview of main page my app was force close!

this is my adapter:

public class RecyclerViewDataAdapter extends RecyclerView.Adapter<RecyclerViewDataAdapter.ItemRowHolder> {

private ArrayList<SectionDataModel> dataList;
private Context mContext;
private ImageView bg;
private boolean isLang;



public RecyclerViewDataAdapter(Context context, ArrayList<SectionDataModel> dataList) {
    this.dataList = dataList;
    this.mContext = context;
}

@Override
public ItemRowHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
    View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.list_item, null);
    ItemRowHolder mh = new ItemRowHolder(v);
    return mh;
}

@Override
public void onBindViewHolder(final ItemRowHolder itemRowHolder, int i) {

    final String sectionName = dataList.get(i).getHeaderTitle();
    final String sectionSub = dataList.get(i).getHeaderSubTitle();
    final int sectionhesder = dataList.get(i).getHeader();

    final int bgd = dataList.get(i).getPhoto();
    final int bgg = dataList.get(i).getBg();
    ArrayList singleSectionItems = dataList.get(i).getAllItemsInSection();

    itemRowHolder.itemSubTitle.setText(sectionSub);
    itemRowHolder.itemTitle.setText(sectionName);
    itemRowHolder.bg.setImageResource(bgd);

    itemRowHolder.bg.setBackgroundResource(bgg);
    if (isLang = Locale.getDefault().getLanguage().equals("fa")) {
        itemRowHolder.bg.setScaleType(ImageView.ScaleType.FIT_START);

    } else {
        itemRowHolder.bg.setScaleType(ImageView.ScaleType.FIT_END);
    }


    SectionListDataAdapter itemListDataAdapter = new SectionListDataAdapter(mContext, singleSectionItems);

    itemRowHolder.recycler_view_list.setHasFixedSize(true);
    itemRowHolder.recycler_view_list.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
    itemRowHolder.recycler_view_list.setAdapter(itemListDataAdapter);

    itemRowHolder.recycler_view_list.setNestedScrollingEnabled(false);


   /*  itemRowHolder.recycler_view_list.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            int action = event.getAction();
            switch (action) {
                case MotionEvent.ACTION_DOWN:
                    // Disallow ScrollView to intercept touch events.
                    v.getParent().requestDisallowInterceptTouchEvent(true);
                    break;
                case MotionEvent.ACTION_UP:
                    //Allow ScrollView to intercept touch events once again.
                    v.getParent().requestDisallowInterceptTouchEvent(false);
                    break;
            }
            // Handle RecyclerView touch events.
            v.onTouchEvent(event);
            return true;
        }
    });*/

    itemRowHolder.btnMore.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(mContext, TopicActivity.class);
            intent.putExtra("topicn",sectionName.toString());
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            mContext.startActivity(intent);




        }
    });




   /* Glide.with(mContext)
            .load(feedItem.getImageURL())
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .centerCrop()
            .error(R.drawable.bg)
            .into(feedListRowHolder.thumbView);*/
}

@Override
public int getItemCount() {
    return (null != dataList ? dataList.size() : 0);
}

public class ItemRowHolder extends RecyclerView.ViewHolder {


    protected RelativeLayout itemHeader;
    protected TextView itemTitle;
    protected TextView itemSubTitle;
    protected RecyclerView recycler_view_list;

    protected Button btnMore;

    public ImageView bg;


    public ItemRowHolder(View view) {
        super(view);

        this.itemTitle = (TextView) view.findViewById(R.id.itemTitle);
        this.itemSubTitle = (TextView) view.findViewById(R.id.itemsub);
        this.itemHeader = (RelativeLayout) view.findViewById(R.id.header);
        this.recycler_view_list = (RecyclerView) view.findViewById(R.id.recycler_view_list);
        this.btnMore= (Button) view.findViewById(R.id.btnMore);


        this.bg= (ImageView) view.findViewById(R.id.bg);
  }}}

Live demo: http://3cc79966.ngrok.io/p/46MTXhRZx

Note: problem is only in iOS and Android browsers (not in simulator)

If you scroll within the modal, everything works fine. However, when you tap outside the modal and then try to scroll again, it doesn't work.

If you're lucky enough and scroll at the sides or around the modal, you can actually see that it's scrolling the view behind it.

So my guess is that when you tap outside the scrollable area, or scroll out the scrollable area (if you drag starting from the 'sluiten' bar for instance), the area behind it takes over control.

During that period, the scrollview itself is blocked (doesn't work) because the view behind it has control. At the moment the view behind it is done scrolling, it seems to return control to the modal again.

I've tried almost every suggestion that I could find, and none seem to work.

CSS of the View that renders is fairly simple:

{ position: 'fixed', top: 0, bottom: 0, left: 0, right: 0,
  alignItems: 'center', justifyContent: 'center',
  pointerEvents: 'none' }

That view contains another View with:

maxSize: {
  width: width * 0.9,
  maxWidth: 460,
  maxHeight: height * 0.7,
}

And that View contains a ScrollView component which has this CSS:

scrollview: { overflow: 'auto', display: 'initial', flexShrink: 'initial' },

Any help/hints is much appreciated!

First of all, I worked on this all day but could not get anything done. I have a RecyclerView with an adapter that uses RecyclerView's SortedList. I tried implementing TouchHelper with the callback class:

public class TimerListTouchHelperCallback extends ItemTouchHelper.SimpleCallback {

    private OnItemChangeListener onItemChangeListener;

    public TimerListTouchHelperCallback(OnItemChangeListener listener, int dragDirs, int swipeDirs) {
        super(dragDirs, swipeDirs);

        this.onItemChangeListener = listener;

    }

    @Override
    public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
        TimerHolder holder = (TimerHolder) viewHolder;

        int holderState = holder.getState();

        if (holderState == TimerHolder.TIMER_PENDING_DELETE) return 0;
        else return super.getSwipeDirs(recyclerView, viewHolder);
    }

    @Override
    public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
        return false;
    }




    @Override
    public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
        TimerHolder holder = (TimerHolder) viewHolder;

        int position = holder.getAdapterPosition();
        // ViewHolder's state is changed that should handle the layout change.
        holder.setState(TimerHolder.TIMER_PENDING_DELETE); 

        if (onItemChangeListener != null) onItemChangeListener.onItemSwiped(position);
    }


    protected interface OnItemChangeListener{
        void onItemSwiped(int position);
    }
}

Here is the initialization of the TouchHelper

timerAdapter = new TimerAdapter(this, timerList);
    timerListView.setAdapter(timerAdapter);

TimerListTouchHelperCallback touchHelperCallback = new TimerListTouchHelperCallback(
        timerAdapter,
        ItemTouchHelper.LEFT,
        ItemTouchHelper.LEFT);

ItemTouchHelper swipeToDismissTouchHelper = new ItemTouchHelper(touchHelperCallback);

swipeToDismissTouchHelper.attachToRecyclerView(timerListView);

My adapter implements the interface OnItemChangeListener

@Override
public void onItemSwiped(int position) {
    notifyItemChanged(position);
    removalPendingTimers.add(timerList.get(position));
}

My ViewHolder reads the state and when the state is TimerHolder.TIMER_PENDING_DELETE it hides the rest of the view and shows the interface with an undo button. But this is not happening until I scroll the view out and scroll it back again. Any suggestions what I am missing?

Problem case

Links

Adapter class ViewHolder class

We are actually releasing a version to the test system as a common release in GitFlow. We create a release branch, clean things up and merge it into master and development.

The thing is that if I have to do a late Hotfix (for whatever reason) for the live system, I can't use the common process to just create a branch from master because the master is one release version ahead.

Is this really a common practice? I mean such late hotfixes are of course seldom but ... If no, how should we handle it? Would it be a good idea to create a second master branch for test system releases?